@alan-ai-hq/agent-manager-darwin-arm64 0.1.135 → 0.1.136
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/alan-agent.cjs +426 -216
- package/alan-holder.cjs +310 -145
- package/package.json +1 -1
package/alan-agent.cjs
CHANGED
|
@@ -20379,10 +20379,13 @@ var init_desired_state = __esm({
|
|
|
20379
20379
|
function runProviderCredentialPath(runId) {
|
|
20380
20380
|
return `/public/machines/me/runs/${encodeURIComponent(runId)}/provider-credential`;
|
|
20381
20381
|
}
|
|
20382
|
+
function runCodexCredentialRefreshPath(runId) {
|
|
20383
|
+
return `${runProviderCredentialPath(runId)}/refresh`;
|
|
20384
|
+
}
|
|
20382
20385
|
function runAttachmentPath(runId, attachmentId) {
|
|
20383
20386
|
return `/public/machines/me/runs/${encodeURIComponent(runId)}/attachments/${encodeURIComponent(attachmentId)}`;
|
|
20384
20387
|
}
|
|
20385
|
-
var machineEndpointsSchema, machineCredentialGrantSchema, MACHINE_PATHS, machinePlatformSchema, machineRegisterRequestSchema, machineEnrollRequestSchema, machineRenewRequestSchema, machineRenewReusedSchema, deviceAuthorizationSchema, machineDeviceAuthorizationRequestSchema, machineDeviceTokenRequestSchema, machineDeviceTokenSchema, DEVICE_TOKEN_ERRORS, machineDeviceTokenErrorSchema, DEVICE_SLOW_DOWN_INCREMENT_SECONDS, machineMcpCredentialRequestSchema, machineMcpCredentialSchema, runtimeReleaseSchema, machineSiblingSchema, MACHINE_SIBLINGS_LIMIT, machineSiblingsResponseSchema, runProviderCredentialSchema;
|
|
20388
|
+
var machineEndpointsSchema, machineCredentialGrantSchema, MACHINE_PATHS, machinePlatformSchema, machineRegisterRequestSchema, machineEnrollRequestSchema, machineRenewRequestSchema, machineRenewReusedSchema, deviceAuthorizationSchema, machineDeviceAuthorizationRequestSchema, machineDeviceTokenRequestSchema, machineDeviceTokenSchema, DEVICE_TOKEN_ERRORS, machineDeviceTokenErrorSchema, DEVICE_SLOW_DOWN_INCREMENT_SECONDS, machineMcpCredentialRequestSchema, machineMcpCredentialSchema, runtimeReleaseSchema, machineSiblingSchema, MACHINE_SIBLINGS_LIMIT, machineSiblingsResponseSchema, runCodexCredentialSchema, runCodexCredentialRefreshRequestSchema, runProviderCredentialSchema;
|
|
20386
20389
|
var init_machine_identity = __esm({
|
|
20387
20390
|
"../shared/dist/runtime-v2/machine-identity.js"() {
|
|
20388
20391
|
"use strict";
|
|
@@ -20498,9 +20501,20 @@ var init_machine_identity = __esm({
|
|
|
20498
20501
|
machineSiblingsResponseSchema = external_exports.object({
|
|
20499
20502
|
machines: external_exports.array(machineSiblingSchema).max(MACHINE_SIBLINGS_LIMIT)
|
|
20500
20503
|
});
|
|
20504
|
+
runCodexCredentialSchema = external_exports.object({
|
|
20505
|
+
accessToken: external_exports.string().min(1),
|
|
20506
|
+
chatgptAccountId: external_exports.string().min(1),
|
|
20507
|
+
chatgptPlanType: external_exports.string().nullable()
|
|
20508
|
+
});
|
|
20509
|
+
runCodexCredentialRefreshRequestSchema = external_exports.object({
|
|
20510
|
+
/** sha256 hex of the access token Codex was refused with; a newer stored token is returned instead of rotating. */
|
|
20511
|
+
rejectedAccessTokenSha256: external_exports.string().regex(/^[0-9a-f]{64}$/).optional()
|
|
20512
|
+
});
|
|
20501
20513
|
runProviderCredentialSchema = external_exports.object({
|
|
20502
20514
|
/** Environment variables for the agent CLI, e.g. ANTHROPIC_API_KEY; empty when the CLI's own login is used. */
|
|
20503
|
-
env: external_exports.record(external_exports.string(), external_exports.string())
|
|
20515
|
+
env: external_exports.record(external_exports.string(), external_exports.string()),
|
|
20516
|
+
/** The team's Codex login for a cloud sandbox; absent where the CLI's own login is used. */
|
|
20517
|
+
codex: runCodexCredentialSchema.optional()
|
|
20504
20518
|
});
|
|
20505
20519
|
}
|
|
20506
20520
|
});
|
|
@@ -24402,11 +24416,20 @@ var init_chunk_DALFHI4B = __esm({
|
|
|
24402
24416
|
}
|
|
24403
24417
|
});
|
|
24404
24418
|
|
|
24405
|
-
// ../agent-core/dist/chunk-
|
|
24419
|
+
// ../agent-core/dist/chunk-54ZRJOQP.js
|
|
24406
24420
|
function specForErrorKind(errorKind) {
|
|
24407
24421
|
const spec = ERROR_SPECS[errorKind];
|
|
24408
24422
|
return { message: spec.message, errorKind, recoveryClass: spec.recoveryClass };
|
|
24409
24423
|
}
|
|
24424
|
+
function withAgentSignIn(classified, harness) {
|
|
24425
|
+
const agent = AGENT_SIGN_IN_BY_HARNESS.get(harness);
|
|
24426
|
+
if (!agent || classified.message !== ERROR_SPECS.not_logged_in.message) return classified;
|
|
24427
|
+
const local = agent.localSignIn ?? "sign in to it";
|
|
24428
|
+
return {
|
|
24429
|
+
...classified,
|
|
24430
|
+
message: `${agent.name} isn't signed in: for cloud runs connect it in Team settings \u2192 Integrations \u2192 Coding agents; on your computer ${local}; then retry.`
|
|
24431
|
+
};
|
|
24432
|
+
}
|
|
24410
24433
|
function embeddedJson(text2) {
|
|
24411
24434
|
const start = text2.indexOf("{");
|
|
24412
24435
|
if (start === -1) return void 0;
|
|
@@ -24565,7 +24588,8 @@ function retryOwnerFor(classified, harnessOwnsRetry, safe) {
|
|
|
24565
24588
|
if (!safe) return "none";
|
|
24566
24589
|
return classified.errorKind === "resume_failed" || classified.errorKind === "history_rejected" ? "alan_resume" : "user_confirmed_fresh_run";
|
|
24567
24590
|
}
|
|
24568
|
-
function createCliProblem(
|
|
24591
|
+
function createCliProblem(observed, options) {
|
|
24592
|
+
const classified = withAgentSignIn(observed, options.harness);
|
|
24569
24593
|
const automatic = classified.recoveryClass === "auto_recovering";
|
|
24570
24594
|
const harnessOwnsRetry = options.finality === "observation" && automatic;
|
|
24571
24595
|
const safe = options.outcomeCertainty === "no_effect" || harnessOwnsRetry;
|
|
@@ -24595,9 +24619,9 @@ function createCliProblem(classified, options) {
|
|
|
24595
24619
|
...classified.resetsAt ? { resetsAt: classified.resetsAt } : {}
|
|
24596
24620
|
});
|
|
24597
24621
|
}
|
|
24598
|
-
var import_crypto2, ERROR_SPECS, AGENT_ERROR_KINDS, STATUS_PREFIX, TEXT_RULES, CODEX_TIMEOUT_MESSAGE, CODEX_EXPIRED_MESSAGE, EPOCH_RESET, WORDED_RESET, COMMAND_NOT_FOUND, CODE_RULES, TEXT_REFINES, STATUS_LEAD, CLI_PROBLEM_CODE_BY_ERROR_KIND, KEY_REJECTION_KINDS;
|
|
24599
|
-
var
|
|
24600
|
-
"../agent-core/dist/chunk-
|
|
24622
|
+
var import_crypto2, ERROR_SPECS, AGENT_ERROR_KINDS, AGENT_SIGN_IN_BY_HARNESS, STATUS_PREFIX, TEXT_RULES, CODEX_TIMEOUT_MESSAGE, CODEX_EXPIRED_MESSAGE, EPOCH_RESET, WORDED_RESET, COMMAND_NOT_FOUND, CODE_RULES, TEXT_REFINES, STATUS_LEAD, CLI_PROBLEM_CODE_BY_ERROR_KIND, KEY_REJECTION_KINDS;
|
|
24623
|
+
var init_chunk_54ZRJOQP = __esm({
|
|
24624
|
+
"../agent-core/dist/chunk-54ZRJOQP.js"() {
|
|
24601
24625
|
"use strict";
|
|
24602
24626
|
init_chunk_YXWJW7I5();
|
|
24603
24627
|
import_crypto2 = require("crypto");
|
|
@@ -24616,7 +24640,7 @@ var init_chunk_R6R6ORR2 = __esm({
|
|
|
24616
24640
|
recoveryClass: "user_fixable"
|
|
24617
24641
|
},
|
|
24618
24642
|
not_logged_in: {
|
|
24619
|
-
message: "
|
|
24643
|
+
message: "The agent CLI isn't signed in: for cloud runs connect it in Team settings \u2192 Integrations \u2192 Coding agents; on your computer sign in to the CLI; then retry.",
|
|
24620
24644
|
recoveryClass: "user_fixable"
|
|
24621
24645
|
},
|
|
24622
24646
|
not_authenticated: {
|
|
@@ -24707,6 +24731,19 @@ var init_chunk_R6R6ORR2 = __esm({
|
|
|
24707
24731
|
AGENT_ERROR_KINDS = Object.keys(ERROR_SPECS).filter(
|
|
24708
24732
|
(key) => key in ERROR_SPECS
|
|
24709
24733
|
);
|
|
24734
|
+
AGENT_SIGN_IN_BY_HARNESS = /* @__PURE__ */ new Map([
|
|
24735
|
+
["claude_cli", { name: "Claude Code", localSignIn: "run `claude` then `/login`" }],
|
|
24736
|
+
["codex_app_server", { name: "Codex", localSignIn: "run `codex login`" }],
|
|
24737
|
+
["codex_exec", { name: "Codex", localSignIn: "run `codex login`" }],
|
|
24738
|
+
["cursor_agent_cli", { name: "Cursor Agent", localSignIn: "run `cursor-agent login`" }],
|
|
24739
|
+
["copilot_cli", { name: "GitHub Copilot CLI", localSignIn: "run `copilot` then `/login`" }],
|
|
24740
|
+
["opencode_serve", { name: "OpenCode", localSignIn: "run `opencode auth login`" }],
|
|
24741
|
+
["droid_cli", { name: "Droid" }],
|
|
24742
|
+
["antigravity_cli", { name: "Antigravity" }],
|
|
24743
|
+
["grok_cli", { name: "Grok CLI" }],
|
|
24744
|
+
["kimi_cli", { name: "Kimi CLI" }],
|
|
24745
|
+
["command_code_cli", { name: "Command Code" }]
|
|
24746
|
+
]);
|
|
24710
24747
|
STATUS_PREFIX = /\b(?:api error|status|http)[:\s]+(\d{3})\b/i;
|
|
24711
24748
|
TEXT_RULES = [
|
|
24712
24749
|
{ kind: "auth_expired", pattern: /\bcodex cli connection expired\b|\breconnect openai codex\b/ },
|
|
@@ -24847,7 +24884,7 @@ var init_chunk_R6R6ORR2 = __esm({
|
|
|
24847
24884
|
}
|
|
24848
24885
|
});
|
|
24849
24886
|
|
|
24850
|
-
// ../agent-core/dist/chunk-
|
|
24887
|
+
// ../agent-core/dist/chunk-YPYC4VBL.js
|
|
24851
24888
|
function collectStrings(value2, out) {
|
|
24852
24889
|
if (typeof value2 === "string") out.push(value2);
|
|
24853
24890
|
else if (Array.isArray(value2)) for (const item of value2) collectStrings(item, out);
|
|
@@ -25217,11 +25254,11 @@ function silentStartError(name, timeoutMs) {
|
|
|
25217
25254
|
};
|
|
25218
25255
|
}
|
|
25219
25256
|
var import_crypto3, import_fs4, import_path3, IMAGE_MIME_BY_EXT, VIDEO_MIME_BY_EXT, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, MAX_IMAGE_BYTES, MAX_VIDEO_BYTES, AGENT_BROWSER_MENTION, LocalMediaReader, SessionOpenRefusal, JsonRpcError, ACP_PROTOCOL_VERSION, ACP_ERROR, STDERR_TAIL_LINES, RESULT_EXIT_GRACE_MS, PerTurnSession;
|
|
25220
|
-
var
|
|
25221
|
-
"../agent-core/dist/chunk-
|
|
25257
|
+
var init_chunk_YPYC4VBL = __esm({
|
|
25258
|
+
"../agent-core/dist/chunk-YPYC4VBL.js"() {
|
|
25222
25259
|
"use strict";
|
|
25223
25260
|
init_chunk_UGRKZTAD();
|
|
25224
|
-
|
|
25261
|
+
init_chunk_54ZRJOQP();
|
|
25225
25262
|
init_chunk_J4T6L5LX();
|
|
25226
25263
|
init_chunk_YXWJW7I5();
|
|
25227
25264
|
import_crypto3 = require("crypto");
|
|
@@ -27279,9 +27316,9 @@ var init_claude = __esm({
|
|
|
27279
27316
|
"../agent-core/dist/providers/claude.js"() {
|
|
27280
27317
|
"use strict";
|
|
27281
27318
|
init_chunk_DALFHI4B();
|
|
27282
|
-
|
|
27319
|
+
init_chunk_YPYC4VBL();
|
|
27283
27320
|
init_chunk_UGRKZTAD();
|
|
27284
|
-
|
|
27321
|
+
init_chunk_54ZRJOQP();
|
|
27285
27322
|
init_chunk_J2KTV5FP();
|
|
27286
27323
|
init_chunk_J4T6L5LX();
|
|
27287
27324
|
init_chunk_6WN2R725();
|
|
@@ -29070,11 +29107,12 @@ async function withDeadline(work, clock, ms, what) {
|
|
|
29070
29107
|
`codex app-server did not answer ${what} within ${ms} ms`
|
|
29071
29108
|
);
|
|
29072
29109
|
}
|
|
29073
|
-
async function handshake(session, log) {
|
|
29110
|
+
async function handshake(session, spec, log) {
|
|
29111
|
+
const experimentalApi = spec.externalAuth !== void 0;
|
|
29074
29112
|
const init = asRecord(
|
|
29075
29113
|
await session.rpc.request("initialize", {
|
|
29076
29114
|
clientInfo: CLIENT_INFO,
|
|
29077
|
-
capabilities: { experimentalApi
|
|
29115
|
+
capabilities: { experimentalApi, requestAttestation: false }
|
|
29078
29116
|
})
|
|
29079
29117
|
);
|
|
29080
29118
|
const userAgent = asString(init?.userAgent);
|
|
@@ -29167,7 +29205,7 @@ function createCodexDriver(options = {}) {
|
|
|
29167
29205
|
await started;
|
|
29168
29206
|
try {
|
|
29169
29207
|
const opening = (async () => {
|
|
29170
|
-
await handshake(session, resolved.log);
|
|
29208
|
+
await handshake(session, spec, resolved.log);
|
|
29171
29209
|
await preflight(session, spec);
|
|
29172
29210
|
return openThread(session, spec, resolved.log);
|
|
29173
29211
|
})();
|
|
@@ -30055,9 +30093,9 @@ var init_codex = __esm({
|
|
|
30055
30093
|
"../agent-core/dist/providers/codex.js"() {
|
|
30056
30094
|
"use strict";
|
|
30057
30095
|
init_chunk_DALFHI4B();
|
|
30058
|
-
|
|
30096
|
+
init_chunk_YPYC4VBL();
|
|
30059
30097
|
init_chunk_UGRKZTAD();
|
|
30060
|
-
|
|
30098
|
+
init_chunk_54ZRJOQP();
|
|
30061
30099
|
init_chunk_J2KTV5FP();
|
|
30062
30100
|
init_chunk_J4T6L5LX();
|
|
30063
30101
|
init_chunk_6WN2R725();
|
|
@@ -41325,9 +41363,9 @@ var require_tar_stream = __commonJS({
|
|
|
41325
41363
|
var init_dist = __esm({
|
|
41326
41364
|
"../agent-core/dist/index.js"() {
|
|
41327
41365
|
"use strict";
|
|
41328
|
-
|
|
41366
|
+
init_chunk_YPYC4VBL();
|
|
41329
41367
|
init_chunk_UGRKZTAD();
|
|
41330
|
-
|
|
41368
|
+
init_chunk_54ZRJOQP();
|
|
41331
41369
|
init_chunk_J4T6L5LX();
|
|
41332
41370
|
init_chunk_YXWJW7I5();
|
|
41333
41371
|
}
|
|
@@ -42072,9 +42110,9 @@ var import_promises48, import_path9, import_crypto12, import_promises49, CURSOR_
|
|
|
42072
42110
|
var init_acp3 = __esm({
|
|
42073
42111
|
"../agent-core/dist/providers/acp.js"() {
|
|
42074
42112
|
"use strict";
|
|
42075
|
-
|
|
42113
|
+
init_chunk_YPYC4VBL();
|
|
42076
42114
|
init_chunk_UGRKZTAD();
|
|
42077
|
-
|
|
42115
|
+
init_chunk_54ZRJOQP();
|
|
42078
42116
|
init_chunk_J2KTV5FP();
|
|
42079
42117
|
init_chunk_J4T6L5LX();
|
|
42080
42118
|
init_chunk_6WN2R725();
|
|
@@ -42889,7 +42927,7 @@ var init_acp3 = __esm({
|
|
|
42889
42927
|
var init_classify = __esm({
|
|
42890
42928
|
"../agent-core/dist/classify.js"() {
|
|
42891
42929
|
"use strict";
|
|
42892
|
-
|
|
42930
|
+
init_chunk_54ZRJOQP();
|
|
42893
42931
|
init_chunk_YXWJW7I5();
|
|
42894
42932
|
}
|
|
42895
42933
|
});
|
|
@@ -42919,38 +42957,31 @@ function toTurnResult(harness, outcome2, spec, providerSessionId, clock, apiKeyS
|
|
|
42919
42957
|
return { outcome: "aborted", ...session };
|
|
42920
42958
|
case "interrupted":
|
|
42921
42959
|
return { outcome: "interrupted", message: outcome2.reason, ...session };
|
|
42922
|
-
case "failed":
|
|
42923
|
-
|
|
42924
|
-
|
|
42925
|
-
|
|
42926
|
-
|
|
42927
|
-
|
|
42928
|
-
|
|
42929
|
-
|
|
42930
|
-
|
|
42931
|
-
|
|
42932
|
-
|
|
42933
|
-
|
|
42934
|
-
}),
|
|
42935
|
-
...session
|
|
42936
|
-
};
|
|
42960
|
+
case "failed": {
|
|
42961
|
+
const problem = createCliProblem(outcome2.error, {
|
|
42962
|
+
harness,
|
|
42963
|
+
phase: "stream",
|
|
42964
|
+
finality: "terminal",
|
|
42965
|
+
outcomeCertainty: "effect_unknown",
|
|
42966
|
+
occurredAt: new Date(clock.now()).toISOString(),
|
|
42967
|
+
scope: { runId: spec.runId, conversationId: spec.conversationId },
|
|
42968
|
+
apiKeySupplied
|
|
42969
|
+
});
|
|
42970
|
+
return { outcome: "failed", message: problem.detail, problem, ...session };
|
|
42971
|
+
}
|
|
42937
42972
|
}
|
|
42938
42973
|
}
|
|
42939
42974
|
function refusalResult(harness, refusal2, spec, clock, apiKeySupplied) {
|
|
42940
|
-
const
|
|
42941
|
-
|
|
42942
|
-
|
|
42943
|
-
|
|
42944
|
-
|
|
42945
|
-
|
|
42946
|
-
|
|
42947
|
-
|
|
42948
|
-
|
|
42949
|
-
|
|
42950
|
-
scope: { runId: spec.runId, conversationId: spec.conversationId },
|
|
42951
|
-
apiKeySupplied
|
|
42952
|
-
})
|
|
42953
|
-
};
|
|
42975
|
+
const problem = createCliProblem(refusal2.classified ?? specForErrorKind("not_authenticated"), {
|
|
42976
|
+
harness,
|
|
42977
|
+
phase: "preflight",
|
|
42978
|
+
finality: "terminal",
|
|
42979
|
+
outcomeCertainty: "no_effect",
|
|
42980
|
+
occurredAt: new Date(clock.now()).toISOString(),
|
|
42981
|
+
scope: { runId: spec.runId, conversationId: spec.conversationId },
|
|
42982
|
+
apiKeySupplied
|
|
42983
|
+
});
|
|
42984
|
+
return { outcome: "failed", message: problem.detail, problem };
|
|
42954
42985
|
}
|
|
42955
42986
|
function createPersistentDriver(provider4, options) {
|
|
42956
42987
|
const { log, clock } = options;
|
|
@@ -43783,9 +43814,9 @@ var import_http10, import_crypto13, import_promises50, import_path10, import_pat
|
|
|
43783
43814
|
var init_opencode = __esm({
|
|
43784
43815
|
"../agent-core/dist/providers/opencode.js"() {
|
|
43785
43816
|
"use strict";
|
|
43786
|
-
|
|
43817
|
+
init_chunk_YPYC4VBL();
|
|
43787
43818
|
init_chunk_UGRKZTAD();
|
|
43788
|
-
|
|
43819
|
+
init_chunk_54ZRJOQP();
|
|
43789
43820
|
init_chunk_J2KTV5FP();
|
|
43790
43821
|
init_chunk_J4T6L5LX();
|
|
43791
43822
|
init_chunk_6WN2R725();
|
|
@@ -45059,21 +45090,63 @@ var codex_exports = {};
|
|
|
45059
45090
|
__export(codex_exports, {
|
|
45060
45091
|
createCodexHolderDriver: () => createCodexHolderDriver
|
|
45061
45092
|
});
|
|
45093
|
+
function sha2563(value2) {
|
|
45094
|
+
return (0, import_node_crypto25.createHash)("sha256").update(value2).digest("hex");
|
|
45095
|
+
}
|
|
45096
|
+
function createCodexLogin(broker) {
|
|
45097
|
+
const state = {};
|
|
45098
|
+
return {
|
|
45099
|
+
forTurn: (runId, tokens2) => {
|
|
45100
|
+
state.runId = runId;
|
|
45101
|
+
state.latest = tokens2;
|
|
45102
|
+
},
|
|
45103
|
+
externalAuth: {
|
|
45104
|
+
current: async () => {
|
|
45105
|
+
if (state.latest === void 0) throw new Error("No Codex sign-in for this turn");
|
|
45106
|
+
state.given = state.latest;
|
|
45107
|
+
return state.given;
|
|
45108
|
+
},
|
|
45109
|
+
refresh: async () => {
|
|
45110
|
+
if (broker === void 0 || state.runId === void 0) {
|
|
45111
|
+
throw new Error("Codex sign-in cannot be refreshed on this machine");
|
|
45112
|
+
}
|
|
45113
|
+
const rejected2 = state.given === void 0 ? void 0 : sha2563(state.given.accessToken);
|
|
45114
|
+
const fresh = await broker.refresh(state.runId, rejected2);
|
|
45115
|
+
state.latest = fresh;
|
|
45116
|
+
state.given = fresh;
|
|
45117
|
+
return fresh;
|
|
45118
|
+
}
|
|
45119
|
+
}
|
|
45120
|
+
};
|
|
45121
|
+
}
|
|
45122
|
+
function withLogin(planned, externalAuth, accountId) {
|
|
45123
|
+
return {
|
|
45124
|
+
...planned,
|
|
45125
|
+
spec: { ...planned.spec, externalAuth },
|
|
45126
|
+
key: JSON.stringify([planned.key, accountId])
|
|
45127
|
+
};
|
|
45128
|
+
}
|
|
45062
45129
|
function createCodexHolderDriver(options) {
|
|
45063
45130
|
const clock = options.clock ?? systemClock2;
|
|
45064
45131
|
const sessions = options.sessions ?? createCodexDriver({ ...options.timings, clock, log: options.log });
|
|
45132
|
+
const login = createCodexLogin(options.codexCredentials);
|
|
45065
45133
|
return createPersistentDriver(
|
|
45066
45134
|
{
|
|
45067
45135
|
harness: "codex_app_server",
|
|
45068
45136
|
displayName: "Codex app-server",
|
|
45069
|
-
plan: (spec, inputs, resumeId, managedMcp) =>
|
|
45070
|
-
|
|
45071
|
-
|
|
45072
|
-
|
|
45073
|
-
|
|
45074
|
-
|
|
45075
|
-
|
|
45076
|
-
|
|
45137
|
+
plan: (spec, inputs, resumeId, managedMcp) => {
|
|
45138
|
+
const planned = planCodexSession(spec, {
|
|
45139
|
+
command: options.command ?? "codex",
|
|
45140
|
+
cwd: spec.projectPath ?? options.defaultCwd,
|
|
45141
|
+
cliEnv: options.cliEnvironment,
|
|
45142
|
+
providerEnv: inputs.providerEnv,
|
|
45143
|
+
...managedMcp === void 0 ? {} : { managedMcp },
|
|
45144
|
+
...resumeId === void 0 ? {} : { resumeThreadId: resumeId }
|
|
45145
|
+
});
|
|
45146
|
+
if (inputs.codex === void 0) return planned;
|
|
45147
|
+
login.forTurn(spec.runId, inputs.codex);
|
|
45148
|
+
return withLogin(planned, login.externalAuth, inputs.codex.chatgptAccountId);
|
|
45149
|
+
},
|
|
45077
45150
|
canResume: () => true,
|
|
45078
45151
|
open: async (spec) => {
|
|
45079
45152
|
const session = await sessions.open(spec);
|
|
@@ -45093,9 +45166,11 @@ function createCodexHolderDriver(options) {
|
|
|
45093
45166
|
}
|
|
45094
45167
|
);
|
|
45095
45168
|
}
|
|
45169
|
+
var import_node_crypto25;
|
|
45096
45170
|
var init_codex2 = __esm({
|
|
45097
45171
|
"src/holder/drivers/codex.ts"() {
|
|
45098
45172
|
"use strict";
|
|
45173
|
+
import_node_crypto25 = require("crypto");
|
|
45099
45174
|
init_dist();
|
|
45100
45175
|
init_codex();
|
|
45101
45176
|
init_persistent();
|
|
@@ -45547,9 +45622,9 @@ var import_crypto15, import_promises51, FACTORY_API_VERSION, FACTORY_PROTOCOL_VE
|
|
|
45547
45622
|
var init_droid = __esm({
|
|
45548
45623
|
"../agent-core/dist/providers/droid.js"() {
|
|
45549
45624
|
"use strict";
|
|
45550
|
-
|
|
45625
|
+
init_chunk_YPYC4VBL();
|
|
45551
45626
|
init_chunk_UGRKZTAD();
|
|
45552
|
-
|
|
45627
|
+
init_chunk_54ZRJOQP();
|
|
45553
45628
|
init_chunk_J2KTV5FP();
|
|
45554
45629
|
init_chunk_J4T6L5LX();
|
|
45555
45630
|
init_chunk_6WN2R725();
|
|
@@ -46020,6 +46095,35 @@ var init_opencode2 = __esm({
|
|
|
46020
46095
|
});
|
|
46021
46096
|
|
|
46022
46097
|
// ../agent-core/dist/providers/antigravity.js
|
|
46098
|
+
function settingsPath(env) {
|
|
46099
|
+
const home = env.HOME?.trim() || env.USERPROFILE?.trim();
|
|
46100
|
+
return home ? (0, import_path12.resolve)(home, ".gemini", "antigravity-cli", "settings.json") : void 0;
|
|
46101
|
+
}
|
|
46102
|
+
async function readSettings2(path4) {
|
|
46103
|
+
let raw;
|
|
46104
|
+
try {
|
|
46105
|
+
raw = (await (0, import_promises52.readFile)(path4, "utf8")).trim();
|
|
46106
|
+
} catch {
|
|
46107
|
+
return {};
|
|
46108
|
+
}
|
|
46109
|
+
if (!raw) return {};
|
|
46110
|
+
try {
|
|
46111
|
+
const parsed = JSON.parse(raw);
|
|
46112
|
+
return isRecord(parsed) ? parsed : "malformed";
|
|
46113
|
+
} catch {
|
|
46114
|
+
return "malformed";
|
|
46115
|
+
}
|
|
46116
|
+
}
|
|
46117
|
+
async function selectAntigravityApiKeyMode(env) {
|
|
46118
|
+
const path4 = settingsPath(env);
|
|
46119
|
+
if (!env.GEMINI_API_KEY?.trim() || path4 === void 0) return "no_key";
|
|
46120
|
+
const settings2 = await readSettings2(path4);
|
|
46121
|
+
if (settings2 === "malformed") return "malformed";
|
|
46122
|
+
if (settings2.modelProvider === "gemini") return "already_selected";
|
|
46123
|
+
await (0, import_promises52.mkdir)((0, import_path12.dirname)(path4), { recursive: true });
|
|
46124
|
+
await (0, import_promises52.writeFile)(path4, JSON.stringify({ ...settings2, modelProvider: "gemini" }), { mode: 384 });
|
|
46125
|
+
return "selected";
|
|
46126
|
+
}
|
|
46023
46127
|
function readAntigravityCapabilities(version2, help) {
|
|
46024
46128
|
const text2 = help.toLowerCase().replace(/\s+/g, " ");
|
|
46025
46129
|
const structured = /\bstream-json\b/.test(text2) || /\bjsonl\b/.test(text2) || /\bjson\b/.test(text2);
|
|
@@ -46060,21 +46164,21 @@ function antigravityArgs(input2, capabilities, prompt) {
|
|
|
46060
46164
|
];
|
|
46061
46165
|
}
|
|
46062
46166
|
function workspaceRoot(cwd) {
|
|
46063
|
-
for (let current = (0,
|
|
46064
|
-
if ((0, import_fs8.existsSync)((0,
|
|
46065
|
-
if ((0,
|
|
46167
|
+
for (let current = (0, import_path13.resolve)(cwd); ; current = (0, import_path13.dirname)(current)) {
|
|
46168
|
+
if ((0, import_fs8.existsSync)((0, import_path13.join)(current, ".git"))) return current;
|
|
46169
|
+
if ((0, import_path13.dirname)(current) === current) return (0, import_path13.resolve)(cwd);
|
|
46066
46170
|
}
|
|
46067
46171
|
}
|
|
46068
46172
|
function instructionPaths(cwd) {
|
|
46069
46173
|
const root = workspaceRoot(cwd);
|
|
46070
46174
|
const paths = [];
|
|
46071
|
-
for (let current = (0,
|
|
46072
|
-
const path4 = (0,
|
|
46175
|
+
for (let current = (0, import_path13.resolve)(cwd); ; current = (0, import_path13.dirname)(current)) {
|
|
46176
|
+
const path4 = (0, import_path13.join)(current, INSTRUCTIONS_FILE);
|
|
46073
46177
|
try {
|
|
46074
46178
|
if ((0, import_fs8.existsSync)(path4) && (0, import_fs8.statSync)(path4).isFile()) paths.unshift(path4);
|
|
46075
46179
|
} catch {
|
|
46076
46180
|
}
|
|
46077
|
-
if (current === root || (0,
|
|
46181
|
+
if (current === root || (0, import_path13.dirname)(current) === current) return paths;
|
|
46078
46182
|
}
|
|
46079
46183
|
}
|
|
46080
46184
|
function antigravityWorkspaceInstructions(cwd, maxChars = MAX_INSTRUCTION_CHARS) {
|
|
@@ -46328,7 +46432,7 @@ function normalizeAntigravityFrame(event) {
|
|
|
46328
46432
|
}
|
|
46329
46433
|
function antigravityBrainRoot(env) {
|
|
46330
46434
|
const home = env.HOME?.trim() || env.USERPROFILE?.trim();
|
|
46331
|
-
return home ? (0,
|
|
46435
|
+
return home ? (0, import_path14.resolve)(home, ".gemini", "antigravity-cli", "brain") : void 0;
|
|
46332
46436
|
}
|
|
46333
46437
|
function parseEntry(text2) {
|
|
46334
46438
|
try {
|
|
@@ -46366,14 +46470,14 @@ function childTranscriptPath(root, frame) {
|
|
|
46366
46470
|
try {
|
|
46367
46471
|
const url3 = new URL(logUri);
|
|
46368
46472
|
if (url3.protocol !== "file:") return void 0;
|
|
46369
|
-
path4 = (0,
|
|
46473
|
+
path4 = (0, import_path14.resolve)((0, import_url3.fileURLToPath)(url3));
|
|
46370
46474
|
} catch {
|
|
46371
46475
|
return void 0;
|
|
46372
46476
|
}
|
|
46373
|
-
const fromRoot = (0,
|
|
46374
|
-
if (!fromRoot || (0,
|
|
46477
|
+
const fromRoot = (0, import_path14.relative)(root, path4);
|
|
46478
|
+
if (!fromRoot || (0, import_path14.isAbsolute)(fromRoot) || fromRoot.split(import_path14.sep).includes("..")) return void 0;
|
|
46375
46479
|
const expected = [conversationId, ...LOG_DIRS, TRANSCRIPT_FILE];
|
|
46376
|
-
const segments = fromRoot.split(
|
|
46480
|
+
const segments = fromRoot.split(import_path14.sep);
|
|
46377
46481
|
const matches = segments.length === expected.length && segments.every((segment, index) => segment === expected[index]);
|
|
46378
46482
|
return matches ? path4 : void 0;
|
|
46379
46483
|
}
|
|
@@ -46551,11 +46655,15 @@ ${output2.stderr}`).join("\n")
|
|
|
46551
46655
|
name: "antigravity_cli",
|
|
46552
46656
|
capabilities,
|
|
46553
46657
|
open: async (spec) => {
|
|
46554
|
-
const found = await
|
|
46658
|
+
const [found, apiKeyMode] = await Promise.all([
|
|
46659
|
+
capabilities(spec.command, spec.env),
|
|
46660
|
+
selectAntigravityApiKeyMode(spec.env).catch(() => "unwritable")
|
|
46661
|
+
]);
|
|
46555
46662
|
session.log.info("antigravity.opened", {
|
|
46556
46663
|
version: found.version,
|
|
46557
46664
|
structured: found.structuredPrint,
|
|
46558
|
-
resumeId: spec.resumeSessionId
|
|
46665
|
+
resumeId: spec.resumeSessionId,
|
|
46666
|
+
apiKeyMode
|
|
46559
46667
|
});
|
|
46560
46668
|
return new AntigravitySession(
|
|
46561
46669
|
provider2(spec, found, options.platform ?? process.platform),
|
|
@@ -46612,21 +46720,24 @@ function antigravityTurnInput(run2, context) {
|
|
|
46612
46720
|
});
|
|
46613
46721
|
return { turnId: run2.runId, text: appendImagePathReferences(text2, images) };
|
|
46614
46722
|
}
|
|
46615
|
-
var
|
|
46723
|
+
var import_promises52, import_path12, import_fs8, import_path13, import_path14, import_url3, import_crypto16, NO_ANTIGRAVITY_CAPABILITIES, INSTRUCTIONS_FILE, MAX_INSTRUCTION_CHARS, SHORTENED_NOTE, DIFF_BLOCK_START, DIFF_BLOCK_END, HUNK_HEADER, TRANSCRIPT_FILE, FULL_TRANSCRIPT_FILE, LOG_DIRS, TOOL_RESULT_TYPES, BrainTranscript, AntigravityTranscripts, ANTIGRAVITY_GRAMMAR_NAME, AntigravityGrammar, ignored, HANDLERS, SUCCESSFUL_STATUSES, SESSION_START_TYPES, RESULT_TYPES, SUBAGENT_START_TYPES, RESUME_FORKED, EXITED_WITHOUT_RESULT, AntigravityTurn, DEFAULTS6, AntigravitySession, WINDOWS_LINE_MARGIN;
|
|
46616
46724
|
var init_antigravity = __esm({
|
|
46617
46725
|
"../agent-core/dist/providers/antigravity.js"() {
|
|
46618
46726
|
"use strict";
|
|
46619
46727
|
init_chunk_DALFHI4B();
|
|
46620
|
-
|
|
46728
|
+
init_chunk_YPYC4VBL();
|
|
46621
46729
|
init_chunk_UGRKZTAD();
|
|
46622
|
-
|
|
46730
|
+
init_chunk_54ZRJOQP();
|
|
46623
46731
|
init_chunk_J4T6L5LX();
|
|
46624
46732
|
init_chunk_6WN2R725();
|
|
46625
46733
|
init_chunk_YXWJW7I5();
|
|
46626
|
-
|
|
46734
|
+
import_promises52 = require("fs/promises");
|
|
46627
46735
|
import_path12 = require("path");
|
|
46628
|
-
|
|
46736
|
+
init_type_guards();
|
|
46737
|
+
import_fs8 = require("fs");
|
|
46629
46738
|
import_path13 = require("path");
|
|
46739
|
+
init_effort();
|
|
46740
|
+
import_path14 = require("path");
|
|
46630
46741
|
import_url3 = require("url");
|
|
46631
46742
|
import_crypto16 = require("crypto");
|
|
46632
46743
|
init_agent2();
|
|
@@ -46666,7 +46777,7 @@ var init_antigravity = __esm({
|
|
|
46666
46777
|
#full;
|
|
46667
46778
|
constructor(path4) {
|
|
46668
46779
|
this.#cursor = new TranscriptCursor(path4);
|
|
46669
|
-
this.#fullPath = (0,
|
|
46780
|
+
this.#fullPath = (0, import_path14.resolve)((0, import_path14.dirname)(path4), FULL_TRANSCRIPT_FILE);
|
|
46670
46781
|
}
|
|
46671
46782
|
skipExisting() {
|
|
46672
46783
|
this.#cursor.read();
|
|
@@ -46714,7 +46825,7 @@ var init_antigravity = __esm({
|
|
|
46714
46825
|
/** A conversation this turn did not resume was created by it, so it is read whole. */
|
|
46715
46826
|
trackParent(conversationId) {
|
|
46716
46827
|
if (this.#parent?.conversationId === conversationId) return;
|
|
46717
|
-
const path4 = (0,
|
|
46828
|
+
const path4 = (0, import_path14.resolve)(this.#root, conversationId, ...LOG_DIRS, TRANSCRIPT_FILE);
|
|
46718
46829
|
this.#parent = { conversationId, transcript: new BrainTranscript(path4) };
|
|
46719
46830
|
}
|
|
46720
46831
|
/** A launcher keeps the first valid transcript it names; later frames change nothing. */
|
|
@@ -47119,8 +47230,8 @@ function parseConfig(raw) {
|
|
|
47119
47230
|
}
|
|
47120
47231
|
}
|
|
47121
47232
|
async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
47122
|
-
const path4 = (0,
|
|
47123
|
-
const original = await (0,
|
|
47233
|
+
const path4 = (0, import_path15.join)(cwd, ".mcp.json");
|
|
47234
|
+
const original = await (0, import_promises53.readFile)(path4, "utf8").catch(() => null);
|
|
47124
47235
|
const config2 = parseConfig(original);
|
|
47125
47236
|
const next = {
|
|
47126
47237
|
...config2,
|
|
@@ -47137,12 +47248,12 @@ async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
|
47137
47248
|
}
|
|
47138
47249
|
}
|
|
47139
47250
|
};
|
|
47140
|
-
await (0,
|
|
47141
|
-
await (0,
|
|
47251
|
+
await (0, import_promises53.mkdir)(cwd, { recursive: true });
|
|
47252
|
+
await (0, import_promises53.writeFile)(path4, `${JSON.stringify(next, null, 2)}
|
|
47142
47253
|
`);
|
|
47143
47254
|
return async () => {
|
|
47144
|
-
if (original === null) await (0,
|
|
47145
|
-
else await (0,
|
|
47255
|
+
if (original === null) await (0, import_promises53.rm)(path4, { force: true });
|
|
47256
|
+
else await (0, import_promises53.writeFile)(path4, original);
|
|
47146
47257
|
};
|
|
47147
47258
|
}
|
|
47148
47259
|
function commandCodeString(value2) {
|
|
@@ -47314,19 +47425,19 @@ function commandCodeTurnInput(run2, context) {
|
|
|
47314
47425
|
});
|
|
47315
47426
|
return { turnId: run2.runId, text: appendImagePathReferences(text2, images) };
|
|
47316
47427
|
}
|
|
47317
|
-
var
|
|
47428
|
+
var import_promises53, import_path15, import_crypto17, COMMAND_CODE_GRAMMAR_NAME, SILENT3, CommandCodeGrammar, SHELL_TOOL, STOP_TOOLS, REPORTED_STATUS, SHELL_STATUS, SWEEP_INTERVAL_MS, CommandCodeBackgroundTasks, EXITED_WITHOUT_RESULT2, CommandCodeTurn, COMMAND_CODE_MAX_TURNS, DEFAULTS7, CommandCodeSession;
|
|
47318
47429
|
var init_command_code = __esm({
|
|
47319
47430
|
"../agent-core/dist/providers/command-code.js"() {
|
|
47320
47431
|
"use strict";
|
|
47321
|
-
|
|
47432
|
+
init_chunk_YPYC4VBL();
|
|
47322
47433
|
init_chunk_UGRKZTAD();
|
|
47323
|
-
|
|
47434
|
+
init_chunk_54ZRJOQP();
|
|
47324
47435
|
init_chunk_J2KTV5FP();
|
|
47325
47436
|
init_chunk_J4T6L5LX();
|
|
47326
47437
|
init_chunk_6WN2R725();
|
|
47327
47438
|
init_chunk_YXWJW7I5();
|
|
47328
|
-
|
|
47329
|
-
|
|
47439
|
+
import_promises53 = require("fs/promises");
|
|
47440
|
+
import_path15 = require("path");
|
|
47330
47441
|
init_agent2();
|
|
47331
47442
|
init_runtime_v2();
|
|
47332
47443
|
init_acp();
|
|
@@ -51312,7 +51423,7 @@ var require_websocket = __commonJS({
|
|
|
51312
51423
|
var http = require("http");
|
|
51313
51424
|
var net = require("net");
|
|
51314
51425
|
var tls = require("tls");
|
|
51315
|
-
var { randomBytes: randomBytes6, createHash:
|
|
51426
|
+
var { randomBytes: randomBytes6, createHash: createHash31 } = require("crypto");
|
|
51316
51427
|
var { Duplex, Readable: Readable2 } = require("stream");
|
|
51317
51428
|
var { URL: URL2 } = require("url");
|
|
51318
51429
|
var PerMessageDeflate = require_permessage_deflate();
|
|
@@ -51969,7 +52080,7 @@ var require_websocket = __commonJS({
|
|
|
51969
52080
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
51970
52081
|
return;
|
|
51971
52082
|
}
|
|
51972
|
-
const digest =
|
|
52083
|
+
const digest = createHash31("sha1").update(key + GUID).digest("base64");
|
|
51973
52084
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
51974
52085
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
51975
52086
|
return;
|
|
@@ -52336,7 +52447,7 @@ var require_websocket_server = __commonJS({
|
|
|
52336
52447
|
var EventEmitter = require("events");
|
|
52337
52448
|
var http = require("http");
|
|
52338
52449
|
var { Duplex } = require("stream");
|
|
52339
|
-
var { createHash:
|
|
52450
|
+
var { createHash: createHash31 } = require("crypto");
|
|
52340
52451
|
var extension = require_extension();
|
|
52341
52452
|
var PerMessageDeflate = require_permessage_deflate();
|
|
52342
52453
|
var subprotocol = require_subprotocol();
|
|
@@ -52633,7 +52744,7 @@ var require_websocket_server = __commonJS({
|
|
|
52633
52744
|
);
|
|
52634
52745
|
}
|
|
52635
52746
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
52636
|
-
const digest =
|
|
52747
|
+
const digest = createHash31("sha1").update(key + GUID).digest("base64");
|
|
52637
52748
|
const headers = [
|
|
52638
52749
|
"HTTP/1.1 101 Switching Protocols",
|
|
52639
52750
|
"Upgrade: websocket",
|
|
@@ -52721,7 +52832,7 @@ var require_websocket_server = __commonJS({
|
|
|
52721
52832
|
// package.json
|
|
52722
52833
|
var package_default = {
|
|
52723
52834
|
name: "@alan-ai-hq/agent-manager",
|
|
52724
|
-
version: "0.1.
|
|
52835
|
+
version: "0.1.136",
|
|
52725
52836
|
private: true,
|
|
52726
52837
|
type: "module",
|
|
52727
52838
|
description: "Alan machine runtime (alan-agent): identity, link, reconciler, session holders, run log, uploader, local API",
|
|
@@ -52770,8 +52881,8 @@ var package_default = {
|
|
|
52770
52881
|
};
|
|
52771
52882
|
|
|
52772
52883
|
// src/cli/commands/compat.ts
|
|
52773
|
-
var
|
|
52774
|
-
var
|
|
52884
|
+
var import_node_crypto30 = require("crypto");
|
|
52885
|
+
var import_promises64 = require("fs/promises");
|
|
52775
52886
|
init_runtime_v2();
|
|
52776
52887
|
init_zod();
|
|
52777
52888
|
|
|
@@ -53577,6 +53688,13 @@ function createHolderApiClient({
|
|
|
53577
53688
|
}
|
|
53578
53689
|
return runProviderCredentialSchema.parse(jsonBody(response));
|
|
53579
53690
|
},
|
|
53691
|
+
refreshCodexCredential: async (runId, body, signal) => {
|
|
53692
|
+
const response = await request2("POST", runCodexCredentialRefreshPath(runId), signal, body);
|
|
53693
|
+
if (!isOk(response)) {
|
|
53694
|
+
throw new RuntimeFault("io_failed", `Codex sign-in refresh failed: ${response.status}`);
|
|
53695
|
+
}
|
|
53696
|
+
return runCodexCredentialSchema.parse(jsonBody(response));
|
|
53697
|
+
},
|
|
53580
53698
|
mintMcpCredential: async (conversationId, signal) => {
|
|
53581
53699
|
const response = await request2("POST", MACHINE_PATHS.mcpCredential, signal, {
|
|
53582
53700
|
conversationId
|
|
@@ -63093,16 +63211,33 @@ async function scanLocalSkills(home, context, cache2, mode = "incremental") {
|
|
|
63093
63211
|
// src/capabilities/skills/store.ts
|
|
63094
63212
|
var import_promises40 = require("fs/promises");
|
|
63095
63213
|
var import_node_path42 = require("path");
|
|
63214
|
+
|
|
63215
|
+
// ../shared/dist/node/alan-skill-identity.js
|
|
63216
|
+
var import_node_crypto20 = require("crypto");
|
|
63217
|
+
var ALAN_SKILL_NAMESPACE = "ec71d99b-d207-4ca2-a9eb-3a7bed4a73fd";
|
|
63218
|
+
function uuidV5(name, namespace) {
|
|
63219
|
+
const bytes = (0, import_node_crypto20.createHash)("sha1").update(Buffer.from(namespace.replaceAll("-", ""), "hex")).update(name, "utf8").digest().subarray(0, 16);
|
|
63220
|
+
bytes[6] = bytes[6] & 15 | 80;
|
|
63221
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
63222
|
+
const hex3 = bytes.toString("hex");
|
|
63223
|
+
return `${hex3.slice(0, 8)}-${hex3.slice(8, 12)}-${hex3.slice(12, 16)}-${hex3.slice(16, 20)}-${hex3.slice(20)}`;
|
|
63224
|
+
}
|
|
63225
|
+
function alanSkillId(slug) {
|
|
63226
|
+
return uuidV5(`alan:${slug}`, ALAN_SKILL_NAMESPACE);
|
|
63227
|
+
}
|
|
63228
|
+
|
|
63229
|
+
// src/capabilities/skills/store.ts
|
|
63096
63230
|
init_runtime_v2();
|
|
63097
63231
|
init_zod();
|
|
63098
|
-
function skillsLayout(stateDir) {
|
|
63232
|
+
function skillsLayout(stateDir, home) {
|
|
63099
63233
|
const root = (0, import_node_path42.join)(stateDir, "skills");
|
|
63100
63234
|
return {
|
|
63101
63235
|
root,
|
|
63102
63236
|
installedFile: (0, import_node_path42.join)(root, "installed.json"),
|
|
63103
63237
|
localFile: (0, import_node_path42.join)(root, "local.json"),
|
|
63104
63238
|
versionsDir: (0, import_node_path42.join)(root, "versions"),
|
|
63105
|
-
tmpDir: (0, import_node_path42.join)(root, "tmp")
|
|
63239
|
+
tmpDir: (0, import_node_path42.join)(root, "tmp"),
|
|
63240
|
+
nativeDir: home === void 0 || home === "" ? null : (0, import_node_path42.join)(home, ".agents", "skills")
|
|
63106
63241
|
};
|
|
63107
63242
|
}
|
|
63108
63243
|
function packageDirectory(layout, versionId) {
|
|
@@ -63169,6 +63304,17 @@ async function isIntact(layout, skill) {
|
|
|
63169
63304
|
return false;
|
|
63170
63305
|
}
|
|
63171
63306
|
}
|
|
63307
|
+
async function resolveNativeBuiltIn(layout, invocation) {
|
|
63308
|
+
const slug = invocation.displayName;
|
|
63309
|
+
if (layout.nativeDir === null || invocation.skillId !== alanSkillId(slug)) return null;
|
|
63310
|
+
const directory = (0, import_node_path42.join)(layout.nativeDir, slug);
|
|
63311
|
+
try {
|
|
63312
|
+
await inspectSkillPackage(directory, { expectedName: slug });
|
|
63313
|
+
return { packageDirectory: directory };
|
|
63314
|
+
} catch {
|
|
63315
|
+
return null;
|
|
63316
|
+
}
|
|
63317
|
+
}
|
|
63172
63318
|
async function resolveSkillInvocations(layout, invocations) {
|
|
63173
63319
|
if (invocations.length === 0) return { kind: "resolved", skills: [] };
|
|
63174
63320
|
const installed = await readInstalledSkills(layout);
|
|
@@ -63187,9 +63333,11 @@ async function resolveSkillInvocations(layout, invocations) {
|
|
|
63187
63333
|
);
|
|
63188
63334
|
if (skill !== void 0 && await isIntact(layout, skill)) {
|
|
63189
63335
|
resolved.push({ packageDirectory: packageDirectory(layout, skill.versionId) });
|
|
63190
|
-
|
|
63191
|
-
missing.push(invocation.displayName);
|
|
63336
|
+
continue;
|
|
63192
63337
|
}
|
|
63338
|
+
const native = await resolveNativeBuiltIn(layout, invocation);
|
|
63339
|
+
if (native === null) missing.push(invocation.displayName);
|
|
63340
|
+
else resolved.push(native);
|
|
63193
63341
|
}
|
|
63194
63342
|
return missing.length === 0 ? { kind: "resolved", skills: resolved } : { kind: "missing", names: missing };
|
|
63195
63343
|
}
|
|
@@ -63303,7 +63451,7 @@ var import_promises43 = require("fs/promises");
|
|
|
63303
63451
|
|
|
63304
63452
|
// ../shared/dist/node/skill-bundle.js
|
|
63305
63453
|
var import_node_buffer2 = require("buffer");
|
|
63306
|
-
var
|
|
63454
|
+
var import_node_crypto21 = require("crypto");
|
|
63307
63455
|
var import_promises42 = require("fs/promises");
|
|
63308
63456
|
var import_node_path44 = require("path");
|
|
63309
63457
|
var import_node_stream = require("stream");
|
|
@@ -63442,7 +63590,7 @@ function requireSafeArchivePath(value2) {
|
|
|
63442
63590
|
return normalized2;
|
|
63443
63591
|
}
|
|
63444
63592
|
function sha2562(bytes) {
|
|
63445
|
-
return `sha256:${(0,
|
|
63593
|
+
return `sha256:${(0, import_node_crypto21.createHash)("sha256").update(bytes).digest("hex")}`;
|
|
63446
63594
|
}
|
|
63447
63595
|
|
|
63448
63596
|
// src/capabilities/skills/local-upload.ts
|
|
@@ -63486,14 +63634,14 @@ async function publishLocalSkill(options) {
|
|
|
63486
63634
|
}
|
|
63487
63635
|
|
|
63488
63636
|
// src/capabilities/skills/sync.ts
|
|
63489
|
-
var
|
|
63637
|
+
var import_node_crypto22 = require("crypto");
|
|
63490
63638
|
var import_promises44 = require("fs/promises");
|
|
63491
63639
|
var import_node_path45 = require("path");
|
|
63492
63640
|
var SKILL_PREPARE_WAIT_MS = 15e3;
|
|
63493
63641
|
async function install(layout, source, skill, download, signal) {
|
|
63494
63642
|
const bytes = await source.download(download.url, signal);
|
|
63495
63643
|
await (0, import_promises44.mkdir)(layout.tmpDir, { recursive: true, mode: 448 });
|
|
63496
|
-
const staging = (0, import_node_path45.join)(layout.tmpDir, (0,
|
|
63644
|
+
const staging = (0, import_node_path45.join)(layout.tmpDir, (0, import_node_crypto22.randomUUID)());
|
|
63497
63645
|
await extractSkillBundle(Buffer.from(bytes), staging, {
|
|
63498
63646
|
expectedArchiveHash: download.archiveHash,
|
|
63499
63647
|
expectedContentHash: skill.contentHash
|
|
@@ -63533,11 +63681,28 @@ async function mapBounded(items, limit, work) {
|
|
|
63533
63681
|
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
63534
63682
|
return results;
|
|
63535
63683
|
}
|
|
63536
|
-
|
|
63684
|
+
function installedRecorder(layout, present2, onRecorded) {
|
|
63685
|
+
const ready = new Map(
|
|
63686
|
+
present2.map((skill) => [skill.skillId, skill])
|
|
63687
|
+
);
|
|
63688
|
+
let chain = Promise.resolve();
|
|
63689
|
+
return {
|
|
63690
|
+
record: (skill) => {
|
|
63691
|
+
ready.set(skill.skillId, skill);
|
|
63692
|
+
const snapshot2 = [...ready.values()];
|
|
63693
|
+
const write = chain.then(() => writeInstalledSkills(layout, snapshot2)).then(onRecorded);
|
|
63694
|
+
chain = write.catch(() => void 0);
|
|
63695
|
+
return write;
|
|
63696
|
+
},
|
|
63697
|
+
settled: () => chain
|
|
63698
|
+
};
|
|
63699
|
+
}
|
|
63700
|
+
async function applyDesired(layout, source, log, present2, response, onRecorded, signal) {
|
|
63537
63701
|
const held = new Map(present2.map((skill) => [skill.skillId, skill]));
|
|
63538
63702
|
const downloads = new Map(
|
|
63539
63703
|
response.downloads.map((download) => [download.skillId, download])
|
|
63540
63704
|
);
|
|
63705
|
+
const recorder = installedRecorder(layout, present2, onRecorded);
|
|
63541
63706
|
const installOne = async (skill) => {
|
|
63542
63707
|
const download = downloads.get(skill.skillId);
|
|
63543
63708
|
if (download === void 0) {
|
|
@@ -63547,6 +63712,7 @@ async function applyDesired(layout, source, log, present2, response, signal) {
|
|
|
63547
63712
|
}
|
|
63548
63713
|
try {
|
|
63549
63714
|
await install(layout, source, skill, download, signal);
|
|
63715
|
+
await recorder.record(skill);
|
|
63550
63716
|
return "downloaded";
|
|
63551
63717
|
} catch (error61) {
|
|
63552
63718
|
log.warn("skills.install_failed", { skillId: skill.skillId, slug: skill.slug, error: error61 });
|
|
@@ -63557,6 +63723,7 @@ async function applyDesired(layout, source, log, present2, response, signal) {
|
|
|
63557
63723
|
const installed = response.skills.filter((_, index) => outcomes[index] !== "failed");
|
|
63558
63724
|
const failed = response.skills.filter((_, index) => outcomes[index] === "failed").map((skill) => skill.slug);
|
|
63559
63725
|
const downloaded = outcomes.filter((outcome2) => outcome2 === "downloaded").length;
|
|
63726
|
+
await recorder.settled();
|
|
63560
63727
|
await writeInstalledSkills(layout, installed);
|
|
63561
63728
|
const removed = await sweep(layout, installed);
|
|
63562
63729
|
return { installed: installed.length, downloaded, removed, failed };
|
|
@@ -63647,14 +63814,14 @@ async function settleLocal(layout, source, log, local, exchange3, response, sign
|
|
|
63647
63814
|
const uploads = await uploadRequested(layout, source, log, local, response.uploads ?? [], signal);
|
|
63648
63815
|
return serverLost || uploads > 0;
|
|
63649
63816
|
}
|
|
63650
|
-
async function syncOnce(layout, source, log, local, signal) {
|
|
63817
|
+
async function syncOnce(layout, source, log, local, onRecorded, signal) {
|
|
63651
63818
|
let report2 = { installed: 0, downloaded: 0, removed: 0, failed: [] };
|
|
63652
63819
|
if (local !== null) await loadContext(layout, local);
|
|
63653
63820
|
for (let exchange3 = 0; exchange3 < MAX_EXCHANGES; exchange3 += 1) {
|
|
63654
63821
|
const present2 = await intactSkills(layout);
|
|
63655
63822
|
const pending = local === null ? null : localExchange(local);
|
|
63656
63823
|
const response = await source.sync(syncRequest(present2, pending), signal);
|
|
63657
|
-
report2 = await applyDesired(layout, source, log, present2, response, signal);
|
|
63824
|
+
report2 = await applyDesired(layout, source, log, present2, response, onRecorded, signal);
|
|
63658
63825
|
if (local === null || pending === null) return report2;
|
|
63659
63826
|
const again = await settleLocal(layout, source, log, local, pending, response, signal);
|
|
63660
63827
|
if (!again) return report2;
|
|
@@ -63668,7 +63835,7 @@ function aborted2(signal) {
|
|
|
63668
63835
|
});
|
|
63669
63836
|
}
|
|
63670
63837
|
function openMachineSkills(options) {
|
|
63671
|
-
const layout = skillsLayout(options.stateDir);
|
|
63838
|
+
const layout = skillsLayout(options.stateDir, options.local?.home);
|
|
63672
63839
|
const { source, log } = options;
|
|
63673
63840
|
const local = options.local === void 0 ? null : {
|
|
63674
63841
|
options: options.local,
|
|
@@ -63684,6 +63851,10 @@ function openMachineSkills(options) {
|
|
|
63684
63851
|
const waitMs = options.waitMs ?? SKILL_PREPARE_WAIT_MS;
|
|
63685
63852
|
const lifetime = new AbortController();
|
|
63686
63853
|
const flight = {};
|
|
63854
|
+
const recordWatchers = /* @__PURE__ */ new Set();
|
|
63855
|
+
const recorded = () => {
|
|
63856
|
+
for (const watcher of recordWatchers) watcher();
|
|
63857
|
+
};
|
|
63687
63858
|
const rescans = /* @__PURE__ */ new Set();
|
|
63688
63859
|
const rescanOnce = async (state) => {
|
|
63689
63860
|
try {
|
|
@@ -63700,7 +63871,7 @@ function openMachineSkills(options) {
|
|
|
63700
63871
|
return task;
|
|
63701
63872
|
};
|
|
63702
63873
|
const run2 = () => {
|
|
63703
|
-
const running = syncOnce(layout, source, log, local, lifetime.signal).then((report2) => {
|
|
63874
|
+
const running = syncOnce(layout, source, log, local, recorded, lifetime.signal).then((report2) => {
|
|
63704
63875
|
log.info("skills.synced", { ...report2 });
|
|
63705
63876
|
return report2;
|
|
63706
63877
|
}).catch((error61) => {
|
|
@@ -63741,6 +63912,25 @@ function openMachineSkills(options) {
|
|
|
63741
63912
|
if ((await resolveSkillInvocations(layout, named)).kind === "resolved") return;
|
|
63742
63913
|
}
|
|
63743
63914
|
};
|
|
63915
|
+
const recordedUntilResolved = (named, until) => new Promise((resolve12) => {
|
|
63916
|
+
const done = () => {
|
|
63917
|
+
recordWatchers.delete(check3);
|
|
63918
|
+
until.removeEventListener("abort", done);
|
|
63919
|
+
resolve12();
|
|
63920
|
+
};
|
|
63921
|
+
const check3 = () => {
|
|
63922
|
+
void resolveSkillInvocations(layout, named).then((resolution) => {
|
|
63923
|
+
if (resolution.kind === "resolved") done();
|
|
63924
|
+
});
|
|
63925
|
+
};
|
|
63926
|
+
if (until.aborted) {
|
|
63927
|
+
resolve12();
|
|
63928
|
+
return;
|
|
63929
|
+
}
|
|
63930
|
+
recordWatchers.add(check3);
|
|
63931
|
+
until.addEventListener("abort", done, { once: true });
|
|
63932
|
+
check3();
|
|
63933
|
+
});
|
|
63744
63934
|
return {
|
|
63745
63935
|
sync,
|
|
63746
63936
|
rescan,
|
|
@@ -63748,8 +63938,11 @@ function openMachineSkills(options) {
|
|
|
63748
63938
|
const named = invocations ?? [];
|
|
63749
63939
|
if ((await resolveSkillInvocations(layout, named)).kind === "resolved") return;
|
|
63750
63940
|
const picksLocal = named.some((invocation) => invocation.kind === "local_skill");
|
|
63941
|
+
const settled2 = new AbortController();
|
|
63942
|
+
const until = AbortSignal.any([signal, AbortSignal.timeout(waitMs), settled2.signal]);
|
|
63751
63943
|
const settle = picksLocal ? rescanUntilResolved(named) : exchangeUntilResolved(named);
|
|
63752
|
-
await Promise.race([settle,
|
|
63944
|
+
await Promise.race([settle, recordedUntilResolved(named, until), aborted2(until)]);
|
|
63945
|
+
settled2.abort();
|
|
63753
63946
|
},
|
|
63754
63947
|
[Symbol.asyncDispose]: async () => {
|
|
63755
63948
|
lifetime.abort();
|
|
@@ -63861,7 +64054,7 @@ async function openApprovedPaths(options) {
|
|
|
63861
64054
|
}
|
|
63862
64055
|
|
|
63863
64056
|
// src/capabilities/workspace/locks.ts
|
|
63864
|
-
var
|
|
64057
|
+
var import_node_crypto23 = require("crypto");
|
|
63865
64058
|
var import_promises46 = require("fs/promises");
|
|
63866
64059
|
var import_node_path47 = require("path");
|
|
63867
64060
|
init_zod();
|
|
@@ -63878,7 +64071,7 @@ var ownerSchema = external_exports.object({
|
|
|
63878
64071
|
since: external_exports.number().int().nonnegative()
|
|
63879
64072
|
});
|
|
63880
64073
|
function repositoryLockKey(commonDir, platform3) {
|
|
63881
|
-
return (0,
|
|
64074
|
+
return (0, import_node_crypto23.createHash)("sha256").update(comparablePath(commonDir, platform3)).digest("hex").slice(0, 32);
|
|
63882
64075
|
}
|
|
63883
64076
|
async function readOwner2(path4) {
|
|
63884
64077
|
let text2;
|
|
@@ -63991,7 +64184,7 @@ function openRepositoryLocks(options) {
|
|
|
63991
64184
|
},
|
|
63992
64185
|
tryShared: async (commonDir, runId) => {
|
|
63993
64186
|
const { key, dir } = await folder(commonDir);
|
|
63994
|
-
const file2 = `${RUN_FILE_PREFIX}${(0,
|
|
64187
|
+
const file2 = `${RUN_FILE_PREFIX}${(0, import_node_crypto23.createHash)("sha256").update(runId).digest("hex").slice(0, 32)}.json`;
|
|
63995
64188
|
const path4 = (0, import_node_path47.join)(dir, file2);
|
|
63996
64189
|
const owner = await self(runId);
|
|
63997
64190
|
await writeJsonFileAtomic(path4, owner);
|
|
@@ -64898,14 +65091,14 @@ async function sendNativeHookSignal(discoveryPath, hookSignal, signal) {
|
|
|
64898
65091
|
}
|
|
64899
65092
|
|
|
64900
65093
|
// src/sessions/index.ts
|
|
64901
|
-
var
|
|
64902
|
-
var
|
|
65094
|
+
var import_node_crypto29 = require("crypto");
|
|
65095
|
+
var import_promises62 = require("fs/promises");
|
|
64903
65096
|
var import_node_os10 = require("os");
|
|
64904
65097
|
var import_node_path63 = require("path");
|
|
64905
65098
|
init_runtime_v2();
|
|
64906
65099
|
|
|
64907
65100
|
// src/holder/control-client.ts
|
|
64908
|
-
var
|
|
65101
|
+
var import_node_crypto24 = require("crypto");
|
|
64909
65102
|
var import_node_net2 = require("net");
|
|
64910
65103
|
init_runtime_v2();
|
|
64911
65104
|
|
|
@@ -64975,7 +65168,7 @@ async function connectHolder(endpoint, token, onEvent) {
|
|
|
64975
65168
|
});
|
|
64976
65169
|
const pid = await ready;
|
|
64977
65170
|
const request2 = (body) => {
|
|
64978
|
-
const id = (0,
|
|
65171
|
+
const id = (0, import_node_crypto24.randomUUID)();
|
|
64979
65172
|
return new Promise((resolve12, reject) => {
|
|
64980
65173
|
const timer = AbortSignal.timeout(REQUEST_TIMEOUT_MS7);
|
|
64981
65174
|
timer.addEventListener("abort", () => {
|
|
@@ -65237,7 +65430,7 @@ function createConversationMcpAuthorization(options) {
|
|
|
65237
65430
|
}
|
|
65238
65431
|
|
|
65239
65432
|
// src/holder/run-inputs.ts
|
|
65240
|
-
var
|
|
65433
|
+
var import_promises54 = require("fs/promises");
|
|
65241
65434
|
var import_node_path53 = require("path");
|
|
65242
65435
|
var NO_RUN_INPUTS = {
|
|
65243
65436
|
attachments: [],
|
|
@@ -65253,16 +65446,16 @@ function safeFilename(filename) {
|
|
|
65253
65446
|
async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
65254
65447
|
const dir = (0, import_node_path53.join)(tmpDir, "runs", spec.runId);
|
|
65255
65448
|
const cleanup = async () => {
|
|
65256
|
-
await (0,
|
|
65449
|
+
await (0, import_promises54.rm)(dir, { recursive: true, force: true });
|
|
65257
65450
|
};
|
|
65258
65451
|
try {
|
|
65259
65452
|
const credential = await source.fetchProviderCredential(spec.runId, signal);
|
|
65260
65453
|
const attachments = [];
|
|
65261
|
-
if (spec.attachments?.length) await (0,
|
|
65454
|
+
if (spec.attachments?.length) await (0, import_promises54.mkdir)(dir, { recursive: true, mode: 448 });
|
|
65262
65455
|
for (const [index, attachment] of (spec.attachments ?? []).entries()) {
|
|
65263
65456
|
const bytes = await source.downloadAttachment(spec.runId, attachment.id, signal);
|
|
65264
65457
|
const path4 = (0, import_node_path53.join)(dir, `${index}-${safeFilename(attachment.filename)}`);
|
|
65265
|
-
await (0,
|
|
65458
|
+
await (0, import_promises54.writeFile)(path4, bytes, { mode: 384 });
|
|
65266
65459
|
attachments.push({
|
|
65267
65460
|
id: attachment.id,
|
|
65268
65461
|
kind: attachment.kind,
|
|
@@ -65275,7 +65468,13 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
|
65275
65468
|
...attachment.height === void 0 ? {} : { height: attachment.height }
|
|
65276
65469
|
});
|
|
65277
65470
|
}
|
|
65278
|
-
return {
|
|
65471
|
+
return {
|
|
65472
|
+
attachments,
|
|
65473
|
+
providerEnv: credential.env,
|
|
65474
|
+
...credential.codex === void 0 ? {} : { codex: credential.codex },
|
|
65475
|
+
skills,
|
|
65476
|
+
[Symbol.asyncDispose]: cleanup
|
|
65477
|
+
};
|
|
65279
65478
|
} catch (error61) {
|
|
65280
65479
|
await cleanup();
|
|
65281
65480
|
throw error61;
|
|
@@ -65283,7 +65482,7 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
|
65283
65482
|
}
|
|
65284
65483
|
|
|
65285
65484
|
// src/holder/serve.ts
|
|
65286
|
-
var
|
|
65485
|
+
var import_node_crypto28 = require("crypto");
|
|
65287
65486
|
var import_node_fs21 = require("fs");
|
|
65288
65487
|
var import_node_net3 = require("net");
|
|
65289
65488
|
var import_node_path62 = require("path");
|
|
@@ -65291,7 +65490,7 @@ init_runtime_v2();
|
|
|
65291
65490
|
|
|
65292
65491
|
// src/holder/admission.ts
|
|
65293
65492
|
var import_node_fs18 = require("fs");
|
|
65294
|
-
var
|
|
65493
|
+
var import_promises58 = require("fs/promises");
|
|
65295
65494
|
var import_node_os9 = require("os");
|
|
65296
65495
|
var import_node_path58 = require("path");
|
|
65297
65496
|
init_constants();
|
|
@@ -65305,7 +65504,7 @@ function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os8.hom
|
|
|
65305
65504
|
}
|
|
65306
65505
|
|
|
65307
65506
|
// src/holder/admission-relocation.ts
|
|
65308
|
-
var
|
|
65507
|
+
var import_promises55 = require("fs/promises");
|
|
65309
65508
|
var import_node_path55 = require("path");
|
|
65310
65509
|
var MAX_RELOCATION_CANDIDATES = 200;
|
|
65311
65510
|
var RELOCATION_BUDGET_MS = 2e4;
|
|
@@ -65341,7 +65540,7 @@ async function originIdentity(git, path4, signal) {
|
|
|
65341
65540
|
}
|
|
65342
65541
|
async function childDirectories(parent, limit) {
|
|
65343
65542
|
try {
|
|
65344
|
-
const entries = await (0,
|
|
65543
|
+
const entries = await (0, import_promises55.readdir)(parent, { withFileTypes: true });
|
|
65345
65544
|
return entries.filter((entry) => entry.isDirectory()).slice(0, limit).map((entry) => (0, import_node_path55.join)(parent, entry.name));
|
|
65346
65545
|
} catch {
|
|
65347
65546
|
return [];
|
|
@@ -65377,8 +65576,8 @@ async function discoverRelocatedWorkspace(search) {
|
|
|
65377
65576
|
}
|
|
65378
65577
|
|
|
65379
65578
|
// src/holder/checkout-refresh.ts
|
|
65380
|
-
var
|
|
65381
|
-
var
|
|
65579
|
+
var import_node_crypto26 = require("crypto");
|
|
65580
|
+
var import_promises56 = require("fs/promises");
|
|
65382
65581
|
var import_node_path56 = require("path");
|
|
65383
65582
|
function short(sha) {
|
|
65384
65583
|
return sha.slice(0, 12);
|
|
@@ -65391,8 +65590,8 @@ function staleLine(path4, snapshot2, tip) {
|
|
|
65391
65590
|
}
|
|
65392
65591
|
async function claimOnce(dir, name) {
|
|
65393
65592
|
try {
|
|
65394
|
-
await (0,
|
|
65395
|
-
await (await (0,
|
|
65593
|
+
await (0, import_promises56.mkdir)(dir, { recursive: true, mode: 448 });
|
|
65594
|
+
await (await (0, import_promises56.open)((0, import_node_path56.join)(dir, name), "wx")).close();
|
|
65396
65595
|
return true;
|
|
65397
65596
|
} catch {
|
|
65398
65597
|
return false;
|
|
@@ -65424,7 +65623,7 @@ async function fastForward(freshness, operationId, deps, signal) {
|
|
|
65424
65623
|
async function atFirstLease(freshness, spec, deps, signal) {
|
|
65425
65624
|
const first = await claimOnce(
|
|
65426
65625
|
(0, import_node_path56.join)(deps.dir, "leased"),
|
|
65427
|
-
(0,
|
|
65626
|
+
(0, import_node_crypto26.createHash)("sha256").update(freshness.path).digest("hex")
|
|
65428
65627
|
);
|
|
65429
65628
|
switch (freshness.state) {
|
|
65430
65629
|
case "current":
|
|
@@ -65475,7 +65674,7 @@ function createCheckoutRefresh(deps) {
|
|
|
65475
65674
|
}
|
|
65476
65675
|
|
|
65477
65676
|
// src/holder/lease.ts
|
|
65478
|
-
var
|
|
65677
|
+
var import_promises57 = require("fs/promises");
|
|
65479
65678
|
var import_node_path57 = require("path");
|
|
65480
65679
|
var LEASE_CHECK_EVERY_MS = 5e3;
|
|
65481
65680
|
var MAX_TRANSIENT_FAILURES = 3;
|
|
@@ -65490,8 +65689,8 @@ function identityFailure(code, workspacePath) {
|
|
|
65490
65689
|
return { code, problemCode: "app.workspace.missing", message: MESSAGES[code], workspacePath };
|
|
65491
65690
|
}
|
|
65492
65691
|
async function fileIdentity(path4) {
|
|
65493
|
-
const canonical = await (0,
|
|
65494
|
-
const info = await (0,
|
|
65692
|
+
const canonical = await (0, import_promises57.realpath)(path4);
|
|
65693
|
+
const info = await (0, import_promises57.stat)(canonical, { bigint: true });
|
|
65495
65694
|
return `${canonical}:${info.dev}:${info.ino}`;
|
|
65496
65695
|
}
|
|
65497
65696
|
async function snapshot(git, path4, signal) {
|
|
@@ -65510,7 +65709,7 @@ async function snapshot(git, path4, signal) {
|
|
|
65510
65709
|
workspace: await fileIdentity(path4),
|
|
65511
65710
|
repository: await fileIdentity(commonDir),
|
|
65512
65711
|
worktree: await fileIdentity(gitDir),
|
|
65513
|
-
commonDir: await (0,
|
|
65712
|
+
commonDir: await (0, import_promises57.realpath)(commonDir)
|
|
65514
65713
|
};
|
|
65515
65714
|
} catch {
|
|
65516
65715
|
return null;
|
|
@@ -65523,7 +65722,7 @@ async function gitValue(git, path4, args, signal) {
|
|
|
65523
65722
|
}
|
|
65524
65723
|
async function pathExists(path4) {
|
|
65525
65724
|
try {
|
|
65526
|
-
await (0,
|
|
65725
|
+
await (0, import_promises57.stat)(path4);
|
|
65527
65726
|
return true;
|
|
65528
65727
|
} catch (error61) {
|
|
65529
65728
|
return errnoCode(error61) !== "ENOENT" && errnoCode(error61) !== "ENOTDIR";
|
|
@@ -65532,13 +65731,13 @@ async function pathExists(path4) {
|
|
|
65532
65731
|
async function hasGitMarker(path4) {
|
|
65533
65732
|
let directory;
|
|
65534
65733
|
try {
|
|
65535
|
-
directory = await (0,
|
|
65734
|
+
directory = await (0, import_promises57.realpath)(path4);
|
|
65536
65735
|
} catch {
|
|
65537
65736
|
return true;
|
|
65538
65737
|
}
|
|
65539
65738
|
for (; ; ) {
|
|
65540
65739
|
try {
|
|
65541
|
-
await (0,
|
|
65740
|
+
await (0, import_promises57.stat)((0, import_node_path57.join)(directory, ".git"));
|
|
65542
65741
|
return true;
|
|
65543
65742
|
} catch (error61) {
|
|
65544
65743
|
const code = errnoCode(error61);
|
|
@@ -65708,7 +65907,7 @@ function volumeRoot(path4) {
|
|
|
65708
65907
|
}
|
|
65709
65908
|
async function exists4(path4) {
|
|
65710
65909
|
try {
|
|
65711
|
-
await (0,
|
|
65910
|
+
await (0, import_promises58.stat)(path4);
|
|
65712
65911
|
return true;
|
|
65713
65912
|
} catch {
|
|
65714
65913
|
return false;
|
|
@@ -65716,10 +65915,10 @@ async function exists4(path4) {
|
|
|
65716
65915
|
}
|
|
65717
65916
|
async function inspectReadiness(path4) {
|
|
65718
65917
|
try {
|
|
65719
|
-
if (!(await (0,
|
|
65918
|
+
if (!(await (0, import_promises58.stat)(path4)).isDirectory()) {
|
|
65720
65919
|
return { ready: false, missing: true, message: MESSAGES2.missing };
|
|
65721
65920
|
}
|
|
65722
|
-
await (0,
|
|
65921
|
+
await (0, import_promises58.access)(path4, import_node_fs18.constants.R_OK | import_node_fs18.constants.W_OK | import_node_fs18.constants.X_OK);
|
|
65723
65922
|
return { ready: true };
|
|
65724
65923
|
} catch (error61) {
|
|
65725
65924
|
const code = errnoCode(error61) ?? "";
|
|
@@ -65797,8 +65996,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
|
|
|
65797
65996
|
const { env } = context;
|
|
65798
65997
|
const path4 = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os9.homedir)());
|
|
65799
65998
|
try {
|
|
65800
|
-
await (0,
|
|
65801
|
-
await (0,
|
|
65999
|
+
await (0, import_promises58.mkdir)(path4, { recursive: true, mode: 448 });
|
|
66000
|
+
await (0, import_promises58.access)(path4, import_node_fs18.constants.R_OK | import_node_fs18.constants.W_OK | import_node_fs18.constants.X_OK);
|
|
65802
66001
|
return {
|
|
65803
66002
|
kind: "admitted",
|
|
65804
66003
|
spec: { ...spec, projectPath: path4 },
|
|
@@ -65869,7 +66068,10 @@ function createHolderWorkspace(machine, clock, log) {
|
|
|
65869
66068
|
env: machine.env,
|
|
65870
66069
|
git,
|
|
65871
66070
|
platform: platform3,
|
|
65872
|
-
skills: skillsLayout(
|
|
66071
|
+
skills: skillsLayout(
|
|
66072
|
+
machine.stateDir,
|
|
66073
|
+
machine.env.HOME || machine.env.USERPROFILE || (0, import_node_os9.homedir)()
|
|
66074
|
+
),
|
|
65873
66075
|
approvedRoots: async () => {
|
|
65874
66076
|
const approved = await openApprovedPaths({
|
|
65875
66077
|
file: (0, import_node_path58.join)(machine.stateDir, "workspaces.json"),
|
|
@@ -65913,7 +66115,7 @@ async function respondToTurn(runningRunId, gate, driver, request2) {
|
|
|
65913
66115
|
}
|
|
65914
66116
|
|
|
65915
66117
|
// src/holder/session-facts.ts
|
|
65916
|
-
var
|
|
66118
|
+
var import_promises59 = require("fs/promises");
|
|
65917
66119
|
var CLI_RSS_CACHE_MS = 1e4;
|
|
65918
66120
|
var LOGIN_PROBLEM_PREFIX = "cli.auth.";
|
|
65919
66121
|
function isLoginFailure(result) {
|
|
@@ -65939,8 +66141,8 @@ function createSessionFacts(options) {
|
|
|
65939
66141
|
const path4 = await resolveCommandOnPath(command, env, platform3);
|
|
65940
66142
|
if (path4 === null) return null;
|
|
65941
66143
|
try {
|
|
65942
|
-
const real = await (0,
|
|
65943
|
-
const info = await (0,
|
|
66144
|
+
const real = await (0, import_promises59.realpath)(path4);
|
|
66145
|
+
const info = await (0, import_promises59.stat)(real);
|
|
65944
66146
|
return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
|
|
65945
66147
|
} catch {
|
|
65946
66148
|
return null;
|
|
@@ -66027,12 +66229,12 @@ function createSessionFacts(options) {
|
|
|
66027
66229
|
init_acp2();
|
|
66028
66230
|
|
|
66029
66231
|
// src/run-log/complete.ts
|
|
66030
|
-
var
|
|
66232
|
+
var import_node_crypto27 = require("crypto");
|
|
66031
66233
|
var import_node_fs19 = require("fs");
|
|
66032
66234
|
var import_node_path60 = require("path");
|
|
66033
66235
|
|
|
66034
66236
|
// src/run-log/directory.ts
|
|
66035
|
-
var
|
|
66237
|
+
var import_promises60 = require("fs/promises");
|
|
66036
66238
|
var import_node_path59 = require("path");
|
|
66037
66239
|
init_runtime_v2();
|
|
66038
66240
|
init_zod();
|
|
@@ -66052,7 +66254,7 @@ function runDirectory(runsDir, runId) {
|
|
|
66052
66254
|
}
|
|
66053
66255
|
async function isRunClaimed(runsDir, runId) {
|
|
66054
66256
|
try {
|
|
66055
|
-
return (await (0,
|
|
66257
|
+
return (await (0, import_promises60.stat)(runDirectory(runsDir, runId).log)).size > 0;
|
|
66056
66258
|
} catch (error61) {
|
|
66057
66259
|
if (errnoCode(error61) === "ENOENT") return false;
|
|
66058
66260
|
throw error61;
|
|
@@ -66061,7 +66263,7 @@ async function isRunClaimed(runsDir, runId) {
|
|
|
66061
66263
|
|
|
66062
66264
|
// src/run-log/complete.ts
|
|
66063
66265
|
function writeLogFile(path4, dir, text2) {
|
|
66064
|
-
const temp = (0, import_node_path60.join)(dir, `.log.${(0,
|
|
66266
|
+
const temp = (0, import_node_path60.join)(dir, `.log.${(0, import_node_crypto27.randomUUID)()}.tmp`);
|
|
66065
66267
|
const fd = (0, import_node_fs19.openSync)(temp, "wx", 384);
|
|
66066
66268
|
try {
|
|
66067
66269
|
(0, import_node_fs19.writeSync)(fd, text2);
|
|
@@ -66090,7 +66292,7 @@ async function writeCompleteRunLog(runsDir, meta3, records) {
|
|
|
66090
66292
|
}
|
|
66091
66293
|
|
|
66092
66294
|
// src/run-log/reader.ts
|
|
66093
|
-
var
|
|
66295
|
+
var import_promises61 = require("fs/promises");
|
|
66094
66296
|
init_runtime_v2();
|
|
66095
66297
|
|
|
66096
66298
|
// src/run-log/tail.ts
|
|
@@ -66113,7 +66315,7 @@ function firstRecordLength(bytes) {
|
|
|
66113
66315
|
return bytes.indexOf(RUN_LOG_RECORD_SEPARATOR) + 1;
|
|
66114
66316
|
}
|
|
66115
66317
|
async function openRunLogReader(path4) {
|
|
66116
|
-
const handle = await (0,
|
|
66318
|
+
const handle = await (0, import_promises61.open)(path4, "r");
|
|
66117
66319
|
const readAt = async (position, length) => {
|
|
66118
66320
|
const buffer = Buffer.alloc(length);
|
|
66119
66321
|
const { bytesRead } = await handle.read(buffer, 0, length, position);
|
|
@@ -66147,7 +66349,7 @@ async function openRunLogReader(path4) {
|
|
|
66147
66349
|
};
|
|
66148
66350
|
}
|
|
66149
66351
|
async function readLastRecord(path4) {
|
|
66150
|
-
const handle = await (0,
|
|
66352
|
+
const handle = await (0, import_promises61.open)(path4, "r").catch(() => null);
|
|
66151
66353
|
if (handle === null) return null;
|
|
66152
66354
|
try {
|
|
66153
66355
|
const { size } = await handle.stat();
|
|
@@ -66493,13 +66695,13 @@ var TASK_UNSUPPORTED = {
|
|
|
66493
66695
|
reason: "unsupported",
|
|
66494
66696
|
message: "This agent cannot stop one background task."
|
|
66495
66697
|
};
|
|
66496
|
-
function
|
|
66497
|
-
return (0,
|
|
66698
|
+
function sha2564(value2) {
|
|
66699
|
+
return (0, import_node_crypto28.createHash)("sha256").update(value2).digest("hex");
|
|
66498
66700
|
}
|
|
66499
66701
|
function tokenMatches(expected, presented) {
|
|
66500
|
-
const a = Buffer.from(
|
|
66501
|
-
const b = Buffer.from(
|
|
66502
|
-
return (0,
|
|
66702
|
+
const a = Buffer.from(sha2564(expected), "hex");
|
|
66703
|
+
const b = Buffer.from(sha2564(presented), "hex");
|
|
66704
|
+
return (0, import_node_crypto28.timingSafeEqual)(a, b);
|
|
66503
66705
|
}
|
|
66504
66706
|
async function runHolder({
|
|
66505
66707
|
launch,
|
|
@@ -66536,7 +66738,7 @@ async function runHolder({
|
|
|
66536
66738
|
startedAt: identity.startedAt,
|
|
66537
66739
|
...identity.command === void 0 ? {} : { command: identity.command },
|
|
66538
66740
|
endpoint: launch.endpoint,
|
|
66539
|
-
tokenSha256:
|
|
66741
|
+
tokenSha256: sha2564(launch.token),
|
|
66540
66742
|
state: holder.state,
|
|
66541
66743
|
runId: holder.runId,
|
|
66542
66744
|
updatedAt: clock.now()
|
|
@@ -66807,7 +67009,7 @@ var DEFAULT_MAX_ACTIVE_RUNS = 32;
|
|
|
66807
67009
|
var HOLDER_BUSY = "busy";
|
|
66808
67010
|
async function listIds(dir, schema) {
|
|
66809
67011
|
const ids = [];
|
|
66810
|
-
for (const name of await (0,
|
|
67012
|
+
for (const name of await (0, import_promises62.readdir)(dir).catch(() => [])) {
|
|
66811
67013
|
const parsed = schema.safeParse(name);
|
|
66812
67014
|
if (parsed.success) ids.push(parsed.data);
|
|
66813
67015
|
}
|
|
@@ -66863,7 +67065,7 @@ async function openSessions(deps) {
|
|
|
66863
67065
|
await reapLeftoverEngines(engineRecordsPath(dir), { clock, log, conversationId }).catch(
|
|
66864
67066
|
(error61) => log.warn("sessions.engine_reap_failed", { conversationId, error: error61 })
|
|
66865
67067
|
);
|
|
66866
|
-
await (0,
|
|
67068
|
+
await (0, import_promises62.rm)(dir, { recursive: true, force: true });
|
|
66867
67069
|
};
|
|
66868
67070
|
const retireIfGone = async (conversationId) => {
|
|
66869
67071
|
const files = sessionFiles(paths, conversationId);
|
|
@@ -66951,7 +67153,7 @@ async function openSessions(deps) {
|
|
|
66951
67153
|
log.info("sessions.reattached", { conversationId });
|
|
66952
67154
|
return;
|
|
66953
67155
|
}
|
|
66954
|
-
if (alive) await (0,
|
|
67156
|
+
if (alive) await (0, import_promises62.rm)(files.dir, { recursive: true, force: true });
|
|
66955
67157
|
else await discardSession(conversationId);
|
|
66956
67158
|
};
|
|
66957
67159
|
const busyRunIds = async () => {
|
|
@@ -66982,8 +67184,8 @@ async function openSessions(deps) {
|
|
|
66982
67184
|
protocol: HOLDER_PROTOCOL,
|
|
66983
67185
|
conversationId,
|
|
66984
67186
|
machineId: deps.machineId,
|
|
66985
|
-
endpoint: ipcEndpoint(paths.sockets, (0,
|
|
66986
|
-
token: (0,
|
|
67187
|
+
endpoint: ipcEndpoint(paths.sockets, (0, import_node_crypto29.randomUUID)().slice(0, 8)),
|
|
67188
|
+
token: (0, import_node_crypto29.randomBytes)(32).toString("hex"),
|
|
66987
67189
|
runsDir: paths.runs,
|
|
66988
67190
|
statusPath: files.status
|
|
66989
67191
|
};
|
|
@@ -67009,7 +67211,7 @@ async function openSessions(deps) {
|
|
|
67009
67211
|
const meta3 = await readRunMeta(dir.meta);
|
|
67010
67212
|
const last = await readLastRecord(dir.log);
|
|
67011
67213
|
if (meta3 === null || last === null) return null;
|
|
67012
|
-
const logged = await (0,
|
|
67214
|
+
const logged = await (0, import_promises62.stat)(dir.log).catch((error61) => {
|
|
67013
67215
|
if (errnoCode(error61) === "ENOENT") return null;
|
|
67014
67216
|
throw error61;
|
|
67015
67217
|
});
|
|
@@ -67389,7 +67591,7 @@ function takeEnrollmentCodeFromEnv(env = process.env) {
|
|
|
67389
67591
|
}
|
|
67390
67592
|
|
|
67391
67593
|
// src/cli/context.ts
|
|
67392
|
-
var
|
|
67594
|
+
var import_promises63 = require("fs/promises");
|
|
67393
67595
|
var import_node_os12 = require("os");
|
|
67394
67596
|
var import_node_path65 = require("path");
|
|
67395
67597
|
var DESKTOP_BUNDLE_IDS = {
|
|
@@ -67439,7 +67641,7 @@ async function installedServiceSpec(ctx) {
|
|
|
67439
67641
|
const spec = serviceSpec(ctx);
|
|
67440
67642
|
if (ctx.config.host === "app") return spec;
|
|
67441
67643
|
const layout = installLayout(ctx.config.installDir, ctx.config.profile);
|
|
67442
|
-
const installed = await (0,
|
|
67644
|
+
const installed = await (0, import_promises63.access)(layout.launcher).then(
|
|
67443
67645
|
() => true,
|
|
67444
67646
|
() => false
|
|
67445
67647
|
);
|
|
@@ -67567,7 +67769,7 @@ var manifestRevisionSchema = external_exports.object({ revision: external_export
|
|
|
67567
67769
|
async function manifestRevision(path4) {
|
|
67568
67770
|
let raw;
|
|
67569
67771
|
try {
|
|
67570
|
-
raw = JSON.parse(await (0,
|
|
67772
|
+
raw = JSON.parse(await (0, import_promises64.readFile)(path4, "utf8"));
|
|
67571
67773
|
} catch (error61) {
|
|
67572
67774
|
throw new RuntimeFault("invalid_file", `Cannot read the skill manifest at ${path4}`, {
|
|
67573
67775
|
cause: error61
|
|
@@ -67585,7 +67787,7 @@ async function runSkills(argv) {
|
|
|
67585
67787
|
case "scan":
|
|
67586
67788
|
writeJson({
|
|
67587
67789
|
status: "failed",
|
|
67588
|
-
attemptId: (0,
|
|
67790
|
+
attemptId: (0, import_node_crypto30.randomUUID)(),
|
|
67589
67791
|
retainedInventoryRevision: null,
|
|
67590
67792
|
diagnostics: [
|
|
67591
67793
|
{ code: "RUNTIME_SKILL_SCAN_UNSUPPORTED", message: SKILLS_SYNCED_BY_RUNTIME }
|
|
@@ -67601,7 +67803,7 @@ async function runSkills(argv) {
|
|
|
67601
67803
|
);
|
|
67602
67804
|
}
|
|
67603
67805
|
writeJson({
|
|
67604
|
-
attemptId: (0,
|
|
67806
|
+
attemptId: (0, import_node_crypto30.randomUUID)(),
|
|
67605
67807
|
desiredRevision: await manifestRevision(manifest),
|
|
67606
67808
|
skills: []
|
|
67607
67809
|
});
|
|
@@ -67621,7 +67823,7 @@ async function runSkills(argv) {
|
|
|
67621
67823
|
}
|
|
67622
67824
|
|
|
67623
67825
|
// src/cli/commands/doctor.ts
|
|
67624
|
-
var
|
|
67826
|
+
var import_promises67 = require("fs/promises");
|
|
67625
67827
|
var import_node_path69 = require("path");
|
|
67626
67828
|
init_runtime_v2();
|
|
67627
67829
|
|
|
@@ -67799,11 +68001,11 @@ async function authorizeDevice(input2) {
|
|
|
67799
68001
|
}
|
|
67800
68002
|
|
|
67801
68003
|
// src/identity/enroll.ts
|
|
67802
|
-
var
|
|
68004
|
+
var import_promises65 = require("fs/promises");
|
|
67803
68005
|
init_runtime_v2();
|
|
67804
68006
|
|
|
67805
68007
|
// src/identity/installation.ts
|
|
67806
|
-
var
|
|
68008
|
+
var import_node_crypto31 = require("crypto");
|
|
67807
68009
|
var import_node_path66 = require("path");
|
|
67808
68010
|
init_zod();
|
|
67809
68011
|
var installationFileSchema = external_exports.object({
|
|
@@ -67816,7 +68018,7 @@ async function ensureInstallationId(paths) {
|
|
|
67816
68018
|
const path4 = installationPath(paths);
|
|
67817
68019
|
const existing = await readJsonFile(path4, installationFileSchema);
|
|
67818
68020
|
if (existing.kind === "ok") return existing.value.installationId;
|
|
67819
|
-
const created = { installationId: (0,
|
|
68021
|
+
const created = { installationId: (0, import_node_crypto31.randomUUID)() };
|
|
67820
68022
|
await writeJsonFileAtomic(path4, created);
|
|
67821
68023
|
return created.installationId;
|
|
67822
68024
|
}
|
|
@@ -67903,12 +68105,12 @@ async function enrollFromGrantFile(input2) {
|
|
|
67903
68105
|
clock: input2.clock,
|
|
67904
68106
|
access: input2.access
|
|
67905
68107
|
});
|
|
67906
|
-
await (0,
|
|
68108
|
+
await (0, import_promises65.rm)(input2.grantPath, { force: true });
|
|
67907
68109
|
return machine;
|
|
67908
68110
|
}
|
|
67909
68111
|
|
|
67910
68112
|
// src/identity/migrate-v1.ts
|
|
67911
|
-
var
|
|
68113
|
+
var import_promises66 = require("fs/promises");
|
|
67912
68114
|
var import_node_path67 = require("path");
|
|
67913
68115
|
init_runtime_v2();
|
|
67914
68116
|
init_zod();
|
|
@@ -67959,8 +68161,8 @@ async function scrubLegacyInstall(install2) {
|
|
|
67959
68161
|
const scrubbed = { ...install2.config, migratedToRuntimeV2: true };
|
|
67960
68162
|
for (const key of SCRUBBED_KEYS) delete scrubbed[key];
|
|
67961
68163
|
await writeJsonFileAtomic(`${install2.configPath}.migrated-v1`, scrubbed);
|
|
67962
|
-
await (0,
|
|
67963
|
-
await (0,
|
|
68164
|
+
await (0, import_promises66.rm)(install2.configPath, { force: true });
|
|
68165
|
+
await (0, import_promises66.rm)(install2.ownerLeasePath, { force: true });
|
|
67964
68166
|
}
|
|
67965
68167
|
async function exchangeCredential(deps) {
|
|
67966
68168
|
const { config: config2 } = deps.install;
|
|
@@ -68369,7 +68571,7 @@ async function probeHolder(dir, conversationId) {
|
|
|
68369
68571
|
}
|
|
68370
68572
|
}
|
|
68371
68573
|
async function holdersCheck(ctx) {
|
|
68372
|
-
const names = await (0,
|
|
68574
|
+
const names = await (0, import_promises67.readdir)(ctx.paths.sessions).catch(() => []);
|
|
68373
68575
|
const holders = (await Promise.all(names.map((name) => probeHolder((0, import_node_path69.join)(ctx.paths.sessions, name), name)))).filter((facts) => facts !== null);
|
|
68374
68576
|
const dead = holders.filter((holder) => !holder.alive).length;
|
|
68375
68577
|
return check2(
|
|
@@ -68381,7 +68583,7 @@ async function holdersCheck(ctx) {
|
|
|
68381
68583
|
}
|
|
68382
68584
|
async function freeBytesAt(path4) {
|
|
68383
68585
|
try {
|
|
68384
|
-
const stats = await (0,
|
|
68586
|
+
const stats = await (0, import_promises67.statfs)(path4);
|
|
68385
68587
|
return { path: path4, freeBytes: stats.bavail * stats.bsize };
|
|
68386
68588
|
} catch (error61) {
|
|
68387
68589
|
const parent = (0, import_node_path69.dirname)(path4);
|
|
@@ -68520,7 +68722,7 @@ async function runDoctor(argv, context = cliContext) {
|
|
|
68520
68722
|
}
|
|
68521
68723
|
|
|
68522
68724
|
// src/cli/commands/git-credential.ts
|
|
68523
|
-
var
|
|
68725
|
+
var import_promises68 = require("fs/promises");
|
|
68524
68726
|
var import_node_net4 = require("net");
|
|
68525
68727
|
var MAX_RESPONSE_BYTES = 64 * 1024;
|
|
68526
68728
|
async function readAll(stream) {
|
|
@@ -68630,7 +68832,7 @@ async function configure(argv) {
|
|
|
68630
68832
|
}
|
|
68631
68833
|
async function configureGitGateway(config2, gatewayUrl, signal) {
|
|
68632
68834
|
const { launcher } = installLayout(config2.installDir, config2.profile);
|
|
68633
|
-
const installed = await (0,
|
|
68835
|
+
const installed = await (0, import_promises68.access)(launcher).then(
|
|
68634
68836
|
() => true,
|
|
68635
68837
|
() => false
|
|
68636
68838
|
);
|
|
@@ -68690,7 +68892,14 @@ async function machineAccess(paths, log, conversationId, transport) {
|
|
|
68690
68892
|
return (await api()).fetchProviderCredential(runId, signal);
|
|
68691
68893
|
}
|
|
68692
68894
|
};
|
|
68693
|
-
|
|
68895
|
+
const codexCredentials = {
|
|
68896
|
+
refresh: async (runId, rejectedAccessTokenSha256) => (await api()).refreshCodexCredential(
|
|
68897
|
+
runId,
|
|
68898
|
+
rejectedAccessTokenSha256 === void 0 ? {} : { rejectedAccessTokenSha256 },
|
|
68899
|
+
new AbortController().signal
|
|
68900
|
+
)
|
|
68901
|
+
};
|
|
68902
|
+
return { source, managedMcp, codexCredentials };
|
|
68694
68903
|
}
|
|
68695
68904
|
async function runHold(argv) {
|
|
68696
68905
|
var _stack = [];
|
|
@@ -68725,6 +68934,7 @@ async function runHold(argv) {
|
|
|
68725
68934
|
defaultCwd: process.cwd(),
|
|
68726
68935
|
timings: config2.sessionTimings,
|
|
68727
68936
|
log,
|
|
68937
|
+
codexCredentials: access7.codexCredentials,
|
|
68728
68938
|
...access7.managedMcp === void 0 ? {} : { managedMcp: access7.managedMcp }
|
|
68729
68939
|
}),
|
|
68730
68940
|
clock: systemClock,
|
|
@@ -68813,7 +69023,7 @@ async function runHook(argv, overrides = {}) {
|
|
|
68813
69023
|
}
|
|
68814
69024
|
|
|
68815
69025
|
// src/cli/commands/ingestion-hooks.ts
|
|
68816
|
-
var
|
|
69026
|
+
var import_promises69 = require("fs/promises");
|
|
68817
69027
|
var CODEX_TRUST_NOTE = "Codex runs new hooks only after you review them: open /hooks in Codex.";
|
|
68818
69028
|
function isAction(value2) {
|
|
68819
69029
|
return value2 === "enable" || value2 === "disable" || value2 === "status";
|
|
@@ -68836,7 +69046,7 @@ function errorMessage2(error61) {
|
|
|
68836
69046
|
return error61 instanceof Error ? error61.message : String(error61);
|
|
68837
69047
|
}
|
|
68838
69048
|
async function exists5(path4) {
|
|
68839
|
-
return (0,
|
|
69049
|
+
return (0, import_promises69.access)(path4).then(
|
|
68840
69050
|
() => true,
|
|
68841
69051
|
() => false
|
|
68842
69052
|
);
|
|
@@ -69195,7 +69405,7 @@ async function runToken(argv, signal) {
|
|
|
69195
69405
|
}
|
|
69196
69406
|
|
|
69197
69407
|
// src/cli/commands/logout.ts
|
|
69198
|
-
var
|
|
69408
|
+
var import_promises70 = require("fs/promises");
|
|
69199
69409
|
var import_node_path74 = require("path");
|
|
69200
69410
|
init_runtime_v2();
|
|
69201
69411
|
var RUNTIME_EXIT_WAIT_MS = 35e3;
|
|
@@ -69255,7 +69465,7 @@ async function stopHolder(launch, deps, outcome2) {
|
|
|
69255
69465
|
}
|
|
69256
69466
|
async function stopHeldRuns(ctx, deps, outcome2 = "aborted") {
|
|
69257
69467
|
const stopped = [];
|
|
69258
|
-
for (const name of await (0,
|
|
69468
|
+
for (const name of await (0, import_promises70.readdir)(ctx.paths.sessions).catch(() => [])) {
|
|
69259
69469
|
const launch = await readJsonFile(
|
|
69260
69470
|
(0, import_node_path74.join)(ctx.paths.sessions, name, "launch.json"),
|
|
69261
69471
|
holderLaunchSchema
|
|
@@ -69294,7 +69504,7 @@ async function forgetMachineLocally(ctx) {
|
|
|
69294
69504
|
const machine = await readMachineFile(ctx.paths);
|
|
69295
69505
|
if (machine === null) return;
|
|
69296
69506
|
await credentialStoreFor(ctx.paths, machine.credentialStore, ctx.access).clear();
|
|
69297
|
-
await (0,
|
|
69507
|
+
await (0, import_promises70.rm)(ctx.paths.machine, { force: true });
|
|
69298
69508
|
}
|
|
69299
69509
|
async function runLogout(argv, signal) {
|
|
69300
69510
|
var _stack = [];
|
|
@@ -69382,18 +69592,18 @@ function createRunAppends() {
|
|
|
69382
69592
|
}
|
|
69383
69593
|
|
|
69384
69594
|
// src/local-api/server.ts
|
|
69385
|
-
var
|
|
69386
|
-
var
|
|
69595
|
+
var import_node_crypto33 = require("crypto");
|
|
69596
|
+
var import_promises71 = require("fs/promises");
|
|
69387
69597
|
var import_node_http4 = require("http");
|
|
69388
69598
|
var import_node_path75 = require("path");
|
|
69389
69599
|
|
|
69390
69600
|
// src/local-api/guard.ts
|
|
69391
|
-
var
|
|
69601
|
+
var import_node_crypto32 = require("crypto");
|
|
69392
69602
|
var ALLOWED = { kind: "allowed" };
|
|
69393
69603
|
function tokenMatches2(expected, header) {
|
|
69394
69604
|
if (header === void 0 || !header.startsWith("Bearer ")) return false;
|
|
69395
69605
|
const presented = Buffer.from(header.slice("Bearer ".length));
|
|
69396
|
-
return presented.length === expected.length && (0,
|
|
69606
|
+
return presented.length === expected.length && (0, import_node_crypto32.timingSafeEqual)(presented, expected);
|
|
69397
69607
|
}
|
|
69398
69608
|
function isBrowserReachable(req, allowedHosts) {
|
|
69399
69609
|
if (req.headers.origin !== void 0 || req.headers.referer !== void 0) return true;
|
|
@@ -70038,7 +70248,7 @@ async function serveLocalApi(deps) {
|
|
|
70038
70248
|
server.keepAliveTimeout = KEEP_ALIVE_TIMEOUT_MS;
|
|
70039
70249
|
server.maxConnections = HARD_MAX_CONNECTIONS;
|
|
70040
70250
|
const port = await listenOnLoopback(server);
|
|
70041
|
-
const token = (0,
|
|
70251
|
+
const token = (0, import_node_crypto33.randomBytes)(32).toString("base64url");
|
|
70042
70252
|
const guard = createRequestGuard({ token, port, rateLimit: limits.rateLimit, clock });
|
|
70043
70253
|
const appAttachments = createAppAttachments(clock);
|
|
70044
70254
|
const routeDeps = {
|
|
@@ -70122,7 +70332,7 @@ async function serveLocalApi(deps) {
|
|
|
70122
70332
|
await watchedStatus[Symbol.asyncDispose]();
|
|
70123
70333
|
const current = await readJsonFile(discoveryPath, localApiDiscoverySchema);
|
|
70124
70334
|
if (current.kind === "ok" && current.value.token === token) {
|
|
70125
|
-
await (0,
|
|
70335
|
+
await (0, import_promises71.rm)(discoveryPath, { force: true });
|
|
70126
70336
|
}
|
|
70127
70337
|
await closeServer(server);
|
|
70128
70338
|
log.info("local_api.closed", {});
|
|
@@ -73875,7 +74085,7 @@ function refusalFailure(refusal2) {
|
|
|
73875
74085
|
}
|
|
73876
74086
|
|
|
73877
74087
|
// src/link/probe.ts
|
|
73878
|
-
var
|
|
74088
|
+
var import_promises72 = require("dns/promises");
|
|
73879
74089
|
var import_node_net5 = require("net");
|
|
73880
74090
|
var import_node_tls2 = require("tls");
|
|
73881
74091
|
var PROBE_TIMEOUT_MS4 = 5e3;
|
|
@@ -73911,7 +74121,7 @@ async function connectOnce(url3, clock) {
|
|
|
73911
74121
|
}
|
|
73912
74122
|
async function probeEndpoint(url3, clock) {
|
|
73913
74123
|
try {
|
|
73914
|
-
await (0,
|
|
74124
|
+
await (0, import_promises72.lookup)(url3.hostname);
|
|
73915
74125
|
} catch (error61) {
|
|
73916
74126
|
const reason = classifyTransportFailure(error61);
|
|
73917
74127
|
return reason === "other" ? "dns" : reason;
|
|
@@ -74213,9 +74423,9 @@ function planReconcile(desired, held) {
|
|
|
74213
74423
|
}
|
|
74214
74424
|
|
|
74215
74425
|
// src/reconciler/desired-sync.ts
|
|
74216
|
-
var
|
|
74426
|
+
var import_node_crypto34 = require("crypto");
|
|
74217
74427
|
function fingerprintOf(desired) {
|
|
74218
|
-
return (0,
|
|
74428
|
+
return (0, import_node_crypto34.createHash)("sha256").update(JSON.stringify(desired)).digest("hex");
|
|
74219
74429
|
}
|
|
74220
74430
|
var FAILED_READ_RETRY_MS = 3e4;
|
|
74221
74431
|
function createDesiredSync(deps) {
|
|
@@ -74352,7 +74562,7 @@ function createReconciler(host, lifecycle, log, signal) {
|
|
|
74352
74562
|
}
|
|
74353
74563
|
|
|
74354
74564
|
// src/uploader/index.ts
|
|
74355
|
-
var
|
|
74565
|
+
var import_promises73 = require("fs/promises");
|
|
74356
74566
|
init_runtime_v2();
|
|
74357
74567
|
init_zod();
|
|
74358
74568
|
var RETRY_DELAYS_MS = [250, 500, 1e3, 2e3, 5e3, 1e4, 3e4];
|
|
@@ -74493,7 +74703,7 @@ function startUploader({ api, runsDir, clock, log }) {
|
|
|
74493
74703
|
active.set(runId, task);
|
|
74494
74704
|
};
|
|
74495
74705
|
const sweep2 = async () => {
|
|
74496
|
-
for (const name of await (0,
|
|
74706
|
+
for (const name of await (0, import_promises73.readdir)(runsDir).catch(() => [])) {
|
|
74497
74707
|
const runId = runIdSchema.safeParse(name);
|
|
74498
74708
|
if (runId.success) run2(runId.data);
|
|
74499
74709
|
}
|
|
@@ -74503,18 +74713,18 @@ function startUploader({ api, runsDir, clock, log }) {
|
|
|
74503
74713
|
const dir = runDirectory(runsDir, runId);
|
|
74504
74714
|
const progress = await readJsonFile(dir.upload, uploadProgressSchema);
|
|
74505
74715
|
if (progress.kind !== "ok" || !progress.value.sealed) return false;
|
|
74506
|
-
const sealedAt = (await (0,
|
|
74716
|
+
const sealedAt = (await (0, import_promises73.stat)(dir.upload)).mtimeMs;
|
|
74507
74717
|
if (clock.now() - sealedAt < options.sealedForMs) return false;
|
|
74508
74718
|
return (await readLastRecord(dir.log))?.update.sessionUpdate === "_alan/run.ended";
|
|
74509
74719
|
};
|
|
74510
74720
|
const prune = async (options) => {
|
|
74511
74721
|
let removed = 0;
|
|
74512
|
-
for (const name of await (0,
|
|
74722
|
+
for (const name of await (0, import_promises73.readdir)(runsDir).catch(() => [])) {
|
|
74513
74723
|
const runId = runIdSchema.safeParse(name);
|
|
74514
74724
|
if (!runId.success) continue;
|
|
74515
74725
|
try {
|
|
74516
74726
|
if (!await isPrunable(runId.data, options)) continue;
|
|
74517
|
-
await (0,
|
|
74727
|
+
await (0, import_promises73.rm)(runDirectory(runsDir, runId.data).dir, { recursive: true, force: true });
|
|
74518
74728
|
removed += 1;
|
|
74519
74729
|
} catch (error61) {
|
|
74520
74730
|
log.warn("upload.prune_failed", { runId: runId.data, error: error61 });
|
|
@@ -75814,17 +76024,17 @@ async function runServiceCommand(argv, ctx = cliContext()) {
|
|
|
75814
76024
|
}
|
|
75815
76025
|
|
|
75816
76026
|
// src/cli/commands/upgrade.ts
|
|
75817
|
-
var
|
|
76027
|
+
var import_promises74 = require("fs/promises");
|
|
75818
76028
|
var import_node_path79 = require("path");
|
|
75819
76029
|
function isNotNewer(version2, installed) {
|
|
75820
76030
|
return installed !== null && isReleaseVersion(version2) && isReleaseVersion(installed) && compareVersions(version2, installed) <= 0;
|
|
75821
76031
|
}
|
|
75822
76032
|
async function installFromSource(source) {
|
|
75823
76033
|
const { layout, from, ifNewer } = source;
|
|
75824
|
-
const isTarball = (await (0,
|
|
76034
|
+
const isTarball = (await (0, import_promises74.stat)(from)).isFile();
|
|
75825
76035
|
const downloads = (0, import_node_path79.join)(layout.root, ".downloads");
|
|
75826
|
-
if (isTarball) await (0,
|
|
75827
|
-
const scratch = isTarball ? await (0,
|
|
76036
|
+
if (isTarball) await (0, import_promises74.mkdir)(downloads, { recursive: true, mode: 448 });
|
|
76037
|
+
const scratch = isTarball ? await (0, import_promises74.mkdtemp)((0, import_node_path79.join)(downloads, "upgrade-")) : null;
|
|
75828
76038
|
try {
|
|
75829
76039
|
const sourceDir = scratch === null ? from : await extractPackageTarball(from, scratch);
|
|
75830
76040
|
const version2 = await readPackageVersion(sourceDir);
|
|
@@ -75832,7 +76042,7 @@ async function installFromSource(source) {
|
|
|
75832
76042
|
if (ifNewer && isNotNewer(version2, installed)) return { kind: "skipped", version: version2, installed };
|
|
75833
76043
|
return { kind: "installed", ...await installVersion(layout, sourceDir) };
|
|
75834
76044
|
} finally {
|
|
75835
|
-
if (scratch !== null) await (0,
|
|
76045
|
+
if (scratch !== null) await (0, import_promises74.rm)(scratch, { recursive: true, force: true });
|
|
75836
76046
|
}
|
|
75837
76047
|
}
|
|
75838
76048
|
async function runUpgrade(argv) {
|