@tangle-network/cli-agent-registry 0.0.0-stage → 0.15.0
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 +11 -0
- package/README.md +175 -2
- package/dist/backend-types-CNo_Zj_K.mjs +36 -0
- package/dist/backend-types-DRmLR1e0.d.mts +47 -0
- package/dist/backend-types.d.mts +2 -0
- package/dist/backend-types.mjs +2 -0
- package/dist/cli-auth-bundle-C6DtK7GX.mjs +95 -0
- package/dist/cli-auth-bundle-CwAaH0Ap.d.mts +51 -0
- package/dist/cli-auth-bundle.d.mts +2 -0
- package/dist/cli-auth-bundle.mjs +2 -0
- package/dist/cli-auth-placeholder.d.mts +54 -0
- package/dist/cli-auth-placeholder.mjs +200 -0
- package/dist/cli-backend-auth-env.d.mts +6 -0
- package/dist/cli-backend-auth-env.mjs +44 -0
- package/dist/default-backend.d.mts +24 -0
- package/dist/default-backend.mjs +31 -0
- package/dist/harness-D1fTxnDD.mjs +199 -0
- package/dist/harness-contracts-BZoECCMc.mjs +1076 -0
- package/dist/host-contracts.d.mts +30 -0
- package/dist/host-contracts.json +422 -0
- package/dist/host-contracts.mjs +63 -0
- package/dist/index.d.mts +1397 -0
- package/dist/index.mjs +151 -0
- package/dist/local-cli-auth.d.mts +14 -0
- package/dist/local-cli-auth.mjs +31 -0
- package/dist/native-session-contracts.d.mts +349 -0
- package/dist/native-session-contracts.mjs +40 -0
- package/dist/servable-models.d.mts +103 -0
- package/dist/servable-models.mjs +131 -0
- package/dist/session-contract-BhzcbPRW.d.mts +97 -0
- package/dist/session-contract.d.mts +2 -0
- package/dist/session-contract.mjs +142 -0
- package/dist/spec-CcvTM7-j.d.mts +346 -0
- package/dist/specs-BBF55TnM.mjs +735 -0
- package/dist/specs.d.mts +72 -0
- package/dist/specs.mjs +3 -0
- package/package.json +87 -3
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { t as HARNESSES } from "./harness-contracts-BZoECCMc.mjs";
|
|
2
|
+
import { HARNESS_SESSION_UNSUPPORTED, NATIVE_SESSION_CONTRACTS, configDirHomeEnv } from "./native-session-contracts.mjs";
|
|
3
|
+
import { HarnessSessionContractError, SESSION_FORMAT_IDS, assertArgvHonoursSessionContract, assertFlagsHonourSessionContract, assertStoreLocationHonoursSessionContract, compileSessionStoreGlob, forbiddenArgViolations, normalizePosixPath, sessionContractProblems, sessionStoreForPath, substituteNativeSessionId } from "./session-contract.mjs";
|
|
4
|
+
import { a as parseBackendType, i as isBackendType, n as BACKEND_TYPE, r as backendTypeSchema, t as ALL_BACKEND_TYPES } from "./backend-types-CNo_Zj_K.mjs";
|
|
5
|
+
import { a as agentProfileSchema, c as cliAgentHostPassthroughEnvVarNames, d as canonicalModelSlug, f as cliAgentClaimEnvVarNames, g as SYNTHETIC_ROUTER_MODEL, h as harnessModelWire, i as MANAGED_MODEL_KEY_NAME_ENV_VAR, l as getSpec, m as harnessModelSupportFor, n as CLI_AGENT_SPECS, o as claimDeliverableEnvVarNames, p as cliAgentEnvRoleName, r as MANAGED_MODEL_KEY_ENV_VAR, s as cliAgentEnvVarNamesByRole, t as AGENT_BACKEND_ENV_VAR, u as messageStorageDirOf } from "./specs-BBF55TnM.mjs";
|
|
6
|
+
import { a as materializeCliAuthBundle } from "./cli-auth-bundle-C6DtK7GX.mjs";
|
|
7
|
+
import { resolveDefaultBackend } from "./default-backend.mjs";
|
|
8
|
+
import { describeLocalCliAuthExpectation, discoverLocalCliAuthFiles } from "./local-cli-auth.mjs";
|
|
9
|
+
import { MANAGED_MODEL_LADDER, bareModelId, isServableManagedModel, managedModelChain } from "./servable-models.mjs";
|
|
10
|
+
import { sha256DigestSchema } from "@tangle-network/agent-interface";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
//#region src/adapter-bindings.ts
|
|
13
|
+
/**
|
|
14
|
+
* A composition-owned factory map. Wiring requirements come from this selected
|
|
15
|
+
* catalog, not every harness known elsewhere. No provider implementation is
|
|
16
|
+
* imported here, and separate registries cannot overwrite each other's bindings.
|
|
17
|
+
*
|
|
18
|
+
* Registration itself does not authorize execution. As with the existing API,
|
|
19
|
+
* factories may be staged before catalog admission; callers must still resolve
|
|
20
|
+
* a selected spec and enforce its capabilities before dispatching a request.
|
|
21
|
+
* Unregistering a required factory is not retirement: select a new composition
|
|
22
|
+
* after draining its sessions rather than weakening the wiring invariant.
|
|
23
|
+
*/
|
|
24
|
+
function createAdapterRegistry(specs) {
|
|
25
|
+
const selected = /* @__PURE__ */ new Map();
|
|
26
|
+
for (const spec of specs) {
|
|
27
|
+
if (selected.has(spec.name)) throw new Error(`cli-agent-registry: duplicate spec "${spec.name}"`);
|
|
28
|
+
selected.set(spec.name, {
|
|
29
|
+
sessions: spec.capabilities.sessions,
|
|
30
|
+
nativeSession: spec.nativeSession != null
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const factories = /* @__PURE__ */ new Map();
|
|
34
|
+
function assertSessionContractDeclared(name) {
|
|
35
|
+
const spec = selected.get(name);
|
|
36
|
+
if (!spec?.sessions || spec.nativeSession) return;
|
|
37
|
+
if (Object.hasOwn(HARNESS_SESSION_UNSUPPORTED, name)) return;
|
|
38
|
+
throw new HarnessSessionContractError("harness_session_contract_missing", `${name} runs sessions but declares no nativeSession contract`);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
registerAdapterFactory(name, factory, options) {
|
|
42
|
+
assertSessionContractDeclared(name);
|
|
43
|
+
if (factories.has(name) && !options?.force) throw new Error(`cli-agent-registry: adapter factory for "${name}" already registered. Pass { force: true } to override (test stubs only) or call unregisterAdapterFactory() first.`);
|
|
44
|
+
factories.set(name, factory);
|
|
45
|
+
},
|
|
46
|
+
unregisterAdapterFactory(name) {
|
|
47
|
+
return factories.delete(name);
|
|
48
|
+
},
|
|
49
|
+
getAdapterFactory(name) {
|
|
50
|
+
return factories.get(name);
|
|
51
|
+
},
|
|
52
|
+
listRegisteredAdapters() {
|
|
53
|
+
return Array.from(factories.keys());
|
|
54
|
+
},
|
|
55
|
+
assertAdaptersWired() {
|
|
56
|
+
const missing = [];
|
|
57
|
+
for (const [name, spec] of selected) {
|
|
58
|
+
assertSessionContractDeclared(name);
|
|
59
|
+
if (spec.sessions && !factories.has(name)) missing.push(name);
|
|
60
|
+
}
|
|
61
|
+
if (missing.length > 0) throw new Error(`cli-agent-registry: executable backend specs without an adapter factory registered: ${missing.join(", ")}. Register each selected adapter in the composition root before startup.`);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const defaultRegistry = createAdapterRegistry(CLI_AGENT_SPECS);
|
|
66
|
+
function registerAdapterFactory(name, factory, options) {
|
|
67
|
+
defaultRegistry.registerAdapterFactory(name, factory, options);
|
|
68
|
+
}
|
|
69
|
+
function unregisterAdapterFactory(name) {
|
|
70
|
+
return defaultRegistry.unregisterAdapterFactory(name);
|
|
71
|
+
}
|
|
72
|
+
function getAdapterFactory(name) {
|
|
73
|
+
return defaultRegistry.getAdapterFactory(name);
|
|
74
|
+
}
|
|
75
|
+
function listRegisteredAdapters() {
|
|
76
|
+
return defaultRegistry.listRegisteredAdapters();
|
|
77
|
+
}
|
|
78
|
+
function assertAdaptersWired() {
|
|
79
|
+
defaultRegistry.assertAdaptersWired();
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/agent-run-request.ts
|
|
83
|
+
/** A backend carries an inline profile, a profile digest, or neither. */
|
|
84
|
+
function agentRunBackendVariants(base) {
|
|
85
|
+
const profileSha256 = z.string().regex(/^[a-f0-9]{64}$/, "profileSha256 must be a lowercase SHA-256");
|
|
86
|
+
return z.union([
|
|
87
|
+
z.object({
|
|
88
|
+
...base,
|
|
89
|
+
profile: agentProfileSchema
|
|
90
|
+
}).strict(),
|
|
91
|
+
z.object({
|
|
92
|
+
...base,
|
|
93
|
+
profileSha256
|
|
94
|
+
}).strict(),
|
|
95
|
+
z.object(base).strict()
|
|
96
|
+
]);
|
|
97
|
+
}
|
|
98
|
+
const agentRunWorkspaceSchema = z.object({
|
|
99
|
+
rootPath: z.string().optional(),
|
|
100
|
+
debugDirectory: z.string().optional(),
|
|
101
|
+
skipInitialization: z.boolean().optional(),
|
|
102
|
+
cleanupOnShutdown: z.boolean().optional()
|
|
103
|
+
});
|
|
104
|
+
/** The shared request fields, in wire order around each end's workspace and backend. */
|
|
105
|
+
function agentRunRequestSharedShape(workspace, backend) {
|
|
106
|
+
return {
|
|
107
|
+
sessionId: z.string().optional(),
|
|
108
|
+
displayName: z.string().optional(),
|
|
109
|
+
description: z.string().optional(),
|
|
110
|
+
domains: z.array(z.string()).optional(),
|
|
111
|
+
workspace,
|
|
112
|
+
backend,
|
|
113
|
+
expectedPublicProfileRequestDigest: sha256DigestSchema.optional(),
|
|
114
|
+
expectedPublicProfileRevision: z.object({
|
|
115
|
+
workspacePlanDigest: sha256DigestSchema,
|
|
116
|
+
materializedDigest: sha256DigestSchema,
|
|
117
|
+
launchDigest: z.string().regex(/^[a-f0-9]{64}$/)
|
|
118
|
+
}).strict().optional(),
|
|
119
|
+
expectedSecretProfileReceipt: z.string().regex(/^hmac-sha256:[a-f0-9]{64}$/).optional(),
|
|
120
|
+
githubToken: z.string().optional(),
|
|
121
|
+
metadata: z.record(z.string(), z.unknown()).optional()
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/cli-dir-layout.ts
|
|
126
|
+
/** What every CLI's directory is read with; a spec adds its own entries. */
|
|
127
|
+
const DEFAULT_CLI_DIR_LAYOUT = {
|
|
128
|
+
homeSessionData: [],
|
|
129
|
+
sessionData: ["messages/**", "history.jsonl"],
|
|
130
|
+
configAllow: [
|
|
131
|
+
"config.toml",
|
|
132
|
+
"settings.json",
|
|
133
|
+
"settings.local.json",
|
|
134
|
+
"opencode.jsonc",
|
|
135
|
+
"package.json",
|
|
136
|
+
"package-lock.json",
|
|
137
|
+
"models_cache.json",
|
|
138
|
+
"installation_id",
|
|
139
|
+
"version.json",
|
|
140
|
+
".personality_migration"
|
|
141
|
+
],
|
|
142
|
+
credential: []
|
|
143
|
+
};
|
|
144
|
+
/** The default layout with a spec's additions. */
|
|
145
|
+
function mergeCliDirLayout(additions) {
|
|
146
|
+
return Object.fromEntries(Object.entries(DEFAULT_CLI_DIR_LAYOUT).map(([key, paths]) => [key, [...paths, ...additions?.[key] ?? []]]));
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
export { AGENT_BACKEND_ENV_VAR, ALL_BACKEND_TYPES, BACKEND_TYPE, CLI_AGENT_SPECS, DEFAULT_CLI_DIR_LAYOUT, HARNESSES, HARNESS_SESSION_UNSUPPORTED, HarnessSessionContractError, MANAGED_MODEL_KEY_ENV_VAR, MANAGED_MODEL_KEY_NAME_ENV_VAR, MANAGED_MODEL_LADDER, NATIVE_SESSION_CONTRACTS, SESSION_FORMAT_IDS, SYNTHETIC_ROUTER_MODEL, agentProfileSchema, agentRunBackendVariants, agentRunRequestSharedShape, agentRunWorkspaceSchema, assertAdaptersWired, assertArgvHonoursSessionContract, assertFlagsHonourSessionContract, assertStoreLocationHonoursSessionContract, backendTypeSchema, bareModelId, canonicalModelSlug, claimDeliverableEnvVarNames, cliAgentClaimEnvVarNames, cliAgentEnvRoleName, cliAgentEnvVarNamesByRole, cliAgentHostPassthroughEnvVarNames, compileSessionStoreGlob, configDirHomeEnv, createAdapterRegistry, describeLocalCliAuthExpectation, discoverLocalCliAuthFiles, forbiddenArgViolations, getAdapterFactory, getSpec, harnessModelSupportFor, harnessModelWire, isBackendType, isServableManagedModel, listRegisteredAdapters, managedModelChain, materializeCliAuthBundle, mergeCliDirLayout, messageStorageDirOf, normalizePosixPath, parseBackendType, registerAdapterFactory, resolveDefaultBackend, sessionContractProblems, sessionStoreForPath, substituteNativeSessionId, unregisterAdapterFactory };
|
|
150
|
+
|
|
151
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { i as LocalCliAuthFile } from "./cli-auth-bundle-CwAaH0Ap.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/local-cli-auth.d.ts
|
|
4
|
+
type LocalCliAuthBackend = "codex" | "claude-code";
|
|
5
|
+
type DiscoverOptions = {
|
|
6
|
+
homeDir?: string;
|
|
7
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
8
|
+
credentialOnly?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare function discoverLocalCliAuthFiles(backendType: LocalCliAuthBackend, options?: DiscoverOptions): LocalCliAuthFile[] | undefined;
|
|
11
|
+
declare function describeLocalCliAuthExpectation(backendType: LocalCliAuthBackend): string;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { type LocalCliAuthFile, describeLocalCliAuthExpectation, discoverLocalCliAuthFiles };
|
|
14
|
+
//# sourceMappingURL=local-cli-auth.d.mts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { t as AUTH_BUNDLE_PATHS } from "./cli-auth-bundle-C6DtK7GX.mjs";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { basename, dirname, join } from "node:path";
|
|
5
|
+
//#region src/local-cli-auth.ts
|
|
6
|
+
const DEFAULT_MODE = 384;
|
|
7
|
+
function readAuthFile(sourcePath, targetPath) {
|
|
8
|
+
if (!existsSync(sourcePath)) return null;
|
|
9
|
+
return {
|
|
10
|
+
path: targetPath,
|
|
11
|
+
content: readFileSync(sourcePath, "utf-8"),
|
|
12
|
+
mode: DEFAULT_MODE
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function discoverLocalCliAuthFiles(backendType, options = {}) {
|
|
16
|
+
const env = options.env ?? (options.homeDir === void 0 ? process.env : {});
|
|
17
|
+
const homeDir = options.homeDir ?? (env.HOME || homedir());
|
|
18
|
+
const authPath = AUTH_BUNDLE_PATHS[backendType];
|
|
19
|
+
const configDir = env[backendType === "codex" ? "CODEX_HOME" : "CLAUDE_CONFIG_DIR"] || join(homeDir, dirname(authPath));
|
|
20
|
+
const credentialDir = backendType === "claude-code" ? env.CLAUDE_SECURESTORAGE_CONFIG_DIR || configDir : configDir;
|
|
21
|
+
const authFiles = [authPath, ...backendType === "claude-code" && !options.credentialOnly ? [".claude/settings.json", ".claude/settings.local.json"] : []].map((path) => readAuthFile(join(path === authPath ? credentialDir : configDir, basename(path)), path)).filter((entry) => entry !== null);
|
|
22
|
+
return authFiles.length > 0 ? authFiles : void 0;
|
|
23
|
+
}
|
|
24
|
+
function describeLocalCliAuthExpectation(backendType) {
|
|
25
|
+
if (backendType === "codex") return "auth.json in CODEX_HOME, or ~/.codex when CODEX_HOME is unset";
|
|
26
|
+
return "Claude credential files in CLAUDE_SECURESTORAGE_CONFIG_DIR or CLAUDE_CONFIG_DIR (default ~/.claude)";
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { describeLocalCliAuthExpectation, discoverLocalCliAuthFiles };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=local-cli-auth.mjs.map
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { o as NativeSessionStore } from "./session-contract-BhzcbPRW.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/native-session-contracts.d.ts
|
|
4
|
+
/** Native session contracts. A receipt proves each pin. There is no pending list. */
|
|
5
|
+
declare const NATIVE_SESSION_CONTRACTS: {
|
|
6
|
+
readonly "claude-code": {
|
|
7
|
+
version: 1;
|
|
8
|
+
stores: [NativeSessionStore];
|
|
9
|
+
identity: {
|
|
10
|
+
kind: "pre-minted";
|
|
11
|
+
args: string[];
|
|
12
|
+
};
|
|
13
|
+
resume: {
|
|
14
|
+
kind: "args";
|
|
15
|
+
args: string[];
|
|
16
|
+
};
|
|
17
|
+
forbiddenArgs: string[];
|
|
18
|
+
storeEnv: {
|
|
19
|
+
CLAUDE_CONFIG_DIR: string;
|
|
20
|
+
};
|
|
21
|
+
evidence: {
|
|
22
|
+
servedModel: "provider-response";
|
|
23
|
+
usage: "per-response";
|
|
24
|
+
endingError: "session-record";
|
|
25
|
+
};
|
|
26
|
+
cliVersion: "2.1.311";
|
|
27
|
+
};
|
|
28
|
+
readonly codex: {
|
|
29
|
+
version: 1;
|
|
30
|
+
stores: [NativeSessionStore, NativeSessionStore];
|
|
31
|
+
identity: {
|
|
32
|
+
kind: "first-event";
|
|
33
|
+
event: string;
|
|
34
|
+
deadlineMs: number;
|
|
35
|
+
};
|
|
36
|
+
resume: {
|
|
37
|
+
kind: "args";
|
|
38
|
+
args: string[];
|
|
39
|
+
};
|
|
40
|
+
forbiddenArgs: string[];
|
|
41
|
+
storeEnv: {
|
|
42
|
+
CODEX_HOME: string;
|
|
43
|
+
};
|
|
44
|
+
evidence: {
|
|
45
|
+
servedModel: "turn-context";
|
|
46
|
+
usage: "cumulative";
|
|
47
|
+
endingError: "session-record";
|
|
48
|
+
};
|
|
49
|
+
cliVersion: "0.164.0";
|
|
50
|
+
};
|
|
51
|
+
readonly opencode: {
|
|
52
|
+
version: 1;
|
|
53
|
+
stores: [{
|
|
54
|
+
root: string;
|
|
55
|
+
files: string[];
|
|
56
|
+
write: "sqlite-wal";
|
|
57
|
+
shared: true;
|
|
58
|
+
format: "opencode.sqlite";
|
|
59
|
+
}];
|
|
60
|
+
identity: {
|
|
61
|
+
kind: "first-event";
|
|
62
|
+
event: string;
|
|
63
|
+
deadlineMs: number;
|
|
64
|
+
};
|
|
65
|
+
resume: {
|
|
66
|
+
kind: "args";
|
|
67
|
+
args: string[];
|
|
68
|
+
};
|
|
69
|
+
forbiddenArgs: never[];
|
|
70
|
+
storeEnv: {
|
|
71
|
+
XDG_DATA_HOME: string;
|
|
72
|
+
};
|
|
73
|
+
evidence: {
|
|
74
|
+
servedModel: "turn-context";
|
|
75
|
+
usage: "per-response";
|
|
76
|
+
endingError: "session-record";
|
|
77
|
+
};
|
|
78
|
+
cliVersion: "1.19.4";
|
|
79
|
+
};
|
|
80
|
+
readonly pi: {
|
|
81
|
+
version: 1;
|
|
82
|
+
stores: [{
|
|
83
|
+
root: string;
|
|
84
|
+
files: string[];
|
|
85
|
+
write: "jsonl-append";
|
|
86
|
+
shared: false;
|
|
87
|
+
format: "pi.session-jsonl";
|
|
88
|
+
}];
|
|
89
|
+
identity: {
|
|
90
|
+
kind: "pre-minted";
|
|
91
|
+
args: string[];
|
|
92
|
+
};
|
|
93
|
+
resume: {
|
|
94
|
+
kind: "args";
|
|
95
|
+
args: string[];
|
|
96
|
+
};
|
|
97
|
+
forbiddenArgs: string[];
|
|
98
|
+
storeEnv: {
|
|
99
|
+
PI_CODING_AGENT_DIR: string;
|
|
100
|
+
PI_CODING_AGENT_SESSION_DIR: string;
|
|
101
|
+
"--session-dir": string;
|
|
102
|
+
};
|
|
103
|
+
evidence: {
|
|
104
|
+
servedModel: "session-record";
|
|
105
|
+
usage: "per-response";
|
|
106
|
+
endingError: "session-record";
|
|
107
|
+
};
|
|
108
|
+
cliVersion: "1.4.0";
|
|
109
|
+
};
|
|
110
|
+
readonly "kimi-code": {
|
|
111
|
+
version: 1;
|
|
112
|
+
stores: [NativeSessionStore];
|
|
113
|
+
identity: {
|
|
114
|
+
kind: "pre-minted";
|
|
115
|
+
args: string[];
|
|
116
|
+
};
|
|
117
|
+
resume: {
|
|
118
|
+
kind: "args";
|
|
119
|
+
args: string[];
|
|
120
|
+
};
|
|
121
|
+
forbiddenArgs: never[];
|
|
122
|
+
storeEnv: {};
|
|
123
|
+
evidence: {
|
|
124
|
+
servedModel: "none";
|
|
125
|
+
usage: "per-response";
|
|
126
|
+
endingError: "session-record";
|
|
127
|
+
};
|
|
128
|
+
cliVersion: "1.49.0";
|
|
129
|
+
};
|
|
130
|
+
readonly "factory-droids": {
|
|
131
|
+
version: 1;
|
|
132
|
+
stores: [{
|
|
133
|
+
root: string;
|
|
134
|
+
files: string[];
|
|
135
|
+
write: "jsonl-append";
|
|
136
|
+
shared: false;
|
|
137
|
+
format: "factory.session-jsonl";
|
|
138
|
+
}, {
|
|
139
|
+
root: string;
|
|
140
|
+
files: string[];
|
|
141
|
+
write: "json-rewrite";
|
|
142
|
+
shared: false;
|
|
143
|
+
format: "factory.session-jsonl";
|
|
144
|
+
}];
|
|
145
|
+
identity: {
|
|
146
|
+
kind: "first-event";
|
|
147
|
+
event: string;
|
|
148
|
+
deadlineMs: number;
|
|
149
|
+
};
|
|
150
|
+
resume: {
|
|
151
|
+
kind: "args";
|
|
152
|
+
args: string[];
|
|
153
|
+
};
|
|
154
|
+
forbiddenArgs: never[];
|
|
155
|
+
storeEnv: {};
|
|
156
|
+
evidence: {
|
|
157
|
+
servedModel: "turn-context";
|
|
158
|
+
usage: "session-total";
|
|
159
|
+
endingError: "none";
|
|
160
|
+
};
|
|
161
|
+
cliVersion: "0.250.0";
|
|
162
|
+
};
|
|
163
|
+
readonly amp: {
|
|
164
|
+
version: 1;
|
|
165
|
+
stores: [{
|
|
166
|
+
root: string;
|
|
167
|
+
files: string[];
|
|
168
|
+
write: "json-rewrite";
|
|
169
|
+
shared: false;
|
|
170
|
+
format: "amp.thread-json";
|
|
171
|
+
}];
|
|
172
|
+
identity: {
|
|
173
|
+
kind: "first-event";
|
|
174
|
+
event: string;
|
|
175
|
+
deadlineMs: number;
|
|
176
|
+
};
|
|
177
|
+
resume: {
|
|
178
|
+
kind: "args";
|
|
179
|
+
args: string[];
|
|
180
|
+
};
|
|
181
|
+
forbiddenArgs: never[];
|
|
182
|
+
storeEnv: {
|
|
183
|
+
XDG_DATA_HOME: string;
|
|
184
|
+
};
|
|
185
|
+
evidence: {
|
|
186
|
+
servedModel: "session-record";
|
|
187
|
+
usage: "per-response";
|
|
188
|
+
endingError: "none";
|
|
189
|
+
};
|
|
190
|
+
cliVersion: "0.0.1793104576-gc52692";
|
|
191
|
+
};
|
|
192
|
+
readonly prime: {
|
|
193
|
+
version: 1;
|
|
194
|
+
stores: [{
|
|
195
|
+
root: string;
|
|
196
|
+
files: string[];
|
|
197
|
+
write: "jsonl-append";
|
|
198
|
+
shared: true;
|
|
199
|
+
format: "prime.session-jsonl";
|
|
200
|
+
}];
|
|
201
|
+
identity: {
|
|
202
|
+
kind: "api-created";
|
|
203
|
+
call: "acp session/new";
|
|
204
|
+
};
|
|
205
|
+
resume: {
|
|
206
|
+
kind: "api";
|
|
207
|
+
};
|
|
208
|
+
forbiddenArgs: string[];
|
|
209
|
+
storeEnv: {};
|
|
210
|
+
evidence: {
|
|
211
|
+
servedModel: "session-record";
|
|
212
|
+
usage: "per-response";
|
|
213
|
+
endingError: "session-record";
|
|
214
|
+
};
|
|
215
|
+
cliVersion: "0.10.1";
|
|
216
|
+
};
|
|
217
|
+
readonly hermes: {
|
|
218
|
+
version: 1;
|
|
219
|
+
stores: [NativeSessionStore];
|
|
220
|
+
identity: {
|
|
221
|
+
kind: "first-event";
|
|
222
|
+
event: string;
|
|
223
|
+
deadlineMs: number;
|
|
224
|
+
};
|
|
225
|
+
resume: {
|
|
226
|
+
kind: "args";
|
|
227
|
+
args: string[];
|
|
228
|
+
};
|
|
229
|
+
forbiddenArgs: never[];
|
|
230
|
+
storeEnv: {
|
|
231
|
+
HERMES_HOME: string;
|
|
232
|
+
};
|
|
233
|
+
evidence: {
|
|
234
|
+
servedModel: "session-record";
|
|
235
|
+
usage: "session-total";
|
|
236
|
+
endingError: "none";
|
|
237
|
+
};
|
|
238
|
+
cliVersion: "0.22.4";
|
|
239
|
+
};
|
|
240
|
+
readonly openclaw: {
|
|
241
|
+
version: 1;
|
|
242
|
+
stores: [{
|
|
243
|
+
root: string;
|
|
244
|
+
files: string[];
|
|
245
|
+
write: "sqlite-wal";
|
|
246
|
+
shared: true;
|
|
247
|
+
format: "openclaw.session-jsonl";
|
|
248
|
+
}];
|
|
249
|
+
identity: {
|
|
250
|
+
kind: "pre-minted";
|
|
251
|
+
args: string[];
|
|
252
|
+
};
|
|
253
|
+
resume: {
|
|
254
|
+
kind: "args";
|
|
255
|
+
args: string[];
|
|
256
|
+
};
|
|
257
|
+
forbiddenArgs: never[];
|
|
258
|
+
storeEnv: {};
|
|
259
|
+
evidence: {
|
|
260
|
+
servedModel: "session-record";
|
|
261
|
+
usage: "per-response";
|
|
262
|
+
endingError: "none";
|
|
263
|
+
};
|
|
264
|
+
cliVersion: "2026.10.8";
|
|
265
|
+
};
|
|
266
|
+
readonly acp: {
|
|
267
|
+
version: 1;
|
|
268
|
+
stores: [NativeSessionStore, NativeSessionStore, NativeSessionStore, NativeSessionStore, NativeSessionStore];
|
|
269
|
+
identity: {
|
|
270
|
+
kind: "api-created";
|
|
271
|
+
call: "acp session/new";
|
|
272
|
+
};
|
|
273
|
+
resume: {
|
|
274
|
+
kind: "api";
|
|
275
|
+
};
|
|
276
|
+
forbiddenArgs: never[];
|
|
277
|
+
storeEnv: {};
|
|
278
|
+
evidence: {
|
|
279
|
+
servedModel: "session-record";
|
|
280
|
+
usage: "session-total";
|
|
281
|
+
endingError: "none";
|
|
282
|
+
};
|
|
283
|
+
cliVersion: "claude-agent-acp 0.97.0; codex-acp 0.16.0; gemini-cli 0.65.0";
|
|
284
|
+
};
|
|
285
|
+
readonly grok: {
|
|
286
|
+
version: 1;
|
|
287
|
+
stores: [{
|
|
288
|
+
root: string;
|
|
289
|
+
files: string[];
|
|
290
|
+
write: "jsonl-append";
|
|
291
|
+
shared: false;
|
|
292
|
+
format: "grok.acp-session-dir";
|
|
293
|
+
}];
|
|
294
|
+
identity: {
|
|
295
|
+
kind: "first-event";
|
|
296
|
+
event: string;
|
|
297
|
+
deadlineMs: number;
|
|
298
|
+
};
|
|
299
|
+
resume: {
|
|
300
|
+
kind: "args";
|
|
301
|
+
args: string[];
|
|
302
|
+
};
|
|
303
|
+
forbiddenArgs: never[];
|
|
304
|
+
storeEnv: {
|
|
305
|
+
GROK_HOME: string;
|
|
306
|
+
};
|
|
307
|
+
evidence: {
|
|
308
|
+
servedModel: "session-record";
|
|
309
|
+
usage: "none";
|
|
310
|
+
endingError: "none";
|
|
311
|
+
};
|
|
312
|
+
cliVersion: "0.1.220";
|
|
313
|
+
};
|
|
314
|
+
readonly nanoclaw: {
|
|
315
|
+
version: 1;
|
|
316
|
+
stores: [{
|
|
317
|
+
root: string;
|
|
318
|
+
files: string[];
|
|
319
|
+
write: "sqlite-wal";
|
|
320
|
+
shared: false;
|
|
321
|
+
format: "nanoclaw.session-sqlite";
|
|
322
|
+
}];
|
|
323
|
+
identity: {
|
|
324
|
+
kind: "first-event";
|
|
325
|
+
event: string;
|
|
326
|
+
deadlineMs: number;
|
|
327
|
+
};
|
|
328
|
+
resume: {
|
|
329
|
+
kind: "api";
|
|
330
|
+
};
|
|
331
|
+
forbiddenArgs: never[];
|
|
332
|
+
storeEnv: {
|
|
333
|
+
NANOCLAW_RUNTIME_ROOT: string;
|
|
334
|
+
};
|
|
335
|
+
evidence: {
|
|
336
|
+
servedModel: "none";
|
|
337
|
+
usage: "per-response";
|
|
338
|
+
endingError: "none";
|
|
339
|
+
};
|
|
340
|
+
cliVersion: "2.1.54";
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
/** Store env and XDG roots under the private runtime home. Undefined when HOME itself is the store. */
|
|
344
|
+
declare function configDirHomeEnv(harness: string, runtimeHome: string, agentHome: string): Record<string, string> | undefined;
|
|
345
|
+
/** No capture claims these sessions. They stay until their product surfaces drop them. */
|
|
346
|
+
declare const HARNESS_SESSION_UNSUPPORTED: Readonly<Record<string, string>>;
|
|
347
|
+
//#endregion
|
|
348
|
+
export { HARNESS_SESSION_UNSUPPORTED, NATIVE_SESSION_CONTRACTS, configDirHomeEnv };
|
|
349
|
+
//# sourceMappingURL=native-session-contracts.d.mts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { t as HARNESSES } from "./harness-contracts-BZoECCMc.mjs";
|
|
2
|
+
//#region src/native-session-contracts.ts
|
|
3
|
+
/** Native session contracts. A receipt proves each pin. There is no pending list. */
|
|
4
|
+
const NATIVE_SESSION_CONTRACTS = {
|
|
5
|
+
"claude-code": HARNESSES["claude-code"].session.contract,
|
|
6
|
+
codex: HARNESSES["codex"].session.contract,
|
|
7
|
+
opencode: HARNESSES["opencode"].session.contract,
|
|
8
|
+
pi: HARNESSES["pi"].session.contract,
|
|
9
|
+
"kimi-code": HARNESSES["kimi-code"].session.contract,
|
|
10
|
+
"factory-droids": HARNESSES["factory-droids"].session.contract,
|
|
11
|
+
amp: HARNESSES["amp"].session.contract,
|
|
12
|
+
prime: HARNESSES["prime"].session.contract,
|
|
13
|
+
hermes: HARNESSES["hermes"].session.contract,
|
|
14
|
+
openclaw: HARNESSES["openclaw"].session.contract,
|
|
15
|
+
acp: HARNESSES["acp"].session.contract,
|
|
16
|
+
grok: HARNESSES["grok"].session.contract,
|
|
17
|
+
nanoclaw: HARNESSES["nanoclaw"].session.contract
|
|
18
|
+
};
|
|
19
|
+
const HOME_KEYED_RUNTIMES = new Set(["opencode"]);
|
|
20
|
+
/** Store env and XDG roots under the private runtime home. Undefined when HOME itself is the store. */
|
|
21
|
+
function configDirHomeEnv(harness, runtimeHome, agentHome) {
|
|
22
|
+
const contract = NATIVE_SESSION_CONTRACTS[harness];
|
|
23
|
+
const stores = Object.entries(contract?.storeEnv ?? {}).filter(([name]) => !name.startsWith("--"));
|
|
24
|
+
if (stores.length === 0 || HOME_KEYED_RUNTIMES.has(harness)) return void 0;
|
|
25
|
+
const home = runtimeHome.replace(/\/+$/u, "");
|
|
26
|
+
return {
|
|
27
|
+
HOME: agentHome,
|
|
28
|
+
XDG_CONFIG_HOME: `${home}/.config`,
|
|
29
|
+
XDG_CACHE_HOME: `${home}/.cache`,
|
|
30
|
+
XDG_DATA_HOME: `${home}/.local/share`,
|
|
31
|
+
XDG_STATE_HOME: `${home}/.local/state`,
|
|
32
|
+
...Object.fromEntries(stores.map(([name, relative]) => [name, `${home}/${relative}`]))
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** No capture claims these sessions. They stay until their product surfaces drop them. */
|
|
36
|
+
const HARNESS_SESSION_UNSUPPORTED = { cursor: HARNESSES["cursor"].session.defect.reason };
|
|
37
|
+
//#endregion
|
|
38
|
+
export { HARNESS_SESSION_UNSUPPORTED, NATIVE_SESSION_CONTRACTS, configDirHomeEnv };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=native-session-contracts.mjs.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { HarnessModelSupportOptions } from "@tangle-network/agent-interface/harness-capabilities";
|
|
2
|
+
|
|
3
|
+
//#region src/servable-models.d.ts
|
|
4
|
+
/** One reviewed rung of {@link MANAGED_MODEL_LADDER}. */
|
|
5
|
+
interface ManagedModelRung {
|
|
6
|
+
/** Provider-qualified id the Tangle Router routes verbatim. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Why this rung sits where it does: serving state and price when reviewed. */
|
|
9
|
+
reason: string;
|
|
10
|
+
/** ISO date the rung was checked against the live `GET /v1/models`. */
|
|
11
|
+
reviewedAt: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The models a managed (Tangle-funded) run may default to, most preferred
|
|
15
|
+
* first. Every managed default in the platform is the first rung a harness can
|
|
16
|
+
* run ({@link managedModelChain}), so this list is the one place a default
|
|
17
|
+
* model is chosen.
|
|
18
|
+
*
|
|
19
|
+
* A managed run sends its model id to the Tangle router, which answers only
|
|
20
|
+
* when BOTH of these hold:
|
|
21
|
+
*
|
|
22
|
+
* 1. the router routes the id — it appears in `GET /v1/models` with
|
|
23
|
+
* `routeability.routeable = true`; and
|
|
24
|
+
* 2. the router holds a spend-authorizing price for the id — a
|
|
25
|
+
* `ProviderPriceVersion` row whose `authority` is `provider_official` or
|
|
26
|
+
* `operator_reviewed`. Third-party price observations are recorded but
|
|
27
|
+
* cannot authorize spend, so they do not count.
|
|
28
|
+
*
|
|
29
|
+
* A model that fails either test answers 503 `provider_pricing_unavailable`
|
|
30
|
+
* to a Tangle-funded call. A CLI reads 503 as transient and retries until its
|
|
31
|
+
* own timeout, so the run produces no output and no error for many minutes.
|
|
32
|
+
* That is why an unservable default is worse than a wrong one: it does not
|
|
33
|
+
* fail, it hangs.
|
|
34
|
+
*
|
|
35
|
+
* Which models a harness can run is not decided here: the capability table
|
|
36
|
+
* ({@link harnessModelSupportFor}) drops the rungs a harness refuses (measured
|
|
37
|
+
* exclusions). claude-code and codex run the whole ladder: the router
|
|
38
|
+
* translates every non-vendor model on their Messages and Responses wires to
|
|
39
|
+
* chat completions, so they lead with the same cheapest rung as every other
|
|
40
|
+
* Router-backed harness.
|
|
41
|
+
*/
|
|
42
|
+
declare const MANAGED_MODEL_LADDER: readonly ManagedModelRung[];
|
|
43
|
+
/** The bare id a provider-prefixed model id carries. */
|
|
44
|
+
declare function bareModelId(modelId: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Whether a managed default may use this id. Accepts the provider-prefixed
|
|
47
|
+
* form and the bare form, because a harness on a provider-native wire sends
|
|
48
|
+
* the bare id its own CLI expects.
|
|
49
|
+
*/
|
|
50
|
+
declare function isServableManagedModel(modelId: string): boolean;
|
|
51
|
+
interface ManagedModelChainOptions {
|
|
52
|
+
/**
|
|
53
|
+
* The model the caller or its profile named. It is returned alone and never
|
|
54
|
+
* substituted: a named model that cannot run fails loud where it is checked.
|
|
55
|
+
*/
|
|
56
|
+
named?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The operator's configured model (a deployment's `OPENCODE_MODEL_NAME` or
|
|
59
|
+
* `TANGLE_ROUTER_MODEL`), tried ahead of the ladder when the harness runs it.
|
|
60
|
+
*/
|
|
61
|
+
operatorModel?: string;
|
|
62
|
+
/** The run's reasoning effort; some harness × model pairs fail only with one. */
|
|
63
|
+
reasoningEffort?: HarnessModelSupportOptions["reasoningEffort"];
|
|
64
|
+
/**
|
|
65
|
+
* The models the box's Router key allows (Platform's `allowedModels` on the
|
|
66
|
+
* minted key); absent or null allows every model. A default the key refuses
|
|
67
|
+
* fails the box's first turn with `model_not_allowed`, so the chain keeps
|
|
68
|
+
* only allowed ladder rungs, spelled as the key spells them, then the key's
|
|
69
|
+
* other models.
|
|
70
|
+
*/
|
|
71
|
+
allowedModels?: readonly string[] | null;
|
|
72
|
+
}
|
|
73
|
+
/** A model the chain left out, and why. */
|
|
74
|
+
interface SkippedManagedModel {
|
|
75
|
+
id: string;
|
|
76
|
+
reason: string;
|
|
77
|
+
}
|
|
78
|
+
type ManagedModelChain = {
|
|
79
|
+
ok: true;
|
|
80
|
+
chain: string[];
|
|
81
|
+
skipped: SkippedManagedModel[];
|
|
82
|
+
} | {
|
|
83
|
+
ok: false;
|
|
84
|
+
chain: [];
|
|
85
|
+
skipped: SkippedManagedModel[]; /** One sentence a create or run refusal can show as-is. */
|
|
86
|
+
message: string;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* The ordered models a managed run of `harness` may use, first choice first.
|
|
90
|
+
* Every managed default site takes `chain[0]`; the rest is the order a later
|
|
91
|
+
* fallback would try.
|
|
92
|
+
*
|
|
93
|
+
* - A named model is the whole chain.
|
|
94
|
+
* - A harness the Router cannot serve (`CliAgentSpec.callerCredentialOnly`)
|
|
95
|
+
* has no managed chain: its CLI calls its vendor's own service, so it runs
|
|
96
|
+
* only on the caller's own credential.
|
|
97
|
+
* - Otherwise the operator's model, then {@link MANAGED_MODEL_LADDER}, keeping
|
|
98
|
+
* only the ids the capability table lets this harness run.
|
|
99
|
+
*/
|
|
100
|
+
declare function managedModelChain(harness: string, options?: ManagedModelChainOptions): ManagedModelChain;
|
|
101
|
+
//#endregion
|
|
102
|
+
export { MANAGED_MODEL_LADDER, ManagedModelChain, ManagedModelChainOptions, ManagedModelRung, SkippedManagedModel, bareModelId, isServableManagedModel, managedModelChain };
|
|
103
|
+
//# sourceMappingURL=servable-models.d.mts.map
|