@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,52 @@
|
|
|
1
|
+
import type { BreakpointBackend } from "../backend.js";
|
|
2
|
+
import type { BreakpointContext, BackendConfig, RoutingConfig } from "../types.js";
|
|
3
|
+
export { ServerBreakpointBackend, ServerBackendError } from "./server.js";
|
|
4
|
+
export type { ServerBreakpointBackendConfig } from "./server.js";
|
|
5
|
+
export { ExternalTrackerBackend, GenericRestTrackerAdapter, JiraTrackerAdapter, LinearTrackerAdapter, createExternalTrackerAdapter, redactExternalTrackerSecrets, } from "./external-tracker.js";
|
|
6
|
+
export type { ExternalTrackerAdapter, ExternalTrackerComment, ExternalTrackerCreateIssueInput, ExternalTrackerIssue, ExternalTrackerReference, ExternalTrackerWebhookEvent, ExternalTrackerWebhookResult, } from "./external-tracker.js";
|
|
7
|
+
export { AgentMuxResponderBackend, AgentMuxResponderBackendError, } from "./adapters.js";
|
|
8
|
+
export type { AgentMuxClientLike, AgentMuxResponderBackendConfig, AgentMuxRunHandleLike, AgentMuxRunOptions, AgentMuxRunResult, } from "./adapters.js";
|
|
9
|
+
/**
|
|
10
|
+
* Factory function type for creating backends from config.
|
|
11
|
+
*/
|
|
12
|
+
export type BackendFactory = (config: Record<string, unknown>) => BreakpointBackend;
|
|
13
|
+
/**
|
|
14
|
+
* Register a custom backend factory.
|
|
15
|
+
* Called by extension packages (e.g., custom server backend, GitHub Issues backend).
|
|
16
|
+
*/
|
|
17
|
+
export declare function registerBackendFactory(name: string, factory: BackendFactory): void;
|
|
18
|
+
/**
|
|
19
|
+
* Create a backend from a type name and config object.
|
|
20
|
+
* Validates at runtime that the factory returns a BreakpointBackend-conforming object.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createBackend(type: string, config: Record<string, unknown>): BreakpointBackend;
|
|
23
|
+
/**
|
|
24
|
+
* Create the default git-native backend with optional config.
|
|
25
|
+
*
|
|
26
|
+
* This is the recommended entry point for consumers who want the built-in
|
|
27
|
+
* backend without explicit configuration.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createDefaultBackend(options?: Record<string, unknown>): BreakpointBackend;
|
|
30
|
+
/**
|
|
31
|
+
* Resolve the backend for a given config, falling back to defaults.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveBackend(config: BackendConfig): BreakpointBackend;
|
|
34
|
+
/**
|
|
35
|
+
* Match a routing config against a breakpoint context to find the appropriate backend name.
|
|
36
|
+
*
|
|
37
|
+
* Uses **first-match-wins** semantics: routes are evaluated in array order and the
|
|
38
|
+
* first rule whose domain or tag criteria match the context is selected. If no rule
|
|
39
|
+
* matches, the `defaultBackend` is returned. This means higher-priority rules should
|
|
40
|
+
* appear earlier in the routes array. There is no automatic conflict resolution --
|
|
41
|
+
* if multiple rules could match, the first one in array order wins.
|
|
42
|
+
*
|
|
43
|
+
* Matching logic per rule (short-circuit on first hit):
|
|
44
|
+
* 1. If the rule specifies `domains` and the context has a `domain`, check membership.
|
|
45
|
+
* 2. If the rule specifies `tags` and the context has tags, check intersection.
|
|
46
|
+
*/
|
|
47
|
+
export declare function matchRoute(routingConfig: RoutingConfig, context: BreakpointContext): string;
|
|
48
|
+
/**
|
|
49
|
+
* List all registered backend types.
|
|
50
|
+
*/
|
|
51
|
+
export declare function listRegisteredBackends(): string[];
|
|
52
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/backends/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,aAAa,EAId,MAAM,aAAa,CAAC;AASrB,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC1E,YAAY,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAC5B,4BAA4B,GAC7B,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,+BAA+B,EAC/B,oBAAoB,EACpB,wBAAwB,EACxB,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,kBAAkB,EAClB,8BAA8B,EAC9B,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,iBAAiB,CAAC;AAgGpF;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,cAAc,GACtB,IAAI,CAEN;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,iBAAiB,CAYnB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,iBAAiB,CAEnB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,aAAa,GACpB,iBAAiB,CAEnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CACxB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,iBAAiB,GACzB,MAAM,CAUR;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAEjD"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { GitNativeBackend } from "./git-native.js";
|
|
2
|
+
import { GitHubIssuesBackend } from "./github-issues.js";
|
|
3
|
+
import { ExternalTrackerBackend } from "./external-tracker.js";
|
|
4
|
+
import { ServerBreakpointBackend } from "./server.js";
|
|
5
|
+
import { AgentMuxResponderBackend } from "./adapters.js";
|
|
6
|
+
export { ServerBreakpointBackend, ServerBackendError } from "./server.js";
|
|
7
|
+
export { ExternalTrackerBackend, GenericRestTrackerAdapter, JiraTrackerAdapter, LinearTrackerAdapter, createExternalTrackerAdapter, redactExternalTrackerSecrets, } from "./external-tracker.js";
|
|
8
|
+
export { AgentMuxResponderBackend, AgentMuxResponderBackendError, } from "./adapters.js";
|
|
9
|
+
/**
|
|
10
|
+
* Registry of backend factories.
|
|
11
|
+
*/
|
|
12
|
+
const backendFactories = new Map();
|
|
13
|
+
// Register the built-in git-native backend
|
|
14
|
+
backendFactories.set("git-native", (config) => {
|
|
15
|
+
return new GitNativeBackend(config);
|
|
16
|
+
});
|
|
17
|
+
// Register the GitHub Issues backend
|
|
18
|
+
backendFactories.set("github-issues", (config) => {
|
|
19
|
+
return new GitHubIssuesBackend(config);
|
|
20
|
+
});
|
|
21
|
+
// Register the provider-neutral external tracker backend
|
|
22
|
+
backendFactories.set("external-tracker", (config) => {
|
|
23
|
+
return new ExternalTrackerBackend(config);
|
|
24
|
+
});
|
|
25
|
+
// Register the adapters responder backend
|
|
26
|
+
backendFactories.set("adapters", (config) => {
|
|
27
|
+
return new AgentMuxResponderBackend(config);
|
|
28
|
+
});
|
|
29
|
+
// Register the breakpoints-pro server backend
|
|
30
|
+
backendFactories.set("server", (config) => {
|
|
31
|
+
const serverUrl = config.url
|
|
32
|
+
?? config.serverUrl;
|
|
33
|
+
if (!serverUrl) {
|
|
34
|
+
throw new Error('Server backend requires a "url" or "serverUrl" property in config. ' +
|
|
35
|
+
'Example: { type: "server", url: "http://localhost:3847" }');
|
|
36
|
+
}
|
|
37
|
+
return new ServerBreakpointBackend({
|
|
38
|
+
serverUrl,
|
|
39
|
+
authToken: config.authToken,
|
|
40
|
+
projectId: config.projectId,
|
|
41
|
+
repoId: config.repoId,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* Required method names on the BreakpointBackend interface.
|
|
46
|
+
* Used for runtime validation that factory-produced objects conform to the contract.
|
|
47
|
+
*/
|
|
48
|
+
const REQUIRED_BACKEND_METHODS = [
|
|
49
|
+
"submitBreakpoint",
|
|
50
|
+
"getBreakpoint",
|
|
51
|
+
"waitForAnswer",
|
|
52
|
+
"listPendingBreakpoints",
|
|
53
|
+
"answerBreakpoint",
|
|
54
|
+
"cancelBreakpoint",
|
|
55
|
+
];
|
|
56
|
+
/**
|
|
57
|
+
* Validate that an object conforms to the BreakpointBackend interface at runtime.
|
|
58
|
+
* Checks for the `name` property and all required methods.
|
|
59
|
+
* Throws a descriptive error if validation fails.
|
|
60
|
+
*/
|
|
61
|
+
function validateBackendConformance(backend, type) {
|
|
62
|
+
if (backend === null || backend === undefined || typeof backend !== "object") {
|
|
63
|
+
throw new Error(`Backend factory for "${type}" returned ${backend === null ? "null" : typeof backend} ` +
|
|
64
|
+
`instead of a BreakpointBackend-conforming object.`);
|
|
65
|
+
}
|
|
66
|
+
const obj = backend;
|
|
67
|
+
if (typeof obj.name !== "string" || obj.name.length === 0) {
|
|
68
|
+
throw new Error(`Backend factory for "${type}" returned an object without a valid "name" property. ` +
|
|
69
|
+
`BreakpointBackend requires a non-empty readonly name string.`);
|
|
70
|
+
}
|
|
71
|
+
const missingMethods = [];
|
|
72
|
+
for (const method of REQUIRED_BACKEND_METHODS) {
|
|
73
|
+
if (typeof obj[method] !== "function") {
|
|
74
|
+
missingMethods.push(method);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (missingMethods.length > 0) {
|
|
78
|
+
throw new Error(`Backend factory for "${type}" returned an object missing required methods: ` +
|
|
79
|
+
`${missingMethods.join(", ")}. ` +
|
|
80
|
+
`BreakpointBackend requires: name, ${REQUIRED_BACKEND_METHODS.join(", ")}.`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Register a custom backend factory.
|
|
85
|
+
* Called by extension packages (e.g., custom server backend, GitHub Issues backend).
|
|
86
|
+
*/
|
|
87
|
+
export function registerBackendFactory(name, factory) {
|
|
88
|
+
backendFactories.set(name, factory);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Create a backend from a type name and config object.
|
|
92
|
+
* Validates at runtime that the factory returns a BreakpointBackend-conforming object.
|
|
93
|
+
*/
|
|
94
|
+
export function createBackend(type, config) {
|
|
95
|
+
const factory = backendFactories.get(type);
|
|
96
|
+
if (!factory) {
|
|
97
|
+
throw new Error(`Unknown backend type: "${type}". ` +
|
|
98
|
+
`Available: ${[...backendFactories.keys()].join(", ")}. ` +
|
|
99
|
+
`Use registerBackendFactory() to add custom backends.`);
|
|
100
|
+
}
|
|
101
|
+
const backend = factory(config);
|
|
102
|
+
validateBackendConformance(backend, type);
|
|
103
|
+
return backend;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Create the default git-native backend with optional config.
|
|
107
|
+
*
|
|
108
|
+
* This is the recommended entry point for consumers who want the built-in
|
|
109
|
+
* backend without explicit configuration.
|
|
110
|
+
*/
|
|
111
|
+
export function createDefaultBackend(options) {
|
|
112
|
+
return new GitNativeBackend(options);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Resolve the backend for a given config, falling back to defaults.
|
|
116
|
+
*/
|
|
117
|
+
export function resolveBackend(config) {
|
|
118
|
+
return createBackend(config.type, config);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Match a routing config against a breakpoint context to find the appropriate backend name.
|
|
122
|
+
*
|
|
123
|
+
* Uses **first-match-wins** semantics: routes are evaluated in array order and the
|
|
124
|
+
* first rule whose domain or tag criteria match the context is selected. If no rule
|
|
125
|
+
* matches, the `defaultBackend` is returned. This means higher-priority rules should
|
|
126
|
+
* appear earlier in the routes array. There is no automatic conflict resolution --
|
|
127
|
+
* if multiple rules could match, the first one in array order wins.
|
|
128
|
+
*
|
|
129
|
+
* Matching logic per rule (short-circuit on first hit):
|
|
130
|
+
* 1. If the rule specifies `domains` and the context has a `domain`, check membership.
|
|
131
|
+
* 2. If the rule specifies `tags` and the context has tags, check intersection.
|
|
132
|
+
*/
|
|
133
|
+
export function matchRoute(routingConfig, context) {
|
|
134
|
+
for (const rule of routingConfig.routes) {
|
|
135
|
+
if (rule.domains && context.domain) {
|
|
136
|
+
if (rule.domains.includes(context.domain))
|
|
137
|
+
return rule.backend;
|
|
138
|
+
}
|
|
139
|
+
if (rule.tags && context.tags.length > 0) {
|
|
140
|
+
if (rule.tags.some((t) => context.tags.includes(t)))
|
|
141
|
+
return rule.backend;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return routingConfig.defaultBackend;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* List all registered backend types.
|
|
148
|
+
*/
|
|
149
|
+
export function listRegisteredBackends() {
|
|
150
|
+
return [...backendFactories.keys()];
|
|
151
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ServerBreakpointBackend -- BreakpointBackend implementation backed by the
|
|
3
|
+
* breakpoints-pro HTTP server.
|
|
4
|
+
*
|
|
5
|
+
* Bridges tasks-adapter naming (Breakpoint / Responder) to the server's
|
|
6
|
+
* internal naming (Question / Expert) by translating HTTP payloads.
|
|
7
|
+
* Communicates exclusively via fetch(), so it can run in any environment.
|
|
8
|
+
*/
|
|
9
|
+
import type { BreakpointBackend, BreakpointBackendCapabilities, SubmitBreakpointParams, WaitForAnswerOptions, SubmitAnswerParams, ListRespondersParams } from "../backend.js";
|
|
10
|
+
import type { Breakpoint, BreakpointAnswer, BreakpointWaitResult, ResponderProfile } from "../types.js";
|
|
11
|
+
export interface ServerBreakpointBackendConfig {
|
|
12
|
+
serverUrl: string;
|
|
13
|
+
authToken?: string;
|
|
14
|
+
projectId?: string;
|
|
15
|
+
repoId?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare class ServerBackendError extends Error {
|
|
18
|
+
readonly statusCode: number;
|
|
19
|
+
readonly responseBody?: unknown | undefined;
|
|
20
|
+
constructor(message: string, statusCode: number, responseBody?: unknown | undefined);
|
|
21
|
+
}
|
|
22
|
+
export declare class ServerBreakpointBackend implements BreakpointBackend {
|
|
23
|
+
readonly name = "server";
|
|
24
|
+
private serverUrl;
|
|
25
|
+
private authToken;
|
|
26
|
+
private projectId;
|
|
27
|
+
private repoId;
|
|
28
|
+
constructor(config: ServerBreakpointBackendConfig);
|
|
29
|
+
capabilities(): BreakpointBackendCapabilities;
|
|
30
|
+
private buildUrl;
|
|
31
|
+
private buildHeaders;
|
|
32
|
+
private request;
|
|
33
|
+
submitBreakpoint(params: SubmitBreakpointParams): Promise<Breakpoint>;
|
|
34
|
+
getBreakpoint(id: string): Promise<Breakpoint>;
|
|
35
|
+
waitForAnswer(id: string, options?: WaitForAnswerOptions): Promise<BreakpointWaitResult>;
|
|
36
|
+
listPendingBreakpoints(responderId?: string): Promise<Breakpoint[]>;
|
|
37
|
+
answerBreakpoint(id: string, answer: SubmitAnswerParams): Promise<BreakpointAnswer>;
|
|
38
|
+
cancelBreakpoint(id: string): Promise<void>;
|
|
39
|
+
listResponders(params?: ListRespondersParams): Promise<ResponderProfile[]>;
|
|
40
|
+
claimBreakpoint(id: string, responderId: string): Promise<Breakpoint>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/backends/server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,6BAA6B,EAC7B,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAEhB,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAWrB,MAAM,WAAW,6BAA6B;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAID,qBAAa,kBAAmB,SAAQ,KAAK;aAGzB,UAAU,EAAE,MAAM;aAClB,YAAY,CAAC,EAAE,OAAO;gBAFtC,OAAO,EAAE,MAAM,EACC,UAAU,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,OAAO,YAAA;CAKzC;AAwID,qBAAa,uBAAwB,YAAW,iBAAiB;IAC/D,QAAQ,CAAC,IAAI,YAAY;IAEzB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,MAAM,CAAqB;gBAEvB,MAAM,EAAE,6BAA6B;IAOjD,YAAY,IAAI,6BAA6B;IAO7C,OAAO,CAAC,QAAQ;IAYhB,OAAO,CAAC,YAAY;YAUN,OAAO;IAmCf,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,UAAU,CAAC;IAwCrE,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAS9C,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAqFxF,sBAAsB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAkCnE,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA4BnF,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO3C,cAAc,CAAC,MAAM,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAkB1E,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAa5E"}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ServerBreakpointBackend -- BreakpointBackend implementation backed by the
|
|
3
|
+
* breakpoints-pro HTTP server.
|
|
4
|
+
*
|
|
5
|
+
* Bridges tasks-adapter naming (Breakpoint / Responder) to the server's
|
|
6
|
+
* internal naming (Question / Expert) by translating HTTP payloads.
|
|
7
|
+
* Communicates exclusively via fetch(), so it can run in any environment.
|
|
8
|
+
*/
|
|
9
|
+
import { BreakpointSchema, DEFAULT_POLL_INTERVAL_MS, DEFAULT_TIMEOUT_MS } from "../types.js";
|
|
10
|
+
import { unsupportedBackendFeatureMessage as unsupportedFeatureMessage, unsupportedBreakpointBackendCapabilities, } from "../backend.js";
|
|
11
|
+
const API_BASE_PATH = "/api/v1";
|
|
12
|
+
// ── Error ───────────────────────────────────────────────────────────────
|
|
13
|
+
export class ServerBackendError extends Error {
|
|
14
|
+
statusCode;
|
|
15
|
+
responseBody;
|
|
16
|
+
constructor(message, statusCode, responseBody) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.statusCode = statusCode;
|
|
19
|
+
this.responseBody = responseBody;
|
|
20
|
+
this.name = "ServerBackendError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// ── Mapping helpers ─────────────────────────────────────────────────────
|
|
24
|
+
function mapServerAnswerToBreakpointAnswer(answer) {
|
|
25
|
+
return {
|
|
26
|
+
id: answer.id,
|
|
27
|
+
breakpointId: answer.questionId,
|
|
28
|
+
responderId: answer.expertId,
|
|
29
|
+
responderName: answer.expertName,
|
|
30
|
+
text: answer.text,
|
|
31
|
+
confidence: answer.confidence,
|
|
32
|
+
references: answer.references,
|
|
33
|
+
followUpQuestions: answer.followUpQuestions,
|
|
34
|
+
answeredAt: answer.answeredAt,
|
|
35
|
+
approved: answer.approved,
|
|
36
|
+
rating: answer.rating,
|
|
37
|
+
decisionMemory: answer.decisionMemory,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function mapServerQuestionToBreakpoint(question) {
|
|
41
|
+
const context = question.context;
|
|
42
|
+
return BreakpointSchema.parse({
|
|
43
|
+
id: question.id,
|
|
44
|
+
text: question.text,
|
|
45
|
+
context,
|
|
46
|
+
status: question.status,
|
|
47
|
+
routing: {
|
|
48
|
+
strategy: question.routing.strategy,
|
|
49
|
+
targetResponders: question.routing.targetExperts,
|
|
50
|
+
timeoutMs: question.routing.timeoutMs,
|
|
51
|
+
presentToUser: question.routing.presentToUser,
|
|
52
|
+
},
|
|
53
|
+
answers: question.answers.map(mapServerAnswerToBreakpointAnswer),
|
|
54
|
+
selectedAnswer: question.selectedAnswer,
|
|
55
|
+
projectId: question.projectId,
|
|
56
|
+
repoId: question.repoId,
|
|
57
|
+
createdBy: question.createdBy,
|
|
58
|
+
claimedByResponderId: question.claimedByExpertId,
|
|
59
|
+
claimedByResponderName: question.claimedByExpertName,
|
|
60
|
+
createdAt: question.createdAt,
|
|
61
|
+
updatedAt: question.updatedAt,
|
|
62
|
+
expiresAt: question.expiresAt,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function mapExpertProfileToResponderProfile(expert) {
|
|
66
|
+
const allDomains = expert.expertiseAreas.map((area) => area.domain);
|
|
67
|
+
const allTags = expert.expertiseAreas.flatMap((area) => [...area.topics, ...area.keywords]);
|
|
68
|
+
return {
|
|
69
|
+
id: expert.id,
|
|
70
|
+
name: expert.name,
|
|
71
|
+
title: expert.title,
|
|
72
|
+
domains: allDomains,
|
|
73
|
+
tags: allTags,
|
|
74
|
+
availability: expert.availability,
|
|
75
|
+
responseTimeSla: expert.responseTimeSla,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
// ── Backend implementation ──────────────────────────────────────────────
|
|
79
|
+
export class ServerBreakpointBackend {
|
|
80
|
+
name = "server";
|
|
81
|
+
serverUrl;
|
|
82
|
+
authToken;
|
|
83
|
+
projectId;
|
|
84
|
+
repoId;
|
|
85
|
+
constructor(config) {
|
|
86
|
+
this.serverUrl = config.serverUrl.replace(/\/+$/, "");
|
|
87
|
+
this.authToken = config.authToken;
|
|
88
|
+
this.projectId = config.projectId;
|
|
89
|
+
this.repoId = config.repoId;
|
|
90
|
+
}
|
|
91
|
+
capabilities() {
|
|
92
|
+
return {
|
|
93
|
+
...unsupportedBreakpointBackendCapabilities,
|
|
94
|
+
assignment: true,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
buildUrl(path, params) {
|
|
98
|
+
const url = new URL(`${this.serverUrl}${path}`);
|
|
99
|
+
if (params) {
|
|
100
|
+
for (const [key, value] of Object.entries(params)) {
|
|
101
|
+
if (value !== undefined) {
|
|
102
|
+
url.searchParams.set(key, value);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return url.toString();
|
|
107
|
+
}
|
|
108
|
+
buildHeaders() {
|
|
109
|
+
const headers = {
|
|
110
|
+
"Content-Type": "application/json",
|
|
111
|
+
};
|
|
112
|
+
if (this.authToken) {
|
|
113
|
+
headers["Authorization"] = `Bearer ${this.authToken}`;
|
|
114
|
+
}
|
|
115
|
+
return headers;
|
|
116
|
+
}
|
|
117
|
+
async request(method, path, options) {
|
|
118
|
+
const url = this.buildUrl(path, options?.params);
|
|
119
|
+
const response = await fetch(url, {
|
|
120
|
+
method,
|
|
121
|
+
headers: this.buildHeaders(),
|
|
122
|
+
body: options?.body ? JSON.stringify(options.body) : undefined,
|
|
123
|
+
signal: options?.signal,
|
|
124
|
+
});
|
|
125
|
+
if (!response.ok) {
|
|
126
|
+
let responseBody;
|
|
127
|
+
try {
|
|
128
|
+
responseBody = await response.json();
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
process.stderr.write(`[tasks-adapter] response body read failed: ${e instanceof Error ? e.message : String(e)}\n`);
|
|
132
|
+
responseBody = await response.text().catch(() => undefined);
|
|
133
|
+
}
|
|
134
|
+
throw new ServerBackendError(`Server responded with ${response.status}: ${responseBody?.error ?? response.statusText}`, response.status, responseBody);
|
|
135
|
+
}
|
|
136
|
+
return await response.json();
|
|
137
|
+
}
|
|
138
|
+
async submitBreakpoint(params) {
|
|
139
|
+
if (params.proven) {
|
|
140
|
+
throw new ServerBackendError(unsupportedFeatureMessage(this.name, "ask_breakpoint.proven"), 400);
|
|
141
|
+
}
|
|
142
|
+
const projectId = params.projectId ?? this.projectId;
|
|
143
|
+
const repoId = params.repoId ?? this.repoId;
|
|
144
|
+
if (!projectId) {
|
|
145
|
+
throw new ServerBackendError("projectId is required for server backend", 400);
|
|
146
|
+
}
|
|
147
|
+
if (!repoId) {
|
|
148
|
+
throw new ServerBackendError("repoId is required for server backend", 400);
|
|
149
|
+
}
|
|
150
|
+
const body = {
|
|
151
|
+
text: params.text,
|
|
152
|
+
context: params.context,
|
|
153
|
+
routing: {
|
|
154
|
+
strategy: params.routing.strategy,
|
|
155
|
+
targetExperts: params.routing.targetResponders,
|
|
156
|
+
timeoutMs: params.routing.timeoutMs,
|
|
157
|
+
presentToUser: params.routing.presentToUser,
|
|
158
|
+
},
|
|
159
|
+
projectId,
|
|
160
|
+
repoId,
|
|
161
|
+
};
|
|
162
|
+
const question = await this.request("POST", `${API_BASE_PATH}/questions`, { body });
|
|
163
|
+
return mapServerQuestionToBreakpoint(question);
|
|
164
|
+
}
|
|
165
|
+
async getBreakpoint(id) {
|
|
166
|
+
const question = await this.request("GET", `${API_BASE_PATH}/questions/${encodeURIComponent(id)}`);
|
|
167
|
+
return mapServerQuestionToBreakpoint(question);
|
|
168
|
+
}
|
|
169
|
+
async waitForAnswer(id, options) {
|
|
170
|
+
const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
171
|
+
const pollIntervalMs = options?.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
172
|
+
const startTime = Date.now();
|
|
173
|
+
const TIMEOUT_SENTINEL = Symbol("timeout");
|
|
174
|
+
const abortController = new AbortController();
|
|
175
|
+
const externalSignal = options?.signal;
|
|
176
|
+
if (externalSignal) {
|
|
177
|
+
if (externalSignal.aborted) {
|
|
178
|
+
abortController.abort(externalSignal.reason);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
externalSignal.addEventListener("abort", () => {
|
|
182
|
+
abortController.abort(externalSignal.reason);
|
|
183
|
+
}, { once: true });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const timeoutId = setTimeout(() => {
|
|
187
|
+
abortController.abort(TIMEOUT_SENTINEL);
|
|
188
|
+
}, timeoutMs);
|
|
189
|
+
try {
|
|
190
|
+
while (!abortController.signal.aborted) {
|
|
191
|
+
const breakpoint = await this.getBreakpoint(id);
|
|
192
|
+
const elapsedMs = Date.now() - startTime;
|
|
193
|
+
if (breakpoint.answers.length > 0) {
|
|
194
|
+
const selectedAnswer = breakpoint.selectedAnswer
|
|
195
|
+
? breakpoint.answers.find((a) => a.id === breakpoint.selectedAnswer)
|
|
196
|
+
: breakpoint.answers[0];
|
|
197
|
+
return {
|
|
198
|
+
answered: true,
|
|
199
|
+
breakpoint,
|
|
200
|
+
answer: selectedAnswer,
|
|
201
|
+
allAnswers: breakpoint.answers,
|
|
202
|
+
resolution: "answered",
|
|
203
|
+
elapsedMs,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
if (breakpoint.status === "cancelled" || breakpoint.status === "expired") {
|
|
207
|
+
return {
|
|
208
|
+
answered: false,
|
|
209
|
+
breakpoint,
|
|
210
|
+
allAnswers: [],
|
|
211
|
+
resolution: breakpoint.status,
|
|
212
|
+
elapsedMs,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
const aborted = await new Promise((resolve) => {
|
|
216
|
+
const pollTimeout = setTimeout(() => resolve(false), pollIntervalMs);
|
|
217
|
+
if (abortController.signal.aborted) {
|
|
218
|
+
clearTimeout(pollTimeout);
|
|
219
|
+
resolve(true);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
abortController.signal.addEventListener("abort", () => {
|
|
223
|
+
clearTimeout(pollTimeout);
|
|
224
|
+
resolve(true);
|
|
225
|
+
}, { once: true });
|
|
226
|
+
});
|
|
227
|
+
if (aborted)
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
finally {
|
|
232
|
+
clearTimeout(timeoutId);
|
|
233
|
+
}
|
|
234
|
+
const breakpoint = await this.getBreakpoint(id);
|
|
235
|
+
const isTimeout = abortController.signal.reason === TIMEOUT_SENTINEL;
|
|
236
|
+
return {
|
|
237
|
+
answered: false,
|
|
238
|
+
breakpoint,
|
|
239
|
+
allAnswers: breakpoint.answers,
|
|
240
|
+
resolution: isTimeout ? "timeout" : "aborted",
|
|
241
|
+
elapsedMs: Date.now() - startTime,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
async listPendingBreakpoints(responderId) {
|
|
245
|
+
if (!this.projectId) {
|
|
246
|
+
throw new ServerBackendError("projectId is required to list pending breakpoints", 400);
|
|
247
|
+
}
|
|
248
|
+
if (responderId) {
|
|
249
|
+
const questions = await this.request("GET", `${API_BASE_PATH}/experts/${encodeURIComponent(responderId)}/questions`, {
|
|
250
|
+
params: {
|
|
251
|
+
status: "routed",
|
|
252
|
+
projectId: this.projectId,
|
|
253
|
+
repoId: this.repoId,
|
|
254
|
+
},
|
|
255
|
+
});
|
|
256
|
+
return questions.map(mapServerQuestionToBreakpoint);
|
|
257
|
+
}
|
|
258
|
+
const questions = await this.request("GET", `${API_BASE_PATH}/questions`, {
|
|
259
|
+
params: {
|
|
260
|
+
status: "pending",
|
|
261
|
+
projectId: this.projectId,
|
|
262
|
+
repoId: this.repoId,
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
return questions.map(mapServerQuestionToBreakpoint);
|
|
266
|
+
}
|
|
267
|
+
async answerBreakpoint(id, answer) {
|
|
268
|
+
if (answer.sign || answer.keyFingerprint) {
|
|
269
|
+
throw new ServerBackendError(unsupportedFeatureMessage(this.name, "answer signing"), 400);
|
|
270
|
+
}
|
|
271
|
+
const body = {
|
|
272
|
+
expertId: answer.responderId,
|
|
273
|
+
expertName: answer.responderName,
|
|
274
|
+
text: answer.text,
|
|
275
|
+
approved: answer.approved,
|
|
276
|
+
confidence: answer.confidence ?? 80,
|
|
277
|
+
references: answer.references ?? [],
|
|
278
|
+
followUpQuestions: answer.followUpQuestions ?? [],
|
|
279
|
+
decisionMemory: answer.decisionMemory,
|
|
280
|
+
};
|
|
281
|
+
const serverAnswer = await this.request("POST", `${API_BASE_PATH}/questions/${encodeURIComponent(id)}/answers`, { body });
|
|
282
|
+
return mapServerAnswerToBreakpointAnswer(serverAnswer);
|
|
283
|
+
}
|
|
284
|
+
async cancelBreakpoint(id) {
|
|
285
|
+
await this.request("DELETE", `${API_BASE_PATH}/questions/${encodeURIComponent(id)}`);
|
|
286
|
+
}
|
|
287
|
+
async listResponders(params) {
|
|
288
|
+
const projectId = params?.projectId ?? this.projectId;
|
|
289
|
+
const repoId = params?.repoId ?? this.repoId;
|
|
290
|
+
const experts = await this.request("GET", `${API_BASE_PATH}/experts`, {
|
|
291
|
+
params: {
|
|
292
|
+
projectId,
|
|
293
|
+
repoId,
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
return experts.map(mapExpertProfileToResponderProfile);
|
|
297
|
+
}
|
|
298
|
+
async claimBreakpoint(id, responderId) {
|
|
299
|
+
const body = {
|
|
300
|
+
expertId: responderId,
|
|
301
|
+
};
|
|
302
|
+
const question = await this.request("POST", `${API_BASE_PATH}/questions/${encodeURIComponent(id)}/claim`, { body });
|
|
303
|
+
return mapServerQuestionToBreakpoint(question);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type AuthToken } from "../auth/index.js";
|
|
2
|
+
export interface BmuxClientConfig {
|
|
3
|
+
serverUrl?: string;
|
|
4
|
+
authToken?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Get the path to the tasks-adapter config directory (~/.tasks-adapter).
|
|
8
|
+
*/
|
|
9
|
+
export declare function getBmuxDir(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Get the path to the auth state file (~/.tasks-adapter/auth.json).
|
|
12
|
+
*/
|
|
13
|
+
export declare function getAuthStorePath(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Get the path to the client config file (~/.tasks-adapter/config.json).
|
|
16
|
+
*/
|
|
17
|
+
export declare function getClientConfigPath(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Get the path to the SSH keys directory (~/.tasks-adapter/keys).
|
|
20
|
+
*/
|
|
21
|
+
export declare function getKeysDir(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Load CLI/MCP client configuration from ~/.tasks-adapter/config.json.
|
|
24
|
+
*/
|
|
25
|
+
export declare function loadClientConfig(): BmuxClientConfig;
|
|
26
|
+
/**
|
|
27
|
+
* Save or update CLI/MCP client configuration in ~/.tasks-adapter/config.json.
|
|
28
|
+
*/
|
|
29
|
+
export declare function saveClientConfig(next: BmuxClientConfig): void;
|
|
30
|
+
/**
|
|
31
|
+
* Load the stored authentication state from ~/.tasks-adapter/auth.json.
|
|
32
|
+
* Returns null if no auth file exists or the contents are invalid.
|
|
33
|
+
*/
|
|
34
|
+
export declare function loadAuthState(): AuthToken | null;
|
|
35
|
+
/**
|
|
36
|
+
* Save authentication state to ~/.tasks-adapter/auth.json.
|
|
37
|
+
* Creates the directory if it does not exist.
|
|
38
|
+
* Sets file permissions to 0600 (owner read/write only).
|
|
39
|
+
*/
|
|
40
|
+
export declare function saveAuthState(state: AuthToken): void;
|
|
41
|
+
/**
|
|
42
|
+
* Clear the stored authentication state by removing ~/.tasks-adapter/auth.json.
|
|
43
|
+
*/
|
|
44
|
+
export declare function clearAuthState(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Check whether a token has expired based on its expiresAt timestamp.
|
|
47
|
+
*/
|
|
48
|
+
export declare function isTokenExpired(expiresAt: string): boolean;
|
|
49
|
+
//# sourceMappingURL=auth-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../../src/cli/auth-store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AASnE,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAID;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,gBAAgB,CAuBnD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAoC7D;AAID;;;GAGG;AACH,wBAAgB,aAAa,IAAI,SAAS,GAAG,IAAI,CAoBhD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CASpD;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAMrC;AAID;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAGzD"}
|