@tangle-network/cli-agent-registry 0.15.32 → 0.15.34

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,346 @@
1
+ import { n as HARNESS_WARM_TRANSPORT_ENV } from "./harness-contracts-B1vAJ1yx.mjs";
2
+ import { ProxySecretBindingSchema, ProxySecretGrantSchema, ProxySecretReceiptSchema, ProxySecretUpdateControlsSchema, ProxySecretsSchema, isProxySecretScopeAttenuation, ownPropertyRecordSchema, proxySecretPresentationsEqual } from "@tangle-network/agent-interface";
3
+ import { z } from "zod";
4
+ //#region ../runtime-contracts/dist/model-key-proxy.js
5
+ const MODEL_PROXY_TOKENS = {
6
+ OPENCODE_MODEL_API_KEY: "proxy-model-token",
7
+ OPENAI_API_KEY: "proxy-openai-token",
8
+ ANTHROPIC_API_KEY: "proxy-anthropic-token",
9
+ OPENROUTER_API_KEY: "proxy-openrouter-token",
10
+ TANGLE_INFERENCE_KEY: "proxy-openai-token",
11
+ ZAI_API_KEY: "proxy-zai-token",
12
+ ZHIPU_API_KEY: "proxy-zai-token"
13
+ };
14
+ new Set(Object.values(MODEL_PROXY_TOKENS));
15
+ //#endregion
16
+ //#region ../runtime-contracts/dist/declared-secrets.js
17
+ /** Bound values stay at the proxy. Declarations carry metadata only and are
18
+ * revalidated at every rebuild; an unbound name keeps box delivery unless the store's policy binds it.
19
+ * A declaration may bind several hosts: one credential, one slot and placeholder, many vendor hosts. */
20
+ const MAX_SECRET_VALUE_LENGTH = 65536;
21
+ new Set([
22
+ ...Object.keys(MODEL_PROXY_TOKENS),
23
+ "TANGLE_API_KEY",
24
+ "GITHUB_TOKEN",
25
+ "GH_TOKEN"
26
+ ]);
27
+ /** True for a slot name, which exists at the proxy and never in a box env. */
28
+ function isDeclaredSecretSlotEnvVar(name) {
29
+ return /^TANGLE_DECLARED_SLOT_\d+$/.test(name);
30
+ }
31
+ //#endregion
32
+ //#region ../runtime-contracts/dist/model-key-refresh.js
33
+ const batchCredentialOwner = {
34
+ allocationId: z.uuid(),
35
+ ownerId: z.string().min(1).max(256)
36
+ };
37
+ z.strictObject({
38
+ ...batchCredentialOwner,
39
+ childKeyId: z.string().min(1).max(200).optional(),
40
+ keyExpiresAt: z.iso.datetime({ offset: true }).optional()
41
+ });
42
+ const batchCredentialIdentity = {
43
+ ...batchCredentialOwner,
44
+ expiresAt: z.iso.datetime({ offset: true })
45
+ };
46
+ z.discriminatedUnion("operation", [
47
+ z.strictObject({
48
+ operation: z.literal("batch-allocate"),
49
+ ...batchCredentialIdentity,
50
+ admissionDeadlineMs: z.number().int().positive(),
51
+ sourceKey: z.string().min(1).max(4096)
52
+ }),
53
+ z.strictObject({
54
+ operation: z.literal("batch-rotate"),
55
+ ...batchCredentialIdentity
56
+ }),
57
+ z.strictObject({
58
+ operation: z.literal("batch-release"),
59
+ ...batchCredentialIdentity,
60
+ childKeyId: z.string().min(1).max(200).optional()
61
+ })
62
+ ]);
63
+ z.union([z.object({
64
+ refreshed: z.literal(true),
65
+ apiKey: z.string().min(1),
66
+ keyId: z.string().min(1),
67
+ baseUrl: z.string().url(),
68
+ expiresAt: z.iso.datetime({ offset: true })
69
+ }), z.object({
70
+ refreshed: z.literal(false),
71
+ reason: z.string().min(1)
72
+ })]);
73
+ //#endregion
74
+ //#region ../runtime-contracts/dist/proxy-secret-materialization.js
75
+ const syntheticHeader = {
76
+ alg: "HS256",
77
+ typ: "JWT"
78
+ };
79
+ const encode = (value) => btoa(value instanceof Uint8Array ? String.fromCharCode(...value) : JSON.stringify(value)).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
80
+ function placeholderPrefix(slot, format, expiresAt) {
81
+ return format === "jwt" ? `${encode(syntheticHeader)}.${encode({
82
+ sub: "sandbox-placeholder",
83
+ aud: "proxy-secret-placeholder",
84
+ exp: Math.floor(Date.parse(expiresAt) / 1e3)
85
+ })}.` : `proxy-declared-${slot.slice(21)}-token-`;
86
+ }
87
+ function isSyntheticPlaceholder(material) {
88
+ const prefix = placeholderPrefix(material.slot, material.grant.placeholderFormat, material.issuerExpiresAt);
89
+ return material.placeholder.startsWith(prefix) && /^[A-Za-z0-9_-]{43}$/.test(material.placeholder.slice(prefix.length));
90
+ }
91
+ /** Private compiled transport; real values stay in resolvedSecrets[slot]. */
92
+ const proxySecretMaterializationsSchema = z.array(z.preprocess((input) => {
93
+ if (input && typeof input === "object" && "issuerExpiresAt" in input && (!("executionExpiresAt" in input) || input.executionExpiresAt === void 0) && (!("native" in input) || input.native === void 0)) return {
94
+ ...input,
95
+ executionExpiresAt: input.issuerExpiresAt
96
+ };
97
+ return input;
98
+ }, z.strictObject({
99
+ binding: ProxySecretBindingSchema,
100
+ grant: ProxySecretGrantSchema,
101
+ placeholder: z.string().min(1),
102
+ slot: z.string().refine(isDeclaredSecretSlotEnvVar),
103
+ issuerExpiresAt: z.iso.datetime(),
104
+ executionExpiresAt: z.iso.datetime(),
105
+ native: z.unknown().optional()
106
+ }))).superRefine((materials, ctx) => {
107
+ const bindings = ProxySecretsSchema.safeParse(materials.map((m) => m.binding));
108
+ const unique = (values) => new Set(values).size === values.length;
109
+ if (!bindings.success || !unique(materials.map((m) => m.slot)) || !unique(materials.map((m) => m.placeholder)) || !unique(materials.map((m) => m.grant.grantId)) || new Set(materials.map((m) => m.grant.epoch)).size > 1 || new Set(materials.map((m) => m.grant.sandboxId)).size > 1 || materials.some((material) => !isSyntheticPlaceholder(material)) || materials.some(({ binding, grant, issuerExpiresAt, executionExpiresAt }) => !isProxySecretScopeAttenuation(binding, grant.scope) || !proxySecretPresentationsEqual(binding.presentation, grant.presentation) || (binding.placeholderFormat ?? "opaque") !== grant.placeholderFormat || Date.parse(grant.expiresAt) > Date.parse(executionExpiresAt) || Date.parse(executionExpiresAt) > Date.parse(issuerExpiresAt))) ctx.addIssue({
110
+ code: "custom",
111
+ message: "Invalid proxy secret materialization"
112
+ });
113
+ });
114
+ ProxySecretUpdateControlsSchema.extend({
115
+ resolvedSecrets: ownPropertyRecordSchema(z.string().min(1), { maxEntries: Number.MAX_SAFE_INTEGER }).default({}),
116
+ proxySecretGrants: ProxySecretReceiptSchema.options[0].shape.bindings,
117
+ expectedProxySecretGeneration: ProxySecretUpdateControlsSchema.shape.expectedProxySecretGeneration.unwrap()
118
+ }).strict().refine((body) => new Set(body.proxySecretGrants.map((b) => b.envName)).size === body.proxySecretGrants.length);
119
+ const sourceBindingSchema = ProxySecretReceiptSchema.options[0].shape.bindings.element;
120
+ const sourceRevisionSchema = z.iso.datetime();
121
+ const sourceLeaseTokenSchema = z.uuid();
122
+ const sourceAuthority = {
123
+ binding: sourceBindingSchema,
124
+ issuerExpiresAt: z.iso.datetime()
125
+ };
126
+ z.discriminatedUnion("operation", [
127
+ z.strictObject({
128
+ operation: z.literal("read"),
129
+ ...sourceAuthority,
130
+ rekey: z.literal(true).optional()
131
+ }),
132
+ z.strictObject({
133
+ operation: z.literal("lease"),
134
+ ...sourceAuthority,
135
+ expectedUpdatedAt: sourceRevisionSchema,
136
+ leaseExpiresAt: z.iso.datetime(),
137
+ leaseToken: sourceLeaseTokenSchema.optional()
138
+ }),
139
+ z.strictObject({
140
+ operation: z.literal("commit"),
141
+ ...sourceAuthority,
142
+ expectedUpdatedAt: sourceRevisionSchema,
143
+ leaseToken: sourceLeaseTokenSchema,
144
+ value: z.string().min(1).max(MAX_SECRET_VALUE_LENGTH)
145
+ }),
146
+ z.strictObject({
147
+ operation: z.literal("release"),
148
+ ...sourceAuthority,
149
+ leaseToken: sourceLeaseTokenSchema
150
+ })
151
+ ]);
152
+ const sourceMetadataSchema = z.strictObject({
153
+ secretId: z.string().min(1),
154
+ key: ProxySecretBindingSchema.shape.secretRef.shape.key,
155
+ updatedAt: sourceRevisionSchema
156
+ });
157
+ const sourceSnapshotSchema = sourceMetadataSchema.extend({ value: z.string().min(1).max(MAX_SECRET_VALUE_LENGTH) });
158
+ z.discriminatedUnion("operation", [
159
+ z.strictObject({
160
+ operation: z.literal("read"),
161
+ source: sourceSnapshotSchema,
162
+ binding: sourceBindingSchema,
163
+ refreshExpiresAt: z.iso.datetime()
164
+ }),
165
+ z.strictObject({
166
+ operation: z.literal("lease"),
167
+ source: sourceSnapshotSchema,
168
+ leaseToken: sourceLeaseTokenSchema,
169
+ leaseExpiresAt: z.iso.datetime(),
170
+ phase: z.enum([
171
+ "leased",
172
+ "started",
173
+ "replay"
174
+ ]).default("leased")
175
+ }),
176
+ z.strictObject({
177
+ operation: z.literal("commit"),
178
+ source: sourceMetadataSchema
179
+ }),
180
+ z.strictObject({
181
+ operation: z.literal("release"),
182
+ released: z.literal(true)
183
+ })
184
+ ]);
185
+ const nativeCredentialProtocolSchema = z.enum([
186
+ "legacy",
187
+ "canonical",
188
+ "unselected"
189
+ ]);
190
+ z.strictObject({
191
+ nativeCredentialProtocol: nativeCredentialProtocolSchema,
192
+ priorExposure: z.boolean(),
193
+ containerId: z.string().min(1),
194
+ expectedProxySecretGeneration: ProxySecretUpdateControlsSchema.shape.expectedProxySecretGeneration,
195
+ authorityExpiresAt: z.iso.datetime().optional()
196
+ });
197
+ ownPropertyRecordSchema(z.strictObject({
198
+ revision: ProxySecretGrantSchema.shape.identity.shape.revision,
199
+ value: z.string().min(1).max(MAX_SECRET_VALUE_LENGTH),
200
+ refresh: z.strictObject({
201
+ revision: sourceRevisionSchema,
202
+ leaseToken: sourceLeaseTokenSchema
203
+ }).optional()
204
+ }));
205
+ z.strictObject({
206
+ grant: ProxySecretGrantSchema,
207
+ value: z.string().min(1).max(MAX_SECRET_VALUE_LENGTH),
208
+ expectedUpdatedAt: sourceRevisionSchema.optional(),
209
+ replayOnly: z.boolean().optional(),
210
+ leaseExpiresAt: z.iso.datetime()
211
+ });
212
+ z.discriminatedUnion("status", [
213
+ z.strictObject({
214
+ status: z.literal("refreshed"),
215
+ value: z.string().min(1).max(MAX_SECRET_VALUE_LENGTH),
216
+ sourceExpiresAt: z.iso.datetime().optional()
217
+ }),
218
+ z.strictObject({
219
+ status: z.literal("nonrefreshable"),
220
+ reason: z.string().min(1)
221
+ }),
222
+ z.strictObject({
223
+ status: z.literal("refused"),
224
+ reason: z.string().min(1)
225
+ })
226
+ ]);
227
+ //#endregion
228
+ //#region ../runtime-contracts/dist/runtime-environment.js
229
+ const SAFE_ENV_VAR_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
230
+ function isSafeEnvVarName(name) {
231
+ if (typeof name !== "string") return false;
232
+ if (name.length === 0 || name.length > 256) return false;
233
+ return SAFE_ENV_VAR_NAME_RE.test(name);
234
+ }
235
+ /** Client proxy URLs first, then bypass names. */
236
+ const EGRESS_PROXY_ENV_NAMES = [
237
+ "HTTPS_PROXY",
238
+ "https_proxy",
239
+ "HTTP_PROXY",
240
+ "http_proxy",
241
+ "NO_PROXY",
242
+ "no_proxy"
243
+ ];
244
+ const CA_TRUST_ENV_NAMES = [
245
+ "NODE_EXTRA_CA_CERTS",
246
+ "SSL_CERT_FILE",
247
+ "CURL_CA_BUNDLE",
248
+ "GIT_SSL_CAINFO",
249
+ "NIX_SSL_CERT_FILE"
250
+ ];
251
+ [...EGRESS_PROXY_ENV_NAMES, ...CA_TRUST_ENV_NAMES];
252
+ const FORBIDDEN_ENV_VAR_NAMES = new Set([
253
+ "LD_PRELOAD",
254
+ "LD_LIBRARY_PATH",
255
+ "LD_AUDIT",
256
+ "DYLD_INSERT_LIBRARIES",
257
+ "DYLD_LIBRARY_PATH",
258
+ "DYLD_FALLBACK_LIBRARY_PATH",
259
+ "NODE_OPTIONS",
260
+ "NODE_PATH",
261
+ "NODE_TLS_REJECT_UNAUTHORIZED",
262
+ "PYTHONPATH",
263
+ "PYTHONSTARTUP",
264
+ "PERL5OPT",
265
+ "PERL5LIB",
266
+ "RUBYOPT",
267
+ "RUBYLIB",
268
+ "PATH",
269
+ "NIX_BIN_PATH",
270
+ "EGRESS_EDGE_POOL_ENABLED",
271
+ "EDGE_BIND_ID",
272
+ "PRIVACY_EGRESS",
273
+ "LOG_REDACT",
274
+ "IFS",
275
+ "BASH_ENV",
276
+ "ENV",
277
+ "SHELL",
278
+ "SHELLOPTS",
279
+ "PROMPT_COMMAND",
280
+ "HOME",
281
+ "XDG_CONFIG_HOME",
282
+ "XDG_DATA_HOME",
283
+ "XDG_CACHE_HOME",
284
+ "XDG_STATE_HOME",
285
+ "XDG_RUNTIME_DIR",
286
+ "HTTPS_PROXY",
287
+ "HTTP_PROXY",
288
+ "ALL_PROXY",
289
+ "NO_PROXY",
290
+ "https_proxy",
291
+ "http_proxy",
292
+ "all_proxy",
293
+ "no_proxy",
294
+ "SSL_CERT_FILE",
295
+ "SSL_CERT_DIR",
296
+ "REQUESTS_CA_BUNDLE",
297
+ "CURL_CA_BUNDLE",
298
+ "NODE_EXTRA_CA_CERTS",
299
+ "HOSTNAME",
300
+ "CONTAINER_ID",
301
+ "AGENT_WORKSPACE_ROOT",
302
+ "WORKSPACE_PATH",
303
+ "STORAGE_PATH",
304
+ "WORKSPACE_FILE_API_ROOT_ONLY",
305
+ "WORKSPACE_ALLOWED_ABSOLUTE_PATHS",
306
+ "TANGLE_PLAN_CALLBACK_ALLOWED_ORIGINS"
307
+ ]);
308
+ const FORBIDDEN_ENV_VAR_PREFIXES = [
309
+ "SIDECAR_",
310
+ "ORCHESTRATOR_",
311
+ "AGENT_INTERNAL_",
312
+ "SANDBOX_DEV_",
313
+ "AGENT_SUBPROCESS_",
314
+ "TEE_ATTESTATION_"
315
+ ];
316
+ const RUNTIME_CALLER_ALLOWED_ENV_NAMES = new Set(["SIDECAR_CAPABILITIES", "SIDECAR_PLATFORM_CONTROL_RUNTIME"]);
317
+ new Set(Object.values(HARNESS_WARM_TRANSPORT_ENV).flatMap(({ warmServer, prewarm }) => [warmServer, prewarm]));
318
+ function isForbiddenEnvVarName(name) {
319
+ if (RUNTIME_CALLER_ALLOWED_ENV_NAMES.has(name)) return false;
320
+ if (FORBIDDEN_ENV_VAR_NAMES.has(name)) return true;
321
+ for (const prefix of FORBIDDEN_ENV_VAR_PREFIXES) if (name.startsWith(prefix)) return true;
322
+ return false;
323
+ }
324
+ /**
325
+ * POSIX names for caller-owned container env. Runtime process.env merges must additionally enforce
326
+ * isForbiddenEnvVarName, including project provisioning and Sidecar config.
327
+ */
328
+ const safeEnvRecordSchema = ownPropertyRecordSchema(z.string(), { maxEntries: Number.MAX_SAFE_INTEGER }).refine((value) => Object.keys(value).every(isSafeEnvVarName), { message: "invalid env var name" });
329
+ /** Names only: the caller must keep a separate source and pass values to resume({ env }). */
330
+ const sandboxEnvRecoverySchema = z.object({ callerResupplies: z.array(z.string().max(256).refine(isSafeEnvVarName, { message: "invalid env var name" })).max(128).refine((keys) => new Set(keys).size === keys.length, { message: "callerResupplies must contain unique keys" }) }).strict();
331
+ z.object({
332
+ envRecovery: sandboxEnvRecoverySchema,
333
+ dryRun: z.boolean().optional()
334
+ }).strict();
335
+ z.object({
336
+ envRecovery: sandboxEnvRecoverySchema,
337
+ eligibleCallerResupplyKeys: z.array(z.string()),
338
+ requiredOnColdResumeKeys: z.array(z.string()),
339
+ automaticCredentialRecovery: z.literal(false),
340
+ dryRun: z.boolean()
341
+ }).strict();
342
+ safeEnvRecordSchema.refine((value) => Object.keys(value).every((key) => !isForbiddenEnvVarName(key) && !key.startsWith("SIDECAR_")), { message: "runtime-owned env var name cannot be set by callers" });
343
+ //#endregion
344
+ export { isSafeEnvVarName as n, proxySecretMaterializationsSchema as r, isForbiddenEnvVarName as t };
345
+
346
+ //# sourceMappingURL=harness-Dn0LC8Pe.mjs.map
@@ -1,5 +1,5 @@
1
- import { o as CliAgentEnvVars } from "./spec-BJnoebFr.mjs";
2
- import { o as NativeSessionStore } from "./session-contract-IJy6T_nD.mjs";
1
+ import { o as CliAgentEnvVars } from "./spec-Br00Ybw5.mjs";
2
+ import { o as NativeSessionStore } from "./session-contract-Cx8ziXIJ.mjs";
3
3
 
4
4
  //#region src/host-contracts.d.ts
5
5
  type HostStore = Omit<NativeSessionStore, "format"> & {
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import { a as isBackendType, i as backendTypeSchema, n as BACKEND_TYPE, o as parseBackendType, r as BackendType, t as ALL_BACKEND_TYPES } from "./backend-types-BZoSzUzQ.mjs";
2
- import { i as LocalCliAuthFile, s as materializeCliAuthBundle } from "./cli-auth-bundle-BIABHp5D.mjs";
3
- import { C as mergeCliDirLayout, S as DEFAULT_CLI_DIR_LAYOUT, _ as harnessModelSupportFor, a as CliAgentEnvExtraRole, b as CliDirLayout, c as CliAgentRuntimeSpec, d as HarnessSpecCapabilities, f as ProviderLogger, g as cliAgentEnvRoleName, h as cliAgentClaimEnvVarNames, i as CliAgentEnvExtraParser, l as CliAgentSpec, m as canonicalModelSlug, n as CliAgentBuiltinTool, o as CliAgentEnvVars, p as ProviderPhase, r as CliAgentEnvExtra, s as CliAgentModelWire, t as AdapterFactory, u as CliAuthHome, v as harnessModelWire, x as CliDirLayoutAdditions, y as SYNTHETIC_ROUTER_MODEL } from "./spec-BJnoebFr.mjs";
4
- import { _ as substituteNativeSessionId, a as NativeSessionIdentity, c as SessionFormatId, d as assertStoreLocationHonoursSessionContract, f as compileSessionStoreGlob, g as sessionStoreForPath, h as sessionContractProblems, i as HarnessSessionEvidence, l as assertArgvHonoursSessionContract, m as normalizePosixPath, n as HarnessSessionContractError, o as NativeSessionStore, p as forbiddenArgViolations, r as HarnessSessionContractErrorCode, s as SESSION_FORMAT_IDS, t as HarnessSessionContract, u as assertFlagsHonourSessionContract } from "./session-contract-IJy6T_nD.mjs";
5
- import { AGENT_BACKEND_ENV_VAR, CLI_AGENT_SPECS, MANAGED_MODEL_KEY_ENV_VAR, MANAGED_MODEL_KEY_NAME_ENV_VAR, agentProfileSchema, claimDeliverableEnvVarNames, cliAgentEnvVarNamesByRole, cliAgentHostPassthroughEnvVarNames, getSpec, messageStorageDirOf } from "./specs.mjs";
1
+ import { a as isBackendType, i as backendTypeSchema, n as BACKEND_TYPE, o as parseBackendType, r as BackendType, t as ALL_BACKEND_TYPES } from "./backend-types-DRmLR1e0.mjs";
2
+ import { LocalCliAuthFile, materializeCliAuthBundle } from "./cli-auth-bundle.mjs";
3
+ import { C as mergeCliDirLayout, S as DEFAULT_CLI_DIR_LAYOUT, _ as harnessModelSupportFor, a as CliAgentEnvExtraRole, b as CliDirLayout, c as CliAgentRuntimeSpec, d as HarnessSpecCapabilities, f as ProviderLogger, g as cliAgentEnvRoleName, h as cliAgentClaimEnvVarNames, i as CliAgentEnvExtraParser, l as CliAgentSpec, m as canonicalModelSlug, n as CliAgentBuiltinTool, o as CliAgentEnvVars, p as ProviderPhase, r as CliAgentEnvExtra, s as CliAgentModelWire, t as AdapterFactory, u as CliAuthHome, v as harnessModelWire, x as CliDirLayoutAdditions, y as SYNTHETIC_ROUTER_MODEL } from "./spec-Br00Ybw5.mjs";
4
+ import { _ as substituteNativeSessionId, a as NativeSessionIdentity, c as SessionFormatId, d as assertStoreLocationHonoursSessionContract, f as compileSessionStoreGlob, g as sessionStoreForPath, h as sessionContractProblems, i as HarnessSessionEvidence, l as assertArgvHonoursSessionContract, m as normalizePosixPath, n as HarnessSessionContractError, o as NativeSessionStore, p as forbiddenArgViolations, r as HarnessSessionContractErrorCode, s as SESSION_FORMAT_IDS, t as HarnessSessionContract, u as assertFlagsHonourSessionContract } from "./session-contract-Cx8ziXIJ.mjs";
5
+ import { a as agentProfileSchema, c as cliAgentHostPassthroughEnvVarNames, i as MANAGED_MODEL_KEY_NAME_ENV_VAR, l as getSpec, n as CLI_AGENT_SPECS, o as claimDeliverableEnvVarNames, r as MANAGED_MODEL_KEY_ENV_VAR, s as cliAgentEnvVarNamesByRole, t as AGENT_BACKEND_ENV_VAR, u as messageStorageDirOf } from "./specs-CStHlNhB.mjs";
6
6
  import { resolveDefaultBackend } from "./default-backend.mjs";
7
7
  import { describeLocalCliAuthExpectation, discoverLocalCliAuthFiles } from "./local-cli-auth.mjs";
8
8
  import { HARNESS_SESSION_UNSUPPORTED, NATIVE_SESSION_CONTRACTS, configDirHomeEnv } from "./native-session-contracts.mjs";
package/dist/index.mjs CHANGED
@@ -2,8 +2,8 @@ import { t as HARNESSES } from "./harness-contracts-B1vAJ1yx.mjs";
2
2
  import { HARNESS_SESSION_UNSUPPORTED, NATIVE_SESSION_CONTRACTS, configDirHomeEnv } from "./native-session-contracts.mjs";
3
3
  import { HarnessSessionContractError, SESSION_FORMAT_IDS, assertArgvHonoursSessionContract, assertFlagsHonourSessionContract, assertStoreLocationHonoursSessionContract, compileSessionStoreGlob, forbiddenArgViolations, normalizePosixPath, sessionContractProblems, sessionStoreForPath, substituteNativeSessionId } from "./session-contract.mjs";
4
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-D_iuiC3T.mjs";
6
- import { a as materializeCliAuthBundle } from "./cli-auth-bundle-DcxhAW23.mjs";
5
+ import { _ as harnessModelWire, a as agentProfileSchema, c as cliAgentHostPassthroughEnvVarNames, g as harnessModelSupportFor, h as cliAgentEnvRoleName, i as MANAGED_MODEL_KEY_NAME_ENV_VAR, l as getSpec, m as cliAgentClaimEnvVarNames, n as CLI_AGENT_SPECS, o as claimDeliverableEnvVarNames, p as canonicalModelSlug, r as MANAGED_MODEL_KEY_ENV_VAR, s as cliAgentEnvVarNamesByRole, t as AGENT_BACKEND_ENV_VAR, u as messageStorageDirOf, v as SYNTHETIC_ROUTER_MODEL } from "./specs-CZ6eAF6G.mjs";
6
+ import { c as materializeCliAuthBundle } from "./cli-auth-bundle-B4SGUcYM.mjs";
7
7
  import { resolveDefaultBackend } from "./default-backend.mjs";
8
8
  import { describeLocalCliAuthExpectation, discoverLocalCliAuthFiles } from "./local-cli-auth.mjs";
9
9
  import { MANAGED_MODEL_LADDER, bareModelId, isServableManagedModel, managedModelChain } from "./servable-models.mjs";
@@ -1,4 +1,4 @@
1
- import { i as LocalCliAuthFile } from "./cli-auth-bundle-BIABHp5D.mjs";
1
+ import { LocalCliAuthFile } from "./cli-auth-bundle.mjs";
2
2
 
3
3
  //#region src/local-cli-auth.d.ts
4
4
  type LocalCliAuthBackend = "codex" | "claude-code";
@@ -1,4 +1,4 @@
1
- import { t as AUTH_BUNDLE_PATHS } from "./cli-auth-bundle-DcxhAW23.mjs";
1
+ import { t as AUTH_BUNDLE_PATHS } from "./cli-auth-bundle-B4SGUcYM.mjs";
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
4
  import { basename, dirname, join } from "node:path";
@@ -1,4 +1,4 @@
1
- import { o as NativeSessionStore } from "./session-contract-IJy6T_nD.mjs";
1
+ import { o as NativeSessionStore } from "./session-contract-Cx8ziXIJ.mjs";
2
2
 
3
3
  //#region src/native-session-contracts.d.ts
4
4
  /** Native session contracts. A receipt proves each pin. There is no pending list. */
@@ -0,0 +1,17 @@
1
+ import { z } from "zod";
2
+
3
+ //#region ../runtime-contracts/dist/public-profile-request.d.ts
4
+ declare const cliAuthReferenceSchema: z.ZodObject<{
5
+ account: z.ZodString;
6
+ secretEnv: z.ZodString;
7
+ format: z.ZodEnum<{
8
+ files: "files";
9
+ token: "token";
10
+ bundle: "bundle";
11
+ }>;
12
+ }, z.core.$strict>;
13
+ /** A supplied account binding label, not a verified native account principal. */
14
+ type CliAuthReference = z.infer<typeof cliAuthReferenceSchema>;
15
+ //#endregion
16
+ export { cliAuthReferenceSchema as n, CliAuthReference as t };
17
+ //# sourceMappingURL=public-profile-request-BwBfLgGv.d.mts.map
@@ -1,4 +1,4 @@
1
- import { l as getSpec, m as harnessModelSupportFor } from "./specs-D_iuiC3T.mjs";
1
+ import { g as harnessModelSupportFor, l as getSpec } from "./specs-CZ6eAF6G.mjs";
2
2
  //#region src/servable-models.ts
3
3
  /**
4
4
  * The models a managed (Tangle-funded) run may default to, most preferred
@@ -96,4 +96,4 @@ declare function sessionStoreForPath(contract: Pick<HarnessSessionContract, "sto
96
96
  declare function sessionContractProblems(contract: HarnessSessionContract): string[];
97
97
  //#endregion
98
98
  export { substituteNativeSessionId as _, NativeSessionIdentity as a, SessionFormatId as c, assertStoreLocationHonoursSessionContract as d, compileSessionStoreGlob as f, sessionStoreForPath as g, sessionContractProblems as h, HarnessSessionEvidence as i, assertArgvHonoursSessionContract as l, normalizePosixPath as m, HarnessSessionContractError as n, NativeSessionStore as o, forbiddenArgViolations as p, HarnessSessionContractErrorCode as r, SESSION_FORMAT_IDS as s, HarnessSessionContract as t, assertFlagsHonourSessionContract as u };
99
- //# sourceMappingURL=session-contract-IJy6T_nD.d.mts.map
99
+ //# sourceMappingURL=session-contract-Cx8ziXIJ.d.mts.map
@@ -1,2 +1,2 @@
1
- import { _ as substituteNativeSessionId, a as NativeSessionIdentity, c as SessionFormatId, d as assertStoreLocationHonoursSessionContract, f as compileSessionStoreGlob, g as sessionStoreForPath, h as sessionContractProblems, i as HarnessSessionEvidence, l as assertArgvHonoursSessionContract, m as normalizePosixPath, n as HarnessSessionContractError, o as NativeSessionStore, p as forbiddenArgViolations, r as HarnessSessionContractErrorCode, s as SESSION_FORMAT_IDS, t as HarnessSessionContract, u as assertFlagsHonourSessionContract } from "./session-contract-IJy6T_nD.mjs";
1
+ import { _ as substituteNativeSessionId, a as NativeSessionIdentity, c as SessionFormatId, d as assertStoreLocationHonoursSessionContract, f as compileSessionStoreGlob, g as sessionStoreForPath, h as sessionContractProblems, i as HarnessSessionEvidence, l as assertArgvHonoursSessionContract, m as normalizePosixPath, n as HarnessSessionContractError, o as NativeSessionStore, p as forbiddenArgViolations, r as HarnessSessionContractErrorCode, s as SESSION_FORMAT_IDS, t as HarnessSessionContract, u as assertFlagsHonourSessionContract } from "./session-contract-Cx8ziXIJ.mjs";
2
2
  export { HarnessSessionContract, HarnessSessionContractError, HarnessSessionContractErrorCode, HarnessSessionEvidence, NativeSessionIdentity, NativeSessionStore, SESSION_FORMAT_IDS, SessionFormatId, assertArgvHonoursSessionContract, assertFlagsHonourSessionContract, assertStoreLocationHonoursSessionContract, compileSessionStoreGlob, forbiddenArgViolations, normalizePosixPath, sessionContractProblems, sessionStoreForPath, substituteNativeSessionId };
@@ -1,4 +1,4 @@
1
- import { t as HarnessSessionContract } from "./session-contract-IJy6T_nD.mjs";
1
+ import { t as HarnessSessionContract } from "./session-contract-Cx8ziXIJ.mjs";
2
2
  import { SdkProviderAdapter, WellKnownInteractionKind } from "@tangle-network/agent-interface";
3
3
  import { HarnessModelSupport, HarnessModelSupportOptions } from "@tangle-network/agent-interface/harness-capabilities";
4
4
 
@@ -345,4 +345,4 @@ type ProviderLogger = {
345
345
  };
346
346
  //#endregion
347
347
  export { mergeCliDirLayout as C, DEFAULT_CLI_DIR_LAYOUT as S, harnessModelSupportFor as _, CliAgentEnvExtraRole as a, CliDirLayout as b, CliAgentRuntimeSpec as c, HarnessSpecCapabilities as d, ProviderLogger as f, cliAgentEnvRoleName as g, cliAgentClaimEnvVarNames as h, CliAgentEnvExtraParser as i, CliAgentSpec as l, canonicalModelSlug as m, CliAgentBuiltinTool as n, CliAgentEnvVars as o, ProviderPhase as p, CliAgentEnvExtra as r, CliAgentModelWire as s, AdapterFactory as t, CliAuthHome as u, harnessModelWire as v, CliDirLayoutAdditions as x, SYNTHETIC_ROUTER_MODEL as y };
348
- //# sourceMappingURL=spec-BJnoebFr.d.mts.map
348
+ //# sourceMappingURL=spec-Br00Ybw5.d.mts.map
@@ -0,0 +1,84 @@
1
+ import { t as CliAuthReference } from "./public-profile-request-BwBfLgGv.mjs";
2
+ import { l as CliAgentSpec } from "./spec-Br00Ybw5.mjs";
3
+ import { ProxySecretBinding, agentProfileSchema } from "@tangle-network/agent-interface";
4
+
5
+ //#region src/native-inference-policy.d.ts
6
+ /** Inference only. Provider login and refresh remain protected Host operations. */
7
+ declare const NATIVE_INFERENCE_SCOPES: {
8
+ codex: {
9
+ hosts: string[];
10
+ methods: string[];
11
+ paths: string[];
12
+ };
13
+ "claude-code": {
14
+ hosts: string[];
15
+ methods: string[];
16
+ paths: string[];
17
+ };
18
+ };
19
+ /** Stable aliases name a source/reference component, never credential bytes. */
20
+ declare function nativeCliAuthProxyBindings(harness: keyof typeof NATIVE_INFERENCE_SCOPES, cliAuth: CliAuthReference, sourceId: string): Promise<readonly ProxySecretBinding[]>;
21
+ //#endregion
22
+ //#region src/specs.d.ts
23
+ /** Backend name shared by create, warm rebind and Sidecar backend resolution. */
24
+ declare const AGENT_BACKEND_ENV_VAR = "AGENT_BACKEND";
25
+ /** Salted proxy model key. The name OPENCODE_MODEL_API_KEY is load-bearing; do not rename it. */
26
+ declare const MANAGED_MODEL_KEY_ENV_VAR = "OPENCODE_MODEL_API_KEY";
27
+ /** Name of the box env var holding a caller-owned provider key. A name, never a secret. */
28
+ declare const MANAGED_MODEL_KEY_NAME_ENV_VAR = "OPENCODE_MODEL_API_KEY_ENV";
29
+ /**
30
+ * Env var names declared across ALL registered harness specs, grouped by
31
+ * their `CliAgentEnvVars` role. The ONE derivation every allowlist that must
32
+ * track "what env names can a backend legitimately use" builds from — the
33
+ * FC kernel-cmdline whitelist, the egress secret handling, the sidecar
34
+ * terminal scrub, the SSH env forward, and the rebind union below. Deriving
35
+ * from roles (not one flat set) lets each consumer apply its own security
36
+ * policy per role: apiKey and oauthToken names are secret channels.
37
+ * Native subscription tokens stay out of warm-claim delivery.
38
+ */
39
+ declare function cliAgentEnvVarNamesByRole(): {
40
+ apiKey: ReadonlySet<string>;
41
+ oauthToken: ReadonlySet<string>;
42
+ model: ReadonlySet<string>;
43
+ baseUrl: ReadonlySet<string>;
44
+ authMode: ReadonlySet<string>;
45
+ authFiles: ReadonlySet<string>;
46
+ extras: ReadonlySet<string>;
47
+ };
48
+ /**
49
+ * Union of every spec's `hostPassthroughEnvVars` — the operator tuning names
50
+ * a host process (orchestrator system env, host-agent process env) may
51
+ * forward into containers. Request/caller env always keeps precedence at the
52
+ * host-agent boundary; the orchestrator system-env channel stays
53
+ * operator-authoritative. Replaces the old `OPENCODE_*` prefix forward,
54
+ * which leaked ANY stray host var with that prefix (model tuple and key
55
+ * included) into every tenant.
56
+ */
57
+ declare function cliAgentHostPassthroughEnvVarNames(): ReadonlySet<string>;
58
+ /**
59
+ * Union of every env var name a warm-claim rebind may deliver, across all
60
+ * registered harnesses. The ONE source both sides of the rebind derive from:
61
+ * the host-agent selects its delivery from it and the sidecar rebind route
62
+ * carves it out of the loader-control rejection, so the two can never drift
63
+ * into "host delivers a name the sidecar 400s" — which silently cold-paths
64
+ * every warm claim of that backend. Includes each spec's apiKey name because
65
+ * acceptance is a superset of delivery: the HOST decides which key names are
66
+ * safe to send (egress proxy-swap-covered only), while the sidecar must not
67
+ * reject a name a valid host may deliver.
68
+ */
69
+ declare function claimDeliverableEnvVarNames(): ReadonlySet<string>;
70
+ /**
71
+ * claude-code is the only provider that demotes uid + forces HOME=/home/agent
72
+ * when the sidecar runs as root. All other CLIs inherit the sidecar HOME.
73
+ */
74
+ declare const CLI_AGENT_SPECS: readonly CliAgentSpec[];
75
+ declare function getSpec(name: string): CliAgentSpec | undefined;
76
+ /**
77
+ * The directory, relative to a session's storage path, where a backend's
78
+ * message log lives: the one value adapters, the sidecar and the parked
79
+ * export read. Throws for a backend whose spec names none.
80
+ */
81
+ declare function messageStorageDirOf(name: string): string;
82
+ //#endregion
83
+ export { agentProfileSchema as a, cliAgentHostPassthroughEnvVarNames as c, NATIVE_INFERENCE_SCOPES as d, nativeCliAuthProxyBindings as f, MANAGED_MODEL_KEY_NAME_ENV_VAR as i, getSpec as l, CLI_AGENT_SPECS as n, claimDeliverableEnvVarNames as o, MANAGED_MODEL_KEY_ENV_VAR as r, cliAgentEnvVarNamesByRole as s, AGENT_BACKEND_ENV_VAR as t, messageStorageDirOf as u };
84
+ //# sourceMappingURL=specs-CStHlNhB.d.mts.map
@@ -1,7 +1,7 @@
1
1
  import { t as HARNESSES } from "./harness-contracts-B1vAJ1yx.mjs";
2
2
  import { NATIVE_SESSION_CONTRACTS } from "./native-session-contracts.mjs";
3
3
  import { n as BACKEND_TYPE } from "./backend-types-CNo_Zj_K.mjs";
4
- import { agentProfileJsonSchema, agentProfileSchema } from "@tangle-network/agent-interface";
4
+ import { ProxySecretsSchema, agentProfileJsonSchema, agentProfileSchema } from "@tangle-network/agent-interface";
5
5
  import { z } from "zod";
6
6
  import { harnessModelSupport } from "@tangle-network/agent-interface/harness-capabilities";
7
7
  //#region src/synthetic-router-model.mjs
@@ -92,17 +92,55 @@ function cliAgentClaimEnvVarNames(spec) {
92
92
  return names;
93
93
  }
94
94
  //#endregion
95
+ //#region src/native-inference-policy.ts
96
+ /** Inference only. Provider login and refresh remain protected Host operations. */
97
+ const NATIVE_INFERENCE_SCOPES = {
98
+ codex: {
99
+ hosts: ["chatgpt.com"],
100
+ methods: ["GET", "POST"],
101
+ paths: ["/backend-api/*"]
102
+ },
103
+ "claude-code": {
104
+ hosts: ["api.anthropic.com"],
105
+ methods: ["POST"],
106
+ paths: ["/v1/*"]
107
+ }
108
+ };
109
+ /** Stable aliases name a source/reference component, never credential bytes. */
110
+ async function nativeCliAuthProxyBindings(harness, cliAuth, sourceId) {
111
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(JSON.stringify([
112
+ harness,
113
+ cliAuth,
114
+ sourceId
115
+ ])));
116
+ const alias = `NATIVE_${Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("")}`;
117
+ const access = {
118
+ envName: `${alias}_ACCESS`,
119
+ secretRef: {
120
+ kind: "secret-ref",
121
+ key: cliAuth.secretEnv
122
+ },
123
+ ...NATIVE_INFERENCE_SCOPES[harness],
124
+ presentation: { type: "bearer" },
125
+ placeholderFormat: harness === "codex" ? "jwt" : "opaque"
126
+ };
127
+ return ProxySecretsSchema.parse(harness === "codex" ? [access, {
128
+ ...access,
129
+ envName: `${alias}_ACCOUNT`,
130
+ presentation: {
131
+ type: "header",
132
+ name: "ChatGPT-Account-ID"
133
+ },
134
+ placeholderFormat: "opaque"
135
+ }] : [access]);
136
+ }
137
+ //#endregion
95
138
  //#region src/specs.ts
96
139
  z.globalRegistry.add(agentProfileSchema, {
97
140
  id: "AgentProfile",
98
141
  ...agentProfileJsonSchema
99
142
  });
100
- /**
101
- * Env var naming a sandbox's selected backend. Stamped into every create env
102
- * by the orchestrator (`buildSidecarContainerConfig`); read by the sidecar's
103
- * backend resolution (`resolveConfiguredBackend`) and by the host-agent's
104
- * warm-claim env selection to pick which spec's env vars the rebind delivers.
105
- */
143
+ /** Backend name shared by create, warm rebind and Sidecar backend resolution. */
106
144
  const AGENT_BACKEND_ENV_VAR = "AGENT_BACKEND";
107
145
  /** Salted proxy model key. The name OPENCODE_MODEL_API_KEY is load-bearing; do not rename it. */
108
146
  const MANAGED_MODEL_KEY_ENV_VAR = "OPENCODE_MODEL_API_KEY";
@@ -724,6 +762,6 @@ function messageStorageDirOf(name) {
724
762
  return dir;
725
763
  }
726
764
  //#endregion
727
- export { agentProfileSchema as a, cliAgentHostPassthroughEnvVarNames as c, canonicalModelSlug as d, cliAgentClaimEnvVarNames as f, SYNTHETIC_ROUTER_MODEL as g, harnessModelWire as h, MANAGED_MODEL_KEY_NAME_ENV_VAR as i, getSpec as l, harnessModelSupportFor as m, CLI_AGENT_SPECS as n, claimDeliverableEnvVarNames as o, cliAgentEnvRoleName as p, MANAGED_MODEL_KEY_ENV_VAR as r, cliAgentEnvVarNamesByRole as s, AGENT_BACKEND_ENV_VAR as t, messageStorageDirOf as u };
765
+ export { harnessModelWire as _, agentProfileSchema as a, cliAgentHostPassthroughEnvVarNames as c, NATIVE_INFERENCE_SCOPES as d, nativeCliAuthProxyBindings as f, harnessModelSupportFor as g, cliAgentEnvRoleName as h, MANAGED_MODEL_KEY_NAME_ENV_VAR as i, getSpec as l, cliAgentClaimEnvVarNames as m, CLI_AGENT_SPECS as n, claimDeliverableEnvVarNames as o, canonicalModelSlug as p, MANAGED_MODEL_KEY_ENV_VAR as r, cliAgentEnvVarNamesByRole as s, AGENT_BACKEND_ENV_VAR as t, messageStorageDirOf as u, SYNTHETIC_ROUTER_MODEL as v };
728
766
 
729
- //# sourceMappingURL=specs-D_iuiC3T.mjs.map
767
+ //# sourceMappingURL=specs-CZ6eAF6G.mjs.map