@alan-ai-hq/agent-manager-darwin-arm64 0.1.147 → 0.1.148
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 +1271 -736
- package/alan-holder.cjs +950 -496
- package/package.json +1 -1
package/alan-agent.cjs
CHANGED
|
@@ -19060,21 +19060,21 @@ function visit(schema, fnOrHandlers) {
|
|
|
19060
19060
|
case "object": {
|
|
19061
19061
|
const oldShape = def.shape;
|
|
19062
19062
|
const keys = Object.keys(oldShape);
|
|
19063
|
-
let
|
|
19063
|
+
let changed2 = false;
|
|
19064
19064
|
const newShape = {};
|
|
19065
19065
|
for (const k of keys) {
|
|
19066
19066
|
const mapped = run2(oldShape[k]);
|
|
19067
19067
|
if (mapped !== oldShape[k])
|
|
19068
|
-
|
|
19068
|
+
changed2 = true;
|
|
19069
19069
|
newShape[k] = mapped;
|
|
19070
19070
|
}
|
|
19071
19071
|
let newCatchall = def.catchall;
|
|
19072
19072
|
if (def.catchall) {
|
|
19073
19073
|
newCatchall = run2(def.catchall);
|
|
19074
19074
|
if (newCatchall !== def.catchall)
|
|
19075
|
-
|
|
19075
|
+
changed2 = true;
|
|
19076
19076
|
}
|
|
19077
|
-
return
|
|
19077
|
+
return changed2 ? clone(s, { ...def, shape: newShape, catchall: newCatchall }) : s;
|
|
19078
19078
|
}
|
|
19079
19079
|
case "array": {
|
|
19080
19080
|
const mapped = run2(def.element);
|
|
@@ -19082,21 +19082,21 @@ function visit(schema, fnOrHandlers) {
|
|
|
19082
19082
|
}
|
|
19083
19083
|
case "tuple": {
|
|
19084
19084
|
const oldItems = def.items;
|
|
19085
|
-
let
|
|
19085
|
+
let changed2 = false;
|
|
19086
19086
|
const newItems = [];
|
|
19087
19087
|
for (const item of oldItems) {
|
|
19088
19088
|
const mapped = run2(item);
|
|
19089
19089
|
if (mapped !== item)
|
|
19090
|
-
|
|
19090
|
+
changed2 = true;
|
|
19091
19091
|
newItems.push(mapped);
|
|
19092
19092
|
}
|
|
19093
19093
|
let newRest = def.rest;
|
|
19094
19094
|
if (def.rest) {
|
|
19095
19095
|
newRest = run2(def.rest);
|
|
19096
19096
|
if (newRest !== def.rest)
|
|
19097
|
-
|
|
19097
|
+
changed2 = true;
|
|
19098
19098
|
}
|
|
19099
|
-
return
|
|
19099
|
+
return changed2 ? clone(s, { ...def, items: newItems, rest: newRest }) : s;
|
|
19100
19100
|
}
|
|
19101
19101
|
case "record":
|
|
19102
19102
|
case "map": {
|
|
@@ -19110,15 +19110,15 @@ function visit(schema, fnOrHandlers) {
|
|
|
19110
19110
|
}
|
|
19111
19111
|
case "union": {
|
|
19112
19112
|
const oldOptions = def.options;
|
|
19113
|
-
let
|
|
19113
|
+
let changed2 = false;
|
|
19114
19114
|
const newOptions = [];
|
|
19115
19115
|
for (const opt of oldOptions) {
|
|
19116
19116
|
const mapped = run2(opt);
|
|
19117
19117
|
if (mapped !== opt)
|
|
19118
|
-
|
|
19118
|
+
changed2 = true;
|
|
19119
19119
|
newOptions.push(mapped);
|
|
19120
19120
|
}
|
|
19121
|
-
return
|
|
19121
|
+
return changed2 ? clone(s, { ...def, options: newOptions }) : s;
|
|
19122
19122
|
}
|
|
19123
19123
|
case "intersection": {
|
|
19124
19124
|
const newLeft = run2(def.left);
|
|
@@ -19568,6 +19568,262 @@ var init_zod = __esm({
|
|
|
19568
19568
|
}
|
|
19569
19569
|
});
|
|
19570
19570
|
|
|
19571
|
+
// ../shared/dist/runtime-v2/workspace.js
|
|
19572
|
+
function isMutatingWorkspaceQuery(request2) {
|
|
19573
|
+
return request2.method === "git.checkpoint" || request2.method === "git.push" || request2.method === "git.prepare_checkout";
|
|
19574
|
+
}
|
|
19575
|
+
var UNSAFE_LINE, CONTROL_CHARACTERS, machinePathSchema, gitShaSchema, gitBranchSchema, gitRemoteNameSchema, gitRemoteUrlSchema, statusFingerprintSchema, singleLineSchema, operationIdSchema, repoTargetShape, trustedRepoTargetShape, workspaceStatusRequestSchema, gitStatusRequestSchema, gitCheckpointRequestSchema, gitPushRequestSchema, gitPrepareCheckoutRequestSchema, gitVerifyHeadRequestSchema, workspaceQueryRequestSchema, WORKSPACE_QUERY_METHODS, workspaceQueryMethodSchema, workspaceStatusValueSchema, gitStatusValueSchema, gitCheckpointValueSchema, gitPushValueSchema, gitPrepareCheckoutValueSchema, gitVerifyHeadValueSchema, WORKSPACE_QUERY_ERROR_CODES, workspaceQueryErrorCodeSchema, publishedGitReceiptSchema, workspaceQueryErrorSchema, resultEnvelopeSchema;
|
|
19576
|
+
var init_workspace = __esm({
|
|
19577
|
+
"../shared/dist/runtime-v2/workspace.js"() {
|
|
19578
|
+
"use strict";
|
|
19579
|
+
init_zod();
|
|
19580
|
+
UNSAFE_LINE = /[\0\r\n]/;
|
|
19581
|
+
CONTROL_CHARACTERS = /[\x00-\x1f\x7f]/;
|
|
19582
|
+
machinePathSchema = external_exports.string().min(1).max(4096).refine((value2) => !UNSAFE_LINE.test(value2), "path contains unsafe characters");
|
|
19583
|
+
gitShaSchema = external_exports.string().regex(/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/, "not a Git SHA");
|
|
19584
|
+
gitBranchSchema = external_exports.string().min(1).max(255).refine((value2) => !value2.startsWith("-") && !value2.startsWith("+") && !value2.includes("..") && !value2.includes("@{") && !value2.endsWith(".lock") && !/[\s~^:?*[\\]/.test(value2) && !CONTROL_CHARACTERS.test(value2), "not a safe Git branch name");
|
|
19585
|
+
gitRemoteNameSchema = external_exports.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/, "not a safe Git remote name");
|
|
19586
|
+
gitRemoteUrlSchema = external_exports.string().min(1).max(2048).refine((value2) => !UNSAFE_LINE.test(value2), "remote URL contains unsafe characters");
|
|
19587
|
+
statusFingerprintSchema = external_exports.string().regex(/^[0-9a-f]{64}$/, "not a status fingerprint");
|
|
19588
|
+
singleLineSchema = (max) => external_exports.string().min(1).max(max).refine((value2) => !CONTROL_CHARACTERS.test(value2), "contains control characters");
|
|
19589
|
+
operationIdSchema = external_exports.guid();
|
|
19590
|
+
repoTargetShape = {
|
|
19591
|
+
path: machinePathSchema,
|
|
19592
|
+
expectedRepoRoot: machinePathSchema.optional(),
|
|
19593
|
+
projectPath: machinePathSchema.optional()
|
|
19594
|
+
};
|
|
19595
|
+
trustedRepoTargetShape = {
|
|
19596
|
+
path: machinePathSchema,
|
|
19597
|
+
expectedRepoRoot: machinePathSchema,
|
|
19598
|
+
projectPath: machinePathSchema
|
|
19599
|
+
};
|
|
19600
|
+
workspaceStatusRequestSchema = external_exports.object({
|
|
19601
|
+
method: external_exports.literal("workspace.status"),
|
|
19602
|
+
path: machinePathSchema
|
|
19603
|
+
});
|
|
19604
|
+
gitStatusRequestSchema = external_exports.object({
|
|
19605
|
+
method: external_exports.literal("git.status"),
|
|
19606
|
+
...repoTargetShape,
|
|
19607
|
+
remote: gitRemoteNameSchema.default("origin"),
|
|
19608
|
+
expectedRemoteUrl: gitRemoteUrlSchema.optional()
|
|
19609
|
+
});
|
|
19610
|
+
gitCheckpointRequestSchema = external_exports.object({
|
|
19611
|
+
method: external_exports.literal("git.checkpoint"),
|
|
19612
|
+
operationId: operationIdSchema,
|
|
19613
|
+
...trustedRepoTargetShape,
|
|
19614
|
+
switchId: singleLineSchema(200),
|
|
19615
|
+
repoKey: singleLineSchema(256),
|
|
19616
|
+
expectedHeadSha: gitShaSchema,
|
|
19617
|
+
expectedBranch: gitBranchSchema,
|
|
19618
|
+
expectedStatusFingerprint: statusFingerprintSchema,
|
|
19619
|
+
expectedProposedTreeSha: gitShaSchema,
|
|
19620
|
+
/** Goes to `git commit-tree` over stdin; newlines carry trailers, NUL is unrepresentable. */
|
|
19621
|
+
commitMessage: external_exports.string().min(1).max(64 * 1024).refine((value2) => !value2.includes("\0") && value2.trim().length > 0, "invalid commit message"),
|
|
19622
|
+
authorName: singleLineSchema(256),
|
|
19623
|
+
authorEmail: singleLineSchema(320).refine((value2) => !/[<>]/.test(value2), "invalid email")
|
|
19624
|
+
});
|
|
19625
|
+
gitPushRequestSchema = external_exports.object({
|
|
19626
|
+
method: external_exports.literal("git.push"),
|
|
19627
|
+
operationId: operationIdSchema,
|
|
19628
|
+
...trustedRepoTargetShape,
|
|
19629
|
+
remote: gitRemoteNameSchema.default("origin"),
|
|
19630
|
+
expectedRemoteUrl: gitRemoteUrlSchema,
|
|
19631
|
+
expectedHeadSha: gitShaSchema,
|
|
19632
|
+
expectedBranch: gitBranchSchema
|
|
19633
|
+
});
|
|
19634
|
+
gitPrepareCheckoutRequestSchema = external_exports.object({
|
|
19635
|
+
method: external_exports.literal("git.prepare_checkout"),
|
|
19636
|
+
operationId: operationIdSchema,
|
|
19637
|
+
...trustedRepoTargetShape,
|
|
19638
|
+
remote: gitRemoteNameSchema.default("origin"),
|
|
19639
|
+
expectedRemoteUrl: gitRemoteUrlSchema,
|
|
19640
|
+
branch: gitBranchSchema,
|
|
19641
|
+
targetSha: gitShaSchema
|
|
19642
|
+
});
|
|
19643
|
+
gitVerifyHeadRequestSchema = external_exports.object({
|
|
19644
|
+
method: external_exports.literal("git.verify_head"),
|
|
19645
|
+
...trustedRepoTargetShape,
|
|
19646
|
+
expectedSha: gitShaSchema
|
|
19647
|
+
});
|
|
19648
|
+
workspaceQueryRequestSchema = external_exports.discriminatedUnion("method", [
|
|
19649
|
+
workspaceStatusRequestSchema,
|
|
19650
|
+
gitStatusRequestSchema,
|
|
19651
|
+
gitCheckpointRequestSchema,
|
|
19652
|
+
gitPushRequestSchema,
|
|
19653
|
+
gitPrepareCheckoutRequestSchema,
|
|
19654
|
+
gitVerifyHeadRequestSchema
|
|
19655
|
+
]);
|
|
19656
|
+
WORKSPACE_QUERY_METHODS = [
|
|
19657
|
+
"workspace.status",
|
|
19658
|
+
"git.status",
|
|
19659
|
+
"git.checkpoint",
|
|
19660
|
+
"git.push",
|
|
19661
|
+
"git.prepare_checkout",
|
|
19662
|
+
"git.verify_head"
|
|
19663
|
+
];
|
|
19664
|
+
workspaceQueryMethodSchema = external_exports.enum(WORKSPACE_QUERY_METHODS);
|
|
19665
|
+
workspaceStatusValueSchema = external_exports.object({
|
|
19666
|
+
repoRoot: machinePathSchema,
|
|
19667
|
+
/** null: detached HEAD. */
|
|
19668
|
+
branch: external_exports.string().nullable(),
|
|
19669
|
+
/** null: unborn branch. */
|
|
19670
|
+
headSha: gitShaSchema.nullable(),
|
|
19671
|
+
dirty: external_exports.boolean(),
|
|
19672
|
+
filesChanged: external_exports.number().int().nonnegative(),
|
|
19673
|
+
ahead: external_exports.number().int().nonnegative().nullable(),
|
|
19674
|
+
behind: external_exports.number().int().nonnegative().nullable(),
|
|
19675
|
+
hasUpstream: external_exports.boolean()
|
|
19676
|
+
});
|
|
19677
|
+
gitStatusValueSchema = workspaceStatusValueSchema.extend({
|
|
19678
|
+
remoteUrl: gitRemoteUrlSchema.nullable(),
|
|
19679
|
+
upstream: external_exports.string().nullable(),
|
|
19680
|
+
statusFingerprint: statusFingerprintSchema,
|
|
19681
|
+
proposedTreeSha: gitShaSchema
|
|
19682
|
+
});
|
|
19683
|
+
gitCheckpointValueSchema = external_exports.object({
|
|
19684
|
+
repoRoot: machinePathSchema,
|
|
19685
|
+
sha: gitShaSchema,
|
|
19686
|
+
replayed: external_exports.boolean()
|
|
19687
|
+
});
|
|
19688
|
+
gitPushValueSchema = external_exports.object({
|
|
19689
|
+
repoRoot: machinePathSchema,
|
|
19690
|
+
pushedSha: gitShaSchema,
|
|
19691
|
+
branch: gitBranchSchema,
|
|
19692
|
+
remote: gitRemoteNameSchema,
|
|
19693
|
+
/** The remote already had the SHA before this push. */
|
|
19694
|
+
replayed: external_exports.boolean()
|
|
19695
|
+
});
|
|
19696
|
+
gitPrepareCheckoutValueSchema = external_exports.object({
|
|
19697
|
+
repoRoot: machinePathSchema,
|
|
19698
|
+
branch: gitBranchSchema,
|
|
19699
|
+
headSha: gitShaSchema,
|
|
19700
|
+
replayed: external_exports.boolean()
|
|
19701
|
+
});
|
|
19702
|
+
gitVerifyHeadValueSchema = external_exports.object({
|
|
19703
|
+
repoRoot: machinePathSchema,
|
|
19704
|
+
headSha: gitShaSchema,
|
|
19705
|
+
verified: external_exports.literal(true)
|
|
19706
|
+
});
|
|
19707
|
+
WORKSPACE_QUERY_ERROR_CODES = [
|
|
19708
|
+
"path_not_approved",
|
|
19709
|
+
"workspace_busy",
|
|
19710
|
+
"workspace_repository_mismatch",
|
|
19711
|
+
"operation_in_progress",
|
|
19712
|
+
"git_not_installed",
|
|
19713
|
+
"runtime_operation_failed",
|
|
19714
|
+
"invalid_git_request",
|
|
19715
|
+
"repository_not_found",
|
|
19716
|
+
"repository_path_changed",
|
|
19717
|
+
"repository_path_not_authorized",
|
|
19718
|
+
"path_canonicalization_failed",
|
|
19719
|
+
"git_status_unreadable",
|
|
19720
|
+
"git_operation_failed",
|
|
19721
|
+
"git_network_timeout",
|
|
19722
|
+
"git_output_limit_exceeded",
|
|
19723
|
+
"git_remote_unavailable",
|
|
19724
|
+
"git_fetch_failed",
|
|
19725
|
+
"git_push_failed",
|
|
19726
|
+
"remote_url_credentials_rejected",
|
|
19727
|
+
"remote_url_mismatch",
|
|
19728
|
+
"source_changed_since_approval",
|
|
19729
|
+
"source_dirty_after_checkpoint",
|
|
19730
|
+
"source_head_unreadable",
|
|
19731
|
+
"checkpoint_empty",
|
|
19732
|
+
"checkpoint_tree_unavailable",
|
|
19733
|
+
"checkpoint_commit_failed",
|
|
19734
|
+
"checkpoint_lock_unavailable",
|
|
19735
|
+
"checkpoint_index_sync_failed",
|
|
19736
|
+
"push_verification_failed",
|
|
19737
|
+
"target_checkout_dirty",
|
|
19738
|
+
"target_checkout_failed",
|
|
19739
|
+
"target_branch_in_use",
|
|
19740
|
+
"target_branch_diverged",
|
|
19741
|
+
"target_fast_forward_failed",
|
|
19742
|
+
"target_verification_failed",
|
|
19743
|
+
"target_sha_mismatch",
|
|
19744
|
+
"target_sha_unavailable",
|
|
19745
|
+
"target_head_unreadable",
|
|
19746
|
+
"verify_head_mismatch"
|
|
19747
|
+
];
|
|
19748
|
+
workspaceQueryErrorCodeSchema = external_exports.enum(WORKSPACE_QUERY_ERROR_CODES);
|
|
19749
|
+
publishedGitReceiptSchema = external_exports.object({
|
|
19750
|
+
pushedSha: gitShaSchema,
|
|
19751
|
+
branch: gitBranchSchema,
|
|
19752
|
+
remote: gitRemoteNameSchema,
|
|
19753
|
+
replayed: external_exports.boolean()
|
|
19754
|
+
});
|
|
19755
|
+
workspaceQueryErrorSchema = external_exports.object({
|
|
19756
|
+
code: workspaceQueryErrorCodeSchema,
|
|
19757
|
+
message: external_exports.string().max(4096),
|
|
19758
|
+
/** Only with source_changed_since_approval after a push: what already reached the remote. */
|
|
19759
|
+
published: publishedGitReceiptSchema.optional()
|
|
19760
|
+
});
|
|
19761
|
+
resultEnvelopeSchema = external_exports.discriminatedUnion("ok", [
|
|
19762
|
+
external_exports.object({ ok: external_exports.literal(true), value: external_exports.unknown() }),
|
|
19763
|
+
external_exports.object({ ok: external_exports.literal(false), error: workspaceQueryErrorSchema })
|
|
19764
|
+
]);
|
|
19765
|
+
}
|
|
19766
|
+
});
|
|
19767
|
+
|
|
19768
|
+
// ../shared/dist/runtime-v2/agent-context.js
|
|
19769
|
+
var AGENT_CONTEXT_VERSION, agentSessionKindSchema, agentTurnTriggerSchema, agentBranchSourceSchema, agentContextRepositorySchema, agentContextBuildSchema, agentContextEnvironmentSchema, agentContextPullRequestSchema, agentContextSchema;
|
|
19770
|
+
var init_agent_context = __esm({
|
|
19771
|
+
"../shared/dist/runtime-v2/agent-context.js"() {
|
|
19772
|
+
"use strict";
|
|
19773
|
+
init_zod();
|
|
19774
|
+
init_workspace();
|
|
19775
|
+
AGENT_CONTEXT_VERSION = 1;
|
|
19776
|
+
agentSessionKindSchema = external_exports.enum(["chat", "task", "workflow", "pr_review"]);
|
|
19777
|
+
agentTurnTriggerSchema = external_exports.enum(["user", "image_build"]);
|
|
19778
|
+
agentBranchSourceSchema = external_exports.enum([
|
|
19779
|
+
"handoff",
|
|
19780
|
+
"pull_request",
|
|
19781
|
+
"task",
|
|
19782
|
+
"chat_selection",
|
|
19783
|
+
"environment_default"
|
|
19784
|
+
]);
|
|
19785
|
+
agentContextRepositorySchema = external_exports.object({
|
|
19786
|
+
name: external_exports.string().min(1).max(200),
|
|
19787
|
+
url: gitRemoteUrlSchema,
|
|
19788
|
+
path: machinePathSchema,
|
|
19789
|
+
branch: gitBranchSchema,
|
|
19790
|
+
branchSource: agentBranchSourceSchema,
|
|
19791
|
+
base: gitBranchSchema
|
|
19792
|
+
});
|
|
19793
|
+
agentContextBuildSchema = external_exports.object({
|
|
19794
|
+
id: external_exports.guid(),
|
|
19795
|
+
status: external_exports.enum(["queued", "running", "succeeded", "failed", "cancelled", "superseded"]),
|
|
19796
|
+
trigger: external_exports.enum(["agent", "base_bumped", "preview", "manual", "push"])
|
|
19797
|
+
});
|
|
19798
|
+
agentContextEnvironmentSchema = external_exports.object({
|
|
19799
|
+
id: external_exports.guid(),
|
|
19800
|
+
name: external_exports.string().min(1).max(200),
|
|
19801
|
+
installCommand: external_exports.string().max(8192).nullable(),
|
|
19802
|
+
startCommand: external_exports.string().max(8192).nullable(),
|
|
19803
|
+
imageBuildId: external_exports.guid().nullable(),
|
|
19804
|
+
/** The newest build when it is not the one sessions boot from. */
|
|
19805
|
+
pendingBuild: agentContextBuildSchema.optional(),
|
|
19806
|
+
/** Saved variable names; values never leave the API. */
|
|
19807
|
+
variables: external_exports.array(external_exports.string().min(1).max(200)).max(200)
|
|
19808
|
+
});
|
|
19809
|
+
agentContextPullRequestSchema = external_exports.object({
|
|
19810
|
+
number: external_exports.number().int().positive(),
|
|
19811
|
+
url: external_exports.string().url().max(2048),
|
|
19812
|
+
head: gitBranchSchema,
|
|
19813
|
+
base: gitBranchSchema
|
|
19814
|
+
});
|
|
19815
|
+
agentContextSchema = external_exports.object({
|
|
19816
|
+
kind: agentSessionKindSchema,
|
|
19817
|
+
trigger: agentTurnTriggerSchema,
|
|
19818
|
+
organizationId: external_exports.guid(),
|
|
19819
|
+
taskWorkingBranch: gitBranchSchema.optional(),
|
|
19820
|
+
pullRequest: agentContextPullRequestSchema.optional(),
|
|
19821
|
+
repositories: external_exports.array(agentContextRepositorySchema).max(64),
|
|
19822
|
+
environment: agentContextEnvironmentSchema.optional()
|
|
19823
|
+
});
|
|
19824
|
+
}
|
|
19825
|
+
});
|
|
19826
|
+
|
|
19571
19827
|
// ../shared/dist/skills/domain.js
|
|
19572
19828
|
var SKILLS_PROTOCOL_VERSION, SKILL_PACKAGE_LIMITS;
|
|
19573
19829
|
var init_domain = __esm({
|
|
@@ -20114,203 +20370,6 @@ var init_run_context = __esm({
|
|
|
20114
20370
|
}
|
|
20115
20371
|
});
|
|
20116
20372
|
|
|
20117
|
-
// ../shared/dist/runtime-v2/workspace.js
|
|
20118
|
-
function isMutatingWorkspaceQuery(request2) {
|
|
20119
|
-
return request2.method === "git.checkpoint" || request2.method === "git.push" || request2.method === "git.prepare_checkout";
|
|
20120
|
-
}
|
|
20121
|
-
var UNSAFE_LINE, CONTROL_CHARACTERS, machinePathSchema, gitShaSchema, gitBranchSchema, gitRemoteNameSchema, gitRemoteUrlSchema, statusFingerprintSchema, singleLineSchema, operationIdSchema, repoTargetShape, trustedRepoTargetShape, workspaceStatusRequestSchema, gitStatusRequestSchema, gitCheckpointRequestSchema, gitPushRequestSchema, gitPrepareCheckoutRequestSchema, gitVerifyHeadRequestSchema, workspaceQueryRequestSchema, WORKSPACE_QUERY_METHODS, workspaceQueryMethodSchema, workspaceStatusValueSchema, gitStatusValueSchema, gitCheckpointValueSchema, gitPushValueSchema, gitPrepareCheckoutValueSchema, gitVerifyHeadValueSchema, WORKSPACE_QUERY_ERROR_CODES, workspaceQueryErrorCodeSchema, publishedGitReceiptSchema, workspaceQueryErrorSchema, resultEnvelopeSchema;
|
|
20122
|
-
var init_workspace = __esm({
|
|
20123
|
-
"../shared/dist/runtime-v2/workspace.js"() {
|
|
20124
|
-
"use strict";
|
|
20125
|
-
init_zod();
|
|
20126
|
-
UNSAFE_LINE = /[\0\r\n]/;
|
|
20127
|
-
CONTROL_CHARACTERS = /[\x00-\x1f\x7f]/;
|
|
20128
|
-
machinePathSchema = external_exports.string().min(1).max(4096).refine((value2) => !UNSAFE_LINE.test(value2), "path contains unsafe characters");
|
|
20129
|
-
gitShaSchema = external_exports.string().regex(/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/, "not a Git SHA");
|
|
20130
|
-
gitBranchSchema = external_exports.string().min(1).max(255).refine((value2) => !value2.startsWith("-") && !value2.startsWith("+") && !value2.includes("..") && !value2.includes("@{") && !value2.endsWith(".lock") && !/[\s~^:?*[\\]/.test(value2) && !CONTROL_CHARACTERS.test(value2), "not a safe Git branch name");
|
|
20131
|
-
gitRemoteNameSchema = external_exports.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/, "not a safe Git remote name");
|
|
20132
|
-
gitRemoteUrlSchema = external_exports.string().min(1).max(2048).refine((value2) => !UNSAFE_LINE.test(value2), "remote URL contains unsafe characters");
|
|
20133
|
-
statusFingerprintSchema = external_exports.string().regex(/^[0-9a-f]{64}$/, "not a status fingerprint");
|
|
20134
|
-
singleLineSchema = (max) => external_exports.string().min(1).max(max).refine((value2) => !CONTROL_CHARACTERS.test(value2), "contains control characters");
|
|
20135
|
-
operationIdSchema = external_exports.guid();
|
|
20136
|
-
repoTargetShape = {
|
|
20137
|
-
path: machinePathSchema,
|
|
20138
|
-
expectedRepoRoot: machinePathSchema.optional(),
|
|
20139
|
-
projectPath: machinePathSchema.optional()
|
|
20140
|
-
};
|
|
20141
|
-
trustedRepoTargetShape = {
|
|
20142
|
-
path: machinePathSchema,
|
|
20143
|
-
expectedRepoRoot: machinePathSchema,
|
|
20144
|
-
projectPath: machinePathSchema
|
|
20145
|
-
};
|
|
20146
|
-
workspaceStatusRequestSchema = external_exports.object({
|
|
20147
|
-
method: external_exports.literal("workspace.status"),
|
|
20148
|
-
path: machinePathSchema
|
|
20149
|
-
});
|
|
20150
|
-
gitStatusRequestSchema = external_exports.object({
|
|
20151
|
-
method: external_exports.literal("git.status"),
|
|
20152
|
-
...repoTargetShape,
|
|
20153
|
-
remote: gitRemoteNameSchema.default("origin"),
|
|
20154
|
-
expectedRemoteUrl: gitRemoteUrlSchema.optional()
|
|
20155
|
-
});
|
|
20156
|
-
gitCheckpointRequestSchema = external_exports.object({
|
|
20157
|
-
method: external_exports.literal("git.checkpoint"),
|
|
20158
|
-
operationId: operationIdSchema,
|
|
20159
|
-
...trustedRepoTargetShape,
|
|
20160
|
-
switchId: singleLineSchema(200),
|
|
20161
|
-
repoKey: singleLineSchema(256),
|
|
20162
|
-
expectedHeadSha: gitShaSchema,
|
|
20163
|
-
expectedBranch: gitBranchSchema,
|
|
20164
|
-
expectedStatusFingerprint: statusFingerprintSchema,
|
|
20165
|
-
expectedProposedTreeSha: gitShaSchema,
|
|
20166
|
-
/** Goes to `git commit-tree` over stdin; newlines carry trailers, NUL is unrepresentable. */
|
|
20167
|
-
commitMessage: external_exports.string().min(1).max(64 * 1024).refine((value2) => !value2.includes("\0") && value2.trim().length > 0, "invalid commit message"),
|
|
20168
|
-
authorName: singleLineSchema(256),
|
|
20169
|
-
authorEmail: singleLineSchema(320).refine((value2) => !/[<>]/.test(value2), "invalid email")
|
|
20170
|
-
});
|
|
20171
|
-
gitPushRequestSchema = external_exports.object({
|
|
20172
|
-
method: external_exports.literal("git.push"),
|
|
20173
|
-
operationId: operationIdSchema,
|
|
20174
|
-
...trustedRepoTargetShape,
|
|
20175
|
-
remote: gitRemoteNameSchema.default("origin"),
|
|
20176
|
-
expectedRemoteUrl: gitRemoteUrlSchema,
|
|
20177
|
-
expectedHeadSha: gitShaSchema,
|
|
20178
|
-
expectedBranch: gitBranchSchema
|
|
20179
|
-
});
|
|
20180
|
-
gitPrepareCheckoutRequestSchema = external_exports.object({
|
|
20181
|
-
method: external_exports.literal("git.prepare_checkout"),
|
|
20182
|
-
operationId: operationIdSchema,
|
|
20183
|
-
...trustedRepoTargetShape,
|
|
20184
|
-
remote: gitRemoteNameSchema.default("origin"),
|
|
20185
|
-
expectedRemoteUrl: gitRemoteUrlSchema,
|
|
20186
|
-
branch: gitBranchSchema,
|
|
20187
|
-
targetSha: gitShaSchema
|
|
20188
|
-
});
|
|
20189
|
-
gitVerifyHeadRequestSchema = external_exports.object({
|
|
20190
|
-
method: external_exports.literal("git.verify_head"),
|
|
20191
|
-
...trustedRepoTargetShape,
|
|
20192
|
-
expectedSha: gitShaSchema
|
|
20193
|
-
});
|
|
20194
|
-
workspaceQueryRequestSchema = external_exports.discriminatedUnion("method", [
|
|
20195
|
-
workspaceStatusRequestSchema,
|
|
20196
|
-
gitStatusRequestSchema,
|
|
20197
|
-
gitCheckpointRequestSchema,
|
|
20198
|
-
gitPushRequestSchema,
|
|
20199
|
-
gitPrepareCheckoutRequestSchema,
|
|
20200
|
-
gitVerifyHeadRequestSchema
|
|
20201
|
-
]);
|
|
20202
|
-
WORKSPACE_QUERY_METHODS = [
|
|
20203
|
-
"workspace.status",
|
|
20204
|
-
"git.status",
|
|
20205
|
-
"git.checkpoint",
|
|
20206
|
-
"git.push",
|
|
20207
|
-
"git.prepare_checkout",
|
|
20208
|
-
"git.verify_head"
|
|
20209
|
-
];
|
|
20210
|
-
workspaceQueryMethodSchema = external_exports.enum(WORKSPACE_QUERY_METHODS);
|
|
20211
|
-
workspaceStatusValueSchema = external_exports.object({
|
|
20212
|
-
repoRoot: machinePathSchema,
|
|
20213
|
-
/** null: detached HEAD. */
|
|
20214
|
-
branch: external_exports.string().nullable(),
|
|
20215
|
-
/** null: unborn branch. */
|
|
20216
|
-
headSha: gitShaSchema.nullable(),
|
|
20217
|
-
dirty: external_exports.boolean(),
|
|
20218
|
-
filesChanged: external_exports.number().int().nonnegative(),
|
|
20219
|
-
ahead: external_exports.number().int().nonnegative().nullable(),
|
|
20220
|
-
behind: external_exports.number().int().nonnegative().nullable(),
|
|
20221
|
-
hasUpstream: external_exports.boolean()
|
|
20222
|
-
});
|
|
20223
|
-
gitStatusValueSchema = workspaceStatusValueSchema.extend({
|
|
20224
|
-
remoteUrl: gitRemoteUrlSchema.nullable(),
|
|
20225
|
-
upstream: external_exports.string().nullable(),
|
|
20226
|
-
statusFingerprint: statusFingerprintSchema,
|
|
20227
|
-
proposedTreeSha: gitShaSchema
|
|
20228
|
-
});
|
|
20229
|
-
gitCheckpointValueSchema = external_exports.object({
|
|
20230
|
-
repoRoot: machinePathSchema,
|
|
20231
|
-
sha: gitShaSchema,
|
|
20232
|
-
replayed: external_exports.boolean()
|
|
20233
|
-
});
|
|
20234
|
-
gitPushValueSchema = external_exports.object({
|
|
20235
|
-
repoRoot: machinePathSchema,
|
|
20236
|
-
pushedSha: gitShaSchema,
|
|
20237
|
-
branch: gitBranchSchema,
|
|
20238
|
-
remote: gitRemoteNameSchema,
|
|
20239
|
-
/** The remote already had the SHA before this push. */
|
|
20240
|
-
replayed: external_exports.boolean()
|
|
20241
|
-
});
|
|
20242
|
-
gitPrepareCheckoutValueSchema = external_exports.object({
|
|
20243
|
-
repoRoot: machinePathSchema,
|
|
20244
|
-
branch: gitBranchSchema,
|
|
20245
|
-
headSha: gitShaSchema,
|
|
20246
|
-
replayed: external_exports.boolean()
|
|
20247
|
-
});
|
|
20248
|
-
gitVerifyHeadValueSchema = external_exports.object({
|
|
20249
|
-
repoRoot: machinePathSchema,
|
|
20250
|
-
headSha: gitShaSchema,
|
|
20251
|
-
verified: external_exports.literal(true)
|
|
20252
|
-
});
|
|
20253
|
-
WORKSPACE_QUERY_ERROR_CODES = [
|
|
20254
|
-
"path_not_approved",
|
|
20255
|
-
"workspace_busy",
|
|
20256
|
-
"workspace_repository_mismatch",
|
|
20257
|
-
"operation_in_progress",
|
|
20258
|
-
"git_not_installed",
|
|
20259
|
-
"runtime_operation_failed",
|
|
20260
|
-
"invalid_git_request",
|
|
20261
|
-
"repository_not_found",
|
|
20262
|
-
"repository_path_changed",
|
|
20263
|
-
"repository_path_not_authorized",
|
|
20264
|
-
"path_canonicalization_failed",
|
|
20265
|
-
"git_status_unreadable",
|
|
20266
|
-
"git_operation_failed",
|
|
20267
|
-
"git_network_timeout",
|
|
20268
|
-
"git_output_limit_exceeded",
|
|
20269
|
-
"git_remote_unavailable",
|
|
20270
|
-
"git_fetch_failed",
|
|
20271
|
-
"git_push_failed",
|
|
20272
|
-
"remote_url_credentials_rejected",
|
|
20273
|
-
"remote_url_mismatch",
|
|
20274
|
-
"source_changed_since_approval",
|
|
20275
|
-
"source_dirty_after_checkpoint",
|
|
20276
|
-
"source_head_unreadable",
|
|
20277
|
-
"checkpoint_empty",
|
|
20278
|
-
"checkpoint_tree_unavailable",
|
|
20279
|
-
"checkpoint_commit_failed",
|
|
20280
|
-
"checkpoint_lock_unavailable",
|
|
20281
|
-
"checkpoint_index_sync_failed",
|
|
20282
|
-
"push_verification_failed",
|
|
20283
|
-
"target_checkout_dirty",
|
|
20284
|
-
"target_checkout_failed",
|
|
20285
|
-
"target_branch_in_use",
|
|
20286
|
-
"target_branch_diverged",
|
|
20287
|
-
"target_fast_forward_failed",
|
|
20288
|
-
"target_verification_failed",
|
|
20289
|
-
"target_sha_mismatch",
|
|
20290
|
-
"target_sha_unavailable",
|
|
20291
|
-
"target_head_unreadable",
|
|
20292
|
-
"verify_head_mismatch"
|
|
20293
|
-
];
|
|
20294
|
-
workspaceQueryErrorCodeSchema = external_exports.enum(WORKSPACE_QUERY_ERROR_CODES);
|
|
20295
|
-
publishedGitReceiptSchema = external_exports.object({
|
|
20296
|
-
pushedSha: gitShaSchema,
|
|
20297
|
-
branch: gitBranchSchema,
|
|
20298
|
-
remote: gitRemoteNameSchema,
|
|
20299
|
-
replayed: external_exports.boolean()
|
|
20300
|
-
});
|
|
20301
|
-
workspaceQueryErrorSchema = external_exports.object({
|
|
20302
|
-
code: workspaceQueryErrorCodeSchema,
|
|
20303
|
-
message: external_exports.string().max(4096),
|
|
20304
|
-
/** Only with source_changed_since_approval after a push: what already reached the remote. */
|
|
20305
|
-
published: publishedGitReceiptSchema.optional()
|
|
20306
|
-
});
|
|
20307
|
-
resultEnvelopeSchema = external_exports.discriminatedUnion("ok", [
|
|
20308
|
-
external_exports.object({ ok: external_exports.literal(true), value: external_exports.unknown() }),
|
|
20309
|
-
external_exports.object({ ok: external_exports.literal(false), error: workspaceQueryErrorSchema })
|
|
20310
|
-
]);
|
|
20311
|
-
}
|
|
20312
|
-
});
|
|
20313
|
-
|
|
20314
20373
|
// ../shared/dist/runtime-v2/desired-state.js
|
|
20315
20374
|
var repoLocalPathSchema, requestedCheckoutSchema, runSpecSchema, desiredRunSchema, desiredStateSchema;
|
|
20316
20375
|
var init_desired_state = __esm({
|
|
@@ -20318,6 +20377,7 @@ var init_desired_state = __esm({
|
|
|
20318
20377
|
"use strict";
|
|
20319
20378
|
init_zod();
|
|
20320
20379
|
init_contracts();
|
|
20380
|
+
init_agent_context();
|
|
20321
20381
|
init_ids();
|
|
20322
20382
|
init_run_context();
|
|
20323
20383
|
init_workspace();
|
|
@@ -20352,6 +20412,7 @@ var init_desired_state = __esm({
|
|
|
20352
20412
|
repoLocalPaths: external_exports.array(repoLocalPathSchema).optional(),
|
|
20353
20413
|
/** Applied once, at the conversation's first turn on a cloud sandbox; never moves local work. */
|
|
20354
20414
|
requestedCheckouts: external_exports.array(requestedCheckoutSchema).max(64).optional(),
|
|
20415
|
+
agentContext: agentContextSchema.optional(),
|
|
20355
20416
|
workflowId: external_exports.guid().optional(),
|
|
20356
20417
|
workflowExecutionId: external_exports.guid().optional(),
|
|
20357
20418
|
agentId: external_exports.string().min(1).optional(),
|
|
@@ -21421,6 +21482,7 @@ var init_skills = __esm({
|
|
|
21421
21482
|
var init_runtime_v2 = __esm({
|
|
21422
21483
|
"../shared/dist/runtime-v2/index.js"() {
|
|
21423
21484
|
"use strict";
|
|
21485
|
+
init_agent_context();
|
|
21424
21486
|
init_capabilities();
|
|
21425
21487
|
init_desired_state();
|
|
21426
21488
|
init_git_capability();
|
|
@@ -22315,7 +22377,7 @@ var init_agent = __esm({
|
|
|
22315
22377
|
|
|
22316
22378
|
// ../shared/dist/agent/transcript/preview.js
|
|
22317
22379
|
function toPreviewText(value2, limit) {
|
|
22318
|
-
const text3 = value2.replace(/```[\s\S]*?```/g, (
|
|
22380
|
+
const text3 = value2.replace(/```[\s\S]*?```/g, (block2) => block2.replace(/```\w*\n?|```/g, " ")).replace(/!\[[^\]]*\]\([^)]*\)/g, "").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").replace(/`([^`]+)`/g, "$1").replace(/^\s{0,3}#{1,6}\s+/gm, "").replace(/^\s{0,3}>\s?/gm, "").replace(/^\s{0,3}(?:[-*+]|\d+\.)\s+/gm, "").replace(/^\s{0,3}(?:[-*_]\s*){3,}$/gm, "").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/__([^_]+)__/g, "$1").replace(/\*([^*\n]+)\*/g, "$1").replace(/~~([^~]+)~~/g, "$1").replace(/\s+/g, " ").trim();
|
|
22319
22381
|
if (text3.length <= limit)
|
|
22320
22382
|
return text3;
|
|
22321
22383
|
const clipped = text3.slice(0, limit - 1);
|
|
@@ -22682,8 +22744,8 @@ function decode3(bytes, start, end) {
|
|
|
22682
22744
|
}
|
|
22683
22745
|
async function linuxStartTicks(pid) {
|
|
22684
22746
|
try {
|
|
22685
|
-
const
|
|
22686
|
-
const fields =
|
|
22747
|
+
const stat23 = await (0, import_promises9.readFile)(`/proc/${pid}/stat`, "utf8");
|
|
22748
|
+
const fields = stat23.slice(stat23.lastIndexOf(")") + 2).split(" ");
|
|
22687
22749
|
return fields[19];
|
|
22688
22750
|
} catch {
|
|
22689
22751
|
return void 0;
|
|
@@ -24125,7 +24187,7 @@ function toolEdits(node2) {
|
|
|
24125
24187
|
const content = node2.event.update.content;
|
|
24126
24188
|
if (!Array.isArray(content))
|
|
24127
24189
|
return [];
|
|
24128
|
-
return content.flatMap((
|
|
24190
|
+
return content.flatMap((block2, index) => isRecord7(block2) && block2.type === "diff" ? readDiff(block2.diff, `${node2.key}:${index}`) : []);
|
|
24129
24191
|
}
|
|
24130
24192
|
function shellCommand(node2) {
|
|
24131
24193
|
const input2 = node2.event.update.rawInput;
|
|
@@ -24231,7 +24293,7 @@ function resultText(node2) {
|
|
|
24231
24293
|
const { rawOutput, content } = node2.event.update;
|
|
24232
24294
|
if (typeof rawOutput === "string" && rawOutput.trim())
|
|
24233
24295
|
return rawOutput;
|
|
24234
|
-
return (Array.isArray(content) ? content : []).map((
|
|
24296
|
+
return (Array.isArray(content) ? content : []).map((block2) => isRecord7(block2) && block2.type === "content" ? block2.content : block2).map((block2) => isRecord7(block2) && typeof block2.text === "string" ? block2.text : "").join("");
|
|
24235
24297
|
}
|
|
24236
24298
|
function parseRecord(value2) {
|
|
24237
24299
|
try {
|
|
@@ -24376,9 +24438,9 @@ function attachChildren(nodes) {
|
|
|
24376
24438
|
const u = node2.event.update;
|
|
24377
24439
|
if (typeof u.toolCallId === "string")
|
|
24378
24440
|
tools.set(u.toolCallId, node2);
|
|
24379
|
-
for (const
|
|
24380
|
-
if (isRecord7(
|
|
24381
|
-
terminals.set(
|
|
24441
|
+
for (const block2 of Array.isArray(u.content) ? u.content : []) {
|
|
24442
|
+
if (isRecord7(block2) && block2.type === "terminal" && typeof block2.terminalId === "string")
|
|
24443
|
+
terminals.set(block2.terminalId, node2);
|
|
24382
24444
|
}
|
|
24383
24445
|
}
|
|
24384
24446
|
const parents = /* @__PURE__ */ new Map();
|
|
@@ -24416,11 +24478,11 @@ function turnStart(turn) {
|
|
|
24416
24478
|
}
|
|
24417
24479
|
function hasAnswerContent(node2) {
|
|
24418
24480
|
const content = node2.event.update.content;
|
|
24419
|
-
return Array.isArray(content) && content.some((
|
|
24481
|
+
return Array.isArray(content) && content.some((block2) => isRecord7(block2) && (block2.type !== "text" || typeof block2.text === "string" && block2.text.trim().length > 0));
|
|
24420
24482
|
}
|
|
24421
24483
|
function messageText(node2) {
|
|
24422
24484
|
const content = node2.event.update.content;
|
|
24423
|
-
return Array.isArray(content) ? content.flatMap((
|
|
24485
|
+
return Array.isArray(content) ? content.flatMap((block2) => isRecord7(block2) && block2.type === "text" && typeof block2.text === "string" ? [block2.text] : []).join("") : "";
|
|
24424
24486
|
}
|
|
24425
24487
|
function prepareConversationTurns(transcript, streaming, previousTurns = []) {
|
|
24426
24488
|
const entries = Array.isArray(transcript.entries) ? transcript.entries : [];
|
|
@@ -24779,9 +24841,9 @@ function applyContent(state, index, update) {
|
|
|
24779
24841
|
}
|
|
24780
24842
|
entry.lastUpdateIndex = state.updateCount;
|
|
24781
24843
|
if (update.sessionUpdate.endsWith("_chunk")) {
|
|
24782
|
-
const
|
|
24783
|
-
if (
|
|
24784
|
-
entry.content.push(
|
|
24844
|
+
const block2 = update.content;
|
|
24845
|
+
if (block2)
|
|
24846
|
+
entry.content.push(block2);
|
|
24785
24847
|
} else {
|
|
24786
24848
|
const content = update.content;
|
|
24787
24849
|
if (content !== void 0) {
|
|
@@ -24827,9 +24889,9 @@ function applyTool(state, index, update) {
|
|
|
24827
24889
|
}
|
|
24828
24890
|
entry.lastUpdateIndex = state.updateCount;
|
|
24829
24891
|
if (update.sessionUpdate === "tool_call_content_chunk") {
|
|
24830
|
-
const
|
|
24831
|
-
if (
|
|
24832
|
-
entry.content.push(
|
|
24892
|
+
const block2 = update.content;
|
|
24893
|
+
if (block2)
|
|
24894
|
+
entry.content.push(block2);
|
|
24833
24895
|
return;
|
|
24834
24896
|
}
|
|
24835
24897
|
const u = update;
|
|
@@ -24889,8 +24951,8 @@ function toolContentText(content) {
|
|
|
24889
24951
|
if (!Array.isArray(content))
|
|
24890
24952
|
return null;
|
|
24891
24953
|
const parts4 = [];
|
|
24892
|
-
for (const
|
|
24893
|
-
const inner = isRecord8(
|
|
24954
|
+
for (const block2 of content) {
|
|
24955
|
+
const inner = isRecord8(block2) && block2.type === "content" ? block2.content : block2;
|
|
24894
24956
|
if (!isRecord8(inner) || typeof inner.text !== "string")
|
|
24895
24957
|
return null;
|
|
24896
24958
|
parts4.push(inner.text);
|
|
@@ -24942,13 +25004,13 @@ function rendersBesideSteps(update) {
|
|
|
24942
25004
|
const meta3 = isRecord8(update._meta) ? update._meta : {};
|
|
24943
25005
|
return parsedFromRawOutput(update) || meta3["alan.dev/subagentLauncher"] !== void 0 || meta3["alan.dev/backgroundTask"] !== void 0;
|
|
24944
25006
|
}
|
|
24945
|
-
function diffWithoutText(
|
|
24946
|
-
const inner = isRecord8(
|
|
25007
|
+
function diffWithoutText(block2) {
|
|
25008
|
+
const inner = isRecord8(block2) && block2.type === "content" ? block2.content : block2;
|
|
24947
25009
|
if (!isRecord8(inner) || inner.type !== "diff")
|
|
24948
25010
|
return null;
|
|
24949
25011
|
const path4 = typeof inner.path === "string" ? { path: inner.path } : {};
|
|
24950
25012
|
const stub = { type: "diff", ...path4 };
|
|
24951
|
-
return isRecord8(
|
|
25013
|
+
return isRecord8(block2) && block2.type === "content" ? { ...block2, content: stub } : stub;
|
|
24952
25014
|
}
|
|
24953
25015
|
function stepSummary(node2) {
|
|
24954
25016
|
const update = node2.event.update;
|
|
@@ -24960,7 +25022,7 @@ function stepSummary(node2) {
|
|
|
24960
25022
|
if (update.sessionUpdate !== "tool_call_update" || rendersBesideSteps(update))
|
|
24961
25023
|
return { ...node2, children };
|
|
24962
25024
|
const { content, rawOutput: _rawOutput, ...rest } = update;
|
|
24963
|
-
const diffs = (Array.isArray(content) ? content : []).map(diffWithoutText).filter((
|
|
25025
|
+
const diffs = (Array.isArray(content) ? content : []).map(diffWithoutText).filter((block2) => block2 !== null);
|
|
24964
25026
|
return {
|
|
24965
25027
|
...node2,
|
|
24966
25028
|
event: { ...node2.event, update: diffs.length > 0 ? { ...rest, content: diffs } : rest },
|
|
@@ -25223,7 +25285,7 @@ function isRecord9(value2) {
|
|
|
25223
25285
|
function scopedContent(value2, turnId) {
|
|
25224
25286
|
if (!Array.isArray(value2))
|
|
25225
25287
|
return value2;
|
|
25226
|
-
return value2.map((
|
|
25288
|
+
return value2.map((block2) => isRecord9(block2) && block2.type === "terminal" && typeof block2.terminalId === "string" ? { ...block2, terminalId: `${turnId}:${block2.terminalId}` } : block2);
|
|
25227
25289
|
}
|
|
25228
25290
|
function scopeTranscriptEvent(value2) {
|
|
25229
25291
|
if (!isRecord9(value2) || !Number.isSafeInteger(value2.seq) || !Number.isFinite(value2.at))
|
|
@@ -26552,8 +26614,8 @@ function readMediaFiles(candidates2, cwd, mimeByExt, maxBytes) {
|
|
|
26552
26614
|
seen.add(path4);
|
|
26553
26615
|
const mimeType = mimeByExt[(0, import_path3.extname)(path4).toLowerCase()];
|
|
26554
26616
|
if (!mimeType) continue;
|
|
26555
|
-
const
|
|
26556
|
-
if (!
|
|
26617
|
+
const stat23 = (0, import_fs4.statSync)(path4);
|
|
26618
|
+
if (!stat23.isFile() || stat23.size <= 0 || stat23.size > maxBytes) continue;
|
|
26557
26619
|
files.push({ path: path4, mimeType, buffer: (0, import_fs4.readFileSync)(path4) });
|
|
26558
26620
|
}
|
|
26559
26621
|
return files;
|
|
@@ -27298,7 +27360,259 @@ var init_chunk_J2KTV5FP = __esm({
|
|
|
27298
27360
|
}
|
|
27299
27361
|
});
|
|
27300
27362
|
|
|
27301
|
-
// ../agent-core/dist/chunk-
|
|
27363
|
+
// ../agent-core/dist/chunk-GI3ZGXTY.js
|
|
27364
|
+
function repositories(input2, context) {
|
|
27365
|
+
const problems = new Map(input2.problems.map((problem) => [problem.path, problem]));
|
|
27366
|
+
const listed = context?.repositories ?? [];
|
|
27367
|
+
const known = new Set(listed.map((repository) => repository.path));
|
|
27368
|
+
const unlisted = input2.problems.filter((problem) => !known.has(problem.path));
|
|
27369
|
+
return [
|
|
27370
|
+
...listed.map((repository) => {
|
|
27371
|
+
const problem = problems.get(repository.path);
|
|
27372
|
+
return {
|
|
27373
|
+
path: repository.path,
|
|
27374
|
+
name: repository.name,
|
|
27375
|
+
url: repository.url,
|
|
27376
|
+
branch: repository.branch,
|
|
27377
|
+
branchSource: repository.branchSource,
|
|
27378
|
+
base: repository.base,
|
|
27379
|
+
checkout: problem ? "needs_attention" : "ok",
|
|
27380
|
+
...problem ? { problem: problem.problem, action: problem.action } : {}
|
|
27381
|
+
};
|
|
27382
|
+
}),
|
|
27383
|
+
...unlisted.map(
|
|
27384
|
+
(problem) => ({
|
|
27385
|
+
path: problem.path,
|
|
27386
|
+
checkout: "needs_attention",
|
|
27387
|
+
problem: problem.problem,
|
|
27388
|
+
action: problem.action
|
|
27389
|
+
})
|
|
27390
|
+
)
|
|
27391
|
+
];
|
|
27392
|
+
}
|
|
27393
|
+
function branchInstruction(repository) {
|
|
27394
|
+
const { path: path4, branch, branchSource } = repository;
|
|
27395
|
+
if (!branch || !branchSource) return void 0;
|
|
27396
|
+
const reason = BRANCH_REASONS[branchSource];
|
|
27397
|
+
if (branchSource === "task") {
|
|
27398
|
+
return `Commit work in ${path4} on ${branch}, ${reason}; create it from ${repository.base ?? "the default branch"} if it does not exist.`;
|
|
27399
|
+
}
|
|
27400
|
+
return `Work in ${path4} on ${branch}, ${reason}.`;
|
|
27401
|
+
}
|
|
27402
|
+
function repositoryInstructions(repository) {
|
|
27403
|
+
const problem = repository.problem && repository.action ? `${repository.path} ${repository.problem}. ${repository.action} before relying on its files.` : void 0;
|
|
27404
|
+
const branch = problem && repository.branchSource !== "environment_default" ? void 0 : branchInstruction(repository);
|
|
27405
|
+
return [branch, problem].filter((line) => line !== void 0);
|
|
27406
|
+
}
|
|
27407
|
+
function environmentInstructions(environment, cwd) {
|
|
27408
|
+
const lines2 = [];
|
|
27409
|
+
const start = environment.start;
|
|
27410
|
+
if (start?.state === "failed") {
|
|
27411
|
+
lines2.push(
|
|
27412
|
+
`The start command exited with code ${start.exitCode}. Read ${start.log}, fix the cause, then run the start command from ${cwd} before testing the app.`
|
|
27413
|
+
);
|
|
27414
|
+
} else if (start?.state === "pending") {
|
|
27415
|
+
lines2.push(`The start command is still starting; check ${start.log} before testing the app.`);
|
|
27416
|
+
}
|
|
27417
|
+
const build = environment.pendingBuild;
|
|
27418
|
+
if (build?.status === "queued" || build?.status === "running") {
|
|
27419
|
+
lines2.push(
|
|
27420
|
+
`Image build ${build.id} is ${build.status}; its result arrives as a message, so do not poll for it.`
|
|
27421
|
+
);
|
|
27422
|
+
} else if (build?.status === "failed") {
|
|
27423
|
+
lines2.push(
|
|
27424
|
+
`The latest image build (${build.id}) failed; sessions still boot from the previous image.`
|
|
27425
|
+
);
|
|
27426
|
+
}
|
|
27427
|
+
if (environment.variables.length > 0) {
|
|
27428
|
+
lines2.push("Saved variables are set in this sandbox; never print or commit their values.");
|
|
27429
|
+
}
|
|
27430
|
+
return lines2;
|
|
27431
|
+
}
|
|
27432
|
+
function instructionsFor(snapshot2) {
|
|
27433
|
+
const cwd = snapshot2.workspace.cwd ?? snapshot2.workspace.root ?? "the workspace";
|
|
27434
|
+
return [
|
|
27435
|
+
...snapshot2.session.trigger === "image_build" ? ["Alan sent this turn, not the user: it reports an image build result."] : [],
|
|
27436
|
+
...snapshot2.environment ? environmentInstructions(snapshot2.environment, cwd) : []
|
|
27437
|
+
];
|
|
27438
|
+
}
|
|
27439
|
+
function startingInstructions(snapshot2) {
|
|
27440
|
+
const cwd = snapshot2.workspace.cwd ?? snapshot2.workspace.root;
|
|
27441
|
+
return [
|
|
27442
|
+
...cwd ? [`Work from ${cwd}.`] : [],
|
|
27443
|
+
...snapshot2.workspace.repositories.flatMap(repositoryInstructions)
|
|
27444
|
+
];
|
|
27445
|
+
}
|
|
27446
|
+
function sessionKind(input2, context) {
|
|
27447
|
+
if (context) return context.kind;
|
|
27448
|
+
if (input2.spec.workflowExecutionId) return "workflow";
|
|
27449
|
+
return input2.spec.taskId ? "task" : "chat";
|
|
27450
|
+
}
|
|
27451
|
+
function environmentOf(input2, context) {
|
|
27452
|
+
const environment = context?.environment;
|
|
27453
|
+
if (!environment) return void 0;
|
|
27454
|
+
const start = environment.startCommand === null ? { state: "not_configured" } : input2.start;
|
|
27455
|
+
return {
|
|
27456
|
+
id: environment.id,
|
|
27457
|
+
name: environment.name,
|
|
27458
|
+
installCommand: environment.installCommand,
|
|
27459
|
+
startCommand: environment.startCommand,
|
|
27460
|
+
imageBuildId: environment.imageBuildId,
|
|
27461
|
+
...environment.pendingBuild ? { pendingBuild: environment.pendingBuild } : {},
|
|
27462
|
+
variables: environment.variables,
|
|
27463
|
+
...start ? { start: start.state === "not_configured" ? start : { ...start, log: input2.startLogPath } } : {}
|
|
27464
|
+
};
|
|
27465
|
+
}
|
|
27466
|
+
function knownContext(snapshot2) {
|
|
27467
|
+
const organizationId = snapshot2?.session.organizationId;
|
|
27468
|
+
if (!snapshot2 || !organizationId) return void 0;
|
|
27469
|
+
const environment = snapshot2.environment;
|
|
27470
|
+
return {
|
|
27471
|
+
kind: snapshot2.session.kind,
|
|
27472
|
+
trigger: "user",
|
|
27473
|
+
organizationId,
|
|
27474
|
+
...snapshot2.task ? { taskWorkingBranch: snapshot2.task.workingBranch } : {},
|
|
27475
|
+
...snapshot2.pullRequest ? { pullRequest: snapshot2.pullRequest } : {},
|
|
27476
|
+
repositories: snapshot2.workspace.repositories.flatMap(
|
|
27477
|
+
({ path: path4, name, url: url3, branch, branchSource, base }) => name && url3 && branch && branchSource && base ? [{ path: path4, name, url: url3, branch, branchSource, base }] : []
|
|
27478
|
+
),
|
|
27479
|
+
...environment ? {
|
|
27480
|
+
environment: {
|
|
27481
|
+
id: environment.id,
|
|
27482
|
+
name: environment.name,
|
|
27483
|
+
installCommand: environment.installCommand,
|
|
27484
|
+
startCommand: environment.startCommand,
|
|
27485
|
+
imageBuildId: environment.imageBuildId,
|
|
27486
|
+
...environment.pendingBuild ? { pendingBuild: environment.pendingBuild } : {},
|
|
27487
|
+
variables: environment.variables
|
|
27488
|
+
}
|
|
27489
|
+
} : {}
|
|
27490
|
+
};
|
|
27491
|
+
}
|
|
27492
|
+
function agentContextSnapshot(input2) {
|
|
27493
|
+
const context = input2.spec.agentContext ?? knownContext(input2.known);
|
|
27494
|
+
if (!context && input2.problems.length === 0) return null;
|
|
27495
|
+
const environment = environmentOf(input2, context);
|
|
27496
|
+
const base = {
|
|
27497
|
+
session: {
|
|
27498
|
+
kind: sessionKind(input2, context),
|
|
27499
|
+
trigger: context?.trigger ?? "user",
|
|
27500
|
+
conversationId: input2.spec.conversationId,
|
|
27501
|
+
runId: input2.spec.runId,
|
|
27502
|
+
...input2.spec.teamId ? { teamId: input2.spec.teamId } : {},
|
|
27503
|
+
...input2.spec.taskId ? { taskId: input2.spec.taskId } : {},
|
|
27504
|
+
...input2.spec.workflowExecutionId ? { workflowExecutionId: input2.spec.workflowExecutionId } : {},
|
|
27505
|
+
...context ? { organizationId: context.organizationId } : {}
|
|
27506
|
+
},
|
|
27507
|
+
...context?.taskWorkingBranch ? { task: { workingBranch: context.taskWorkingBranch } } : {},
|
|
27508
|
+
...context?.pullRequest ? { pullRequest: context.pullRequest } : {},
|
|
27509
|
+
workspace: {
|
|
27510
|
+
...input2.workspaceRoot ? { root: input2.workspaceRoot } : {},
|
|
27511
|
+
...input2.spec.projectPath ? { cwd: input2.spec.projectPath } : {},
|
|
27512
|
+
repositories: repositories(input2, context)
|
|
27513
|
+
},
|
|
27514
|
+
...environment ? { environment } : {}
|
|
27515
|
+
};
|
|
27516
|
+
return { ...base, instructions: instructionsFor(base) };
|
|
27517
|
+
}
|
|
27518
|
+
function isScalar(value2) {
|
|
27519
|
+
return value2 === null || typeof value2 === "string" || typeof value2 === "number" || typeof value2 === "boolean";
|
|
27520
|
+
}
|
|
27521
|
+
function scalar(value2) {
|
|
27522
|
+
if (typeof value2 !== "string") return String(value2);
|
|
27523
|
+
return PLAIN_SCALAR.test(value2) ? value2 : JSON.stringify(value2);
|
|
27524
|
+
}
|
|
27525
|
+
function snakeCase(key) {
|
|
27526
|
+
return key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
27527
|
+
}
|
|
27528
|
+
function yamlLines(record2, indent) {
|
|
27529
|
+
return Object.entries(record2).flatMap(([key, value2]) => {
|
|
27530
|
+
const name = `${indent}${snakeCase(key)}:`;
|
|
27531
|
+
if (isScalar(value2)) return [`${name} ${scalar(value2)}`];
|
|
27532
|
+
if (Array.isArray(value2)) {
|
|
27533
|
+
if (value2.length === 0) return [];
|
|
27534
|
+
return [
|
|
27535
|
+
name,
|
|
27536
|
+
...value2.flatMap((item) => {
|
|
27537
|
+
if (isScalar(item)) return [`${indent} - ${scalar(item)}`];
|
|
27538
|
+
if (typeof item !== "object" || item === null) return [];
|
|
27539
|
+
const [first = "", ...rest] = yamlLines(item, `${indent} `);
|
|
27540
|
+
return [`${indent} - ${first.trimStart()}`, ...rest];
|
|
27541
|
+
})
|
|
27542
|
+
];
|
|
27543
|
+
}
|
|
27544
|
+
if (typeof value2 === "object" && value2 !== null)
|
|
27545
|
+
return [name, ...yamlLines(value2, `${indent} `)];
|
|
27546
|
+
return [];
|
|
27547
|
+
});
|
|
27548
|
+
}
|
|
27549
|
+
function block(tag, body) {
|
|
27550
|
+
return [`<${tag} version="${AGENT_CONTEXT_VERSION}">`, ...yamlLines(body, ""), `</${tag}>`].join(
|
|
27551
|
+
"\n"
|
|
27552
|
+
);
|
|
27553
|
+
}
|
|
27554
|
+
function stableRepository(repository) {
|
|
27555
|
+
const { checkout: _checkout, problem: _problem, action: _action, ...rest } = repository;
|
|
27556
|
+
return rest;
|
|
27557
|
+
}
|
|
27558
|
+
function commandPreview(command) {
|
|
27559
|
+
if (command === null || command.length <= COMMAND_PREVIEW_CHARS) return command;
|
|
27560
|
+
const lines2 = command.split("\n").length;
|
|
27561
|
+
return `${command.slice(0, COMMAND_PREVIEW_CHARS)}\u2026 (${lines2} lines; get_cloud_machine has the full command)`;
|
|
27562
|
+
}
|
|
27563
|
+
function withCommandPreviews(environment) {
|
|
27564
|
+
return {
|
|
27565
|
+
...environment,
|
|
27566
|
+
...environment.installCommand !== void 0 ? { installCommand: commandPreview(environment.installCommand) } : {},
|
|
27567
|
+
...environment.startCommand !== void 0 ? { startCommand: commandPreview(environment.startCommand) } : {}
|
|
27568
|
+
};
|
|
27569
|
+
}
|
|
27570
|
+
function changed(a, b) {
|
|
27571
|
+
return JSON.stringify(a) !== JSON.stringify(b);
|
|
27572
|
+
}
|
|
27573
|
+
function environmentUpdate(previous, next) {
|
|
27574
|
+
if (!next) return void 0;
|
|
27575
|
+
const { start: previousStart, ...previousFacts } = previous ?? {};
|
|
27576
|
+
const { start, ...facts } = next;
|
|
27577
|
+
if (changed(previousFacts, facts)) return next;
|
|
27578
|
+
return start?.state === "failed" && changed(previousStart, start) ? { start } : void 0;
|
|
27579
|
+
}
|
|
27580
|
+
function updateBody(previous, next) {
|
|
27581
|
+
const known = new Set(previous.instructions);
|
|
27582
|
+
const instructions = next.instructions.filter((line) => !known.has(line));
|
|
27583
|
+
const before = new Map(
|
|
27584
|
+
previous.workspace.repositories.map((repository) => [
|
|
27585
|
+
repository.path,
|
|
27586
|
+
stableRepository(repository)
|
|
27587
|
+
])
|
|
27588
|
+
);
|
|
27589
|
+
const repositories2 = next.workspace.repositories.map(stableRepository).filter(
|
|
27590
|
+
(repository) => repository.path !== void 0 && changed(before.get(repository.path), repository)
|
|
27591
|
+
);
|
|
27592
|
+
const environment = environmentUpdate(previous.environment, next.environment);
|
|
27593
|
+
const facts = {
|
|
27594
|
+
...changed(previous.task, next.task) && next.task ? { task: next.task } : {},
|
|
27595
|
+
...changed(previous.pullRequest, next.pullRequest) && next.pullRequest ? { pullRequest: next.pullRequest } : {},
|
|
27596
|
+
...repositories2.length > 0 ? { workspace: { repositories: repositories2 } } : {},
|
|
27597
|
+
...environment ? { environment: withCommandPreviews(environment) } : {},
|
|
27598
|
+
...instructions.length > 0 ? { instructions } : {}
|
|
27599
|
+
};
|
|
27600
|
+
if (Object.keys(facts).length === 0) return void 0;
|
|
27601
|
+
return next.session.trigger === "user" ? facts : { session: { trigger: next.session.trigger }, ...facts };
|
|
27602
|
+
}
|
|
27603
|
+
function renderAgentContext(snapshot2, previous) {
|
|
27604
|
+
const full = block("alan_agent_context", {
|
|
27605
|
+
...snapshot2,
|
|
27606
|
+
...snapshot2.environment ? { environment: withCommandPreviews(snapshot2.environment) } : {},
|
|
27607
|
+
instructions: [...startingInstructions(snapshot2), ...snapshot2.instructions]
|
|
27608
|
+
});
|
|
27609
|
+
const update = previous ? updateBody(previous, snapshot2) : void 0;
|
|
27610
|
+
return {
|
|
27611
|
+
snapshot: snapshot2,
|
|
27612
|
+
full,
|
|
27613
|
+
...update ? { update: block("alan_agent_context_update", update) } : {}
|
|
27614
|
+
};
|
|
27615
|
+
}
|
|
27302
27616
|
function truncate(value2, limit) {
|
|
27303
27617
|
const normalized2 = Array.from(value2, (character) => {
|
|
27304
27618
|
const code = character.charCodeAt(0);
|
|
@@ -27557,11 +27871,12 @@ function cloudExecutionSection(spec) {
|
|
|
27557
27871
|
if (spec.sandboxId) lines2.push(`Sandbox ID: ${spec.sandboxId}.`);
|
|
27558
27872
|
if (spec.cloudEnvironmentId) lines2.push(`Cloud environment ID: ${spec.cloudEnvironmentId}.`);
|
|
27559
27873
|
lines2.push(
|
|
27560
|
-
"Run setup, development and validation in this sandbox. The execution location is separate from the deployment of the application you are testing; verify that application's origin before acting."
|
|
27874
|
+
"Run setup, development and validation in this sandbox. The execution location is separate from the deployment of the application you are testing; verify that application's origin before acting.",
|
|
27875
|
+
"A turn can begin with an <alan_agent_context> block, or an <alan_agent_context_update> with only what changed since. Alan writes these, not the user: they state this session's repositories, branches, environment and start command state, and their instructions apply."
|
|
27561
27876
|
);
|
|
27562
27877
|
if (!isReadOnlyMode(spec.mode) && !isReadOnlyAgent(spec.agentId)) {
|
|
27563
27878
|
lines2.push(
|
|
27564
|
-
"Own the authorized work end to end: inspect context, make reasonable assumptions, implement, test, review and create or update the pull request for code changes when the repository workflow calls for one. Do not stop at a plan or ask for routine implementation choices or permission already granted. For application changes,
|
|
27879
|
+
"Own the authorized work end to end: inspect context, make reasonable assumptions, implement, test, review and create or update the pull request for code changes when the repository workflow calls for one. Do not stop at a plan or ask for routine implementation choices or permission already granted. For application changes, follow the session context for where to work and whether the start command is running, start the app if needed, and verify it is reachable before testing. For user-facing flows, use alan-test-feature when installed to test the running app, capture a video, and create a test report. Ask only for a missing secret, an essential decision you cannot derive, or an action requiring explicit approval. Respect the user's scope, repository rules and tool authorization; report blocked capabilities and validation gaps while continuing independent work."
|
|
27565
27880
|
);
|
|
27566
27881
|
}
|
|
27567
27882
|
const skills = spec.promptContext?.availableSkills ?? [];
|
|
@@ -27658,11 +27973,71 @@ function buildTurnText(input2) {
|
|
|
27658
27973
|
${body}` : body;
|
|
27659
27974
|
return spec.mode === "plan" ? planModePrefix(prefixed) : prefixed;
|
|
27660
27975
|
}
|
|
27661
|
-
var MAX_PARSED_ATTACHMENTS, MAX_PARSED_ATTACHMENT_CHARS, MAX_METADATA_CHARS, UNAVAILABLE, READ_ONLY_MODES, AGENT_MODES;
|
|
27662
|
-
var
|
|
27663
|
-
"../agent-core/dist/chunk-
|
|
27976
|
+
var startCommandStateSchema, repositorySnapshotSchema, environmentSnapshotSchema, agentContextSnapshotSchema, BRANCH_REASONS, PLAIN_SCALAR, COMMAND_PREVIEW_CHARS, MAX_PARSED_ATTACHMENTS, MAX_PARSED_ATTACHMENT_CHARS, MAX_METADATA_CHARS, UNAVAILABLE, READ_ONLY_MODES, AGENT_MODES;
|
|
27977
|
+
var init_chunk_GI3ZGXTY = __esm({
|
|
27978
|
+
"../agent-core/dist/chunk-GI3ZGXTY.js"() {
|
|
27664
27979
|
"use strict";
|
|
27980
|
+
init_runtime_v2();
|
|
27981
|
+
init_zod();
|
|
27665
27982
|
init_agent2();
|
|
27983
|
+
startCommandStateSchema = external_exports.discriminatedUnion("state", [
|
|
27984
|
+
external_exports.object({ state: external_exports.literal("not_configured") }),
|
|
27985
|
+
external_exports.object({ state: external_exports.literal("pending") }),
|
|
27986
|
+
external_exports.object({ state: external_exports.literal("running") }),
|
|
27987
|
+
external_exports.object({ state: external_exports.literal("exited_ok") }),
|
|
27988
|
+
external_exports.object({ state: external_exports.literal("failed"), exitCode: external_exports.number().int() })
|
|
27989
|
+
]);
|
|
27990
|
+
repositorySnapshotSchema = external_exports.object({
|
|
27991
|
+
path: external_exports.string(),
|
|
27992
|
+
name: external_exports.string().optional(),
|
|
27993
|
+
url: external_exports.string().optional(),
|
|
27994
|
+
branch: external_exports.string().optional(),
|
|
27995
|
+
branchSource: agentBranchSourceSchema.optional(),
|
|
27996
|
+
base: external_exports.string().optional(),
|
|
27997
|
+
checkout: external_exports.enum(["ok", "needs_attention"]),
|
|
27998
|
+
problem: external_exports.string().optional(),
|
|
27999
|
+
action: external_exports.string().optional()
|
|
28000
|
+
});
|
|
28001
|
+
environmentSnapshotSchema = external_exports.object({
|
|
28002
|
+
id: external_exports.string(),
|
|
28003
|
+
name: external_exports.string(),
|
|
28004
|
+
installCommand: external_exports.string().nullable(),
|
|
28005
|
+
startCommand: external_exports.string().nullable(),
|
|
28006
|
+
imageBuildId: external_exports.string().nullable(),
|
|
28007
|
+
pendingBuild: agentContextBuildSchema.optional(),
|
|
28008
|
+
variables: external_exports.array(external_exports.string()),
|
|
28009
|
+
start: external_exports.intersection(startCommandStateSchema, external_exports.object({ log: external_exports.string().optional() })).optional()
|
|
28010
|
+
});
|
|
28011
|
+
agentContextSnapshotSchema = external_exports.object({
|
|
28012
|
+
session: external_exports.object({
|
|
28013
|
+
kind: agentSessionKindSchema,
|
|
28014
|
+
trigger: agentTurnTriggerSchema,
|
|
28015
|
+
conversationId: external_exports.string(),
|
|
28016
|
+
runId: external_exports.string(),
|
|
28017
|
+
teamId: external_exports.string().optional(),
|
|
28018
|
+
taskId: external_exports.string().optional(),
|
|
28019
|
+
workflowExecutionId: external_exports.string().optional(),
|
|
28020
|
+
organizationId: external_exports.string().optional()
|
|
28021
|
+
}),
|
|
28022
|
+
task: external_exports.object({ workingBranch: external_exports.string() }).optional(),
|
|
28023
|
+
pullRequest: agentContextPullRequestSchema.optional(),
|
|
28024
|
+
workspace: external_exports.object({
|
|
28025
|
+
root: external_exports.string().optional(),
|
|
28026
|
+
cwd: external_exports.string().optional(),
|
|
28027
|
+
repositories: external_exports.array(repositorySnapshotSchema)
|
|
28028
|
+
}),
|
|
28029
|
+
environment: environmentSnapshotSchema.optional(),
|
|
28030
|
+
instructions: external_exports.array(external_exports.string())
|
|
28031
|
+
});
|
|
28032
|
+
BRANCH_REASONS = {
|
|
28033
|
+
handoff: "the branch handed off from the user's computer",
|
|
28034
|
+
pull_request: "this pull request's branch",
|
|
28035
|
+
task: "this task's branch",
|
|
28036
|
+
chat_selection: "the branch the user selected for this chat",
|
|
28037
|
+
environment_default: "the environment's default branch"
|
|
28038
|
+
};
|
|
28039
|
+
PLAIN_SCALAR = /^[A-Za-z0-9_./@~+-][A-Za-z0-9_./@~+:-]*$/;
|
|
28040
|
+
COMMAND_PREVIEW_CHARS = 200;
|
|
27666
28041
|
MAX_PARSED_ATTACHMENTS = 3;
|
|
27667
28042
|
MAX_PARSED_ATTACHMENT_CHARS = 12e3;
|
|
27668
28043
|
MAX_METADATA_CHARS = 240;
|
|
@@ -28100,16 +28475,16 @@ function parseClaudeEvent(event, state) {
|
|
|
28100
28475
|
}
|
|
28101
28476
|
function thoughtsOf(event, content, messageId, state) {
|
|
28102
28477
|
const texts = content.flatMap((raw) => {
|
|
28103
|
-
const
|
|
28104
|
-
if (!
|
|
28105
|
-
return [asString(
|
|
28478
|
+
const block2 = asRecord(raw);
|
|
28479
|
+
if (!block2 || asString(block2.type) !== "thinking") return [];
|
|
28480
|
+
return [asString(block2.thinking) || asString(block2.text)];
|
|
28106
28481
|
});
|
|
28107
28482
|
if (texts.length === 0) return [];
|
|
28108
28483
|
const frameId = asString(event.uuid) || synthId(state, "claude-thought-frame");
|
|
28109
28484
|
return thoughtBlocksFor(state, messageId).complete(frameId, texts);
|
|
28110
28485
|
}
|
|
28111
|
-
function textUpdates(frame,
|
|
28112
|
-
const text22 = asString(
|
|
28486
|
+
function textUpdates(frame, block2) {
|
|
28487
|
+
const text22 = asString(block2.text);
|
|
28113
28488
|
if (!text22 || frame.alreadyStreamed) return [];
|
|
28114
28489
|
const content = textBlock(frame.previousBlockWasText ? `
|
|
28115
28490
|
${text22}` : text22);
|
|
@@ -28130,12 +28505,12 @@ function thoughtUpdates(frame) {
|
|
|
28130
28505
|
}
|
|
28131
28506
|
];
|
|
28132
28507
|
}
|
|
28133
|
-
function blockUpdates(frame,
|
|
28134
|
-
const blockType = asString(
|
|
28135
|
-
if (blockType === "text") return textUpdates(frame,
|
|
28508
|
+
function blockUpdates(frame, block2) {
|
|
28509
|
+
const blockType = asString(block2.type);
|
|
28510
|
+
if (blockType === "text") return textUpdates(frame, block2);
|
|
28136
28511
|
frame.previousBlockWasText = false;
|
|
28137
28512
|
if (blockType === "thinking") return thoughtUpdates(frame);
|
|
28138
|
-
if (blockType === "tool_use") return parseToolUse(
|
|
28513
|
+
if (blockType === "tool_use") return parseToolUse(block2, frame.meta);
|
|
28139
28514
|
return [];
|
|
28140
28515
|
}
|
|
28141
28516
|
function parseAssistant(event, state) {
|
|
@@ -28153,8 +28528,8 @@ function parseAssistant(event, state) {
|
|
|
28153
28528
|
previousBlockWasText: false
|
|
28154
28529
|
};
|
|
28155
28530
|
return content.flatMap((raw) => {
|
|
28156
|
-
const
|
|
28157
|
-
return
|
|
28531
|
+
const block2 = asRecord(raw);
|
|
28532
|
+
return block2 ? blockUpdates(frame, block2) : [];
|
|
28158
28533
|
});
|
|
28159
28534
|
}
|
|
28160
28535
|
function toolUseMeta(name, input2, meta3) {
|
|
@@ -28167,11 +28542,11 @@ function toolUseMeta(name, input2, meta3) {
|
|
|
28167
28542
|
...!isAsk && normalizeToolName2(name) === "exitplanmode" ? { [EXIT_PLAN_MODE_INPUT_META]: input2 } : {}
|
|
28168
28543
|
};
|
|
28169
28544
|
}
|
|
28170
|
-
function parseToolUse(
|
|
28171
|
-
const toolCallId = asString(
|
|
28545
|
+
function parseToolUse(block2, meta3) {
|
|
28546
|
+
const toolCallId = asString(block2.id);
|
|
28172
28547
|
if (!toolCallId) return [];
|
|
28173
|
-
const name = canonicalizeManagedMcpToolName(asString(
|
|
28174
|
-
const input2 =
|
|
28548
|
+
const name = canonicalizeManagedMcpToolName(asString(block2.name));
|
|
28549
|
+
const input2 = block2.input;
|
|
28175
28550
|
const inputRecord = asRecord(input2) ?? {};
|
|
28176
28551
|
const pendingFileChange = claudeToolInputDiffContent(name, input2);
|
|
28177
28552
|
const updates = [
|
|
@@ -28213,21 +28588,21 @@ function parseUser(event) {
|
|
|
28213
28588
|
if (!message2) return [];
|
|
28214
28589
|
const meta3 = nesting(event);
|
|
28215
28590
|
return asArray(message2.content).flatMap((raw) => {
|
|
28216
|
-
const
|
|
28217
|
-
if (!
|
|
28218
|
-
const toolCallId = asString(
|
|
28591
|
+
const block2 = asRecord(raw);
|
|
28592
|
+
if (!block2 || asString(block2.type) !== "tool_result") return [];
|
|
28593
|
+
const toolCallId = asString(block2.tool_use_id);
|
|
28219
28594
|
if (!toolCallId) return [];
|
|
28220
|
-
const text22 = flattenToolResult(
|
|
28595
|
+
const text22 = flattenToolResult(block2.content);
|
|
28221
28596
|
const content = outputContent(text22);
|
|
28222
28597
|
const diffs = claudeFileChangeContents(event.tool_use_result);
|
|
28223
28598
|
return [
|
|
28224
28599
|
{
|
|
28225
28600
|
sessionUpdate: "tool_call_update",
|
|
28226
28601
|
toolCallId,
|
|
28227
|
-
status:
|
|
28602
|
+
status: block2.is_error === true ? "failed" : "completed",
|
|
28228
28603
|
...content || diffs.length ? { content: [...diffs, ...content ?? []] } : {},
|
|
28229
28604
|
rawOutput: text22,
|
|
28230
|
-
_meta: { ...meta3._meta, [PROVIDER_PAYLOAD_META]: event.tool_use_result ??
|
|
28605
|
+
_meta: { ...meta3._meta, [PROVIDER_PAYLOAD_META]: event.tool_use_result ?? block2 }
|
|
28231
28606
|
}
|
|
28232
28607
|
];
|
|
28233
28608
|
});
|
|
@@ -28740,12 +29115,12 @@ function isTopLevel(record2) {
|
|
|
28740
29115
|
return record2.isSidechain !== true;
|
|
28741
29116
|
}
|
|
28742
29117
|
function hasToolResult(content) {
|
|
28743
|
-
return asArray(content).some((
|
|
29118
|
+
return asArray(content).some((block2) => asString(asRecord(block2)?.type) === "tool_result");
|
|
28744
29119
|
}
|
|
28745
29120
|
function userText(content) {
|
|
28746
29121
|
if (typeof content === "string") return content;
|
|
28747
|
-
return asArray(content).map((
|
|
28748
|
-
const record2 = asRecord(
|
|
29122
|
+
return asArray(content).map((block2) => {
|
|
29123
|
+
const record2 = asRecord(block2);
|
|
28749
29124
|
return record2 && asString(record2.type) === "text" ? asString(record2.text) : "";
|
|
28750
29125
|
}).filter(Boolean).join("\n");
|
|
28751
29126
|
}
|
|
@@ -28781,8 +29156,8 @@ function claudeTranscriptModel(record2) {
|
|
|
28781
29156
|
function claudeTranscriptTurnError(record2) {
|
|
28782
29157
|
if (asString(record2.type) !== "assistant" || !isTopLevel(record2)) return null;
|
|
28783
29158
|
if (record2.isApiErrorMessage !== true) return null;
|
|
28784
|
-
const text22 = asArray(asRecord(record2.message)?.content).map((
|
|
28785
|
-
const part = asRecord(
|
|
29159
|
+
const text22 = asArray(asRecord(record2.message)?.content).map((block2) => {
|
|
29160
|
+
const part = asRecord(block2);
|
|
28786
29161
|
return part && asString(part.type) === "text" ? asString(part.text) : "";
|
|
28787
29162
|
}).join("").trim();
|
|
28788
29163
|
return text22 || asString(record2.error) || "The provider request failed";
|
|
@@ -28940,7 +29315,7 @@ var init_claude = __esm({
|
|
|
28940
29315
|
init_chunk_HBIPWAUI();
|
|
28941
29316
|
init_chunk_J2KTV5FP();
|
|
28942
29317
|
init_chunk_M6YHY2EZ();
|
|
28943
|
-
|
|
29318
|
+
init_chunk_GI3ZGXTY();
|
|
28944
29319
|
init_chunk_YXWJW7I5();
|
|
28945
29320
|
init_effort();
|
|
28946
29321
|
import_crypto6 = require("crypto");
|
|
@@ -29463,11 +29838,11 @@ var init_claude = __esm({
|
|
|
29463
29838
|
}
|
|
29464
29839
|
this.#iterations += 1;
|
|
29465
29840
|
for (const raw of asArray(asRecord(event.message)?.content)) {
|
|
29466
|
-
const
|
|
29467
|
-
if (!
|
|
29468
|
-
const id = asString(
|
|
29841
|
+
const block2 = asRecord(raw);
|
|
29842
|
+
if (!block2 || asString(block2.type) !== "tool_use") continue;
|
|
29843
|
+
const id = asString(block2.id);
|
|
29469
29844
|
if (!id) continue;
|
|
29470
|
-
const name = canonicalizeManagedMcpToolName(asString(
|
|
29845
|
+
const name = canonicalizeManagedMcpToolName(asString(block2.name));
|
|
29471
29846
|
if (isInteractiveToolName(name) || INTERACTIVE_TOOL_NAMES.has(normalizeToolName2(name))) {
|
|
29472
29847
|
this.#suppressedResults.add(id);
|
|
29473
29848
|
}
|
|
@@ -31114,9 +31489,9 @@ function contentText(content, separator = "") {
|
|
|
31114
31489
|
if (typeof content === "string") return content;
|
|
31115
31490
|
const parts22 = [];
|
|
31116
31491
|
for (const raw of asArray(content)) {
|
|
31117
|
-
const
|
|
31118
|
-
if (!
|
|
31119
|
-
const text3 = asString(
|
|
31492
|
+
const block2 = asRecord(raw);
|
|
31493
|
+
if (!block2) continue;
|
|
31494
|
+
const text3 = asString(block2.text) || asString(block2.input_text) || asString(block2.output_text);
|
|
31120
31495
|
if (text3) parts22.push(text3);
|
|
31121
31496
|
}
|
|
31122
31497
|
return parts22.join(separator);
|
|
@@ -31129,9 +31504,9 @@ function codexRolloutPromptText(payload) {
|
|
|
31129
31504
|
const kinds = asArray(passthroughOf(payload)?.content_item_kinds);
|
|
31130
31505
|
const parts22 = [];
|
|
31131
31506
|
asArray(payload.content).forEach((raw, index) => {
|
|
31132
|
-
const
|
|
31133
|
-
if (!
|
|
31134
|
-
const text3 = asString(
|
|
31507
|
+
const block2 = asRecord(raw);
|
|
31508
|
+
if (!block2) return;
|
|
31509
|
+
const text3 = asString(block2.text) || asString(block2.input_text);
|
|
31135
31510
|
if (!text3) return;
|
|
31136
31511
|
const kind = asString(kinds[index]);
|
|
31137
31512
|
const typed = kind ? kind.startsWith("user.") : !INJECTED_USER_PREFIXES.some((prefix) => text3.trimStart().startsWith(prefix));
|
|
@@ -31799,7 +32174,7 @@ var init_codex = __esm({
|
|
|
31799
32174
|
init_chunk_HBIPWAUI();
|
|
31800
32175
|
init_chunk_J2KTV5FP();
|
|
31801
32176
|
init_chunk_M6YHY2EZ();
|
|
31802
|
-
|
|
32177
|
+
init_chunk_GI3ZGXTY();
|
|
31803
32178
|
init_chunk_YXWJW7I5();
|
|
31804
32179
|
import_fs6 = require("fs");
|
|
31805
32180
|
import_path6 = require("path");
|
|
@@ -33379,7 +33754,7 @@ var require_identity = __commonJS({
|
|
|
33379
33754
|
var isDocument = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === DOC;
|
|
33380
33755
|
var isMap = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === MAP;
|
|
33381
33756
|
var isPair = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === PAIR;
|
|
33382
|
-
var
|
|
33757
|
+
var isScalar2 = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === SCALAR;
|
|
33383
33758
|
var isSeq = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === SEQ;
|
|
33384
33759
|
function isCollection(node2) {
|
|
33385
33760
|
if (node2 && typeof node2 === "object")
|
|
@@ -33401,7 +33776,7 @@ var require_identity = __commonJS({
|
|
|
33401
33776
|
}
|
|
33402
33777
|
return false;
|
|
33403
33778
|
}
|
|
33404
|
-
var hasAnchor = (node2) => (
|
|
33779
|
+
var hasAnchor = (node2) => (isScalar2(node2) || isCollection(node2)) && !!node2.anchor;
|
|
33405
33780
|
exports2.ALIAS = ALIAS;
|
|
33406
33781
|
exports2.DOC = DOC;
|
|
33407
33782
|
exports2.MAP = MAP;
|
|
@@ -33416,7 +33791,7 @@ var require_identity = __commonJS({
|
|
|
33416
33791
|
exports2.isMap = isMap;
|
|
33417
33792
|
exports2.isNode = isNode;
|
|
33418
33793
|
exports2.isPair = isPair;
|
|
33419
|
-
exports2.isScalar =
|
|
33794
|
+
exports2.isScalar = isScalar2;
|
|
33420
33795
|
exports2.isSeq = isSeq;
|
|
33421
33796
|
}
|
|
33422
33797
|
});
|
|
@@ -37772,13 +38147,13 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
37772
38147
|
"../../node_modules/yaml/dist/compose/resolve-block-scalar.js"(exports2) {
|
|
37773
38148
|
"use strict";
|
|
37774
38149
|
var Scalar = require_Scalar();
|
|
37775
|
-
function resolveBlockScalar(ctx,
|
|
37776
|
-
const start =
|
|
37777
|
-
const header = parseBlockScalarHeader(
|
|
38150
|
+
function resolveBlockScalar(ctx, scalar2, onError) {
|
|
38151
|
+
const start = scalar2.offset;
|
|
38152
|
+
const header = parseBlockScalarHeader(scalar2, ctx.options.strict, onError);
|
|
37778
38153
|
if (!header)
|
|
37779
38154
|
return { value: "", type: null, comment: "", range: [start, start, start] };
|
|
37780
38155
|
const type = header.mode === ">" ? Scalar.Scalar.BLOCK_FOLDED : Scalar.Scalar.BLOCK_LITERAL;
|
|
37781
|
-
const lines2 =
|
|
38156
|
+
const lines2 = scalar2.source ? splitLines(scalar2.source) : [];
|
|
37782
38157
|
let chompStart = lines2.length;
|
|
37783
38158
|
for (let i = lines2.length - 1; i >= 0; --i) {
|
|
37784
38159
|
const content = lines2[i][1];
|
|
@@ -37790,12 +38165,12 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
37790
38165
|
if (chompStart === 0) {
|
|
37791
38166
|
const value3 = header.chomp === "+" && lines2.length > 0 ? "\n".repeat(Math.max(1, lines2.length - 1)) : "";
|
|
37792
38167
|
let end2 = start + header.length;
|
|
37793
|
-
if (
|
|
37794
|
-
end2 +=
|
|
38168
|
+
if (scalar2.source)
|
|
38169
|
+
end2 += scalar2.source.length;
|
|
37795
38170
|
return { value: value3, type, comment: header.comment, range: [start, end2, end2] };
|
|
37796
38171
|
}
|
|
37797
|
-
let trimIndent =
|
|
37798
|
-
let offset =
|
|
38172
|
+
let trimIndent = scalar2.indent + header.indent;
|
|
38173
|
+
let offset = scalar2.offset + header.length;
|
|
37799
38174
|
let contentStart = 0;
|
|
37800
38175
|
for (let i = 0; i < chompStart; ++i) {
|
|
37801
38176
|
const [indent, content] = lines2[i];
|
|
@@ -37873,7 +38248,7 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
37873
38248
|
default:
|
|
37874
38249
|
value2 += "\n";
|
|
37875
38250
|
}
|
|
37876
|
-
const end = start + header.length +
|
|
38251
|
+
const end = start + header.length + scalar2.source.length;
|
|
37877
38252
|
return { value: value2, type, comment: header.comment, range: [start, end, end] };
|
|
37878
38253
|
}
|
|
37879
38254
|
function parseBlockScalarHeader({ offset, props }, strict, onError) {
|
|
@@ -37956,8 +38331,8 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
37956
38331
|
"use strict";
|
|
37957
38332
|
var Scalar = require_Scalar();
|
|
37958
38333
|
var resolveEnd = require_resolve_end();
|
|
37959
|
-
function resolveFlowScalar(
|
|
37960
|
-
const { offset, type, source, end } =
|
|
38334
|
+
function resolveFlowScalar(scalar2, strict, onError) {
|
|
38335
|
+
const { offset, type, source, end } = scalar2;
|
|
37961
38336
|
let _type;
|
|
37962
38337
|
let value2;
|
|
37963
38338
|
const _onError = (rel, code, msg) => onError(offset + rel, code, msg);
|
|
@@ -37976,7 +38351,7 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
37976
38351
|
break;
|
|
37977
38352
|
/* istanbul ignore next should not happen */
|
|
37978
38353
|
default:
|
|
37979
|
-
onError(
|
|
38354
|
+
onError(scalar2, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${type}`);
|
|
37980
38355
|
return {
|
|
37981
38356
|
value: "",
|
|
37982
38357
|
type: null,
|
|
@@ -38190,26 +38565,26 @@ var require_compose_scalar = __commonJS({
|
|
|
38190
38565
|
tag = findScalarTagByTest(ctx, value2, token, onError);
|
|
38191
38566
|
else
|
|
38192
38567
|
tag = ctx.schema[identity.SCALAR];
|
|
38193
|
-
let
|
|
38568
|
+
let scalar2;
|
|
38194
38569
|
try {
|
|
38195
38570
|
const res = tag.resolve(value2, (msg) => onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg), ctx.options);
|
|
38196
|
-
|
|
38571
|
+
scalar2 = identity.isScalar(res) ? res : new Scalar.Scalar(res);
|
|
38197
38572
|
} catch (error61) {
|
|
38198
38573
|
const msg = error61 instanceof Error ? error61.message : String(error61);
|
|
38199
38574
|
onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg);
|
|
38200
|
-
|
|
38575
|
+
scalar2 = new Scalar.Scalar(value2);
|
|
38201
38576
|
}
|
|
38202
|
-
|
|
38203
|
-
|
|
38577
|
+
scalar2.range = range;
|
|
38578
|
+
scalar2.source = value2;
|
|
38204
38579
|
if (type)
|
|
38205
|
-
|
|
38580
|
+
scalar2.type = type;
|
|
38206
38581
|
if (tagName)
|
|
38207
|
-
|
|
38582
|
+
scalar2.tag = tagName;
|
|
38208
38583
|
if (tag.format)
|
|
38209
|
-
|
|
38584
|
+
scalar2.format = tag.format;
|
|
38210
38585
|
if (comment)
|
|
38211
|
-
|
|
38212
|
-
return
|
|
38586
|
+
scalar2.comment = comment;
|
|
38587
|
+
return scalar2;
|
|
38213
38588
|
}
|
|
38214
38589
|
function findScalarTagByName(schema, value2, tagName, tagToken, onError) {
|
|
38215
38590
|
if (tagName === "!")
|
|
@@ -38958,7 +39333,7 @@ var require_cst = __commonJS({
|
|
|
38958
39333
|
var FLOW_END = "";
|
|
38959
39334
|
var SCALAR = "";
|
|
38960
39335
|
var isCollection = (token) => !!token && "items" in token;
|
|
38961
|
-
var
|
|
39336
|
+
var isScalar2 = (token) => !!token && (token.type === "scalar" || token.type === "single-quoted-scalar" || token.type === "double-quoted-scalar" || token.type === "block-scalar");
|
|
38962
39337
|
function prettyToken(token) {
|
|
38963
39338
|
switch (token) {
|
|
38964
39339
|
case BOM:
|
|
@@ -39042,7 +39417,7 @@ var require_cst = __commonJS({
|
|
|
39042
39417
|
exports2.FLOW_END = FLOW_END;
|
|
39043
39418
|
exports2.SCALAR = SCALAR;
|
|
39044
39419
|
exports2.isCollection = isCollection;
|
|
39045
|
-
exports2.isScalar =
|
|
39420
|
+
exports2.isScalar = isScalar2;
|
|
39046
39421
|
exports2.prettyToken = prettyToken;
|
|
39047
39422
|
exports2.tokenType = tokenType;
|
|
39048
39423
|
}
|
|
@@ -40037,37 +40412,37 @@ var require_parser = __commonJS({
|
|
|
40037
40412
|
};
|
|
40038
40413
|
}
|
|
40039
40414
|
}
|
|
40040
|
-
*scalar(
|
|
40415
|
+
*scalar(scalar2) {
|
|
40041
40416
|
if (this.type === "map-value-ind") {
|
|
40042
40417
|
const prev = getPrevProps(this.peek(2));
|
|
40043
40418
|
const start = getFirstKeyStartProps(prev);
|
|
40044
40419
|
let sep4;
|
|
40045
|
-
if (
|
|
40046
|
-
sep4 =
|
|
40420
|
+
if (scalar2.end) {
|
|
40421
|
+
sep4 = scalar2.end;
|
|
40047
40422
|
sep4.push(this.sourceToken);
|
|
40048
|
-
delete
|
|
40423
|
+
delete scalar2.end;
|
|
40049
40424
|
} else
|
|
40050
40425
|
sep4 = [this.sourceToken];
|
|
40051
40426
|
const map2 = {
|
|
40052
40427
|
type: "block-map",
|
|
40053
|
-
offset:
|
|
40054
|
-
indent:
|
|
40055
|
-
items: [{ start, key:
|
|
40428
|
+
offset: scalar2.offset,
|
|
40429
|
+
indent: scalar2.indent,
|
|
40430
|
+
items: [{ start, key: scalar2, sep: sep4 }]
|
|
40056
40431
|
};
|
|
40057
40432
|
this.onKeyLine = true;
|
|
40058
40433
|
this.stack[this.stack.length - 1] = map2;
|
|
40059
40434
|
} else
|
|
40060
|
-
yield* this.lineEnd(
|
|
40435
|
+
yield* this.lineEnd(scalar2);
|
|
40061
40436
|
}
|
|
40062
|
-
*blockScalar(
|
|
40437
|
+
*blockScalar(scalar2) {
|
|
40063
40438
|
switch (this.type) {
|
|
40064
40439
|
case "space":
|
|
40065
40440
|
case "comment":
|
|
40066
40441
|
case "newline":
|
|
40067
|
-
|
|
40442
|
+
scalar2.props.push(this.sourceToken);
|
|
40068
40443
|
return;
|
|
40069
40444
|
case "scalar":
|
|
40070
|
-
|
|
40445
|
+
scalar2.source = this.source;
|
|
40071
40446
|
this.atNewLine = true;
|
|
40072
40447
|
this.indent = 0;
|
|
40073
40448
|
if (this.onNewLine) {
|
|
@@ -42442,16 +42817,16 @@ var require_headers = __commonJS({
|
|
|
42442
42817
|
}
|
|
42443
42818
|
return 0;
|
|
42444
42819
|
}
|
|
42445
|
-
function indexOf(
|
|
42820
|
+
function indexOf(block2, num2, offset, end) {
|
|
42446
42821
|
for (; offset < end; offset++) {
|
|
42447
|
-
if (
|
|
42822
|
+
if (block2[offset] === num2) return offset;
|
|
42448
42823
|
}
|
|
42449
42824
|
return end;
|
|
42450
42825
|
}
|
|
42451
|
-
function cksum(
|
|
42826
|
+
function cksum(block2) {
|
|
42452
42827
|
let sum = 8 * 32;
|
|
42453
|
-
for (let i = 0; i < 148; i++) sum +=
|
|
42454
|
-
for (let j = 156; j < 512; j++) sum +=
|
|
42828
|
+
for (let i = 0; i < 148; i++) sum += block2[i];
|
|
42829
|
+
for (let j = 156; j < 512; j++) sum += block2[j];
|
|
42455
42830
|
return sum;
|
|
42456
42831
|
}
|
|
42457
42832
|
function encodeOct(val, n) {
|
|
@@ -43226,7 +43601,7 @@ function within(root, path4) {
|
|
|
43226
43601
|
}
|
|
43227
43602
|
async function resolveReal(path4) {
|
|
43228
43603
|
try {
|
|
43229
|
-
return await (0,
|
|
43604
|
+
return await (0, import_promises50.realpath)(path4);
|
|
43230
43605
|
} catch {
|
|
43231
43606
|
const parent = (0, import_path9.dirname)(path4);
|
|
43232
43607
|
if (parent === path4) return path4;
|
|
@@ -43255,14 +43630,14 @@ function createWorkspaceFs(roots, writable) {
|
|
|
43255
43630
|
return {
|
|
43256
43631
|
read: async (params) => {
|
|
43257
43632
|
const path4 = await confined(params);
|
|
43258
|
-
const bytes = await (0,
|
|
43633
|
+
const bytes = await (0, import_promises50.readFile)(path4);
|
|
43259
43634
|
if (bytes.byteLength > MAX_READ_BYTES) throw new FsDenied(`${path4} is too large to read`);
|
|
43260
43635
|
return { content: sliceLines(bytes.toString("utf8"), params) };
|
|
43261
43636
|
},
|
|
43262
43637
|
write: async (params) => {
|
|
43263
43638
|
if (!writable) throw new FsDenied("This session is read-only");
|
|
43264
43639
|
const path4 = await confined(params);
|
|
43265
|
-
await (0,
|
|
43640
|
+
await (0, import_promises50.writeFile)(path4, asString(params.content));
|
|
43266
43641
|
return {};
|
|
43267
43642
|
}
|
|
43268
43643
|
};
|
|
@@ -43359,8 +43734,8 @@ function refusal(error61, displayName) {
|
|
|
43359
43734
|
return failure3("failed", String(error61));
|
|
43360
43735
|
}
|
|
43361
43736
|
function toolResultText(update) {
|
|
43362
|
-
const texts = (update.content ?? []).flatMap((
|
|
43363
|
-
const text3 = asString(asRecord(asRecord(
|
|
43737
|
+
const texts = (update.content ?? []).flatMap((block2) => {
|
|
43738
|
+
const text3 = asString(asRecord(asRecord(block2)?.content)?.text);
|
|
43364
43739
|
return text3 ? [text3] : [];
|
|
43365
43740
|
});
|
|
43366
43741
|
if (typeof update.rawOutput === "string" && update.rawOutput) texts.push(update.rawOutput);
|
|
@@ -43456,11 +43831,11 @@ function isStopReason(value2) {
|
|
|
43456
43831
|
function v2ToolContent(content) {
|
|
43457
43832
|
if (!Array.isArray(content)) return void 0;
|
|
43458
43833
|
return content.map((item) => {
|
|
43459
|
-
const
|
|
43460
|
-
if (!
|
|
43461
|
-
const path4 = asString(
|
|
43462
|
-
const oldText = typeof
|
|
43463
|
-
const newText = typeof
|
|
43834
|
+
const block2 = asRecord(item);
|
|
43835
|
+
if (!block2 || asString(block2.type) !== "diff" || asRecord(block2.diff)) return item;
|
|
43836
|
+
const path4 = asString(block2.path);
|
|
43837
|
+
const oldText = typeof block2.oldText === "string" ? block2.oldText : null;
|
|
43838
|
+
const newText = typeof block2.newText === "string" ? block2.newText : null;
|
|
43464
43839
|
const operation = oldText === null ? "add" : newText === null ? "delete" : "modify";
|
|
43465
43840
|
return {
|
|
43466
43841
|
type: "diff",
|
|
@@ -43865,7 +44240,7 @@ async function acpTurnInput(run2, context) {
|
|
|
43865
44240
|
const encoded = await Promise.all(
|
|
43866
44241
|
images.map(async (image) => ({
|
|
43867
44242
|
mimeType: image.mimeType,
|
|
43868
|
-
data: (await (0,
|
|
44243
|
+
data: (await (0, import_promises51.readFile)(image.path)).toString("base64")
|
|
43869
44244
|
}))
|
|
43870
44245
|
);
|
|
43871
44246
|
return {
|
|
@@ -43874,7 +44249,7 @@ async function acpTurnInput(run2, context) {
|
|
|
43874
44249
|
...encoded.length ? { images: encoded, imagePaths: images.map((image) => image.path) } : {}
|
|
43875
44250
|
};
|
|
43876
44251
|
}
|
|
43877
|
-
var
|
|
44252
|
+
var import_promises50, import_path9, import_crypto13, import_promises51, CURSOR_ASK_QUESTION, copilotAcpProfile, cursorAcpProfile, MODEL_REJECTED, MAX_READ_BYTES, FsDenied, ENV_REFERENCE, AcpBackgroundTasks, CURSOR_CREATE_PLAN, STATUSES2, READ_KINDS, ALLOW_KINDS, REJECT_KINDS, CANCELLED_PERMISSION, STOP_REASONS, CHUNKS, ECHOES, AcpTurn, STDERR_TAIL_LINES4, MAX_BETWEEN_UPDATES2, AcpSession, DEFAULTS3, CLIENT_INFO2, TASK_BACKGROUNDED, TASK_COMPLETED, SESSION_NOTIFICATION, KILLED_STATUSES, SUCCESS_STATUSES, SUBAGENT_ID, grokTaskDialect, grokAcpProfile, kimiAcpProfile, ACP_PROFILES, ACP_MODES;
|
|
43878
44253
|
var init_acp3 = __esm({
|
|
43879
44254
|
"../agent-core/dist/providers/acp.js"() {
|
|
43880
44255
|
"use strict";
|
|
@@ -43883,14 +44258,14 @@ var init_acp3 = __esm({
|
|
|
43883
44258
|
init_chunk_HBIPWAUI();
|
|
43884
44259
|
init_chunk_J2KTV5FP();
|
|
43885
44260
|
init_chunk_M6YHY2EZ();
|
|
43886
|
-
|
|
44261
|
+
init_chunk_GI3ZGXTY();
|
|
43887
44262
|
init_chunk_YXWJW7I5();
|
|
43888
|
-
|
|
44263
|
+
import_promises50 = require("fs/promises");
|
|
43889
44264
|
import_path9 = require("path");
|
|
43890
44265
|
init_effort();
|
|
43891
44266
|
init_acp();
|
|
43892
44267
|
import_crypto13 = require("crypto");
|
|
43893
|
-
|
|
44268
|
+
import_promises51 = require("fs/promises");
|
|
43894
44269
|
init_agent2();
|
|
43895
44270
|
CURSOR_ASK_QUESTION = "cursor/ask_question";
|
|
43896
44271
|
copilotAcpProfile = {
|
|
@@ -44710,6 +45085,9 @@ var init_driver = __esm({
|
|
|
44710
45085
|
});
|
|
44711
45086
|
|
|
44712
45087
|
// src/holder/drivers/persistent.ts
|
|
45088
|
+
function sessionContextFor(opened, inputs) {
|
|
45089
|
+
return opened.fresh ? inputs.agentContext?.full : inputs.agentContext?.update;
|
|
45090
|
+
}
|
|
44713
45091
|
function errorMessage(error61) {
|
|
44714
45092
|
return error61 instanceof Error ? error61.message : String(error61);
|
|
44715
45093
|
}
|
|
@@ -44765,14 +45143,14 @@ function createPersistentDriver(provider4, options) {
|
|
|
44765
45143
|
const resumeNotice = (spec, session, sink) => {
|
|
44766
45144
|
if (spec.resumeFallbackContext) {
|
|
44767
45145
|
log.info("holder.session_resume_fallback", { harness: provider4.harness, runId: spec.runId });
|
|
44768
|
-
return { session, contextPrefix: spec.resumeFallbackContext };
|
|
45146
|
+
return { session, fresh: true, contextPrefix: spec.resumeFallbackContext };
|
|
44769
45147
|
}
|
|
44770
45148
|
sink.onEvent({
|
|
44771
45149
|
seq: 0,
|
|
44772
45150
|
at: clock.now(),
|
|
44773
45151
|
update: noticeUpdate("warning", "session_resume_failed", RESUME_UNAVAILABLE)
|
|
44774
45152
|
});
|
|
44775
|
-
return { session };
|
|
45153
|
+
return { session, fresh: true };
|
|
44776
45154
|
};
|
|
44777
45155
|
const managedMcpAccess = async (signal) => {
|
|
44778
45156
|
const managed = options.managedMcp;
|
|
@@ -44783,7 +45161,7 @@ function createPersistentDriver(provider4, options) {
|
|
|
44783
45161
|
const ensureSession = async (spec, inputs, sink, managedMcp) => {
|
|
44784
45162
|
const wanted = provider4.plan(spec, inputs, void 0, managedMcp);
|
|
44785
45163
|
const reused = await reuseLive(spec, wanted.key);
|
|
44786
|
-
if (reused) return { session: reused };
|
|
45164
|
+
if (reused) return { session: reused, fresh: false };
|
|
44787
45165
|
const requested = live.providerSessionId ?? spec.providerSessionId;
|
|
44788
45166
|
const resumeId = requested !== void 0 && requested !== live.rejectedSessionId && provider4.canResume(wanted, requested) ? requested : void 0;
|
|
44789
45167
|
const planned = provider4.plan(spec, inputs, resumeId, managedMcp);
|
|
@@ -44802,7 +45180,7 @@ function createPersistentDriver(provider4, options) {
|
|
|
44802
45180
|
requested
|
|
44803
45181
|
});
|
|
44804
45182
|
const resumed = resumeId !== void 0 && !opened.resumeFailed;
|
|
44805
|
-
if (requested === void 0 || resumed) return { session: opened.session };
|
|
45183
|
+
if (requested === void 0 || resumed) return { session: opened.session, fresh: !resumed };
|
|
44806
45184
|
return resumeNotice(spec, opened.session, sink);
|
|
44807
45185
|
};
|
|
44808
45186
|
const runOnSession = async (opened, spec, sink, signal, inputs) => {
|
|
@@ -44854,7 +45232,7 @@ function createPersistentDriver(provider4, options) {
|
|
|
44854
45232
|
};
|
|
44855
45233
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
44856
45234
|
try {
|
|
44857
|
-
const contextPrefix = [inputs
|
|
45235
|
+
const contextPrefix = [sessionContextFor(opened, inputs), opened.contextPrefix].filter((part) => part !== void 0).join("\n\n");
|
|
44858
45236
|
const input2 = await provider4.turnInput(spec, inputs, contextPrefix || void 0);
|
|
44859
45237
|
if (signal.aborted) return { outcome: "aborted" };
|
|
44860
45238
|
const result = await session.sendTurn(input2);
|
|
@@ -45035,8 +45413,8 @@ var init_acp4 = __esm({
|
|
|
45035
45413
|
});
|
|
45036
45414
|
|
|
45037
45415
|
// ../agent-core/dist/providers/opencode.js
|
|
45038
|
-
function parseSseBlock(
|
|
45039
|
-
const data =
|
|
45416
|
+
function parseSseBlock(block2) {
|
|
45417
|
+
const data = block2.split("\n").map((line) => line.endsWith("\r") ? line.slice(0, -1) : line).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).replace(/^ /, "")).join("\n");
|
|
45040
45418
|
if (!data) return void 0;
|
|
45041
45419
|
let parsed;
|
|
45042
45420
|
try {
|
|
@@ -45415,7 +45793,7 @@ async function sameDirectory(left, right) {
|
|
|
45415
45793
|
}
|
|
45416
45794
|
async function canonicalDirectory(directory) {
|
|
45417
45795
|
try {
|
|
45418
|
-
return await (0,
|
|
45796
|
+
return await (0, import_promises52.realpath)(directory);
|
|
45419
45797
|
} catch {
|
|
45420
45798
|
return (0, import_path10.resolve)(directory);
|
|
45421
45799
|
}
|
|
@@ -45611,7 +45989,7 @@ function openCodeTurnInput(run2, context) {
|
|
|
45611
45989
|
...images.length ? { imagePaths: images.map((image) => image.path) } : {}
|
|
45612
45990
|
};
|
|
45613
45991
|
}
|
|
45614
|
-
var import_http10, import_crypto14,
|
|
45992
|
+
var import_http10, import_crypto14, import_promises52, import_path10, import_path11, import_url2, import_crypto15, IDLE_SOCKET_MS3, OpenCodeHttpError, OpenCodeClient, OPENCODE_CONFIG_ENV, OPENCODE_ENGINE, TEXT_PARTS, STEP_PARTS, STOPPED_BY_USER, OpenCodeSubagents, NAMED_KINDS, OPENCODE_ABORTED_ERROR, PROVIDER_EVENT_META, TASK_TOOL_NAME, TASK_RESULT_TAG, TASK_ERROR_TAG, PERMISSION_DENIED, FILE_OPERATIONS2, PartReader, NOTHING, NON_INTERACTIVE_PERMISSIONS, CONTENT_FILTER_FINISHES, OUTPUT_PARTS, OpenCodeTurn, LISTENING, OUTPUT_TAIL_LINES, IMAGE_TYPES, OpenCodeSession, OPENCODE_MIN_VERSION, OPENCODE_REQUIREMENT, OPENCODE_TESTED_LINE, OPENCODE_SUPPORTED_MAJOR, DEFAULTS4, STORE_LOCKED, NON_INTERACTIVE_RULES, TITLE_LENGTH, MAX_VARIANT_LENGTH;
|
|
45615
45993
|
var init_opencode = __esm({
|
|
45616
45994
|
"../agent-core/dist/providers/opencode.js"() {
|
|
45617
45995
|
"use strict";
|
|
@@ -45620,12 +45998,12 @@ var init_opencode = __esm({
|
|
|
45620
45998
|
init_chunk_HBIPWAUI();
|
|
45621
45999
|
init_chunk_J2KTV5FP();
|
|
45622
46000
|
init_chunk_M6YHY2EZ();
|
|
45623
|
-
|
|
46001
|
+
init_chunk_GI3ZGXTY();
|
|
45624
46002
|
init_chunk_YXWJW7I5();
|
|
45625
46003
|
import_http10 = require("http");
|
|
45626
46004
|
init_runtime_v2();
|
|
45627
46005
|
import_crypto14 = require("crypto");
|
|
45628
|
-
|
|
46006
|
+
import_promises52 = require("fs/promises");
|
|
45629
46007
|
import_path10 = require("path");
|
|
45630
46008
|
init_agent2();
|
|
45631
46009
|
import_path11 = require("path");
|
|
@@ -47176,7 +47554,7 @@ function droidToolCall(toolUse) {
|
|
|
47176
47554
|
function droidResultText(result) {
|
|
47177
47555
|
const blocks = asArray(result.content);
|
|
47178
47556
|
if (blocks.length) {
|
|
47179
|
-
return blocks.map((
|
|
47557
|
+
return blocks.map((block2) => asString(asRecord(block2)?.text)).filter(Boolean).join("\n");
|
|
47180
47558
|
}
|
|
47181
47559
|
const value2 = result.value;
|
|
47182
47560
|
if (typeof value2 === "string") return value2;
|
|
@@ -47426,12 +47804,12 @@ async function droidTurnInput(run2, context) {
|
|
|
47426
47804
|
const encoded = await Promise.all(
|
|
47427
47805
|
images.map(async (image) => ({
|
|
47428
47806
|
mimeType: image.mimeType,
|
|
47429
|
-
data: (await (0,
|
|
47807
|
+
data: (await (0, import_promises53.readFile)(image.path)).toString("base64")
|
|
47430
47808
|
}))
|
|
47431
47809
|
);
|
|
47432
47810
|
return { turnId: run2.runId, text: text3, ...encoded.length ? { images: encoded } : {} };
|
|
47433
47811
|
}
|
|
47434
|
-
var import_crypto16,
|
|
47812
|
+
var import_crypto16, import_promises53, FACTORY_API_VERSION, FACTORY_PROTOCOL_VERSION, SUBAGENT_TOOLS, TASK_OUTPUT_TOOLS, TASK_STOP_TOOLS, SILENT2, DroidTurn, STDERR_TAIL_LINES5, UNSUPPORTED_REQUEST2, DroidSession, DEFAULTS5, DROID_REQUIREMENT, DROID_JSONRPC_ARGS;
|
|
47435
47813
|
var init_droid = __esm({
|
|
47436
47814
|
"../agent-core/dist/providers/droid.js"() {
|
|
47437
47815
|
"use strict";
|
|
@@ -47440,11 +47818,11 @@ var init_droid = __esm({
|
|
|
47440
47818
|
init_chunk_HBIPWAUI();
|
|
47441
47819
|
init_chunk_J2KTV5FP();
|
|
47442
47820
|
init_chunk_M6YHY2EZ();
|
|
47443
|
-
|
|
47821
|
+
init_chunk_GI3ZGXTY();
|
|
47444
47822
|
init_chunk_YXWJW7I5();
|
|
47445
47823
|
init_runtime_v2();
|
|
47446
47824
|
import_crypto16 = require("crypto");
|
|
47447
|
-
|
|
47825
|
+
import_promises53 = require("fs/promises");
|
|
47448
47826
|
init_agent2();
|
|
47449
47827
|
FACTORY_API_VERSION = "1.0.0";
|
|
47450
47828
|
FACTORY_PROTOCOL_VERSION = "1.187.0";
|
|
@@ -47919,7 +48297,7 @@ function settingsPath(env) {
|
|
|
47919
48297
|
async function readSettings2(path4) {
|
|
47920
48298
|
let raw;
|
|
47921
48299
|
try {
|
|
47922
|
-
raw = (await (0,
|
|
48300
|
+
raw = (await (0, import_promises54.readFile)(path4, "utf8")).trim();
|
|
47923
48301
|
} catch {
|
|
47924
48302
|
return {};
|
|
47925
48303
|
}
|
|
@@ -47937,8 +48315,8 @@ async function selectAntigravityApiKeyMode(env) {
|
|
|
47937
48315
|
const settings2 = await readSettings2(path4);
|
|
47938
48316
|
if (settings2 === "malformed") return "malformed";
|
|
47939
48317
|
if (settings2.modelProvider === "gemini") return "already_selected";
|
|
47940
|
-
await (0,
|
|
47941
|
-
await (0,
|
|
48318
|
+
await (0, import_promises54.mkdir)((0, import_path12.dirname)(path4), { recursive: true });
|
|
48319
|
+
await (0, import_promises54.writeFile)(path4, JSON.stringify({ ...settings2, modelProvider: "gemini" }), { mode: 384 });
|
|
47942
48320
|
return "selected";
|
|
47943
48321
|
}
|
|
47944
48322
|
function readAntigravityCapabilities(version2, help) {
|
|
@@ -48537,7 +48915,7 @@ function antigravityTurnInput(run2, context) {
|
|
|
48537
48915
|
});
|
|
48538
48916
|
return { turnId: run2.runId, text: appendImagePathReferences(text3, images) };
|
|
48539
48917
|
}
|
|
48540
|
-
var
|
|
48918
|
+
var import_promises54, import_path12, import_fs8, import_path13, import_path14, import_url3, import_crypto17, 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;
|
|
48541
48919
|
var init_antigravity = __esm({
|
|
48542
48920
|
"../agent-core/dist/providers/antigravity.js"() {
|
|
48543
48921
|
"use strict";
|
|
@@ -48546,9 +48924,9 @@ var init_antigravity = __esm({
|
|
|
48546
48924
|
init_chunk_XC5676SG();
|
|
48547
48925
|
init_chunk_HBIPWAUI();
|
|
48548
48926
|
init_chunk_M6YHY2EZ();
|
|
48549
|
-
|
|
48927
|
+
init_chunk_GI3ZGXTY();
|
|
48550
48928
|
init_chunk_YXWJW7I5();
|
|
48551
|
-
|
|
48929
|
+
import_promises54 = require("fs/promises");
|
|
48552
48930
|
import_path12 = require("path");
|
|
48553
48931
|
init_type_guards();
|
|
48554
48932
|
import_fs8 = require("fs");
|
|
@@ -49048,7 +49426,7 @@ function parseConfig(raw) {
|
|
|
49048
49426
|
}
|
|
49049
49427
|
async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
49050
49428
|
const path4 = (0, import_path15.join)(cwd, ".mcp.json");
|
|
49051
|
-
const original = await (0,
|
|
49429
|
+
const original = await (0, import_promises55.readFile)(path4, "utf8").catch(() => null);
|
|
49052
49430
|
const config2 = parseConfig(original);
|
|
49053
49431
|
const next = {
|
|
49054
49432
|
...config2,
|
|
@@ -49065,12 +49443,12 @@ async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
|
49065
49443
|
}
|
|
49066
49444
|
}
|
|
49067
49445
|
};
|
|
49068
|
-
await (0,
|
|
49069
|
-
await (0,
|
|
49446
|
+
await (0, import_promises55.mkdir)(cwd, { recursive: true });
|
|
49447
|
+
await (0, import_promises55.writeFile)(path4, `${JSON.stringify(next, null, 2)}
|
|
49070
49448
|
`);
|
|
49071
49449
|
return async () => {
|
|
49072
|
-
if (original === null) await (0,
|
|
49073
|
-
else await (0,
|
|
49450
|
+
if (original === null) await (0, import_promises55.rm)(path4, { force: true });
|
|
49451
|
+
else await (0, import_promises55.writeFile)(path4, original);
|
|
49074
49452
|
};
|
|
49075
49453
|
}
|
|
49076
49454
|
function commandCodeString(value2) {
|
|
@@ -49242,7 +49620,7 @@ function commandCodeTurnInput(run2, context) {
|
|
|
49242
49620
|
});
|
|
49243
49621
|
return { turnId: run2.runId, text: appendImagePathReferences(text3, images) };
|
|
49244
49622
|
}
|
|
49245
|
-
var
|
|
49623
|
+
var import_promises55, import_path15, import_crypto18, 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;
|
|
49246
49624
|
var init_command_code = __esm({
|
|
49247
49625
|
"../agent-core/dist/providers/command-code.js"() {
|
|
49248
49626
|
"use strict";
|
|
@@ -49251,9 +49629,9 @@ var init_command_code = __esm({
|
|
|
49251
49629
|
init_chunk_HBIPWAUI();
|
|
49252
49630
|
init_chunk_J2KTV5FP();
|
|
49253
49631
|
init_chunk_M6YHY2EZ();
|
|
49254
|
-
|
|
49632
|
+
init_chunk_GI3ZGXTY();
|
|
49255
49633
|
init_chunk_YXWJW7I5();
|
|
49256
|
-
|
|
49634
|
+
import_promises55 = require("fs/promises");
|
|
49257
49635
|
import_path15 = require("path");
|
|
49258
49636
|
init_agent2();
|
|
49259
49637
|
init_runtime_v2();
|
|
@@ -54649,7 +55027,7 @@ var require_websocket_server = __commonJS({
|
|
|
54649
55027
|
// package.json
|
|
54650
55028
|
var package_default = {
|
|
54651
55029
|
name: "@alan-ai-hq/agent-manager",
|
|
54652
|
-
version: "0.1.
|
|
55030
|
+
version: "0.1.148",
|
|
54653
55031
|
private: true,
|
|
54654
55032
|
type: "module",
|
|
54655
55033
|
description: "Alan machine runtime (alan-agent): identity, link, reconciler, session holders, run log, uploader, local API",
|
|
@@ -54699,7 +55077,7 @@ var package_default = {
|
|
|
54699
55077
|
|
|
54700
55078
|
// src/cli/commands/compat.ts
|
|
54701
55079
|
var import_node_crypto32 = require("crypto");
|
|
54702
|
-
var
|
|
55080
|
+
var import_promises71 = require("fs/promises");
|
|
54703
55081
|
init_runtime_v2();
|
|
54704
55082
|
init_zod();
|
|
54705
55083
|
|
|
@@ -57448,9 +57826,9 @@ function isProcessAlive(pid) {
|
|
|
57448
57826
|
}
|
|
57449
57827
|
}
|
|
57450
57828
|
async function linuxStartTime(pid) {
|
|
57451
|
-
const
|
|
57452
|
-
if (
|
|
57453
|
-
const fields =
|
|
57829
|
+
const stat23 = await (0, import_promises13.readFile)(`/proc/${pid}/stat`, "utf8").catch(() => null);
|
|
57830
|
+
if (stat23 === null) return null;
|
|
57831
|
+
const fields = stat23.slice(stat23.lastIndexOf(")") + 2).split(" ");
|
|
57454
57832
|
return fields[19] ?? null;
|
|
57455
57833
|
}
|
|
57456
57834
|
async function linuxCommand(pid) {
|
|
@@ -58695,16 +59073,16 @@ function windowsManager(host, profile) {
|
|
|
58695
59073
|
files.taskXml,
|
|
58696
59074
|
Buffer.from(`${UTF8_BOM}${xml2}`, "utf16le")
|
|
58697
59075
|
);
|
|
58698
|
-
const
|
|
59076
|
+
const changed2 = configChanged || xmlChanged;
|
|
58699
59077
|
const mode = await currentMode();
|
|
58700
59078
|
const outcome2 = (manager) => ({
|
|
58701
59079
|
manager,
|
|
58702
59080
|
name: files.runValue,
|
|
58703
59081
|
definitionPath: files.config,
|
|
58704
|
-
changed,
|
|
59082
|
+
changed: changed2,
|
|
58705
59083
|
linger: null
|
|
58706
59084
|
});
|
|
58707
|
-
if (
|
|
59085
|
+
if (changed2 || mode === null) {
|
|
58708
59086
|
await stopRunning(mode);
|
|
58709
59087
|
const registered = await register2();
|
|
58710
59088
|
await start(registered);
|
|
@@ -58933,15 +59311,15 @@ function systemdManager(host, profile) {
|
|
|
58933
59311
|
name: unit,
|
|
58934
59312
|
definitionPath: unitPath,
|
|
58935
59313
|
install: async (spec, { restart }) => {
|
|
58936
|
-
const
|
|
58937
|
-
if (
|
|
59314
|
+
const changed2 = await writeDefinition(unitPath, renderSystemdUnit(spec));
|
|
59315
|
+
if (changed2) await runChecked(host.exec, systemctl("daemon-reload"));
|
|
58938
59316
|
await runChecked(host.exec, systemctl("enable", unit));
|
|
58939
|
-
await runChecked(host.exec, systemctlJob(
|
|
59317
|
+
await runChecked(host.exec, systemctlJob(changed2 || restart ? "restart" : "start", unit));
|
|
58940
59318
|
return {
|
|
58941
59319
|
manager: "systemd",
|
|
58942
59320
|
name: unit,
|
|
58943
59321
|
definitionPath: unitPath,
|
|
58944
|
-
changed,
|
|
59322
|
+
changed: changed2,
|
|
58945
59323
|
linger: await readLinger(host.exec, host.username)
|
|
58946
59324
|
};
|
|
58947
59325
|
},
|
|
@@ -59101,9 +59479,9 @@ function xdgAutostartManager(host, profile) {
|
|
|
59101
59479
|
448
|
|
59102
59480
|
);
|
|
59103
59481
|
const entryChanged = await writeDefinition(files.entry, renderAutostartEntry(spec, files));
|
|
59104
|
-
const
|
|
59482
|
+
const changed2 = scriptChanged || entryChanged;
|
|
59105
59483
|
const supervisor = await readRecordedProcess(files.supervisorRecord);
|
|
59106
|
-
if (supervisor === null ||
|
|
59484
|
+
if (supervisor === null || changed2 || restart) {
|
|
59107
59485
|
await stopRunning();
|
|
59108
59486
|
await start();
|
|
59109
59487
|
}
|
|
@@ -59111,7 +59489,7 @@ function xdgAutostartManager(host, profile) {
|
|
|
59111
59489
|
manager: "xdg-autostart",
|
|
59112
59490
|
name: files.name,
|
|
59113
59491
|
definitionPath: files.entry,
|
|
59114
|
-
changed,
|
|
59492
|
+
changed: changed2,
|
|
59115
59493
|
linger: null
|
|
59116
59494
|
};
|
|
59117
59495
|
},
|
|
@@ -59166,16 +59544,16 @@ function launchdManager(host, profile) {
|
|
|
59166
59544
|
definitionPath: plist,
|
|
59167
59545
|
install: async (spec, { restart }) => {
|
|
59168
59546
|
await (0, import_promises23.mkdir)((0, import_node_path20.dirname)(spec.logPath), { recursive: true, mode: 448 });
|
|
59169
|
-
const
|
|
59547
|
+
const changed2 = await writeDefinition(plist, renderLaunchdPlist(spec));
|
|
59170
59548
|
const loaded = await isLoaded();
|
|
59171
|
-
if (loaded && !
|
|
59549
|
+
if (loaded && !changed2) {
|
|
59172
59550
|
await runChecked(host.exec, launchctl("kickstart", ...restart ? ["-k"] : [], target));
|
|
59173
|
-
return { manager: "launchd", name: label, definitionPath: plist, changed, linger: null };
|
|
59551
|
+
return { manager: "launchd", name: label, definitionPath: plist, changed: changed2, linger: null };
|
|
59174
59552
|
}
|
|
59175
59553
|
if (loaded) await host.exec(launchctl("bootout", target));
|
|
59176
59554
|
await host.exec(launchctl("enable", target));
|
|
59177
59555
|
await runChecked(host.exec, launchctl("bootstrap", domain2, plist));
|
|
59178
|
-
return { manager: "launchd", name: label, definitionPath: plist, changed, linger: null };
|
|
59556
|
+
return { manager: "launchd", name: label, definitionPath: plist, changed: changed2, linger: null };
|
|
59179
59557
|
},
|
|
59180
59558
|
uninstall: async () => {
|
|
59181
59559
|
const loaded = await isLoaded();
|
|
@@ -61312,10 +61690,10 @@ function openCodeScanFromVerbose(text3) {
|
|
|
61312
61690
|
const id = (lines2[index] ?? "").trim();
|
|
61313
61691
|
index += 1;
|
|
61314
61692
|
if (!isProviderSlashModelId(id)) continue;
|
|
61315
|
-
const
|
|
61316
|
-
if (
|
|
61317
|
-
index =
|
|
61318
|
-
const entry = parseVerboseEntry(
|
|
61693
|
+
const block2 = readJsonBlock(lines2, index);
|
|
61694
|
+
if (block2 === null) continue;
|
|
61695
|
+
index = block2.end + 1;
|
|
61696
|
+
const entry = parseVerboseEntry(block2.json);
|
|
61319
61697
|
if (entry === null) continue;
|
|
61320
61698
|
if (entry.status === "deprecated") deprecated.add(id);
|
|
61321
61699
|
else models.push(verboseModel(id, entry));
|
|
@@ -61689,9 +62067,9 @@ function installIngestionHooks(provider4, options, now) {
|
|
|
61689
62067
|
];
|
|
61690
62068
|
}
|
|
61691
62069
|
const next = { ...settings2, hooks: nextHooks };
|
|
61692
|
-
const
|
|
61693
|
-
if (
|
|
61694
|
-
return { provider: provider4, path: path4, changed };
|
|
62070
|
+
const changed2 = JSON.stringify(next) !== JSON.stringify(settings2);
|
|
62071
|
+
if (changed2) writeSettings(path4, next);
|
|
62072
|
+
return { provider: provider4, path: path4, changed: changed2 };
|
|
61695
62073
|
}
|
|
61696
62074
|
function removeIngestionHooks(provider4, where, now) {
|
|
61697
62075
|
const path4 = providerHookSettingsPath(provider4, where);
|
|
@@ -61699,18 +62077,18 @@ function removeIngestionHooks(provider4, where, now) {
|
|
|
61699
62077
|
const settings2 = readSettings(path4, true, now);
|
|
61700
62078
|
const hooks = hooksOf(settings2);
|
|
61701
62079
|
const nextHooks = {};
|
|
61702
|
-
let
|
|
62080
|
+
let changed2 = false;
|
|
61703
62081
|
for (const [event, groups] of Object.entries(hooks)) {
|
|
61704
62082
|
if (!hasHandler(groups, isIngestionHandler)) {
|
|
61705
62083
|
nextHooks[event] = groups;
|
|
61706
62084
|
continue;
|
|
61707
62085
|
}
|
|
61708
|
-
|
|
62086
|
+
changed2 = true;
|
|
61709
62087
|
const retained = withoutIngestionHandlers(groups, path4, event);
|
|
61710
62088
|
if (retained.length > 0) nextHooks[event] = retained;
|
|
61711
62089
|
}
|
|
61712
|
-
if (
|
|
61713
|
-
return { provider: provider4, path: path4, changed };
|
|
62090
|
+
if (changed2) writeSettings(path4, { ...settings2, hooks: nextHooks });
|
|
62091
|
+
return { provider: provider4, path: path4, changed: changed2 };
|
|
61714
62092
|
}
|
|
61715
62093
|
function ingestionHooksInstalled(provider4, where) {
|
|
61716
62094
|
const hooks = hooksOf(readSettings(providerHookSettingsPath(provider4, where), false, 0));
|
|
@@ -62146,18 +62524,18 @@ async function readTranscriptWindow(path4, offset, limits) {
|
|
|
62146
62524
|
limits.maxRecordBytes,
|
|
62147
62525
|
Math.max(limits.windowBytes - gathered, MIN_READ_BYTES)
|
|
62148
62526
|
);
|
|
62149
|
-
const
|
|
62527
|
+
const block2 = await readCompleteLines(
|
|
62150
62528
|
handle,
|
|
62151
62529
|
position,
|
|
62152
62530
|
size,
|
|
62153
62531
|
firstReadBytes,
|
|
62154
62532
|
limits.maxRecordBytes
|
|
62155
62533
|
);
|
|
62156
|
-
const recordEnd =
|
|
62157
|
-
if (
|
|
62158
|
-
pieces.push(
|
|
62159
|
-
gathered +=
|
|
62160
|
-
position +=
|
|
62534
|
+
const recordEnd = block2.oversized ? await findRecordEnd(handle, block2.scannedEnd, size) : null;
|
|
62535
|
+
if (block2.lines.length > 0) {
|
|
62536
|
+
pieces.push(block2.lines);
|
|
62537
|
+
gathered += block2.lines.length;
|
|
62538
|
+
position += block2.lines.length;
|
|
62161
62539
|
} else if (recordEnd !== null) {
|
|
62162
62540
|
pieces.push(SKIPPED_RECORD_LINE);
|
|
62163
62541
|
skipped.push({ offset: position, bytes: recordEnd - position });
|
|
@@ -62199,7 +62577,7 @@ function textOf(update) {
|
|
|
62199
62577
|
return update.content.type === "text" ? update.content.text : "";
|
|
62200
62578
|
}
|
|
62201
62579
|
if (isUpdate(update, "agent_message")) {
|
|
62202
|
-
return (update.content ?? []).map((
|
|
62580
|
+
return (update.content ?? []).map((block2) => block2.type === "text" ? block2.text : "").join("");
|
|
62203
62581
|
}
|
|
62204
62582
|
return "";
|
|
62205
62583
|
}
|
|
@@ -63170,6 +63548,7 @@ function captureProbe(command, args, options) {
|
|
|
63170
63548
|
}
|
|
63171
63549
|
|
|
63172
63550
|
// src/capabilities/providers/inventory.ts
|
|
63551
|
+
var import_promises36 = require("fs/promises");
|
|
63173
63552
|
var import_node_os3 = require("os");
|
|
63174
63553
|
init_runtime_v2();
|
|
63175
63554
|
|
|
@@ -63473,6 +63852,42 @@ ${output2.stderr}`)) {
|
|
|
63473
63852
|
}
|
|
63474
63853
|
|
|
63475
63854
|
// src/capabilities/providers/inventory.ts
|
|
63855
|
+
var PROBE_CONCURRENCY = 4;
|
|
63856
|
+
function createProbeQueue(capture, env, limit) {
|
|
63857
|
+
let active = 0;
|
|
63858
|
+
const waiting = [];
|
|
63859
|
+
const shared = /* @__PURE__ */ new Map();
|
|
63860
|
+
const acquire = () => {
|
|
63861
|
+
if (active < limit) {
|
|
63862
|
+
active += 1;
|
|
63863
|
+
return Promise.resolve();
|
|
63864
|
+
}
|
|
63865
|
+
return new Promise((resolve14) => waiting.push(resolve14));
|
|
63866
|
+
};
|
|
63867
|
+
const release2 = () => {
|
|
63868
|
+
const next = waiting.shift();
|
|
63869
|
+
if (next === void 0) active -= 1;
|
|
63870
|
+
else next();
|
|
63871
|
+
};
|
|
63872
|
+
const run2 = async (task) => {
|
|
63873
|
+
await acquire();
|
|
63874
|
+
try {
|
|
63875
|
+
return await task();
|
|
63876
|
+
} finally {
|
|
63877
|
+
release2();
|
|
63878
|
+
}
|
|
63879
|
+
};
|
|
63880
|
+
const limited = (command, args, options) => {
|
|
63881
|
+
if (options.env !== env) return run2(() => capture(command, args, options));
|
|
63882
|
+
const key = [command, ...args].join("\0");
|
|
63883
|
+
const existing = shared.get(key);
|
|
63884
|
+
if (existing !== void 0) return existing;
|
|
63885
|
+
const output2 = run2(() => capture(command, args, options));
|
|
63886
|
+
shared.set(key, output2);
|
|
63887
|
+
return output2;
|
|
63888
|
+
};
|
|
63889
|
+
return { capture: limited, run: run2 };
|
|
63890
|
+
}
|
|
63476
63891
|
function readMachineFacts(platform3, runtimeVersion) {
|
|
63477
63892
|
return machineFactsSchema.parse({
|
|
63478
63893
|
os: platform3,
|
|
@@ -63497,11 +63912,11 @@ function runFacts(run2) {
|
|
|
63497
63912
|
return {};
|
|
63498
63913
|
}
|
|
63499
63914
|
}
|
|
63500
|
-
async function scanProvider(provider4, options,
|
|
63915
|
+
async function scanProvider(provider4, options, queue) {
|
|
63501
63916
|
const { env, platform: platform3, clock } = options;
|
|
63502
63917
|
const executable = await resolveProviderExecutable(provider4, env, platform3);
|
|
63503
63918
|
if (executable !== null && provider4.backendKind === ALAN_CODE_BACKEND) {
|
|
63504
|
-
return scanAlanCode(executable, options, capture);
|
|
63919
|
+
return scanAlanCode(executable, options, queue.capture);
|
|
63505
63920
|
}
|
|
63506
63921
|
if (executable === null || !options.probes) {
|
|
63507
63922
|
return {
|
|
@@ -63511,14 +63926,14 @@ async function scanProvider(provider4, options, capture) {
|
|
|
63511
63926
|
checkedAt: clock.now()
|
|
63512
63927
|
};
|
|
63513
63928
|
}
|
|
63514
|
-
const authResult = probeAuth(provider4.backendKind, provider4.name, executable, env, capture);
|
|
63929
|
+
const authResult = probeAuth(provider4.backendKind, provider4.name, executable, env, queue.capture);
|
|
63515
63930
|
const accountLabelProbe = options.accountLabelProbe ?? (options.capture === void 0 ? probeAccountLabel : async () => void 0);
|
|
63516
63931
|
const [run2, auth, models, authLabel] = await Promise.all([
|
|
63517
|
-
probeRun(executable, env, capture),
|
|
63932
|
+
probeRun(executable, env, queue.capture),
|
|
63518
63933
|
authResult,
|
|
63519
|
-
discoverProviderModels(provider4, executable, options, capture),
|
|
63934
|
+
discoverProviderModels(provider4, executable, options, queue.capture),
|
|
63520
63935
|
authResult.then(
|
|
63521
|
-
(result) => result.auth === "signed_in" ? accountLabelProbe(provider4.backendKind, executable, env, capture).catch(() => void 0) : void 0
|
|
63936
|
+
(result) => result.auth === "signed_in" ? queue.run(() => accountLabelProbe(provider4.backendKind, executable, env, queue.capture)).catch(() => void 0) : void 0
|
|
63522
63937
|
)
|
|
63523
63938
|
]);
|
|
63524
63939
|
return {
|
|
@@ -63566,9 +63981,9 @@ async function scanAlanCode(executable, options, capture) {
|
|
|
63566
63981
|
};
|
|
63567
63982
|
}
|
|
63568
63983
|
async function scanCapabilities(options) {
|
|
63569
|
-
const
|
|
63984
|
+
const queue = createProbeQueue(options.capture ?? captureProbe, options.env, PROBE_CONCURRENCY);
|
|
63570
63985
|
const [providers, hasGit] = await Promise.all([
|
|
63571
|
-
Promise.all(PROVIDER_COMMANDS.map((provider4) => scanProvider(provider4, options,
|
|
63986
|
+
Promise.all(PROVIDER_COMMANDS.map((provider4) => scanProvider(provider4, options, queue))),
|
|
63572
63987
|
isCommandOnPath("git", options.env, options.platform)
|
|
63573
63988
|
]);
|
|
63574
63989
|
return {
|
|
@@ -63586,23 +64001,61 @@ function sameCapabilities(a, b) {
|
|
|
63586
64001
|
});
|
|
63587
64002
|
return comparable(a) === comparable(b);
|
|
63588
64003
|
}
|
|
64004
|
+
async function executablesFingerprint(env, platform3) {
|
|
64005
|
+
const entries = await Promise.all(
|
|
64006
|
+
PROVIDER_COMMANDS.map(async (provider4) => {
|
|
64007
|
+
const executable = await resolveProviderExecutable(provider4, env, platform3);
|
|
64008
|
+
if (executable === null) return `${provider4.backendKind}:-`;
|
|
64009
|
+
try {
|
|
64010
|
+
const target = await (0, import_promises36.realpath)(executable);
|
|
64011
|
+
const { size, mtimeMs } = await (0, import_promises36.stat)(target);
|
|
64012
|
+
return `${provider4.backendKind}:${target}:${size}:${mtimeMs}`;
|
|
64013
|
+
} catch {
|
|
64014
|
+
return `${provider4.backendKind}:${executable}:?`;
|
|
64015
|
+
}
|
|
64016
|
+
})
|
|
64017
|
+
);
|
|
64018
|
+
return entries.join("\n");
|
|
64019
|
+
}
|
|
63589
64020
|
function createCapabilityInventory(options) {
|
|
63590
64021
|
let last = null;
|
|
63591
64022
|
let running = null;
|
|
63592
|
-
const rescan = () => {
|
|
63593
|
-
running ??=
|
|
63594
|
-
|
|
64023
|
+
const rescan = (reason) => {
|
|
64024
|
+
running ??= (async () => {
|
|
64025
|
+
const startedAt = options.clock.monotonic();
|
|
64026
|
+
const env = options.env();
|
|
64027
|
+
const fingerprint = await executablesFingerprint(env, options.platform);
|
|
64028
|
+
const capabilities = await scanCapabilities({ ...options, env });
|
|
64029
|
+
last = { capabilities, fingerprint };
|
|
64030
|
+
options.log.info("capabilities.scanned", {
|
|
64031
|
+
reason,
|
|
64032
|
+
durationMs: Math.round(options.clock.monotonic() - startedAt)
|
|
64033
|
+
});
|
|
63595
64034
|
return capabilities;
|
|
63596
|
-
}).finally(() => {
|
|
64035
|
+
})().finally(() => {
|
|
63597
64036
|
running = null;
|
|
63598
64037
|
});
|
|
63599
64038
|
return running;
|
|
63600
64039
|
};
|
|
64040
|
+
const youngerThan = (scan, ageMs) => options.clock.now() - scan.capabilities.scannedAt < ageMs;
|
|
63601
64041
|
return {
|
|
63602
64042
|
scan: ({ refresh }) => {
|
|
63603
64043
|
if (running !== null) return running;
|
|
63604
|
-
|
|
63605
|
-
return
|
|
64044
|
+
if (refresh) return rescan("requested");
|
|
64045
|
+
return last !== null && youngerThan(last, options.maxAgeMs) ? Promise.resolve(last.capabilities) : rescan("expired");
|
|
64046
|
+
},
|
|
64047
|
+
latest: () => {
|
|
64048
|
+
if (running !== null) return running;
|
|
64049
|
+
return last === null ? rescan("first") : Promise.resolve(last.capabilities);
|
|
64050
|
+
},
|
|
64051
|
+
rescanIfChanged: async () => {
|
|
64052
|
+
if (running !== null) return running;
|
|
64053
|
+
const previous = last;
|
|
64054
|
+
if (previous === null) return rescan("first");
|
|
64055
|
+
if (!youngerThan(previous, options.staleAfterMs)) return rescan("stale");
|
|
64056
|
+
const fingerprint = await executablesFingerprint(options.env(), options.platform);
|
|
64057
|
+
if (running !== null) return running;
|
|
64058
|
+
return fingerprint === previous.fingerprint ? previous.capabilities : rescan("cli_changed");
|
|
63606
64059
|
}
|
|
63607
64060
|
};
|
|
63608
64061
|
}
|
|
@@ -63863,16 +64316,16 @@ async function openCliEnvironment(options) {
|
|
|
63863
64316
|
if (options.clock.now() < retryAt) return false;
|
|
63864
64317
|
retryAt = options.clock.now() + DEGRADED_RETRY_MS;
|
|
63865
64318
|
const next = await resolve14();
|
|
63866
|
-
const
|
|
64319
|
+
const changed2 = envValue(next.env, "PATH") !== envValue(state.env, "PATH");
|
|
63867
64320
|
state = next;
|
|
63868
|
-
return
|
|
64321
|
+
return changed2;
|
|
63869
64322
|
}
|
|
63870
64323
|
};
|
|
63871
64324
|
}
|
|
63872
64325
|
|
|
63873
64326
|
// src/capabilities/providers/managed.ts
|
|
63874
64327
|
var import_node_crypto17 = require("crypto");
|
|
63875
|
-
var
|
|
64328
|
+
var import_promises37 = require("fs/promises");
|
|
63876
64329
|
var import_node_path38 = require("path");
|
|
63877
64330
|
init_zod();
|
|
63878
64331
|
var PACKAGES = {
|
|
@@ -63889,7 +64342,7 @@ var VERSION = /^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?$/;
|
|
|
63889
64342
|
var selectedSchema = external_exports.record(external_exports.string(), external_exports.string());
|
|
63890
64343
|
async function readManagedProviderVersion(file2, backendKind) {
|
|
63891
64344
|
try {
|
|
63892
|
-
const selected = selectedSchema.parse(JSON.parse(await (0,
|
|
64345
|
+
const selected = selectedSchema.parse(JSON.parse(await (0, import_promises37.readFile)(file2, "utf8")));
|
|
63893
64346
|
const version2 = selected[backendKind];
|
|
63894
64347
|
return version2 !== void 0 && VERSION.test(version2) ? version2 : null;
|
|
63895
64348
|
} catch {
|
|
@@ -63956,7 +64409,7 @@ function selection(root, backendKind, version2) {
|
|
|
63956
64409
|
};
|
|
63957
64410
|
}
|
|
63958
64411
|
async function runnable(file2) {
|
|
63959
|
-
return (0,
|
|
64412
|
+
return (0, import_promises37.stat)(file2).then(
|
|
63960
64413
|
(value2) => value2.isFile(),
|
|
63961
64414
|
() => false
|
|
63962
64415
|
);
|
|
@@ -63999,13 +64452,13 @@ function createManagedProviderClis(options) {
|
|
|
63999
64452
|
return next;
|
|
64000
64453
|
};
|
|
64001
64454
|
const persist = async () => {
|
|
64002
|
-
await (0,
|
|
64455
|
+
await (0, import_promises37.mkdir)(options.root, { recursive: true, mode: 448 });
|
|
64003
64456
|
const staged = `${file2}.${(0, import_node_crypto17.randomUUID)()}`;
|
|
64004
64457
|
try {
|
|
64005
|
-
await (0,
|
|
64006
|
-
await (0,
|
|
64458
|
+
await (0, import_promises37.writeFile)(staged, JSON.stringify(state), { mode: 384 });
|
|
64459
|
+
await (0, import_promises37.rename)(staged, file2);
|
|
64007
64460
|
} finally {
|
|
64008
|
-
await (0,
|
|
64461
|
+
await (0, import_promises37.rm)(staged, { force: true });
|
|
64009
64462
|
}
|
|
64010
64463
|
};
|
|
64011
64464
|
const activate = async (backendKind, version2) => {
|
|
@@ -64027,7 +64480,7 @@ function createManagedProviderClis(options) {
|
|
|
64027
64480
|
return {
|
|
64028
64481
|
selectionFile: file2,
|
|
64029
64482
|
load: async () => {
|
|
64030
|
-
const raw = await (0,
|
|
64483
|
+
const raw = await (0, import_promises37.readFile)(file2, "utf8").catch((error61) => {
|
|
64031
64484
|
if (error61 instanceof Error && "code" in error61 && error61.code === "ENOENT") return "{}";
|
|
64032
64485
|
throw error61;
|
|
64033
64486
|
});
|
|
@@ -64035,7 +64488,7 @@ function createManagedProviderClis(options) {
|
|
|
64035
64488
|
try {
|
|
64036
64489
|
parsed = selectedSchema.parse(JSON.parse(raw));
|
|
64037
64490
|
} catch {
|
|
64038
|
-
await (0,
|
|
64491
|
+
await (0, import_promises37.rename)(file2, `${file2}.invalid.${(0, import_node_crypto17.randomUUID)()}`).catch(() => void 0);
|
|
64039
64492
|
return;
|
|
64040
64493
|
}
|
|
64041
64494
|
for (const [backendKind, version2] of Object.entries(parsed)) {
|
|
@@ -64055,7 +64508,7 @@ function createManagedProviderClis(options) {
|
|
|
64055
64508
|
const groups = await Promise.all(
|
|
64056
64509
|
Object.keys(PACKAGES).map(async (backendKind) => {
|
|
64057
64510
|
const directory = (0, import_node_path38.join)(options.root, "versions", backendKind);
|
|
64058
|
-
const versions = await (0,
|
|
64511
|
+
const versions = await (0, import_promises37.readdir)(directory).catch((error61) => {
|
|
64059
64512
|
if (error61 instanceof Error && "code" in error61 && error61.code === "ENOENT") return [];
|
|
64060
64513
|
throw error61;
|
|
64061
64514
|
});
|
|
@@ -64092,7 +64545,7 @@ function createManagedProviderClis(options) {
|
|
|
64092
64545
|
const target = (0, import_node_path38.join)(options.root, "versions", backendKind, exact);
|
|
64093
64546
|
const existing = selection(options.root, backendKind, exact);
|
|
64094
64547
|
if (!await runnable(existing.executable) || !await options.probe(existing.executable, backendKind)) {
|
|
64095
|
-
await (0,
|
|
64548
|
+
await (0, import_promises37.mkdir)((0, import_node_path38.dirname)(target), { recursive: true, mode: 448 });
|
|
64096
64549
|
const staged = `${target}.${(0, import_node_crypto17.randomUUID)()}`;
|
|
64097
64550
|
try {
|
|
64098
64551
|
await options.installPackage(provider4.name, exact, staged, provider4.command, signal);
|
|
@@ -64100,10 +64553,10 @@ function createManagedProviderClis(options) {
|
|
|
64100
64553
|
if (!await runnable(built) || !await options.probe(built, backendKind)) {
|
|
64101
64554
|
throw new Error(`${backendKind}@${exact} failed its executable probe`);
|
|
64102
64555
|
}
|
|
64103
|
-
await (0,
|
|
64104
|
-
await (0,
|
|
64556
|
+
await (0, import_promises37.rm)(target, { recursive: true, force: true });
|
|
64557
|
+
await (0, import_promises37.rename)(staged, target);
|
|
64105
64558
|
} finally {
|
|
64106
|
-
await (0,
|
|
64559
|
+
await (0, import_promises37.rm)(staged, { recursive: true, force: true });
|
|
64107
64560
|
}
|
|
64108
64561
|
}
|
|
64109
64562
|
return activate(backendKind, exact);
|
|
@@ -64206,13 +64659,13 @@ ${help.stderr}`);
|
|
|
64206
64659
|
}
|
|
64207
64660
|
|
|
64208
64661
|
// src/capabilities/skills/local-preview.ts
|
|
64209
|
-
var
|
|
64662
|
+
var import_promises42 = require("fs/promises");
|
|
64210
64663
|
var import_node_path43 = __toESM(require("path"));
|
|
64211
64664
|
|
|
64212
64665
|
// ../shared/dist/node/skill-package.js
|
|
64213
64666
|
var import_node_buffer = require("buffer");
|
|
64214
64667
|
var import_node_crypto18 = require("crypto");
|
|
64215
|
-
var
|
|
64668
|
+
var import_promises38 = require("fs/promises");
|
|
64216
64669
|
var import_node_path39 = require("path");
|
|
64217
64670
|
var import_yaml = __toESM(require_dist(), 1);
|
|
64218
64671
|
init_contracts();
|
|
@@ -64308,11 +64761,11 @@ async function readSkillPackageFile(packageRoot, path4, expectedSha256) {
|
|
|
64308
64761
|
if (!normalizedPath || normalizedPath !== path4 || normalizedPath.includes("\\") || components.some((component) => !component || component === "." || component === "..")) {
|
|
64309
64762
|
throw new SkillPackageError("INVALID_PATH", `Invalid Skill package path: ${path4}`, path4);
|
|
64310
64763
|
}
|
|
64311
|
-
const absolutePath = await (0,
|
|
64764
|
+
const absolutePath = await (0, import_promises38.realpath)((0, import_node_path39.resolve)(root, ...components)).catch(() => null);
|
|
64312
64765
|
if (!absolutePath || normalizeRelativePath(root, absolutePath) !== normalizedPath) {
|
|
64313
64766
|
throw new SkillPackageError("INVALID_PATH", `Skill package file was not found: ${path4}`, path4);
|
|
64314
64767
|
}
|
|
64315
|
-
const entryStat = await (0,
|
|
64768
|
+
const entryStat = await (0, import_promises38.lstat)(absolutePath);
|
|
64316
64769
|
if (!entryStat.isFile()) {
|
|
64317
64770
|
throw new SkillPackageError("SPECIAL_FILE_BLOCKED", `Only regular files are allowed in Skill packages: ${path4}`, path4);
|
|
64318
64771
|
}
|
|
@@ -64329,11 +64782,11 @@ async function readSkillPackageFile(packageRoot, path4, expectedSha256) {
|
|
|
64329
64782
|
return { file: read.manifest, bytes: read.bytes };
|
|
64330
64783
|
}
|
|
64331
64784
|
async function requirePackageRoot(packageRoot) {
|
|
64332
|
-
const root = await (0,
|
|
64785
|
+
const root = await (0, import_promises38.realpath)((0, import_node_path39.resolve)(packageRoot)).catch(() => null);
|
|
64333
64786
|
if (!root) {
|
|
64334
64787
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package directory does not exist");
|
|
64335
64788
|
}
|
|
64336
|
-
const rootStat = await (0,
|
|
64789
|
+
const rootStat = await (0, import_promises38.lstat)(root);
|
|
64337
64790
|
if (!rootStat.isDirectory()) {
|
|
64338
64791
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package root must be a directory");
|
|
64339
64792
|
}
|
|
@@ -64353,13 +64806,13 @@ async function walkPackage(root, ignoredPaths) {
|
|
|
64353
64806
|
}
|
|
64354
64807
|
return files;
|
|
64355
64808
|
async function walkDirectory(directory) {
|
|
64356
|
-
const entries = await (0,
|
|
64809
|
+
const entries = await (0, import_promises38.readdir)(directory, { withFileTypes: true });
|
|
64357
64810
|
for (const entry of entries) {
|
|
64358
64811
|
const absolutePath = (0, import_node_path39.resolve)(directory, entry.name);
|
|
64359
64812
|
const normalizedPath = normalizeRelativePath(root, absolutePath);
|
|
64360
64813
|
if (isIgnored(normalizedPath, entry.name, entry.isDirectory(), ignored2))
|
|
64361
64814
|
continue;
|
|
64362
|
-
const entryStat = await (0,
|
|
64815
|
+
const entryStat = await (0, import_promises38.lstat)(absolutePath);
|
|
64363
64816
|
if (entryStat.isSymbolicLink()) {
|
|
64364
64817
|
throw new SkillPackageError("SYMLINK_BLOCKED", `Nested symbolic links are not allowed in Skill packages: ${normalizedPath}`, normalizedPath);
|
|
64365
64818
|
}
|
|
@@ -64468,7 +64921,7 @@ function isSecretPath(path4) {
|
|
|
64468
64921
|
return name.endsWith(".private-key.pem") || name.endsWith(".private-key.key");
|
|
64469
64922
|
}
|
|
64470
64923
|
async function readPackageFile(file2) {
|
|
64471
|
-
const bytes = await (0,
|
|
64924
|
+
const bytes = await (0, import_promises38.readFile)(file2.absolutePath);
|
|
64472
64925
|
return {
|
|
64473
64926
|
bytes,
|
|
64474
64927
|
manifest: {
|
|
@@ -64639,13 +65092,13 @@ function uint642(value2) {
|
|
|
64639
65092
|
|
|
64640
65093
|
// src/capabilities/skills/local-sources.ts
|
|
64641
65094
|
var import_node_crypto20 = require("crypto");
|
|
64642
|
-
var
|
|
65095
|
+
var import_promises40 = require("fs/promises");
|
|
64643
65096
|
var import_node_path41 = __toESM(require("path"));
|
|
64644
65097
|
init_type_guards();
|
|
64645
65098
|
|
|
64646
65099
|
// src/capabilities/skills/local-scan.ts
|
|
64647
65100
|
var import_node_crypto19 = require("crypto");
|
|
64648
|
-
var
|
|
65101
|
+
var import_promises39 = require("fs/promises");
|
|
64649
65102
|
var import_node_path40 = __toESM(require("path"));
|
|
64650
65103
|
var MAX_CANDIDATES = 2e3;
|
|
64651
65104
|
var MAX_DIAGNOSTICS = 100;
|
|
@@ -64766,7 +65219,7 @@ function invalid(resolvedRoot, name, error61) {
|
|
|
64766
65219
|
}
|
|
64767
65220
|
async function scanRootAsPackage(pass, resolvedRoot) {
|
|
64768
65221
|
if (!await exists3(import_node_path40.default.join(resolvedRoot.directory, "SKILL.md"))) return null;
|
|
64769
|
-
const canonical = await (0,
|
|
65222
|
+
const canonical = await (0, import_promises39.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
|
|
64770
65223
|
if (isManaged(pass, canonical)) return { candidates: [], diagnostics: [], incomplete: false };
|
|
64771
65224
|
try {
|
|
64772
65225
|
const inspected = await inspectCached(pass, canonical, null);
|
|
@@ -64796,7 +65249,7 @@ async function scanRoot(pass, resolvedRoot) {
|
|
|
64796
65249
|
if (asPackage !== null) return asPackage;
|
|
64797
65250
|
let entries;
|
|
64798
65251
|
try {
|
|
64799
|
-
entries = await (0,
|
|
65252
|
+
entries = await (0, import_promises39.readdir)(resolvedRoot.directory, { withFileTypes: true });
|
|
64800
65253
|
} catch (error61) {
|
|
64801
65254
|
const code = errnoCode(error61);
|
|
64802
65255
|
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
@@ -64814,7 +65267,7 @@ async function scanRoot(pass, resolvedRoot) {
|
|
|
64814
65267
|
incomplete: true
|
|
64815
65268
|
};
|
|
64816
65269
|
}
|
|
64817
|
-
const canonicalRoot = await (0,
|
|
65270
|
+
const canonicalRoot = await (0, import_promises39.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
|
|
64818
65271
|
const scan = { candidates: [], diagnostics: [], incomplete: false };
|
|
64819
65272
|
for (const entry of entries) {
|
|
64820
65273
|
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
@@ -64826,7 +65279,7 @@ async function scanRoot(pass, resolvedRoot) {
|
|
|
64826
65279
|
}
|
|
64827
65280
|
async function scanEntry(pass, resolvedRoot, canonicalRoot, name) {
|
|
64828
65281
|
const rootLabel = resolvedRoot.root.label;
|
|
64829
|
-
const canonical = await (0,
|
|
65282
|
+
const canonical = await (0, import_promises39.realpath)(import_node_path40.default.join(resolvedRoot.directory, name)).catch(() => null);
|
|
64830
65283
|
if (canonical === null) {
|
|
64831
65284
|
const message2 = `Could not resolve Skill ${name}`;
|
|
64832
65285
|
return { kind: "diagnostic", diagnostic: { code: "SOURCE_UNREADABLE", message: message2, rootLabel } };
|
|
@@ -64911,12 +65364,12 @@ function deduplicateByContent(candidates2) {
|
|
|
64911
65364
|
async function fingerprintPackage(root) {
|
|
64912
65365
|
const hash2 = (0, import_node_crypto19.createHash)("sha256").update("alan-skill-stat-fingerprint-v1\0");
|
|
64913
65366
|
const visit2 = async (directory, relativeDirectory) => {
|
|
64914
|
-
const entries = await (0,
|
|
65367
|
+
const entries = await (0, import_promises39.readdir)(directory, { withFileTypes: true });
|
|
64915
65368
|
entries.sort((left, right) => Buffer.compare(Buffer.from(left.name), Buffer.from(right.name)));
|
|
64916
65369
|
for (const entry of entries) {
|
|
64917
65370
|
const relative6 = relativeDirectory ? `${relativeDirectory}/${entry.name}` : entry.name;
|
|
64918
65371
|
const absolute = import_node_path40.default.join(directory, entry.name);
|
|
64919
|
-
const metadata = await (0,
|
|
65372
|
+
const metadata = await (0, import_promises39.lstat)(absolute);
|
|
64920
65373
|
const kind = entryKind(entry);
|
|
64921
65374
|
hash2.update(relative6.normalize("NFC")).update(`\0${kind}\0${metadata.size}\0${metadata.mtimeMs}\0${metadata.mode & 511}\0`);
|
|
64922
65375
|
if (entry.isDirectory()) await visit2(absolute, relative6);
|
|
@@ -64932,7 +65385,7 @@ function entryKind(entry) {
|
|
|
64932
65385
|
}
|
|
64933
65386
|
async function canonicalDirectories(directories) {
|
|
64934
65387
|
const canonical = await Promise.all(
|
|
64935
|
-
directories.map((directory) => (0,
|
|
65388
|
+
directories.map((directory) => (0, import_promises39.realpath)(directory).catch(() => directory))
|
|
64936
65389
|
);
|
|
64937
65390
|
return [...new Set(canonical)];
|
|
64938
65391
|
}
|
|
@@ -64945,7 +65398,7 @@ function isWithinDirectory2(parent, candidate) {
|
|
|
64945
65398
|
}
|
|
64946
65399
|
async function exists3(candidate) {
|
|
64947
65400
|
try {
|
|
64948
|
-
await (0,
|
|
65401
|
+
await (0, import_promises39.access)(candidate);
|
|
64949
65402
|
return true;
|
|
64950
65403
|
} catch {
|
|
64951
65404
|
return false;
|
|
@@ -64953,7 +65406,7 @@ async function exists3(candidate) {
|
|
|
64953
65406
|
}
|
|
64954
65407
|
async function isDirectory3(candidate) {
|
|
64955
65408
|
try {
|
|
64956
|
-
return (await (0,
|
|
65409
|
+
return (await (0, import_promises39.lstat)(candidate)).isDirectory();
|
|
64957
65410
|
} catch {
|
|
64958
65411
|
return false;
|
|
64959
65412
|
}
|
|
@@ -65041,7 +65494,7 @@ async function resolveLocalScanInput(home, context, mode) {
|
|
|
65041
65494
|
async function readSkillSourceConfig(home) {
|
|
65042
65495
|
let content;
|
|
65043
65496
|
try {
|
|
65044
|
-
content = await (0,
|
|
65497
|
+
content = await (0, import_promises40.readFile)(skillSourceConfigPath(home), "utf8");
|
|
65045
65498
|
} catch (error61) {
|
|
65046
65499
|
if (errnoCode(error61) !== "ENOENT") {
|
|
65047
65500
|
return { kind: "invalid_config", diagnostic: "~/.alan/config.toml could not be read" };
|
|
@@ -65158,7 +65611,7 @@ async function scanLocalSkills(home, context, cache2, mode = "incremental", mana
|
|
|
65158
65611
|
}
|
|
65159
65612
|
|
|
65160
65613
|
// src/capabilities/skills/store.ts
|
|
65161
|
-
var
|
|
65614
|
+
var import_promises41 = require("fs/promises");
|
|
65162
65615
|
var import_node_path42 = require("path");
|
|
65163
65616
|
|
|
65164
65617
|
// ../shared/dist/node/alan-skill-identity.js
|
|
@@ -65229,7 +65682,7 @@ function writeLocalSkills(layout, file2) {
|
|
|
65229
65682
|
async function isLocalSkillCurrent(entry, contentHash, ignoredPaths) {
|
|
65230
65683
|
if (entry.contentHash !== contentHash) return false;
|
|
65231
65684
|
try {
|
|
65232
|
-
if (await (0,
|
|
65685
|
+
if (await (0, import_promises41.realpath)(entry.path) !== entry.path) return false;
|
|
65233
65686
|
const inspected = await inspectSkillPackage(entry.path, { expectedName: null, ignoredPaths });
|
|
65234
65687
|
return inspected.contentHash === contentHash;
|
|
65235
65688
|
} catch {
|
|
@@ -65244,7 +65697,7 @@ async function resolveLocalSkill(local, invocation) {
|
|
|
65244
65697
|
}
|
|
65245
65698
|
async function hasSkillFile(directory) {
|
|
65246
65699
|
try {
|
|
65247
|
-
return (await (0,
|
|
65700
|
+
return (await (0, import_promises41.stat)((0, import_node_path42.join)(directory, "SKILL.md"))).isFile();
|
|
65248
65701
|
} catch {
|
|
65249
65702
|
return false;
|
|
65250
65703
|
}
|
|
@@ -65308,7 +65761,7 @@ async function availableSkillIndex(layout) {
|
|
|
65308
65761
|
});
|
|
65309
65762
|
}
|
|
65310
65763
|
if (layout.nativeDir !== null) {
|
|
65311
|
-
const entries = await (0,
|
|
65764
|
+
const entries = await (0, import_promises41.readdir)(layout.nativeDir, { withFileTypes: true }).catch(() => []);
|
|
65312
65765
|
for (const entry of entries) {
|
|
65313
65766
|
if (entry.isDirectory() || entry.isSymbolicLink())
|
|
65314
65767
|
candidates2.push({ directory: (0, import_node_path42.join)(layout.nativeDir, entry.name) });
|
|
@@ -65399,7 +65852,7 @@ async function readLocalSkillFile(layout, ref) {
|
|
|
65399
65852
|
}
|
|
65400
65853
|
async function isDirectory4(candidate) {
|
|
65401
65854
|
try {
|
|
65402
|
-
return (await (0,
|
|
65855
|
+
return (await (0, import_promises42.stat)(candidate)).isDirectory();
|
|
65403
65856
|
} catch {
|
|
65404
65857
|
return false;
|
|
65405
65858
|
}
|
|
@@ -65412,29 +65865,29 @@ async function addSkillSource(home, input2) {
|
|
|
65412
65865
|
return { state: "invalid", diagnostic: `${sourcePath} is not a folder` };
|
|
65413
65866
|
}
|
|
65414
65867
|
const configPath = skillSourceConfigPath(home);
|
|
65415
|
-
await (0,
|
|
65416
|
-
await (0,
|
|
65868
|
+
await (0, import_promises42.mkdir)(import_node_path43.default.dirname(configPath), { recursive: true, mode: 448 });
|
|
65869
|
+
await (0, import_promises42.writeFile)(configPath, DEFAULT_SKILL_CONFIG, { flag: "wx", mode: 384 }).catch(
|
|
65417
65870
|
(error61) => {
|
|
65418
65871
|
if (errnoCode(error61) !== "EEXIST") throw error61;
|
|
65419
65872
|
}
|
|
65420
65873
|
);
|
|
65421
65874
|
const loaded = await readSkillSourceConfig(home);
|
|
65422
65875
|
if (loaded.kind === "invalid_config") return { state: "invalid", diagnostic: loaded.diagnostic };
|
|
65423
|
-
const canonical = await (0,
|
|
65876
|
+
const canonical = await (0, import_promises42.realpath)(sourcePath).catch(() => sourcePath);
|
|
65424
65877
|
for (const source of loaded.config.sources) {
|
|
65425
|
-
if (await (0,
|
|
65878
|
+
if (await (0, import_promises42.realpath)(source.path).catch(() => source.path) === canonical) {
|
|
65426
65879
|
return { state: "already_present", label: source.label };
|
|
65427
65880
|
}
|
|
65428
65881
|
}
|
|
65429
|
-
const current = await (0,
|
|
65430
|
-
const
|
|
65882
|
+
const current = await (0, import_promises42.readFile)(configPath, "utf8");
|
|
65883
|
+
const block2 = [
|
|
65431
65884
|
"",
|
|
65432
65885
|
"[[skills.sources]]",
|
|
65433
65886
|
`path = ${JSON.stringify(sourcePath)}`,
|
|
65434
65887
|
`label = ${JSON.stringify(label)}`,
|
|
65435
65888
|
""
|
|
65436
65889
|
].join("\n");
|
|
65437
|
-
await (0,
|
|
65890
|
+
await (0, import_promises42.writeFile)(configPath, `${current.replace(/\n*$/, "\n")}${block2}`, { mode: 384 });
|
|
65438
65891
|
const reloaded = await readSkillSourceConfig(home);
|
|
65439
65892
|
if (reloaded.kind === "invalid_config") {
|
|
65440
65893
|
return { state: "invalid", diagnostic: reloaded.diagnostic };
|
|
@@ -65443,12 +65896,12 @@ async function addSkillSource(home, input2) {
|
|
|
65443
65896
|
}
|
|
65444
65897
|
|
|
65445
65898
|
// src/capabilities/skills/local-upload.ts
|
|
65446
|
-
var
|
|
65899
|
+
var import_promises44 = require("fs/promises");
|
|
65447
65900
|
|
|
65448
65901
|
// ../shared/dist/node/skill-bundle.js
|
|
65449
65902
|
var import_node_buffer2 = require("buffer");
|
|
65450
65903
|
var import_node_crypto22 = require("crypto");
|
|
65451
|
-
var
|
|
65904
|
+
var import_promises43 = require("fs/promises");
|
|
65452
65905
|
var import_node_path44 = require("path");
|
|
65453
65906
|
var import_node_stream = require("stream");
|
|
65454
65907
|
var import_node_zlib = require("zlib");
|
|
@@ -65459,7 +65912,7 @@ async function createSkillBundle(packageRoot, options = {}) {
|
|
|
65459
65912
|
const archive = (0, import_tar_stream.pack)();
|
|
65460
65913
|
const tarPromise = collectStream(archive);
|
|
65461
65914
|
for (const file2 of before.files) {
|
|
65462
|
-
const bytes2 = await (0,
|
|
65915
|
+
const bytes2 = await (0, import_promises43.readFile)((0, import_node_path44.join)(packageRoot, ...file2.path.split("/")));
|
|
65463
65916
|
await addArchiveEntry(archive, {
|
|
65464
65917
|
name: file2.path,
|
|
65465
65918
|
type: "file",
|
|
@@ -65491,7 +65944,7 @@ async function extractSkillBundle(archiveBytes, destination, expected) {
|
|
|
65491
65944
|
throw new Error("Skill archive hash does not match the expected immutable Version");
|
|
65492
65945
|
}
|
|
65493
65946
|
const tarBytes = await decompressBounded(archiveBytes);
|
|
65494
|
-
await (0,
|
|
65947
|
+
await (0, import_promises43.mkdir)(destination, { recursive: false, mode: 448 });
|
|
65495
65948
|
try {
|
|
65496
65949
|
await extractTar(tarBytes, destination);
|
|
65497
65950
|
const inspected = await inspectSkillPackage(destination, { expectedName: null });
|
|
@@ -65499,7 +65952,7 @@ async function extractSkillBundle(archiveBytes, destination, expected) {
|
|
|
65499
65952
|
throw new Error("Extracted Skill package hash does not match the expected immutable Version");
|
|
65500
65953
|
}
|
|
65501
65954
|
} catch (error61) {
|
|
65502
|
-
await (0,
|
|
65955
|
+
await (0, import_promises43.rm)(destination, { recursive: true, force: true });
|
|
65503
65956
|
throw error61;
|
|
65504
65957
|
}
|
|
65505
65958
|
}
|
|
@@ -65575,8 +66028,8 @@ async function extractEntry(header, stream, destination, limits) {
|
|
|
65575
66028
|
throw new Error(`Skill archive file size is invalid: ${path4}`);
|
|
65576
66029
|
}
|
|
65577
66030
|
const outputPath = (0, import_node_path44.join)(destination, ...path4.split("/"));
|
|
65578
|
-
await (0,
|
|
65579
|
-
await (0,
|
|
66031
|
+
await (0, import_promises43.mkdir)((0, import_node_path44.dirname)(outputPath), { recursive: true, mode: 448 });
|
|
66032
|
+
await (0, import_promises43.writeFile)(outputPath, bytes, { mode: (header.mode ?? 420) & 73 ? 493 : 420 });
|
|
65580
66033
|
}
|
|
65581
66034
|
function requireSafeArchivePath(value2) {
|
|
65582
66035
|
const normalized2 = value2.replaceAll("\\", "/").normalize("NFC");
|
|
@@ -65602,8 +66055,8 @@ async function publishLocalSkill(options) {
|
|
|
65602
66055
|
if (Date.parse(request2.uploadGrant.expiresAt) <= (options.now ?? Date.now())) {
|
|
65603
66056
|
throw new RuntimeFault("invalid_file", "Skill upload grant expired");
|
|
65604
66057
|
}
|
|
65605
|
-
const folder = await (0,
|
|
65606
|
-
if (!folder.isDirectory() || await (0,
|
|
66058
|
+
const folder = await (0, import_promises44.lstat)(entry.path);
|
|
66059
|
+
if (!folder.isDirectory() || await (0, import_promises44.realpath)(entry.path) !== entry.path) {
|
|
65607
66060
|
throw new RuntimeFault("invalid_file", "Skill folder moved since the last scan");
|
|
65608
66061
|
}
|
|
65609
66062
|
const bundle = await createSkillBundle(entry.path, {
|
|
@@ -65632,7 +66085,7 @@ async function publishLocalSkill(options) {
|
|
|
65632
66085
|
// src/capabilities/skills/native-index.ts
|
|
65633
66086
|
var import_node_crypto23 = require("crypto");
|
|
65634
66087
|
var import_node_fs16 = require("fs");
|
|
65635
|
-
var
|
|
66088
|
+
var import_promises45 = require("fs/promises");
|
|
65636
66089
|
var import_node_path45 = require("path");
|
|
65637
66090
|
var ALAN_SKILLS_PLUGIN_NAME = "alan";
|
|
65638
66091
|
var PLUGIN_MANIFEST = `${JSON.stringify(
|
|
@@ -65646,32 +66099,32 @@ var PLUGIN_MANIFEST = `${JSON.stringify(
|
|
|
65646
66099
|
`;
|
|
65647
66100
|
async function entryKind2(path4) {
|
|
65648
66101
|
try {
|
|
65649
|
-
return (await (0,
|
|
66102
|
+
return (await (0, import_promises45.lstat)(path4)).isSymbolicLink() ? "link" : "other";
|
|
65650
66103
|
} catch (error61) {
|
|
65651
66104
|
if (errnoCode(error61) === "ENOENT") return "missing";
|
|
65652
66105
|
throw error61;
|
|
65653
66106
|
}
|
|
65654
66107
|
}
|
|
65655
66108
|
async function linkTarget(path4) {
|
|
65656
|
-
return (0,
|
|
66109
|
+
return (0, import_promises45.readlink)(path4).catch(() => null);
|
|
65657
66110
|
}
|
|
65658
66111
|
async function removeLink(path4) {
|
|
65659
66112
|
try {
|
|
65660
|
-
await (0,
|
|
66113
|
+
await (0, import_promises45.unlink)(path4);
|
|
65661
66114
|
} catch (error61) {
|
|
65662
66115
|
const code = errnoCode(error61);
|
|
65663
66116
|
if (code === "ENOENT") return;
|
|
65664
66117
|
if (code !== "EPERM" && code !== "EISDIR") throw error61;
|
|
65665
|
-
await (0,
|
|
66118
|
+
await (0, import_promises45.rmdir)(path4);
|
|
65666
66119
|
}
|
|
65667
66120
|
}
|
|
65668
66121
|
async function placeLink(plan2, platform3) {
|
|
65669
66122
|
if (await linkTarget(plan2.path) === plan2.target) return false;
|
|
65670
66123
|
const staged = (0, import_node_path45.join)((0, import_node_path45.dirname)(plan2.path), `.${(0, import_node_path45.basename)(plan2.path)}.${(0, import_node_crypto23.randomUUID)()}.tmp`);
|
|
65671
|
-
await (0,
|
|
66124
|
+
await (0, import_promises45.symlink)(plan2.target, staged, platform3 === "win32" ? "junction" : "dir");
|
|
65672
66125
|
try {
|
|
65673
66126
|
if (platform3 === "win32") await removeLink(plan2.path);
|
|
65674
|
-
await (0,
|
|
66127
|
+
await (0, import_promises45.rename)(staged, plan2.path);
|
|
65675
66128
|
} catch (error61) {
|
|
65676
66129
|
await removeLink(staged).catch(() => void 0);
|
|
65677
66130
|
throw error61;
|
|
@@ -65684,14 +66137,14 @@ function versionTarget(layout, versionId, platform3) {
|
|
|
65684
66137
|
}
|
|
65685
66138
|
async function writeManifest(layout) {
|
|
65686
66139
|
const manifest = (0, import_node_path45.join)(layout.pluginDir, ".claude-plugin", "plugin.json");
|
|
65687
|
-
if (await (0,
|
|
65688
|
-
await (0,
|
|
66140
|
+
if (await (0, import_promises45.readFile)(manifest, "utf8").catch(() => null) === PLUGIN_MANIFEST) return;
|
|
66141
|
+
await (0, import_promises45.mkdir)((0, import_node_path45.dirname)(manifest), { recursive: true, mode: 448 });
|
|
65689
66142
|
const staged = `${manifest}.${(0, import_node_crypto23.randomUUID)()}.tmp`;
|
|
65690
|
-
await (0,
|
|
65691
|
-
await (0,
|
|
66143
|
+
await (0, import_promises45.writeFile)(staged, PLUGIN_MANIFEST, { mode: 384 });
|
|
66144
|
+
await (0, import_promises45.rename)(staged, manifest);
|
|
65692
66145
|
}
|
|
65693
66146
|
async function reconcilePluginSkills(layout, installed, platform3) {
|
|
65694
|
-
await (0,
|
|
66147
|
+
await (0, import_promises45.mkdir)(layout.pluginSkillsDir, { recursive: true, mode: 448 });
|
|
65695
66148
|
const wanted = new Map(installed.map((skill) => [skill.slug, skill]));
|
|
65696
66149
|
let linked = 0;
|
|
65697
66150
|
for (const skill of installed) {
|
|
@@ -65700,16 +66153,16 @@ async function reconcilePluginSkills(layout, installed, platform3) {
|
|
|
65700
66153
|
target: versionTarget(layout, skill.versionId, platform3)
|
|
65701
66154
|
};
|
|
65702
66155
|
if (await entryKind2(plan2.path) === "other") {
|
|
65703
|
-
await (0,
|
|
66156
|
+
await (0, import_promises45.rm)(plan2.path, { recursive: true, force: true });
|
|
65704
66157
|
}
|
|
65705
66158
|
if (await placeLink(plan2, platform3)) linked += 1;
|
|
65706
66159
|
}
|
|
65707
66160
|
let unlinked = 0;
|
|
65708
|
-
for (const name of await (0,
|
|
66161
|
+
for (const name of await (0, import_promises45.readdir)(layout.pluginSkillsDir)) {
|
|
65709
66162
|
if (wanted.has(name)) continue;
|
|
65710
66163
|
const path4 = (0, import_node_path45.join)(layout.pluginSkillsDir, name);
|
|
65711
66164
|
if (await entryKind2(path4) === "link") await removeLink(path4);
|
|
65712
|
-
else await (0,
|
|
66165
|
+
else await (0, import_promises45.rm)(path4, { recursive: true, force: true });
|
|
65713
66166
|
unlinked += 1;
|
|
65714
66167
|
}
|
|
65715
66168
|
return { linked, unlinked };
|
|
@@ -65721,9 +66174,9 @@ async function isOwnCodexLink(layout, path4) {
|
|
|
65721
66174
|
return isWithinDirectory2(layout.pluginSkillsDir, absolute);
|
|
65722
66175
|
}
|
|
65723
66176
|
async function isForeignPackage(layout, path4) {
|
|
65724
|
-
const resolved = await (0,
|
|
66177
|
+
const resolved = await (0, import_promises45.realpath)(path4).catch(() => null);
|
|
65725
66178
|
if (resolved === null) return false;
|
|
65726
|
-
const root = await (0,
|
|
66179
|
+
const root = await (0, import_promises45.realpath)(layout.root).catch(() => layout.root);
|
|
65727
66180
|
return !isWithinDirectory2(root, resolved);
|
|
65728
66181
|
}
|
|
65729
66182
|
async function codexSlot(layout, path4, slug) {
|
|
@@ -65740,7 +66193,7 @@ async function codexSlot(layout, path4, slug) {
|
|
|
65740
66193
|
}
|
|
65741
66194
|
async function unlinkStaleCodexEntries(layout, codexSkillsDir, wanted) {
|
|
65742
66195
|
let unlinked = 0;
|
|
65743
|
-
for (const name of await (0,
|
|
66196
|
+
for (const name of await (0, import_promises45.readdir)(codexSkillsDir)) {
|
|
65744
66197
|
const path4 = (0, import_node_path45.join)(codexSkillsDir, name);
|
|
65745
66198
|
if (wanted.has(name) && !name.endsWith(".tmp")) continue;
|
|
65746
66199
|
if (await entryKind2(path4) !== "link" || !await isOwnCodexLink(layout, path4)) continue;
|
|
@@ -65750,7 +66203,7 @@ async function unlinkStaleCodexEntries(layout, codexSkillsDir, wanted) {
|
|
|
65750
66203
|
return unlinked;
|
|
65751
66204
|
}
|
|
65752
66205
|
async function reconcileCodexSkills(layout, installed, codexSkillsDir, platform3) {
|
|
65753
|
-
await (0,
|
|
66206
|
+
await (0, import_promises45.mkdir)(codexSkillsDir, { recursive: true, mode: 448 });
|
|
65754
66207
|
const report2 = { linked: 0, unlinked: 0, skipped: [] };
|
|
65755
66208
|
for (const skill of installed) {
|
|
65756
66209
|
const path4 = (0, import_node_path45.join)(codexSkillsDir, skill.slug);
|
|
@@ -65787,35 +66240,35 @@ function installedSkillFolders(layout) {
|
|
|
65787
66240
|
|
|
65788
66241
|
// src/capabilities/skills/sync.ts
|
|
65789
66242
|
var import_node_crypto24 = require("crypto");
|
|
65790
|
-
var
|
|
66243
|
+
var import_promises46 = require("fs/promises");
|
|
65791
66244
|
var import_node_path46 = require("path");
|
|
65792
66245
|
init_zod();
|
|
65793
66246
|
var SKILL_PREPARE_WAIT_MS = 15e3;
|
|
65794
66247
|
var RETIRED_VERSION_RETENTION_MS = 24 * 60 * 60 * 1e3;
|
|
65795
66248
|
async function makeFilesReadOnly(directory, platform3) {
|
|
65796
66249
|
if (platform3 === "win32") return;
|
|
65797
|
-
for (const entry of await (0,
|
|
66250
|
+
for (const entry of await (0, import_promises46.readdir)(directory, { withFileTypes: true })) {
|
|
65798
66251
|
const path4 = (0, import_node_path46.join)(directory, entry.name);
|
|
65799
66252
|
if (entry.isDirectory()) await makeFilesReadOnly(path4, platform3);
|
|
65800
66253
|
else if (entry.isFile()) {
|
|
65801
|
-
const executable = ((await (0,
|
|
65802
|
-
await (0,
|
|
66254
|
+
const executable = ((await (0, import_promises46.lstat)(path4)).mode & 64) !== 0;
|
|
66255
|
+
await (0, import_promises46.chmod)(path4, executable ? 365 : 292);
|
|
65803
66256
|
}
|
|
65804
66257
|
}
|
|
65805
66258
|
}
|
|
65806
66259
|
async function install(env, skill, download, signal) {
|
|
65807
66260
|
const { layout, source, platform: platform3 } = env;
|
|
65808
66261
|
const bytes = await source.download(download.url, signal);
|
|
65809
|
-
await (0,
|
|
66262
|
+
await (0, import_promises46.mkdir)(layout.tmpDir, { recursive: true, mode: 448 });
|
|
65810
66263
|
const staging = (0, import_node_path46.join)(layout.tmpDir, (0, import_node_crypto24.randomUUID)());
|
|
65811
66264
|
await extractSkillBundle(Buffer.from(bytes), staging, {
|
|
65812
66265
|
expectedArchiveHash: download.archiveHash,
|
|
65813
66266
|
expectedContentHash: skill.contentHash
|
|
65814
66267
|
});
|
|
65815
66268
|
const target = packageDirectory(layout, skill.versionId);
|
|
65816
|
-
await (0,
|
|
65817
|
-
await (0,
|
|
65818
|
-
await (0,
|
|
66269
|
+
await (0, import_promises46.mkdir)(layout.versionsDir, { recursive: true, mode: 448 });
|
|
66270
|
+
await (0, import_promises46.rm)(target, { recursive: true, force: true });
|
|
66271
|
+
await (0, import_promises46.rename)(staging, target);
|
|
65819
66272
|
await makeFilesReadOnly(target, platform3);
|
|
65820
66273
|
}
|
|
65821
66274
|
var retiredFileSchema = external_exports.record(external_exports.string(), external_exports.number());
|
|
@@ -65827,14 +66280,14 @@ async function sweep(env, keep) {
|
|
|
65827
66280
|
const now = env.now();
|
|
65828
66281
|
const stillRetired = {};
|
|
65829
66282
|
const expired = [];
|
|
65830
|
-
for (const name of await (0,
|
|
66283
|
+
for (const name of await (0, import_promises46.readdir)(layout.versionsDir).catch(() => [])) {
|
|
65831
66284
|
if (kept.has(name)) continue;
|
|
65832
66285
|
const since = retired[name] ?? now;
|
|
65833
66286
|
if (now - since >= RETIRED_VERSION_RETENTION_MS) expired.push(name);
|
|
65834
66287
|
else stillRetired[name] = since;
|
|
65835
66288
|
}
|
|
65836
66289
|
const results = await Promise.allSettled(
|
|
65837
|
-
expired.map((name) => (0,
|
|
66290
|
+
expired.map((name) => (0, import_promises46.rm)((0, import_node_path46.join)(layout.versionsDir, name), { recursive: true, force: true }))
|
|
65838
66291
|
);
|
|
65839
66292
|
results.forEach((result, index) => {
|
|
65840
66293
|
const name = expired[index];
|
|
@@ -65843,7 +66296,7 @@ async function sweep(env, keep) {
|
|
|
65843
66296
|
if (JSON.stringify(stillRetired) !== JSON.stringify(retired)) {
|
|
65844
66297
|
await writeJsonFileAtomic(layout.retiredFile, stillRetired);
|
|
65845
66298
|
}
|
|
65846
|
-
await (0,
|
|
66299
|
+
await (0, import_promises46.rm)(layout.tmpDir, { recursive: true, force: true });
|
|
65847
66300
|
return results.filter((result) => result.status === "fulfilled").length;
|
|
65848
66301
|
}
|
|
65849
66302
|
async function intactSkills(layout) {
|
|
@@ -66171,7 +66624,7 @@ var import_node_path49 = require("path");
|
|
|
66171
66624
|
init_runtime_v2();
|
|
66172
66625
|
|
|
66173
66626
|
// src/capabilities/workspace/approved-paths.ts
|
|
66174
|
-
var
|
|
66627
|
+
var import_promises47 = require("fs/promises");
|
|
66175
66628
|
init_zod();
|
|
66176
66629
|
|
|
66177
66630
|
// src/capabilities/workspace/paths.ts
|
|
@@ -66209,7 +66662,7 @@ var storeSchema = external_exports.object({
|
|
|
66209
66662
|
});
|
|
66210
66663
|
async function realpathOrNull(path4) {
|
|
66211
66664
|
try {
|
|
66212
|
-
return await (0,
|
|
66665
|
+
return await (0, import_promises47.realpath)(path4);
|
|
66213
66666
|
} catch (error61) {
|
|
66214
66667
|
const code = errnoCode(error61);
|
|
66215
66668
|
if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM") {
|
|
@@ -66269,7 +66722,7 @@ async function openApprovedPaths(options) {
|
|
|
66269
66722
|
|
|
66270
66723
|
// src/capabilities/workspace/locks.ts
|
|
66271
66724
|
var import_node_crypto25 = require("crypto");
|
|
66272
|
-
var
|
|
66725
|
+
var import_promises48 = require("fs/promises");
|
|
66273
66726
|
var import_node_path48 = require("path");
|
|
66274
66727
|
init_zod();
|
|
66275
66728
|
var LOCK_FORMAT = 1;
|
|
@@ -66290,7 +66743,7 @@ function repositoryLockKey(commonDir, platform3) {
|
|
|
66290
66743
|
async function readOwner2(path4) {
|
|
66291
66744
|
let text3;
|
|
66292
66745
|
try {
|
|
66293
|
-
text3 = await (0,
|
|
66746
|
+
text3 = await (0, import_promises48.readFile)(path4, "utf8");
|
|
66294
66747
|
} catch (error61) {
|
|
66295
66748
|
if (errnoCode(error61) === "ENOENT") return { kind: "missing" };
|
|
66296
66749
|
return { kind: "unreadable" };
|
|
@@ -66311,7 +66764,7 @@ async function removeIfSame(path4, expected) {
|
|
|
66311
66764
|
if (current.kind !== "owner" || current.owner.since !== expected.since) return;
|
|
66312
66765
|
if (current.owner.pid !== expected.pid || current.owner.holder !== expected.holder) return;
|
|
66313
66766
|
}
|
|
66314
|
-
await (0,
|
|
66767
|
+
await (0, import_promises48.unlink)(path4).catch((error61) => {
|
|
66315
66768
|
if (errnoCode(error61) !== "ENOENT") throw error61;
|
|
66316
66769
|
});
|
|
66317
66770
|
}
|
|
@@ -66336,7 +66789,7 @@ function openRepositoryLocks(options) {
|
|
|
66336
66789
|
await removeIfSame(path4, read.owner);
|
|
66337
66790
|
return null;
|
|
66338
66791
|
}
|
|
66339
|
-
const age = await (0,
|
|
66792
|
+
const age = await (0, import_promises48.stat)(path4).then(
|
|
66340
66793
|
(info) => clock.now() - info.mtimeMs,
|
|
66341
66794
|
() => 0
|
|
66342
66795
|
);
|
|
@@ -66351,12 +66804,12 @@ function openRepositoryLocks(options) {
|
|
|
66351
66804
|
const folder = async (commonDir) => {
|
|
66352
66805
|
const key = repositoryLockKey(commonDir, platform3);
|
|
66353
66806
|
const dir = (0, import_node_path48.join)(options.dir, key);
|
|
66354
|
-
await (0,
|
|
66807
|
+
await (0, import_promises48.mkdir)(dir, { recursive: true, mode: 448 });
|
|
66355
66808
|
return { key, dir };
|
|
66356
66809
|
};
|
|
66357
66810
|
const createExclusive = async (path4, owner) => {
|
|
66358
66811
|
try {
|
|
66359
|
-
const handle = await (0,
|
|
66812
|
+
const handle = await (0, import_promises48.open)(path4, "wx", 384);
|
|
66360
66813
|
try {
|
|
66361
66814
|
await handle.writeFile(JSON.stringify(owner));
|
|
66362
66815
|
} finally {
|
|
@@ -66369,7 +66822,7 @@ function openRepositoryLocks(options) {
|
|
|
66369
66822
|
}
|
|
66370
66823
|
};
|
|
66371
66824
|
const liveRun = async (dir) => {
|
|
66372
|
-
const entries = await (0,
|
|
66825
|
+
const entries = await (0, import_promises48.readdir)(dir);
|
|
66373
66826
|
for (const entry of entries) {
|
|
66374
66827
|
if (!entry.startsWith(RUN_FILE_PREFIX)) continue;
|
|
66375
66828
|
const holder = await heldBy((0, import_node_path48.join)(dir, entry));
|
|
@@ -66634,7 +67087,7 @@ async function openWorkspaces(options) {
|
|
|
66634
67087
|
|
|
66635
67088
|
// src/cli/config.ts
|
|
66636
67089
|
var import_node_os11 = require("os");
|
|
66637
|
-
var
|
|
67090
|
+
var import_node_path70 = require("path");
|
|
66638
67091
|
init_zod();
|
|
66639
67092
|
|
|
66640
67093
|
// src/client/contract.ts
|
|
@@ -66918,7 +67371,7 @@ var mcpConfigResultSchema = external_exports.object({
|
|
|
66918
67371
|
});
|
|
66919
67372
|
|
|
66920
67373
|
// src/client/runtime-client.ts
|
|
66921
|
-
var
|
|
67374
|
+
var import_promises49 = require("fs/promises");
|
|
66922
67375
|
init_acp();
|
|
66923
67376
|
init_runtime_v2();
|
|
66924
67377
|
|
|
@@ -66979,7 +67432,7 @@ var DEFAULT_BACKOFF = { initialMs: 250, maxMs: 3e4 };
|
|
|
66979
67432
|
async function readDiscovery(path4) {
|
|
66980
67433
|
let text3;
|
|
66981
67434
|
try {
|
|
66982
|
-
text3 = await (0,
|
|
67435
|
+
text3 = await (0, import_promises49.readFile)(path4, "utf8");
|
|
66983
67436
|
} catch (error61) {
|
|
66984
67437
|
throw new RuntimeClientError("unavailable", "The runtime is not running", { cause: error61 });
|
|
66985
67438
|
}
|
|
@@ -67362,9 +67815,9 @@ async function sendNativeHookSignal(discoveryPath, hookSignal, signal) {
|
|
|
67362
67815
|
|
|
67363
67816
|
// src/sessions/index.ts
|
|
67364
67817
|
var import_node_crypto31 = require("crypto");
|
|
67365
|
-
var
|
|
67818
|
+
var import_promises69 = require("fs/promises");
|
|
67366
67819
|
var import_node_os10 = require("os");
|
|
67367
|
-
var
|
|
67820
|
+
var import_node_path69 = require("path");
|
|
67368
67821
|
init_runtime_v2();
|
|
67369
67822
|
|
|
67370
67823
|
// src/holder/control-client.ts
|
|
@@ -67700,17 +68153,17 @@ function createConversationMcpAuthorization(options) {
|
|
|
67700
68153
|
}
|
|
67701
68154
|
|
|
67702
68155
|
// src/holder/mcp-helper-access.ts
|
|
67703
|
-
var
|
|
68156
|
+
var import_promises56 = require("fs/promises");
|
|
67704
68157
|
function createHelperMcpAccess(options) {
|
|
67705
68158
|
return {
|
|
67706
68159
|
[Symbol.asyncDispose]: async () => {
|
|
67707
|
-
await (0,
|
|
68160
|
+
await (0, import_promises56.rm)(options.credentialPath, { force: true });
|
|
67708
68161
|
},
|
|
67709
68162
|
url: options.managedMcp.url,
|
|
67710
68163
|
authorization: async (signal) => {
|
|
67711
68164
|
const authorization = await options.managedMcp.authorization(signal);
|
|
67712
68165
|
if (authorization === void 0 || signal.aborted) {
|
|
67713
|
-
await (0,
|
|
68166
|
+
await (0, import_promises56.rm)(options.credentialPath, { force: true });
|
|
67714
68167
|
return void 0;
|
|
67715
68168
|
}
|
|
67716
68169
|
const credential = {
|
|
@@ -67725,7 +68178,7 @@ function createHelperMcpAccess(options) {
|
|
|
67725
68178
|
}
|
|
67726
68179
|
|
|
67727
68180
|
// src/holder/run-inputs.ts
|
|
67728
|
-
var
|
|
68181
|
+
var import_promises57 = require("fs/promises");
|
|
67729
68182
|
var import_node_path54 = require("path");
|
|
67730
68183
|
init_dist();
|
|
67731
68184
|
var NO_RUN_INPUTS = {
|
|
@@ -67742,16 +68195,16 @@ function safeFilename(filename) {
|
|
|
67742
68195
|
async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
67743
68196
|
const dir = (0, import_node_path54.join)(tmpDir, "runs", spec.runId);
|
|
67744
68197
|
const cleanup = async () => {
|
|
67745
|
-
await (0,
|
|
68198
|
+
await (0, import_promises57.rm)(dir, { recursive: true, force: true });
|
|
67746
68199
|
};
|
|
67747
68200
|
try {
|
|
67748
68201
|
const credential = await source.fetchProviderCredential(spec.runId, signal);
|
|
67749
68202
|
const attachments = [];
|
|
67750
|
-
if (spec.attachments?.length) await (0,
|
|
68203
|
+
if (spec.attachments?.length) await (0, import_promises57.mkdir)(dir, { recursive: true, mode: 448 });
|
|
67751
68204
|
for (const [index, attachment] of (spec.attachments ?? []).entries()) {
|
|
67752
68205
|
const bytes = await source.downloadAttachment(spec.runId, attachment.id, signal);
|
|
67753
68206
|
const path4 = (0, import_node_path54.join)(dir, `${index}-${safeFilename(attachment.filename)}`);
|
|
67754
|
-
await (0,
|
|
68207
|
+
await (0, import_promises57.writeFile)(path4, bytes, { mode: 384 });
|
|
67755
68208
|
const imageMimeType = attachment.kind === "image" ? detectImageMimeType(Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)) : null;
|
|
67756
68209
|
attachments.push({
|
|
67757
68210
|
id: attachment.id,
|
|
@@ -67782,14 +68235,14 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
|
67782
68235
|
var import_node_crypto30 = require("crypto");
|
|
67783
68236
|
var import_node_fs22 = require("fs");
|
|
67784
68237
|
var import_node_net3 = require("net");
|
|
67785
|
-
var
|
|
68238
|
+
var import_node_path68 = require("path");
|
|
67786
68239
|
init_runtime_v2();
|
|
67787
68240
|
|
|
67788
68241
|
// src/holder/admission.ts
|
|
67789
68242
|
var import_node_fs19 = require("fs");
|
|
67790
|
-
var
|
|
68243
|
+
var import_promises63 = require("fs/promises");
|
|
67791
68244
|
var import_node_os9 = require("os");
|
|
67792
|
-
var
|
|
68245
|
+
var import_node_path62 = require("path");
|
|
67793
68246
|
init_constants();
|
|
67794
68247
|
|
|
67795
68248
|
// ../shared/dist/node/local-workspace.js
|
|
@@ -67801,7 +68254,7 @@ function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os8.hom
|
|
|
67801
68254
|
}
|
|
67802
68255
|
|
|
67803
68256
|
// src/holder/admission-relocation.ts
|
|
67804
|
-
var
|
|
68257
|
+
var import_promises58 = require("fs/promises");
|
|
67805
68258
|
var import_node_path56 = require("path");
|
|
67806
68259
|
var MAX_RELOCATION_CANDIDATES = 200;
|
|
67807
68260
|
var RELOCATION_BUDGET_MS = 2e4;
|
|
@@ -67837,7 +68290,7 @@ async function originIdentity(git, path4, signal) {
|
|
|
67837
68290
|
}
|
|
67838
68291
|
async function childDirectories(parent, limit) {
|
|
67839
68292
|
try {
|
|
67840
|
-
const entries = await (0,
|
|
68293
|
+
const entries = await (0, import_promises58.readdir)(parent, { withFileTypes: true });
|
|
67841
68294
|
return entries.filter((entry) => entry.isDirectory()).slice(0, limit).map((entry) => (0, import_node_path56.join)(parent, entry.name));
|
|
67842
68295
|
} catch {
|
|
67843
68296
|
return [];
|
|
@@ -67872,29 +68325,79 @@ async function discoverRelocatedWorkspace(search) {
|
|
|
67872
68325
|
return matches[0] ?? null;
|
|
67873
68326
|
}
|
|
67874
68327
|
|
|
68328
|
+
// src/holder/agent-context.ts
|
|
68329
|
+
var import_promises59 = require("fs/promises");
|
|
68330
|
+
var import_node_path57 = require("path");
|
|
68331
|
+
|
|
68332
|
+
// ../agent-core/dist/prompt.js
|
|
68333
|
+
init_chunk_GI3ZGXTY();
|
|
68334
|
+
|
|
68335
|
+
// src/holder/agent-context.ts
|
|
68336
|
+
async function readText4(path4) {
|
|
68337
|
+
return (0, import_promises59.readFile)(path4, "utf8").then(
|
|
68338
|
+
(text3) => text3.trim(),
|
|
68339
|
+
() => null
|
|
68340
|
+
);
|
|
68341
|
+
}
|
|
68342
|
+
async function startCommandState(statusPath) {
|
|
68343
|
+
const [status, exit] = await Promise.all([readText4(statusPath), readText4(`${statusPath}.exit`)]);
|
|
68344
|
+
if (status === null || status === "started") return { state: "pending" };
|
|
68345
|
+
const failed = /^failed (\d+)$/.exec(status);
|
|
68346
|
+
if (failed) return { state: "failed", exitCode: Number(failed[1]) };
|
|
68347
|
+
if (exit === null) return { state: "running" };
|
|
68348
|
+
const code = Number(exit);
|
|
68349
|
+
return code === 0 ? { state: "exited_ok" } : { state: "failed", exitCode: code };
|
|
68350
|
+
}
|
|
68351
|
+
function createAgentContext(deps) {
|
|
68352
|
+
const statusPath = (0, import_node_path57.join)(deps.homeDir, ".alan", "start-commands.status");
|
|
68353
|
+
const logPath = (0, import_node_path57.join)(deps.homeDir, ".alan", "start-commands.log");
|
|
68354
|
+
return async (spec, problems) => {
|
|
68355
|
+
const file2 = (0, import_node_path57.join)(deps.dir, `${spec.conversationId}.json`);
|
|
68356
|
+
const saved = await readJsonFile(file2, agentContextSnapshotSchema);
|
|
68357
|
+
const known = saved.kind === "ok" ? saved.value : void 0;
|
|
68358
|
+
const hasEnvironment = (spec.agentContext ?? known)?.environment !== void 0;
|
|
68359
|
+
const start = hasEnvironment ? await startCommandState(statusPath) : void 0;
|
|
68360
|
+
const snapshot2 = agentContextSnapshot({
|
|
68361
|
+
spec,
|
|
68362
|
+
...spec.approvedWorkspacePaths?.[0] ? { workspaceRoot: spec.approvedWorkspacePaths[0] } : {},
|
|
68363
|
+
problems,
|
|
68364
|
+
...start ? { start } : {},
|
|
68365
|
+
startLogPath: logPath,
|
|
68366
|
+
...known ? { known } : {}
|
|
68367
|
+
});
|
|
68368
|
+
if (snapshot2 === null) return void 0;
|
|
68369
|
+
const rendered = renderAgentContext(snapshot2, known);
|
|
68370
|
+
return {
|
|
68371
|
+
full: rendered.full,
|
|
68372
|
+
...rendered.update ? { update: rendered.update } : {},
|
|
68373
|
+
save: () => writeJsonFileAtomic(file2, snapshot2)
|
|
68374
|
+
};
|
|
68375
|
+
};
|
|
68376
|
+
}
|
|
68377
|
+
|
|
67875
68378
|
// src/holder/checkout-refresh.ts
|
|
67876
|
-
var
|
|
68379
|
+
var import_node_path60 = require("path");
|
|
67877
68380
|
|
|
67878
68381
|
// src/holder/claim-once.ts
|
|
67879
68382
|
var import_node_crypto28 = require("crypto");
|
|
67880
|
-
var
|
|
67881
|
-
var
|
|
68383
|
+
var import_promises60 = require("fs/promises");
|
|
68384
|
+
var import_node_path58 = require("path");
|
|
67882
68385
|
async function claimOnce(dir, name) {
|
|
67883
68386
|
try {
|
|
67884
|
-
await (0,
|
|
67885
|
-
await (await (0,
|
|
68387
|
+
await (0, import_promises60.mkdir)(dir, { recursive: true, mode: 448 });
|
|
68388
|
+
await (await (0, import_promises60.open)((0, import_node_path58.join)(dir, name), "wx")).close();
|
|
67886
68389
|
return true;
|
|
67887
68390
|
} catch {
|
|
67888
68391
|
return false;
|
|
67889
68392
|
}
|
|
67890
68393
|
}
|
|
67891
68394
|
function claimFirstLease(freshnessDir, path4) {
|
|
67892
|
-
return claimOnce((0,
|
|
68395
|
+
return claimOnce((0, import_node_path58.join)(freshnessDir, "leased"), (0, import_node_crypto28.createHash)("sha256").update(path4).digest("hex"));
|
|
67893
68396
|
}
|
|
67894
68397
|
|
|
67895
68398
|
// src/holder/requested-checkout.ts
|
|
67896
|
-
var
|
|
67897
|
-
var
|
|
68399
|
+
var import_promises61 = require("fs/promises");
|
|
68400
|
+
var import_node_path59 = require("path");
|
|
67898
68401
|
var REMOTE2 = "origin";
|
|
67899
68402
|
var REASON_MAX_CHARS = 200;
|
|
67900
68403
|
function firstLine3(text3) {
|
|
@@ -67903,24 +68406,20 @@ function firstLine3(text3) {
|
|
|
67903
68406
|
function reasonOf(output2, command) {
|
|
67904
68407
|
return firstLine3(output2.stderr) || `git ${command} exited ${output2.exitCode}`;
|
|
67905
68408
|
}
|
|
67906
|
-
function noted(
|
|
67907
|
-
return {
|
|
67908
|
-
kind: "noted",
|
|
67909
|
-
line: `Note: ${checkout.path} ${situation}: ${reason}. ${action} before relying on its files.`
|
|
67910
|
-
};
|
|
68409
|
+
function noted(situation, reason, action) {
|
|
68410
|
+
return { kind: "noted", problem: `${situation}: ${reason}`, action };
|
|
67911
68411
|
}
|
|
67912
68412
|
function notSwitched(checkout, current, reason) {
|
|
67913
68413
|
const on2 = current ?? "a detached HEAD";
|
|
67914
68414
|
return noted(
|
|
67915
|
-
checkout,
|
|
67916
68415
|
`is on ${on2}, not ${checkout.branch}, the branch picked for this chat`,
|
|
67917
68416
|
reason,
|
|
67918
68417
|
`Switch it to ${checkout.branch}`
|
|
67919
68418
|
);
|
|
67920
68419
|
}
|
|
67921
68420
|
async function clone2(checkout, deps, signal) {
|
|
67922
|
-
const parent = (0,
|
|
67923
|
-
await (0,
|
|
68421
|
+
const parent = (0, import_node_path59.dirname)(checkout.path);
|
|
68422
|
+
await (0, import_promises61.mkdir)(parent, { recursive: true });
|
|
67924
68423
|
await assertValidBranch(deps.git, parent, checkout.branch, signal);
|
|
67925
68424
|
const output2 = await deps.git.run(
|
|
67926
68425
|
{
|
|
@@ -67942,7 +68441,6 @@ async function clone2(checkout, deps, signal) {
|
|
|
67942
68441
|
);
|
|
67943
68442
|
if (output2.exitCode === 0) return { kind: "moved", how: "cloned" };
|
|
67944
68443
|
return noted(
|
|
67945
|
-
checkout,
|
|
67946
68444
|
`is missing, and cloning it on ${checkout.branch}, the branch picked for this chat, failed`,
|
|
67947
68445
|
reasonOf(output2, "clone"),
|
|
67948
68446
|
`Clone ${checkout.repoUrl} there`
|
|
@@ -68004,7 +68502,6 @@ async function moveOnto(checkout, git, tip, current) {
|
|
|
68004
68502
|
if (localHead === tip) return SWITCHED;
|
|
68005
68503
|
const merged = await git(["merge", "--quiet", "--ff-only", tip]);
|
|
68006
68504
|
return merged.exitCode === 0 ? SWITCHED : noted(
|
|
68007
|
-
checkout,
|
|
68008
68505
|
`is on ${branch} but behind ${REMOTE2}/${branch}`,
|
|
68009
68506
|
reasonOf(merged, "merge"),
|
|
68010
68507
|
"Run `git pull --ff-only` there"
|
|
@@ -68063,7 +68560,6 @@ async function applyRequestedCheckout(checkout, spec, deps, signal) {
|
|
|
68063
68560
|
return await switchTo(checkout, status.branch, `checkout-${spec.runId}`, deps, signal);
|
|
68064
68561
|
} catch (error61) {
|
|
68065
68562
|
return noted(
|
|
68066
|
-
checkout,
|
|
68067
68563
|
`could not be put on ${checkout.branch}, the branch picked for this chat`,
|
|
68068
68564
|
firstLine3(error61 instanceof Error ? error61.message : String(error61)) || "unknown error",
|
|
68069
68565
|
"Check it"
|
|
@@ -68075,11 +68571,15 @@ async function applyRequestedCheckout(checkout, spec, deps, signal) {
|
|
|
68075
68571
|
function short(sha) {
|
|
68076
68572
|
return sha.slice(0, 12);
|
|
68077
68573
|
}
|
|
68078
|
-
function
|
|
68574
|
+
function staleCheckout(path4, snapshot2, tip) {
|
|
68079
68575
|
const checkout = snapshot2 === void 0 ? "is the environment snapshot's checkout" : `is the environment snapshot's checkout of ${snapshot2.branch} (commit ${short(snapshot2.head)})`;
|
|
68080
68576
|
const base = snapshot2 === void 0 ? "its upstream" : `origin/${snapshot2.base}`;
|
|
68081
68577
|
const remote = tip === void 0 ? "may be ahead" : `is ahead at ${short(tip)}`;
|
|
68082
|
-
return
|
|
68578
|
+
return {
|
|
68579
|
+
path: path4,
|
|
68580
|
+
problem: `${checkout}; ${base} ${remote}`,
|
|
68581
|
+
action: "Run `git pull --ff-only` there"
|
|
68582
|
+
};
|
|
68083
68583
|
}
|
|
68084
68584
|
async function fastForward(freshness, operationId, deps, signal) {
|
|
68085
68585
|
var _stack = [];
|
|
@@ -68117,14 +68617,14 @@ async function atFirstLease(freshness, spec, deps, signal) {
|
|
|
68117
68617
|
return first && freshness.fetched && await fastForward(freshness, `refresh-${spec.runId}`, deps, signal) ? "moved" : "noted";
|
|
68118
68618
|
}
|
|
68119
68619
|
}
|
|
68120
|
-
function
|
|
68620
|
+
function problemFor(freshness) {
|
|
68121
68621
|
switch (freshness.state) {
|
|
68122
68622
|
case "behind":
|
|
68123
|
-
return
|
|
68623
|
+
return staleCheckout(freshness.path, freshness.snapshot, freshness.tip);
|
|
68124
68624
|
case "failed":
|
|
68125
|
-
return
|
|
68625
|
+
return staleCheckout(freshness.path, freshness.snapshot);
|
|
68126
68626
|
default:
|
|
68127
|
-
return
|
|
68627
|
+
return staleCheckout(freshness.path, void 0);
|
|
68128
68628
|
}
|
|
68129
68629
|
}
|
|
68130
68630
|
async function checkoutsOf(spec, leaseTargets) {
|
|
@@ -68146,7 +68646,7 @@ function requestedCheckoutsOf(spec, log) {
|
|
|
68146
68646
|
}
|
|
68147
68647
|
async function applyRequestedCheckouts(spec, deps, signal) {
|
|
68148
68648
|
const settled2 = /* @__PURE__ */ new Set();
|
|
68149
|
-
const
|
|
68649
|
+
const problems = [];
|
|
68150
68650
|
for (const checkout of requestedCheckoutsOf(spec, deps.log)) {
|
|
68151
68651
|
const outcome2 = await applyRequestedCheckout(checkout, spec, deps, signal);
|
|
68152
68652
|
deps.log.info("workspace.requested_checkout", {
|
|
@@ -68157,21 +68657,23 @@ async function applyRequestedCheckouts(spec, deps, signal) {
|
|
|
68157
68657
|
...outcome2.kind === "moved" ? { how: outcome2.how } : {}
|
|
68158
68658
|
});
|
|
68159
68659
|
if (outcome2.kind === "on_branch") continue;
|
|
68160
|
-
settled2.add((0,
|
|
68161
|
-
if (outcome2.kind === "noted")
|
|
68660
|
+
settled2.add((0, import_node_path60.resolve)(checkout.path));
|
|
68661
|
+
if (outcome2.kind === "noted") {
|
|
68662
|
+
problems.push({ path: checkout.path, problem: outcome2.problem, action: outcome2.action });
|
|
68663
|
+
}
|
|
68162
68664
|
}
|
|
68163
|
-
return { settled: settled2,
|
|
68665
|
+
return { settled: settled2, problems };
|
|
68164
68666
|
}
|
|
68165
68667
|
async function refreshSnapshotCheckouts(spec, targets, settled2, deps, signal) {
|
|
68166
|
-
const
|
|
68668
|
+
const problems = [];
|
|
68167
68669
|
for (const target of targets) {
|
|
68168
|
-
if (settled2.has((0,
|
|
68670
|
+
if (settled2.has((0, import_node_path60.resolve)(target))) continue;
|
|
68169
68671
|
const freshness = await readCheckoutFreshness(deps.dir, target);
|
|
68170
68672
|
if (freshness === null) continue;
|
|
68171
68673
|
const outcome2 = await atFirstLease(freshness, spec, deps, signal).catch(
|
|
68172
68674
|
() => "noted"
|
|
68173
68675
|
);
|
|
68174
|
-
if (outcome2 === "noted")
|
|
68676
|
+
if (outcome2 === "noted") problems.push(problemFor(freshness));
|
|
68175
68677
|
deps.log.info("workspace.refresh", {
|
|
68176
68678
|
runId: spec.runId,
|
|
68177
68679
|
path: freshness.path,
|
|
@@ -68179,25 +68681,24 @@ async function refreshSnapshotCheckouts(spec, targets, settled2, deps, signal) {
|
|
|
68179
68681
|
outcome: outcome2
|
|
68180
68682
|
});
|
|
68181
68683
|
}
|
|
68182
|
-
return
|
|
68684
|
+
return problems;
|
|
68183
68685
|
}
|
|
68184
68686
|
function createCheckoutRefresh(deps) {
|
|
68185
68687
|
return async (spec, leaseTargets, signal) => {
|
|
68186
|
-
if (spec.providerSessionId !== void 0) return
|
|
68187
|
-
if (!await claimOnce((0,
|
|
68688
|
+
if (spec.providerSessionId !== void 0) return [];
|
|
68689
|
+
if (!await claimOnce((0, import_node_path60.join)(deps.dir, "conversations"), spec.conversationId)) return [];
|
|
68188
68690
|
const requested = await applyRequestedCheckouts(spec, deps, signal);
|
|
68189
68691
|
const targets = await checkoutsOf(spec, leaseTargets);
|
|
68190
|
-
|
|
68191
|
-
...requested.
|
|
68692
|
+
return [
|
|
68693
|
+
...requested.problems,
|
|
68192
68694
|
...await refreshSnapshotCheckouts(spec, targets, requested.settled, deps, signal)
|
|
68193
68695
|
];
|
|
68194
|
-
return lines2.length === 0 ? void 0 : lines2.join("\n");
|
|
68195
68696
|
};
|
|
68196
68697
|
}
|
|
68197
68698
|
|
|
68198
68699
|
// src/holder/lease.ts
|
|
68199
|
-
var
|
|
68200
|
-
var
|
|
68700
|
+
var import_promises62 = require("fs/promises");
|
|
68701
|
+
var import_node_path61 = require("path");
|
|
68201
68702
|
var LEASE_CHECK_EVERY_MS = 5e3;
|
|
68202
68703
|
var MAX_TRANSIENT_FAILURES = 3;
|
|
68203
68704
|
var BACKOFF_BASE_MS = 1e3;
|
|
@@ -68211,8 +68712,8 @@ function identityFailure(code, workspacePath) {
|
|
|
68211
68712
|
return { code, problemCode: "app.workspace.missing", message: MESSAGES[code], workspacePath };
|
|
68212
68713
|
}
|
|
68213
68714
|
async function fileIdentity(path4) {
|
|
68214
|
-
const canonical = await (0,
|
|
68215
|
-
const info = await (0,
|
|
68715
|
+
const canonical = await (0, import_promises62.realpath)(path4);
|
|
68716
|
+
const info = await (0, import_promises62.stat)(canonical, { bigint: true });
|
|
68216
68717
|
return `${canonical}:${info.dev}:${info.ino}`;
|
|
68217
68718
|
}
|
|
68218
68719
|
async function snapshot(git, path4, signal) {
|
|
@@ -68231,7 +68732,7 @@ async function snapshot(git, path4, signal) {
|
|
|
68231
68732
|
workspace: await fileIdentity(path4),
|
|
68232
68733
|
repository: await fileIdentity(commonDir),
|
|
68233
68734
|
worktree: await fileIdentity(gitDir),
|
|
68234
|
-
commonDir: await (0,
|
|
68735
|
+
commonDir: await (0, import_promises62.realpath)(commonDir)
|
|
68235
68736
|
};
|
|
68236
68737
|
} catch {
|
|
68237
68738
|
return null;
|
|
@@ -68244,7 +68745,7 @@ async function gitValue(git, path4, args, signal) {
|
|
|
68244
68745
|
}
|
|
68245
68746
|
async function pathExists(path4) {
|
|
68246
68747
|
try {
|
|
68247
|
-
await (0,
|
|
68748
|
+
await (0, import_promises62.stat)(path4);
|
|
68248
68749
|
return true;
|
|
68249
68750
|
} catch (error61) {
|
|
68250
68751
|
return errnoCode(error61) !== "ENOENT" && errnoCode(error61) !== "ENOTDIR";
|
|
@@ -68253,19 +68754,19 @@ async function pathExists(path4) {
|
|
|
68253
68754
|
async function hasGitMarker(path4) {
|
|
68254
68755
|
let directory;
|
|
68255
68756
|
try {
|
|
68256
|
-
directory = await (0,
|
|
68757
|
+
directory = await (0, import_promises62.realpath)(path4);
|
|
68257
68758
|
} catch {
|
|
68258
68759
|
return true;
|
|
68259
68760
|
}
|
|
68260
68761
|
for (; ; ) {
|
|
68261
68762
|
try {
|
|
68262
|
-
await (0,
|
|
68763
|
+
await (0, import_promises62.stat)((0, import_node_path61.join)(directory, ".git"));
|
|
68263
68764
|
return true;
|
|
68264
68765
|
} catch (error61) {
|
|
68265
68766
|
const code = errnoCode(error61);
|
|
68266
68767
|
if (code !== "ENOENT" && code !== "ENOTDIR") return true;
|
|
68267
68768
|
}
|
|
68268
|
-
const parent = (0,
|
|
68769
|
+
const parent = (0, import_node_path61.dirname)(directory);
|
|
68269
68770
|
if (parent === directory) return false;
|
|
68270
68771
|
directory = parent;
|
|
68271
68772
|
}
|
|
@@ -68429,7 +68930,7 @@ function volumeRoot(path4) {
|
|
|
68429
68930
|
}
|
|
68430
68931
|
async function exists4(path4) {
|
|
68431
68932
|
try {
|
|
68432
|
-
await (0,
|
|
68933
|
+
await (0, import_promises63.stat)(path4);
|
|
68433
68934
|
return true;
|
|
68434
68935
|
} catch {
|
|
68435
68936
|
return false;
|
|
@@ -68437,10 +68938,10 @@ async function exists4(path4) {
|
|
|
68437
68938
|
}
|
|
68438
68939
|
async function inspectReadiness(path4) {
|
|
68439
68940
|
try {
|
|
68440
|
-
if (!(await (0,
|
|
68941
|
+
if (!(await (0, import_promises63.stat)(path4)).isDirectory()) {
|
|
68441
68942
|
return { ready: false, missing: true, message: MESSAGES2.missing };
|
|
68442
68943
|
}
|
|
68443
|
-
await (0,
|
|
68944
|
+
await (0, import_promises63.access)(path4, import_node_fs19.constants.R_OK | import_node_fs19.constants.W_OK | import_node_fs19.constants.X_OK);
|
|
68444
68945
|
return { ready: true };
|
|
68445
68946
|
} catch (error61) {
|
|
68446
68947
|
const code = errnoCode(error61) ?? "";
|
|
@@ -68518,8 +69019,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
|
|
|
68518
69019
|
const { env } = context;
|
|
68519
69020
|
const path4 = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os9.homedir)());
|
|
68520
69021
|
try {
|
|
68521
|
-
await (0,
|
|
68522
|
-
await (0,
|
|
69022
|
+
await (0, import_promises63.mkdir)(path4, { recursive: true, mode: 448 });
|
|
69023
|
+
await (0, import_promises63.access)(path4, import_node_fs19.constants.R_OK | import_node_fs19.constants.W_OK | import_node_fs19.constants.X_OK);
|
|
68523
69024
|
return {
|
|
68524
69025
|
kind: "admitted",
|
|
68525
69026
|
spec: { ...spec, projectPath: path4 },
|
|
@@ -68597,7 +69098,7 @@ var CHECKOUT_NETWORK_TIMEOUT_MS = 12e4;
|
|
|
68597
69098
|
function createHolderWorkspace(machine, clock, log) {
|
|
68598
69099
|
const platform3 = machine.platform ?? process.platform;
|
|
68599
69100
|
const git = createGitRunner({ env: machine.env, platform: platform3, localTimeoutMs: PROBE_TIMEOUT_MS2 });
|
|
68600
|
-
const locks = openRepositoryLocks({ dir: (0,
|
|
69101
|
+
const locks = openRepositoryLocks({ dir: (0, import_node_path62.join)(machine.stateDir, "locks"), clock, platform: platform3 });
|
|
68601
69102
|
return {
|
|
68602
69103
|
admission: {
|
|
68603
69104
|
env: machine.env,
|
|
@@ -68609,7 +69110,7 @@ function createHolderWorkspace(machine, clock, log) {
|
|
|
68609
69110
|
),
|
|
68610
69111
|
approvedRoots: async () => {
|
|
68611
69112
|
const approved = await openApprovedPaths({
|
|
68612
|
-
file: (0,
|
|
69113
|
+
file: (0, import_node_path62.join)(machine.stateDir, "workspaces.json"),
|
|
68613
69114
|
log,
|
|
68614
69115
|
platform: platform3
|
|
68615
69116
|
});
|
|
@@ -68627,7 +69128,11 @@ function createHolderWorkspace(machine, clock, log) {
|
|
|
68627
69128
|
}),
|
|
68628
69129
|
locks,
|
|
68629
69130
|
log,
|
|
68630
|
-
dir: (0,
|
|
69131
|
+
dir: (0, import_node_path62.join)(machine.stateDir, "checkout-freshness")
|
|
69132
|
+
}),
|
|
69133
|
+
prepareAgentContext: createAgentContext({
|
|
69134
|
+
dir: (0, import_node_path62.join)(machine.stateDir, "agent-context"),
|
|
69135
|
+
homeDir: machine.env.HOME || (0, import_node_os9.homedir)()
|
|
68631
69136
|
})
|
|
68632
69137
|
} : {}
|
|
68633
69138
|
};
|
|
@@ -68655,7 +69160,7 @@ async function respondToTurn(runningRunId, gate, driver, request2) {
|
|
|
68655
69160
|
}
|
|
68656
69161
|
|
|
68657
69162
|
// src/holder/session-facts.ts
|
|
68658
|
-
var
|
|
69163
|
+
var import_promises64 = require("fs/promises");
|
|
68659
69164
|
var CLI_RSS_CACHE_MS = 1e4;
|
|
68660
69165
|
var LOGIN_PROBLEM_PREFIX = "cli.auth.";
|
|
68661
69166
|
function isLoginFailure(result) {
|
|
@@ -68681,8 +69186,8 @@ function createSessionFacts(options) {
|
|
|
68681
69186
|
const path4 = await resolveCommandOnPath(command, env, platform3);
|
|
68682
69187
|
if (path4 === null) return null;
|
|
68683
69188
|
try {
|
|
68684
|
-
const real = await (0,
|
|
68685
|
-
const info = await (0,
|
|
69189
|
+
const real = await (0, import_promises64.realpath)(path4);
|
|
69190
|
+
const info = await (0, import_promises64.stat)(real);
|
|
68686
69191
|
return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
|
|
68687
69192
|
} catch {
|
|
68688
69193
|
return null;
|
|
@@ -68769,12 +69274,12 @@ function createSessionFacts(options) {
|
|
|
68769
69274
|
init_acp2();
|
|
68770
69275
|
|
|
68771
69276
|
// src/run-log/archive.ts
|
|
68772
|
-
var
|
|
68773
|
-
var
|
|
69277
|
+
var import_promises65 = require("fs/promises");
|
|
69278
|
+
var import_node_path63 = require("path");
|
|
68774
69279
|
init_runtime_v2();
|
|
68775
69280
|
async function openRunArchive(runsDir) {
|
|
68776
|
-
const path4 = (0,
|
|
68777
|
-
const text3 = await (0,
|
|
69281
|
+
const path4 = (0, import_node_path63.join)((0, import_node_path63.dirname)(runsDir), "archived-runs.txt");
|
|
69282
|
+
const text3 = await (0, import_promises65.readFile)(path4, "utf8").catch((error61) => {
|
|
68778
69283
|
if (errnoCode(error61) === "ENOENT") return "";
|
|
68779
69284
|
throw error61;
|
|
68780
69285
|
});
|
|
@@ -68788,7 +69293,7 @@ async function openRunArchive(runsDir) {
|
|
|
68788
69293
|
add: async (runIds) => {
|
|
68789
69294
|
const added = runIds.filter((runId) => !archived.has(runId));
|
|
68790
69295
|
if (added.length === 0) return;
|
|
68791
|
-
await (0,
|
|
69296
|
+
await (0, import_promises65.appendFile)(path4, `
|
|
68792
69297
|
${added.join("\n")}
|
|
68793
69298
|
`, { mode: 384 });
|
|
68794
69299
|
for (const runId of added) archived.add(runId);
|
|
@@ -68799,11 +69304,11 @@ ${added.join("\n")}
|
|
|
68799
69304
|
// src/run-log/complete.ts
|
|
68800
69305
|
var import_node_crypto29 = require("crypto");
|
|
68801
69306
|
var import_node_fs20 = require("fs");
|
|
68802
|
-
var
|
|
69307
|
+
var import_node_path65 = require("path");
|
|
68803
69308
|
|
|
68804
69309
|
// src/run-log/directory.ts
|
|
68805
|
-
var
|
|
68806
|
-
var
|
|
69310
|
+
var import_promises66 = require("fs/promises");
|
|
69311
|
+
var import_node_path64 = require("path");
|
|
68807
69312
|
init_runtime_v2();
|
|
68808
69313
|
init_zod();
|
|
68809
69314
|
var runMetaSchema = external_exports.object({
|
|
@@ -68829,17 +69334,17 @@ async function readRunMeta(path4) {
|
|
|
68829
69334
|
return read.kind === "ok" ? read.value : null;
|
|
68830
69335
|
}
|
|
68831
69336
|
function runDirectory(runsDir, runId) {
|
|
68832
|
-
const dir = (0,
|
|
69337
|
+
const dir = (0, import_node_path64.join)(runsDir, runId);
|
|
68833
69338
|
return {
|
|
68834
69339
|
dir,
|
|
68835
|
-
log: (0,
|
|
68836
|
-
upload: (0,
|
|
68837
|
-
meta: (0,
|
|
69340
|
+
log: (0, import_node_path64.join)(dir, "log.jsonl"),
|
|
69341
|
+
upload: (0, import_node_path64.join)(dir, "upload.json"),
|
|
69342
|
+
meta: (0, import_node_path64.join)(dir, "run.json")
|
|
68838
69343
|
};
|
|
68839
69344
|
}
|
|
68840
69345
|
async function isRunClaimed(runsDir, runId) {
|
|
68841
69346
|
try {
|
|
68842
|
-
return (await (0,
|
|
69347
|
+
return (await (0, import_promises66.stat)(runDirectory(runsDir, runId).log)).size > 0;
|
|
68843
69348
|
} catch (error61) {
|
|
68844
69349
|
if (errnoCode(error61) === "ENOENT") return false;
|
|
68845
69350
|
throw error61;
|
|
@@ -68848,7 +69353,7 @@ async function isRunClaimed(runsDir, runId) {
|
|
|
68848
69353
|
|
|
68849
69354
|
// src/run-log/complete.ts
|
|
68850
69355
|
function writeLogFile(path4, dir, text3) {
|
|
68851
|
-
const temp = (0,
|
|
69356
|
+
const temp = (0, import_node_path65.join)(dir, `.log.${(0, import_node_crypto29.randomUUID)()}.tmp`);
|
|
68852
69357
|
const fd = (0, import_node_fs20.openSync)(temp, "wx", 384);
|
|
68853
69358
|
try {
|
|
68854
69359
|
(0, import_node_fs20.writeSync)(fd, text3);
|
|
@@ -68877,8 +69382,8 @@ async function writeCompleteRunLog(runsDir, meta3, records) {
|
|
|
68877
69382
|
}
|
|
68878
69383
|
|
|
68879
69384
|
// src/run-log/conversation-index.ts
|
|
68880
|
-
var
|
|
68881
|
-
var
|
|
69385
|
+
var import_promises67 = require("fs/promises");
|
|
69386
|
+
var import_node_path66 = require("path");
|
|
68882
69387
|
init_runtime_v2();
|
|
68883
69388
|
init_zod();
|
|
68884
69389
|
var ORDINALS_PER_SHARD = 1e3;
|
|
@@ -68895,13 +69400,13 @@ var coverageSchema = external_exports.object({
|
|
|
68895
69400
|
nextExpectedOrdinal: external_exports.number().int().positive()
|
|
68896
69401
|
});
|
|
68897
69402
|
function conversationsDirectory(runsDir) {
|
|
68898
|
-
return (0,
|
|
69403
|
+
return (0, import_node_path66.join)((0, import_node_path66.dirname)(runsDir), "conversations");
|
|
68899
69404
|
}
|
|
68900
69405
|
function indexDirectory(runsDir, conversationId) {
|
|
68901
|
-
return (0,
|
|
69406
|
+
return (0, import_node_path66.join)(conversationsDirectory(runsDir), conversationId, "turn-index");
|
|
68902
69407
|
}
|
|
68903
69408
|
function shardPath(runsDir, conversationId, ordinal) {
|
|
68904
|
-
return (0,
|
|
69409
|
+
return (0, import_node_path66.join)(
|
|
68905
69410
|
indexDirectory(runsDir, conversationId),
|
|
68906
69411
|
`${Math.floor(ordinal / ORDINALS_PER_SHARD)}.jsonl`
|
|
68907
69412
|
);
|
|
@@ -68910,10 +69415,10 @@ async function indexConversationRun(runsDir, conversationId, ordinal, assistantO
|
|
|
68910
69415
|
const nextOrdinal = assistantOrdinal + 1;
|
|
68911
69416
|
if (nextOrdinal <= ordinal) throw new Error("Assistant order must follow the prompt");
|
|
68912
69417
|
const path4 = shardPath(runsDir, conversationId, ordinal);
|
|
68913
|
-
await (0,
|
|
68914
|
-
await (0,
|
|
69418
|
+
await (0, import_promises67.mkdir)((0, import_node_path66.dirname)(path4), { recursive: true, mode: 448 });
|
|
69419
|
+
await (0, import_promises67.appendFile)(path4, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
|
|
68915
69420
|
`, { mode: 384 });
|
|
68916
|
-
const coveragePath = (0,
|
|
69421
|
+
const coveragePath = (0, import_node_path66.join)((0, import_node_path66.dirname)((0, import_node_path66.dirname)(path4)), "coverage.json");
|
|
68917
69422
|
const coverage = await readJsonFile(coveragePath, coverageSchema);
|
|
68918
69423
|
const current = coverage.kind === "ok" ? coverage.value : null;
|
|
68919
69424
|
const next = nextCoverage(current, ordinal, nextOrdinal);
|
|
@@ -68928,13 +69433,13 @@ function nextCoverage(current, ordinal, nextOrdinal) {
|
|
|
68928
69433
|
return null;
|
|
68929
69434
|
}
|
|
68930
69435
|
async function readConversationIndexCoverage(runsDir, conversationId) {
|
|
68931
|
-
const path4 = (0,
|
|
69436
|
+
const path4 = (0, import_node_path66.join)((0, import_node_path66.dirname)(indexDirectory(runsDir, conversationId)), "coverage.json");
|
|
68932
69437
|
const result = await readJsonFile(path4, coverageSchema);
|
|
68933
69438
|
return result.kind === "ok" ? result.value : null;
|
|
68934
69439
|
}
|
|
68935
69440
|
async function readConversationRunIndex(runsDir, conversationId, before, limit) {
|
|
68936
69441
|
const directory = indexDirectory(runsDir, conversationId);
|
|
68937
|
-
const names = await (0,
|
|
69442
|
+
const names = await (0, import_promises67.readdir)(directory).catch((error61) => {
|
|
68938
69443
|
if (error61.code === "ENOENT") return [];
|
|
68939
69444
|
throw error61;
|
|
68940
69445
|
});
|
|
@@ -68943,7 +69448,7 @@ async function readConversationRunIndex(runsDir, conversationId, before, limit)
|
|
|
68943
69448
|
).sort((left, right) => right - left);
|
|
68944
69449
|
const selected = [];
|
|
68945
69450
|
for (const shard of shards) {
|
|
68946
|
-
const text3 = await (0,
|
|
69451
|
+
const text3 = await (0, import_promises67.readFile)((0, import_node_path66.join)(directory, `${shard}.jsonl`), "utf8");
|
|
68947
69452
|
const records = text3.split("\n").flatMap((line) => {
|
|
68948
69453
|
if (!line) return [];
|
|
68949
69454
|
const parsed = indexRecordSchema.parse(JSON.parse(line));
|
|
@@ -68968,7 +69473,7 @@ async function readIndexableRun(runsDir, name) {
|
|
|
68968
69473
|
return { conversationId: meta3.conversationId, ordinal, assistantOrdinal, runId: runId.data };
|
|
68969
69474
|
}
|
|
68970
69475
|
async function readIndexableRuns(runsDir) {
|
|
68971
|
-
const names = await (0,
|
|
69476
|
+
const names = await (0, import_promises67.readdir)(runsDir).catch(() => []);
|
|
68972
69477
|
const byConversation = /* @__PURE__ */ new Map();
|
|
68973
69478
|
let next = 0;
|
|
68974
69479
|
const worker = async () => {
|
|
@@ -68998,21 +69503,21 @@ async function writeConversationIndex(directory, runs) {
|
|
|
68998
69503
|
else lines2.push(line);
|
|
68999
69504
|
coverage = nextCoverage(coverage, run2.ordinal, nextOrdinal) ?? coverage;
|
|
69000
69505
|
}
|
|
69001
|
-
await (0,
|
|
69506
|
+
await (0, import_promises67.mkdir)((0, import_node_path66.join)(directory, "turn-index"), { recursive: true, mode: 448 });
|
|
69002
69507
|
for (const [shard, lines2] of shards) {
|
|
69003
|
-
await (0,
|
|
69508
|
+
await (0, import_promises67.writeFile)((0, import_node_path66.join)(directory, "turn-index", `${shard}.jsonl`), `${lines2.join("\n")}
|
|
69004
69509
|
`, {
|
|
69005
69510
|
mode: 384
|
|
69006
69511
|
});
|
|
69007
69512
|
}
|
|
69008
|
-
await (0,
|
|
69513
|
+
await (0, import_promises67.writeFile)((0, import_node_path66.join)(directory, "coverage.json"), `${JSON.stringify(coverage)}
|
|
69009
69514
|
`, {
|
|
69010
69515
|
mode: 384
|
|
69011
69516
|
});
|
|
69012
69517
|
}
|
|
69013
69518
|
async function rebuildConversationIndexes(runsDir) {
|
|
69014
69519
|
const root = conversationsDirectory(runsDir);
|
|
69015
|
-
const exists6 = await (0,
|
|
69520
|
+
const exists6 = await (0, import_promises67.stat)(root).then(
|
|
69016
69521
|
() => true,
|
|
69017
69522
|
(error61) => {
|
|
69018
69523
|
if (errnoCode(error61) === "ENOENT") return false;
|
|
@@ -69021,18 +69526,18 @@ async function rebuildConversationIndexes(runsDir) {
|
|
|
69021
69526
|
);
|
|
69022
69527
|
if (exists6) return 0;
|
|
69023
69528
|
const building = `${root}.rebuilding`;
|
|
69024
|
-
await (0,
|
|
69025
|
-
await (0,
|
|
69529
|
+
await (0, import_promises67.rm)(building, { recursive: true, force: true });
|
|
69530
|
+
await (0, import_promises67.mkdir)(building, { recursive: true, mode: 448 });
|
|
69026
69531
|
const byConversation = await readIndexableRuns(runsDir);
|
|
69027
69532
|
for (const [conversationId, runs] of byConversation) {
|
|
69028
|
-
await writeConversationIndex((0,
|
|
69533
|
+
await writeConversationIndex((0, import_node_path66.join)(building, conversationId), runs);
|
|
69029
69534
|
}
|
|
69030
|
-
await (0,
|
|
69535
|
+
await (0, import_promises67.rename)(building, root);
|
|
69031
69536
|
return byConversation.size;
|
|
69032
69537
|
}
|
|
69033
69538
|
|
|
69034
69539
|
// src/run-log/reader.ts
|
|
69035
|
-
var
|
|
69540
|
+
var import_promises68 = require("fs/promises");
|
|
69036
69541
|
init_runtime_v2();
|
|
69037
69542
|
|
|
69038
69543
|
// src/run-log/tail.ts
|
|
@@ -69055,7 +69560,7 @@ function firstRecordLength(bytes) {
|
|
|
69055
69560
|
return bytes.indexOf(RUN_LOG_RECORD_SEPARATOR) + 1;
|
|
69056
69561
|
}
|
|
69057
69562
|
async function openRunLogReader(path4) {
|
|
69058
|
-
const handle = await (0,
|
|
69563
|
+
const handle = await (0, import_promises68.open)(path4, "r");
|
|
69059
69564
|
const readAt = async (position, length) => {
|
|
69060
69565
|
const buffer = Buffer.alloc(length);
|
|
69061
69566
|
const { bytesRead } = await handle.read(buffer, 0, length, position);
|
|
@@ -69089,7 +69594,7 @@ async function openRunLogReader(path4) {
|
|
|
69089
69594
|
};
|
|
69090
69595
|
}
|
|
69091
69596
|
async function readLastRecord(path4) {
|
|
69092
|
-
const handle = await (0,
|
|
69597
|
+
const handle = await (0, import_promises68.open)(path4, "r").catch(() => null);
|
|
69093
69598
|
if (handle === null) return null;
|
|
69094
69599
|
try {
|
|
69095
69600
|
const { size } = await handle.stat();
|
|
@@ -69123,7 +69628,7 @@ var decoder = new TextDecoder();
|
|
|
69123
69628
|
|
|
69124
69629
|
// src/run-log/writer.ts
|
|
69125
69630
|
var import_node_fs21 = require("fs");
|
|
69126
|
-
var
|
|
69631
|
+
var import_node_path67 = require("path");
|
|
69127
69632
|
init_runtime_v2();
|
|
69128
69633
|
function lastSeq(fd, size) {
|
|
69129
69634
|
for (const length of tailWindows(size)) {
|
|
@@ -69139,7 +69644,7 @@ function lastSeq(fd, size) {
|
|
|
69139
69644
|
throw new RuntimeFault("record_too_large", "Run log tail record is larger than any record");
|
|
69140
69645
|
}
|
|
69141
69646
|
function openRunLog(path4, clock) {
|
|
69142
|
-
(0, import_node_fs21.mkdirSync)((0,
|
|
69647
|
+
(0, import_node_fs21.mkdirSync)((0, import_node_path67.dirname)(path4), { recursive: true, mode: 448 });
|
|
69143
69648
|
const fd = (0, import_node_fs21.openSync)(path4, "a+", 384);
|
|
69144
69649
|
let size = (0, import_node_fs21.fstatSync)(fd).size;
|
|
69145
69650
|
let seq = lastSeq(fd, size);
|
|
@@ -69317,8 +69822,12 @@ function fitForRunLog(update) {
|
|
|
69317
69822
|
async function runWithInputs({ spec, leaseTargets, skills }, context, sink, signal) {
|
|
69318
69823
|
var _stack = [];
|
|
69319
69824
|
try {
|
|
69320
|
-
const
|
|
69825
|
+
const workspace = context.workspace;
|
|
69826
|
+
const sessionContext = (workspace?.refreshFirstCheckout?.(spec, leaseTargets, signal) ?? Promise.resolve([])).catch((error61) => {
|
|
69321
69827
|
context.log.warn("workspace.refresh_failed", { runId: spec.runId, error: error61 });
|
|
69828
|
+
return [];
|
|
69829
|
+
}).then((problems) => workspace?.prepareAgentContext?.(spec, problems)).catch((error61) => {
|
|
69830
|
+
context.log.warn("holder.agent_context_failed", { runId: spec.runId, error: error61 });
|
|
69322
69831
|
return void 0;
|
|
69323
69832
|
});
|
|
69324
69833
|
let inputs;
|
|
@@ -69331,17 +69840,37 @@ async function runWithInputs({ spec, leaseTargets, skills }, context, sink, sign
|
|
|
69331
69840
|
message: `Could not fetch this run's attachments or provider credential: ${error61 instanceof Error ? error61.message : String(error61)}`
|
|
69332
69841
|
};
|
|
69333
69842
|
}
|
|
69334
|
-
const
|
|
69843
|
+
const agentContext = await sessionContext;
|
|
69335
69844
|
const prepared = __using(_stack, inputs, true);
|
|
69336
|
-
const run2 = (turnSink, turnSignal) =>
|
|
69845
|
+
const run2 = async (turnSink, turnSignal) => {
|
|
69846
|
+
const result = await context.driver.runTurn(
|
|
69847
|
+
spec,
|
|
69848
|
+
turnSink,
|
|
69849
|
+
turnSignal,
|
|
69850
|
+
agentContext === void 0 ? prepared : {
|
|
69851
|
+
...prepared,
|
|
69852
|
+
agentContext: {
|
|
69853
|
+
full: agentContext.full,
|
|
69854
|
+
...agentContext.update ? { update: agentContext.update } : {}
|
|
69855
|
+
}
|
|
69856
|
+
}
|
|
69857
|
+
);
|
|
69858
|
+
if (agentContext !== void 0 && result.outcome !== "rejected") {
|
|
69859
|
+
await agentContext.save().catch((error61) => {
|
|
69860
|
+
context.log.warn("holder.agent_context_save_failed", { runId: spec.runId, error: error61 });
|
|
69861
|
+
});
|
|
69862
|
+
}
|
|
69863
|
+
return result;
|
|
69864
|
+
};
|
|
69865
|
+
if (workspace === void 0) return await run2(sink, signal);
|
|
69866
|
+
return await runLeased(
|
|
69337
69867
|
spec,
|
|
69338
|
-
|
|
69339
|
-
|
|
69340
|
-
|
|
69868
|
+
leaseTargets,
|
|
69869
|
+
{ ...context, lease: workspace.lease },
|
|
69870
|
+
sink,
|
|
69871
|
+
signal,
|
|
69872
|
+
run2
|
|
69341
69873
|
);
|
|
69342
|
-
if (context.workspace === void 0) return await run2(sink, signal);
|
|
69343
|
-
const leased = { ...context, lease: context.workspace.lease };
|
|
69344
|
-
return await runLeased(spec, leaseTargets, leased, sink, signal, run2);
|
|
69345
69874
|
} catch (_) {
|
|
69346
69875
|
var _error = _, _hasError = true;
|
|
69347
69876
|
} finally {
|
|
@@ -69475,7 +70004,7 @@ async function runHolder({
|
|
|
69475
70004
|
try {
|
|
69476
70005
|
const identity = await readProcessIdentity(process.pid);
|
|
69477
70006
|
if (identity === null) throw new RuntimeFault("internal", "Cannot read own process identity");
|
|
69478
|
-
const _engines = __using(_stack, recordSpawnedEngines(engineRecordsPath((0,
|
|
70007
|
+
const _engines = __using(_stack, recordSpawnedEngines(engineRecordsPath((0, import_node_path68.dirname)(launch.statusPath)), clock, log));
|
|
69479
70008
|
const holder = {
|
|
69480
70009
|
state: "idle",
|
|
69481
70010
|
runId: null,
|
|
@@ -69769,7 +70298,7 @@ var DEFAULT_MAX_ACTIVE_RUNS = 32;
|
|
|
69769
70298
|
var HOLDER_BUSY = "busy";
|
|
69770
70299
|
async function listIds(dir, schema) {
|
|
69771
70300
|
const ids = [];
|
|
69772
|
-
for (const name of await (0,
|
|
70301
|
+
for (const name of await (0, import_promises69.readdir)(dir).catch(() => [])) {
|
|
69773
70302
|
const parsed = schema.safeParse(name);
|
|
69774
70303
|
if (parsed.success) ids.push(parsed.data);
|
|
69775
70304
|
}
|
|
@@ -69783,14 +70312,14 @@ function holderIdentity(status) {
|
|
|
69783
70312
|
return command === void 0 ? { pid, startedAt } : { pid, startedAt, command };
|
|
69784
70313
|
}
|
|
69785
70314
|
function sessionFiles(paths, conversationId) {
|
|
69786
|
-
const dir = (0,
|
|
69787
|
-
return { dir, launch: (0,
|
|
70315
|
+
const dir = (0, import_node_path69.join)(paths.sessions, conversationId);
|
|
70316
|
+
return { dir, launch: (0, import_node_path69.join)(dir, "launch.json"), status: (0, import_node_path69.join)(dir, "holder.json") };
|
|
69788
70317
|
}
|
|
69789
70318
|
async function removeHolderFiles(files) {
|
|
69790
70319
|
for (const path4 of [files.launch, files.status, engineRecordsPath(files.dir)]) {
|
|
69791
|
-
await (0,
|
|
70320
|
+
await (0, import_promises69.rm)(path4, { force: true });
|
|
69792
70321
|
}
|
|
69793
|
-
await (0,
|
|
70322
|
+
await (0, import_promises69.rmdir)(files.dir).catch((error61) => {
|
|
69794
70323
|
if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(errnoCode(error61) ?? "")) throw error61;
|
|
69795
70324
|
});
|
|
69796
70325
|
}
|
|
@@ -69980,7 +70509,7 @@ async function openSessions(deps) {
|
|
|
69980
70509
|
const meta3 = await readRunMeta(dir.meta);
|
|
69981
70510
|
const last = await readLastRecord(dir.log);
|
|
69982
70511
|
if (meta3 === null || last === null) return null;
|
|
69983
|
-
const logged = await (0,
|
|
70512
|
+
const logged = await (0, import_promises69.stat)(dir.log).catch((error61) => {
|
|
69984
70513
|
if (errnoCode(error61) === "ENOENT") return null;
|
|
69985
70514
|
throw error61;
|
|
69986
70515
|
});
|
|
@@ -70292,7 +70821,7 @@ function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node
|
|
|
70292
70821
|
providerProbes: ALAN_RUNTIME_PROVIDER_PROBES === "on",
|
|
70293
70822
|
providerToolchain: ALAN_RUNTIME_PROVIDER_NODE !== void 0 && ALAN_RUNTIME_PROVIDER_NPM_CLI !== void 0 ? { node: ALAN_RUNTIME_PROVIDER_NODE, npmCli: ALAN_RUNTIME_PROVIDER_NPM_CLI } : null,
|
|
70294
70823
|
home,
|
|
70295
|
-
configHome: XDG_CONFIG_HOME ?? (0,
|
|
70824
|
+
configHome: XDG_CONFIG_HOME ?? (0, import_node_path70.join)(home, ".config"),
|
|
70296
70825
|
codexHome: resolveCodexHome(CODEX_HOME, home),
|
|
70297
70826
|
...githubProxyConfig({ ALAN_RUNTIME_GITHUB_PROXY, XDG_CONFIG_HOME, GH_CONFIG_DIR }, home),
|
|
70298
70827
|
gitGatewayUrl: ALAN_RUNTIME_GIT_GATEWAY_URL ?? null,
|
|
@@ -70302,13 +70831,13 @@ function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node
|
|
|
70302
70831
|
};
|
|
70303
70832
|
}
|
|
70304
70833
|
function resolveCodexHome(configuredHome, home) {
|
|
70305
|
-
return configuredHome ?? (0,
|
|
70834
|
+
return configuredHome ?? (0, import_node_path70.join)(home, ".codex");
|
|
70306
70835
|
}
|
|
70307
70836
|
function githubProxyConfig(env, home) {
|
|
70308
|
-
const configHome = env.XDG_CONFIG_HOME ?? (0,
|
|
70837
|
+
const configHome = env.XDG_CONFIG_HOME ?? (0, import_node_path70.join)(home, ".config");
|
|
70309
70838
|
return {
|
|
70310
70839
|
githubProxy: env.ALAN_RUNTIME_GITHUB_PROXY === "on",
|
|
70311
|
-
ghConfigDir: env.GH_CONFIG_DIR ?? (0,
|
|
70840
|
+
ghConfigDir: env.GH_CONFIG_DIR ?? (0, import_node_path70.join)(configHome, "gh")
|
|
70312
70841
|
};
|
|
70313
70842
|
}
|
|
70314
70843
|
function serviceEnvironment2(env, profile) {
|
|
@@ -70366,9 +70895,9 @@ function takeEnrollmentCodeFromEnv(env = process.env) {
|
|
|
70366
70895
|
}
|
|
70367
70896
|
|
|
70368
70897
|
// src/cli/context.ts
|
|
70369
|
-
var
|
|
70898
|
+
var import_promises70 = require("fs/promises");
|
|
70370
70899
|
var import_node_os12 = require("os");
|
|
70371
|
-
var
|
|
70900
|
+
var import_node_path71 = require("path");
|
|
70372
70901
|
var DESKTOP_BUNDLE_IDS = {
|
|
70373
70902
|
production: ["com.alan-ai.desktop"],
|
|
70374
70903
|
staging: ["com.alan-ai.desktop.staging"],
|
|
@@ -70408,7 +70937,7 @@ function serviceSpec({ config: config2, paths, self }) {
|
|
|
70408
70937
|
profile: config2.profile,
|
|
70409
70938
|
program: serviceCommand(config2.host, self, launcher),
|
|
70410
70939
|
environment: config2.serviceEnvironment,
|
|
70411
|
-
logPath: (0,
|
|
70940
|
+
logPath: (0, import_node_path71.join)(paths.logs, "service.log"),
|
|
70412
70941
|
associatedBundleIds: DESKTOP_BUNDLE_IDS[config2.profile]
|
|
70413
70942
|
};
|
|
70414
70943
|
}
|
|
@@ -70416,7 +70945,7 @@ async function installedServiceSpec(ctx) {
|
|
|
70416
70945
|
const spec = serviceSpec(ctx);
|
|
70417
70946
|
if (ctx.config.host === "app") return spec;
|
|
70418
70947
|
const layout = installLayout(ctx.config.installDir, ctx.config.profile);
|
|
70419
|
-
const installed = await (0,
|
|
70948
|
+
const installed = await (0, import_promises70.access)(layout.launcher).then(
|
|
70420
70949
|
() => true,
|
|
70421
70950
|
() => false
|
|
70422
70951
|
);
|
|
@@ -70544,7 +71073,7 @@ var manifestRevisionSchema = external_exports.object({ revision: external_export
|
|
|
70544
71073
|
async function manifestRevision(path4) {
|
|
70545
71074
|
let raw;
|
|
70546
71075
|
try {
|
|
70547
|
-
raw = JSON.parse(await (0,
|
|
71076
|
+
raw = JSON.parse(await (0, import_promises71.readFile)(path4, "utf8"));
|
|
70548
71077
|
} catch (error61) {
|
|
70549
71078
|
throw new RuntimeFault("invalid_file", `Cannot read the skill manifest at ${path4}`, {
|
|
70550
71079
|
cause: error61
|
|
@@ -70598,8 +71127,8 @@ async function runSkills(argv) {
|
|
|
70598
71127
|
}
|
|
70599
71128
|
|
|
70600
71129
|
// src/cli/commands/doctor.ts
|
|
70601
|
-
var
|
|
70602
|
-
var
|
|
71130
|
+
var import_promises74 = require("fs/promises");
|
|
71131
|
+
var import_node_path75 = require("path");
|
|
70603
71132
|
init_runtime_v2();
|
|
70604
71133
|
|
|
70605
71134
|
// src/identity/credential.ts
|
|
@@ -70776,18 +71305,18 @@ async function authorizeDevice(input2) {
|
|
|
70776
71305
|
}
|
|
70777
71306
|
|
|
70778
71307
|
// src/identity/enroll.ts
|
|
70779
|
-
var
|
|
71308
|
+
var import_promises72 = require("fs/promises");
|
|
70780
71309
|
init_runtime_v2();
|
|
70781
71310
|
|
|
70782
71311
|
// src/identity/installation.ts
|
|
70783
71312
|
var import_node_crypto33 = require("crypto");
|
|
70784
|
-
var
|
|
71313
|
+
var import_node_path72 = require("path");
|
|
70785
71314
|
init_zod();
|
|
70786
71315
|
var installationFileSchema = external_exports.object({
|
|
70787
71316
|
installationId: external_exports.uuid()
|
|
70788
71317
|
});
|
|
70789
71318
|
function installationPath(paths) {
|
|
70790
|
-
return (0,
|
|
71319
|
+
return (0, import_node_path72.join)(paths.stateDir, "installation.json");
|
|
70791
71320
|
}
|
|
70792
71321
|
async function ensureInstallationId(paths) {
|
|
70793
71322
|
const path4 = installationPath(paths);
|
|
@@ -70880,13 +71409,13 @@ async function enrollFromGrantFile(input2) {
|
|
|
70880
71409
|
clock: input2.clock,
|
|
70881
71410
|
access: input2.access
|
|
70882
71411
|
});
|
|
70883
|
-
await (0,
|
|
71412
|
+
await (0, import_promises72.rm)(input2.grantPath, { force: true });
|
|
70884
71413
|
return machine;
|
|
70885
71414
|
}
|
|
70886
71415
|
|
|
70887
71416
|
// src/identity/migrate-v1.ts
|
|
70888
|
-
var
|
|
70889
|
-
var
|
|
71417
|
+
var import_promises73 = require("fs/promises");
|
|
71418
|
+
var import_node_path73 = require("path");
|
|
70890
71419
|
init_runtime_v2();
|
|
70891
71420
|
init_zod();
|
|
70892
71421
|
var EXIT_POLL_MS = 200;
|
|
@@ -70907,11 +71436,11 @@ var ownerLeaseSchema = external_exports.looseObject({ pid: external_exports.numb
|
|
|
70907
71436
|
function legacyConfigPath(home, profile) {
|
|
70908
71437
|
switch (profile) {
|
|
70909
71438
|
case "production":
|
|
70910
|
-
return (0,
|
|
71439
|
+
return (0, import_node_path73.join)(home, ".alan", "agent", "config.json");
|
|
70911
71440
|
case "staging":
|
|
70912
|
-
return (0,
|
|
71441
|
+
return (0, import_node_path73.join)(home, ".alan-staging", "agent", "config.json");
|
|
70913
71442
|
default:
|
|
70914
|
-
return (0,
|
|
71443
|
+
return (0, import_node_path73.join)(home, ".alan-dev", "agent", "config.json");
|
|
70915
71444
|
}
|
|
70916
71445
|
}
|
|
70917
71446
|
async function findLegacyInstall(home, profile) {
|
|
@@ -70936,8 +71465,8 @@ async function scrubLegacyInstall(install2) {
|
|
|
70936
71465
|
const scrubbed = { ...install2.config, migratedToRuntimeV2: true };
|
|
70937
71466
|
for (const key of SCRUBBED_KEYS) delete scrubbed[key];
|
|
70938
71467
|
await writeJsonFileAtomic(`${install2.configPath}.migrated-v1`, scrubbed);
|
|
70939
|
-
await (0,
|
|
70940
|
-
await (0,
|
|
71468
|
+
await (0, import_promises73.rm)(install2.configPath, { force: true });
|
|
71469
|
+
await (0, import_promises73.rm)(install2.ownerLeasePath, { force: true });
|
|
70941
71470
|
}
|
|
70942
71471
|
async function exchangeCredential(deps) {
|
|
70943
71472
|
const { config: config2 } = deps.install;
|
|
@@ -71046,7 +71575,7 @@ async function loadIdentity(paths, options = {}) {
|
|
|
71046
71575
|
}
|
|
71047
71576
|
|
|
71048
71577
|
// src/cli/commands/status.ts
|
|
71049
|
-
var
|
|
71578
|
+
var import_node_path74 = require("path");
|
|
71050
71579
|
async function serviceStatus(ctx) {
|
|
71051
71580
|
try {
|
|
71052
71581
|
return await createServiceManager(ctx.host, ctx.config.profile).status();
|
|
@@ -71073,7 +71602,7 @@ async function runtimeState(ctx) {
|
|
|
71073
71602
|
const running = await readRunningRuntime(ctx.paths.lock);
|
|
71074
71603
|
if (running === null) return { state: "offline", pid: null, localApi: null };
|
|
71075
71604
|
const discovery = await readJsonFile(
|
|
71076
|
-
(0,
|
|
71605
|
+
(0, import_node_path74.join)(ctx.paths.stateDir, LOCAL_API_DISCOVERY_FILE),
|
|
71077
71606
|
localApiDiscoverySchema
|
|
71078
71607
|
);
|
|
71079
71608
|
const localApi = discovery.kind === "ok" && discovery.value.pid === running.pid ? {
|
|
@@ -71294,7 +71823,7 @@ async function runtimeCheck(ctx, status) {
|
|
|
71294
71823
|
return check2("runtime", "warn", "No runtime is running for this profile");
|
|
71295
71824
|
}
|
|
71296
71825
|
const client = createRuntimeClient({
|
|
71297
|
-
discoveryPath: (0,
|
|
71826
|
+
discoveryPath: (0, import_node_path75.join)(ctx.paths.stateDir, LOCAL_API_DISCOVERY_FILE)
|
|
71298
71827
|
});
|
|
71299
71828
|
try {
|
|
71300
71829
|
const live = await client.status(AbortSignal.timeout(LOCAL_TIMEOUT_MS));
|
|
@@ -71321,7 +71850,7 @@ async function runtimeCheck(ctx, status) {
|
|
|
71321
71850
|
}
|
|
71322
71851
|
}
|
|
71323
71852
|
async function probeHolder(dir, conversationId) {
|
|
71324
|
-
const launch = await readJsonFile((0,
|
|
71853
|
+
const launch = await readJsonFile((0, import_node_path75.join)(dir, "launch.json"), holderLaunchSchema);
|
|
71325
71854
|
if (launch.kind !== "ok") return null;
|
|
71326
71855
|
try {
|
|
71327
71856
|
const reply2 = await withTimeout(
|
|
@@ -71346,8 +71875,8 @@ async function probeHolder(dir, conversationId) {
|
|
|
71346
71875
|
}
|
|
71347
71876
|
}
|
|
71348
71877
|
async function holdersCheck(ctx) {
|
|
71349
|
-
const names = await (0,
|
|
71350
|
-
const holders = (await Promise.all(names.map((name) => probeHolder((0,
|
|
71878
|
+
const names = await (0, import_promises74.readdir)(ctx.paths.sessions).catch(() => []);
|
|
71879
|
+
const holders = (await Promise.all(names.map((name) => probeHolder((0, import_node_path75.join)(ctx.paths.sessions, name), name)))).filter((facts) => facts !== null);
|
|
71351
71880
|
const dead = holders.filter((holder) => !holder.alive).length;
|
|
71352
71881
|
return check2(
|
|
71353
71882
|
"holders",
|
|
@@ -71358,10 +71887,10 @@ async function holdersCheck(ctx) {
|
|
|
71358
71887
|
}
|
|
71359
71888
|
async function freeBytesAt(path4) {
|
|
71360
71889
|
try {
|
|
71361
|
-
const stats = await (0,
|
|
71890
|
+
const stats = await (0, import_promises74.statfs)(path4);
|
|
71362
71891
|
return { path: path4, freeBytes: stats.bavail * stats.bsize };
|
|
71363
71892
|
} catch (error61) {
|
|
71364
|
-
const parent = (0,
|
|
71893
|
+
const parent = (0, import_node_path75.dirname)(path4);
|
|
71365
71894
|
if (parent === path4) throw error61;
|
|
71366
71895
|
return freeBytesAt(parent);
|
|
71367
71896
|
}
|
|
@@ -71497,7 +72026,7 @@ async function runDoctor(argv, context = cliContext) {
|
|
|
71497
72026
|
}
|
|
71498
72027
|
|
|
71499
72028
|
// src/cli/commands/git-credential.ts
|
|
71500
|
-
var
|
|
72029
|
+
var import_promises75 = require("fs/promises");
|
|
71501
72030
|
var import_node_net4 = require("net");
|
|
71502
72031
|
var MAX_RESPONSE_BYTES = 64 * 1024;
|
|
71503
72032
|
async function readAll(stream) {
|
|
@@ -71607,7 +72136,7 @@ async function configure(argv) {
|
|
|
71607
72136
|
}
|
|
71608
72137
|
async function configureGitGateway(config2, gatewayUrl, signal) {
|
|
71609
72138
|
const { launcher } = installLayout(config2.installDir, config2.profile);
|
|
71610
|
-
const installed = await (0,
|
|
72139
|
+
const installed = await (0, import_promises75.access)(launcher).then(
|
|
71611
72140
|
() => true,
|
|
71612
72141
|
() => false
|
|
71613
72142
|
);
|
|
@@ -71634,7 +72163,7 @@ async function runGitCredential(argv) {
|
|
|
71634
72163
|
}
|
|
71635
72164
|
|
|
71636
72165
|
// src/cli/commands/hold.ts
|
|
71637
|
-
var
|
|
72166
|
+
var import_node_path76 = require("path");
|
|
71638
72167
|
init_agent2();
|
|
71639
72168
|
init_runtime_v2();
|
|
71640
72169
|
async function machineAccess(paths, log, conversationId, transport) {
|
|
@@ -71692,7 +72221,7 @@ async function runHold(argv) {
|
|
|
71692
72221
|
const config2 = loadRuntimeConfig();
|
|
71693
72222
|
const paths = runtimePaths(config2.stateDir);
|
|
71694
72223
|
const log = __using(_stack, openFileLog(
|
|
71695
|
-
(0,
|
|
72224
|
+
(0, import_node_path76.join)(paths.logs, `holder-${launch.value.conversationId}.jsonl`),
|
|
71696
72225
|
config2.logLevel,
|
|
71697
72226
|
systemClock
|
|
71698
72227
|
));
|
|
@@ -71703,7 +72232,7 @@ async function runHold(argv) {
|
|
|
71703
72232
|
);
|
|
71704
72233
|
const transport = __using(_stack, createHttpTransport());
|
|
71705
72234
|
const access7 = await machineAccess(paths, log, launch.value.conversationId, transport);
|
|
71706
|
-
const credentialPath = (0,
|
|
72235
|
+
const credentialPath = (0, import_node_path76.join)(paths.tmp, "mcp", `${launch.value.conversationId}.json`);
|
|
71707
72236
|
const managedMcp = __using(_stack, access7.managedMcp === void 0 ? void 0 : createHelperMcpAccess({
|
|
71708
72237
|
managedMcp: access7.managedMcp,
|
|
71709
72238
|
conversationId: launch.value.conversationId,
|
|
@@ -71744,7 +72273,7 @@ async function runHold(argv) {
|
|
|
71744
72273
|
}
|
|
71745
72274
|
|
|
71746
72275
|
// src/cli/commands/hook.ts
|
|
71747
|
-
var
|
|
72276
|
+
var import_node_path77 = require("path");
|
|
71748
72277
|
var RUNTIME_ANSWER_MS = 2e3;
|
|
71749
72278
|
var DEBUG_VARIABLE = "ALAN_HOOK_DEBUG";
|
|
71750
72279
|
function flag(argv, name) {
|
|
@@ -71776,7 +72305,7 @@ async function forwardHook(argv, io) {
|
|
|
71776
72305
|
return "transcript outside provider root";
|
|
71777
72306
|
}
|
|
71778
72307
|
const verdict = await io.send(
|
|
71779
|
-
(0,
|
|
72308
|
+
(0, import_node_path77.join)(io.stateDir, LOCAL_API_DISCOVERY_FILE),
|
|
71780
72309
|
hookSignal,
|
|
71781
72310
|
AbortSignal.timeout(RUNTIME_ANSWER_MS)
|
|
71782
72311
|
);
|
|
@@ -71812,7 +72341,7 @@ async function runHook(argv, overrides = {}) {
|
|
|
71812
72341
|
}
|
|
71813
72342
|
|
|
71814
72343
|
// src/cli/commands/ingestion-hooks.ts
|
|
71815
|
-
var
|
|
72344
|
+
var import_promises76 = require("fs/promises");
|
|
71816
72345
|
var CODEX_TRUST_NOTE = "Codex runs new hooks only after you review them: open /hooks in Codex.";
|
|
71817
72346
|
function isAction(value2) {
|
|
71818
72347
|
return value2 === "enable" || value2 === "disable" || value2 === "status";
|
|
@@ -71835,7 +72364,7 @@ function errorMessage2(error61) {
|
|
|
71835
72364
|
return error61 instanceof Error ? error61.message : String(error61);
|
|
71836
72365
|
}
|
|
71837
72366
|
async function exists5(path4) {
|
|
71838
|
-
return (0,
|
|
72367
|
+
return (0, import_promises76.access)(path4).then(
|
|
71839
72368
|
() => true,
|
|
71840
72369
|
() => false
|
|
71841
72370
|
);
|
|
@@ -71938,10 +72467,10 @@ async function runIntegrationsCommand(argv) {
|
|
|
71938
72467
|
}
|
|
71939
72468
|
|
|
71940
72469
|
// src/cli/commands/legacy.ts
|
|
71941
|
-
var
|
|
72470
|
+
var import_node_path79 = require("path");
|
|
71942
72471
|
|
|
71943
72472
|
// src/cli/commands/setup.ts
|
|
71944
|
-
var
|
|
72473
|
+
var import_node_path78 = require("path");
|
|
71945
72474
|
init_zod();
|
|
71946
72475
|
|
|
71947
72476
|
// src/cli/legacy.ts
|
|
@@ -72023,7 +72552,7 @@ async function grantFileCredential(argv, grantPath, ctx, deps) {
|
|
|
72023
72552
|
return enrollFromGrantFile({
|
|
72024
72553
|
paths: ctx.paths,
|
|
72025
72554
|
storeKind: credentialStoreFlag(argv) ?? ctx.config.credentialStore,
|
|
72026
|
-
grantPath: (0,
|
|
72555
|
+
grantPath: (0, import_node_path78.resolve)(grantPath),
|
|
72027
72556
|
clock: deps.clock,
|
|
72028
72557
|
access: ctx.access
|
|
72029
72558
|
});
|
|
@@ -72099,7 +72628,7 @@ async function runSetup(argv, signal) {
|
|
|
72099
72628
|
var _stack = [];
|
|
72100
72629
|
try {
|
|
72101
72630
|
const ctx = cliContext();
|
|
72102
|
-
const log = __using(_stack, openFileLog((0,
|
|
72631
|
+
const log = __using(_stack, openFileLog((0, import_node_path78.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
|
|
72103
72632
|
const result = await setupMachine(argv, ctx, {
|
|
72104
72633
|
enrollment: (apiUrl) => createEnrollmentClient({ apiUrl }),
|
|
72105
72634
|
isProcessAlive,
|
|
@@ -72182,7 +72711,7 @@ async function runToken(argv, signal) {
|
|
|
72182
72711
|
);
|
|
72183
72712
|
}
|
|
72184
72713
|
const ctx = cliContext();
|
|
72185
|
-
const log = __using(_stack, openFileLog((0,
|
|
72714
|
+
const log = __using(_stack, openFileLog((0, import_node_path79.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
|
|
72186
72715
|
const result = await rotateMachineCredential(ctx, { clock: systemClock, log, signal });
|
|
72187
72716
|
process.stdout.write(`${rotationMessage(result)}
|
|
72188
72717
|
`);
|
|
@@ -72194,8 +72723,8 @@ async function runToken(argv, signal) {
|
|
|
72194
72723
|
}
|
|
72195
72724
|
|
|
72196
72725
|
// src/cli/commands/logout.ts
|
|
72197
|
-
var
|
|
72198
|
-
var
|
|
72726
|
+
var import_promises77 = require("fs/promises");
|
|
72727
|
+
var import_node_path80 = require("path");
|
|
72199
72728
|
init_runtime_v2();
|
|
72200
72729
|
var RUNTIME_EXIT_WAIT_MS = 35e3;
|
|
72201
72730
|
var TURN_END_WAIT_MS = 3e4;
|
|
@@ -72254,9 +72783,9 @@ async function stopHolder(launch, deps, outcome2) {
|
|
|
72254
72783
|
}
|
|
72255
72784
|
async function stopHeldRuns(ctx, deps, outcome2 = "aborted") {
|
|
72256
72785
|
const stopped = [];
|
|
72257
|
-
for (const name of await (0,
|
|
72786
|
+
for (const name of await (0, import_promises77.readdir)(ctx.paths.sessions).catch(() => [])) {
|
|
72258
72787
|
const launch = await readJsonFile(
|
|
72259
|
-
(0,
|
|
72788
|
+
(0, import_node_path80.join)(ctx.paths.sessions, name, "launch.json"),
|
|
72260
72789
|
holderLaunchSchema
|
|
72261
72790
|
);
|
|
72262
72791
|
if (launch.kind !== "ok") continue;
|
|
@@ -72293,13 +72822,13 @@ async function forgetMachineLocally(ctx) {
|
|
|
72293
72822
|
const machine = await readMachineFile(ctx.paths);
|
|
72294
72823
|
if (machine === null) return;
|
|
72295
72824
|
await credentialStoreFor(ctx.paths, machine.credentialStore, ctx.access).clear();
|
|
72296
|
-
await (0,
|
|
72825
|
+
await (0, import_promises77.rm)(ctx.paths.machine, { force: true });
|
|
72297
72826
|
}
|
|
72298
72827
|
async function runLogout(argv, signal) {
|
|
72299
72828
|
var _stack = [];
|
|
72300
72829
|
try {
|
|
72301
72830
|
const ctx = cliContext();
|
|
72302
|
-
const log = __using(_stack, openFileLog((0,
|
|
72831
|
+
const log = __using(_stack, openFileLog((0, import_node_path80.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
|
|
72303
72832
|
const result = await logoutMachine(argv, ctx, {
|
|
72304
72833
|
api: (apiUrl, accessToken) => createApiClient({ apiUrl, accessToken }),
|
|
72305
72834
|
stopHeldRuns,
|
|
@@ -72317,7 +72846,7 @@ async function runLogout(argv, signal) {
|
|
|
72317
72846
|
|
|
72318
72847
|
// src/cli/commands/run.ts
|
|
72319
72848
|
var import_node_fs24 = require("fs");
|
|
72320
|
-
var
|
|
72849
|
+
var import_node_path84 = require("path");
|
|
72321
72850
|
|
|
72322
72851
|
// src/local-api/app-attachments.ts
|
|
72323
72852
|
function createAppAttachments(clock) {
|
|
@@ -72394,9 +72923,9 @@ function createRunAppends() {
|
|
|
72394
72923
|
|
|
72395
72924
|
// src/local-api/server.ts
|
|
72396
72925
|
var import_node_crypto35 = require("crypto");
|
|
72397
|
-
var
|
|
72926
|
+
var import_promises78 = require("fs/promises");
|
|
72398
72927
|
var import_node_http4 = require("http");
|
|
72399
|
-
var
|
|
72928
|
+
var import_node_path81 = require("path");
|
|
72400
72929
|
|
|
72401
72930
|
// src/local-api/guard.ts
|
|
72402
72931
|
var import_node_crypto34 = require("crypto");
|
|
@@ -72713,9 +73242,9 @@ async function nextChangedRuns(bell, signal) {
|
|
|
72713
73242
|
}
|
|
72714
73243
|
if (signal.aborted) return [];
|
|
72715
73244
|
await systemClock.sleep(50, signal);
|
|
72716
|
-
const
|
|
73245
|
+
const changed2 = [...bell.pending];
|
|
72717
73246
|
bell.pending.clear();
|
|
72718
|
-
return
|
|
73247
|
+
return changed2;
|
|
72719
73248
|
}
|
|
72720
73249
|
async function writeChangedTurn(writer, runId, read) {
|
|
72721
73250
|
const { ordinal, state } = read.changed;
|
|
@@ -72735,8 +73264,8 @@ async function streamLocalConversationMessages(deps, conversationId, limit, fram
|
|
|
72735
73264
|
const bell = { pending: /* @__PURE__ */ new Set(), wake: void 0 };
|
|
72736
73265
|
const slot = { current: null };
|
|
72737
73266
|
const _subscription = __using(_stack, deps.appends.subscribe((runId) => {
|
|
72738
|
-
const
|
|
72739
|
-
if (
|
|
73267
|
+
const changed2 = runId ?? slot.current?.runId;
|
|
73268
|
+
if (changed2) bell.pending.add(changed2);
|
|
72740
73269
|
bell.wake?.();
|
|
72741
73270
|
}));
|
|
72742
73271
|
signal.addEventListener("abort", () => bell.wake?.(), { once: true });
|
|
@@ -73439,7 +73968,7 @@ async function serveLocalApi(deps) {
|
|
|
73439
73968
|
startedAtMs,
|
|
73440
73969
|
runtimeVersion: deps.runtimeVersion
|
|
73441
73970
|
};
|
|
73442
|
-
const discoveryPath = (0,
|
|
73971
|
+
const discoveryPath = (0, import_node_path81.join)(deps.stateDir, LOCAL_API_DISCOVERY_FILE);
|
|
73443
73972
|
await writeJsonFileAtomic(discoveryPath, discovery);
|
|
73444
73973
|
const followers = startMaintenance({
|
|
73445
73974
|
everyMs: limits.refreshEveryMs,
|
|
@@ -73473,7 +74002,7 @@ async function serveLocalApi(deps) {
|
|
|
73473
74002
|
await watchedStatus[Symbol.asyncDispose]();
|
|
73474
74003
|
const current = await readJsonFile(discoveryPath, localApiDiscoverySchema);
|
|
73475
74004
|
if (current.kind === "ok" && current.value.token === token) {
|
|
73476
|
-
await (0,
|
|
74005
|
+
await (0, import_promises78.rm)(discoveryPath, { force: true });
|
|
73477
74006
|
}
|
|
73478
74007
|
await closeServer(server);
|
|
73479
74008
|
log.info("local_api.closed", {});
|
|
@@ -73558,7 +74087,7 @@ function machineFeatureActions(deps) {
|
|
|
73558
74087
|
}
|
|
73559
74088
|
|
|
73560
74089
|
// src/cli/commands/machine-plane.ts
|
|
73561
|
-
var
|
|
74090
|
+
var import_node_path83 = require("path");
|
|
73562
74091
|
|
|
73563
74092
|
// src/link/index.ts
|
|
73564
74093
|
init_runtime_v2();
|
|
@@ -77226,7 +77755,7 @@ function refusalFailure(refusal2) {
|
|
|
77226
77755
|
}
|
|
77227
77756
|
|
|
77228
77757
|
// src/link/probe.ts
|
|
77229
|
-
var
|
|
77758
|
+
var import_promises79 = require("dns/promises");
|
|
77230
77759
|
var import_node_net5 = require("net");
|
|
77231
77760
|
var import_node_tls2 = require("tls");
|
|
77232
77761
|
var PROBE_TIMEOUT_MS4 = 5e3;
|
|
@@ -77262,7 +77791,7 @@ async function connectOnce(url3, clock) {
|
|
|
77262
77791
|
}
|
|
77263
77792
|
async function probeEndpoint(url3, clock) {
|
|
77264
77793
|
try {
|
|
77265
|
-
await (0,
|
|
77794
|
+
await (0, import_promises79.lookup)(url3.hostname);
|
|
77266
77795
|
} catch (error61) {
|
|
77267
77796
|
const reason = classifyTransportFailure(error61);
|
|
77268
77797
|
return reason === "other" ? "dns" : reason;
|
|
@@ -77711,7 +78240,7 @@ function createReconciler(host, lifecycle, log, signal) {
|
|
|
77711
78240
|
}
|
|
77712
78241
|
|
|
77713
78242
|
// src/uploader/index.ts
|
|
77714
|
-
var
|
|
78243
|
+
var import_promises80 = require("fs/promises");
|
|
77715
78244
|
init_runtime_v2();
|
|
77716
78245
|
init_zod();
|
|
77717
78246
|
var RETRY_DELAYS_MS = [250, 500, 1e3, 2e3, 5e3, 1e4, 3e4];
|
|
@@ -77859,7 +78388,7 @@ function startUploader({ api, runsDir, clock, log, archive }) {
|
|
|
77859
78388
|
};
|
|
77860
78389
|
const unsealedRunIds = async () => {
|
|
77861
78390
|
const runIds = [];
|
|
77862
|
-
for (const name of await (0,
|
|
78391
|
+
for (const name of await (0, import_promises80.readdir)(runsDir).catch(() => [])) {
|
|
77863
78392
|
const runId = runIdSchema.safeParse(name);
|
|
77864
78393
|
if (runId.success && !sealed.has(runId.data) && !archive?.has(runId.data))
|
|
77865
78394
|
runIds.push(runId.data);
|
|
@@ -77874,13 +78403,13 @@ function startUploader({ api, runsDir, clock, log, archive }) {
|
|
|
77874
78403
|
const dir = runDirectory(runsDir, runId);
|
|
77875
78404
|
const progress = await readJsonFile(dir.upload, uploadProgressSchema);
|
|
77876
78405
|
if (progress.kind !== "ok" || !progress.value.sealed) return false;
|
|
77877
|
-
const sealedAt = (await (0,
|
|
78406
|
+
const sealedAt = (await (0, import_promises80.stat)(dir.upload)).mtimeMs;
|
|
77878
78407
|
if (clock.now() - sealedAt < options.sealedForMs) return false;
|
|
77879
78408
|
return (await readLastRecord(dir.log))?.update.sessionUpdate === "_alan/run.ended";
|
|
77880
78409
|
};
|
|
77881
78410
|
const archivable = async (options) => {
|
|
77882
78411
|
const found = [];
|
|
77883
|
-
for (const name of await (0,
|
|
78412
|
+
for (const name of await (0, import_promises80.readdir)(runsDir).catch(() => [])) {
|
|
77884
78413
|
const runId = runIdSchema.safeParse(name);
|
|
77885
78414
|
if (!runId.success || archive?.has(runId.data)) continue;
|
|
77886
78415
|
try {
|
|
@@ -77976,19 +78505,20 @@ async function startGitHubProxySidecar(deps) {
|
|
|
77976
78505
|
function createCapabilityPublisher(deps) {
|
|
77977
78506
|
const { inventory, log } = deps;
|
|
77978
78507
|
let stored = null;
|
|
77979
|
-
const publish = async (
|
|
77980
|
-
const capabilities = await
|
|
78508
|
+
const publish = async (scanned, onlyChanges) => {
|
|
78509
|
+
const capabilities = await scanned;
|
|
77981
78510
|
if (onlyChanges && stored !== null && sameCapabilities(stored, capabilities)) return;
|
|
77982
78511
|
if (await deps.push(capabilities)) stored = capabilities;
|
|
77983
78512
|
};
|
|
77984
78513
|
const report2 = (error61) => log.warn("capabilities.publish_failed", { error: error61 });
|
|
77985
78514
|
return {
|
|
77986
78515
|
connected: () => {
|
|
77987
|
-
publish(
|
|
78516
|
+
publish(inventory.latest(), false).catch(report2);
|
|
77988
78517
|
},
|
|
77989
78518
|
rescan: () => {
|
|
77990
|
-
publish(true, true).catch(report2);
|
|
78519
|
+
publish(inventory.scan({ refresh: true }), true).catch(report2);
|
|
77991
78520
|
},
|
|
78521
|
+
rescanIfChanged: () => publish(inventory.rescanIfChanged(), true).catch(report2),
|
|
77992
78522
|
answerScan: async (request2) => {
|
|
77993
78523
|
const capabilities = await inventory.scan({ refresh: request2.refresh === true });
|
|
77994
78524
|
stored = capabilities;
|
|
@@ -78081,12 +78611,12 @@ async function startMachineNativeIngest(deps) {
|
|
|
78081
78611
|
}
|
|
78082
78612
|
|
|
78083
78613
|
// src/cli/commands/run-updates.ts
|
|
78084
|
-
var
|
|
78614
|
+
var import_node_path82 = require("path");
|
|
78085
78615
|
init_runtime_v2();
|
|
78086
78616
|
var UPDATE_CHECK_EVERY_MS = 6 * 60 * 60 * 1e3;
|
|
78087
78617
|
var DEFERRED_RETRY_MS = 5 * 60 * 1e3;
|
|
78088
78618
|
function isInstalledBundle(layout, bundlePath) {
|
|
78089
|
-
return (0,
|
|
78619
|
+
return (0, import_node_path82.resolve)((0, import_node_path82.dirname)((0, import_node_path82.dirname)(bundlePath))) === (0, import_node_path82.resolve)(layout.versions);
|
|
78090
78620
|
}
|
|
78091
78621
|
async function settleUpgradeOnStart({
|
|
78092
78622
|
layout,
|
|
@@ -78193,7 +78723,7 @@ function startRuntimeUpdates(options) {
|
|
|
78193
78723
|
layout,
|
|
78194
78724
|
release: npmRelease,
|
|
78195
78725
|
tarball: await options.downloader.download(npmRelease.dist.tarball, signal),
|
|
78196
|
-
tmpDir: (0,
|
|
78726
|
+
tmpDir: (0, import_node_path82.join)(layout.root, ".downloads")
|
|
78197
78727
|
});
|
|
78198
78728
|
await lifecycle.exclusive("upgrade", async () => {
|
|
78199
78729
|
await recordPendingUpgrade(layout, currentVersion2, version2, clock.now());
|
|
@@ -78236,7 +78766,8 @@ function startRuntimeUpdates(options) {
|
|
|
78236
78766
|
|
|
78237
78767
|
// src/cli/commands/machine-plane.ts
|
|
78238
78768
|
var MAINTENANCE_EVERY_MS = 3e3;
|
|
78239
|
-
var
|
|
78769
|
+
var CAPABILITY_CHECK_MS = 15 * 6e4;
|
|
78770
|
+
var CAPABILITY_STALE_AFTER_MS = 60 * 6e4;
|
|
78240
78771
|
var LOCAL_SKILLS_RESCAN_MS = 6e4;
|
|
78241
78772
|
var CAPABILITY_MAX_AGE_MS = 6e4;
|
|
78242
78773
|
var RUN_ARCHIVE_EVERY_MS = 6 * 60 * 6e4;
|
|
@@ -78424,7 +78955,7 @@ async function startMachinePlane(deps) {
|
|
|
78424
78955
|
[ALAN_MANAGED_SESSION_ENV]: "1"
|
|
78425
78956
|
},
|
|
78426
78957
|
cwd: paths.stateDir,
|
|
78427
|
-
outputPath: (0,
|
|
78958
|
+
outputPath: (0, import_node_path83.join)(paths.logs, "holders.log")
|
|
78428
78959
|
},
|
|
78429
78960
|
deps.holderIsolation
|
|
78430
78961
|
);
|
|
@@ -78461,7 +78992,7 @@ async function startMachinePlane(deps) {
|
|
|
78461
78992
|
}),
|
|
78462
78993
|
local: { home: config2.home, machineId: identity.machineId },
|
|
78463
78994
|
// Only a cloud sandbox's runtime has a git gateway; a person's own ~/.codex is theirs.
|
|
78464
|
-
...config2.gitGatewayUrl === null ? {} : { codexSkillsDir: (0,
|
|
78995
|
+
...config2.gitGatewayUrl === null ? {} : { codexSkillsDir: (0, import_node_path83.join)(config2.codexHome, "skills") },
|
|
78465
78996
|
log
|
|
78466
78997
|
})
|
|
78467
78998
|
);
|
|
@@ -78598,15 +79129,19 @@ async function startMachinePlane(deps) {
|
|
|
78598
79129
|
probes: config2.providerProbes,
|
|
78599
79130
|
clock,
|
|
78600
79131
|
maxAgeMs: CAPABILITY_MAX_AGE_MS,
|
|
78601
|
-
|
|
79132
|
+
staleAfterMs: CAPABILITY_STALE_AFTER_MS,
|
|
79133
|
+
openCodeEntitlement: checkOpenCodeEntitlement,
|
|
79134
|
+
log
|
|
78602
79135
|
}),
|
|
78603
79136
|
push: (scanned) => link.pushCapabilities(scanned),
|
|
78604
79137
|
log
|
|
78605
79138
|
});
|
|
78606
79139
|
stack.use(
|
|
78607
79140
|
startMaintenance({
|
|
78608
|
-
everyMs:
|
|
78609
|
-
jobs: [
|
|
79141
|
+
everyMs: CAPABILITY_CHECK_MS,
|
|
79142
|
+
jobs: [
|
|
79143
|
+
{ name: "capabilities.rescan", run: () => capabilities.rescanIfChanged() }
|
|
79144
|
+
],
|
|
78610
79145
|
clock,
|
|
78611
79146
|
log
|
|
78612
79147
|
})
|
|
@@ -78659,7 +79194,7 @@ async function startMachinePlane(deps) {
|
|
|
78659
79194
|
git: createGitRunner({ env: cliEnvironment }),
|
|
78660
79195
|
clock,
|
|
78661
79196
|
log,
|
|
78662
|
-
dir: (0,
|
|
79197
|
+
dir: (0, import_node_path83.join)(paths.stateDir, "checkout-freshness")
|
|
78663
79198
|
},
|
|
78664
79199
|
stopped.signal
|
|
78665
79200
|
);
|
|
@@ -78953,7 +79488,7 @@ function lockWaitMs(argv) {
|
|
|
78953
79488
|
}
|
|
78954
79489
|
async function openManagedProviders(config2, paths) {
|
|
78955
79490
|
const providerEnv = readCliEnvironment();
|
|
78956
|
-
const bundledNpm = (0,
|
|
79491
|
+
const bundledNpm = (0, import_node_path84.join)((0, import_node_path84.dirname)(process.execPath), "npm", "bin", "npm-cli.js");
|
|
78957
79492
|
const providerToolchain = config2.providerToolchain ?? (process.platform === "win32" && (0, import_node_fs24.existsSync)(bundledNpm) ? { node: process.execPath, npmCli: bundledNpm } : null);
|
|
78958
79493
|
const npmPath = providerToolchain?.node ?? await resolveCommandOnPath("npm", providerEnv, process.platform);
|
|
78959
79494
|
const npmOptions = npmPath === null || process.platform === "win32" && providerToolchain === null ? null : {
|
|
@@ -78961,7 +79496,7 @@ async function openManagedProviders(config2, paths) {
|
|
|
78961
79496
|
...providerToolchain === null ? {} : { argsBeforeNpm: [providerToolchain.npmCli] },
|
|
78962
79497
|
env: providerEnv
|
|
78963
79498
|
};
|
|
78964
|
-
const providerNodeDir = providerToolchain?.node === void 0 ? void 0 : (0,
|
|
79499
|
+
const providerNodeDir = providerToolchain?.node === void 0 ? void 0 : (0, import_node_path84.dirname)(providerToolchain.node);
|
|
78965
79500
|
const probeEnv = providerNodeDir === void 0 ? providerEnv : {
|
|
78966
79501
|
...providerEnv,
|
|
78967
79502
|
PATH: `${providerNodeDir}${pathDelimiter(process.platform)}${envValue(providerEnv, "PATH")}`
|
|
@@ -78971,7 +79506,7 @@ async function openManagedProviders(config2, paths) {
|
|
|
78971
79506
|
throw new Error("Provider installer is unavailable on this computer");
|
|
78972
79507
|
};
|
|
78973
79508
|
const managed = createManagedProviderClis({
|
|
78974
|
-
root: (0,
|
|
79509
|
+
root: (0, import_node_path84.join)(paths.stateDir, "provider-clis"),
|
|
78975
79510
|
resolveVersion: npmOptions === null ? unavailable : createNpmVersionResolver(npmOptions),
|
|
78976
79511
|
installPackage: npmOptions === null ? unavailable : createNpmPackageInstaller(npmOptions),
|
|
78977
79512
|
probe: (executable, backendKind) => probeManagedProvider(executable, backendKind, canonicalProbeEnv)
|
|
@@ -79003,7 +79538,7 @@ async function runService(argv, stop, restart = new AbortController().signal) {
|
|
|
79003
79538
|
waitMs: lockWaitMs(argv),
|
|
79004
79539
|
signal: stop
|
|
79005
79540
|
}));
|
|
79006
|
-
const log = __using(_stack, openFileLog((0,
|
|
79541
|
+
const log = __using(_stack, openFileLog((0, import_node_path84.join)(paths.logs, "runtime.jsonl"), config2.logLevel, clock));
|
|
79007
79542
|
const lifecycle = createLifecycleQueue({ clock, log });
|
|
79008
79543
|
const install2 = installLayout(config2.installDir, config2.profile);
|
|
79009
79544
|
const bundlePath = process.argv[1] ?? "";
|
|
@@ -79037,7 +79572,7 @@ async function runService(argv, stop, restart = new AbortController().signal) {
|
|
|
79037
79572
|
openCliEnvironment({
|
|
79038
79573
|
env: readCliEnvironment(),
|
|
79039
79574
|
platform: process.platform,
|
|
79040
|
-
lastKnownGoodFile: (0,
|
|
79575
|
+
lastKnownGoodFile: (0, import_node_path84.join)(paths.stateDir, "login-path.json"),
|
|
79041
79576
|
clock,
|
|
79042
79577
|
decorate: (env) => withPackagedAlanCodeEngine(env, bundlePath, process.platform)
|
|
79043
79578
|
})
|
|
@@ -79214,17 +79749,17 @@ async function runServiceCommand(argv, ctx = cliContext()) {
|
|
|
79214
79749
|
}
|
|
79215
79750
|
|
|
79216
79751
|
// src/cli/commands/upgrade.ts
|
|
79217
|
-
var
|
|
79218
|
-
var
|
|
79752
|
+
var import_promises81 = require("fs/promises");
|
|
79753
|
+
var import_node_path85 = require("path");
|
|
79219
79754
|
function isNotNewer(version2, installed) {
|
|
79220
79755
|
return installed !== null && isReleaseVersion(version2) && isReleaseVersion(installed) && compareVersions(version2, installed) <= 0;
|
|
79221
79756
|
}
|
|
79222
79757
|
async function installFromSource(source) {
|
|
79223
79758
|
const { layout, from, ifNewer } = source;
|
|
79224
|
-
const isTarball = (await (0,
|
|
79225
|
-
const downloads = (0,
|
|
79226
|
-
if (isTarball) await (0,
|
|
79227
|
-
const scratch = isTarball ? await (0,
|
|
79759
|
+
const isTarball = (await (0, import_promises81.stat)(from)).isFile();
|
|
79760
|
+
const downloads = (0, import_node_path85.join)(layout.root, ".downloads");
|
|
79761
|
+
if (isTarball) await (0, import_promises81.mkdir)(downloads, { recursive: true, mode: 448 });
|
|
79762
|
+
const scratch = isTarball ? await (0, import_promises81.mkdtemp)((0, import_node_path85.join)(downloads, "upgrade-")) : null;
|
|
79228
79763
|
try {
|
|
79229
79764
|
const sourceDir = scratch === null ? from : await extractPackageTarball(from, scratch);
|
|
79230
79765
|
const version2 = await readPackageVersion(sourceDir);
|
|
@@ -79232,7 +79767,7 @@ async function installFromSource(source) {
|
|
|
79232
79767
|
if (ifNewer && isNotNewer(version2, installed)) return { kind: "skipped", version: version2, installed };
|
|
79233
79768
|
return { kind: "installed", ...await installVersion(layout, sourceDir) };
|
|
79234
79769
|
} finally {
|
|
79235
|
-
if (scratch !== null) await (0,
|
|
79770
|
+
if (scratch !== null) await (0, import_promises81.rm)(scratch, { recursive: true, force: true });
|
|
79236
79771
|
}
|
|
79237
79772
|
}
|
|
79238
79773
|
async function runUpgrade(argv) {
|
|
@@ -79244,7 +79779,7 @@ async function runUpgrade(argv) {
|
|
|
79244
79779
|
const layout = installLayout(config2.installDir, config2.profile);
|
|
79245
79780
|
const outcome2 = await installFromSource({
|
|
79246
79781
|
layout,
|
|
79247
|
-
from: (0,
|
|
79782
|
+
from: (0, import_node_path85.resolve)(from),
|
|
79248
79783
|
ifNewer: hasFlag(argv, "--if-newer")
|
|
79249
79784
|
});
|
|
79250
79785
|
if (outcome2.kind === "skipped") {
|