@edukors/ai-cli 0.0.0-stage → 0.1.1
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/LICENSE +9 -0
- package/README.md +162 -2
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +256 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +3 -0
- package/dist/constants.js.map +1 -0
- package/dist/diagnostics.d.ts +28 -0
- package/dist/diagnostics.js +35 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/engine.d.ts +157 -0
- package/dist/engine.js +395 -0
- package/dist/engine.js.map +1 -0
- package/dist/errors.d.ts +27 -0
- package/dist/errors.js +59 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +95 -0
- package/dist/events.js +8 -0
- package/dist/events.js.map +1 -0
- package/dist/host/main.d.ts +2 -0
- package/dist/host/main.js +30 -0
- package/dist/host/main.js.map +1 -0
- package/dist/host/stdio.d.ts +34 -0
- package/dist/host/stdio.js +254 -0
- package/dist/host/stdio.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/config.d.ts +19 -0
- package/dist/mcp/config.js +63 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/external.d.ts +55 -0
- package/dist/mcp/external.js +129 -0
- package/dist/mcp/external.js.map +1 -0
- package/dist/mcp/toolServer.d.ts +30 -0
- package/dist/mcp/toolServer.js +102 -0
- package/dist/mcp/toolServer.js.map +1 -0
- package/dist/platform/discovery.d.ts +23 -0
- package/dist/platform/discovery.js +64 -0
- package/dist/platform/discovery.js.map +1 -0
- package/dist/platform/env.d.ts +12 -0
- package/dist/platform/env.js +104 -0
- package/dist/platform/env.js.map +1 -0
- package/dist/platform/login.d.ts +16 -0
- package/dist/platform/login.js +42 -0
- package/dist/platform/login.js.map +1 -0
- package/dist/platform/paths.d.ts +19 -0
- package/dist/platform/paths.js +46 -0
- package/dist/platform/paths.js.map +1 -0
- package/dist/platform/process.d.ts +55 -0
- package/dist/platform/process.js +186 -0
- package/dist/platform/process.js.map +1 -0
- package/dist/provider.d.ts +156 -0
- package/dist/provider.js +2 -0
- package/dist/provider.js.map +1 -0
- package/dist/providers/claude/adapter.d.ts +43 -0
- package/dist/providers/claude/adapter.js +398 -0
- package/dist/providers/claude/adapter.js.map +1 -0
- package/dist/providers/claude/events.d.ts +36 -0
- package/dist/providers/claude/events.js +90 -0
- package/dist/providers/claude/events.js.map +1 -0
- package/dist/providers/codex/adapter.d.ts +28 -0
- package/dist/providers/codex/adapter.js +497 -0
- package/dist/providers/codex/adapter.js.map +1 -0
- package/dist/providers/codex/rpc.d.ts +17 -0
- package/dist/providers/codex/rpc.js +75 -0
- package/dist/providers/codex/rpc.js.map +1 -0
- package/dist/providers.d.ts +9 -0
- package/dist/providers.js +15 -0
- package/dist/providers.js.map +1 -0
- package/dist/redact.d.ts +7 -0
- package/dist/redact.js +48 -0
- package/dist/redact.js.map +1 -0
- package/dist/registry/lock.d.ts +18 -0
- package/dist/registry/lock.js +83 -0
- package/dist/registry/lock.js.map +1 -0
- package/dist/registry/registry.d.ts +38 -0
- package/dist/registry/registry.js +119 -0
- package/dist/registry/registry.js.map +1 -0
- package/dist/session.d.ts +126 -0
- package/dist/session.js +333 -0
- package/dist/session.js.map +1 -0
- package/dist/settings.d.ts +8 -0
- package/dist/settings.js +7 -0
- package/dist/settings.js.map +1 -0
- package/dist/skills.d.ts +24 -0
- package/dist/skills.js +91 -0
- package/dist/skills.js.map +1 -0
- package/dist/testing/fakeProvider.d.ts +22 -0
- package/dist/testing/fakeProvider.js +266 -0
- package/dist/testing/fakeProvider.js.map +1 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.js +2 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/tools.d.ts +45 -0
- package/dist/tools.js +32 -0
- package/dist/tools.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/fixtures/fake-ai.mjs +230 -0
- package/fixtures/fake-claude.mjs +62 -0
- package/fixtures/fake-codex.mjs +281 -0
- package/fixtures/fake-mcp-server.mjs +14 -0
- package/package.json +74 -4
package/dist/errors.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable error codes. Applications translate these into actionable language;
|
|
3
|
+
* the raw provider message belongs in redacted diagnostics, not the main UI.
|
|
4
|
+
*/
|
|
5
|
+
export const ERROR_CODES = [
|
|
6
|
+
"PROVIDER_UNKNOWN",
|
|
7
|
+
"CLI_MISSING",
|
|
8
|
+
"CLI_INCOMPATIBLE",
|
|
9
|
+
"CAPABILITY_UNSUPPORTED",
|
|
10
|
+
"ACCOUNT_NOT_FOUND",
|
|
11
|
+
"ACCOUNT_DISCONNECTED",
|
|
12
|
+
"ACCOUNT_EXPIRED",
|
|
13
|
+
"LOGIN_FAILED",
|
|
14
|
+
"SESSION_CLOSED",
|
|
15
|
+
"SESSION_BUSY",
|
|
16
|
+
"QUESTION_NOT_FOUND",
|
|
17
|
+
"PROVIDER_START_FAILED",
|
|
18
|
+
"PROVIDER_CRASHED",
|
|
19
|
+
"PROVIDER_PROTOCOL",
|
|
20
|
+
"PROVIDER_ERROR",
|
|
21
|
+
"RATE_LIMITED",
|
|
22
|
+
"TIMEOUT",
|
|
23
|
+
"CANCELLED",
|
|
24
|
+
"TOOL_NOT_FOUND",
|
|
25
|
+
"TOOL_INVALID_ARGUMENTS",
|
|
26
|
+
"TOOL_FAILED",
|
|
27
|
+
"TOOL_DENIED",
|
|
28
|
+
"REGISTRY_LOCKED",
|
|
29
|
+
"REGISTRY_CORRUPT",
|
|
30
|
+
"REGISTRY_TOO_NEW",
|
|
31
|
+
"INVALID_ARGUMENT",
|
|
32
|
+
"INTERNAL",
|
|
33
|
+
];
|
|
34
|
+
/** Codes where trying again later, without user action, can succeed. */
|
|
35
|
+
const RETRYABLE = new Set(["PROVIDER_CRASHED", "RATE_LIMITED", "TIMEOUT", "REGISTRY_LOCKED", "SESSION_BUSY"]);
|
|
36
|
+
export class AiCliError extends Error {
|
|
37
|
+
code;
|
|
38
|
+
meta;
|
|
39
|
+
retryable;
|
|
40
|
+
constructor(code, message, options = {}) {
|
|
41
|
+
super(message, options.cause === undefined ? undefined : { cause: options.cause });
|
|
42
|
+
this.name = "AiCliError";
|
|
43
|
+
this.code = code;
|
|
44
|
+
this.meta = options.meta;
|
|
45
|
+
this.retryable = options.retryable ?? RETRYABLE.has(code);
|
|
46
|
+
}
|
|
47
|
+
toJSON() {
|
|
48
|
+
return { code: this.code, message: this.message, retryable: this.retryable, ...(this.meta ? { meta: this.meta } : {}) };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export const isAiCliError = (value) => value instanceof AiCliError;
|
|
52
|
+
/** Wraps anything thrown into an AiCliError, keeping the original as the cause. */
|
|
53
|
+
export function toAiCliError(value, fallback = "INTERNAL") {
|
|
54
|
+
if (value instanceof AiCliError)
|
|
55
|
+
return value;
|
|
56
|
+
const message = value instanceof Error ? value.message : String(value);
|
|
57
|
+
return new AiCliError(fallback, message, { cause: value });
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,kBAAkB;IAClB,aAAa;IACb,kBAAkB;IAClB,wBAAwB;IACxB,mBAAmB;IACnB,sBAAsB;IACtB,iBAAiB;IACjB,cAAc;IACd,gBAAgB;IAChB,cAAc;IACd,oBAAoB;IACpB,uBAAuB;IACvB,kBAAkB;IAClB,mBAAmB;IACnB,gBAAgB;IAChB,cAAc;IACd,SAAS;IACT,WAAW;IACX,gBAAgB;IAChB,wBAAwB;IACxB,aAAa;IACb,aAAa;IACb,i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,YAAY,UAAU;QAAE,OAAO,KAAK,CAAC;IAC9C,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,IAAI,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7D,CAAC"}
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { SerializedError } from "./errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* Normalized events. Every provider's protocol is translated into these, so
|
|
4
|
+
* applications never read provider-specific messages.
|
|
5
|
+
*/
|
|
6
|
+
/** Progress phases an application can show without exposing protocol details. */
|
|
7
|
+
export type ActivityPhase = "preparing" | "thinking" | "reading" | "researching" | "applying";
|
|
8
|
+
/**
|
|
9
|
+
* Usage as the provider reports it. A missing field is unknown, never zero.
|
|
10
|
+
* `observedAt` is when the provider reported it, for freshness display.
|
|
11
|
+
*/
|
|
12
|
+
export interface Usage {
|
|
13
|
+
inputTokens?: number;
|
|
14
|
+
outputTokens?: number;
|
|
15
|
+
cachedInputTokens?: number;
|
|
16
|
+
costUsd?: number;
|
|
17
|
+
/** Account-level limit: the most used window, as a fraction from 0 to 1, when the provider exposes it. */
|
|
18
|
+
limitUsed?: number;
|
|
19
|
+
limitResetsAt?: string;
|
|
20
|
+
/** Every limit window the provider reported (e.g. `five_hour`, `seven_day`). */
|
|
21
|
+
windows?: LimitWindow[];
|
|
22
|
+
observedAt: string;
|
|
23
|
+
}
|
|
24
|
+
export interface LimitWindow {
|
|
25
|
+
/** `five_hour`, `seven_day`, or the provider's own name for another window. */
|
|
26
|
+
name: string;
|
|
27
|
+
used: number;
|
|
28
|
+
resetsAt?: string;
|
|
29
|
+
}
|
|
30
|
+
/** The account-level fields of a usage report, from its windows: the most used one leads. */
|
|
31
|
+
export declare function fromWindows(windows: LimitWindow[]): Pick<Usage, "limitUsed" | "limitResetsAt" | "windows">;
|
|
32
|
+
/** Identifies what an event belongs to. `requestId` is absent for session-level events. */
|
|
33
|
+
export interface EventScope {
|
|
34
|
+
appId: string;
|
|
35
|
+
documentId: string;
|
|
36
|
+
accountId: string;
|
|
37
|
+
providerId: string;
|
|
38
|
+
sessionId: string;
|
|
39
|
+
requestId?: string;
|
|
40
|
+
}
|
|
41
|
+
export type SessionCloseReason = "closed" | "accountRemoved" | "disposed";
|
|
42
|
+
export type AiEventBody = {
|
|
43
|
+
type: "sessionOpened";
|
|
44
|
+
resumed: boolean;
|
|
45
|
+
} | {
|
|
46
|
+
type: "textDelta";
|
|
47
|
+
text: string;
|
|
48
|
+
} | {
|
|
49
|
+
type: "activity";
|
|
50
|
+
phase: ActivityPhase;
|
|
51
|
+
detail?: string;
|
|
52
|
+
} | {
|
|
53
|
+
type: "question";
|
|
54
|
+
questionId: string;
|
|
55
|
+
prompt: string;
|
|
56
|
+
options?: string[];
|
|
57
|
+
} | {
|
|
58
|
+
type: "toolStarted";
|
|
59
|
+
callId: string;
|
|
60
|
+
tool: string;
|
|
61
|
+
} | {
|
|
62
|
+
type: "toolCompleted";
|
|
63
|
+
callId: string;
|
|
64
|
+
tool: string;
|
|
65
|
+
ok: boolean;
|
|
66
|
+
errorCode?: string;
|
|
67
|
+
} | {
|
|
68
|
+
type: "usageUpdated";
|
|
69
|
+
usage: Usage;
|
|
70
|
+
}
|
|
71
|
+
/** A user-configured MCP server's connection, reported when the session opens. */
|
|
72
|
+
| {
|
|
73
|
+
type: "mcpServerStatus";
|
|
74
|
+
server: string;
|
|
75
|
+
status: "connected" | "failed";
|
|
76
|
+
tools?: number;
|
|
77
|
+
error?: string;
|
|
78
|
+
} | {
|
|
79
|
+
type: "turnCompleted";
|
|
80
|
+
} | {
|
|
81
|
+
type: "cancelled";
|
|
82
|
+
} | {
|
|
83
|
+
type: "error";
|
|
84
|
+
error: SerializedError;
|
|
85
|
+
} | {
|
|
86
|
+
type: "sessionClosed";
|
|
87
|
+
reason: SessionCloseReason;
|
|
88
|
+
};
|
|
89
|
+
export type AiEventType = AiEventBody["type"];
|
|
90
|
+
/** `seq` increases monotonically per library instance; `at` is an ISO timestamp. */
|
|
91
|
+
export type AiEvent = EventScope & AiEventBody & {
|
|
92
|
+
seq: number;
|
|
93
|
+
at: string;
|
|
94
|
+
};
|
|
95
|
+
export type AiEventListener = (event: AiEvent) => void;
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The account-level fields of a usage report, from its windows: the most used one leads. */
|
|
2
|
+
export function fromWindows(windows) {
|
|
3
|
+
if (!windows.length)
|
|
4
|
+
return {};
|
|
5
|
+
const top = windows.reduce((a, b) => (b.used > a.used ? b : a));
|
|
6
|
+
return { limitUsed: top.used, ...(top.resetsAt ? { limitResetsAt: top.resetsAt } : {}), windows };
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAkCA,6FAA6F;AAC7F,MAAM,UAAU,WAAW,CAAC,OAAsB;IAChD,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAC/B,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;AACpG,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { parseArgs } from "node:util";
|
|
3
|
+
import { createAiCli } from "../engine.js";
|
|
4
|
+
import { bundledProviders } from "../providers.js";
|
|
5
|
+
import { runStdioHost } from "./stdio.js";
|
|
6
|
+
const { values } = parseArgs({
|
|
7
|
+
options: {
|
|
8
|
+
"app-id": { type: "string" },
|
|
9
|
+
"data-dir": { type: "string" },
|
|
10
|
+
fake: { type: "boolean", default: false },
|
|
11
|
+
verbose: { type: "boolean", default: false },
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
if (!values["app-id"]) {
|
|
15
|
+
process.stderr.write("usage: edukors-ai-host --app-id <id> [--data-dir <dir>] [--fake] [--verbose]\n");
|
|
16
|
+
process.exit(2);
|
|
17
|
+
}
|
|
18
|
+
const ai = createAiCli({
|
|
19
|
+
appId: values["app-id"],
|
|
20
|
+
providers: bundledProviders({ fake: values.fake }),
|
|
21
|
+
...(values["data-dir"] ? { dataDir: values["data-dir"] } : {}),
|
|
22
|
+
logSink: (entry) => {
|
|
23
|
+
if (values.verbose || entry.level === "warn" || entry.level === "error")
|
|
24
|
+
process.stderr.write(`[${entry.level}] ${entry.scope}: ${entry.message}\n`);
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const { closed } = runStdioHost({ ai, input: process.stdin, output: process.stdout });
|
|
28
|
+
await closed;
|
|
29
|
+
process.exit(0);
|
|
30
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/host/main.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1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AAO,CAAC,MAAM,EAAE,CAAC,CAAC;AACtF,MAAM,MAAM,CAAC;AACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Readable, Writable } from "node:stream";
|
|
2
|
+
import type { AiCli } from "../engine.js";
|
|
3
|
+
/**
|
|
4
|
+
* The application-host protocol: the library behind a pipe, one JSON object
|
|
5
|
+
* per line. The Tauri app runs it as a sidecar; the Electron app can run it
|
|
6
|
+
* in a worker process. Both speak the same messages.
|
|
7
|
+
*
|
|
8
|
+
* app → host { id, method, params } a request
|
|
9
|
+
* host → app { id, result } | { id, error } its answer
|
|
10
|
+
* host → app { event } a normalized AiEvent
|
|
11
|
+
* host → app { login: { requestId, accountId, url, acceptsCode } }
|
|
12
|
+
* a sign-in address for the user while accounts.connect runs;
|
|
13
|
+
* with acceptsCode, the app collects the pasted code and sends
|
|
14
|
+
* accounts.submitCode
|
|
15
|
+
* host → app { id: "h:<n>", method: "tool.call", params } the host asks the app to run a tool
|
|
16
|
+
* host → app { id: "h:<n>", method: "tool.authorize", params }
|
|
17
|
+
* the host asks the app whether a call to one of the user's MCP
|
|
18
|
+
* servers may go ahead; the app answers { allow, message? }
|
|
19
|
+
* app → host { id: "h:<n>", result } | { id: "h:<n>", error }
|
|
20
|
+
*
|
|
21
|
+
* The first line the host writes is { ready: { protocol, version } }.
|
|
22
|
+
* Nothing else is written to the output; diagnostics go to stderr.
|
|
23
|
+
*/
|
|
24
|
+
export declare const HOST_PROTOCOL_VERSION = 1;
|
|
25
|
+
export interface StdioHostOptions {
|
|
26
|
+
ai: AiCli;
|
|
27
|
+
input: Readable;
|
|
28
|
+
output: Writable;
|
|
29
|
+
/** How long the app has to answer a tool call. */
|
|
30
|
+
toolTimeoutMs?: number;
|
|
31
|
+
}
|
|
32
|
+
export declare function runStdioHost({ ai, input, output, toolTimeoutMs }: StdioHostOptions): {
|
|
33
|
+
closed: Promise<void>;
|
|
34
|
+
};
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AiCliError, toAiCliError } from "../errors.js";
|
|
3
|
+
import { readLines } from "../platform/process.js";
|
|
4
|
+
import { VERSION } from "../version.js";
|
|
5
|
+
import { isAbsolute } from "node:path";
|
|
6
|
+
import { listSkills } from "../skills.js";
|
|
7
|
+
/**
|
|
8
|
+
* The application-host protocol: the library behind a pipe, one JSON object
|
|
9
|
+
* per line. The Tauri app runs it as a sidecar; the Electron app can run it
|
|
10
|
+
* in a worker process. Both speak the same messages.
|
|
11
|
+
*
|
|
12
|
+
* app → host { id, method, params } a request
|
|
13
|
+
* host → app { id, result } | { id, error } its answer
|
|
14
|
+
* host → app { event } a normalized AiEvent
|
|
15
|
+
* host → app { login: { requestId, accountId, url, acceptsCode } }
|
|
16
|
+
* a sign-in address for the user while accounts.connect runs;
|
|
17
|
+
* with acceptsCode, the app collects the pasted code and sends
|
|
18
|
+
* accounts.submitCode
|
|
19
|
+
* host → app { id: "h:<n>", method: "tool.call", params } the host asks the app to run a tool
|
|
20
|
+
* host → app { id: "h:<n>", method: "tool.authorize", params }
|
|
21
|
+
* the host asks the app whether a call to one of the user's MCP
|
|
22
|
+
* servers may go ahead; the app answers { allow, message? }
|
|
23
|
+
* app → host { id: "h:<n>", result } | { id: "h:<n>", error }
|
|
24
|
+
*
|
|
25
|
+
* The first line the host writes is { ready: { protocol, version } }.
|
|
26
|
+
* Nothing else is written to the output; diagnostics go to stderr.
|
|
27
|
+
*/
|
|
28
|
+
export const HOST_PROTOCOL_VERSION = 1;
|
|
29
|
+
const ToolSpecSchema = z.object({ name: z.string(), description: z.string(), inputSchema: z.record(z.string(), z.unknown()) });
|
|
30
|
+
const Options = z.object({ model: z.string().optional(), effort: z.string().optional() });
|
|
31
|
+
const Account = z.object({ accountId: z.string() });
|
|
32
|
+
const SessionRef = z.object({ sessionId: z.string() });
|
|
33
|
+
const METHODS = {
|
|
34
|
+
"providers.list": z.object({}),
|
|
35
|
+
"providers.detect": z.object({ providerId: z.string().optional(), refresh: z.boolean().optional() }),
|
|
36
|
+
"providers.capabilities": z.object({ providerId: z.string() }),
|
|
37
|
+
"accounts.list": z.object({}),
|
|
38
|
+
"accounts.create": z.object({ providerId: z.string(), label: z.string().optional() }),
|
|
39
|
+
"accounts.rename": Account.extend({ label: z.string() }),
|
|
40
|
+
"accounts.remove": Account.extend({ deleteData: z.boolean().optional() }),
|
|
41
|
+
"accounts.connect": Account,
|
|
42
|
+
"accounts.submitCode": Account.extend({ code: z.string() }),
|
|
43
|
+
"accounts.status": Account,
|
|
44
|
+
"accounts.logout": Account,
|
|
45
|
+
"models.list": Account,
|
|
46
|
+
"usage.read": Account,
|
|
47
|
+
"session.open": z.object({
|
|
48
|
+
accountId: z.string(),
|
|
49
|
+
documentId: z.string(),
|
|
50
|
+
instructions: z.string().optional(),
|
|
51
|
+
tools: z.array(ToolSpecSchema).optional(),
|
|
52
|
+
options: Options.optional(),
|
|
53
|
+
resumeId: z.string().optional(),
|
|
54
|
+
mcpServers: z.record(z.string(), z.unknown()).optional(),
|
|
55
|
+
skillsDir: z.string().optional(),
|
|
56
|
+
}),
|
|
57
|
+
"session.send": SessionRef.extend({ text: z.string(), requestId: z.string().optional(), context: z.string().optional() }),
|
|
58
|
+
"session.interrupt": SessionRef,
|
|
59
|
+
"session.answer": SessionRef.extend({ questionId: z.string(), answer: z.string() }),
|
|
60
|
+
"session.updateOptions": SessionRef.extend({ options: Options }),
|
|
61
|
+
"session.close": SessionRef,
|
|
62
|
+
"diagnostics.report": z.object({}),
|
|
63
|
+
/** The skills in a folder, for the settings screen. */
|
|
64
|
+
"skills.list": z.object({ dir: z.string() }),
|
|
65
|
+
/** Aborts a pending request that supports it (accounts.connect). */
|
|
66
|
+
cancel: z.object({ requestId: z.union([z.string(), z.number()]) }),
|
|
67
|
+
};
|
|
68
|
+
const Message = z.object({
|
|
69
|
+
id: z.union([z.string(), z.number()]),
|
|
70
|
+
method: z.string().optional(),
|
|
71
|
+
params: z.unknown().optional(),
|
|
72
|
+
result: z.unknown().optional(),
|
|
73
|
+
error: z.object({ code: z.string().optional(), message: z.string().optional() }).optional(),
|
|
74
|
+
});
|
|
75
|
+
const ToolReply = z.object({ content: z.string(), isError: z.boolean().optional() });
|
|
76
|
+
const AuthorizeReply = z.object({ allow: z.boolean(), message: z.string().optional() });
|
|
77
|
+
export function runStdioHost({ ai, input, output, toolTimeoutMs = 120_000 }) {
|
|
78
|
+
const log = ai.diagnostics.scoped("host");
|
|
79
|
+
const write = (msg) => output.write(JSON.stringify(msg) + "\n");
|
|
80
|
+
const sessions = new Map();
|
|
81
|
+
const aborts = new Map();
|
|
82
|
+
/** Requests to the app waiting for its answer: tool calls and authorizations. */
|
|
83
|
+
const toolCalls = new Map();
|
|
84
|
+
/** Asks the app something and waits; the timeout answers with `fallback`. */
|
|
85
|
+
const askApp = (method, params, parse, fallback) => new Promise((resolve) => {
|
|
86
|
+
const id = `h:${nextToolCall++}`;
|
|
87
|
+
const timer = setTimeout(() => {
|
|
88
|
+
toolCalls.delete(id);
|
|
89
|
+
resolve(fallback);
|
|
90
|
+
}, toolTimeoutMs);
|
|
91
|
+
toolCalls.set(id, { resolve: (result, error) => resolve(parse(result, error)), timer });
|
|
92
|
+
write({ id, method, params });
|
|
93
|
+
});
|
|
94
|
+
const inFlight = new Set();
|
|
95
|
+
let nextToolCall = 1;
|
|
96
|
+
ai.onEvent((event) => write({ event }));
|
|
97
|
+
/** A tool whose work happens in the application, across the pipe. */
|
|
98
|
+
const remoteTool = (spec, sessionId) => ({
|
|
99
|
+
...spec,
|
|
100
|
+
run: (args, context) => askApp("tool.call", { sessionId: sessionId(), requestId: context.requestId, callId: context.callId, documentId: context.documentId, name: spec.name, args }, (result, error) => {
|
|
101
|
+
const reply = ToolReply.safeParse(result);
|
|
102
|
+
return error || !reply.success ? { content: error?.message ?? "The editor returned an invalid tool result.", isError: true } : reply.data;
|
|
103
|
+
}, { content: "The editor did not answer in time.", isError: true }),
|
|
104
|
+
});
|
|
105
|
+
const session = (id) => {
|
|
106
|
+
const found = sessions.get(id);
|
|
107
|
+
if (!found)
|
|
108
|
+
throw new AiCliError("SESSION_CLOSED", "no such session", { meta: { sessionId: id } });
|
|
109
|
+
return found;
|
|
110
|
+
};
|
|
111
|
+
async function handle(id, method, raw) {
|
|
112
|
+
const parsed = METHODS[method].safeParse(raw ?? {});
|
|
113
|
+
if (!parsed.success)
|
|
114
|
+
throw new AiCliError("INVALID_ARGUMENT", z.prettifyError(parsed.error), { meta: { method } });
|
|
115
|
+
const p = parsed.data;
|
|
116
|
+
switch (method) {
|
|
117
|
+
case "providers.list":
|
|
118
|
+
return ai.providers();
|
|
119
|
+
case "providers.detect":
|
|
120
|
+
return p.providerId ? [await ai.detect(p.providerId, { refresh: p.refresh })] : ai.detectAll({ refresh: p.refresh });
|
|
121
|
+
case "providers.capabilities":
|
|
122
|
+
return ai.capabilities(p.providerId);
|
|
123
|
+
case "accounts.list":
|
|
124
|
+
return ai.listAccounts();
|
|
125
|
+
case "accounts.create":
|
|
126
|
+
return ai.createAccount({ providerId: p.providerId, label: p.label });
|
|
127
|
+
case "accounts.rename":
|
|
128
|
+
return ai.renameAccount(p.accountId, p.label);
|
|
129
|
+
case "accounts.remove":
|
|
130
|
+
await ai.removeAccount(p.accountId, { deleteData: p.deleteData });
|
|
131
|
+
return null;
|
|
132
|
+
case "accounts.connect": {
|
|
133
|
+
const controller = new AbortController();
|
|
134
|
+
aborts.set(id, controller);
|
|
135
|
+
try {
|
|
136
|
+
return await ai.connectAccount(p.accountId, {
|
|
137
|
+
signal: controller.signal,
|
|
138
|
+
onLogin: (prompt) => write({ login: { requestId: id, accountId: p.accountId, ...prompt } }),
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
aborts.delete(id);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
case "accounts.submitCode":
|
|
146
|
+
ai.submitLoginCode(p.accountId, p.code);
|
|
147
|
+
return null;
|
|
148
|
+
case "accounts.status":
|
|
149
|
+
return ai.accountStatus(p.accountId);
|
|
150
|
+
case "accounts.logout":
|
|
151
|
+
await ai.logoutAccount(p.accountId);
|
|
152
|
+
return null;
|
|
153
|
+
case "models.list":
|
|
154
|
+
return ai.listModels(p.accountId);
|
|
155
|
+
case "usage.read":
|
|
156
|
+
return ai.readUsage(p.accountId);
|
|
157
|
+
case "session.open": {
|
|
158
|
+
let sessionId = "";
|
|
159
|
+
const tools = (p.tools ?? []).map((t) => remoteTool(t, () => sessionId));
|
|
160
|
+
const opened = await ai.openSession({
|
|
161
|
+
accountId: p.accountId,
|
|
162
|
+
documentId: p.documentId,
|
|
163
|
+
instructions: p.instructions,
|
|
164
|
+
tools,
|
|
165
|
+
options: p.options,
|
|
166
|
+
resumeId: p.resumeId,
|
|
167
|
+
...(p.mcpServers ? { mcpServers: p.mcpServers } : {}),
|
|
168
|
+
...(p.skillsDir ? { skillsDir: p.skillsDir } : {}),
|
|
169
|
+
authorize: ({ signal: _signal, ...request }) => askApp("tool.authorize", { sessionId, ...request }, (result, error) => {
|
|
170
|
+
const reply = AuthorizeReply.safeParse(result);
|
|
171
|
+
return error || !reply.success ? { allow: false, message: error?.message ?? "The editor gave no valid answer." } : reply.data.allow ? { allow: true } : { allow: false, ...(reply.data.message ? { message: reply.data.message } : {}) };
|
|
172
|
+
}, { allow: false, message: "The editor did not answer in time." }),
|
|
173
|
+
});
|
|
174
|
+
sessionId = opened.id;
|
|
175
|
+
sessions.set(opened.id, opened);
|
|
176
|
+
opened.on((e) => e.type === "sessionClosed" && sessions.delete(opened.id));
|
|
177
|
+
return { sessionId: opened.id, resumeId: opened.resumeId ?? null };
|
|
178
|
+
}
|
|
179
|
+
case "session.send":
|
|
180
|
+
return session(p.sessionId).send(p.text, { requestId: p.requestId, context: p.context });
|
|
181
|
+
case "session.interrupt":
|
|
182
|
+
await session(p.sessionId).interrupt();
|
|
183
|
+
return null;
|
|
184
|
+
case "session.answer":
|
|
185
|
+
session(p.sessionId).answer(p.questionId, p.answer);
|
|
186
|
+
return null;
|
|
187
|
+
case "session.updateOptions":
|
|
188
|
+
await session(p.sessionId).updateOptions(p.options);
|
|
189
|
+
return null;
|
|
190
|
+
case "session.close":
|
|
191
|
+
await session(p.sessionId).close();
|
|
192
|
+
return null;
|
|
193
|
+
case "diagnostics.report":
|
|
194
|
+
return ai.diagnosticReport();
|
|
195
|
+
case "skills.list":
|
|
196
|
+
if (!isAbsolute(p.dir))
|
|
197
|
+
throw new AiCliError("INVALID_ARGUMENT", "dir must be an absolute path");
|
|
198
|
+
return listSkills(p.dir);
|
|
199
|
+
case "cancel":
|
|
200
|
+
aborts.get(p.requestId)?.abort();
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
readLines(input, (line) => {
|
|
205
|
+
if (!line.trim())
|
|
206
|
+
return;
|
|
207
|
+
let message;
|
|
208
|
+
try {
|
|
209
|
+
message = Message.parse(JSON.parse(line));
|
|
210
|
+
}
|
|
211
|
+
catch (e) {
|
|
212
|
+
log.warn("ignored an invalid message", { line: line.slice(0, 200) });
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const { id } = message;
|
|
216
|
+
// An answer to a tool call.
|
|
217
|
+
if (typeof id === "string" && id.startsWith("h:") && !message.method) {
|
|
218
|
+
const pending = toolCalls.get(id);
|
|
219
|
+
if (!pending)
|
|
220
|
+
return;
|
|
221
|
+
toolCalls.delete(id);
|
|
222
|
+
clearTimeout(pending.timer);
|
|
223
|
+
pending.resolve(message.result, message.error ?? undefined);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const method = message.method;
|
|
227
|
+
if (!method || !(method in METHODS)) {
|
|
228
|
+
write({ id, error: new AiCliError("INVALID_ARGUMENT", `unknown method: ${method}`).toJSON() });
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const work = handle(id, method, message.params).then((result) => write({ id, result: result ?? null }), (e) => write({ id, error: toAiCliError(e).toJSON() }));
|
|
232
|
+
inFlight.add(work);
|
|
233
|
+
void work.finally(() => inFlight.delete(work));
|
|
234
|
+
});
|
|
235
|
+
const closed = new Promise((resolve) => {
|
|
236
|
+
input.on("end", async () => {
|
|
237
|
+
// The application stopped writing: tools can no longer be answered, and
|
|
238
|
+
// running requests are stopped, but every request still gets its answer.
|
|
239
|
+
for (const pending of toolCalls.values()) {
|
|
240
|
+
clearTimeout(pending.timer);
|
|
241
|
+
pending.resolve(undefined, { message: "The editor closed." });
|
|
242
|
+
}
|
|
243
|
+
for (const controller of aborts.values())
|
|
244
|
+
controller.abort();
|
|
245
|
+
const settled = Promise.allSettled([...inFlight]);
|
|
246
|
+
await ai.dispose();
|
|
247
|
+
await settled;
|
|
248
|
+
resolve();
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
write({ ready: { protocol: HOST_PROTOCOL_VERSION, version: VERSION } });
|
|
252
|
+
return { closed };
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=stdio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["../../src/host/stdio.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAA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G,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QAC3C,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE;YACzB,wEAAwE;YACxE,yEAAyE;YACzE,KAAK,MAAM,OAAO,IAAI,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;gBACzC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBAC5B,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAC;YAChE,CAAC;YACD,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE;gBAAE,UAAU,CAAC,KAAK,EAAE,CAAC;YAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;YAClD,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,OAAO,CAAC;YACd,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,qBAAqB,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IACxE,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export { AiCli, createAiCli } from "./engine.js";
|
|
2
|
+
export type { AccountInfo, AiCliOptions, DiagnosticReport, OpenSessionOptions } from "./engine.js";
|
|
3
|
+
export { AiSession } from "./session.js";
|
|
4
|
+
export type { AuthorizationDecision, AuthorizationRequest, Authorizer, SendOptions, SessionState, TurnResult } from "./session.js";
|
|
5
|
+
export { checkServers, McpServerSpecSchema } from "./mcp/external.js";
|
|
6
|
+
export { parseMcpConfig } from "./mcp/config.js";
|
|
7
|
+
export type { McpProblem, McpProblemCode } from "./mcp/config.js";
|
|
8
|
+
export { listSkills, readSkillFile } from "./skills.js";
|
|
9
|
+
export type { SkillInfo } from "./skills.js";
|
|
10
|
+
export type { McpServerSpec } from "./mcp/external.js";
|
|
11
|
+
export { AiCliError, ERROR_CODES, isAiCliError, toAiCliError } from "./errors.js";
|
|
12
|
+
export type { ErrorCode, ErrorMeta, SerializedError } from "./errors.js";
|
|
13
|
+
export { fromWindows } from "./events.js";
|
|
14
|
+
export type { LimitWindow } from "./events.js";
|
|
15
|
+
export type { ActivityPhase, AiEvent, AiEventBody, AiEventListener, AiEventType, EventScope, SessionCloseReason, Usage } from "./events.js";
|
|
16
|
+
export type { AccountContext, AccountState, AccountStatus, Capabilities, Detection, DetectionStatus, ExternalServer, LoginChannel, LoginPrompt, ModelInfo, ProviderAdapter, ProviderSession, SessionContext, SessionHooks, SessionOptions, TurnInput, TurnOutcome, TurnSink, } from "./provider.js";
|
|
17
|
+
export { defineTool } from "./tools.js";
|
|
18
|
+
export type { ToolCallContext, ToolDefinition, ToolResult, ToolSpec, ValidationResult } from "./tools.js";
|
|
19
|
+
export { Diagnostics } from "./diagnostics.js";
|
|
20
|
+
export type { DiagnosticEntry, LogLevel, LogSink, ScopedLog } from "./diagnostics.js";
|
|
21
|
+
export { redactText, redactValue } from "./redact.js";
|
|
22
|
+
export { buildEnv, commonBinDirs } from "./platform/env.js";
|
|
23
|
+
export { compareVersions, findExecutable, readVersion } from "./platform/discovery.js";
|
|
24
|
+
export { ManagedProcess, killAllSync, readLines, runCommand } from "./platform/process.js";
|
|
25
|
+
export { DataPaths, defaultDataDir, documentKey } from "./platform/paths.js";
|
|
26
|
+
export { AccountRegistry, REGISTRY_SCHEMA_VERSION } from "./registry/registry.js";
|
|
27
|
+
export type { AccountRecord } from "./registry/registry.js";
|
|
28
|
+
export { VERSION } from "./version.js";
|
|
29
|
+
export { bundledProviders } from "./providers.js";
|
|
30
|
+
export { createClaudeProvider } from "./providers/claude/adapter.js";
|
|
31
|
+
export type { ClaudeProviderOptions } from "./providers/claude/adapter.js";
|
|
32
|
+
export { createCodexProvider } from "./providers/codex/adapter.js";
|
|
33
|
+
export type { CodexProviderOptions } from "./providers/codex/adapter.js";
|
|
34
|
+
export { createToolMcpServer, startToolBridge, TOOL_SERVER_NAME } from "./mcp/toolServer.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { AiCli, createAiCli } from "./engine.js";
|
|
2
|
+
export { AiSession } from "./session.js";
|
|
3
|
+
export { checkServers, McpServerSpecSchema } from "./mcp/external.js";
|
|
4
|
+
export { parseMcpConfig } from "./mcp/config.js";
|
|
5
|
+
export { listSkills, readSkillFile } from "./skills.js";
|
|
6
|
+
export { AiCliError, ERROR_CODES, isAiCliError, toAiCliError } from "./errors.js";
|
|
7
|
+
export { fromWindows } from "./events.js";
|
|
8
|
+
export { defineTool } from "./tools.js";
|
|
9
|
+
export { Diagnostics } from "./diagnostics.js";
|
|
10
|
+
export { redactText, redactValue } from "./redact.js";
|
|
11
|
+
export { buildEnv, commonBinDirs } from "./platform/env.js";
|
|
12
|
+
export { compareVersions, findExecutable, readVersion } from "./platform/discovery.js";
|
|
13
|
+
export { ManagedProcess, killAllSync, readLines, runCommand } from "./platform/process.js";
|
|
14
|
+
export { DataPaths, defaultDataDir, documentKey } from "./platform/paths.js";
|
|
15
|
+
export { AccountRegistry, REGISTRY_SCHEMA_VERSION } from "./registry/registry.js";
|
|
16
|
+
export { VERSION } from "./version.js";
|
|
17
|
+
export { bundledProviders } from "./providers.js";
|
|
18
|
+
export { createClaudeProvider } from "./providers/claude/adapter.js";
|
|
19
|
+
export { createCodexProvider } from "./providers/codex/adapter.js";
|
|
20
|
+
export { createToolMcpServer, startToolBridge, TOOL_SERVER_NAME } from "./mcp/toolServer.js";
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
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8BAA8B,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { McpServerSpec } from "./external.js";
|
|
2
|
+
/**
|
|
3
|
+
* The user's MCP servers as written in an editor's settings: the text of a
|
|
4
|
+
* Claude Code `.mcp.json` (`{ "mcpServers": { ... } }`), or just the object of
|
|
5
|
+
* servers, so that what a server's documentation says to paste is what goes
|
|
6
|
+
* in. Problems are stable codes the editor translates, all of them at once.
|
|
7
|
+
*/
|
|
8
|
+
export type McpProblemCode = "notJson" | "notServers" | "reserved" | "badName" | "notObject" | "noCommand" | "noUrl" | "badField" | "badType";
|
|
9
|
+
export interface McpProblem {
|
|
10
|
+
code: McpProblemCode;
|
|
11
|
+
server?: string;
|
|
12
|
+
field?: string;
|
|
13
|
+
detail?: string;
|
|
14
|
+
}
|
|
15
|
+
/** The valid servers, and every problem found. Empty text is no servers. */
|
|
16
|
+
export declare function parseMcpConfig(input: string | unknown): {
|
|
17
|
+
servers: Record<string, McpServerSpec>;
|
|
18
|
+
problems: McpProblem[];
|
|
19
|
+
};
|