mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 06:54:13 +08:00
feat: add repository_dispatch event support
- Add new progress MCP server for reporting task status via API
- Support repository_dispatch events with task description and progress endpoint
- Introduce isDispatch flag to unify dispatch event handling
- Make GitHub data optional for dispatch events without issues/PRs
- Update prompt generation with dispatch-specific instructions
Enables triggering Claude via repository_dispatch with:
{
"event_type": "claude_task",
"client_payload": {
"description": "Task description",
"progress_endpoint": "https://api.example.com/progress"
}
}
This commit is contained in:
@@ -39,13 +39,13 @@ describe("Mode Registry", () => {
|
||||
|
||||
test("getMode throws error for tag mode with workflow_dispatch event", () => {
|
||||
expect(() => getMode("tag", mockWorkflowDispatchContext)).toThrow(
|
||||
"Tag mode cannot handle workflow_dispatch events. Use 'agent' mode for automation events.",
|
||||
"Tag mode cannot handle workflow_dispatch events. Use 'agent' mode for automation events or 'remote-agent' mode for repository_dispatch events.",
|
||||
);
|
||||
});
|
||||
|
||||
test("getMode throws error for tag mode with schedule event", () => {
|
||||
expect(() => getMode("tag", mockScheduleContext)).toThrow(
|
||||
"Tag mode cannot handle schedule events. Use 'agent' mode for automation events.",
|
||||
"Tag mode cannot handle schedule events. Use 'agent' mode for automation events or 'remote-agent' mode for repository_dispatch events.",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -64,7 +64,7 @@ describe("Mode Registry", () => {
|
||||
test("getMode throws error for invalid mode", () => {
|
||||
const invalidMode = "invalid" as unknown as ModeName;
|
||||
expect(() => getMode(invalidMode, mockContext)).toThrow(
|
||||
"Invalid mode 'invalid'. Valid modes are: 'tag', 'agent', 'experimental-review'. Please check your workflow configuration.",
|
||||
"Invalid mode 'invalid'. Valid modes are: 'tag', 'agent', 'remote-agent', 'experimental-review'. Please check your workflow configuration.",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -72,6 +72,7 @@ describe("Mode Registry", () => {
|
||||
expect(isValidMode("tag")).toBe(true);
|
||||
expect(isValidMode("agent")).toBe(true);
|
||||
expect(isValidMode("experimental-review")).toBe(true);
|
||||
expect(isValidMode("remote-agent")).toBe(true);
|
||||
});
|
||||
|
||||
test("isValidMode returns false for invalid mode", () => {
|
||||
|
||||
28
test/report-claude-complete.test.ts
Normal file
28
test/report-claude-complete.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { describe, test, expect } from "bun:test";
|
||||
import type { StreamConfig } from "../src/types/stream-config";
|
||||
|
||||
describe("report-claude-complete", () => {
|
||||
test("StreamConfig type should include system_progress_endpoint", () => {
|
||||
const config: StreamConfig = {
|
||||
progress_endpoint: "https://example.com/progress",
|
||||
system_progress_endpoint: "https://example.com/system-progress",
|
||||
resume_endpoint: "https://example.com/resume",
|
||||
session_id: "test-session",
|
||||
headers: {
|
||||
Authorization: "Bearer test-token",
|
||||
},
|
||||
};
|
||||
|
||||
expect(config.system_progress_endpoint).toBe(
|
||||
"https://example.com/system-progress",
|
||||
);
|
||||
});
|
||||
|
||||
test("StreamConfig type should allow optional fields", () => {
|
||||
const config: StreamConfig = {};
|
||||
|
||||
expect(config.system_progress_endpoint).toBeUndefined();
|
||||
expect(config.progress_endpoint).toBeUndefined();
|
||||
expect(config.headers).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user