@tangle-network/agent-app 0.60.97 → 0.60.99
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/dist/assistant/index.js +4 -4
- package/dist/chat-react/index.js +3 -3
- package/dist/chat-routes/index.js +2 -2
- package/dist/{chunk-EBNIZHRX.js → chunk-BPN4TEAT.js} +2 -2
- package/dist/{chunk-BOEWSEGC.js → chunk-N2UQIEWN.js} +2 -2
- package/dist/{chunk-CYGXIJCQ.js → chunk-VIYABB6R.js} +2 -2
- package/dist/{chunk-MCYJON3F.js → chunk-WVESWAJJ.js} +22 -1
- package/dist/chunk-WVESWAJJ.js.map +1 -0
- package/dist/{chunk-6OQYTH7T.js → chunk-YL5ZTCRU.js} +3 -3
- package/dist/harness/index.d.ts +17 -0
- package/dist/harness/index.js +3 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +173 -9
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/openai-stream.d.ts +2 -0
- package/dist/runtime/router-turn.d.ts +106 -0
- package/dist/sandbox/index.js +2 -2
- package/dist/skills-placement/index.js +1 -1
- package/dist/web-react/agent-profile-editor.js +3 -3
- package/dist/web-react/index.js +4 -4
- package/dist/workspace-react/index.js +2 -2
- package/dist/workspace-react/index.js.map +1 -1
- package/dist/workspace-react/rail-identity.d.ts +4 -3
- package/package.json +1 -1
- package/dist/chunk-MCYJON3F.js.map +0 -1
- /package/dist/{chunk-EBNIZHRX.js.map → chunk-BPN4TEAT.js.map} +0 -0
- /package/dist/{chunk-BOEWSEGC.js.map → chunk-N2UQIEWN.js.map} +0 -0
- /package/dist/{chunk-CYGXIJCQ.js.map → chunk-VIYABB6R.js.map} +0 -0
- /package/dist/{chunk-6OQYTH7T.js.map → chunk-YL5ZTCRU.js.map} +0 -0
package/dist/assistant/index.js
CHANGED
|
@@ -6,14 +6,14 @@ import "../chunk-3HUFJ5LO.js";
|
|
|
6
6
|
import "../chunk-FBVLEGEG.js";
|
|
7
7
|
import {
|
|
8
8
|
ChatComposer
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-VIYABB6R.js";
|
|
10
10
|
import "../chunk-L7MB2LLM.js";
|
|
11
11
|
import "../chunk-KHCJKVQN.js";
|
|
12
12
|
import "../chunk-XEURJVS5.js";
|
|
13
13
|
import "../chunk-E4AY62T2.js";
|
|
14
14
|
import "../chunk-SJWIZT7B.js";
|
|
15
|
-
import "../chunk-
|
|
16
|
-
import "../chunk-
|
|
15
|
+
import "../chunk-YL5ZTCRU.js";
|
|
16
|
+
import "../chunk-BPN4TEAT.js";
|
|
17
17
|
import "../chunk-NJDQ2JCP.js";
|
|
18
18
|
import {
|
|
19
19
|
ModelPicker
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
} from "../chunk-LSUELMHY.js";
|
|
27
27
|
import "../chunk-FQYAJYPW.js";
|
|
28
28
|
import "../chunk-ZMU54CBG.js";
|
|
29
|
-
import "../chunk-
|
|
29
|
+
import "../chunk-WVESWAJJ.js";
|
|
30
30
|
import "../chunk-B7CL7ENS.js";
|
|
31
31
|
import "../chunk-PV33JZKV.js";
|
|
32
32
|
import "../chunk-7YA4QNTU.js";
|
package/dist/chat-react/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ComposerModeControls,
|
|
3
3
|
EntryComposer
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-VIYABB6R.js";
|
|
5
5
|
import "../chunk-L7MB2LLM.js";
|
|
6
6
|
import "../chunk-SJWIZT7B.js";
|
|
7
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-BPN4TEAT.js";
|
|
8
8
|
import "../chunk-NJDQ2JCP.js";
|
|
9
9
|
import "../chunk-HG4OONJA.js";
|
|
10
10
|
import "../chunk-MLG6XKPV.js";
|
|
11
11
|
import "../chunk-ZMU54CBG.js";
|
|
12
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-WVESWAJJ.js";
|
|
13
13
|
import "../chunk-7YA4QNTU.js";
|
|
14
14
|
import "../chunk-6E7LKHYV.js";
|
|
15
15
|
import "../chunk-TXD5HXLE.js";
|
|
@@ -42,9 +42,9 @@ import {
|
|
|
42
42
|
flattenHistory,
|
|
43
43
|
readSandboxBinaryBytes,
|
|
44
44
|
statSandboxFileSize
|
|
45
|
-
} from "../chunk-
|
|
45
|
+
} from "../chunk-N2UQIEWN.js";
|
|
46
46
|
import "../chunk-4LBCTFBP.js";
|
|
47
|
-
import "../chunk-
|
|
47
|
+
import "../chunk-WVESWAJJ.js";
|
|
48
48
|
import "../chunk-LWSJK546.js";
|
|
49
49
|
import "../chunk-KSITU6BQ.js";
|
|
50
50
|
import "../chunk-6A7MYOUI.js";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
snapHarnessToModel,
|
|
17
17
|
snapModelToHarness
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-WVESWAJJ.js";
|
|
19
19
|
|
|
20
20
|
// src/web-react/composer-file-accept.ts
|
|
21
21
|
function isAcceptedFileType(file, accept) {
|
|
@@ -576,4 +576,4 @@ export {
|
|
|
576
576
|
HarnessPicker,
|
|
577
577
|
AgentSessionControls
|
|
578
578
|
};
|
|
579
|
-
//# sourceMappingURL=chunk-
|
|
579
|
+
//# sourceMappingURL=chunk-BPN4TEAT.js.map
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
DEFAULT_HARNESS,
|
|
14
14
|
assertHarnessModelCompatible,
|
|
15
15
|
isHarness
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-WVESWAJJ.js";
|
|
17
17
|
import {
|
|
18
18
|
assertProfilePromptWithinBudget,
|
|
19
19
|
fingerprintAgentProfile
|
|
@@ -2943,4 +2943,4 @@ export {
|
|
|
2943
2943
|
isTerminalPromptEvent,
|
|
2944
2944
|
detectInteractiveQuestion
|
|
2945
2945
|
};
|
|
2946
|
-
//# sourceMappingURL=chunk-
|
|
2946
|
+
//# sourceMappingURL=chunk-N2UQIEWN.js.map
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
filterAcceptedFiles,
|
|
11
11
|
isAcceptedFileType,
|
|
12
12
|
renamePastedImages
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BPN4TEAT.js";
|
|
14
14
|
import {
|
|
15
15
|
OVERLAY_SHADOW,
|
|
16
16
|
POPOVER_OPTION_FOCUS,
|
|
@@ -1551,4 +1551,4 @@ export {
|
|
|
1551
1551
|
ComposerModeControls,
|
|
1552
1552
|
EntryComposer
|
|
1553
1553
|
};
|
|
1554
|
-
//# sourceMappingURL=chunk-
|
|
1554
|
+
//# sourceMappingURL=chunk-VIYABB6R.js.map
|
|
@@ -33,6 +33,26 @@ function resolveSessionHarness(input = {}) {
|
|
|
33
33
|
const harness = coerceHarness(input.requested, coerceHarness(input.workspaceDefault, fallback));
|
|
34
34
|
return { harness, locked: false, swapAttempted: false };
|
|
35
35
|
}
|
|
36
|
+
function configHarness(value, where) {
|
|
37
|
+
if (!isHarness(value)) throw new Error(`${where} names an unknown harness: ${String(value)}`);
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
function configuredHarness(config, workspaceId) {
|
|
41
|
+
const appDefault = config.default?.trim() ? configHarness(config.default.trim(), "The harness default") : DEFAULT_HARNESS;
|
|
42
|
+
const raw = config.workspaces?.trim();
|
|
43
|
+
if (!raw) return appDefault;
|
|
44
|
+
let choices;
|
|
45
|
+
try {
|
|
46
|
+
choices = JSON.parse(raw);
|
|
47
|
+
} catch {
|
|
48
|
+
throw new Error("The per-workspace harness configuration is not JSON");
|
|
49
|
+
}
|
|
50
|
+
if (!choices || typeof choices !== "object" || Array.isArray(choices)) {
|
|
51
|
+
throw new Error("The per-workspace harness configuration must map workspace ids to harnesses");
|
|
52
|
+
}
|
|
53
|
+
const parsed = new Map(Object.entries(choices).map(([id, value]) => [id, configHarness(value, `The harness for workspace ${id}`)]));
|
|
54
|
+
return (workspaceId === void 0 ? void 0 : parsed.get(workspaceId)) ?? appDefault;
|
|
55
|
+
}
|
|
36
56
|
function isModelCompatibleWithHarness(harness, modelId) {
|
|
37
57
|
return harnessSupportsModel(harness, modelId);
|
|
38
58
|
}
|
|
@@ -71,9 +91,10 @@ export {
|
|
|
71
91
|
isHarness,
|
|
72
92
|
coerceHarness,
|
|
73
93
|
resolveSessionHarness,
|
|
94
|
+
configuredHarness,
|
|
74
95
|
isModelCompatibleWithHarness,
|
|
75
96
|
snapModelToHarness,
|
|
76
97
|
snapHarnessToModel,
|
|
77
98
|
assertHarnessModelCompatible
|
|
78
99
|
};
|
|
79
|
-
//# sourceMappingURL=chunk-
|
|
100
|
+
//# sourceMappingURL=chunk-WVESWAJJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/harness/index.ts"],"sourcesContent":["/**\n * Coding-agent harness selection — taxonomy, coercion, and the session-lock invariant.\n *\n * A \"harness\" is the coding-agent CLI a sandbox drives (opencode / codex /\n * claude-code / …). The shell governs WHICH harness a chat session uses and\n * enforces that a session is LOCKED to the harness it started with — the model\n * may change mid-session, the harness may not (swapping it mid-session would\n * orphan the session's running agent state). Every product otherwise hand-rolls\n * this and hard-codes a single harness; this is the one place the rule lives.\n *\n * Substrate-free: the harness list is derived from `@tangle-network/agent-interface`'s canonical\n * harness enum and mirrors the sandbox SDK's `BackendType` (no sandbox dependency). The consumer\n * owns storage — which harness a workspace defaults to, which one a session locked — and maps the\n * resolved value onto the SDK's `backend.type`.\n *\n * Harness↔model COMPATIBILITY (which models a harness can run, snapping) is NOT defined here — it\n * comes from `@tangle-network/agent-interface`, the single source of truth shared with the\n * sandbox-ui pickers and the cli-bridge backends. This module owns the harness TAXONOMY + the\n * session lock, and its server assertion also checks resolved transport-provider evidence.\n */\n\nimport {\n harnessProviders,\n harnessSupportsModel,\n harnessTypeSchema,\n modelProvider,\n preferredHarnessForModel,\n snapHarnessToModel as aiSnapHarnessToModel,\n snapModelToHarness as aiSnapModelToHarness,\n type HarnessType,\n} from '@tangle-network/agent-interface'\n\n/**\n * Canonical harnesses that are NOT sandbox backends. Each value in `KNOWN_HARNESSES` is dispatched\n * as `backend.type`, so a harness the platform ships no provider adapter for must stay out —\n * offering it would resolve a session onto a runner that cannot start.\n */\nconst NON_BACKEND_HARNESSES = ['gemini'] as const satisfies readonly HarnessType[]\n\nconst nonBackendHarnesses = new Set<string>(NON_BACKEND_HARNESSES)\n\n/** A coding-agent backend this shell can dispatch a session onto. */\nexport type Harness = Exclude<HarnessType, (typeof NON_BACKEND_HARNESSES)[number]>\n\n/**\n * The known coding-agent backends: the canonical harness set minus what has no provider adapter,\n * Derived from `harnessTypeSchema.options` so a harness added upstream reaches this shell without\n * an edit here, and kept structural so this module still needs no sandbox dependency.\n */\nexport const KNOWN_HARNESSES: readonly Harness[] = [\n ...harnessTypeSchema.options.filter(\n (harness): harness is Exclude<HarnessType, (typeof NON_BACKEND_HARNESSES)[number]> =>\n !nonBackendHarnesses.has(harness),\n ),\n]\n\n/** Define the default harness to use for code execution and testing environments */\nexport const DEFAULT_HARNESS: Harness = 'opencode'\n\nconst HARNESS_SET: ReadonlySet<string> = new Set(KNOWN_HARNESSES)\n\n/** Determine if a value is a recognized harness string identifier */\nexport function isHarness(value: unknown): value is Harness {\n return typeof value === 'string' && HARNESS_SET.has(value)\n}\n\n/** Coerce an arbitrary value to a known harness, falling back (default `opencode`). */\nexport function coerceHarness(value: unknown, fallback: Harness = DEFAULT_HARNESS): Harness {\n return isHarness(value) ? value : fallback\n}\n\n/** Resolve input options to determine the appropriate session harness to use */\nexport interface ResolveSessionHarnessInput {\n /** The harness already locked to this session (recorded at its first turn). */\n sessionHarness?: unknown\n /** The harness requested now — a new session's choice, or a turn's attempt to switch. */\n requested?: unknown\n /** The workspace's default harness, used only when starting a fresh session. */\n workspaceDefault?: unknown\n /** Final fallback when nothing else resolves (default `opencode`). */\n fallback?: Harness\n}\n\n/** Represent resolved session state including harness, lock status, and swap attempt flag */\nexport interface ResolvedSessionHarness {\n /** The harness to actually run — the locked one when the session already has it. */\n harness: Harness\n /** True when the session already had a locked harness (this turn did not pick it). */\n locked: boolean\n /** True when `requested` differs from the locked harness — a forbidden mid-session\n * swap the caller should reject or warn on. The lock always wins regardless. */\n swapAttempted: boolean\n}\n\n/**\n * Resolve the harness for a turn, enforcing the session lock.\n *\n * - **Session already started** (`sessionHarness` is a known harness): that harness\n * wins (`locked: true`); a differing `requested` sets `swapAttempted` so the caller\n * can reject the swap. The model is a separate per-turn concern and is unaffected.\n * - **Fresh session**: pick `requested → workspaceDefault → fallback`. The caller\n * persists the result as the session's lock for every subsequent turn.\n */\nexport function resolveSessionHarness(input: ResolveSessionHarnessInput = {}): ResolvedSessionHarness {\n const fallback = input.fallback ?? DEFAULT_HARNESS\n if (isHarness(input.sessionHarness)) {\n const locked = input.sessionHarness\n const swapAttempted = isHarness(input.requested) && input.requested !== locked\n return { harness: locked, locked: true, swapAttempted }\n }\n const harness = coerceHarness(input.requested, coerceHarness(input.workspaceDefault, fallback))\n return { harness, locked: false, swapAttempted: false }\n}\n\n/**\n * An app's harness configuration, read from its deploy configuration (for example the env vars\n * `AGENT_HARNESS` and `AGENT_HARNESS_WORKSPACES`), so no product hard-codes `backend.type`.\n */\nexport interface HarnessConfig {\n /** The app default for new sessions. Unset or blank means {@link DEFAULT_HARNESS}. */\n default?: string\n /** Per-workspace choices: a JSON object mapping a workspace id to a harness. */\n workspaces?: string\n}\n\nfunction configHarness(value: unknown, where: string): Harness {\n if (!isHarness(value)) throw new Error(`${where} names an unknown harness: ${String(value)}`)\n return value\n}\n\n/**\n * The harness a workspace's new sessions start on: its own choice, else the app default, else\n * {@link DEFAULT_HARNESS}. Pass the result to {@link resolveSessionHarness} as `workspaceDefault`\n * so a session that already ran keeps its harness. A value naming an unknown harness throws:\n * a configuration typo must fail loudly, never run a different harness than the one configured.\n */\nexport function configuredHarness(config: HarnessConfig, workspaceId?: string): Harness {\n const appDefault = config.default?.trim()\n ? configHarness(config.default.trim(), 'The harness default') : DEFAULT_HARNESS\n const raw = config.workspaces?.trim()\n if (!raw) return appDefault\n let choices: unknown\n try {\n choices = JSON.parse(raw)\n } catch {\n throw new Error('The per-workspace harness configuration is not JSON')\n }\n if (!choices || typeof choices !== 'object' || Array.isArray(choices)) {\n throw new Error('The per-workspace harness configuration must map workspace ids to harnesses')\n }\n // Every entry is checked, not only the caller's, so one bad entry fails every workspace's\n // first turn after the deploy instead of hiding until that workspace sends a message.\n const parsed = new Map(Object.entries(choices).map(([id, value]) =>\n [id, configHarness(value, `The harness for workspace ${id}`)]))\n return (workspaceId === undefined ? undefined : parsed.get(workspaceId)) ?? appDefault\n}\n\n/**\n * Harness ↔ model compatibility + snapping — delegated to `@tangle-network/agent-interface`.\n *\n * `Harness` is the dispatchable subset of `HarnessType`: this shell drops only canonical harnesses\n * for which the platform has no backend. Compatibility therefore comes entirely from Interface;\n * this package keeps no second harness taxonomy.\n */\n\nexport { modelProvider }\n\n/** A resolved model and the transport provider that will execute it. */\nexport interface HarnessModelSelection {\n model: string\n provider?: string\n}\n\n/** Provider-less ids (sentinels like \"default\", or a session's own config) are\n * compatible everywhere — every harness honors its own configuration. */\nexport function isModelCompatibleWithHarness(harness: Harness, modelId: string): boolean {\n return harnessSupportsModel(harness, modelId)\n}\n\n/** Keep `modelId` when the harness can run it; else the harness's best compatible\n * catalog id (preferred patterns in order, highest version). When nothing in the\n * catalog fits, return the original so the caller sees the incompatibility. */\nexport function snapModelToHarness(harness: Harness, modelId: string, canonicalIds: readonly string[]): string {\n return aiSnapModelToHarness(harness, modelId, canonicalIds)\n}\n\n/** Keep the harness when it can run `modelId`; else the model's native harness\n * (anthropic → claude-code, openai → codex, moonshot → kimi-code), falling back to opencode. */\nexport function snapHarnessToModel(harness: Harness, modelId: string): Harness {\n const snapped = aiSnapHarnessToModel(harness, modelId)\n if (!isHarness(snapped)) {\n throw new Error(\n `Harness \"${harness}\" snapped to \"${snapped}\" for model \"${modelId}\", which this platform has no backend for.`,\n )\n }\n return snapped\n}\n\n/** Fail-loud server guard: throw when a harness is asked to run a model it can't.\n * A resolved model tuple supplies provider evidence when its id is unqualified.\n * Call before dispatching a sandbox turn so a bypassed UI cannot reach the\n * sidecar with an incompatible or unproven pair. */\nexport function assertHarnessModelCompatible(\n harness: Harness,\n selection: string | HarnessModelSelection,\n): void {\n const modelId = typeof selection === 'string' ? selection : selection.model\n const transportProvider = typeof selection === 'string' ? undefined : selection.provider\n const providers = harnessProviders(harness)\n const provider = modelProvider(modelId) ?? transportProvider ?? null\n // An omitted/default model is deliberately left to the harness. Once a\n // caller names a model, however, a vendor-locked harness must have provider\n // evidence. Treating a router provider as compatible with every native CLI\n // is how a bare Gemini model reached Claude Code and produced \"Not logged in\".\n const isDefaultSentinel = modelId.trim() === '' || modelId.trim() === 'default'\n const compatible = isDefaultSentinel\n || providers === null\n || (provider !== null && providers.includes(provider))\n if (!compatible) {\n const native = preferredHarnessForModel(modelId)\n const providerDescription = provider ?? 'unqualified'\n throw new Error(\n `Harness \"${harness}\" cannot run model \"${modelId}\" (provider \"${providerDescription}\"). ` +\n `Use ${native ?? 'a router-backed harness (opencode)'} or an allowed model.`,\n )\n }\n}\n"],"mappings":";AAqBA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,OAEjB;AAOP,IAAM,wBAAwB,CAAC,QAAQ;AAEvC,IAAM,sBAAsB,IAAI,IAAY,qBAAqB;AAU1D,IAAM,kBAAsC;AAAA,EACjD,GAAG,kBAAkB,QAAQ;AAAA,IAC3B,CAAC,YACC,CAAC,oBAAoB,IAAI,OAAO;AAAA,EACpC;AACF;AAGO,IAAM,kBAA2B;AAExC,IAAM,cAAmC,IAAI,IAAI,eAAe;AAGzD,SAAS,UAAU,OAAkC;AAC1D,SAAO,OAAO,UAAU,YAAY,YAAY,IA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|
isModelCompatibleWithHarness,
|
|
15
15
|
snapModelToHarness
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-WVESWAJJ.js";
|
|
17
17
|
import {
|
|
18
18
|
isCommitSha,
|
|
19
19
|
parseGitHubLocation,
|
|
@@ -2199,4 +2199,4 @@ export {
|
|
|
2199
2199
|
AGENT_PROFILE_EDITOR_SECTIONS,
|
|
2200
2200
|
AgentProfileEditor
|
|
2201
2201
|
};
|
|
2202
|
-
//# sourceMappingURL=chunk-
|
|
2202
|
+
//# sourceMappingURL=chunk-YL5ZTCRU.js.map
|
package/dist/harness/index.d.ts
CHANGED
|
@@ -70,6 +70,23 @@ export interface ResolvedSessionHarness {
|
|
|
70
70
|
* persists the result as the session's lock for every subsequent turn.
|
|
71
71
|
*/
|
|
72
72
|
export declare function resolveSessionHarness(input?: ResolveSessionHarnessInput): ResolvedSessionHarness;
|
|
73
|
+
/**
|
|
74
|
+
* An app's harness configuration, read from its deploy configuration (for example the env vars
|
|
75
|
+
* `AGENT_HARNESS` and `AGENT_HARNESS_WORKSPACES`), so no product hard-codes `backend.type`.
|
|
76
|
+
*/
|
|
77
|
+
export interface HarnessConfig {
|
|
78
|
+
/** The app default for new sessions. Unset or blank means {@link DEFAULT_HARNESS}. */
|
|
79
|
+
default?: string;
|
|
80
|
+
/** Per-workspace choices: a JSON object mapping a workspace id to a harness. */
|
|
81
|
+
workspaces?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The harness a workspace's new sessions start on: its own choice, else the app default, else
|
|
85
|
+
* {@link DEFAULT_HARNESS}. Pass the result to {@link resolveSessionHarness} as `workspaceDefault`
|
|
86
|
+
* so a session that already ran keeps its harness. A value naming an unknown harness throws:
|
|
87
|
+
* a configuration typo must fail loudly, never run a different harness than the one configured.
|
|
88
|
+
*/
|
|
89
|
+
export declare function configuredHarness(config: HarnessConfig, workspaceId?: string): Harness;
|
|
73
90
|
/**
|
|
74
91
|
* Harness ↔ model compatibility + snapping — delegated to `@tangle-network/agent-interface`.
|
|
75
92
|
*
|
package/dist/harness/index.js
CHANGED
|
@@ -3,18 +3,20 @@ import {
|
|
|
3
3
|
KNOWN_HARNESSES,
|
|
4
4
|
assertHarnessModelCompatible,
|
|
5
5
|
coerceHarness,
|
|
6
|
+
configuredHarness,
|
|
6
7
|
isHarness,
|
|
7
8
|
isModelCompatibleWithHarness,
|
|
8
9
|
modelProvider,
|
|
9
10
|
resolveSessionHarness,
|
|
10
11
|
snapHarnessToModel,
|
|
11
12
|
snapModelToHarness
|
|
12
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-WVESWAJJ.js";
|
|
13
14
|
export {
|
|
14
15
|
DEFAULT_HARNESS,
|
|
15
16
|
KNOWN_HARNESSES,
|
|
16
17
|
assertHarnessModelCompatible,
|
|
17
18
|
coerceHarness,
|
|
19
|
+
configuredHarness,
|
|
18
20
|
isHarness,
|
|
19
21
|
isModelCompatibleWithHarness,
|
|
20
22
|
modelProvider,
|
package/dist/runtime/index.d.ts
CHANGED
package/dist/runtime/index.js
CHANGED
|
@@ -97,13 +97,13 @@ function createOpenAICompatStreamTurn(opts) {
|
|
|
97
97
|
...opts.tools && opts.tools.length > 0 ? { tools: opts.tools } : {},
|
|
98
98
|
...opts.temperature != null ? { temperature: opts.temperature } : {},
|
|
99
99
|
...opts.extraBody
|
|
100
|
-
}, opts.onServedModel ? { requestedModel: opts.model, report: opts.onServedModel } : void 0)
|
|
100
|
+
}, opts.onServedModel ? { requestedModel: opts.model, report: opts.onServedModel } : void 0, opts.headers)
|
|
101
101
|
);
|
|
102
102
|
}
|
|
103
|
-
async function* streamChatCompletions(doFetch, url, apiKey, body, attribution) {
|
|
103
|
+
async function* streamChatCompletions(doFetch, url, apiKey, body, attribution, headers) {
|
|
104
104
|
const res = await doFetch(url, {
|
|
105
105
|
method: "POST",
|
|
106
|
-
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", Accept: "text/event-stream" },
|
|
106
|
+
headers: { ...headers, Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", Accept: "text/event-stream" },
|
|
107
107
|
body: JSON.stringify(body)
|
|
108
108
|
});
|
|
109
109
|
if (!res.ok || !res.body) {
|
|
@@ -163,6 +163,173 @@ async function* streamChatCompletions(doFetch, url, apiKey, body, attribution) {
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
// src/runtime/loop.ts
|
|
167
|
+
import {
|
|
168
|
+
runToolLoop,
|
|
169
|
+
streamToolLoop
|
|
170
|
+
} from "@tangle-network/agent-runtime/tool-loop";
|
|
171
|
+
|
|
172
|
+
// src/runtime/router-turn.ts
|
|
173
|
+
var DEFAULT_BUDGET_MS = 9e4;
|
|
174
|
+
var TOOL_RESULT_LIMIT = 12e3;
|
|
175
|
+
function routerFunctionName(name) {
|
|
176
|
+
return name.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 64);
|
|
177
|
+
}
|
|
178
|
+
function composeRouterTurnPrompt(profile, options = {}) {
|
|
179
|
+
const text = [profile.prompt?.systemPrompt ?? "", ...profile.prompt?.instructions ?? [], ...options.context ?? []].filter((part) => part.trim()).join("\n\n");
|
|
180
|
+
return [...options.toolNames ?? []].sort((a, b) => b.length - a.length).reduce((out, name) => out.split(name).join(routerFunctionName(name)), text);
|
|
181
|
+
}
|
|
182
|
+
function defaultToolError(error) {
|
|
183
|
+
const value = error;
|
|
184
|
+
if (Array.isArray(value?.issues)) {
|
|
185
|
+
return { code: "invalid_arguments", message: JSON.stringify(value.issues).slice(0, 600) };
|
|
186
|
+
}
|
|
187
|
+
if (typeof value?.code === "string" && typeof value.message === "string") {
|
|
188
|
+
return { code: value.code, message: value.message, ...typeof value.status === "number" ? { status: value.status } : {} };
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
function renderResult(outcome) {
|
|
193
|
+
if (!outcome.ok) return `Error (${outcome.code}): ${outcome.message}`;
|
|
194
|
+
let text;
|
|
195
|
+
try {
|
|
196
|
+
text = typeof outcome.result === "string" ? outcome.result : JSON.stringify(outcome.result ?? null);
|
|
197
|
+
} catch {
|
|
198
|
+
text = String(outcome.result);
|
|
199
|
+
}
|
|
200
|
+
return text.length > TOOL_RESULT_LIMIT ? `${text.slice(0, TOOL_RESULT_LIMIT)}\u2026` : text;
|
|
201
|
+
}
|
|
202
|
+
async function runRouterTurn(options) {
|
|
203
|
+
if (!options.apiKey) {
|
|
204
|
+
return {
|
|
205
|
+
text: "",
|
|
206
|
+
servedModel: null,
|
|
207
|
+
toolCalls: [],
|
|
208
|
+
failure: { code: "router_unconfigured", message: "The model credential is not configured." }
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
const emit = options.onEvent ?? (() => {
|
|
212
|
+
});
|
|
213
|
+
const byFunction = /* @__PURE__ */ new Map();
|
|
214
|
+
for (const tool of options.tools ?? []) {
|
|
215
|
+
const fn = routerFunctionName(tool.name);
|
|
216
|
+
if (!byFunction.has(fn)) byFunction.set(fn, tool);
|
|
217
|
+
}
|
|
218
|
+
let servedModel = null;
|
|
219
|
+
const streamTurn = createOpenAICompatStreamTurn({
|
|
220
|
+
baseUrl: options.baseUrl ?? DEFAULT_TANGLE_ROUTER_BASE_URL,
|
|
221
|
+
apiKey: options.apiKey,
|
|
222
|
+
model: options.model,
|
|
223
|
+
tools: [...byFunction.entries()].map(([name, tool]) => ({
|
|
224
|
+
type: "function",
|
|
225
|
+
function: { name, description: tool.description, parameters: tool.inputSchema }
|
|
226
|
+
})),
|
|
227
|
+
...options.maxTokens ? { extraBody: { max_tokens: options.maxTokens } } : {},
|
|
228
|
+
...options.traceId ? { headers: { "x-tangle-trace-id": options.traceId } } : {},
|
|
229
|
+
...options.fetchImpl ? { fetchImpl: options.fetchImpl } : {},
|
|
230
|
+
onServedModel: (served) => {
|
|
231
|
+
servedModel = served.servedModel;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
const segments = [];
|
|
235
|
+
const toolCalls = [];
|
|
236
|
+
const started = /* @__PURE__ */ new Map();
|
|
237
|
+
let segmentOpen = false;
|
|
238
|
+
let toolsRan = 0;
|
|
239
|
+
const deadline = Date.now() + (options.budgetMs ?? DEFAULT_BUDGET_MS);
|
|
240
|
+
const callIdOf = (id, toolName) => id ?? `${toolName}-${started.size}`;
|
|
241
|
+
const run = async () => {
|
|
242
|
+
for await (const step of streamToolLoop({
|
|
243
|
+
systemPrompt: options.systemPrompt,
|
|
244
|
+
userMessage: options.userMessage,
|
|
245
|
+
priorMessages: options.history ?? [],
|
|
246
|
+
streamTurn,
|
|
247
|
+
extractText: (event) => event.type === "text" ? event.text : "",
|
|
248
|
+
extractToolCall: (event) => event.type === "tool_call" ? event.call : null,
|
|
249
|
+
isExecutableTool: (name) => byFunction.has(name),
|
|
250
|
+
deadlineMs: deadline,
|
|
251
|
+
maxToolTurns: options.maxToolTurns ?? 12,
|
|
252
|
+
renderResult: (_label, outcome2) => renderResult(outcome2),
|
|
253
|
+
executeToolCall: async (call) => {
|
|
254
|
+
const tool = byFunction.get(call.toolName);
|
|
255
|
+
if (!tool) return { ok: false, code: "unknown_tool", message: `No tool named ${call.toolName}` };
|
|
256
|
+
toolsRan++;
|
|
257
|
+
try {
|
|
258
|
+
return { ok: true, result: await tool.run(call.args) };
|
|
259
|
+
} catch (error) {
|
|
260
|
+
const mapped = (options.toolError ?? defaultToolError)(error);
|
|
261
|
+
if (mapped) return { ok: false, ...mapped };
|
|
262
|
+
options.onToolFailure?.(tool.name, error);
|
|
263
|
+
return { ok: false, code: "tool_failed", message: "The tool failed; tell the user what could not be completed." };
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
})) {
|
|
267
|
+
if (step.kind === "event") {
|
|
268
|
+
const event = step.event;
|
|
269
|
+
if (event.type === "text" && event.text) {
|
|
270
|
+
if (!segmentOpen) {
|
|
271
|
+
segments.push("");
|
|
272
|
+
segmentOpen = true;
|
|
273
|
+
}
|
|
274
|
+
segments[segments.length - 1] += event.text;
|
|
275
|
+
emit({ type: "text", segment: segments.length, delta: event.text });
|
|
276
|
+
} else if (event.type === "tool_call") {
|
|
277
|
+
segmentOpen = false;
|
|
278
|
+
const tool = byFunction.get(event.call.toolName);
|
|
279
|
+
const callId = callIdOf(event.call.toolCallId, event.call.toolName);
|
|
280
|
+
started.set(callId, Date.now());
|
|
281
|
+
emit({
|
|
282
|
+
type: "tool",
|
|
283
|
+
callId,
|
|
284
|
+
toolName: tool?.name ?? event.call.toolName,
|
|
285
|
+
status: "running",
|
|
286
|
+
input: event.call.args,
|
|
287
|
+
startedAt: started.get(callId)
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
} else if (step.kind === "tool_result") {
|
|
291
|
+
const tool = byFunction.get(step.toolName);
|
|
292
|
+
const callId = callIdOf(step.toolCallId, step.toolName);
|
|
293
|
+
const startedAt = started.get(callId) ?? Date.now();
|
|
294
|
+
const toolName = tool?.name ?? step.toolName;
|
|
295
|
+
toolCalls.push({ callId, toolName, ok: step.outcome.ok });
|
|
296
|
+
emit(step.outcome.ok ? { type: "tool", callId, toolName, status: "completed", output: step.outcome.result, startedAt, endedAt: Date.now() } : {
|
|
297
|
+
type: "tool",
|
|
298
|
+
callId,
|
|
299
|
+
toolName,
|
|
300
|
+
status: "error",
|
|
301
|
+
startedAt,
|
|
302
|
+
endedAt: Date.now(),
|
|
303
|
+
error: { code: step.outcome.code, message: step.outcome.message }
|
|
304
|
+
});
|
|
305
|
+
} else if (step.kind === "capped") {
|
|
306
|
+
return step.stopReason;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return "completed";
|
|
310
|
+
};
|
|
311
|
+
const outcome = (failure) => ({
|
|
312
|
+
text: segments.map((part) => part.trim()).filter(Boolean).join("\n\n"),
|
|
313
|
+
servedModel,
|
|
314
|
+
toolCalls,
|
|
315
|
+
...failure ? { failure } : {}
|
|
316
|
+
});
|
|
317
|
+
let stop;
|
|
318
|
+
try {
|
|
319
|
+
try {
|
|
320
|
+
stop = await run();
|
|
321
|
+
} catch (error) {
|
|
322
|
+
if (toolsRan > 0 || segments.length > 0) throw error;
|
|
323
|
+
stop = await run();
|
|
324
|
+
}
|
|
325
|
+
} catch (error) {
|
|
326
|
+
const status = error.status;
|
|
327
|
+
return outcome(typeof status === "number" ? { code: `model_http_${status}`, status, message: "The model service did not answer." } : { code: "model_unavailable", message: "The model service did not answer." });
|
|
328
|
+
}
|
|
329
|
+
if (stop !== "completed") return outcome({ code: `turn_${stop}`, message: "The reply was stopped before it finished." });
|
|
330
|
+
return outcome();
|
|
331
|
+
}
|
|
332
|
+
|
|
166
333
|
// src/runtime/certified-delivery.ts
|
|
167
334
|
import {
|
|
168
335
|
createCertifiedPromptSource
|
|
@@ -271,12 +438,6 @@ function assertSurfaceOverlay(overlay, label) {
|
|
|
271
438
|
}
|
|
272
439
|
}
|
|
273
440
|
}
|
|
274
|
-
|
|
275
|
-
// src/runtime/loop.ts
|
|
276
|
-
import {
|
|
277
|
-
runToolLoop,
|
|
278
|
-
streamToolLoop
|
|
279
|
-
} from "@tangle-network/agent-runtime/tool-loop";
|
|
280
441
|
export {
|
|
281
442
|
DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR,
|
|
282
443
|
DEFAULT_TANGLE_ROUTER_BASE_URL,
|
|
@@ -286,6 +447,7 @@ export {
|
|
|
286
447
|
__resetCatalogCache,
|
|
287
448
|
buildCatalog,
|
|
288
449
|
catalogModelForId,
|
|
450
|
+
composeRouterTurnPrompt,
|
|
289
451
|
createCertifiedDelivery,
|
|
290
452
|
createOpenAICompatStreamTurn,
|
|
291
453
|
createRouterProtectedModelPort,
|
|
@@ -304,7 +466,9 @@ export {
|
|
|
304
466
|
resolveTangleModelConfig,
|
|
305
467
|
resolveUserTangleExecutionKey,
|
|
306
468
|
resolveUserTangleExecutionKeyForUser,
|
|
469
|
+
routerFunctionName,
|
|
307
470
|
runToolLoop as runAppToolLoop,
|
|
471
|
+
runRouterTurn,
|
|
308
472
|
sortModelsByFreshness,
|
|
309
473
|
streamToolLoop as streamAppToolLoop,
|
|
310
474
|
tangleExecutionKeyHttpError,
|