@tangle-network/sdk-provider-codex 0.4.2 → 0.4.3
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/index.d.mts +5 -4
- package/dist/index.mjs +210 -20
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AgentExecutionInput, AgentExecutionResult, BackendCapabilities, CliAuthFile, InteractionResponse, McpConfig, SdkHostServices, StreamEvent } from "@tangle-network/agent-interface";
|
|
2
2
|
import * as _$_tangle_network_sdk_cli_runner0 from "@tangle-network/sdk-cli-runner";
|
|
3
3
|
import { RpcBridge, StreamParserConfig } from "@tangle-network/sdk-cli-runner";
|
|
4
|
-
import { CliExecArgs, CliProviderAdapterBase, CliProviderConfig, CliProviderOptions, CliTurnProcess, CliTurnSpawn, ExecutionState, HarnessId, PreparedAttachment, WorkspacePlanApplication } from "@tangle-network/sdk-provider-cli-base";
|
|
4
|
+
import { CliExecArgs, CliProviderAdapterBase, CliProviderConfig, CliProviderOptions, CliTurnProcess, CliTurnSpawn, ExecutionState, HarnessId, PreparedAttachment, SecretProfileMcpLease, WorkspacePlanApplication } from "@tangle-network/sdk-provider-cli-base";
|
|
5
5
|
|
|
6
6
|
//#region src/app-server-protocol.d.ts
|
|
7
7
|
type NativeMcp = {
|
|
@@ -218,12 +218,13 @@ declare abstract class CodexSecretProfileAdapter extends CodexNativeLaunchAdapte
|
|
|
218
218
|
protected verifyPreparedSecretProfileRevision(input: AgentExecutionInput, plan: WorkspacePlanApplication): Promise<void>;
|
|
219
219
|
private readNativeConfig;
|
|
220
220
|
private readNativeControls;
|
|
221
|
-
protected nativeArgs(input: AgentExecutionInput
|
|
222
|
-
|
|
221
|
+
protected nativeArgs(input: AgentExecutionInput & {
|
|
222
|
+
managedQuoteVersion?: string;
|
|
223
|
+
}, plan: WorkspacePlanApplication | undefined, mcp?: Record<string, unknown>): string[];
|
|
224
|
+
protected prepareSecretCodexTurn(input: AgentExecutionInput, plan: WorkspacePlanApplication, sessionId: string, mcpInput: AgentExecutionInput, retainRelease: (release: SecretProfileMcpLease) => void): Promise<{
|
|
223
225
|
cwd: string;
|
|
224
226
|
env: Record<string, string | undefined>;
|
|
225
227
|
args: string[];
|
|
226
|
-
release: (() => void | Promise<void>) | undefined;
|
|
227
228
|
validate: (bridge: RpcBridge, extra: Record<string, unknown>) => Promise<Record<string, NativeMcp>>;
|
|
228
229
|
}>;
|
|
229
230
|
shutdown(): Promise<void>;
|
package/dist/index.mjs
CHANGED
|
@@ -2,9 +2,10 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { InteractionKind, ProxySecretBindingSchema, ProxySecretGrantSchema, ProxySecretReceiptSchema, ProxySecretUpdateControlsSchema, ProxySecretsSchema, isProxySecretScopeAttenuation, ownPropertyRecordSchema, proxySecretPresentationsEqual, resolveTangleRouterDefaults } from "@tangle-network/agent-interface";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { HELD_SPARE_IDLE_MS, createDeferredParser, createHeldSpareRegistry, launchDifferences, resolveRawCapturePath, spawnRpcBridge } from "@tangle-network/sdk-cli-runner";
|
|
5
|
-
import { CODEX_DISABLED_FEATURE_ARGS, CliProviderAdapterBase, InteractionBroker, McpInteractionSupport, NATIVE_SESSION_CONTRACTS, PROMPT_SECTION_SEPARATOR, SEALED_NATIVE_HOME_LAYOUT, assertSealedNativeHome, assertSealedNativeSearchPath, codexDeveloperInstructionArgs, deriveFilePart, forgetSessionScopes, interactionToggleEnabled, isLoopbackEndpoint, isPlainRecord, jsonEventParser, localMcpArgv, localMcpEnv, nativeEffortArgs, partitionImageAttachments, provenStoreBinary, reasoningEvents, recordCliTokenUsage, refuseSecretLaunch, resolveExecutableRealpath, secretMcpScope, secretSessionTurnQueue, servableMcpServer, servableStdioServer, sessionObservedEvents, streamPartBase, textDeltaEvents, toolResultEvents, toolStartEvents, trackFilePart, turnEndReason, untilSettledOrAborted, withTurnInteractions } from "@tangle-network/sdk-provider-cli-base";
|
|
5
|
+
import { CODEX_DISABLED_FEATURE_ARGS, CliProviderAdapterBase, InteractionBroker, McpInteractionSupport, NATIVE_SESSION_CONTRACTS, PROMPT_SECTION_SEPARATOR, SEALED_NATIVE_HOME_LAYOUT, assertSealedNativeHome, assertSealedNativeSearchPath, codexDeveloperInstructionArgs, deriveFilePart, directStdioMcpServers, executionCorrelationHeaders, forgetSessionScopes, interactionToggleEnabled, isLoopbackEndpoint, isPlainRecord, jsonEventParser, localMcpArgv, localMcpEnv, nativeEffortArgs, partitionImageAttachments, provenStoreBinary, reasoningEvents, recordCliTokenUsage, refuseSecretLaunch, resolveExecutableRealpath, secretMcpScope, secretSessionTurnQueue, servableMcpServer, servableStdioServer, sessionObservedEvents, streamPartBase, textDeltaEvents, toolResultEvents, toolStartEvents, trackFilePart, turnEndReason, untilSettledOrAborted, withTurnInteractions } from "@tangle-network/sdk-provider-cli-base";
|
|
6
6
|
import { existsSync } from "node:fs";
|
|
7
7
|
import path, { join } from "node:path";
|
|
8
|
+
import { isDeepStrictEqual } from "node:util";
|
|
8
9
|
const TURN_KEY_PLACEHOLDER_PREFIX = "tangle-turn-key";
|
|
9
10
|
const MODEL_KEY_PROXY_PATH_PREFIX = "/v1/";
|
|
10
11
|
const LOOPBACK_BASE_URL = /^http:\/\/127\.0\.0\.1:[0-9]+$/;
|
|
@@ -61,6 +62,12 @@ function managedModelProxyUrl(input) {
|
|
|
61
62
|
const runtimeHome = input.runtimeHome?.trim();
|
|
62
63
|
return proxiedModelUrl(binding.baseUrl, input.upstream, { ...runtimeHome ? { runtimeHome } : {} });
|
|
63
64
|
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region ../runtime-contracts/dist/declared-secrets.js
|
|
67
|
+
/** Bound values stay at the proxy. Declarations carry metadata only and are
|
|
68
|
+
* revalidated at every rebuild; an unbound name keeps box delivery unless the store's policy binds it.
|
|
69
|
+
* A declaration may bind several hosts: one credential, one slot and placeholder, many vendor hosts. */
|
|
70
|
+
const MAX_SECRET_VALUE_LENGTH = 65536;
|
|
64
71
|
new Set([
|
|
65
72
|
...Object.keys(MODEL_PROXY_TOKENS),
|
|
66
73
|
"TANGLE_API_KEY",
|
|
@@ -126,6 +133,48 @@ function isReservedProfileUid(uid) {
|
|
|
126
133
|
return Number.isSafeInteger(uid) && uid >= 2e5;
|
|
127
134
|
}
|
|
128
135
|
//#endregion
|
|
136
|
+
//#region ../runtime-contracts/dist/model-key-refresh.js
|
|
137
|
+
const batchCredentialOwner = {
|
|
138
|
+
allocationId: z.uuid(),
|
|
139
|
+
ownerId: z.string().min(1).max(256)
|
|
140
|
+
};
|
|
141
|
+
z.strictObject({
|
|
142
|
+
...batchCredentialOwner,
|
|
143
|
+
childKeyId: z.string().min(1).max(200).optional(),
|
|
144
|
+
keyExpiresAt: z.iso.datetime({ offset: true }).optional()
|
|
145
|
+
});
|
|
146
|
+
const batchCredentialIdentity = {
|
|
147
|
+
...batchCredentialOwner,
|
|
148
|
+
expiresAt: z.iso.datetime({ offset: true })
|
|
149
|
+
};
|
|
150
|
+
z.discriminatedUnion("operation", [
|
|
151
|
+
z.strictObject({
|
|
152
|
+
operation: z.literal("batch-allocate"),
|
|
153
|
+
...batchCredentialIdentity,
|
|
154
|
+
admissionDeadlineMs: z.number().int().positive(),
|
|
155
|
+
sourceKey: z.string().min(1).max(4096)
|
|
156
|
+
}),
|
|
157
|
+
z.strictObject({
|
|
158
|
+
operation: z.literal("batch-rotate"),
|
|
159
|
+
...batchCredentialIdentity
|
|
160
|
+
}),
|
|
161
|
+
z.strictObject({
|
|
162
|
+
operation: z.literal("batch-release"),
|
|
163
|
+
...batchCredentialIdentity,
|
|
164
|
+
childKeyId: z.string().min(1).max(200).optional()
|
|
165
|
+
})
|
|
166
|
+
]);
|
|
167
|
+
z.union([z.object({
|
|
168
|
+
refreshed: z.literal(true),
|
|
169
|
+
apiKey: z.string().min(1),
|
|
170
|
+
keyId: z.string().min(1),
|
|
171
|
+
baseUrl: z.string().url(),
|
|
172
|
+
expiresAt: z.iso.datetime({ offset: true })
|
|
173
|
+
}), z.object({
|
|
174
|
+
refreshed: z.literal(false),
|
|
175
|
+
reason: z.string().min(1)
|
|
176
|
+
})]);
|
|
177
|
+
//#endregion
|
|
129
178
|
//#region ../runtime-contracts/dist/proxy-secret-materialization.js
|
|
130
179
|
const syntheticHeader = {
|
|
131
180
|
alg: "HS256",
|
|
@@ -143,16 +192,24 @@ function isSyntheticPlaceholder(material) {
|
|
|
143
192
|
const prefix = placeholderPrefix(material.slot, material.grant.placeholderFormat, material.issuerExpiresAt);
|
|
144
193
|
return material.placeholder.startsWith(prefix) && /^[A-Za-z0-9_-]{43}$/.test(material.placeholder.slice(prefix.length));
|
|
145
194
|
}
|
|
146
|
-
z.array(z.
|
|
195
|
+
z.array(z.preprocess((input) => {
|
|
196
|
+
if (input && typeof input === "object" && "issuerExpiresAt" in input && (!("executionExpiresAt" in input) || input.executionExpiresAt === void 0) && (!("native" in input) || input.native === void 0)) return {
|
|
197
|
+
...input,
|
|
198
|
+
executionExpiresAt: input.issuerExpiresAt
|
|
199
|
+
};
|
|
200
|
+
return input;
|
|
201
|
+
}, z.strictObject({
|
|
147
202
|
binding: ProxySecretBindingSchema,
|
|
148
203
|
grant: ProxySecretGrantSchema,
|
|
149
204
|
placeholder: z.string().min(1),
|
|
150
205
|
slot: z.string().refine(isDeclaredSecretSlotEnvVar),
|
|
151
|
-
issuerExpiresAt: z.iso.datetime()
|
|
152
|
-
|
|
206
|
+
issuerExpiresAt: z.iso.datetime(),
|
|
207
|
+
executionExpiresAt: z.iso.datetime(),
|
|
208
|
+
native: z.unknown().optional()
|
|
209
|
+
}))).superRefine((materials, ctx) => {
|
|
153
210
|
const bindings = ProxySecretsSchema.safeParse(materials.map((m) => m.binding));
|
|
154
211
|
const unique = (values) => new Set(values).size === values.length;
|
|
155
|
-
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 }) => !isProxySecretScopeAttenuation(binding, grant.scope) || !proxySecretPresentationsEqual(binding.presentation, grant.presentation) || (binding.placeholderFormat ?? "opaque") !== grant.placeholderFormat || Date.parse(grant.expiresAt) > Date.parse(issuerExpiresAt))) ctx.addIssue({
|
|
212
|
+
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({
|
|
156
213
|
code: "custom",
|
|
157
214
|
message: "Invalid proxy secret materialization"
|
|
158
215
|
});
|
|
@@ -162,6 +219,114 @@ ProxySecretUpdateControlsSchema.extend({
|
|
|
162
219
|
proxySecretGrants: ProxySecretReceiptSchema.options[0].shape.bindings,
|
|
163
220
|
expectedProxySecretGeneration: ProxySecretUpdateControlsSchema.shape.expectedProxySecretGeneration.unwrap()
|
|
164
221
|
}).strict().refine((body) => new Set(body.proxySecretGrants.map((b) => b.envName)).size === body.proxySecretGrants.length);
|
|
222
|
+
const sourceBindingSchema = ProxySecretReceiptSchema.options[0].shape.bindings.element;
|
|
223
|
+
const sourceRevisionSchema = z.iso.datetime();
|
|
224
|
+
const sourceLeaseTokenSchema = z.uuid();
|
|
225
|
+
const sourceAuthority = {
|
|
226
|
+
binding: sourceBindingSchema,
|
|
227
|
+
issuerExpiresAt: z.iso.datetime()
|
|
228
|
+
};
|
|
229
|
+
z.discriminatedUnion("operation", [
|
|
230
|
+
z.strictObject({
|
|
231
|
+
operation: z.literal("read"),
|
|
232
|
+
...sourceAuthority,
|
|
233
|
+
rekey: z.literal(true).optional()
|
|
234
|
+
}),
|
|
235
|
+
z.strictObject({
|
|
236
|
+
operation: z.literal("lease"),
|
|
237
|
+
...sourceAuthority,
|
|
238
|
+
expectedUpdatedAt: sourceRevisionSchema,
|
|
239
|
+
leaseExpiresAt: z.iso.datetime(),
|
|
240
|
+
leaseToken: sourceLeaseTokenSchema.optional()
|
|
241
|
+
}),
|
|
242
|
+
z.strictObject({
|
|
243
|
+
operation: z.literal("commit"),
|
|
244
|
+
...sourceAuthority,
|
|
245
|
+
expectedUpdatedAt: sourceRevisionSchema,
|
|
246
|
+
leaseToken: sourceLeaseTokenSchema,
|
|
247
|
+
value: z.string().min(1).max(MAX_SECRET_VALUE_LENGTH)
|
|
248
|
+
}),
|
|
249
|
+
z.strictObject({
|
|
250
|
+
operation: z.literal("release"),
|
|
251
|
+
...sourceAuthority,
|
|
252
|
+
leaseToken: sourceLeaseTokenSchema
|
|
253
|
+
})
|
|
254
|
+
]);
|
|
255
|
+
const sourceMetadataSchema = z.strictObject({
|
|
256
|
+
secretId: z.string().min(1),
|
|
257
|
+
key: ProxySecretBindingSchema.shape.secretRef.shape.key,
|
|
258
|
+
updatedAt: sourceRevisionSchema
|
|
259
|
+
});
|
|
260
|
+
const sourceSnapshotSchema = sourceMetadataSchema.extend({ value: z.string().min(1).max(MAX_SECRET_VALUE_LENGTH) });
|
|
261
|
+
z.discriminatedUnion("operation", [
|
|
262
|
+
z.strictObject({
|
|
263
|
+
operation: z.literal("read"),
|
|
264
|
+
source: sourceSnapshotSchema,
|
|
265
|
+
binding: sourceBindingSchema,
|
|
266
|
+
refreshExpiresAt: z.iso.datetime()
|
|
267
|
+
}),
|
|
268
|
+
z.strictObject({
|
|
269
|
+
operation: z.literal("lease"),
|
|
270
|
+
source: sourceSnapshotSchema,
|
|
271
|
+
leaseToken: sourceLeaseTokenSchema,
|
|
272
|
+
leaseExpiresAt: z.iso.datetime(),
|
|
273
|
+
phase: z.enum([
|
|
274
|
+
"leased",
|
|
275
|
+
"started",
|
|
276
|
+
"replay"
|
|
277
|
+
]).default("leased")
|
|
278
|
+
}),
|
|
279
|
+
z.strictObject({
|
|
280
|
+
operation: z.literal("commit"),
|
|
281
|
+
source: sourceMetadataSchema
|
|
282
|
+
}),
|
|
283
|
+
z.strictObject({
|
|
284
|
+
operation: z.literal("release"),
|
|
285
|
+
released: z.literal(true)
|
|
286
|
+
})
|
|
287
|
+
]);
|
|
288
|
+
const nativeCredentialProtocolSchema = z.enum([
|
|
289
|
+
"legacy",
|
|
290
|
+
"canonical",
|
|
291
|
+
"unselected"
|
|
292
|
+
]);
|
|
293
|
+
z.strictObject({
|
|
294
|
+
nativeCredentialProtocol: nativeCredentialProtocolSchema,
|
|
295
|
+
priorExposure: z.boolean(),
|
|
296
|
+
containerId: z.string().min(1),
|
|
297
|
+
expectedProxySecretGeneration: ProxySecretUpdateControlsSchema.shape.expectedProxySecretGeneration,
|
|
298
|
+
authorityExpiresAt: z.iso.datetime().optional()
|
|
299
|
+
});
|
|
300
|
+
ownPropertyRecordSchema(z.strictObject({
|
|
301
|
+
revision: ProxySecretGrantSchema.shape.identity.shape.revision,
|
|
302
|
+
value: z.string().min(1).max(MAX_SECRET_VALUE_LENGTH),
|
|
303
|
+
refresh: z.strictObject({
|
|
304
|
+
revision: sourceRevisionSchema,
|
|
305
|
+
leaseToken: sourceLeaseTokenSchema
|
|
306
|
+
}).optional()
|
|
307
|
+
}));
|
|
308
|
+
z.strictObject({
|
|
309
|
+
grant: ProxySecretGrantSchema,
|
|
310
|
+
value: z.string().min(1).max(MAX_SECRET_VALUE_LENGTH),
|
|
311
|
+
expectedUpdatedAt: sourceRevisionSchema.optional(),
|
|
312
|
+
replayOnly: z.boolean().optional(),
|
|
313
|
+
leaseExpiresAt: z.iso.datetime()
|
|
314
|
+
});
|
|
315
|
+
z.discriminatedUnion("status", [
|
|
316
|
+
z.strictObject({
|
|
317
|
+
status: z.literal("refreshed"),
|
|
318
|
+
value: z.string().min(1).max(MAX_SECRET_VALUE_LENGTH),
|
|
319
|
+
sourceExpiresAt: z.iso.datetime().optional()
|
|
320
|
+
}),
|
|
321
|
+
z.strictObject({
|
|
322
|
+
status: z.literal("nonrefreshable"),
|
|
323
|
+
reason: z.string().min(1)
|
|
324
|
+
}),
|
|
325
|
+
z.strictObject({
|
|
326
|
+
status: z.literal("refused"),
|
|
327
|
+
reason: z.string().min(1)
|
|
328
|
+
})
|
|
329
|
+
]);
|
|
165
330
|
//#endregion
|
|
166
331
|
//#region ../runtime-contracts/dist/runtime-environment.js
|
|
167
332
|
const SAFE_ENV_VAR_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
@@ -1079,7 +1244,10 @@ var CodexSecretProfileAdapter = class extends CodexNativeLaunchAdapter {
|
|
|
1079
1244
|
detached: true,
|
|
1080
1245
|
inheritEnv: this.inheritProcessEnv,
|
|
1081
1246
|
command,
|
|
1082
|
-
args: this.nativeArgs(
|
|
1247
|
+
args: this.nativeArgs({
|
|
1248
|
+
...input,
|
|
1249
|
+
managedQuoteVersion: void 0
|
|
1250
|
+
}, plan),
|
|
1083
1251
|
cwd,
|
|
1084
1252
|
env,
|
|
1085
1253
|
...identity,
|
|
@@ -1119,12 +1287,15 @@ var CodexSecretProfileAdapter = class extends CodexNativeLaunchAdapter {
|
|
|
1119
1287
|
const servers = config.mcp_servers ?? {};
|
|
1120
1288
|
if (expected && (Object.keys(servers).length !== Object.keys(expected).length || Object.entries(servers).some(([name, server]) => {
|
|
1121
1289
|
const declared = expected[name];
|
|
1122
|
-
return !declared || server.url !== declared.url || server.command || (server.args
|
|
1123
|
-
}))) this.refuse("native MCP
|
|
1290
|
+
return !declared || (server.url ?? void 0) !== (declared.url ?? void 0) || (server.command ?? void 0) !== declared.command || !isDeepStrictEqual(server.args ?? [], declared.args ?? []) || !isDeepStrictEqual(server.env ?? {}, declared.env ?? {}) || !isDeepStrictEqual(server.env_vars ?? [], declared.env_vars ?? []) || (server.bearer_token_env_var ?? void 0) !== declared.bearer_token_env_var || !isDeepStrictEqual(server.http_headers ?? {}, declared.http_headers ?? {}) || !isDeepStrictEqual(server.env_http_headers ?? {}, declared.env_http_headers ?? {});
|
|
1291
|
+
}))) this.refuse("native MCP controls differ", cwd);
|
|
1124
1292
|
return servers;
|
|
1125
1293
|
}
|
|
1126
1294
|
nativeArgs(input, plan, mcp) {
|
|
1127
|
-
const prompts =
|
|
1295
|
+
const prompts = {
|
|
1296
|
+
...this.resolveProfilePrompts(input, plan),
|
|
1297
|
+
correlationHeaders: executionCorrelationHeaders(input.interactionBinding, input.traceId, input.managedQuoteVersion)
|
|
1298
|
+
};
|
|
1128
1299
|
if (this.config.secretProfileRevisionRoot && plan) {
|
|
1129
1300
|
const context = `The mutable workspace is ${JSON.stringify(input.workspaceRoot ?? this.storagePath)}. The current directory holds the read-only supplied profile. Use absolute paths in the mutable workspace for edits, builds and git commands.`;
|
|
1130
1301
|
prompts.appendSystemPrompt = [prompts.appendSystemPrompt, context].filter(Boolean).join("\n\n");
|
|
@@ -1139,7 +1310,7 @@ var CodexSecretProfileAdapter = class extends CodexNativeLaunchAdapter {
|
|
|
1139
1310
|
...mcp === void 0 ? [] : ["-c", `mcp_servers=${inlineToml(mcp)}`]
|
|
1140
1311
|
];
|
|
1141
1312
|
}
|
|
1142
|
-
async prepareSecretCodexTurn(input, plan, sessionId) {
|
|
1313
|
+
async prepareSecretCodexTurn(input, plan, sessionId, mcpInput, retainRelease) {
|
|
1143
1314
|
const native = await this.readNativeConfig(input, plan);
|
|
1144
1315
|
const cwd = this.bindSecretProfileSessionView(native.cwd, sessionId);
|
|
1145
1316
|
assertSealedNativeSearchPath(cwd, [".codex", ".agents"]);
|
|
@@ -1188,12 +1359,23 @@ var CodexSecretProfileAdapter = class extends CodexNativeLaunchAdapter {
|
|
|
1188
1359
|
};
|
|
1189
1360
|
}
|
|
1190
1361
|
}
|
|
1191
|
-
const
|
|
1362
|
+
const release = served.length ? await this.mcpOwner.proxy?.lease(scope, served, mcpInput) : void 0;
|
|
1363
|
+
if (served.length && typeof release !== "function") this.refuse("MCP lease was not acknowledged", cwd);
|
|
1364
|
+
if (release) retainRelease(release);
|
|
1365
|
+
input.abortSignal?.throwIfAborted();
|
|
1366
|
+
for (const server of directStdioMcpServers(release, served).values()) {
|
|
1367
|
+
const { url: _url, http_headers: _headers, ...controls } = servers[server.name];
|
|
1368
|
+
servers[server.name] = {
|
|
1369
|
+
...controls,
|
|
1370
|
+
command: server.command[0],
|
|
1371
|
+
args: server.command.slice(1),
|
|
1372
|
+
env: { ...server.environment }
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1192
1375
|
return {
|
|
1193
1376
|
cwd,
|
|
1194
1377
|
env: native.env,
|
|
1195
|
-
args,
|
|
1196
|
-
release: served.length ? await this.mcpOwner.proxy?.lease(scope, served) : void 0,
|
|
1378
|
+
args: this.nativeArgs(input, plan, servers),
|
|
1197
1379
|
validate: (bridge, extra) => this.readNativeControls(bridge, plan, cwd, {
|
|
1198
1380
|
...servers,
|
|
1199
1381
|
...extra
|
|
@@ -1250,16 +1432,22 @@ var CodexAppServerAdapter = class extends CodexSecretProfileAdapter {
|
|
|
1250
1432
|
return this.withExecution(input.abortSignal, (signal) => this.executeViaAppServer({
|
|
1251
1433
|
...input,
|
|
1252
1434
|
abortSignal: signal
|
|
1253
|
-
}, services, onEvent));
|
|
1435
|
+
}, services, onEvent, input));
|
|
1254
1436
|
}
|
|
1255
|
-
async executeViaAppServer(input, services, onEvent) {
|
|
1256
|
-
const prepared = await this.prepareAppServerTurn(input, services, onEvent);
|
|
1437
|
+
async executeViaAppServer(input, services, onEvent, mcpInput = input) {
|
|
1438
|
+
const prepared = await this.prepareAppServerTurn(input, services, onEvent, mcpInput);
|
|
1257
1439
|
if (prepared.cached !== void 0) return prepared.cached;
|
|
1258
1440
|
const queue = this.config.secretProfileRevisionRoot ? secretSessionTurnQueue(this.secretProfileSessionView(prepared.sessionId).view) : void 0;
|
|
1259
1441
|
let bridge;
|
|
1260
1442
|
let result;
|
|
1261
1443
|
let closing;
|
|
1262
|
-
const close = () => closing ??= this.closeAppServerTurn(prepared, bridge, queue)
|
|
1444
|
+
const close = () => closing ??= this.closeAppServerTurn(prepared, bridge, queue).catch((error) => {
|
|
1445
|
+
queue?.retryCleanup(() => {
|
|
1446
|
+
closing = void 0;
|
|
1447
|
+
return close();
|
|
1448
|
+
});
|
|
1449
|
+
throw error;
|
|
1450
|
+
});
|
|
1263
1451
|
prepared.run.cleanup = close;
|
|
1264
1452
|
try {
|
|
1265
1453
|
if (queue) await untilSettledOrAborted(queue.previous, input.abortSignal ?? new AbortController().signal);
|
|
@@ -1277,7 +1465,7 @@ var CodexAppServerAdapter = class extends CodexSecretProfileAdapter {
|
|
|
1277
1465
|
}
|
|
1278
1466
|
/** Capture session binding, profile/prompt and native callbacks before acquiring resources.
|
|
1279
1467
|
* Field construction stays one preparation record; launch/run/cleanup have separate owners. */
|
|
1280
|
-
async prepareAppServerTurn(input, services, onEvent) {
|
|
1468
|
+
async prepareAppServerTurn(input, services, onEvent, mcpInput) {
|
|
1281
1469
|
this.ensureInitialized();
|
|
1282
1470
|
const opened = await this.openTurnSession({
|
|
1283
1471
|
...input,
|
|
@@ -1317,6 +1505,7 @@ var CodexAppServerAdapter = class extends CodexSecretProfileAdapter {
|
|
|
1317
1505
|
turn.activeThreadId = initialThreadId(input) ?? opened.providerSessionId;
|
|
1318
1506
|
return {
|
|
1319
1507
|
releaseMcp: void 0,
|
|
1508
|
+
mcpInput,
|
|
1320
1509
|
input,
|
|
1321
1510
|
services,
|
|
1322
1511
|
onEvent,
|
|
@@ -1330,8 +1519,9 @@ var CodexAppServerAdapter = class extends CodexSecretProfileAdapter {
|
|
|
1330
1519
|
}
|
|
1331
1520
|
async launchAppServerTurn(context) {
|
|
1332
1521
|
const { input, profilePlan, run } = context;
|
|
1333
|
-
const secret = this.config.secretProfileRevisionRoot && profilePlan ? await this.prepareSecretCodexTurn(input, profilePlan, context.sessionId)
|
|
1334
|
-
|
|
1522
|
+
const secret = this.config.secretProfileRevisionRoot && profilePlan ? await this.prepareSecretCodexTurn(input, profilePlan, context.sessionId, context.mcpInput, (release) => {
|
|
1523
|
+
context.releaseMcp = release;
|
|
1524
|
+
}) : void 0;
|
|
1335
1525
|
const env = secret?.env ?? this.buildAppServerEnv(profilePlan, run.cwd);
|
|
1336
1526
|
run.cwd = secret?.cwd ?? run.cwd;
|
|
1337
1527
|
const args = secret?.args ?? this.nativeArgs(input, profilePlan);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/sdk-provider-codex",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@tangle-network/agent-backend-types": "1.3.3",
|
|
19
19
|
"@tangle-network/agent-interface": "^5.10.20",
|
|
20
20
|
"@tangle-network/sdk-cli-runner": "0.3.9",
|
|
21
|
-
"@tangle-network/sdk-provider-cli-base": "0.13.
|
|
21
|
+
"@tangle-network/sdk-provider-cli-base": "0.13.20",
|
|
22
22
|
"@tangle-network/sdk-session-persistence": "0.7.5",
|
|
23
23
|
"zod": "4.6.7"
|
|
24
24
|
},
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"registry": "https://registry.npmjs.org"
|
|
35
35
|
},
|
|
36
36
|
"tangleRelease": {
|
|
37
|
-
"sourceSha": "
|
|
38
|
-
"mergedAt": "2026-11-
|
|
37
|
+
"sourceSha": "8af7f9410f67473cf82e7c48ee3bf284a2afea77",
|
|
38
|
+
"mergedAt": "2026-11-07T00:12:57-08:00"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsdown",
|