@happyvertical/smrt-inference 0.60.18 → 0.61.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.
Files changed (82) hide show
  1. package/AGENTS.md +35 -1
  2. package/README.md +86 -0
  3. package/agents/design-runs.md +110 -0
  4. package/agents/engines.md +458 -0
  5. package/dist/agent-cli/credentials.d.ts +28 -0
  6. package/dist/agent-cli/credentials.d.ts.map +1 -0
  7. package/dist/agent-cli/detect.d.ts +28 -0
  8. package/dist/agent-cli/detect.d.ts.map +1 -0
  9. package/dist/agent-cli/env.d.ts +14 -0
  10. package/dist/agent-cli/env.d.ts.map +1 -0
  11. package/dist/agent-cli/locate.d.ts +16 -0
  12. package/dist/agent-cli/locate.d.ts.map +1 -0
  13. package/dist/agent-cli/login.d.ts +30 -0
  14. package/dist/agent-cli/login.d.ts.map +1 -0
  15. package/dist/agent-cli/runner.d.ts +31 -0
  16. package/dist/agent-cli/runner.d.ts.map +1 -0
  17. package/dist/agent-cli/service.d.ts +20 -0
  18. package/dist/agent-cli/service.d.ts.map +1 -0
  19. package/dist/agent-cli/session.d.ts +42 -0
  20. package/dist/agent-cli/session.d.ts.map +1 -0
  21. package/dist/agent-cli/stream.d.ts +50 -0
  22. package/dist/agent-cli/stream.d.ts.map +1 -0
  23. package/dist/agent-cli/test-support.d.ts +21 -0
  24. package/dist/agent-cli/test-support.d.ts.map +1 -0
  25. package/dist/agent-cli/test-support.js +67 -0
  26. package/dist/agent-cli/test-support.js.map +1 -0
  27. package/dist/agent-cli/tools.d.ts +19 -0
  28. package/dist/agent-cli/tools.d.ts.map +1 -0
  29. package/dist/agent-cli/turn.d.ts +138 -0
  30. package/dist/agent-cli/turn.d.ts.map +1 -0
  31. package/dist/chatgpt/connection.d.ts +149 -0
  32. package/dist/chatgpt/connection.d.ts.map +1 -0
  33. package/dist/chatgpt/model.d.ts +42 -0
  34. package/dist/chatgpt/model.d.ts.map +1 -0
  35. package/dist/chatgpt/resolver.d.ts +39 -0
  36. package/dist/chatgpt/resolver.d.ts.map +1 -0
  37. package/dist/chatgpt/support.d.ts +36 -0
  38. package/dist/chatgpt/support.d.ts.map +1 -0
  39. package/dist/chunks/{InferenceOverrideCollection-BS_hqxS9.js → InferenceOverrideCollection-Dc3mkL-1.js} +62 -3
  40. package/dist/chunks/InferenceOverrideCollection-Dc3mkL-1.js.map +1 -0
  41. package/dist/chunks/work-profiles-DCgIbilc.js +484 -0
  42. package/dist/chunks/work-profiles-DCgIbilc.js.map +1 -0
  43. package/dist/design-run-store.d.ts +26 -0
  44. package/dist/design-run-store.d.ts.map +1 -0
  45. package/dist/design-run.d.ts +146 -0
  46. package/dist/design-run.d.ts.map +1 -0
  47. package/dist/engine-id.d.ts +5 -0
  48. package/dist/engine-id.d.ts.map +1 -0
  49. package/dist/engine-model.d.ts +56 -0
  50. package/dist/engine-model.d.ts.map +1 -0
  51. package/dist/engine-status.d.ts +37 -0
  52. package/dist/engine-status.d.ts.map +1 -0
  53. package/dist/index.d.ts +3 -0
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +2 -1
  56. package/dist/index.js.map +1 -1
  57. package/dist/manifest.json +182 -1
  58. package/dist/models/DesignRunRecord.d.ts +22 -0
  59. package/dist/models/DesignRunRecord.d.ts.map +1 -0
  60. package/dist/models.d.ts +1 -0
  61. package/dist/models.d.ts.map +1 -1
  62. package/dist/models.js +2 -2
  63. package/dist/node.js +1 -1
  64. package/dist/node.js.map +1 -1
  65. package/dist/server.d.ts +24 -0
  66. package/dist/server.d.ts.map +1 -1
  67. package/dist/server.js +2471 -150
  68. package/dist/server.js.map +1 -1
  69. package/dist/settings/controller.d.ts +111 -0
  70. package/dist/settings/controller.d.ts.map +1 -0
  71. package/dist/settings/host.d.ts +75 -0
  72. package/dist/settings/host.d.ts.map +1 -0
  73. package/dist/settings/key-store.d.ts +35 -0
  74. package/dist/settings/key-store.d.ts.map +1 -0
  75. package/dist/settings/resolver.d.ts +6 -2
  76. package/dist/settings/resolver.d.ts.map +1 -1
  77. package/dist/smrt-knowledge.json +93 -7
  78. package/dist/smrt-knowledge.okf.md +15 -5
  79. package/dist/work-profiles.d.ts +127 -0
  80. package/dist/work-profiles.d.ts.map +1 -0
  81. package/package.json +15 -10
  82. package/dist/chunks/InferenceOverrideCollection-BS_hqxS9.js.map +0 -1
@@ -0,0 +1,31 @@
1
+ import { type ChildProcess } from 'node:child_process';
2
+ export interface RunOptions {
3
+ command: string;
4
+ args: readonly string[];
5
+ cwd?: string;
6
+ env: Record<string, string>;
7
+ /** Written to stdin, then stdin is closed. */
8
+ stdin?: string;
9
+ signal?: AbortSignal;
10
+ /** The child is killed after this long. */
11
+ timeoutMs: number;
12
+ onStdoutLine?(line: string): void;
13
+ }
14
+ export interface RunResult {
15
+ exitCode: number | null;
16
+ termination: NodeJS.Signals | null;
17
+ timedOut: boolean;
18
+ aborted: boolean;
19
+ /** Set when the process could not be started at all (`ENOENT`, ...). */
20
+ spawnError?: string;
21
+ stderrTail: string;
22
+ }
23
+ /** Ask the tree to stop, then force it. */
24
+ export declare function killTree(child: ChildProcess): void;
25
+ export declare function runProcess(options: RunOptions): Promise<RunResult>;
26
+ export interface CollectResult extends RunResult {
27
+ stdout: string;
28
+ }
29
+ /** Run a short command and collect its stdout (bounded). */
30
+ export declare function runCollect(options: Omit<RunOptions, 'onStdoutLine'>, maxChars?: number): Promise<CollectResult>;
31
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/agent-cli/runner.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,YAAY,EAAS,MAAM,oBAAoB,CAAC;AAM9D,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAqCD,2CAA2C;AAC3C,wBAAgB,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAKlD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAuGlE;AAED,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,4DAA4D;AAC5D,wBAAsB,UAAU,CAC9B,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,EACzC,QAAQ,SAAS,GAChB,OAAO,CAAC,aAAa,CAAC,CAaxB"}
@@ -0,0 +1,20 @@
1
+ import { type AgentCliStatus } from './detect.js';
2
+ import { type LocateDeps } from './locate.js';
3
+ import { AgentLogin } from './login.js';
4
+ import { type AgentTool } from './tools.js';
5
+ /** A host-local cache and sign-in manager. Never reads CLI credential stores. */
6
+ export declare function createAgentCliService(initialDeps?: LocateDeps | null): {
7
+ configureAgentCli: (next: LocateDeps | null) => void;
8
+ invalidateCliStatus: (tool?: AgentTool) => void;
9
+ agentLogin: () => AgentLogin;
10
+ cliStatus: (tool: AgentTool, options?: {
11
+ fresh?: boolean;
12
+ protection?: boolean;
13
+ }) => Promise<AgentCliStatus>;
14
+ allCliStatus: (options?: {
15
+ fresh?: boolean;
16
+ protection?: boolean;
17
+ }) => Promise<AgentCliStatus[]>;
18
+ agentCliDeps: () => LocateDeps;
19
+ };
20
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/agent-cli/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,aAAa,CAAC;AAClE,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAEzD,iFAAiF;AACjF,wBAAgB,qBAAqB,CAAC,WAAW,GAAE,UAAU,GAAG,IAAW;8BAYxC,UAAU,GAAG,IAAI,KAAG,IAAI;iCAMrB,SAAS,KAAG,IAAI;sBAQ7B,UAAU;sBAUzB,SAAS,YACN;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,KACjD,OAAO,CAAC,cAAc,CAAC;6BAef;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,KACjD,OAAO,CAAC,cAAc,EAAE,CAAC;wBA/CX,UAAU;EA2D5B"}
@@ -0,0 +1,42 @@
1
+ import { type ResolvedWorkProfile } from '../work-profiles.js';
2
+ import type { AgentCliLocation } from './detect.js';
3
+ import { type AgentEvent } from './stream.js';
4
+ import type { AgentTool } from './tools.js';
5
+ /** The environment variable that carries the MCP token to the child. */
6
+ export declare const TOKEN_ENV = "SMRT_SHELL_MCP_TOKEN";
7
+ export interface AgentRunSpec {
8
+ command: string;
9
+ args: string[];
10
+ cwd: string;
11
+ env: Record<string, string>;
12
+ stdin: string;
13
+ parse(line: string): AgentEvent[];
14
+ /** The id a later turn resumes with (known up front for Claude Code). */
15
+ sessionId: string | null;
16
+ /** Remove the per-run files. */
17
+ cleanup(): void;
18
+ }
19
+ export interface SpecInput {
20
+ /** Owner-confirmed app setting; omitted keeps the protected invocation. */
21
+ protection?: boolean;
22
+ tool: AgentTool;
23
+ profile?: ResolvedWorkProfile;
24
+ outputSchema?: Record<string, unknown>;
25
+ location: AgentCliLocation;
26
+ /** Host-owned engine state under app data: holds `work/` and temporary `run/`. */
27
+ stateDir: string;
28
+ /** Loopback URL of the shell's `/mcp` route. */
29
+ mcpUrl: string;
30
+ token: string;
31
+ /** The assistant guidance for this engine. */
32
+ systemPrompt: string;
33
+ prompt: string;
34
+ /** The CLI's own session id from an earlier turn of this thread. */
35
+ resumeId?: string | null;
36
+ baseEnv?: Readonly<Record<string, string | undefined>>;
37
+ }
38
+ /** Only a loopback URL may ever receive the token. */
39
+ export declare function assertLoopbackUrl(value: string): URL;
40
+ /** Build the run: an empty private cwd, a private temp dir, the command. */
41
+ export declare function buildAgentRun(input: SpecInput): AgentRunSpec;
42
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/agent-cli/session.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,EACL,KAAK,UAAU,EAIhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,wEAAwE;AACxE,eAAO,MAAM,SAAS,yBAAyB,CAAC;AAEhD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CAAC;IAClC,yEAAyE;IACzE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gCAAgC;IAChC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,kFAAkF;IAClF,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;CACxD;AAED,sDAAsD;AACtD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAQpD;AAqMD,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,YAAY,CAsB5D"}
@@ -0,0 +1,50 @@
1
+ export type AgentEvent = {
2
+ type: 'session';
3
+ id: string;
4
+ } | {
5
+ type: 'execution_model';
6
+ model: string;
7
+ } | {
8
+ type: 'result_channel';
9
+ name: 'StructuredOutput';
10
+ } | {
11
+ type: 'text';
12
+ delta: string;
13
+ }
14
+ /** A whole message (the tool did not stream it, or it is the last word). */
15
+ | {
16
+ type: 'message';
17
+ text: string;
18
+ } | {
19
+ type: 'tool_use';
20
+ id: string;
21
+ name: string;
22
+ args: string;
23
+ } | {
24
+ type: 'tool_result';
25
+ id: string;
26
+ ok: boolean;
27
+ text: string;
28
+ } | {
29
+ type: 'forbidden';
30
+ what: string;
31
+ kind?: 'unoffered_mcp' | 'unknown_item' | 'confined_builtin' | 'native_builtin';
32
+ } | {
33
+ type: 'done';
34
+ ok: boolean;
35
+ text?: string;
36
+ error?: string;
37
+ tokens?: number;
38
+ };
39
+ /** The MCP server name both tools are given, and so the tool-name prefix. */
40
+ export declare const MCP_SERVER_NAME = "smrt";
41
+ /** A tool name as the shell knows it (`mcp__smrt__app_describe` -> `app_describe`). */
42
+ export declare function shellToolName(name: string): string;
43
+ /** Stateful: Claude Code streams text deltas, then repeats the text whole. */
44
+ export declare function claudeParser(outputSchema?: Record<string, unknown>, protection?: boolean): (line: string) => AgentEvent[];
45
+ /** Codex `exec --json`: whole items, no text deltas. */
46
+ export declare function codexParser(options?: {
47
+ confinedBuiltins?: boolean;
48
+ nativeTools?: boolean;
49
+ }): (line: string) => AgentEvent[];
50
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/agent-cli/stream.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,kBAAkB,CAAA;CAAE,GACpD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACjC,4EAA4E;GAC1E;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5D;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9D;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EACD,eAAe,GACf,cAAc,GACd,kBAAkB,GAClB,gBAAgB,CAAC;CACtB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN,6EAA6E;AAC7E,eAAO,MAAM,eAAe,SAAS,CAAC;AA8BtC,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED,8EAA8E;AAC9E,wBAAgB,YAAY,CAC1B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtC,UAAU,UAAO,IAIT,MAAM,MAAM,KAAG,UAAU,EAAE,CAkHpC;AAgBD,wDAAwD;AACxD,wBAAgB,WAAW,CACzB,OAAO,GAAE;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,IAE3D,MAAM,MAAM,KAAG,UAAU,EAAE,CAiHpC"}
@@ -0,0 +1,21 @@
1
+ import { existsSync } from 'node:fs';
2
+ import type { LocateDeps } from './locate.js';
3
+ import type { AgentTool } from './tools.js';
4
+ export declare function tempDir(prefix?: string): string;
5
+ /** `dir/<binary>` is the stream stub; returns its path. */
6
+ export declare function installStub(dir: string, binary: string): string;
7
+ /**
8
+ * `dir/<binary>`: a shell script that behaves like the real tool's version,
9
+ * status and login commands. Signed in = `$HOME/signed-in` exists; its login
10
+ * command creates it. Every call dumps its environment to `$HOME/env-dump`.
11
+ */
12
+ export declare function installFakeCli(dir: string, tool: AgentTool, options?: {
13
+ version?: string;
14
+ brokenVersion?: boolean;
15
+ brokenHelp?: boolean;
16
+ toolHostDisabled?: boolean;
17
+ }): string;
18
+ /** Lookup deps over a temp HOME and PATH, no login shell. */
19
+ export declare function fakeDeps(home: string, pathDirs: string[], extraEnv?: Record<string, string>): LocateDeps;
20
+ export declare const exists: typeof existsSync;
21
+ //# sourceMappingURL=test-support.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-support.d.ts","sourceRoot":"","sources":["../../src/agent-cli/test-support.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,UAAU,EAIX,MAAM,SAAS,CAAC;AAGjB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,wBAAgB,OAAO,CAAC,MAAM,SAAe,GAAG,MAAM,CAErD;AAED,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAM/D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,SAAS,EACf,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACvB,GACL,MAAM,CAgCR;AAED,6DAA6D;AAC7D,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAAE,EAClB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACpC,UAAU,CAaZ;AAED,eAAO,MAAM,MAAM,mBAAa,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { chmodSync, existsSync, mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ //#region src/agent-cli/test-fixtures/stub-cli.mjs?raw
5
+ var stub_cli_default = "#!/usr/bin/env node\n// A stand-in for `claude` / `codex` for tests: no network, no model. It reads\n// the \"prompt\" from stdin and acts on its first line, emitting the same JSON\n// stream shapes the real tools do:\n//\n// say <text> stream <text>, finish\n// tool <name> <json args> call the shell's /mcp route like a real client\n// (URL from the mcp config / -c override, bearer\n// from SMRT_SHELL_MCP_TOKEN), report the result\n// dump write argv + env names to <cwd>/../dump.json\n// hang start a grandchild, write pids, never finish\n// forbidden emit a tool_use of a built-in tool\n// fail exit 1 with noise on stderr\n// resume say whether it was resumed and with which id\nimport { spawn } from 'node:child_process';\nimport { readFileSync, renameSync, writeFileSync } from 'node:fs';\nimport { basename, dirname, join } from 'node:path';\n\nconst argv = process.argv.slice(2);\nif (argv.includes('--help')) process.exit(0);\nconst isCodex = argv[0] === 'exec';\nconst prompt = readFileSync(0, 'utf8');\nconst [head, ...rest] = prompt.split('\\n')[0].split(' ');\nconst out = (o) => process.stdout.write(`${JSON.stringify(o)}\\n`);\nconst sessionOf = () => {\n // codex: `exec resume <options> <id> -`; claude: `--resume <id>`\n if (isCodex && argv[1] === 'resume')\n return { resumed: true, id: argv[argv.length - 2] };\n const i = argv.indexOf('--resume');\n if (i >= 0) return { resumed: true, id: argv[i + 1] };\n const j = argv.indexOf('--session-id');\n return { resumed: false, id: j >= 0 ? argv[j + 1] : 'codex-thread-1' };\n};\nconst session = sessionOf();\nconst sibling = (name) => join(isCodex && basename(dirname(dirname(process.cwd()))) === 'run' ? dirname(dirname(dirname(process.cwd()))) : dirname(process.cwd()), name);\n\nfunction start() {\n if (isCodex) {\n out({ type: 'thread.started', thread_id: session.id });\n out({ type: 'turn.started' });\n } else {\n out({ type: 'system', subtype: 'init', session_id: session.id, tools: [] });\n }\n}\n\nfunction say(text) {\n if (isCodex) {\n out({ type: 'item.completed', item: { id: 'i', type: 'agent_message', text } });\n out({ type: 'turn.completed', usage: {} });\n return;\n }\n const half = Math.ceil(text.length / 2);\n out({ type: 'stream_event', event: { type: 'message_start' } });\n for (const part of [text.slice(0, half), text.slice(half)])\n out({\n type: 'stream_event',\n event: { type: 'content_block_delta', index: 0, delta: { type: 'text_delta', text: part } },\n });\n out({ type: 'assistant', message: { content: [{ type: 'text', text }] } });\n out({ type: 'result', subtype: 'success', is_error: false, result: text, session_id: session.id });\n}\n\nfunction mcpUrl() {\n if (isCodex) {\n const arg = argv.find((a) => a.startsWith('mcp_servers.smrt.url='));\n return JSON.parse(arg.slice('mcp_servers.smrt.url='.length));\n }\n const file = argv[argv.indexOf('--mcp-config') + 1];\n return JSON.parse(readFileSync(file, 'utf8')).mcpServers.smrt.url;\n}\n\nasync function callTool(name, args) {\n const response = await fetch(mcpUrl(), {\n method: 'POST',\n headers: {\n 'content-type': 'application/json',\n accept: 'application/json, text/event-stream',\n authorization: `Bearer ${process.env.SMRT_SHELL_MCP_TOKEN}`,\n 'mcp-protocol-version': '2026-07-28',\n 'mcp-method': 'tools/call',\n 'mcp-name': name,\n },\n body: JSON.stringify({\n jsonrpc: '2.0',\n id: 1,\n method: 'tools/call',\n params: {\n name,\n arguments: args,\n _meta: {\n 'io.modelcontextprotocol/protocolVersion': '2026-07-28',\n 'io.modelcontextprotocol/clientInfo': { name: 'stub', version: '0' },\n 'io.modelcontextprotocol/clientCapabilities': {},\n },\n },\n }),\n });\n const text = await response.text();\n const data = text.startsWith('{')\n ? text\n : (text.split('\\n').find((l) => l.startsWith('data:')) ?? 'data: {}').slice(5);\n const body = JSON.parse(data);\n return { status: response.status, body };\n}\n\nstart();\nif (head === 'say') {\n say(rest.join(' '));\n} else if (head === 'context') {\n say(JSON.stringify({ prompt, resumed: session.resumed }));\n} else if (head === 'resume') {\n say(`${session.resumed ? 'resumed' : 'new'}:${session.id}`);\n} else if (head === 'tool') {\n const [name, ...json] = rest;\n const args = json.length ? JSON.parse(json.join(' ')) : {};\n const id = 'toolu_1';\n if (isCodex) {\n out({ type: 'item.started', item: { id, type: 'mcp_tool_call', server: 'smrt', tool: name, arguments: args, status: 'in_progress' } });\n } else {\n out({ type: 'assistant', message: { content: [{ type: 'tool_use', id, name: `mcp__smrt__${name}`, input: args }] } });\n }\n const { status, body } = await callTool(name, args);\n const result = body.result ?? {};\n const text = (result.content ?? []).map((c) => c.text ?? '').join('\\n') || JSON.stringify(body);\n const ok = status === 200 && !body.error && result.isError !== true;\n if (isCodex) {\n out({ type: 'item.completed', item: { id, type: 'mcp_tool_call', server: 'smrt', tool: name, arguments: args, result: { content: [{ type: 'text', text }] }, status: ok ? 'completed' : 'failed' } });\n } else {\n out({ type: 'user', message: { content: [{ type: 'tool_result', tool_use_id: id, content: text, is_error: !ok }] } });\n }\n say('All done.');\n} else if (head === 'dump') {\n writeFileSync(\n sibling('dump.json'),\n JSON.stringify({ argv, env: process.env, cwd: process.cwd() }),\n );\n say('dumped');\n} else if (head === 'hang' || head === 'hang-text') {\n const grand = spawn('sleep', ['300'], { stdio: 'ignore' });\n // Hosts use existence as readiness: publish the complete snapshot atomically.\n const snapshot = sibling('pids.json');\n writeFileSync(`${snapshot}.tmp`, JSON.stringify({ child: process.pid, grand: grand.pid }));\n renameSync(`${snapshot}.tmp`, snapshot);\n if (head === 'hang-text') say('callback trigger');\n setInterval(() => {}, 1000);\n} else if (head === 'structured') {\n out({ type: 'assistant', message: { content: [{ type: 'tool_use', id: 'result', name: 'StructuredOutput', input: { raw: 'raw-payload' } }] } });\n out({ type: 'user', message: { content: [{ type: 'tool_result', tool_use_id: 'result', content: 'raw-payload' }] } });\n out({ type: 'result', subtype: 'success', structured_output: { ok: true } });\n} else if (head === 'blocked-name') {\n const name = JSON.parse(rest.join(' '));\n if (isCodex) out({ type: 'item.started', item: { id: 'x', type: 'mcp_tool_call', server: 'smrt', tool: name, arguments: { secret: 'raw-payload' } } });\n else out({ type: 'assistant', message: { content: [{ type: 'tool_use', id: 'x', name, input: { secret: 'raw-payload' } }] } });\n setInterval(() => {}, 1000);\n} else if (head === 'confined') {\n const work = process.cwd();\n writeFileSync(join(work, 'stray-patch'), 'discard me');\n for (const type of ['file_change', 'command_execution']) out({type: 'item.completed', item: {id: type, type, command: 'secret-payload', changes: [{path: 'secret-path'}]}});\n say('App request finished.');\n} else if (head === 'token-echo') {\n const token = process.env.SMRT_SHELL_MCP_TOKEN;\n say(token);\n} else if (head === 'native') {\n if (isCodex) out({ type: 'item.completed', item: { id: 'native', type: 'web_search', query: 'secret-native-payload' } });\n else {\n out({ type: 'assistant', message: { content: [{ type: 'tool_use', id: 'native', name: 'Bash', input: { command: 'secret-native-payload' } }] } });\n out({ type: 'user', message: { content: [{ type: 'tool_result', tool_use_id: 'native', content: 'secret-native-payload' }] } });\n }\n say('Native tool finished.');\n} else if (head === 'forbidden') {\n if (isCodex) out({ type: 'item.completed', item: { id: 'x', type: 'unexpected_remote_tool', command: 'ls' } });\n else out({ type: 'assistant', message: { content: [{ type: 'tool_use', id: 'x', name: 'Bash', input: { command: 'ls' } }] } });\n setInterval(() => {}, 1000);\n} else if (head === 'fail') {\n process.stderr.write('boom secret-in-stderr\\n');\n process.exit(1);\n} else if (head === 'host-disabled') {\n out({ type: 'item.completed', item: { type: 'error', message: 'Code Mode is unavailable because code-mode host is disabled. secret-in-host-error' } });\n say('This answer must never be published.');\n setInterval(() => {}, 1000);\n} else if (head === 'mcp-fail') {\n process.stderr.write('MCP startup failed: secret-in-stderr\\n');\n process.exit(1);\n} else {\n say(`unknown command ${head}`);\n}\n";
6
+ //#endregion
7
+ //#region src/agent-cli/test-support.ts
8
+ function tempDir(prefix = "agent-cli-") {
9
+ return mkdtempSync(join(tmpdir(), prefix));
10
+ }
11
+ function installStub(dir, binary) {
12
+ mkdirSync(dir, { recursive: true });
13
+ const path = join(dir, binary);
14
+ writeFileSync(path, stub_cli_default);
15
+ chmodSync(path, 493);
16
+ return path;
17
+ }
18
+ function installFakeCli(dir, tool, options = {}) {
19
+ mkdirSync(dir, { recursive: true });
20
+ const path = join(dir, tool === "claude-code" ? "claude" : "codex");
21
+ const version = options.version ?? "1.2.3";
22
+ const status = tool === "claude-code" ? `if [ -f "$HOME/signed-in" ]; then echo '{"loggedIn":true,"email":"person@example.test","orgName":"Private Org"}'; exit 0; else echo '{"loggedIn":false}'; exit 1; fi` : `if [ -f "$HOME/signed-in" ]; then echo "Logged in using ChatGPT"; exit 0; else echo "Not logged in"; exit 1; fi`;
23
+ const statusCase = tool === "claude-code" ? "\"auth status\"" : "\"login status\"";
24
+ const loginCase = tool === "claude-code" ? "\"auth login\"" : "\"login \"";
25
+ writeFileSync(path, `#!/bin/sh
26
+ env > "$HOME/env-dump"
27
+ case "$*" in *--help*) exit ${options.brokenHelp ? 2 : 0};; esac
28
+ case "$*" in *'model_provider="smrt_preflight"'*)
29
+ [ -z "$SMRT_SHELL_MCP_TOKEN" ] && [ -z "$OPENAI_API_KEY" ] && [ -z "$ANTHROPIC_API_KEY" ] || exit 3
30
+ [ ! -f "$HOME/signed-in" ] && [ "$HOME" = "$CODEX_HOME" ] && [ -z "$HTTP_PROXY" ] && [ -z "$HTTPS_PROXY" ] && [ -z "$ALL_PROXY" ] || exit 3
31
+ case "$*" in *'base_url="http://127.0.0.1:1"'*) ;; *) exit 3;; esac
32
+ case "$*" in *'requires_openai_auth=false'*) ;; *) exit 3;; esac
33
+ case "$*" in *'--enable code_mode_host'*) ;; *) echo '{"type":"item.completed","item":{"type":"error","message":"code-mode host is disabled"}}'; exit 0;; esac
34
+ echo '${options.toolHostDisabled ? "{\"type\":\"item.completed\",\"item\":{\"type\":\"error\",\"message\":\"Code Mode is unavailable because code-mode host is disabled.\"}}" : "{\"type\":\"turn.started\"}"}'
35
+ exit 0;; esac
36
+ case "$1 $2" in
37
+ "--version "*) ${options.brokenVersion ? "exit 3" : `echo "${tool === "claude-code" ? `${version} (Claude Code)` : `codex-cli ${version}`}"`};;
38
+ ${statusCase}) ${status};;
39
+ ${loginCase}) touch "$HOME/signed-in"; exit 0;;
40
+ *) exit 2;;
41
+ esac
42
+ `);
43
+ chmodSync(path, 493);
44
+ return path;
45
+ }
46
+ function fakeDeps(home, pathDirs, extraEnv = {}) {
47
+ return {
48
+ env: {
49
+ HOME: home,
50
+ PATH: [
51
+ ...pathDirs,
52
+ "/usr/bin",
53
+ "/bin"
54
+ ].join(":"),
55
+ ...extraEnv
56
+ },
57
+ platform: process.platform,
58
+ home,
59
+ loginShell: false,
60
+ systemDirs: []
61
+ };
62
+ }
63
+ var exists = existsSync;
64
+ //#endregion
65
+ export { exists, fakeDeps, installFakeCli, installStub, tempDir };
66
+
67
+ //# sourceMappingURL=test-support.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-support.js","names":[],"sources":["../../src/agent-cli/test-support.ts"],"sourcesContent":["// Test helpers for the agent CLI suites: fake `claude` / `codex` executables\n// on a temp PATH (shell scripts that answer `--version`, the status command and\n// the sign-in command like the real tools, with no network) and the stream\n// stub (test-fixtures/stub-cli.mjs) installed under either name.\nimport {\n chmodSync,\n existsSync,\n mkdirSync,\n mkdtempSync,\n writeFileSync,\n} from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\nimport type { LocateDeps } from './locate.js';\nimport stubCli from './test-fixtures/stub-cli.mjs?raw';\nimport type { AgentTool } from './tools.js';\n\nexport function tempDir(prefix = 'agent-cli-'): string {\n return mkdtempSync(join(tmpdir(), prefix));\n}\n\n/** `dir/<binary>` is the stream stub; returns its path. */\nexport function installStub(dir: string, binary: string): string {\n mkdirSync(dir, { recursive: true });\n const path = join(dir, binary);\n writeFileSync(path, stubCli);\n chmodSync(path, 0o755);\n return path;\n}\n\n/**\n * `dir/<binary>`: a shell script that behaves like the real tool's version,\n * status and login commands. Signed in = `$HOME/signed-in` exists; its login\n * command creates it. Every call dumps its environment to `$HOME/env-dump`.\n */\nexport function installFakeCli(\n dir: string,\n tool: AgentTool,\n options: {\n version?: string;\n brokenVersion?: boolean;\n brokenHelp?: boolean;\n toolHostDisabled?: boolean;\n } = {},\n): string {\n mkdirSync(dir, { recursive: true });\n const path = join(dir, tool === 'claude-code' ? 'claude' : 'codex');\n const version = options.version ?? '1.2.3';\n const status =\n tool === 'claude-code'\n ? `if [ -f \"$HOME/signed-in\" ]; then echo '{\"loggedIn\":true,\"email\":\"person@example.test\",\"orgName\":\"Private Org\"}'; exit 0; else echo '{\"loggedIn\":false}'; exit 1; fi`\n : `if [ -f \"$HOME/signed-in\" ]; then echo \"Logged in using ChatGPT\"; exit 0; else echo \"Not logged in\"; exit 1; fi`;\n const statusCase =\n tool === 'claude-code' ? '\"auth status\"' : '\"login status\"';\n const loginCase = tool === 'claude-code' ? '\"auth login\"' : '\"login \"';\n const script = `#!/bin/sh\nenv > \"$HOME/env-dump\"\ncase \"$*\" in *--help*) exit ${options.brokenHelp ? 2 : 0};; esac\ncase \"$*\" in *'model_provider=\"smrt_preflight\"'*)\n [ -z \"$SMRT_SHELL_MCP_TOKEN\" ] && [ -z \"$OPENAI_API_KEY\" ] && [ -z \"$ANTHROPIC_API_KEY\" ] || exit 3\n [ ! -f \"$HOME/signed-in\" ] && [ \"$HOME\" = \"$CODEX_HOME\" ] && [ -z \"$HTTP_PROXY\" ] && [ -z \"$HTTPS_PROXY\" ] && [ -z \"$ALL_PROXY\" ] || exit 3\n case \"$*\" in *'base_url=\"http://127.0.0.1:1\"'*) ;; *) exit 3;; esac\n case \"$*\" in *'requires_openai_auth=false'*) ;; *) exit 3;; esac\n case \"$*\" in *'--enable code_mode_host'*) ;; *) echo '{\"type\":\"item.completed\",\"item\":{\"type\":\"error\",\"message\":\"code-mode host is disabled\"}}'; exit 0;; esac\n echo '${options.toolHostDisabled ? '{\"type\":\"item.completed\",\"item\":{\"type\":\"error\",\"message\":\"Code Mode is unavailable because code-mode host is disabled.\"}}' : '{\"type\":\"turn.started\"}'}'\n exit 0;; esac\ncase \"$1 $2\" in\n \"--version \"*) ${options.brokenVersion ? 'exit 3' : `echo \"${tool === 'claude-code' ? `${version} (Claude Code)` : `codex-cli ${version}`}\"`};;\n ${statusCase}) ${status};;\n ${loginCase}) touch \"$HOME/signed-in\"; exit 0;;\n *) exit 2;;\nesac\n`;\n writeFileSync(path, script);\n chmodSync(path, 0o755);\n return path;\n}\n\n/** Lookup deps over a temp HOME and PATH, no login shell. */\nexport function fakeDeps(\n home: string,\n pathDirs: string[],\n extraEnv: Record<string, string> = {},\n): LocateDeps {\n return {\n env: {\n HOME: home,\n // /usr/bin and /bin only for the fake scripts' own `env` and `touch`.\n PATH: [...pathDirs, '/usr/bin', '/bin'].join(':'),\n ...extraEnv,\n },\n platform: process.platform,\n home,\n loginShell: false,\n systemDirs: [],\n };\n}\n\nexport const exists = existsSync;\n"],"mappings":";;;;;;;AAiBO,SAAS,QAAQ,SAAS,cAAsB;CACrD,OAAO,YAAY,KAAK,OAAO,GAAG,MAAM,CAAC;AAC3C;AAGO,SAAS,YAAY,KAAa,QAAwB;CAC/D,UAAU,KAAK,EAAE,WAAW,KAAK,CAAC;CAClC,MAAM,OAAO,KAAK,KAAK,MAAM;CAC7B,cAAc,MAAM,gBAAO;CAC3B,UAAU,MAAM,GAAK;CACrB,OAAO;AACT;AAOO,SAAS,eACd,KACA,MACA,UAKI,CAAC,GACG;CACR,UAAU,KAAK,EAAE,WAAW,KAAK,CAAC;CAClC,MAAM,OAAO,KAAK,KAAK,SAAS,gBAAgB,WAAW,OAAO;CAClE,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,SACJ,SAAS,gBACL,yKACA;CACN,MAAM,aACJ,SAAS,gBAAgB,oBAAkB;CAC7C,MAAM,YAAY,SAAS,gBAAgB,mBAAiB;CAmB5D,cAAc,MAAM;;8BAhBQ,QAAQ,aAAa,IAAI,EAAC;;;;;;;UAO9C,QAAQ,mBAAmB,6IAA+H,8BAAyB;;;mBAG1K,QAAQ,gBAAgB,WAAW,SAAS,SAAS,gBAAgB,GAAG,QAAO,kBAAmB,aAAa,UAAS,GAAG;IAC1I,WAAU,IAAK,OAAM;IACrB,UAAS;;;CAIe;CAC1B,UAAU,MAAM,GAAK;CACrB,OAAO;AACT;AAGO,SAAS,SACd,MACA,UACA,WAAmC,CAAC,GACxB;CACZ,OAAO;EACL,KAAK;GACH,MAAM;GAEN,MAAM;IAAC,GAAG;IAAU;IAAY;GAAM,CAAA,CAAE,KAAK,GAAG;GAChD,GAAG;EACL;EACA,UAAU,QAAQ;EAClB;EACA,YAAY;EACZ,YAAY,CAAC;CACf;AACF;AAEO,IAAM,SAAS"}
@@ -0,0 +1,19 @@
1
+ export declare const AGENT_TOOLS: readonly ["claude-code", "codex"];
2
+ export type AgentTool = (typeof AGENT_TOOLS)[number];
3
+ export declare function isAgentTool(value: unknown): value is AgentTool;
4
+ export interface AgentToolInfo {
5
+ tool: AgentTool;
6
+ /** Plain-text product name for the UI. */
7
+ label: string;
8
+ /** The executable name looked up on PATH and in the usual install places. */
9
+ binary: string;
10
+ /** Where to send a person who has not installed it. */
11
+ installUrl: string;
12
+ versionArgs: readonly string[];
13
+ /** The tool's own status command: exit 0 / `loggedIn` means signed in. */
14
+ statusArgs: readonly string[];
15
+ /** The tool's own interactive sign-in (opens the vendor page itself). */
16
+ loginArgs: readonly string[];
17
+ }
18
+ export declare const AGENT_TOOL_INFO: Readonly<Record<AgentTool, AgentToolInfo>>;
19
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/agent-cli/tools.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,WAAW,mCAAoC,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAErD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,CAAC;IAChB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,0EAA0E;IAC1E,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,yEAAyE;IACzE,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B;AAED,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,aAAa,CAAC,CAmBtE,CAAC"}
@@ -0,0 +1,138 @@
1
+ import type { AIToolCall } from '@happyvertical/ai';
2
+ import { type ResolvedWorkProfile, type WorkModelFallbackStore, type WorkRunMetadata } from '../work-profiles.js';
3
+ import type { AgentCredentials } from './credentials.js';
4
+ import type { AgentCliLocation } from './detect.js';
5
+ import { type AgentTool } from './tools.js';
6
+ export type AgentTurnStop = 'complete' | 'timeout' | 'aborted' | 'waiting' | 'error';
7
+ export type AgentTurnEvent = {
8
+ type: 'text';
9
+ delta: string;
10
+ } | {
11
+ type: 'tool_call';
12
+ id: string;
13
+ name: string;
14
+ args: string;
15
+ } | {
16
+ type: 'tool_result';
17
+ id: string;
18
+ name: string;
19
+ ok: boolean;
20
+ summary: string;
21
+ details?: Record<string, unknown>;
22
+ } | {
23
+ type: 'approval_required';
24
+ id: string;
25
+ name: string;
26
+ approvalId: string;
27
+ summary: string;
28
+ preview: unknown;
29
+ } | {
30
+ type: 'approval_decided';
31
+ id: string;
32
+ approvalId: string;
33
+ status: 'approved' | 'denied' | 'failed' | 'timeout';
34
+ } | {
35
+ type: 'error';
36
+ code: string;
37
+ message: string;
38
+ } | {
39
+ type: 'done';
40
+ stop: AgentTurnStop;
41
+ };
42
+ export interface AgentTurnLimits {
43
+ /** The whole turn, CLI start to exit. */
44
+ turnTimeoutMs: number;
45
+ toolResultChars: number;
46
+ }
47
+ export declare const DEFAULT_AGENT_LIMITS: AgentTurnLimits;
48
+ /** Process and token dependencies supplied by the authenticated host. */
49
+ export interface AgentEngineDeps {
50
+ locate(tool: AgentTool): Promise<AgentCliLocation | null>;
51
+ credentials: AgentCredentials;
52
+ /** Private app-owned directory, outside a source/project tree. */
53
+ stateDir(): Promise<string>;
54
+ /** Base environment for the child (allow-listed again inside). */
55
+ baseEnv?: Readonly<Record<string, string | undefined>>;
56
+ limits?: Partial<AgentTurnLimits>;
57
+ }
58
+ /** Persistence, guidance and approvals belong to the authenticated host. */
59
+ export interface AgentTurnHost {
60
+ appendMessage(message: AgentTurnMessage): Promise<unknown>;
61
+ lastSession(): Promise<string | null>;
62
+ guidance(): Promise<{
63
+ systemPrompt: string;
64
+ prompt: string;
65
+ }>;
66
+ allowTool(name: string): boolean;
67
+ approvals: {
68
+ subscribe(listener: (event: {
69
+ id: string;
70
+ status: 'pending' | 'approved' | 'denied' | 'failed' | 'timeout';
71
+ }) => void): () => void;
72
+ get(id: string): Promise<{
73
+ id: string;
74
+ status: string;
75
+ summary: string;
76
+ preview: unknown;
77
+ } | null>;
78
+ };
79
+ describeResult(input: {
80
+ name: string;
81
+ text: string;
82
+ ok: boolean;
83
+ approvalId?: string;
84
+ }): Promise<{
85
+ summary: string;
86
+ details?: Record<string, unknown>;
87
+ }>;
88
+ recordExecution?(metadata: WorkRunMetadata): Promise<void>;
89
+ completionNote?(): Promise<string | null>;
90
+ }
91
+ export interface AgentTurnMessage {
92
+ role: 'user' | 'assistant' | 'tool';
93
+ content: string;
94
+ toolCalls?: AIToolCall[];
95
+ toolCallId?: string;
96
+ meta?: {
97
+ id: string;
98
+ name: string;
99
+ ok: boolean;
100
+ summary: string;
101
+ approvalId?: string;
102
+ } | {
103
+ cliSession: {
104
+ tool: string;
105
+ id: string;
106
+ };
107
+ workRun?: WorkRunMetadata;
108
+ };
109
+ }
110
+ export interface AgentTurnOptions {
111
+ /** Trusted host setting, never engine input; default protected. */
112
+ protection?: boolean;
113
+ text: string;
114
+ profile?: ResolvedWorkProfile;
115
+ outputSchema?: Record<string, unknown>;
116
+ fallback?: {
117
+ ownerId: string;
118
+ connectionKey: string;
119
+ nextModel: string;
120
+ store: WorkModelFallbackStore;
121
+ };
122
+ tool: AgentTool;
123
+ mcpUrl: string;
124
+ signal: AbortSignal;
125
+ emit(event: AgentTurnEvent): void;
126
+ deps: AgentEngineDeps;
127
+ host: AgentTurnHost;
128
+ }
129
+ /** What the owner sees; a missing permission says what to do about it. */
130
+ export declare function tokenFailureMessage(code: string | undefined): string;
131
+ /** Log only diagnostic structure, never a message, child output, arguments or credentials. */
132
+ export declare function reportAgentFailure(tool: AgentTool | 'chatgpt', phase: 'binding' | 'process' | 'guard' | 'credential' | 'preflight' | 'driver', error?: unknown, code?: string, blocked?: {
133
+ name: string;
134
+ kind: 'builtin' | 'unoffered_mcp' | 'unknown_item' | 'confined_builtin' | 'native_builtin';
135
+ }): string;
136
+ /** Run a turn and log unexpected host/process failures before preserving their cleanup contract. */
137
+ export declare function runAgentTurn(options: AgentTurnOptions): Promise<AgentTurnStop>;
138
+ //# sourceMappingURL=turn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn.d.ts","sourceRoot":"","sources":["../../src/agent-cli/turn.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EACL,KAAK,mBAAmB,EAGxB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpD,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAE7D,MAAM,MAAM,aAAa,GACrB,UAAU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,CAAC;IACF,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC;IAClC,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,aAAa,CAAC;CACrB;AAUD,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAMpE;AAoCD,8FAA8F;AAC9F,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,SAAS,GAAG,SAAS,EAC3B,KAAK,EACD,SAAS,GACT,SAAS,GACT,OAAO,GACP,YAAY,GACZ,WAAW,GACX,QAAQ,EACZ,KAAK,CAAC,EAAE,OAAO,EACf,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;IACR,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EACA,SAAS,GACT,eAAe,GACf,cAAc,GACd,kBAAkB,GAClB,gBAAgB,CAAC;CACtB,GACA,MAAM,CA6FR;AAED,oGAAoG;AACpG,wBAAsB,YAAY,CAChC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,aAAa,CAAC,CAOxB"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * "Sign in with ChatGPT" connection service (host-agnostic, Node-only).
3
+ *
4
+ * A local app lets its owner use their own ChatGPT plan through OpenAI's
5
+ * official flow (a PREVIEW for open source apps):
6
+ * https://developers.openai.com/siwc/token-sharing-open-source/preview-limitations
7
+ *
8
+ * The SDK owns everything sensitive. `LocalChatGPTSessionManager`
9
+ * (`@happyvertical/auth/local`) runs the loopback callback, PKCE, dynamic
10
+ * client registration and OIDC validation, and keeps the renewable
11
+ * credentials in one owner-only file at `credentialsPath` (put it in the app's
12
+ * private state area, never in a project). This service never reads that
13
+ * file, and never logs, returns or copies a token: its results carry a
14
+ * sign-in state and an account label, nothing else. The only thing that
15
+ * reaches a provider is a minimal `{ accessToken(clientId) }` handle, so a
16
+ * provider can ask for a usable token before a request and nothing more
17
+ * (it cannot sign anyone out).
18
+ *
19
+ * This is a distinct billing path from an API key. It is never selected
20
+ * automatically and never a fallback: a host opts in per call through
21
+ * {@link createChatGPTPlanResolver}.
22
+ */
23
+ /** The `@happyvertical/ai` provider id of this path. */
24
+ export declare const CHATGPT_PLAN_PROVIDER = "chatgpt-plan";
25
+ /** The only host OpenAI's sign-in page may be served from. */
26
+ export declare const CHATGPT_AUTH_HOST = "auth.openai.com";
27
+ /** How long a started sign-in is shown as "in progress". */
28
+ export declare const CHATGPT_SIGN_IN_WINDOW_MS: number;
29
+ /** The slice of `LocalChatGPTSessionManager` this service uses. */
30
+ export interface ChatGPTSessionStore {
31
+ sessions(): Promise<ReadonlyArray<{
32
+ clientId: string;
33
+ subject: string;
34
+ email?: string;
35
+ scopes: string[];
36
+ expiresAt: number;
37
+ }>>;
38
+ begin(selectedClientId?: string): Promise<{
39
+ authorizationUrl: string;
40
+ callback: Promise<{
41
+ clientId: string;
42
+ }>;
43
+ /** SDK-owned cancellation and listener cleanup, when supported. */
44
+ cancel?: () => Promise<void>;
45
+ }>;
46
+ accessToken(clientId: string): Promise<string>;
47
+ logout(clientId: string): Promise<{
48
+ remoteRevocationConfirmed: boolean;
49
+ }>;
50
+ }
51
+ /** What the provider is given instead of the session manager. */
52
+ export interface ChatGPTTokenSource {
53
+ accessToken(clientId: string): Promise<string>;
54
+ }
55
+ /** A model the signed-in account can use. */
56
+ export interface ChatGPTPlanModel {
57
+ id: string;
58
+ label: string;
59
+ intelligenceRank?: number;
60
+ }
61
+ /** The slice of the provider this service uses. */
62
+ export interface ChatGPTPlanModelLister {
63
+ getModels(): Promise<Array<{
64
+ id: string;
65
+ name?: string;
66
+ intelligenceRank?: number;
67
+ }>>;
68
+ }
69
+ export type ChatGPTSignInErrorCode = 'declined' | 'plan_permission_missing' | 'storage_busy' | 'timed_out' | 'failed';
70
+ export interface ChatGPTPlanStatus {
71
+ signedIn: boolean;
72
+ /** Who is signed in: the account email, else a short subject label. */
73
+ account?: {
74
+ label: string;
75
+ };
76
+ /** A sign-in was started and has neither finished nor timed out. */
77
+ signingIn: boolean;
78
+ /** Why the last sign-in did not finish. Cleared by the next start. */
79
+ error?: {
80
+ code: ChatGPTSignInErrorCode;
81
+ message: string;
82
+ };
83
+ }
84
+ export interface ChatGPTPlanConnectionOptions {
85
+ /**
86
+ * The app name OpenAI shows on its page ("<name> wants to use your ChatGPT
87
+ * plan").
88
+ */
89
+ appName: string;
90
+ /**
91
+ * The credential file, in the app's private state area (owner-only, outside
92
+ * any source tree). Required: there is no default location.
93
+ */
94
+ credentialsPath: string;
95
+ /** Tests: a fake session manager. Default: the SDK's local manager. */
96
+ manager?: ChatGPTSessionStore;
97
+ /** Tests: a fake provider factory. Default: `getAI({ type: 'chatgpt-plan' })`. */
98
+ createClient?: (options: Record<string, unknown>) => Promise<ChatGPTPlanModelLister>;
99
+ /** Tests: the clock. */
100
+ now?: () => number;
101
+ }
102
+ export interface ChatGPTPlanConnection {
103
+ /**
104
+ * Start a sign-in. Returns the authorization URL on OpenAI's host (already
105
+ * validated) for the host to open in the system browser; the SDK's loopback
106
+ * listener receives the callback. A second call while one is open returns
107
+ * the same URL.
108
+ */
109
+ start(): Promise<{
110
+ authorizationUrl: string;
111
+ }>;
112
+ /** Signed in or not, and who. Never a token. */
113
+ status(): Promise<ChatGPTPlanStatus>;
114
+ /** Cancel the SDK's pending flow; refuses honestly when the SDK lacks this API. */
115
+ cancel(): Promise<void>;
116
+ /** Forget the local credentials (and ask OpenAI to revoke them). */
117
+ signOut(): Promise<{
118
+ remoteRevocationConfirmed: boolean;
119
+ }>;
120
+ /** The signed-in account's models, newest catalog (cached for ten minutes). */
121
+ models(): Promise<ChatGPTPlanModel[]>;
122
+ /** Strongest ranked model offered by this account, or undefined for an unknown catalog. */
123
+ defaultModel(): Promise<string | undefined>;
124
+ /**
125
+ * `getAI()` options for a `chatgpt-plan` client on the signed-in account:
126
+ * the client id and a token handle, plus `model` as `defaultModel`. These
127
+ * hold a live handle, so they are never serialized or logged. Throws when
128
+ * nobody is signed in.
129
+ */
130
+ clientOptions(options?: {
131
+ model?: string;
132
+ toolNamespace?: {
133
+ name?: string;
134
+ description?: string;
135
+ };
136
+ }): Promise<Record<string, unknown>>;
137
+ }
138
+ export declare class ChatGPTSignedOutError extends Error {
139
+ readonly code = "chatgpt_signed_out";
140
+ constructor();
141
+ }
142
+ /**
143
+ * Whether `url` is a sign-in page on OpenAI's host: https, that host, no
144
+ * userinfo, no fragment. A host that opens a browser checks this first.
145
+ */
146
+ export declare function isChatGPTAuthorizationUrl(url: unknown): url is string;
147
+ /** Build the connection. Nothing is read or opened until first use. */
148
+ export declare function createChatGPTPlanConnection(options: ChatGPTPlanConnectionOptions): ChatGPTPlanConnection;
149
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/chatgpt/connection.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,wDAAwD;AACxD,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AAEpD,8DAA8D;AAC9D,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAEnD,4DAA4D;AAC5D,eAAO,MAAM,yBAAyB,QAAc,CAAC;AAIrD,mEAAmE;AACnE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,IAAI,OAAO,CACjB,aAAa,CAAC;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC,CACH,CAAC;IACF,KAAK,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QACxC,gBAAgB,EAAE,MAAM,CAAC;QACzB,QAAQ,EAAE,OA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