@tangle-network/sdk-provider-cli-base 0.13.67 → 0.13.68

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.
@@ -0,0 +1,44 @@
1
+ import { Bt as ExecutionState, It as CliProviderConfig, Pt as CliExecArgs, bt as CliTurnSpawn, gt as CliProviderAdapterBase, yt as CliTurnProcess } from "../../index-e8cyc1fi.mjs";
2
+ import { StreamParserConfig } from "@tangle-network/sdk-cli-runner";
3
+ import { StreamEvent } from "@tangle-network/agent-interface";
4
+
5
+ //#region src/adapters/exo/adapter.d.ts
6
+ /**
7
+ * Exo (https://github.com/exoharness/exo), driven headless: `exo run` reads
8
+ * an agent definition file, runs one `--prompt` turn of its built-in `basic`
9
+ * loop as a local process in the workspace, and prints the thread id, the
10
+ * reply and a stats line on stdout. The model key lives in Exo's vault.
11
+ */
12
+ type ExoConfig = CliProviderConfig;
13
+ type ExoEvent = {
14
+ type: "thread";
15
+ id: string;
16
+ } | {
17
+ type: "text";
18
+ line: string;
19
+ } | {
20
+ type: "empty";
21
+ };
22
+ declare class ExoProviderAdapter extends CliProviderAdapterBase<ExoConfig, ExoEvent> {
23
+ readonly provider = "exo";
24
+ protected readonly defaultCliPath = "exo";
25
+ /** Exo refuses a vault its mount exposes, so the home is never the workspace. */
26
+ private home;
27
+ private baseUrl;
28
+ protected buildExecArgs(params: {
29
+ message: string;
30
+ config: ExoConfig;
31
+ model?: string;
32
+ sessionId?: string;
33
+ workspaceRoot: string;
34
+ systemPrompt?: string;
35
+ appendSystemPrompt?: string;
36
+ }): CliExecArgs;
37
+ protected buildExecEnv(config: ExoConfig): Record<string, string | undefined>;
38
+ /** Write the agent definition and the vault key into the home, then start the turn. */
39
+ protected spawnExecutionProcess(request: CliTurnSpawn<ExoConfig, ExoEvent>): Promise<CliTurnProcess>;
40
+ protected createEventParser(state: ExecutionState, onEvent?: (event: StreamEvent) => void): StreamParserConfig<ExoEvent>;
41
+ }
42
+ //#endregion
43
+ export { type ExoConfig, ExoProviderAdapter };
44
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1,132 @@
1
+ import { Dt as sessionObservedEvents, L as plaintextResponseParser, U as CliProviderAdapterBase } from "../../src-DtA6aq0e.mjs";
2
+ import { normalizeOpenAiCompatibleBaseUrl, resolveTangleRouterDefaults } from "@tangle-network/agent-interface";
3
+ import { join } from "node:path";
4
+ //#region src/adapters/exo/adapter.ts
5
+ /** The vault secret the agent definition names, and the env it is read from. */
6
+ const SECRET = "tangle-model";
7
+ const KEY_ENV = "EXO_MODEL_API_KEY";
8
+ /** Writes stdin to the path in argv, as whoever runs it. */
9
+ const WRITE_FILE = "const fs = require(\"node:fs\"); fs.writeFileSync(process.argv[1], fs.readFileSync(0));";
10
+ var ExoProviderAdapter = class extends CliProviderAdapterBase {
11
+ provider = "exo";
12
+ defaultCliPath = "exo";
13
+ /** Exo refuses a vault its mount exposes, so the home is never the workspace. */
14
+ home(config) {
15
+ return join(config.runtimeHome?.trim() || this.storagePath, ".exo");
16
+ }
17
+ baseUrl(config) {
18
+ return config.baseUrl ? normalizeOpenAiCompatibleBaseUrl(config.baseUrl) : resolveTangleRouterDefaults().baseUrl;
19
+ }
20
+ buildExecArgs(params) {
21
+ const model = params.model ?? params.config.model ?? resolveTangleRouterDefaults().model;
22
+ const agent = [
23
+ "---",
24
+ "harness: basic",
25
+ "model:",
26
+ ` name: ${JSON.stringify(model)}`,
27
+ ` base_url: ${JSON.stringify(this.baseUrl(params.config))}`,
28
+ ` credential: ${SECRET}`,
29
+ "---",
30
+ "",
31
+ [params.systemPrompt, params.appendSystemPrompt].filter(Boolean).join("\n\n") || "You are a coding agent working in this directory.",
32
+ ""
33
+ ].join("\n");
34
+ const args = [
35
+ "run",
36
+ join(this.home(params.config), "tangle.md"),
37
+ "--sandbox",
38
+ "local-process",
39
+ "--mount",
40
+ `${params.workspaceRoot}:/workspace:rw`,
41
+ "--verbosity",
42
+ "minimal"
43
+ ];
44
+ if (params.sessionId) args.push("--thread", params.sessionId);
45
+ if (params.config.extraFlags?.length) args.push(...params.config.extraFlags);
46
+ args.push("--prompt", params.message);
47
+ return {
48
+ command: this.getCliPath(),
49
+ args,
50
+ useStdin: false,
51
+ stdin: agent
52
+ };
53
+ }
54
+ buildExecEnv(config) {
55
+ return {
56
+ ...this.agentEnvironmentValues(),
57
+ EXO_HOME: this.home(config)
58
+ };
59
+ }
60
+ /** Write the agent definition and the vault key into the home, then start the turn. */
61
+ async spawnExecutionProcess(request) {
62
+ const { config, env, execArgs, workspaceRoot } = request;
63
+ await this.ensureSubprocessOwnedDir(this.home(config));
64
+ await this.runNodeAsSubprocess(WRITE_FILE, [execArgs.args[1] ?? ""], execArgs.stdin);
65
+ if (!config.apiKey) return super.spawnExecutionProcess(request);
66
+ const vault = (verb) => this.runCli({
67
+ command: this.getCliPath(),
68
+ args: [...[
69
+ "vault",
70
+ "secret",
71
+ verb,
72
+ "global",
73
+ SECRET
74
+ ], ...verb === "delete" ? [] : [...["--token-env", KEY_ENV], ...["--allow-origin", new URL(this.baseUrl(config)).origin]]],
75
+ cwd: workspaceRoot,
76
+ env: {
77
+ ...env,
78
+ [KEY_ENV]: config.apiKey
79
+ },
80
+ timeoutMs: 15e3
81
+ });
82
+ if (!(await vault("update")).exit.success) {
83
+ const created = await vault("create");
84
+ if (!created.exit.success) throw new Error(`exo vault secret create failed: ${created.stderr.slice(-300)}`);
85
+ }
86
+ const forget = () => vault("delete").catch(() => void 0);
87
+ try {
88
+ const turn = await super.spawnExecutionProcess(request);
89
+ turn.exitPromise.then(forget, forget);
90
+ return turn;
91
+ } catch (error) {
92
+ await forget();
93
+ throw error;
94
+ }
95
+ }
96
+ createEventParser(state, onEvent) {
97
+ let replying = false;
98
+ return plaintextResponseParser(state, onEvent, {
99
+ classify: (line) => {
100
+ const reply = /^\[\d\d:\d\d:\d\d\] agent: (.*)$/u.exec(line);
101
+ if (reply) {
102
+ replying = true;
103
+ return {
104
+ type: "text",
105
+ line: reply[1] ?? ""
106
+ };
107
+ }
108
+ if (/^(ttft: \S+, )?duration: \d/u.test(line)) return replying ? null : { type: "empty" };
109
+ if (replying) return {
110
+ type: "text",
111
+ line
112
+ };
113
+ const thread = /^thread: \S+ \(([0-9a-f-]{36})\)$/u.exec(line);
114
+ return thread?.[1] ? {
115
+ type: "thread",
116
+ id: thread[1]
117
+ } : null;
118
+ },
119
+ map: (event, response) => {
120
+ if (event.type === "thread") return sessionObservedEvents(state, "exo", event.id);
121
+ if (event.type === "text") response.text(event.line);
122
+ else response.error("exo ended the turn without a reply");
123
+ return [];
124
+ },
125
+ emptyFailureDetail: "exo exited without producing a reply"
126
+ });
127
+ }
128
+ };
129
+ //#endregion
130
+ export { ExoProviderAdapter };
131
+
132
+ //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sdk-provider-cli-base",
3
- "version": "0.13.67",
3
+ "version": "0.13.68",
4
4
  "description": "Base adapter for CLI-based AI agent providers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -23,6 +23,10 @@
23
23
  "import": "./dist/adapters/nanoclaw/index.mjs",
24
24
  "types": "./dist/adapters/nanoclaw/index.d.mts"
25
25
  },
26
+ "./exo": {
27
+ "import": "./dist/adapters/exo/index.mjs",
28
+ "types": "./dist/adapters/exo/index.d.mts"
29
+ },
26
30
  "./nanocode": {
27
31
  "import": "./dist/adapters/nanocode/index.mjs",
28
32
  "types": "./dist/adapters/nanocode/index.d.mts"
@@ -55,12 +59,12 @@
55
59
  "dependencies": {
56
60
  "@modelcontextprotocol/sdk": "^1.32.2",
57
61
  "@tangle-network/agent-core": "^1.0.3",
58
- "@tangle-network/agent-interface": "^5.10.22",
59
- "@tangle-network/agent-profile-materialize": "1.1.102",
62
+ "@tangle-network/agent-interface": "^5.10.23",
63
+ "@tangle-network/agent-profile-materialize": "1.1.103",
60
64
  "@tangle-network/agent-trace-contract": "^2.2.0",
61
- "@tangle-network/cli-agent-registry": "0.15.78",
65
+ "@tangle-network/cli-agent-registry": "0.15.79",
62
66
  "@tangle-network/sdk-cli-runner": "0.3.12",
63
- "@tangle-network/sdk-session-persistence": "0.7.9",
67
+ "@tangle-network/sdk-session-persistence": "0.7.10",
64
68
  "zod": "4.6.7"
65
69
  },
66
70
  "devDependencies": {
@@ -75,8 +79,8 @@
75
79
  "registry": "https://registry.npmjs.org"
76
80
  },
77
81
  "tangleRelease": {
78
- "sourceSha": "c4b4ddcb9f7e8b4b416c40026d8c5eb85bbedef5",
79
- "mergedAt": "2026-11-10T17:06:36-08:00"
82
+ "sourceSha": "50af028ed3405716af1918f2c85292056b2f6df4",
83
+ "mergedAt": "2026-11-10T18:13:25-08:00"
80
84
  },
81
85
  "scripts": {
82
86
  "build": "tsdown",