@a5c-ai/tasks-adapter 5.1.1-staging.0007199a1cb2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -0
- package/dist/auth/forge-interface.d.ts +67 -0
- package/dist/auth/forge-interface.d.ts.map +1 -0
- package/dist/auth/forge-interface.js +69 -0
- package/dist/auth/github-app.d.ts +64 -0
- package/dist/auth/github-app.d.ts.map +1 -0
- package/dist/auth/github-app.js +141 -0
- package/dist/auth/github-oauth.d.ts +27 -0
- package/dist/auth/github-oauth.d.ts.map +1 -0
- package/dist/auth/github-oauth.js +89 -0
- package/dist/auth/index.d.ts +8 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +14 -0
- package/dist/auth/jwt.d.ts +24 -0
- package/dist/auth/jwt.d.ts.map +1 -0
- package/dist/auth/jwt.js +43 -0
- package/dist/auth/middleware.d.ts +22 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +36 -0
- package/dist/auth/ssh-keys.d.ts +21 -0
- package/dist/auth/ssh-keys.d.ts.map +1 -0
- package/dist/auth/ssh-keys.js +59 -0
- package/dist/auth/types.d.ts +165 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +53 -0
- package/dist/backend.d.ts +248 -0
- package/dist/backend.d.ts.map +1 -0
- package/dist/backend.js +40 -0
- package/dist/backends/adapters.d.ts +99 -0
- package/dist/backends/adapters.d.ts.map +1 -0
- package/dist/backends/adapters.js +308 -0
- package/dist/backends/external-tracker.d.ts +133 -0
- package/dist/backends/external-tracker.d.ts.map +1 -0
- package/dist/backends/external-tracker.js +731 -0
- package/dist/backends/git-native.d.ts +69 -0
- package/dist/backends/git-native.d.ts.map +1 -0
- package/dist/backends/git-native.js +797 -0
- package/dist/backends/github-issues.d.ts +78 -0
- package/dist/backends/github-issues.d.ts.map +1 -0
- package/dist/backends/github-issues.js +806 -0
- package/dist/backends/index.d.ts +52 -0
- package/dist/backends/index.d.ts.map +1 -0
- package/dist/backends/index.js +151 -0
- package/dist/backends/server.d.ts +42 -0
- package/dist/backends/server.d.ts.map +1 -0
- package/dist/backends/server.js +305 -0
- package/dist/cli/auth-store.d.ts +49 -0
- package/dist/cli/auth-store.d.ts.map +1 -0
- package/dist/cli/auth-store.js +150 -0
- package/dist/cli/client-config.d.ts +10 -0
- package/dist/cli/client-config.d.ts.map +1 -0
- package/dist/cli/client-config.js +87 -0
- package/dist/cli/commands/ask.d.ts +3 -0
- package/dist/cli/commands/ask.d.ts.map +1 -0
- package/dist/cli/commands/ask.js +171 -0
- package/dist/cli/commands/auth.d.ts +3 -0
- package/dist/cli/commands/auth.d.ts.map +1 -0
- package/dist/cli/commands/auth.js +510 -0
- package/dist/cli/commands/breakpoints.d.ts +3 -0
- package/dist/cli/commands/breakpoints.d.ts.map +1 -0
- package/dist/cli/commands/breakpoints.js +311 -0
- package/dist/cli/commands/responder-loop.d.ts +3 -0
- package/dist/cli/commands/responder-loop.d.ts.map +1 -0
- package/dist/cli/commands/responder-loop.js +78 -0
- package/dist/cli/commands/responders.d.ts +3 -0
- package/dist/cli/commands/responders.d.ts.map +1 -0
- package/dist/cli/commands/responders.js +157 -0
- package/dist/cli/commands/rules.d.ts +3 -0
- package/dist/cli/commands/rules.d.ts.map +1 -0
- package/dist/cli/commands/rules.js +105 -0
- package/dist/cli/commands/server.d.ts +3 -0
- package/dist/cli/commands/server.d.ts.map +1 -0
- package/dist/cli/commands/server.js +34 -0
- package/dist/cli/commands/tasks.d.ts +3 -0
- package/dist/cli/commands/tasks.d.ts.map +1 -0
- package/dist/cli/commands/tasks.js +281 -0
- package/dist/cli/commands/templates.d.ts +3 -0
- package/dist/cli/commands/templates.d.ts.map +1 -0
- package/dist/cli/commands/templates.js +100 -0
- package/dist/cli/index.d.ts +4 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +9 -0
- package/dist/cli/output.d.ts +26 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +143 -0
- package/dist/cli/program.d.ts +6 -0
- package/dist/cli/program.d.ts.map +1 -0
- package/dist/cli/program.js +38 -0
- package/dist/cli/tasks-adapter.d.ts +3 -0
- package/dist/cli/tasks-adapter.d.ts.map +1 -0
- package/dist/cli/tasks-adapter.js +4 -0
- package/dist/client/answer-poller.d.ts +52 -0
- package/dist/client/answer-poller.d.ts.map +1 -0
- package/dist/client/answer-poller.js +200 -0
- package/dist/client/auth-client.d.ts +200 -0
- package/dist/client/auth-client.d.ts.map +1 -0
- package/dist/client/auth-client.js +309 -0
- package/dist/client/breakpoint-router.d.ts +45 -0
- package/dist/client/breakpoint-router.d.ts.map +1 -0
- package/dist/client/breakpoint-router.js +45 -0
- package/dist/client/index.d.ts +17 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +16 -0
- package/dist/client/profile-validator.d.ts +34 -0
- package/dist/client/profile-validator.d.ts.map +1 -0
- package/dist/client/profile-validator.js +89 -0
- package/dist/client/responder-client.d.ts +39 -0
- package/dist/client/responder-client.d.ts.map +1 -0
- package/dist/client/responder-client.js +72 -0
- package/dist/client/responder-matcher.d.ts +49 -0
- package/dist/client/responder-matcher.d.ts.map +1 -0
- package/dist/client/responder-matcher.js +226 -0
- package/dist/client/server-client.d.ts +124 -0
- package/dist/client/server-client.d.ts.map +1 -0
- package/dist/client/server-client.js +266 -0
- package/dist/client/timeout-manager.d.ts +47 -0
- package/dist/client/timeout-manager.d.ts.map +1 -0
- package/dist/client/timeout-manager.js +77 -0
- package/dist/config.d.ts +20 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +93 -0
- package/dist/harness/index.d.ts +4 -0
- package/dist/harness/index.d.ts.map +1 -0
- package/dist/harness/index.js +2 -0
- package/dist/harness/interaction-provider.d.ts +71 -0
- package/dist/harness/interaction-provider.d.ts.map +1 -0
- package/dist/harness/interaction-provider.js +124 -0
- package/dist/harness/routing-rules.d.ts +7 -0
- package/dist/harness/routing-rules.d.ts.map +1 -0
- package/dist/harness/routing-rules.js +37 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/mcp/backend-resolver.d.ts +43 -0
- package/dist/mcp/backend-resolver.d.ts.map +1 -0
- package/dist/mcp/backend-resolver.js +111 -0
- package/dist/mcp/http-transport.d.ts +37 -0
- package/dist/mcp/http-transport.d.ts.map +1 -0
- package/dist/mcp/http-transport.js +103 -0
- package/dist/mcp/index.d.ts +16 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +12 -0
- package/dist/mcp/server.d.ts +20 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +259 -0
- package/dist/mcp/tools/answer-breakpoint.d.ts +32 -0
- package/dist/mcp/tools/answer-breakpoint.d.ts.map +1 -0
- package/dist/mcp/tools/answer-breakpoint.js +45 -0
- package/dist/mcp/tools/ask-breakpoint.d.ts +58 -0
- package/dist/mcp/tools/ask-breakpoint.d.ts.map +1 -0
- package/dist/mcp/tools/ask-breakpoint.js +78 -0
- package/dist/mcp/tools/check-status.d.ts +16 -0
- package/dist/mcp/tools/check-status.d.ts.map +1 -0
- package/dist/mcp/tools/check-status.js +18 -0
- package/dist/mcp/tools/claim-breakpoint.d.ts +18 -0
- package/dist/mcp/tools/claim-breakpoint.d.ts.map +1 -0
- package/dist/mcp/tools/claim-breakpoint.js +28 -0
- package/dist/mcp/tools/list-breakpoints.d.ts +16 -0
- package/dist/mcp/tools/list-breakpoints.d.ts.map +1 -0
- package/dist/mcp/tools/list-breakpoints.js +14 -0
- package/dist/mcp/tools/list-responders.d.ts +18 -0
- package/dist/mcp/tools/list-responders.d.ts.map +1 -0
- package/dist/mcp/tools/list-responders.js +37 -0
- package/dist/mcp/tools/native-tasks.d.ts +270 -0
- package/dist/mcp/tools/native-tasks.d.ts.map +1 -0
- package/dist/mcp/tools/native-tasks.js +481 -0
- package/dist/mcp/tools/poll-breakpoints.d.ts +18 -0
- package/dist/mcp/tools/poll-breakpoints.d.ts.map +1 -0
- package/dist/mcp/tools/poll-breakpoints.js +36 -0
- package/dist/mcp/tools/verify-answer.d.ts +16 -0
- package/dist/mcp/tools/verify-answer.d.ts.map +1 -0
- package/dist/mcp/tools/verify-answer.js +38 -0
- package/dist/proven/index.d.ts +5 -0
- package/dist/proven/index.d.ts.map +1 -0
- package/dist/proven/index.js +3 -0
- package/dist/proven/keys.d.ts +33 -0
- package/dist/proven/keys.d.ts.map +1 -0
- package/dist/proven/keys.js +117 -0
- package/dist/proven/sign.d.ts +16 -0
- package/dist/proven/sign.d.ts.map +1 -0
- package/dist/proven/sign.js +60 -0
- package/dist/proven/types.d.ts +26 -0
- package/dist/proven/types.d.ts.map +1 -0
- package/dist/proven/types.js +5 -0
- package/dist/proven/verify.d.ts +6 -0
- package/dist/proven/verify.d.ts.map +1 -0
- package/dist/proven/verify.js +58 -0
- package/dist/responders/types.d.ts +38 -0
- package/dist/responders/types.d.ts.map +1 -0
- package/dist/responders/types.js +1 -0
- package/dist/router.d.ts +51 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +200 -0
- package/dist/types.d.ts +7711 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +479 -0
- package/package.json +96 -0
- package/responder/README.md +42 -0
- package/responder/backend-responder.json +9 -0
- package/responder/devops-responder.json +9 -0
- package/responder/frontend-responder.json +9 -0
- package/responder/schema.json +89 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BreakpointStatusSchema, DEFAULT_TIMEOUT_MS, TaskPrioritySchema, } from "../../types.js";
|
|
3
|
+
const responderTypeSchema = z.enum(["human", "agent", "tracker", "internal", "auto"]);
|
|
4
|
+
const urgencySchema = z.enum(["low", "medium", "high"]);
|
|
5
|
+
const taskPrioritySchema = TaskPrioritySchema;
|
|
6
|
+
const taskStatusSchema = BreakpointStatusSchema;
|
|
7
|
+
const nativeRoutingParams = {
|
|
8
|
+
responderId: z.string().min(1).optional(),
|
|
9
|
+
responderType: responderTypeSchema.optional(),
|
|
10
|
+
adapter: z.string().min(1).optional(),
|
|
11
|
+
model: z.string().min(1).optional(),
|
|
12
|
+
provider: z.string().min(1).optional(),
|
|
13
|
+
trackerBackend: z.string().min(1).optional(),
|
|
14
|
+
fallbackType: responderTypeSchema.optional(),
|
|
15
|
+
};
|
|
16
|
+
const nativeContextParams = {
|
|
17
|
+
tags: z.array(z.string()).optional(),
|
|
18
|
+
domain: z.string().min(1).optional(),
|
|
19
|
+
urgency: urgencySchema.optional(),
|
|
20
|
+
priority: taskPrioritySchema.optional(),
|
|
21
|
+
dependsOn: z.array(z.string().min(1)).optional(),
|
|
22
|
+
sourceUrl: z.string().url().optional(),
|
|
23
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
24
|
+
projectId: z.string().min(1).optional(),
|
|
25
|
+
repoId: z.string().min(1).optional(),
|
|
26
|
+
};
|
|
27
|
+
export const createTodoDescription = "Create a todo routed through tasks-adapter. The todo is stored as a task-like breakpoint so existing responder backends, routing, and audit trails remain the source of truth.";
|
|
28
|
+
export const createTodoParams = {
|
|
29
|
+
title: z.string().min(1).describe("Short todo title."),
|
|
30
|
+
description: z.string().optional().describe("Optional todo details."),
|
|
31
|
+
...nativeRoutingParams,
|
|
32
|
+
...nativeContextParams,
|
|
33
|
+
backend: z.string().optional(),
|
|
34
|
+
breakpointsDir: z.string().optional(),
|
|
35
|
+
};
|
|
36
|
+
export const createTaskDescription = "Create a task routed through tasks-adapter. This is an alias-friendly task surface backed by the same breakpoint storage as assign_task.";
|
|
37
|
+
export const createTaskParams = {
|
|
38
|
+
title: z.string().min(1).describe("Task title."),
|
|
39
|
+
instructions: z.string().optional().describe("Task instructions or acceptance notes."),
|
|
40
|
+
...nativeRoutingParams,
|
|
41
|
+
...nativeContextParams,
|
|
42
|
+
backend: z.string().optional(),
|
|
43
|
+
breakpointsDir: z.string().optional(),
|
|
44
|
+
};
|
|
45
|
+
export const assignTaskDescription = "Assign a task through tasks-adapter responder routing. Use this instead of direct agent delegation when the work should be visible to the task router.";
|
|
46
|
+
export const assignTaskParams = {
|
|
47
|
+
taskId: z.string().min(1).optional().describe("Existing task or breakpoint id to assign. If omitted, creates a new task."),
|
|
48
|
+
title: z.string().min(1).describe("Task title."),
|
|
49
|
+
instructions: z.string().optional().describe("Task instructions or acceptance notes."),
|
|
50
|
+
assignee: z.string().min(1).optional().describe("Responder id to assign to."),
|
|
51
|
+
...nativeRoutingParams,
|
|
52
|
+
...nativeContextParams,
|
|
53
|
+
backend: z.string().optional(),
|
|
54
|
+
breakpointsDir: z.string().optional(),
|
|
55
|
+
};
|
|
56
|
+
export const searchTasksDescription = "Search task-like breakpoints currently visible to tasks-adapter. This is read-only and uses the configured BreakpointBackend.";
|
|
57
|
+
export const searchTasksParams = {
|
|
58
|
+
query: z.string().optional(),
|
|
59
|
+
status: z.union([taskStatusSchema, z.array(taskStatusSchema)]).optional(),
|
|
60
|
+
priority: z.union([taskPrioritySchema, z.array(taskPrioritySchema)]).optional(),
|
|
61
|
+
assigneeId: z.string().optional(),
|
|
62
|
+
responderId: z.string().optional(),
|
|
63
|
+
domain: z.string().optional(),
|
|
64
|
+
tags: z.array(z.string()).optional(),
|
|
65
|
+
sortBy: z.enum(["createdAt", "updatedAt", "priority", "status"]).optional(),
|
|
66
|
+
sortDirection: z.enum(["asc", "desc"]).optional(),
|
|
67
|
+
offset: z.number().int().nonnegative().optional(),
|
|
68
|
+
limit: z.number().int().positive().optional(),
|
|
69
|
+
backend: z.string().optional(),
|
|
70
|
+
breakpointsDir: z.string().optional(),
|
|
71
|
+
};
|
|
72
|
+
export const addCommentDescription = "Add a discussion comment to a task-like breakpoint through the configured BreakpointBackend.";
|
|
73
|
+
export const addCommentParams = {
|
|
74
|
+
taskId: z.string().min(1),
|
|
75
|
+
authorId: z.string().min(1),
|
|
76
|
+
authorName: z.string().min(1).optional(),
|
|
77
|
+
text: z.string().min(1),
|
|
78
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
79
|
+
backend: z.string().optional(),
|
|
80
|
+
breakpointsDir: z.string().optional(),
|
|
81
|
+
};
|
|
82
|
+
export const addCommentToBreakpointDescription = "Add a discussion comment to a breakpoint through the configured BreakpointBackend.";
|
|
83
|
+
export const addCommentToBreakpointParams = {
|
|
84
|
+
breakpointId: z.string().min(1),
|
|
85
|
+
authorId: z.string().min(1),
|
|
86
|
+
authorName: z.string().min(1).optional(),
|
|
87
|
+
text: z.string().min(1),
|
|
88
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
89
|
+
backend: z.string().optional(),
|
|
90
|
+
breakpointsDir: z.string().optional(),
|
|
91
|
+
};
|
|
92
|
+
export const bulkUpdateTasksDescription = "Apply a backend-agnostic bulk operation to task-like breakpoints with per-item success and failure details.";
|
|
93
|
+
export const bulkUpdateTasksParams = {
|
|
94
|
+
ids: z.array(z.string().min(1)).min(1),
|
|
95
|
+
action: z.enum(["approve", "close", "cancel", "reassign", "transition"]),
|
|
96
|
+
actorId: z.string().min(1).optional(),
|
|
97
|
+
assigneeId: z.string().min(1).optional(),
|
|
98
|
+
assigneeName: z.string().min(1).optional(),
|
|
99
|
+
status: taskStatusSchema.optional(),
|
|
100
|
+
message: z.string().optional(),
|
|
101
|
+
backend: z.string().optional(),
|
|
102
|
+
breakpointsDir: z.string().optional(),
|
|
103
|
+
};
|
|
104
|
+
export const taskStatsDescription = "Compute deterministic task metrics grouped by status and priority.";
|
|
105
|
+
export const taskStatsParams = {
|
|
106
|
+
status: z.union([taskStatusSchema, z.array(taskStatusSchema)]).optional(),
|
|
107
|
+
priority: z.union([taskPrioritySchema, z.array(taskPrioritySchema)]).optional(),
|
|
108
|
+
assigneeId: z.string().optional(),
|
|
109
|
+
responderId: z.string().optional(),
|
|
110
|
+
tags: z.array(z.string()).optional(),
|
|
111
|
+
domain: z.string().optional(),
|
|
112
|
+
backend: z.string().optional(),
|
|
113
|
+
breakpointsDir: z.string().optional(),
|
|
114
|
+
};
|
|
115
|
+
export const exportTasksDescription = "Export matching task-like breakpoints with credential-bearing notification targets redacted.";
|
|
116
|
+
export const exportTasksParams = {
|
|
117
|
+
status: z.union([taskStatusSchema, z.array(taskStatusSchema)]).optional(),
|
|
118
|
+
priority: z.union([taskPrioritySchema, z.array(taskPrioritySchema)]).optional(),
|
|
119
|
+
assigneeId: z.string().optional(),
|
|
120
|
+
responderId: z.string().optional(),
|
|
121
|
+
tags: z.array(z.string()).optional(),
|
|
122
|
+
domain: z.string().optional(),
|
|
123
|
+
backend: z.string().optional(),
|
|
124
|
+
breakpointsDir: z.string().optional(),
|
|
125
|
+
};
|
|
126
|
+
export const escalateDescription = "Escalate an existing task or create a high-urgency intervention through tasks-adapter routing.";
|
|
127
|
+
export const escalateParams = {
|
|
128
|
+
taskId: z.string().min(1).optional().describe("Existing task or breakpoint id to escalate."),
|
|
129
|
+
title: z.string().min(1).optional().describe("Escalation title. Defaults from taskId when available."),
|
|
130
|
+
reason: z.string().min(1).describe("Why escalation is required."),
|
|
131
|
+
targetResponderId: z.string().min(1).optional().describe("Responder id that should receive the escalation."),
|
|
132
|
+
...nativeRoutingParams,
|
|
133
|
+
...nativeContextParams,
|
|
134
|
+
backend: z.string().optional(),
|
|
135
|
+
breakpointsDir: z.string().optional(),
|
|
136
|
+
};
|
|
137
|
+
export const cancelBreakpointDescription = "Cancel a pending breakpoint through the configured BreakpointBackend.";
|
|
138
|
+
export const cancelBreakpointParams = {
|
|
139
|
+
breakpointId: z.string().min(1),
|
|
140
|
+
backend: z.string().optional(),
|
|
141
|
+
breakpointsDir: z.string().optional(),
|
|
142
|
+
};
|
|
143
|
+
export const escalateBreakpointDescription = "Escalate an existing breakpoint through tasks-adapter routing and lifecycle state.";
|
|
144
|
+
export const escalateBreakpointParams = {
|
|
145
|
+
breakpointId: z.string().min(1).describe("Existing breakpoint id to escalate."),
|
|
146
|
+
reason: z.string().min(1).describe("Why escalation is required."),
|
|
147
|
+
targetResponderId: z.string().min(1).optional().describe("Responder id that should receive the escalation."),
|
|
148
|
+
...nativeRoutingParams,
|
|
149
|
+
...nativeContextParams,
|
|
150
|
+
backend: z.string().optional(),
|
|
151
|
+
breakpointsDir: z.string().optional(),
|
|
152
|
+
};
|
|
153
|
+
export async function handleCreateTodo(params, backend) {
|
|
154
|
+
const parsed = z.object(createTodoParams).parse(params);
|
|
155
|
+
const breakpoint = await backend.submitBreakpoint({
|
|
156
|
+
text: parsed.title,
|
|
157
|
+
context: buildContext({
|
|
158
|
+
title: parsed.title,
|
|
159
|
+
description: parsed.description ?? parsed.title,
|
|
160
|
+
interactionKind: "notification",
|
|
161
|
+
nativeTool: "create_todo",
|
|
162
|
+
nativeKind: "todo",
|
|
163
|
+
tags: parsed.tags,
|
|
164
|
+
domain: parsed.domain,
|
|
165
|
+
urgency: parsed.urgency,
|
|
166
|
+
sourceUrl: parsed.sourceUrl,
|
|
167
|
+
metadata: parsed.metadata,
|
|
168
|
+
}),
|
|
169
|
+
routing: buildRouting(parsed),
|
|
170
|
+
priority: parsed.priority,
|
|
171
|
+
dependsOn: parsed.dependsOn?.map((id) => ({ id, blocking: true })),
|
|
172
|
+
projectId: parsed.projectId,
|
|
173
|
+
repoId: parsed.repoId,
|
|
174
|
+
});
|
|
175
|
+
return nativeResult("create_todo", breakpoint);
|
|
176
|
+
}
|
|
177
|
+
export async function handleAssignTask(params, backend) {
|
|
178
|
+
const parsed = z.object(assignTaskParams).parse(params);
|
|
179
|
+
const responderId = parsed.assignee ?? parsed.responderId;
|
|
180
|
+
if (parsed.taskId && responderId && backend.assignBreakpoint) {
|
|
181
|
+
const breakpoint = await backend.assignBreakpoint(parsed.taskId, {
|
|
182
|
+
assigneeId: responderId,
|
|
183
|
+
actorId: parsed.metadata?.actorId,
|
|
184
|
+
});
|
|
185
|
+
return nativeResult("assign_task", breakpoint);
|
|
186
|
+
}
|
|
187
|
+
const breakpoint = await backend.submitBreakpoint({
|
|
188
|
+
text: parsed.title,
|
|
189
|
+
context: buildContext({
|
|
190
|
+
title: parsed.title,
|
|
191
|
+
description: parsed.instructions ?? parsed.title,
|
|
192
|
+
interactionKind: "handoff",
|
|
193
|
+
nativeTool: "assign_task",
|
|
194
|
+
nativeKind: "task",
|
|
195
|
+
tags: parsed.tags,
|
|
196
|
+
domain: parsed.domain,
|
|
197
|
+
urgency: parsed.urgency,
|
|
198
|
+
sourceUrl: parsed.sourceUrl,
|
|
199
|
+
metadata: { ...parsed.metadata, assignee: responderId },
|
|
200
|
+
}),
|
|
201
|
+
routing: buildRouting({ ...parsed, responderId }),
|
|
202
|
+
priority: parsed.priority,
|
|
203
|
+
dependsOn: parsed.dependsOn?.map((id) => ({ id, blocking: true })),
|
|
204
|
+
projectId: parsed.projectId,
|
|
205
|
+
repoId: parsed.repoId,
|
|
206
|
+
});
|
|
207
|
+
return nativeResult("assign_task", breakpoint);
|
|
208
|
+
}
|
|
209
|
+
export async function handleCreateTask(params, backend) {
|
|
210
|
+
const parsed = z.object(createTaskParams).parse(params);
|
|
211
|
+
const breakpoint = await backend.submitBreakpoint({
|
|
212
|
+
text: parsed.title,
|
|
213
|
+
context: buildContext({
|
|
214
|
+
title: parsed.title,
|
|
215
|
+
description: parsed.instructions ?? parsed.title,
|
|
216
|
+
interactionKind: "handoff",
|
|
217
|
+
nativeTool: "create_task",
|
|
218
|
+
nativeKind: "task",
|
|
219
|
+
tags: parsed.tags,
|
|
220
|
+
domain: parsed.domain,
|
|
221
|
+
urgency: parsed.urgency,
|
|
222
|
+
sourceUrl: parsed.sourceUrl,
|
|
223
|
+
metadata: parsed.metadata,
|
|
224
|
+
}),
|
|
225
|
+
routing: buildRouting(parsed),
|
|
226
|
+
priority: parsed.priority,
|
|
227
|
+
dependsOn: parsed.dependsOn?.map((id) => ({ id, blocking: true })),
|
|
228
|
+
projectId: parsed.projectId,
|
|
229
|
+
repoId: parsed.repoId,
|
|
230
|
+
});
|
|
231
|
+
return nativeResult("create_task", breakpoint);
|
|
232
|
+
}
|
|
233
|
+
export async function handleSearchTasks(params, backend) {
|
|
234
|
+
const parsed = z.object(searchTasksParams).parse(params);
|
|
235
|
+
if (backend.searchBreakpoints) {
|
|
236
|
+
const result = await backend.searchBreakpoints({
|
|
237
|
+
query: parsed.query,
|
|
238
|
+
status: normalizeArray(parsed.status),
|
|
239
|
+
priority: normalizeArray(parsed.priority),
|
|
240
|
+
assigneeId: parsed.assigneeId,
|
|
241
|
+
responderId: parsed.responderId,
|
|
242
|
+
domain: parsed.domain,
|
|
243
|
+
tags: parsed.tags,
|
|
244
|
+
sortBy: parsed.sortBy,
|
|
245
|
+
sortDirection: parsed.sortDirection,
|
|
246
|
+
offset: parsed.offset,
|
|
247
|
+
limit: parsed.limit,
|
|
248
|
+
});
|
|
249
|
+
return { tool: "search_tasks", count: result.total, tasks: result.items };
|
|
250
|
+
}
|
|
251
|
+
const pending = await backend.listPendingBreakpoints(parsed.responderId);
|
|
252
|
+
const query = parsed.query?.toLowerCase();
|
|
253
|
+
const tags = parsed.tags?.map((tag) => tag.toLowerCase()) ?? [];
|
|
254
|
+
const domain = parsed.domain?.toLowerCase();
|
|
255
|
+
const statuses = normalizeArray(parsed.status);
|
|
256
|
+
const priorities = normalizeArray(parsed.priority);
|
|
257
|
+
const filtered = pending.filter((task) => {
|
|
258
|
+
if (statuses && !statuses.includes(task.status))
|
|
259
|
+
return false;
|
|
260
|
+
if (priorities && !priorities.includes(task.priority ?? "medium"))
|
|
261
|
+
return false;
|
|
262
|
+
if (parsed.assigneeId && task.assigneeId !== parsed.assigneeId)
|
|
263
|
+
return false;
|
|
264
|
+
if (parsed.responderId && !matchesResponder(task, parsed.responderId))
|
|
265
|
+
return false;
|
|
266
|
+
if (domain && !task.context.domain?.toLowerCase().includes(domain))
|
|
267
|
+
return false;
|
|
268
|
+
if (tags.length > 0) {
|
|
269
|
+
const taskTags = new Set(task.context.tags.map((tag) => tag.toLowerCase()));
|
|
270
|
+
if (!tags.every((tag) => taskTags.has(tag)))
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
if (query && !searchText(task).includes(query))
|
|
274
|
+
return false;
|
|
275
|
+
return true;
|
|
276
|
+
});
|
|
277
|
+
const tasks = typeof parsed.limit === "number" ? filtered.slice(0, parsed.limit) : filtered;
|
|
278
|
+
return { tool: "search_tasks", count: tasks.length, tasks };
|
|
279
|
+
}
|
|
280
|
+
export async function handleEscalate(params, backend) {
|
|
281
|
+
const parsed = z.object(escalateParams).parse(params);
|
|
282
|
+
const existing = parsed.taskId ? await getExistingTask(backend, parsed.taskId) : undefined;
|
|
283
|
+
if (existing && backend.transitionBreakpoint) {
|
|
284
|
+
const breakpoint = await backend.transitionBreakpoint(existing.id, {
|
|
285
|
+
status: "escalated",
|
|
286
|
+
actorId: parsed.metadata?.actorId,
|
|
287
|
+
message: parsed.reason,
|
|
288
|
+
});
|
|
289
|
+
return nativeResult("escalate", breakpoint);
|
|
290
|
+
}
|
|
291
|
+
const title = parsed.title ?? (existing ? `Escalate: ${existing.text}` : "Escalation required");
|
|
292
|
+
const responderId = parsed.targetResponderId ?? parsed.responderId;
|
|
293
|
+
const breakpoint = await backend.submitBreakpoint({
|
|
294
|
+
text: title,
|
|
295
|
+
context: buildContext({
|
|
296
|
+
title,
|
|
297
|
+
description: existing
|
|
298
|
+
? `${parsed.reason}\n\nEscalated task: ${existing.id}\n${existing.text}`
|
|
299
|
+
: parsed.reason,
|
|
300
|
+
interactionKind: "intervention",
|
|
301
|
+
nativeTool: "escalate",
|
|
302
|
+
nativeKind: "escalation",
|
|
303
|
+
tags: ["escalation", ...(parsed.tags ?? [])],
|
|
304
|
+
domain: parsed.domain ?? existing?.context.domain,
|
|
305
|
+
urgency: "high",
|
|
306
|
+
sourceUrl: parsed.sourceUrl,
|
|
307
|
+
metadata: { ...parsed.metadata, escalatedTaskId: parsed.taskId },
|
|
308
|
+
}),
|
|
309
|
+
routing: buildRouting({
|
|
310
|
+
...parsed,
|
|
311
|
+
responderId,
|
|
312
|
+
responderType: parsed.responderType ?? "human",
|
|
313
|
+
}),
|
|
314
|
+
priority: "critical",
|
|
315
|
+
dependsOn: parsed.taskId ? [{ id: parsed.taskId, blocking: false }] : undefined,
|
|
316
|
+
projectId: parsed.projectId,
|
|
317
|
+
repoId: parsed.repoId,
|
|
318
|
+
});
|
|
319
|
+
return nativeResult("escalate", breakpoint);
|
|
320
|
+
}
|
|
321
|
+
export async function handleCancelBreakpoint(params, backend) {
|
|
322
|
+
const parsed = z.object(cancelBreakpointParams).parse(params);
|
|
323
|
+
await backend.cancelBreakpoint(parsed.breakpointId);
|
|
324
|
+
return { tool: "cancel_breakpoint", breakpointId: parsed.breakpointId, cancelled: true };
|
|
325
|
+
}
|
|
326
|
+
export async function handleEscalateBreakpoint(params, backend) {
|
|
327
|
+
const parsed = z.object(escalateBreakpointParams).parse(params);
|
|
328
|
+
const result = await handleEscalate({
|
|
329
|
+
...parsed,
|
|
330
|
+
taskId: parsed.breakpointId,
|
|
331
|
+
}, backend);
|
|
332
|
+
return {
|
|
333
|
+
...result,
|
|
334
|
+
tool: "escalate_breakpoint",
|
|
335
|
+
metadata: {
|
|
336
|
+
...result.metadata,
|
|
337
|
+
nativeTool: "escalate_breakpoint",
|
|
338
|
+
},
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
export async function handleAddComment(params, backend) {
|
|
342
|
+
const parsed = z.object(addCommentParams).parse(params);
|
|
343
|
+
if (!backend.addBreakpointComment) {
|
|
344
|
+
throw new Error(`Backend "${backend.name}" does not support task comments`);
|
|
345
|
+
}
|
|
346
|
+
const comment = await backend.addBreakpointComment(parsed.taskId, {
|
|
347
|
+
authorId: parsed.authorId,
|
|
348
|
+
authorName: parsed.authorName,
|
|
349
|
+
text: parsed.text,
|
|
350
|
+
metadata: parsed.metadata,
|
|
351
|
+
});
|
|
352
|
+
return { tool: "add_comment", taskId: parsed.taskId, comment };
|
|
353
|
+
}
|
|
354
|
+
export async function handleAddCommentToBreakpoint(params, backend) {
|
|
355
|
+
const parsed = z.object(addCommentToBreakpointParams).parse(params);
|
|
356
|
+
const result = await handleAddComment({
|
|
357
|
+
taskId: parsed.breakpointId,
|
|
358
|
+
authorId: parsed.authorId,
|
|
359
|
+
authorName: parsed.authorName,
|
|
360
|
+
text: parsed.text,
|
|
361
|
+
metadata: parsed.metadata,
|
|
362
|
+
}, backend);
|
|
363
|
+
return { ...result, tool: "add_comment_to_breakpoint", breakpointId: parsed.breakpointId };
|
|
364
|
+
}
|
|
365
|
+
export async function handleBulkUpdateTasks(params, backend) {
|
|
366
|
+
const parsed = z.object(bulkUpdateTasksParams).parse(params);
|
|
367
|
+
if (!backend.bulkUpdateBreakpoints) {
|
|
368
|
+
throw new Error(`Backend "${backend.name}" does not support bulk task operations`);
|
|
369
|
+
}
|
|
370
|
+
return {
|
|
371
|
+
tool: "bulk_update_tasks",
|
|
372
|
+
...(await backend.bulkUpdateBreakpoints(parsed)),
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
export async function handleTaskStats(params, backend) {
|
|
376
|
+
const parsed = z.object(taskStatsParams).parse(params);
|
|
377
|
+
if (!backend.getBreakpointMetrics) {
|
|
378
|
+
throw new Error(`Backend "${backend.name}" does not support task stats`);
|
|
379
|
+
}
|
|
380
|
+
return {
|
|
381
|
+
tool: "task_stats",
|
|
382
|
+
...(await backend.getBreakpointMetrics({
|
|
383
|
+
status: normalizeArray(parsed.status),
|
|
384
|
+
priority: normalizeArray(parsed.priority),
|
|
385
|
+
assigneeId: parsed.assigneeId,
|
|
386
|
+
responderId: parsed.responderId,
|
|
387
|
+
tags: parsed.tags,
|
|
388
|
+
domain: parsed.domain,
|
|
389
|
+
})),
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
export async function handleExportTasks(params, backend) {
|
|
393
|
+
const parsed = z.object(exportTasksParams).parse(params);
|
|
394
|
+
if (!backend.exportBreakpoints) {
|
|
395
|
+
throw new Error(`Backend "${backend.name}" does not support task export`);
|
|
396
|
+
}
|
|
397
|
+
return {
|
|
398
|
+
tool: "export_tasks",
|
|
399
|
+
...(await backend.exportBreakpoints({
|
|
400
|
+
status: normalizeArray(parsed.status),
|
|
401
|
+
priority: normalizeArray(parsed.priority),
|
|
402
|
+
assigneeId: parsed.assigneeId,
|
|
403
|
+
responderId: parsed.responderId,
|
|
404
|
+
tags: parsed.tags,
|
|
405
|
+
domain: parsed.domain,
|
|
406
|
+
})),
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
function buildContext(args) {
|
|
410
|
+
return {
|
|
411
|
+
title: args.title,
|
|
412
|
+
description: args.description,
|
|
413
|
+
codeSnippets: [],
|
|
414
|
+
fileReferences: [],
|
|
415
|
+
tags: Array.from(new Set([args.nativeKind, ...(args.tags ?? [])])),
|
|
416
|
+
domain: args.domain,
|
|
417
|
+
urgency: args.urgency,
|
|
418
|
+
interactionKind: args.interactionKind,
|
|
419
|
+
links: args.sourceUrl ? [{ label: "Source", url: args.sourceUrl, kind: "reference" }] : undefined,
|
|
420
|
+
metadata: {
|
|
421
|
+
...args.metadata,
|
|
422
|
+
nativeTool: args.nativeTool,
|
|
423
|
+
nativeKind: args.nativeKind,
|
|
424
|
+
},
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
function buildRouting(params) {
|
|
428
|
+
return {
|
|
429
|
+
strategy: "single",
|
|
430
|
+
targetResponders: params.responderId ? [params.responderId] : [],
|
|
431
|
+
timeoutMs: DEFAULT_TIMEOUT_MS,
|
|
432
|
+
presentToUser: params.responderType !== "agent",
|
|
433
|
+
responderType: params.responderType,
|
|
434
|
+
adapter: params.adapter,
|
|
435
|
+
model: params.model,
|
|
436
|
+
provider: params.provider,
|
|
437
|
+
trackerBackend: params.trackerBackend,
|
|
438
|
+
fallbackType: params.fallbackType,
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
function nativeResult(tool, breakpoint) {
|
|
442
|
+
return {
|
|
443
|
+
tool,
|
|
444
|
+
taskId: breakpoint.id,
|
|
445
|
+
breakpoint,
|
|
446
|
+
routing: breakpoint.routing,
|
|
447
|
+
metadata: {
|
|
448
|
+
nativeTool: tool,
|
|
449
|
+
backendStatus: breakpoint.status,
|
|
450
|
+
},
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
async function getExistingTask(backend, taskId) {
|
|
454
|
+
try {
|
|
455
|
+
return await backend.getBreakpoint(taskId);
|
|
456
|
+
}
|
|
457
|
+
catch {
|
|
458
|
+
return undefined;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
function matchesResponder(task, responderId) {
|
|
462
|
+
return task.routing.targetResponders.includes(responderId) ||
|
|
463
|
+
task.claimedByResponderId === responderId ||
|
|
464
|
+
task.answers.some((answer) => answer.responderId === responderId);
|
|
465
|
+
}
|
|
466
|
+
function searchText(task) {
|
|
467
|
+
return [
|
|
468
|
+
task.id,
|
|
469
|
+
task.text,
|
|
470
|
+
task.context.title,
|
|
471
|
+
task.context.summary,
|
|
472
|
+
task.context.description,
|
|
473
|
+
task.context.domain,
|
|
474
|
+
...task.context.tags,
|
|
475
|
+
].filter(Boolean).join("\n").toLowerCase();
|
|
476
|
+
}
|
|
477
|
+
function normalizeArray(value) {
|
|
478
|
+
if (value === undefined)
|
|
479
|
+
return undefined;
|
|
480
|
+
return Array.isArray(value) ? value : [value];
|
|
481
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { BreakpointBackend } from "../../backend.js";
|
|
3
|
+
import type { Breakpoint } from "../../types.js";
|
|
4
|
+
export declare const pollBreakpointsDescription: string;
|
|
5
|
+
export declare const pollBreakpointsParams: {
|
|
6
|
+
responderId: z.ZodString;
|
|
7
|
+
waitSeconds: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
backend: z.ZodOptional<z.ZodString>;
|
|
9
|
+
breakpointsDir: z.ZodOptional<z.ZodString>;
|
|
10
|
+
};
|
|
11
|
+
export interface PollBreakpointsToolParams {
|
|
12
|
+
responderId: string;
|
|
13
|
+
waitSeconds?: number;
|
|
14
|
+
backend?: string;
|
|
15
|
+
breakpointsDir?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function handlePollBreakpoints(params: PollBreakpointsToolParams, backend: BreakpointBackend): Promise<Breakpoint[]>;
|
|
18
|
+
//# sourceMappingURL=poll-breakpoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poll-breakpoints.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/poll-breakpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIjD,eAAO,MAAM,0BAA0B,QAGsC,CAAC;AAI9E,eAAO,MAAM,qBAAqB;;;;;CAejC,CAAC;AAIF,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAID,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,yBAAyB,EACjC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,UAAU,EAAE,CAAC,CAiBvB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// ── Tool Description ────────────────────────────────────────────────────
|
|
3
|
+
export const pollBreakpointsDescription = "Poll for pending breakpoints routed to a specific responder. " +
|
|
4
|
+
"Returns all breakpoints currently waiting for this responder to answer. " +
|
|
5
|
+
"Use waitSeconds to long-poll if no breakpoints are immediately available.";
|
|
6
|
+
// ── Tool Param Schema ───────────────────────────────────────────────────
|
|
7
|
+
export const pollBreakpointsParams = {
|
|
8
|
+
responderId: z
|
|
9
|
+
.string()
|
|
10
|
+
.describe("The responder ID to poll breakpoints for."),
|
|
11
|
+
waitSeconds: z
|
|
12
|
+
.number()
|
|
13
|
+
.min(0)
|
|
14
|
+
.max(120)
|
|
15
|
+
.optional()
|
|
16
|
+
.describe("How long to wait for breakpoints to appear (0 = immediate return, default). " +
|
|
17
|
+
"If > 0, polls every 2 seconds until breakpoints are found or timeout expires."),
|
|
18
|
+
backend: z.string().optional(),
|
|
19
|
+
breakpointsDir: z.string().optional(),
|
|
20
|
+
};
|
|
21
|
+
// ── Handler ─────────────────────────────────────────────────────────────
|
|
22
|
+
export async function handlePollBreakpoints(params, backend) {
|
|
23
|
+
if (!params.responderId || params.responderId.length === 0) {
|
|
24
|
+
throw new Error("responderId is required and must be non-empty");
|
|
25
|
+
}
|
|
26
|
+
const waitSeconds = params.waitSeconds ?? 0;
|
|
27
|
+
let breakpoints = await backend.listPendingBreakpoints(params.responderId);
|
|
28
|
+
if (breakpoints.length === 0 && waitSeconds > 0) {
|
|
29
|
+
const deadline = Date.now() + waitSeconds * 1000;
|
|
30
|
+
while (breakpoints.length === 0 && Date.now() < deadline) {
|
|
31
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
32
|
+
breakpoints = await backend.listPendingBreakpoints(params.responderId);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return breakpoints;
|
|
36
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { BreakpointBackend } from "../../backend.js";
|
|
3
|
+
import type { ProvenVerificationResult } from "../../types.js";
|
|
4
|
+
export declare const verifyBreakpointAnswerDescription: string;
|
|
5
|
+
export declare const verifyBreakpointAnswerParams: {
|
|
6
|
+
breakpointId: z.ZodString;
|
|
7
|
+
backend: z.ZodOptional<z.ZodString>;
|
|
8
|
+
breakpointsDir: z.ZodOptional<z.ZodString>;
|
|
9
|
+
};
|
|
10
|
+
export interface VerifyBreakpointAnswerParams {
|
|
11
|
+
breakpointId: string;
|
|
12
|
+
backend?: string;
|
|
13
|
+
breakpointsDir?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function handleVerifyBreakpointAnswer(params: VerifyBreakpointAnswerParams, backend: BreakpointBackend): Promise<ProvenVerificationResult>;
|
|
16
|
+
//# sourceMappingURL=verify-answer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-answer.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/verify-answer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAK/D,eAAO,MAAM,iCAAiC,QAE2B,CAAC;AAI1E,eAAO,MAAM,4BAA4B;;;;CAMxC,CAAC;AAIF,MAAM,WAAW,4BAA4B;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAID,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,4BAA4B,EACpC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,wBAAwB,CAAC,CA4BnC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { selectBreakpointAnswer, supportsProvenAnswers, unsupportedBackendFeatureMessage, } from "../../backend.js";
|
|
3
|
+
import { isProvenBreakpointAnswer } from "../../types.js";
|
|
4
|
+
import { verifyAnswer } from "../../proven/verify.js";
|
|
5
|
+
// ── Tool Description ────────────────────────────────────────────────────
|
|
6
|
+
export const verifyBreakpointAnswerDescription = "Verify the cryptographic signature of a breakpoint answer against " +
|
|
7
|
+
"trusted public keys. Returns verification status and signer identity.";
|
|
8
|
+
// ── Tool Param Schema ───────────────────────────────────────────────────
|
|
9
|
+
export const verifyBreakpointAnswerParams = {
|
|
10
|
+
breakpointId: z.string().describe("The ID of the breakpoint whose answer to verify."),
|
|
11
|
+
backend: z.string().optional(),
|
|
12
|
+
breakpointsDir: z.string().optional(),
|
|
13
|
+
};
|
|
14
|
+
// ── Handler ─────────────────────────────────────────────────────────────
|
|
15
|
+
export async function handleVerifyBreakpointAnswer(params, backend) {
|
|
16
|
+
if (!params.breakpointId || params.breakpointId.length === 0) {
|
|
17
|
+
throw new Error("breakpointId is required and must be non-empty");
|
|
18
|
+
}
|
|
19
|
+
const breakpoint = await backend.getBreakpoint(params.breakpointId);
|
|
20
|
+
if (!breakpoint.answers || breakpoint.answers.length === 0) {
|
|
21
|
+
throw new Error("No answers found for this breakpoint");
|
|
22
|
+
}
|
|
23
|
+
const answer = selectBreakpointAnswer(breakpoint);
|
|
24
|
+
if (!answer) {
|
|
25
|
+
if (breakpoint.selectedAnswer) {
|
|
26
|
+
throw new Error(`Selected answer ${breakpoint.selectedAnswer} was not found on breakpoint ${breakpoint.id}`);
|
|
27
|
+
}
|
|
28
|
+
throw new Error("No answers found for this breakpoint");
|
|
29
|
+
}
|
|
30
|
+
if (!isProvenBreakpointAnswer(answer)) {
|
|
31
|
+
if (!supportsProvenAnswers(backend.name)) {
|
|
32
|
+
throw new Error(unsupportedBackendFeatureMessage(backend.name, "signed answers"));
|
|
33
|
+
}
|
|
34
|
+
throw new Error("Answer is not signed/proven -- no cryptographic signature found");
|
|
35
|
+
}
|
|
36
|
+
const result = await verifyAnswer(answer, params.breakpointsDir);
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { generateKeyPair, saveTrustedPublicKey, savePrivateKey, loadTrustedPublicKeys, loadPrivateKey, rotateKey, } from "./keys.js";
|
|
2
|
+
export type { KeyPairMetadata, PublicKeyRecord, PrivateKeyRecord, } from "./keys.js";
|
|
3
|
+
export { signAnswer, signAnswerWithKeyRecord } from "./sign.js";
|
|
4
|
+
export { verifyAnswer } from "./verify.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/proven/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,SAAS,GACV,MAAM,WAAW,CAAC;AAEnB,YAAY,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { PublicKeyRecord, PrivateKeyRecord } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generate a new Ed25519 key pair for a responder.
|
|
4
|
+
*/
|
|
5
|
+
export declare function generateKeyPair(responderId: string, responderName: string): {
|
|
6
|
+
publicKeyRecord: PublicKeyRecord;
|
|
7
|
+
privateKeyRecord: PrivateKeyRecord;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Save a public key to the trusted keys directory (git-tracked).
|
|
11
|
+
*/
|
|
12
|
+
export declare function saveTrustedPublicKey(publicKeyRecord: PublicKeyRecord, baseDir?: string): Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Save a private key to the private keys directory (gitignored).
|
|
15
|
+
*/
|
|
16
|
+
export declare function savePrivateKey(privateKeyRecord: PrivateKeyRecord, baseDir?: string): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Load all trusted public keys from the trusted directory.
|
|
19
|
+
*/
|
|
20
|
+
export declare function loadTrustedPublicKeys(baseDir?: string): Promise<PublicKeyRecord[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Load a private key by fingerprint.
|
|
23
|
+
*/
|
|
24
|
+
export declare function loadPrivateKey(fingerprint: string, baseDir?: string): Promise<PrivateKeyRecord | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Rotate a key: generate new pair, save both, mark old public key as expired.
|
|
27
|
+
*/
|
|
28
|
+
export declare function rotateKey(responderId: string, responderName: string, oldFingerprint: string, baseDir?: string): Promise<{
|
|
29
|
+
publicKeyRecord: PublicKeyRecord;
|
|
30
|
+
privateKeyRecord: PrivateKeyRecord;
|
|
31
|
+
}>;
|
|
32
|
+
export type { PublicKeyRecord, PrivateKeyRecord, KeyPairMetadata } from "./types.js";
|
|
33
|
+
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/proven/keys.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEpE;;GAEG;AACH,wBAAgB,eAAe,CAC7B,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,GACpB;IAAE,eAAe,EAAE,eAAe,CAAC;IAAC,gBAAgB,EAAE,gBAAgB,CAAA;CAAE,CAyB1E;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,eAAe,EAAE,eAAe,EAChC,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CASjB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CASjB;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,EAAE,CAAC,CAmB5B;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAYlC;AAED;;GAEG;AACH,wBAAsB,SAAS,CAC7B,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,eAAe,EAAE,eAAe,CAAC;IAAC,gBAAgB,EAAE,gBAAgB,CAAA;CAAE,CAAC,CAqBnF;AAED,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|