@alan-ai-hq/agent-manager-linux-arm64 0.1.147 → 0.1.149
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 +1739 -853
- package/alan-holder.cjs +1151 -489
- package/package.json +1 -1
package/alan-holder.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 = run(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 = run(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 = run(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 = run(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 = run(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 = run(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 = run(def.left);
|
|
@@ -19568,6 +19568,259 @@ var init_zod = __esm({
|
|
|
19568
19568
|
}
|
|
19569
19569
|
});
|
|
19570
19570
|
|
|
19571
|
+
// ../shared/dist/runtime-v2/workspace.js
|
|
19572
|
+
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;
|
|
19573
|
+
var init_workspace = __esm({
|
|
19574
|
+
"../shared/dist/runtime-v2/workspace.js"() {
|
|
19575
|
+
"use strict";
|
|
19576
|
+
init_zod();
|
|
19577
|
+
UNSAFE_LINE = /[\0\r\n]/;
|
|
19578
|
+
CONTROL_CHARACTERS = /[\x00-\x1f\x7f]/;
|
|
19579
|
+
machinePathSchema = external_exports.string().min(1).max(4096).refine((value) => !UNSAFE_LINE.test(value), "path contains unsafe characters");
|
|
19580
|
+
gitShaSchema = external_exports.string().regex(/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/, "not a Git SHA");
|
|
19581
|
+
gitBranchSchema = external_exports.string().min(1).max(255).refine((value) => !value.startsWith("-") && !value.startsWith("+") && !value.includes("..") && !value.includes("@{") && !value.endsWith(".lock") && !/[\s~^:?*[\\]/.test(value) && !CONTROL_CHARACTERS.test(value), "not a safe Git branch name");
|
|
19582
|
+
gitRemoteNameSchema = external_exports.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/, "not a safe Git remote name");
|
|
19583
|
+
gitRemoteUrlSchema = external_exports.string().min(1).max(2048).refine((value) => !UNSAFE_LINE.test(value), "remote URL contains unsafe characters");
|
|
19584
|
+
statusFingerprintSchema = external_exports.string().regex(/^[0-9a-f]{64}$/, "not a status fingerprint");
|
|
19585
|
+
singleLineSchema = (max) => external_exports.string().min(1).max(max).refine((value) => !CONTROL_CHARACTERS.test(value), "contains control characters");
|
|
19586
|
+
operationIdSchema = external_exports.guid();
|
|
19587
|
+
repoTargetShape = {
|
|
19588
|
+
path: machinePathSchema,
|
|
19589
|
+
expectedRepoRoot: machinePathSchema.optional(),
|
|
19590
|
+
projectPath: machinePathSchema.optional()
|
|
19591
|
+
};
|
|
19592
|
+
trustedRepoTargetShape = {
|
|
19593
|
+
path: machinePathSchema,
|
|
19594
|
+
expectedRepoRoot: machinePathSchema,
|
|
19595
|
+
projectPath: machinePathSchema
|
|
19596
|
+
};
|
|
19597
|
+
workspaceStatusRequestSchema = external_exports.object({
|
|
19598
|
+
method: external_exports.literal("workspace.status"),
|
|
19599
|
+
path: machinePathSchema
|
|
19600
|
+
});
|
|
19601
|
+
gitStatusRequestSchema = external_exports.object({
|
|
19602
|
+
method: external_exports.literal("git.status"),
|
|
19603
|
+
...repoTargetShape,
|
|
19604
|
+
remote: gitRemoteNameSchema.default("origin"),
|
|
19605
|
+
expectedRemoteUrl: gitRemoteUrlSchema.optional()
|
|
19606
|
+
});
|
|
19607
|
+
gitCheckpointRequestSchema = external_exports.object({
|
|
19608
|
+
method: external_exports.literal("git.checkpoint"),
|
|
19609
|
+
operationId: operationIdSchema,
|
|
19610
|
+
...trustedRepoTargetShape,
|
|
19611
|
+
switchId: singleLineSchema(200),
|
|
19612
|
+
repoKey: singleLineSchema(256),
|
|
19613
|
+
expectedHeadSha: gitShaSchema,
|
|
19614
|
+
expectedBranch: gitBranchSchema,
|
|
19615
|
+
expectedStatusFingerprint: statusFingerprintSchema,
|
|
19616
|
+
expectedProposedTreeSha: gitShaSchema,
|
|
19617
|
+
/** Goes to `git commit-tree` over stdin; newlines carry trailers, NUL is unrepresentable. */
|
|
19618
|
+
commitMessage: external_exports.string().min(1).max(64 * 1024).refine((value) => !value.includes("\0") && value.trim().length > 0, "invalid commit message"),
|
|
19619
|
+
authorName: singleLineSchema(256),
|
|
19620
|
+
authorEmail: singleLineSchema(320).refine((value) => !/[<>]/.test(value), "invalid email")
|
|
19621
|
+
});
|
|
19622
|
+
gitPushRequestSchema = external_exports.object({
|
|
19623
|
+
method: external_exports.literal("git.push"),
|
|
19624
|
+
operationId: operationIdSchema,
|
|
19625
|
+
...trustedRepoTargetShape,
|
|
19626
|
+
remote: gitRemoteNameSchema.default("origin"),
|
|
19627
|
+
expectedRemoteUrl: gitRemoteUrlSchema,
|
|
19628
|
+
expectedHeadSha: gitShaSchema,
|
|
19629
|
+
expectedBranch: gitBranchSchema
|
|
19630
|
+
});
|
|
19631
|
+
gitPrepareCheckoutRequestSchema = external_exports.object({
|
|
19632
|
+
method: external_exports.literal("git.prepare_checkout"),
|
|
19633
|
+
operationId: operationIdSchema,
|
|
19634
|
+
...trustedRepoTargetShape,
|
|
19635
|
+
remote: gitRemoteNameSchema.default("origin"),
|
|
19636
|
+
expectedRemoteUrl: gitRemoteUrlSchema,
|
|
19637
|
+
branch: gitBranchSchema,
|
|
19638
|
+
targetSha: gitShaSchema
|
|
19639
|
+
});
|
|
19640
|
+
gitVerifyHeadRequestSchema = external_exports.object({
|
|
19641
|
+
method: external_exports.literal("git.verify_head"),
|
|
19642
|
+
...trustedRepoTargetShape,
|
|
19643
|
+
expectedSha: gitShaSchema
|
|
19644
|
+
});
|
|
19645
|
+
workspaceQueryRequestSchema = external_exports.discriminatedUnion("method", [
|
|
19646
|
+
workspaceStatusRequestSchema,
|
|
19647
|
+
gitStatusRequestSchema,
|
|
19648
|
+
gitCheckpointRequestSchema,
|
|
19649
|
+
gitPushRequestSchema,
|
|
19650
|
+
gitPrepareCheckoutRequestSchema,
|
|
19651
|
+
gitVerifyHeadRequestSchema
|
|
19652
|
+
]);
|
|
19653
|
+
WORKSPACE_QUERY_METHODS = [
|
|
19654
|
+
"workspace.status",
|
|
19655
|
+
"git.status",
|
|
19656
|
+
"git.checkpoint",
|
|
19657
|
+
"git.push",
|
|
19658
|
+
"git.prepare_checkout",
|
|
19659
|
+
"git.verify_head"
|
|
19660
|
+
];
|
|
19661
|
+
workspaceQueryMethodSchema = external_exports.enum(WORKSPACE_QUERY_METHODS);
|
|
19662
|
+
workspaceStatusValueSchema = external_exports.object({
|
|
19663
|
+
repoRoot: machinePathSchema,
|
|
19664
|
+
/** null: detached HEAD. */
|
|
19665
|
+
branch: external_exports.string().nullable(),
|
|
19666
|
+
/** null: unborn branch. */
|
|
19667
|
+
headSha: gitShaSchema.nullable(),
|
|
19668
|
+
dirty: external_exports.boolean(),
|
|
19669
|
+
filesChanged: external_exports.number().int().nonnegative(),
|
|
19670
|
+
ahead: external_exports.number().int().nonnegative().nullable(),
|
|
19671
|
+
behind: external_exports.number().int().nonnegative().nullable(),
|
|
19672
|
+
hasUpstream: external_exports.boolean()
|
|
19673
|
+
});
|
|
19674
|
+
gitStatusValueSchema = workspaceStatusValueSchema.extend({
|
|
19675
|
+
remoteUrl: gitRemoteUrlSchema.nullable(),
|
|
19676
|
+
upstream: external_exports.string().nullable(),
|
|
19677
|
+
statusFingerprint: statusFingerprintSchema,
|
|
19678
|
+
proposedTreeSha: gitShaSchema
|
|
19679
|
+
});
|
|
19680
|
+
gitCheckpointValueSchema = external_exports.object({
|
|
19681
|
+
repoRoot: machinePathSchema,
|
|
19682
|
+
sha: gitShaSchema,
|
|
19683
|
+
replayed: external_exports.boolean()
|
|
19684
|
+
});
|
|
19685
|
+
gitPushValueSchema = external_exports.object({
|
|
19686
|
+
repoRoot: machinePathSchema,
|
|
19687
|
+
pushedSha: gitShaSchema,
|
|
19688
|
+
branch: gitBranchSchema,
|
|
19689
|
+
remote: gitRemoteNameSchema,
|
|
19690
|
+
/** The remote already had the SHA before this push. */
|
|
19691
|
+
replayed: external_exports.boolean()
|
|
19692
|
+
});
|
|
19693
|
+
gitPrepareCheckoutValueSchema = external_exports.object({
|
|
19694
|
+
repoRoot: machinePathSchema,
|
|
19695
|
+
branch: gitBranchSchema,
|
|
19696
|
+
headSha: gitShaSchema,
|
|
19697
|
+
replayed: external_exports.boolean()
|
|
19698
|
+
});
|
|
19699
|
+
gitVerifyHeadValueSchema = external_exports.object({
|
|
19700
|
+
repoRoot: machinePathSchema,
|
|
19701
|
+
headSha: gitShaSchema,
|
|
19702
|
+
verified: external_exports.literal(true)
|
|
19703
|
+
});
|
|
19704
|
+
WORKSPACE_QUERY_ERROR_CODES = [
|
|
19705
|
+
"path_not_approved",
|
|
19706
|
+
"workspace_busy",
|
|
19707
|
+
"workspace_repository_mismatch",
|
|
19708
|
+
"operation_in_progress",
|
|
19709
|
+
"git_not_installed",
|
|
19710
|
+
"runtime_operation_failed",
|
|
19711
|
+
"invalid_git_request",
|
|
19712
|
+
"repository_not_found",
|
|
19713
|
+
"repository_path_changed",
|
|
19714
|
+
"repository_path_not_authorized",
|
|
19715
|
+
"path_canonicalization_failed",
|
|
19716
|
+
"git_status_unreadable",
|
|
19717
|
+
"git_operation_failed",
|
|
19718
|
+
"git_network_timeout",
|
|
19719
|
+
"git_output_limit_exceeded",
|
|
19720
|
+
"git_remote_unavailable",
|
|
19721
|
+
"git_fetch_failed",
|
|
19722
|
+
"git_push_failed",
|
|
19723
|
+
"remote_url_credentials_rejected",
|
|
19724
|
+
"remote_url_mismatch",
|
|
19725
|
+
"source_changed_since_approval",
|
|
19726
|
+
"source_dirty_after_checkpoint",
|
|
19727
|
+
"source_head_unreadable",
|
|
19728
|
+
"checkpoint_empty",
|
|
19729
|
+
"checkpoint_tree_unavailable",
|
|
19730
|
+
"checkpoint_commit_failed",
|
|
19731
|
+
"checkpoint_lock_unavailable",
|
|
19732
|
+
"checkpoint_index_sync_failed",
|
|
19733
|
+
"push_verification_failed",
|
|
19734
|
+
"target_checkout_dirty",
|
|
19735
|
+
"target_checkout_failed",
|
|
19736
|
+
"target_branch_in_use",
|
|
19737
|
+
"target_branch_diverged",
|
|
19738
|
+
"target_fast_forward_failed",
|
|
19739
|
+
"target_verification_failed",
|
|
19740
|
+
"target_sha_mismatch",
|
|
19741
|
+
"target_sha_unavailable",
|
|
19742
|
+
"target_head_unreadable",
|
|
19743
|
+
"verify_head_mismatch"
|
|
19744
|
+
];
|
|
19745
|
+
workspaceQueryErrorCodeSchema = external_exports.enum(WORKSPACE_QUERY_ERROR_CODES);
|
|
19746
|
+
publishedGitReceiptSchema = external_exports.object({
|
|
19747
|
+
pushedSha: gitShaSchema,
|
|
19748
|
+
branch: gitBranchSchema,
|
|
19749
|
+
remote: gitRemoteNameSchema,
|
|
19750
|
+
replayed: external_exports.boolean()
|
|
19751
|
+
});
|
|
19752
|
+
workspaceQueryErrorSchema = external_exports.object({
|
|
19753
|
+
code: workspaceQueryErrorCodeSchema,
|
|
19754
|
+
message: external_exports.string().max(4096),
|
|
19755
|
+
/** Only with source_changed_since_approval after a push: what already reached the remote. */
|
|
19756
|
+
published: publishedGitReceiptSchema.optional()
|
|
19757
|
+
});
|
|
19758
|
+
resultEnvelopeSchema = external_exports.discriminatedUnion("ok", [
|
|
19759
|
+
external_exports.object({ ok: external_exports.literal(true), value: external_exports.unknown() }),
|
|
19760
|
+
external_exports.object({ ok: external_exports.literal(false), error: workspaceQueryErrorSchema })
|
|
19761
|
+
]);
|
|
19762
|
+
}
|
|
19763
|
+
});
|
|
19764
|
+
|
|
19765
|
+
// ../shared/dist/runtime-v2/agent-context.js
|
|
19766
|
+
var AGENT_CONTEXT_VERSION, agentSessionKindSchema, agentTurnTriggerSchema, agentBranchSourceSchema, agentContextRepositorySchema, agentContextBuildSchema, agentContextEnvironmentSchema, agentContextPullRequestSchema, agentContextSchema;
|
|
19767
|
+
var init_agent_context = __esm({
|
|
19768
|
+
"../shared/dist/runtime-v2/agent-context.js"() {
|
|
19769
|
+
"use strict";
|
|
19770
|
+
init_zod();
|
|
19771
|
+
init_workspace();
|
|
19772
|
+
AGENT_CONTEXT_VERSION = 1;
|
|
19773
|
+
agentSessionKindSchema = external_exports.enum(["chat", "task", "workflow", "pr_review"]);
|
|
19774
|
+
agentTurnTriggerSchema = external_exports.enum(["user", "image_build"]);
|
|
19775
|
+
agentBranchSourceSchema = external_exports.enum([
|
|
19776
|
+
"handoff",
|
|
19777
|
+
"pull_request",
|
|
19778
|
+
"task",
|
|
19779
|
+
"chat_selection",
|
|
19780
|
+
"environment_default"
|
|
19781
|
+
]);
|
|
19782
|
+
agentContextRepositorySchema = external_exports.object({
|
|
19783
|
+
name: external_exports.string().min(1).max(200),
|
|
19784
|
+
url: gitRemoteUrlSchema,
|
|
19785
|
+
path: machinePathSchema,
|
|
19786
|
+
branch: gitBranchSchema,
|
|
19787
|
+
branchSource: agentBranchSourceSchema,
|
|
19788
|
+
base: gitBranchSchema
|
|
19789
|
+
});
|
|
19790
|
+
agentContextBuildSchema = external_exports.object({
|
|
19791
|
+
id: external_exports.guid(),
|
|
19792
|
+
status: external_exports.enum(["queued", "running", "succeeded", "failed", "cancelled", "superseded"]),
|
|
19793
|
+
trigger: external_exports.enum(["agent", "base_bumped", "preview", "manual", "push"])
|
|
19794
|
+
});
|
|
19795
|
+
agentContextEnvironmentSchema = external_exports.object({
|
|
19796
|
+
id: external_exports.guid(),
|
|
19797
|
+
name: external_exports.string().min(1).max(200),
|
|
19798
|
+
installCommand: external_exports.string().max(8192).nullable(),
|
|
19799
|
+
startCommand: external_exports.string().max(8192).nullable(),
|
|
19800
|
+
imageBuildId: external_exports.guid().nullable(),
|
|
19801
|
+
/** The newest build when it is not the one sessions boot from. */
|
|
19802
|
+
pendingBuild: agentContextBuildSchema.optional(),
|
|
19803
|
+
/** Saved variable names; values never leave the API. */
|
|
19804
|
+
variables: external_exports.array(external_exports.string().min(1).max(200)).max(200)
|
|
19805
|
+
});
|
|
19806
|
+
agentContextPullRequestSchema = external_exports.object({
|
|
19807
|
+
number: external_exports.number().int().positive(),
|
|
19808
|
+
url: external_exports.string().url().max(2048),
|
|
19809
|
+
head: gitBranchSchema,
|
|
19810
|
+
base: gitBranchSchema
|
|
19811
|
+
});
|
|
19812
|
+
agentContextSchema = external_exports.object({
|
|
19813
|
+
kind: agentSessionKindSchema,
|
|
19814
|
+
trigger: agentTurnTriggerSchema,
|
|
19815
|
+
organizationId: external_exports.guid(),
|
|
19816
|
+
taskWorkingBranch: gitBranchSchema.optional(),
|
|
19817
|
+
pullRequest: agentContextPullRequestSchema.optional(),
|
|
19818
|
+
repositories: external_exports.array(agentContextRepositorySchema).max(64),
|
|
19819
|
+
environment: agentContextEnvironmentSchema.optional()
|
|
19820
|
+
});
|
|
19821
|
+
}
|
|
19822
|
+
});
|
|
19823
|
+
|
|
19571
19824
|
// ../shared/dist/skills/domain.js
|
|
19572
19825
|
var SKILLS_PROTOCOL_VERSION, SKILL_PACKAGE_LIMITS;
|
|
19573
19826
|
var init_domain = __esm({
|
|
@@ -20066,245 +20319,51 @@ var init_run_context = __esm({
|
|
|
20066
20319
|
descriptionAttachmentIds: external_exports.array(external_exports.object({ id: external_exports.string().min(1), filename: external_exports.string() })).optional(),
|
|
20067
20320
|
linkedResources: external_exports.array(external_exports.object({
|
|
20068
20321
|
id: external_exports.string().min(1),
|
|
20069
|
-
type: external_exports.enum(["document", "whiteboard", "url"]),
|
|
20070
|
-
title: external_exports.string(),
|
|
20071
|
-
url: external_exports.string().optional()
|
|
20072
|
-
})).optional()
|
|
20073
|
-
}));
|
|
20074
|
-
pullRequestMetaSchema = wire()(external_exports.object({
|
|
20075
|
-
prNumber: external_exports.number().int().positive(),
|
|
20076
|
-
owner: external_exports.string().min(1),
|
|
20077
|
-
repo: external_exports.string().min(1),
|
|
20078
|
-
title: external_exports.string(),
|
|
20079
|
-
body: external_exports.string().optional(),
|
|
20080
|
-
baseBranch: external_exports.string(),
|
|
20081
|
-
headBranch: external_exports.string(),
|
|
20082
|
-
author: external_exports.string().optional(),
|
|
20083
|
-
state: external_exports.enum(["open", "closed", "merged"]),
|
|
20084
|
-
mergeable: external_exports.boolean().nullable().optional(),
|
|
20085
|
-
labels: external_exports.array(external_exports.string()),
|
|
20086
|
-
changedFilesCount: external_exports.number().int().nonnegative().optional(),
|
|
20087
|
-
additions: external_exports.number().int().nonnegative().optional(),
|
|
20088
|
-
deletions: external_exports.number().int().nonnegative().optional(),
|
|
20089
|
-
changedFiles: external_exports.array(external_exports.object({
|
|
20090
|
-
path: external_exports.string(),
|
|
20091
|
-
status: external_exports.string(),
|
|
20092
|
-
additions: external_exports.number().int(),
|
|
20093
|
-
deletions: external_exports.number().int()
|
|
20094
|
-
})).optional(),
|
|
20095
|
-
linkedTaskReadableId: external_exports.string().nullable().optional(),
|
|
20096
|
-
linkedTaskId: external_exports.string().nullable().optional(),
|
|
20097
|
-
linkedTaskNumber: external_exports.number().int().nullable().optional(),
|
|
20098
|
-
htmlUrl: external_exports.string().optional()
|
|
20099
|
-
}));
|
|
20100
|
-
agentUserIdentitySchema = wire()(external_exports.object({ id: external_exports.string().min(1), name: external_exports.string().nullable(), email: external_exports.string() }));
|
|
20101
|
-
workflowToolRefSchema = wire()(external_exports.object({ type: external_exports.string().min(1), id: external_exports.string().min(1) }));
|
|
20102
|
-
runPromptContextSchema = external_exports.object({
|
|
20103
|
-
taskMeta: taskMetaSchema.optional(),
|
|
20104
|
-
prMeta: pullRequestMetaSchema.optional(),
|
|
20105
|
-
currentUser: agentUserIdentitySchema.optional(),
|
|
20106
|
-
sessionVisibility: external_exports.enum(["private", "team"]).nullable().optional(),
|
|
20107
|
-
workflowTools: external_exports.array(workflowToolRefSchema).optional(),
|
|
20108
|
-
availableSkills: external_exports.array(external_exports.object({
|
|
20109
|
-
name: external_exports.string().min(1),
|
|
20110
|
-
description: external_exports.string(),
|
|
20111
|
-
packageDirectory: external_exports.string().min(1)
|
|
20112
|
-
})).max(2e3).optional()
|
|
20113
|
-
});
|
|
20114
|
-
}
|
|
20115
|
-
});
|
|
20116
|
-
|
|
20117
|
-
// ../shared/dist/runtime-v2/workspace.js
|
|
20118
|
-
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;
|
|
20119
|
-
var init_workspace = __esm({
|
|
20120
|
-
"../shared/dist/runtime-v2/workspace.js"() {
|
|
20121
|
-
"use strict";
|
|
20122
|
-
init_zod();
|
|
20123
|
-
UNSAFE_LINE = /[\0\r\n]/;
|
|
20124
|
-
CONTROL_CHARACTERS = /[\x00-\x1f\x7f]/;
|
|
20125
|
-
machinePathSchema = external_exports.string().min(1).max(4096).refine((value) => !UNSAFE_LINE.test(value), "path contains unsafe characters");
|
|
20126
|
-
gitShaSchema = external_exports.string().regex(/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/, "not a Git SHA");
|
|
20127
|
-
gitBranchSchema = external_exports.string().min(1).max(255).refine((value) => !value.startsWith("-") && !value.startsWith("+") && !value.includes("..") && !value.includes("@{") && !value.endsWith(".lock") && !/[\s~^:?*[\\]/.test(value) && !CONTROL_CHARACTERS.test(value), "not a safe Git branch name");
|
|
20128
|
-
gitRemoteNameSchema = external_exports.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/, "not a safe Git remote name");
|
|
20129
|
-
gitRemoteUrlSchema = external_exports.string().min(1).max(2048).refine((value) => !UNSAFE_LINE.test(value), "remote URL contains unsafe characters");
|
|
20130
|
-
statusFingerprintSchema = external_exports.string().regex(/^[0-9a-f]{64}$/, "not a status fingerprint");
|
|
20131
|
-
singleLineSchema = (max) => external_exports.string().min(1).max(max).refine((value) => !CONTROL_CHARACTERS.test(value), "contains control characters");
|
|
20132
|
-
operationIdSchema = external_exports.guid();
|
|
20133
|
-
repoTargetShape = {
|
|
20134
|
-
path: machinePathSchema,
|
|
20135
|
-
expectedRepoRoot: machinePathSchema.optional(),
|
|
20136
|
-
projectPath: machinePathSchema.optional()
|
|
20137
|
-
};
|
|
20138
|
-
trustedRepoTargetShape = {
|
|
20139
|
-
path: machinePathSchema,
|
|
20140
|
-
expectedRepoRoot: machinePathSchema,
|
|
20141
|
-
projectPath: machinePathSchema
|
|
20142
|
-
};
|
|
20143
|
-
workspaceStatusRequestSchema = external_exports.object({
|
|
20144
|
-
method: external_exports.literal("workspace.status"),
|
|
20145
|
-
path: machinePathSchema
|
|
20146
|
-
});
|
|
20147
|
-
gitStatusRequestSchema = external_exports.object({
|
|
20148
|
-
method: external_exports.literal("git.status"),
|
|
20149
|
-
...repoTargetShape,
|
|
20150
|
-
remote: gitRemoteNameSchema.default("origin"),
|
|
20151
|
-
expectedRemoteUrl: gitRemoteUrlSchema.optional()
|
|
20152
|
-
});
|
|
20153
|
-
gitCheckpointRequestSchema = external_exports.object({
|
|
20154
|
-
method: external_exports.literal("git.checkpoint"),
|
|
20155
|
-
operationId: operationIdSchema,
|
|
20156
|
-
...trustedRepoTargetShape,
|
|
20157
|
-
switchId: singleLineSchema(200),
|
|
20158
|
-
repoKey: singleLineSchema(256),
|
|
20159
|
-
expectedHeadSha: gitShaSchema,
|
|
20160
|
-
expectedBranch: gitBranchSchema,
|
|
20161
|
-
expectedStatusFingerprint: statusFingerprintSchema,
|
|
20162
|
-
expectedProposedTreeSha: gitShaSchema,
|
|
20163
|
-
/** Goes to `git commit-tree` over stdin; newlines carry trailers, NUL is unrepresentable. */
|
|
20164
|
-
commitMessage: external_exports.string().min(1).max(64 * 1024).refine((value) => !value.includes("\0") && value.trim().length > 0, "invalid commit message"),
|
|
20165
|
-
authorName: singleLineSchema(256),
|
|
20166
|
-
authorEmail: singleLineSchema(320).refine((value) => !/[<>]/.test(value), "invalid email")
|
|
20167
|
-
});
|
|
20168
|
-
gitPushRequestSchema = external_exports.object({
|
|
20169
|
-
method: external_exports.literal("git.push"),
|
|
20170
|
-
operationId: operationIdSchema,
|
|
20171
|
-
...trustedRepoTargetShape,
|
|
20172
|
-
remote: gitRemoteNameSchema.default("origin"),
|
|
20173
|
-
expectedRemoteUrl: gitRemoteUrlSchema,
|
|
20174
|
-
expectedHeadSha: gitShaSchema,
|
|
20175
|
-
expectedBranch: gitBranchSchema
|
|
20176
|
-
});
|
|
20177
|
-
gitPrepareCheckoutRequestSchema = external_exports.object({
|
|
20178
|
-
method: external_exports.literal("git.prepare_checkout"),
|
|
20179
|
-
operationId: operationIdSchema,
|
|
20180
|
-
...trustedRepoTargetShape,
|
|
20181
|
-
remote: gitRemoteNameSchema.default("origin"),
|
|
20182
|
-
expectedRemoteUrl: gitRemoteUrlSchema,
|
|
20183
|
-
branch: gitBranchSchema,
|
|
20184
|
-
targetSha: gitShaSchema
|
|
20185
|
-
});
|
|
20186
|
-
gitVerifyHeadRequestSchema = external_exports.object({
|
|
20187
|
-
method: external_exports.literal("git.verify_head"),
|
|
20188
|
-
...trustedRepoTargetShape,
|
|
20189
|
-
expectedSha: gitShaSchema
|
|
20190
|
-
});
|
|
20191
|
-
workspaceQueryRequestSchema = external_exports.discriminatedUnion("method", [
|
|
20192
|
-
workspaceStatusRequestSchema,
|
|
20193
|
-
gitStatusRequestSchema,
|
|
20194
|
-
gitCheckpointRequestSchema,
|
|
20195
|
-
gitPushRequestSchema,
|
|
20196
|
-
gitPrepareCheckoutRequestSchema,
|
|
20197
|
-
gitVerifyHeadRequestSchema
|
|
20198
|
-
]);
|
|
20199
|
-
WORKSPACE_QUERY_METHODS = [
|
|
20200
|
-
"workspace.status",
|
|
20201
|
-
"git.status",
|
|
20202
|
-
"git.checkpoint",
|
|
20203
|
-
"git.push",
|
|
20204
|
-
"git.prepare_checkout",
|
|
20205
|
-
"git.verify_head"
|
|
20206
|
-
];
|
|
20207
|
-
workspaceQueryMethodSchema = external_exports.enum(WORKSPACE_QUERY_METHODS);
|
|
20208
|
-
workspaceStatusValueSchema = external_exports.object({
|
|
20209
|
-
repoRoot: machinePathSchema,
|
|
20210
|
-
/** null: detached HEAD. */
|
|
20211
|
-
branch: external_exports.string().nullable(),
|
|
20212
|
-
/** null: unborn branch. */
|
|
20213
|
-
headSha: gitShaSchema.nullable(),
|
|
20214
|
-
dirty: external_exports.boolean(),
|
|
20215
|
-
filesChanged: external_exports.number().int().nonnegative(),
|
|
20216
|
-
ahead: external_exports.number().int().nonnegative().nullable(),
|
|
20217
|
-
behind: external_exports.number().int().nonnegative().nullable(),
|
|
20218
|
-
hasUpstream: external_exports.boolean()
|
|
20219
|
-
});
|
|
20220
|
-
gitStatusValueSchema = workspaceStatusValueSchema.extend({
|
|
20221
|
-
remoteUrl: gitRemoteUrlSchema.nullable(),
|
|
20222
|
-
upstream: external_exports.string().nullable(),
|
|
20223
|
-
statusFingerprint: statusFingerprintSchema,
|
|
20224
|
-
proposedTreeSha: gitShaSchema
|
|
20225
|
-
});
|
|
20226
|
-
gitCheckpointValueSchema = external_exports.object({
|
|
20227
|
-
repoRoot: machinePathSchema,
|
|
20228
|
-
sha: gitShaSchema,
|
|
20229
|
-
replayed: external_exports.boolean()
|
|
20230
|
-
});
|
|
20231
|
-
gitPushValueSchema = external_exports.object({
|
|
20232
|
-
repoRoot: machinePathSchema,
|
|
20233
|
-
pushedSha: gitShaSchema,
|
|
20234
|
-
branch: gitBranchSchema,
|
|
20235
|
-
remote: gitRemoteNameSchema,
|
|
20236
|
-
/** The remote already had the SHA before this push. */
|
|
20237
|
-
replayed: external_exports.boolean()
|
|
20238
|
-
});
|
|
20239
|
-
gitPrepareCheckoutValueSchema = external_exports.object({
|
|
20240
|
-
repoRoot: machinePathSchema,
|
|
20241
|
-
branch: gitBranchSchema,
|
|
20242
|
-
headSha: gitShaSchema,
|
|
20243
|
-
replayed: external_exports.boolean()
|
|
20244
|
-
});
|
|
20245
|
-
gitVerifyHeadValueSchema = external_exports.object({
|
|
20246
|
-
repoRoot: machinePathSchema,
|
|
20247
|
-
headSha: gitShaSchema,
|
|
20248
|
-
verified: external_exports.literal(true)
|
|
20249
|
-
});
|
|
20250
|
-
WORKSPACE_QUERY_ERROR_CODES = [
|
|
20251
|
-
"path_not_approved",
|
|
20252
|
-
"workspace_busy",
|
|
20253
|
-
"workspace_repository_mismatch",
|
|
20254
|
-
"operation_in_progress",
|
|
20255
|
-
"git_not_installed",
|
|
20256
|
-
"runtime_operation_failed",
|
|
20257
|
-
"invalid_git_request",
|
|
20258
|
-
"repository_not_found",
|
|
20259
|
-
"repository_path_changed",
|
|
20260
|
-
"repository_path_not_authorized",
|
|
20261
|
-
"path_canonicalization_failed",
|
|
20262
|
-
"git_status_unreadable",
|
|
20263
|
-
"git_operation_failed",
|
|
20264
|
-
"git_network_timeout",
|
|
20265
|
-
"git_output_limit_exceeded",
|
|
20266
|
-
"git_remote_unavailable",
|
|
20267
|
-
"git_fetch_failed",
|
|
20268
|
-
"git_push_failed",
|
|
20269
|
-
"remote_url_credentials_rejected",
|
|
20270
|
-
"remote_url_mismatch",
|
|
20271
|
-
"source_changed_since_approval",
|
|
20272
|
-
"source_dirty_after_checkpoint",
|
|
20273
|
-
"source_head_unreadable",
|
|
20274
|
-
"checkpoint_empty",
|
|
20275
|
-
"checkpoint_tree_unavailable",
|
|
20276
|
-
"checkpoint_commit_failed",
|
|
20277
|
-
"checkpoint_lock_unavailable",
|
|
20278
|
-
"checkpoint_index_sync_failed",
|
|
20279
|
-
"push_verification_failed",
|
|
20280
|
-
"target_checkout_dirty",
|
|
20281
|
-
"target_checkout_failed",
|
|
20282
|
-
"target_branch_in_use",
|
|
20283
|
-
"target_branch_diverged",
|
|
20284
|
-
"target_fast_forward_failed",
|
|
20285
|
-
"target_verification_failed",
|
|
20286
|
-
"target_sha_mismatch",
|
|
20287
|
-
"target_sha_unavailable",
|
|
20288
|
-
"target_head_unreadable",
|
|
20289
|
-
"verify_head_mismatch"
|
|
20290
|
-
];
|
|
20291
|
-
workspaceQueryErrorCodeSchema = external_exports.enum(WORKSPACE_QUERY_ERROR_CODES);
|
|
20292
|
-
publishedGitReceiptSchema = external_exports.object({
|
|
20293
|
-
pushedSha: gitShaSchema,
|
|
20294
|
-
branch: gitBranchSchema,
|
|
20295
|
-
remote: gitRemoteNameSchema,
|
|
20296
|
-
replayed: external_exports.boolean()
|
|
20297
|
-
});
|
|
20298
|
-
workspaceQueryErrorSchema = external_exports.object({
|
|
20299
|
-
code: workspaceQueryErrorCodeSchema,
|
|
20300
|
-
message: external_exports.string().max(4096),
|
|
20301
|
-
/** Only with source_changed_since_approval after a push: what already reached the remote. */
|
|
20302
|
-
published: publishedGitReceiptSchema.optional()
|
|
20322
|
+
type: external_exports.enum(["document", "whiteboard", "url"]),
|
|
20323
|
+
title: external_exports.string(),
|
|
20324
|
+
url: external_exports.string().optional()
|
|
20325
|
+
})).optional()
|
|
20326
|
+
}));
|
|
20327
|
+
pullRequestMetaSchema = wire()(external_exports.object({
|
|
20328
|
+
prNumber: external_exports.number().int().positive(),
|
|
20329
|
+
owner: external_exports.string().min(1),
|
|
20330
|
+
repo: external_exports.string().min(1),
|
|
20331
|
+
title: external_exports.string(),
|
|
20332
|
+
body: external_exports.string().optional(),
|
|
20333
|
+
baseBranch: external_exports.string(),
|
|
20334
|
+
headBranch: external_exports.string(),
|
|
20335
|
+
author: external_exports.string().optional(),
|
|
20336
|
+
state: external_exports.enum(["open", "closed", "merged"]),
|
|
20337
|
+
mergeable: external_exports.boolean().nullable().optional(),
|
|
20338
|
+
labels: external_exports.array(external_exports.string()),
|
|
20339
|
+
changedFilesCount: external_exports.number().int().nonnegative().optional(),
|
|
20340
|
+
additions: external_exports.number().int().nonnegative().optional(),
|
|
20341
|
+
deletions: external_exports.number().int().nonnegative().optional(),
|
|
20342
|
+
changedFiles: external_exports.array(external_exports.object({
|
|
20343
|
+
path: external_exports.string(),
|
|
20344
|
+
status: external_exports.string(),
|
|
20345
|
+
additions: external_exports.number().int(),
|
|
20346
|
+
deletions: external_exports.number().int()
|
|
20347
|
+
})).optional(),
|
|
20348
|
+
linkedTaskReadableId: external_exports.string().nullable().optional(),
|
|
20349
|
+
linkedTaskId: external_exports.string().nullable().optional(),
|
|
20350
|
+
linkedTaskNumber: external_exports.number().int().nullable().optional(),
|
|
20351
|
+
htmlUrl: external_exports.string().optional()
|
|
20352
|
+
}));
|
|
20353
|
+
agentUserIdentitySchema = wire()(external_exports.object({ id: external_exports.string().min(1), name: external_exports.string().nullable(), email: external_exports.string() }));
|
|
20354
|
+
workflowToolRefSchema = wire()(external_exports.object({ type: external_exports.string().min(1), id: external_exports.string().min(1) }));
|
|
20355
|
+
runPromptContextSchema = external_exports.object({
|
|
20356
|
+
taskMeta: taskMetaSchema.optional(),
|
|
20357
|
+
prMeta: pullRequestMetaSchema.optional(),
|
|
20358
|
+
currentUser: agentUserIdentitySchema.optional(),
|
|
20359
|
+
sessionVisibility: external_exports.enum(["private", "team"]).nullable().optional(),
|
|
20360
|
+
workflowTools: external_exports.array(workflowToolRefSchema).optional(),
|
|
20361
|
+
availableSkills: external_exports.array(external_exports.object({
|
|
20362
|
+
name: external_exports.string().min(1),
|
|
20363
|
+
description: external_exports.string(),
|
|
20364
|
+
packageDirectory: external_exports.string().min(1)
|
|
20365
|
+
})).max(2e3).optional()
|
|
20303
20366
|
});
|
|
20304
|
-
resultEnvelopeSchema = external_exports.discriminatedUnion("ok", [
|
|
20305
|
-
external_exports.object({ ok: external_exports.literal(true), value: external_exports.unknown() }),
|
|
20306
|
-
external_exports.object({ ok: external_exports.literal(false), error: workspaceQueryErrorSchema })
|
|
20307
|
-
]);
|
|
20308
20367
|
}
|
|
20309
20368
|
});
|
|
20310
20369
|
|
|
@@ -20315,6 +20374,7 @@ var init_desired_state = __esm({
|
|
|
20315
20374
|
"use strict";
|
|
20316
20375
|
init_zod();
|
|
20317
20376
|
init_contracts();
|
|
20377
|
+
init_agent_context();
|
|
20318
20378
|
init_ids();
|
|
20319
20379
|
init_run_context();
|
|
20320
20380
|
init_workspace();
|
|
@@ -20349,6 +20409,7 @@ var init_desired_state = __esm({
|
|
|
20349
20409
|
repoLocalPaths: external_exports.array(repoLocalPathSchema).optional(),
|
|
20350
20410
|
/** Applied once, at the conversation's first turn on a cloud sandbox; never moves local work. */
|
|
20351
20411
|
requestedCheckouts: external_exports.array(requestedCheckoutSchema).max(64).optional(),
|
|
20412
|
+
agentContext: agentContextSchema.optional(),
|
|
20352
20413
|
workflowId: external_exports.guid().optional(),
|
|
20353
20414
|
workflowExecutionId: external_exports.guid().optional(),
|
|
20354
20415
|
agentId: external_exports.string().min(1).optional(),
|
|
@@ -21362,6 +21423,7 @@ var init_skills = __esm({
|
|
|
21362
21423
|
var init_runtime_v2 = __esm({
|
|
21363
21424
|
"../shared/dist/runtime-v2/index.js"() {
|
|
21364
21425
|
"use strict";
|
|
21426
|
+
init_agent_context();
|
|
21365
21427
|
init_capabilities();
|
|
21366
21428
|
init_desired_state();
|
|
21367
21429
|
init_git_capability();
|
|
@@ -22057,6 +22119,7 @@ Team
|
|
|
22057
22119
|
- Scan available context (task, subtasks, code, history) before asking questions you can answer yourself.
|
|
22058
22120
|
- Challenge when off \u2014 never silently implement the wrong thing.
|
|
22059
22121
|
- Act on the user's request and make reasonable implementation and tool choices within its scope. Do not ask again for permission already granted. Ask only when essential information is missing or an action requires additional authority.
|
|
22122
|
+
- When a user asks to create a Skill, default to a team-owned Alan platform Skill through \`alan-skill-authoring\`, whether this session runs locally or in a cloud sandbox. Use a repository or filesystem Skill only when the user explicitly requests that scope. Do not infer repository scope from the current checkout or from a procedure that mentions repository files. If repeated work suggests a reusable Skill, offer the platform Skill and its evidence; do not publish it without the approval required by the authoring workflow.
|
|
22060
22123
|
- Own mistakes. Wrong ID, jumped too fast \u2014 say so and fix it.
|
|
22061
22124
|
- Write for a human reader. Task, subtask and epic descriptions, documents, artifacts and comments are read by people in the app, not parsed by agents. Lead with the outcome in one sentence, then short sections with headings and bullet lists. Spell out internal shorthand, and keep commit hashes, IDs and migration numbers out of sentences \u2014 put them in a trailing "References" list when they matter.
|
|
22062
22125
|
- Think visually, proactively \u2014 not only when asked. Mermaid over paragraphs for architecture, flows, state, and schema. The same applies to data: when you're about to present a comparison, trend, breakdown, or status across several items, reach for a \`\`\`chart fence instead of a paragraph of numbers or a markdown table, even if the user never said the word "chart."
|
|
@@ -22302,7 +22365,7 @@ var init_chunk_YXWJW7I5 = __esm({
|
|
|
22302
22365
|
}
|
|
22303
22366
|
});
|
|
22304
22367
|
|
|
22305
|
-
// ../agent-core/dist/chunk-
|
|
22368
|
+
// ../agent-core/dist/chunk-XE7BX6YP.js
|
|
22306
22369
|
function windowsEnvValue(env, name) {
|
|
22307
22370
|
const wanted = name.toLowerCase();
|
|
22308
22371
|
for (const [key, value] of Object.entries(env).reverse()) {
|
|
@@ -22351,6 +22414,36 @@ function unwrapNativeShim(shim, args, files) {
|
|
|
22351
22414
|
const file2 = import_path.win32.resolve(directory, target.replace(/^%dp0%\\/i, ""));
|
|
22352
22415
|
return files.isFile(file2) ? { kind: "native", file: file2, args } : void 0;
|
|
22353
22416
|
}
|
|
22417
|
+
function binTargets(manifest) {
|
|
22418
|
+
if (typeof manifest !== "object" || manifest === null || !("bin" in manifest)) return [];
|
|
22419
|
+
const { bin } = manifest;
|
|
22420
|
+
if (typeof bin === "string") return [bin];
|
|
22421
|
+
if (typeof bin !== "object" || bin === null) return [];
|
|
22422
|
+
return Object.values(bin).filter((target) => typeof target === "string");
|
|
22423
|
+
}
|
|
22424
|
+
function parseManifest(text2) {
|
|
22425
|
+
try {
|
|
22426
|
+
return JSON.parse(text2);
|
|
22427
|
+
} catch {
|
|
22428
|
+
return void 0;
|
|
22429
|
+
}
|
|
22430
|
+
}
|
|
22431
|
+
function isDeclaredPackageBin(script, files) {
|
|
22432
|
+
const wanted = script.toLowerCase();
|
|
22433
|
+
let dir = import_path.win32.dirname(script);
|
|
22434
|
+
while (import_path.win32.basename(dir).toLowerCase() !== "node_modules") {
|
|
22435
|
+
const text2 = files.readShim(import_path.win32.join(dir, "package.json"));
|
|
22436
|
+
if (text2 !== void 0) {
|
|
22437
|
+
return binTargets(parseManifest(text2)).some(
|
|
22438
|
+
(target) => import_path.win32.resolve(dir, target).toLowerCase() === wanted
|
|
22439
|
+
);
|
|
22440
|
+
}
|
|
22441
|
+
const parent = import_path.win32.dirname(dir);
|
|
22442
|
+
if (parent === dir) return false;
|
|
22443
|
+
dir = parent;
|
|
22444
|
+
}
|
|
22445
|
+
return false;
|
|
22446
|
+
}
|
|
22354
22447
|
function isSimpleNodeShim(text2) {
|
|
22355
22448
|
return text2.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0).every((line) => /^@?echo off$/i.test(line) || NODE_SHIM_ENTRY.test(line));
|
|
22356
22449
|
}
|
|
@@ -22367,6 +22460,7 @@ function unwrapNodeShim(shim, args, env, files) {
|
|
|
22367
22460
|
const dir = import_path.win32.dirname(shim);
|
|
22368
22461
|
const script = import_path.win32.resolve(dir, scriptTemplate.replace(/%dp0%|%~dp0/gi, `${dir}\\`));
|
|
22369
22462
|
if (script.includes("%") || !files.isFile(script)) return void 0;
|
|
22463
|
+
if (!SCRIPT_EXTENSION.test(script) && !isDeclaredPackageBin(script, files)) return void 0;
|
|
22370
22464
|
const local = import_path.win32.join(dir, "node.exe");
|
|
22371
22465
|
const node2 = program.toLowerCase() === "%_prog%" ? files.isFile(local) ? local : resolveWindowsCommand("node", env, files) : program;
|
|
22372
22466
|
if (node2 === void 0 || node2.includes("%")) return void 0;
|
|
@@ -22910,9 +23004,9 @@ function waitForSpawn(child, command) {
|
|
|
22910
23004
|
child.once("error", onError);
|
|
22911
23005
|
});
|
|
22912
23006
|
}
|
|
22913
|
-
var import_child_process, import_fs, import_path, import_child_process2, import_promises6, import_child_process3, import_child_process4, import_child_process5, import_child_process6, import_crypto, import_fs2, import_promises7, import_os, import_path2, SHIM_MAX_BYTES, CMD_MAX_COMMAND_LINE, MAX_COMMAND_LINE, DEFAULT_PATHEXT, LAUNCHABLE_EXTENSIONS, nodeWindowsFiles, NODE_SHIM_ENTRY, NATIVE_SHIM_LINES, NATIVE_SHIM_ENTRY, CMD_META, NEVER_STARTED, HIDDEN_FLAG_PROBE_VALUE, NEWLINE, CARRIAGE_RETURN, EMPTY, MAX_LINE_BYTES, LineSplitter, PS_LINE, POLL_MS, DEFAULT_GRACE_MS, DEFAULT_KILL_WAIT_MS, DEFAULT_TASKKILL_TIMEOUT_MS, statuses, START_TIMEOUT_MS, spawnListeners;
|
|
22914
|
-
var
|
|
22915
|
-
"../agent-core/dist/chunk-
|
|
23007
|
+
var import_child_process, import_fs, import_path, import_child_process2, import_promises6, import_child_process3, import_child_process4, import_child_process5, import_child_process6, import_crypto, import_fs2, import_promises7, import_os, import_path2, SHIM_MAX_BYTES, CMD_MAX_COMMAND_LINE, MAX_COMMAND_LINE, DEFAULT_PATHEXT, LAUNCHABLE_EXTENSIONS, nodeWindowsFiles, NODE_SHIM_ENTRY, SCRIPT_EXTENSION, NATIVE_SHIM_LINES, NATIVE_SHIM_ENTRY, CMD_META, NEVER_STARTED, HIDDEN_FLAG_PROBE_VALUE, NEWLINE, CARRIAGE_RETURN, EMPTY, MAX_LINE_BYTES, LineSplitter, PS_LINE, POLL_MS, DEFAULT_GRACE_MS, DEFAULT_KILL_WAIT_MS, DEFAULT_TASKKILL_TIMEOUT_MS, statuses, START_TIMEOUT_MS, spawnListeners;
|
|
23008
|
+
var init_chunk_XE7BX6YP = __esm({
|
|
23009
|
+
"../agent-core/dist/chunk-XE7BX6YP.js"() {
|
|
22916
23010
|
"use strict";
|
|
22917
23011
|
init_chunk_YXWJW7I5();
|
|
22918
23012
|
import_child_process = require("child_process");
|
|
@@ -22951,7 +23045,8 @@ var init_chunk_M6YHY2EZ = __esm({
|
|
|
22951
23045
|
}
|
|
22952
23046
|
}
|
|
22953
23047
|
};
|
|
22954
|
-
NODE_SHIM_ENTRY = /"(%_prog%|[^"\r\n]*node(?:\.exe)?)"\s+"([^"\r\n]
|
|
23048
|
+
NODE_SHIM_ENTRY = /"(%_prog%|[^"\r\n]*node(?:\.exe)?)"\s+"([^"\r\n]+)"\s+%\*/i;
|
|
23049
|
+
SCRIPT_EXTENSION = /\.(?:c?js|mjs)$/i;
|
|
22955
23050
|
NATIVE_SHIM_LINES = [
|
|
22956
23051
|
/^@echo off$/i,
|
|
22957
23052
|
/^goto start$/i,
|
|
@@ -24230,7 +24325,7 @@ var init_chunk_SBT5W7L4 = __esm({
|
|
|
24230
24325
|
}
|
|
24231
24326
|
});
|
|
24232
24327
|
|
|
24233
|
-
// ../agent-core/dist/chunk-
|
|
24328
|
+
// ../agent-core/dist/chunk-ZCTKXKYY.js
|
|
24234
24329
|
function readCapReset(text2) {
|
|
24235
24330
|
const epoch = EPOCH_RESET.exec(text2);
|
|
24236
24331
|
if (epoch) return { resetsAt: new Date(Number(epoch[1]) * 1e3).toISOString() };
|
|
@@ -24437,8 +24532,8 @@ function createCliProblem(observed, options) {
|
|
|
24437
24532
|
});
|
|
24438
24533
|
}
|
|
24439
24534
|
var import_crypto2, EPOCH_RESET, WORDED_RESET, CODEX_RESET, ERROR_SPECS, AGENT_ERROR_KINDS, AGENT_SIGN_IN_BY_HARNESS, STATUS_PREFIX, TEXT_RULES, CODEX_TIMEOUT_MESSAGE, CODEX_EXPIRED_MESSAGE, COMMAND_NOT_FOUND, CODE_RULES, TEXT_REFINES, STATUS_LEAD, CLI_PROBLEM_CODE_BY_ERROR_KIND, KEY_REJECTION_KINDS;
|
|
24440
|
-
var
|
|
24441
|
-
"../agent-core/dist/chunk-
|
|
24535
|
+
var init_chunk_ZCTKXKYY = __esm({
|
|
24536
|
+
"../agent-core/dist/chunk-ZCTKXKYY.js"() {
|
|
24442
24537
|
"use strict";
|
|
24443
24538
|
init_chunk_YXWJW7I5();
|
|
24444
24539
|
import_crypto2 = require("crypto");
|
|
@@ -24629,7 +24724,7 @@ var init_chunk_HBIPWAUI = __esm({
|
|
|
24629
24724
|
},
|
|
24630
24725
|
{
|
|
24631
24726
|
kind: "overloaded",
|
|
24632
|
-
pattern: /\boverloaded(?:_error)?\b|\bat capacity\b|\bserver_overloaded\b|\b(?:http|status|code|error)\s*:?\s*5\d\d\b|\[5\d\d\]|\bapi error:?\s*5\d\d\b|\b5\d\d (?:internal server error|bad gateway|service unavailable|gateway timeout)\b|\bservice unavailable\b|\bbad gateway\b|\bgateway timeout\b/
|
|
24727
|
+
pattern: /\boverloaded(?:_error)?\b|\bat capacity\b|\bserver_overloaded\b|\b(?:http|status|code|error)\s*:?\s*5\d\d\b|\[5\d\d\]|\bapi error:?\s*5\d\d\b|\b5\d\d (?:internal server error|bad gateway|service unavailable|gateway timeout)\b|\bservice unavailable\b|\bbad gateway\b|\bgateway timeout\b|\bapi server (?:encountered an error|returned an error|is unavailable)\b/
|
|
24633
24728
|
},
|
|
24634
24729
|
{
|
|
24635
24730
|
kind: "context_length",
|
|
@@ -24637,7 +24732,7 @@ var init_chunk_HBIPWAUI = __esm({
|
|
|
24637
24732
|
},
|
|
24638
24733
|
{
|
|
24639
24734
|
kind: "network",
|
|
24640
|
-
pattern: /\b(?:econnrefused|econnreset|enotfound|etimedout|eai_again|ehostunreach|enetunreach)\b|\bfetch failed\b|\bnetwork (?:error|failure|is unreachable|connection (?:failed|lost))\b|\b(?:request|connection|socket) (?:timed out|timeout)\b|\bconnection reset by peer\b/
|
|
24735
|
+
pattern: /\b(?:econnrefused|econnreset|enotfound|etimedout|eai_again|ehostunreach|enetunreach)\b|\bfetch failed\b|\bnetwork (?:error|failure|is unreachable|connection (?:failed|lost))\b|\b(?:request|connection|socket) (?:timed out|timeout)\b|\bconnection reset by peer\b|\bunable to connect to the (?:api|server)\b|\bcould not connect to the (?:api|server)\b|\bplease check your network connection\b/
|
|
24641
24736
|
},
|
|
24642
24737
|
// launchd hands GUI daemons PATH=/usr/bin:/bin:/usr/sbin:/sbin, so `#!/usr/bin/env node`
|
|
24643
24738
|
// fails even though node is installed under nvm/fnm/volta.
|
|
@@ -24702,7 +24797,7 @@ var init_chunk_HBIPWAUI = __esm({
|
|
|
24702
24797
|
}
|
|
24703
24798
|
});
|
|
24704
24799
|
|
|
24705
|
-
// ../agent-core/dist/chunk-
|
|
24800
|
+
// ../agent-core/dist/chunk-A2TG6ROT.js
|
|
24706
24801
|
function detectImageMimeType(buffer) {
|
|
24707
24802
|
if (buffer.length >= 8 && buffer.subarray(0, 8).equals(PNG_SIGNATURE)) return "image/png";
|
|
24708
24803
|
if (buffer.length >= 3 && buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255) {
|
|
@@ -25020,10 +25115,26 @@ function createNdjsonWriter(stream) {
|
|
|
25020
25115
|
}
|
|
25021
25116
|
function hostProcess(child, tree, options, handlers) {
|
|
25022
25117
|
const writer = createNdjsonWriter(child.stdin);
|
|
25023
|
-
const flags = {
|
|
25118
|
+
const flags = {
|
|
25119
|
+
closing: false,
|
|
25120
|
+
outputClosedEarly: false,
|
|
25121
|
+
lastScan: Number.NEGATIVE_INFINITY,
|
|
25122
|
+
lastOutputAt: void 0
|
|
25123
|
+
};
|
|
25024
25124
|
const terminate = () => tree.terminate({ graceMs: options.terminateGraceMs });
|
|
25025
|
-
|
|
25026
|
-
|
|
25125
|
+
const heard = () => {
|
|
25126
|
+
flags.lastOutputAt = options.clock.monotonic();
|
|
25127
|
+
};
|
|
25128
|
+
readNdjson(child.stdout, {
|
|
25129
|
+
onLine: (line) => {
|
|
25130
|
+
heard();
|
|
25131
|
+
handlers.onLine(line);
|
|
25132
|
+
}
|
|
25133
|
+
});
|
|
25134
|
+
const stderr = new LineSplitter((line) => {
|
|
25135
|
+
heard();
|
|
25136
|
+
handlers.onStderrLine(line);
|
|
25137
|
+
});
|
|
25027
25138
|
child.stderr.on("data", (chunk) => stderr.push(chunk));
|
|
25028
25139
|
child.stderr.once("end", () => stderr.flush());
|
|
25029
25140
|
const processExit = new Promise((resolve9) => {
|
|
@@ -25056,6 +25167,9 @@ function hostProcess(child, tree, options, handlers) {
|
|
|
25056
25167
|
};
|
|
25057
25168
|
return {
|
|
25058
25169
|
pid: child.pid,
|
|
25170
|
+
get lastOutputAt() {
|
|
25171
|
+
return flags.lastOutputAt;
|
|
25172
|
+
},
|
|
25059
25173
|
writer,
|
|
25060
25174
|
exited: watch(),
|
|
25061
25175
|
terminate,
|
|
@@ -25086,12 +25200,12 @@ function silentStartError(name, timeoutMs) {
|
|
|
25086
25200
|
};
|
|
25087
25201
|
}
|
|
25088
25202
|
var import_crypto3, import_fs4, import_path3, PNG_SIGNATURE, IMAGE_MIME_BY_EXT, VIDEO_MIME_BY_EXT, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, MAX_IMAGE_BYTES, MAX_VIDEO_BYTES, AGENT_BROWSER_MENTION, LocalMediaReader, SessionOpenRefusal, JsonRpcError, ACP_PROTOCOL_VERSION, ACP_ERROR, STDERR_TAIL_LINES, RESULT_EXIT_GRACE_MS, PerTurnSession;
|
|
25089
|
-
var
|
|
25090
|
-
"../agent-core/dist/chunk-
|
|
25203
|
+
var init_chunk_A2TG6ROT = __esm({
|
|
25204
|
+
"../agent-core/dist/chunk-A2TG6ROT.js"() {
|
|
25091
25205
|
"use strict";
|
|
25092
25206
|
init_chunk_XC5676SG();
|
|
25093
|
-
|
|
25094
|
-
|
|
25207
|
+
init_chunk_ZCTKXKYY();
|
|
25208
|
+
init_chunk_XE7BX6YP();
|
|
25095
25209
|
init_chunk_YXWJW7I5();
|
|
25096
25210
|
import_crypto3 = require("crypto");
|
|
25097
25211
|
import_fs4 = require("fs");
|
|
@@ -25250,6 +25364,7 @@ var init_chunk_4G77APXN = __esm({
|
|
|
25250
25364
|
#sessionId;
|
|
25251
25365
|
#pid;
|
|
25252
25366
|
#current;
|
|
25367
|
+
#host;
|
|
25253
25368
|
constructor(provider4, options, resumeId) {
|
|
25254
25369
|
this.#provider = provider4;
|
|
25255
25370
|
this.#options = options;
|
|
@@ -25265,6 +25380,9 @@ var init_chunk_4G77APXN = __esm({
|
|
|
25265
25380
|
get pid() {
|
|
25266
25381
|
return this.#current ? this.#pid : void 0;
|
|
25267
25382
|
}
|
|
25383
|
+
get lastOutputAt() {
|
|
25384
|
+
return this.#current ? this.#host?.lastOutputAt : void 0;
|
|
25385
|
+
}
|
|
25268
25386
|
onEvent(listener) {
|
|
25269
25387
|
return this.#listeners.add(listener);
|
|
25270
25388
|
}
|
|
@@ -25404,6 +25522,7 @@ var init_chunk_4G77APXN = __esm({
|
|
|
25404
25522
|
}
|
|
25405
25523
|
}
|
|
25406
25524
|
);
|
|
25525
|
+
this.#host = host;
|
|
25407
25526
|
active.interrupt = () => tree.interrupt();
|
|
25408
25527
|
active.terminate = () => host.terminate();
|
|
25409
25528
|
try {
|
|
@@ -25554,7 +25673,259 @@ var init_chunk_J2KTV5FP = __esm({
|
|
|
25554
25673
|
}
|
|
25555
25674
|
});
|
|
25556
25675
|
|
|
25557
|
-
// ../agent-core/dist/chunk-
|
|
25676
|
+
// ../agent-core/dist/chunk-GI3ZGXTY.js
|
|
25677
|
+
function repositories(input2, context) {
|
|
25678
|
+
const problems = new Map(input2.problems.map((problem) => [problem.path, problem]));
|
|
25679
|
+
const listed = context?.repositories ?? [];
|
|
25680
|
+
const known = new Set(listed.map((repository) => repository.path));
|
|
25681
|
+
const unlisted = input2.problems.filter((problem) => !known.has(problem.path));
|
|
25682
|
+
return [
|
|
25683
|
+
...listed.map((repository) => {
|
|
25684
|
+
const problem = problems.get(repository.path);
|
|
25685
|
+
return {
|
|
25686
|
+
path: repository.path,
|
|
25687
|
+
name: repository.name,
|
|
25688
|
+
url: repository.url,
|
|
25689
|
+
branch: repository.branch,
|
|
25690
|
+
branchSource: repository.branchSource,
|
|
25691
|
+
base: repository.base,
|
|
25692
|
+
checkout: problem ? "needs_attention" : "ok",
|
|
25693
|
+
...problem ? { problem: problem.problem, action: problem.action } : {}
|
|
25694
|
+
};
|
|
25695
|
+
}),
|
|
25696
|
+
...unlisted.map(
|
|
25697
|
+
(problem) => ({
|
|
25698
|
+
path: problem.path,
|
|
25699
|
+
checkout: "needs_attention",
|
|
25700
|
+
problem: problem.problem,
|
|
25701
|
+
action: problem.action
|
|
25702
|
+
})
|
|
25703
|
+
)
|
|
25704
|
+
];
|
|
25705
|
+
}
|
|
25706
|
+
function branchInstruction(repository) {
|
|
25707
|
+
const { path, branch, branchSource } = repository;
|
|
25708
|
+
if (!branch || !branchSource) return void 0;
|
|
25709
|
+
const reason = BRANCH_REASONS[branchSource];
|
|
25710
|
+
if (branchSource === "task") {
|
|
25711
|
+
return `Commit work in ${path} on ${branch}, ${reason}; create it from ${repository.base ?? "the default branch"} if it does not exist.`;
|
|
25712
|
+
}
|
|
25713
|
+
return `Work in ${path} on ${branch}, ${reason}.`;
|
|
25714
|
+
}
|
|
25715
|
+
function repositoryInstructions(repository) {
|
|
25716
|
+
const problem = repository.problem && repository.action ? `${repository.path} ${repository.problem}. ${repository.action} before relying on its files.` : void 0;
|
|
25717
|
+
const branch = problem && repository.branchSource !== "environment_default" ? void 0 : branchInstruction(repository);
|
|
25718
|
+
return [branch, problem].filter((line) => line !== void 0);
|
|
25719
|
+
}
|
|
25720
|
+
function environmentInstructions(environment, cwd) {
|
|
25721
|
+
const lines = [];
|
|
25722
|
+
const start = environment.start;
|
|
25723
|
+
if (start?.state === "failed") {
|
|
25724
|
+
lines.push(
|
|
25725
|
+
`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.`
|
|
25726
|
+
);
|
|
25727
|
+
} else if (start?.state === "pending") {
|
|
25728
|
+
lines.push(`The start command is still starting; check ${start.log} before testing the app.`);
|
|
25729
|
+
}
|
|
25730
|
+
const build = environment.pendingBuild;
|
|
25731
|
+
if (build?.status === "queued" || build?.status === "running") {
|
|
25732
|
+
lines.push(
|
|
25733
|
+
`Image build ${build.id} is ${build.status}; its result arrives as a message, so do not poll for it.`
|
|
25734
|
+
);
|
|
25735
|
+
} else if (build?.status === "failed") {
|
|
25736
|
+
lines.push(
|
|
25737
|
+
`The latest image build (${build.id}) failed; sessions still boot from the previous image.`
|
|
25738
|
+
);
|
|
25739
|
+
}
|
|
25740
|
+
if (environment.variables.length > 0) {
|
|
25741
|
+
lines.push("Saved variables are set in this sandbox; never print or commit their values.");
|
|
25742
|
+
}
|
|
25743
|
+
return lines;
|
|
25744
|
+
}
|
|
25745
|
+
function instructionsFor(snapshot2) {
|
|
25746
|
+
const cwd = snapshot2.workspace.cwd ?? snapshot2.workspace.root ?? "the workspace";
|
|
25747
|
+
return [
|
|
25748
|
+
...snapshot2.session.trigger === "image_build" ? ["Alan sent this turn, not the user: it reports an image build result."] : [],
|
|
25749
|
+
...snapshot2.environment ? environmentInstructions(snapshot2.environment, cwd) : []
|
|
25750
|
+
];
|
|
25751
|
+
}
|
|
25752
|
+
function startingInstructions(snapshot2) {
|
|
25753
|
+
const cwd = snapshot2.workspace.cwd ?? snapshot2.workspace.root;
|
|
25754
|
+
return [
|
|
25755
|
+
...cwd ? [`Work from ${cwd}.`] : [],
|
|
25756
|
+
...snapshot2.workspace.repositories.flatMap(repositoryInstructions)
|
|
25757
|
+
];
|
|
25758
|
+
}
|
|
25759
|
+
function sessionKind(input2, context) {
|
|
25760
|
+
if (context) return context.kind;
|
|
25761
|
+
if (input2.spec.workflowExecutionId) return "workflow";
|
|
25762
|
+
return input2.spec.taskId ? "task" : "chat";
|
|
25763
|
+
}
|
|
25764
|
+
function environmentOf(input2, context) {
|
|
25765
|
+
const environment = context?.environment;
|
|
25766
|
+
if (!environment) return void 0;
|
|
25767
|
+
const start = environment.startCommand === null ? { state: "not_configured" } : input2.start;
|
|
25768
|
+
return {
|
|
25769
|
+
id: environment.id,
|
|
25770
|
+
name: environment.name,
|
|
25771
|
+
installCommand: environment.installCommand,
|
|
25772
|
+
startCommand: environment.startCommand,
|
|
25773
|
+
imageBuildId: environment.imageBuildId,
|
|
25774
|
+
...environment.pendingBuild ? { pendingBuild: environment.pendingBuild } : {},
|
|
25775
|
+
variables: environment.variables,
|
|
25776
|
+
...start ? { start: start.state === "not_configured" ? start : { ...start, log: input2.startLogPath } } : {}
|
|
25777
|
+
};
|
|
25778
|
+
}
|
|
25779
|
+
function knownContext(snapshot2) {
|
|
25780
|
+
const organizationId = snapshot2?.session.organizationId;
|
|
25781
|
+
if (!snapshot2 || !organizationId) return void 0;
|
|
25782
|
+
const environment = snapshot2.environment;
|
|
25783
|
+
return {
|
|
25784
|
+
kind: snapshot2.session.kind,
|
|
25785
|
+
trigger: "user",
|
|
25786
|
+
organizationId,
|
|
25787
|
+
...snapshot2.task ? { taskWorkingBranch: snapshot2.task.workingBranch } : {},
|
|
25788
|
+
...snapshot2.pullRequest ? { pullRequest: snapshot2.pullRequest } : {},
|
|
25789
|
+
repositories: snapshot2.workspace.repositories.flatMap(
|
|
25790
|
+
({ path, name, url: url2, branch, branchSource, base }) => name && url2 && branch && branchSource && base ? [{ path, name, url: url2, branch, branchSource, base }] : []
|
|
25791
|
+
),
|
|
25792
|
+
...environment ? {
|
|
25793
|
+
environment: {
|
|
25794
|
+
id: environment.id,
|
|
25795
|
+
name: environment.name,
|
|
25796
|
+
installCommand: environment.installCommand,
|
|
25797
|
+
startCommand: environment.startCommand,
|
|
25798
|
+
imageBuildId: environment.imageBuildId,
|
|
25799
|
+
...environment.pendingBuild ? { pendingBuild: environment.pendingBuild } : {},
|
|
25800
|
+
variables: environment.variables
|
|
25801
|
+
}
|
|
25802
|
+
} : {}
|
|
25803
|
+
};
|
|
25804
|
+
}
|
|
25805
|
+
function agentContextSnapshot(input2) {
|
|
25806
|
+
const context = input2.spec.agentContext ?? knownContext(input2.known);
|
|
25807
|
+
if (!context && input2.problems.length === 0) return null;
|
|
25808
|
+
const environment = environmentOf(input2, context);
|
|
25809
|
+
const base = {
|
|
25810
|
+
session: {
|
|
25811
|
+
kind: sessionKind(input2, context),
|
|
25812
|
+
trigger: context?.trigger ?? "user",
|
|
25813
|
+
conversationId: input2.spec.conversationId,
|
|
25814
|
+
runId: input2.spec.runId,
|
|
25815
|
+
...input2.spec.teamId ? { teamId: input2.spec.teamId } : {},
|
|
25816
|
+
...input2.spec.taskId ? { taskId: input2.spec.taskId } : {},
|
|
25817
|
+
...input2.spec.workflowExecutionId ? { workflowExecutionId: input2.spec.workflowExecutionId } : {},
|
|
25818
|
+
...context ? { organizationId: context.organizationId } : {}
|
|
25819
|
+
},
|
|
25820
|
+
...context?.taskWorkingBranch ? { task: { workingBranch: context.taskWorkingBranch } } : {},
|
|
25821
|
+
...context?.pullRequest ? { pullRequest: context.pullRequest } : {},
|
|
25822
|
+
workspace: {
|
|
25823
|
+
...input2.workspaceRoot ? { root: input2.workspaceRoot } : {},
|
|
25824
|
+
...input2.spec.projectPath ? { cwd: input2.spec.projectPath } : {},
|
|
25825
|
+
repositories: repositories(input2, context)
|
|
25826
|
+
},
|
|
25827
|
+
...environment ? { environment } : {}
|
|
25828
|
+
};
|
|
25829
|
+
return { ...base, instructions: instructionsFor(base) };
|
|
25830
|
+
}
|
|
25831
|
+
function isScalar(value) {
|
|
25832
|
+
return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
25833
|
+
}
|
|
25834
|
+
function scalar(value) {
|
|
25835
|
+
if (typeof value !== "string") return String(value);
|
|
25836
|
+
return PLAIN_SCALAR.test(value) ? value : JSON.stringify(value);
|
|
25837
|
+
}
|
|
25838
|
+
function snakeCase(key) {
|
|
25839
|
+
return key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
25840
|
+
}
|
|
25841
|
+
function yamlLines(record2, indent) {
|
|
25842
|
+
return Object.entries(record2).flatMap(([key, value]) => {
|
|
25843
|
+
const name = `${indent}${snakeCase(key)}:`;
|
|
25844
|
+
if (isScalar(value)) return [`${name} ${scalar(value)}`];
|
|
25845
|
+
if (Array.isArray(value)) {
|
|
25846
|
+
if (value.length === 0) return [];
|
|
25847
|
+
return [
|
|
25848
|
+
name,
|
|
25849
|
+
...value.flatMap((item) => {
|
|
25850
|
+
if (isScalar(item)) return [`${indent} - ${scalar(item)}`];
|
|
25851
|
+
if (typeof item !== "object" || item === null) return [];
|
|
25852
|
+
const [first = "", ...rest] = yamlLines(item, `${indent} `);
|
|
25853
|
+
return [`${indent} - ${first.trimStart()}`, ...rest];
|
|
25854
|
+
})
|
|
25855
|
+
];
|
|
25856
|
+
}
|
|
25857
|
+
if (typeof value === "object" && value !== null)
|
|
25858
|
+
return [name, ...yamlLines(value, `${indent} `)];
|
|
25859
|
+
return [];
|
|
25860
|
+
});
|
|
25861
|
+
}
|
|
25862
|
+
function block(tag, body) {
|
|
25863
|
+
return [`<${tag} version="${AGENT_CONTEXT_VERSION}">`, ...yamlLines(body, ""), `</${tag}>`].join(
|
|
25864
|
+
"\n"
|
|
25865
|
+
);
|
|
25866
|
+
}
|
|
25867
|
+
function stableRepository(repository) {
|
|
25868
|
+
const { checkout: _checkout, problem: _problem, action: _action, ...rest } = repository;
|
|
25869
|
+
return rest;
|
|
25870
|
+
}
|
|
25871
|
+
function commandPreview(command) {
|
|
25872
|
+
if (command === null || command.length <= COMMAND_PREVIEW_CHARS) return command;
|
|
25873
|
+
const lines = command.split("\n").length;
|
|
25874
|
+
return `${command.slice(0, COMMAND_PREVIEW_CHARS)}\u2026 (${lines} lines; get_cloud_machine has the full command)`;
|
|
25875
|
+
}
|
|
25876
|
+
function withCommandPreviews(environment) {
|
|
25877
|
+
return {
|
|
25878
|
+
...environment,
|
|
25879
|
+
...environment.installCommand !== void 0 ? { installCommand: commandPreview(environment.installCommand) } : {},
|
|
25880
|
+
...environment.startCommand !== void 0 ? { startCommand: commandPreview(environment.startCommand) } : {}
|
|
25881
|
+
};
|
|
25882
|
+
}
|
|
25883
|
+
function changed(a, b) {
|
|
25884
|
+
return JSON.stringify(a) !== JSON.stringify(b);
|
|
25885
|
+
}
|
|
25886
|
+
function environmentUpdate(previous, next) {
|
|
25887
|
+
if (!next) return void 0;
|
|
25888
|
+
const { start: previousStart, ...previousFacts } = previous ?? {};
|
|
25889
|
+
const { start, ...facts } = next;
|
|
25890
|
+
if (changed(previousFacts, facts)) return next;
|
|
25891
|
+
return start?.state === "failed" && changed(previousStart, start) ? { start } : void 0;
|
|
25892
|
+
}
|
|
25893
|
+
function updateBody(previous, next) {
|
|
25894
|
+
const known = new Set(previous.instructions);
|
|
25895
|
+
const instructions = next.instructions.filter((line) => !known.has(line));
|
|
25896
|
+
const before = new Map(
|
|
25897
|
+
previous.workspace.repositories.map((repository) => [
|
|
25898
|
+
repository.path,
|
|
25899
|
+
stableRepository(repository)
|
|
25900
|
+
])
|
|
25901
|
+
);
|
|
25902
|
+
const repositories2 = next.workspace.repositories.map(stableRepository).filter(
|
|
25903
|
+
(repository) => repository.path !== void 0 && changed(before.get(repository.path), repository)
|
|
25904
|
+
);
|
|
25905
|
+
const environment = environmentUpdate(previous.environment, next.environment);
|
|
25906
|
+
const facts = {
|
|
25907
|
+
...changed(previous.task, next.task) && next.task ? { task: next.task } : {},
|
|
25908
|
+
...changed(previous.pullRequest, next.pullRequest) && next.pullRequest ? { pullRequest: next.pullRequest } : {},
|
|
25909
|
+
...repositories2.length > 0 ? { workspace: { repositories: repositories2 } } : {},
|
|
25910
|
+
...environment ? { environment: withCommandPreviews(environment) } : {},
|
|
25911
|
+
...instructions.length > 0 ? { instructions } : {}
|
|
25912
|
+
};
|
|
25913
|
+
if (Object.keys(facts).length === 0) return void 0;
|
|
25914
|
+
return next.session.trigger === "user" ? facts : { session: { trigger: next.session.trigger }, ...facts };
|
|
25915
|
+
}
|
|
25916
|
+
function renderAgentContext(snapshot2, previous) {
|
|
25917
|
+
const full = block("alan_agent_context", {
|
|
25918
|
+
...snapshot2,
|
|
25919
|
+
...snapshot2.environment ? { environment: withCommandPreviews(snapshot2.environment) } : {},
|
|
25920
|
+
instructions: [...startingInstructions(snapshot2), ...snapshot2.instructions]
|
|
25921
|
+
});
|
|
25922
|
+
const update = previous ? updateBody(previous, snapshot2) : void 0;
|
|
25923
|
+
return {
|
|
25924
|
+
snapshot: snapshot2,
|
|
25925
|
+
full,
|
|
25926
|
+
...update ? { update: block("alan_agent_context_update", update) } : {}
|
|
25927
|
+
};
|
|
25928
|
+
}
|
|
25558
25929
|
function truncate(value, limit) {
|
|
25559
25930
|
const normalized2 = Array.from(value, (character) => {
|
|
25560
25931
|
const code = character.charCodeAt(0);
|
|
@@ -25813,11 +26184,12 @@ function cloudExecutionSection(spec) {
|
|
|
25813
26184
|
if (spec.sandboxId) lines.push(`Sandbox ID: ${spec.sandboxId}.`);
|
|
25814
26185
|
if (spec.cloudEnvironmentId) lines.push(`Cloud environment ID: ${spec.cloudEnvironmentId}.`);
|
|
25815
26186
|
lines.push(
|
|
25816
|
-
"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."
|
|
26187
|
+
"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.",
|
|
26188
|
+
"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."
|
|
25817
26189
|
);
|
|
25818
26190
|
if (!isReadOnlyMode(spec.mode) && !isReadOnlyAgent(spec.agentId)) {
|
|
25819
26191
|
lines.push(
|
|
25820
|
-
"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,
|
|
26192
|
+
"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."
|
|
25821
26193
|
);
|
|
25822
26194
|
}
|
|
25823
26195
|
const skills = spec.promptContext?.availableSkills ?? [];
|
|
@@ -25914,11 +26286,71 @@ function buildTurnText(input2) {
|
|
|
25914
26286
|
${body}` : body;
|
|
25915
26287
|
return spec.mode === "plan" ? planModePrefix(prefixed) : prefixed;
|
|
25916
26288
|
}
|
|
25917
|
-
var MAX_PARSED_ATTACHMENTS, MAX_PARSED_ATTACHMENT_CHARS, MAX_METADATA_CHARS, UNAVAILABLE, READ_ONLY_MODES, AGENT_MODES;
|
|
25918
|
-
var
|
|
25919
|
-
"../agent-core/dist/chunk-
|
|
26289
|
+
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;
|
|
26290
|
+
var init_chunk_GI3ZGXTY = __esm({
|
|
26291
|
+
"../agent-core/dist/chunk-GI3ZGXTY.js"() {
|
|
25920
26292
|
"use strict";
|
|
26293
|
+
init_runtime_v2();
|
|
26294
|
+
init_zod();
|
|
25921
26295
|
init_agent2();
|
|
26296
|
+
startCommandStateSchema = external_exports.discriminatedUnion("state", [
|
|
26297
|
+
external_exports.object({ state: external_exports.literal("not_configured") }),
|
|
26298
|
+
external_exports.object({ state: external_exports.literal("pending") }),
|
|
26299
|
+
external_exports.object({ state: external_exports.literal("running") }),
|
|
26300
|
+
external_exports.object({ state: external_exports.literal("exited_ok") }),
|
|
26301
|
+
external_exports.object({ state: external_exports.literal("failed"), exitCode: external_exports.number().int() })
|
|
26302
|
+
]);
|
|
26303
|
+
repositorySnapshotSchema = external_exports.object({
|
|
26304
|
+
path: external_exports.string(),
|
|
26305
|
+
name: external_exports.string().optional(),
|
|
26306
|
+
url: external_exports.string().optional(),
|
|
26307
|
+
branch: external_exports.string().optional(),
|
|
26308
|
+
branchSource: agentBranchSourceSchema.optional(),
|
|
26309
|
+
base: external_exports.string().optional(),
|
|
26310
|
+
checkout: external_exports.enum(["ok", "needs_attention"]),
|
|
26311
|
+
problem: external_exports.string().optional(),
|
|
26312
|
+
action: external_exports.string().optional()
|
|
26313
|
+
});
|
|
26314
|
+
environmentSnapshotSchema = external_exports.object({
|
|
26315
|
+
id: external_exports.string(),
|
|
26316
|
+
name: external_exports.string(),
|
|
26317
|
+
installCommand: external_exports.string().nullable(),
|
|
26318
|
+
startCommand: external_exports.string().nullable(),
|
|
26319
|
+
imageBuildId: external_exports.string().nullable(),
|
|
26320
|
+
pendingBuild: agentContextBuildSchema.optional(),
|
|
26321
|
+
variables: external_exports.array(external_exports.string()),
|
|
26322
|
+
start: external_exports.intersection(startCommandStateSchema, external_exports.object({ log: external_exports.string().optional() })).optional()
|
|
26323
|
+
});
|
|
26324
|
+
agentContextSnapshotSchema = external_exports.object({
|
|
26325
|
+
session: external_exports.object({
|
|
26326
|
+
kind: agentSessionKindSchema,
|
|
26327
|
+
trigger: agentTurnTriggerSchema,
|
|
26328
|
+
conversationId: external_exports.string(),
|
|
26329
|
+
runId: external_exports.string(),
|
|
26330
|
+
teamId: external_exports.string().optional(),
|
|
26331
|
+
taskId: external_exports.string().optional(),
|
|
26332
|
+
workflowExecutionId: external_exports.string().optional(),
|
|
26333
|
+
organizationId: external_exports.string().optional()
|
|
26334
|
+
}),
|
|
26335
|
+
task: external_exports.object({ workingBranch: external_exports.string() }).optional(),
|
|
26336
|
+
pullRequest: agentContextPullRequestSchema.optional(),
|
|
26337
|
+
workspace: external_exports.object({
|
|
26338
|
+
root: external_exports.string().optional(),
|
|
26339
|
+
cwd: external_exports.string().optional(),
|
|
26340
|
+
repositories: external_exports.array(repositorySnapshotSchema)
|
|
26341
|
+
}),
|
|
26342
|
+
environment: environmentSnapshotSchema.optional(),
|
|
26343
|
+
instructions: external_exports.array(external_exports.string())
|
|
26344
|
+
});
|
|
26345
|
+
BRANCH_REASONS = {
|
|
26346
|
+
handoff: "the branch handed off from the user's computer",
|
|
26347
|
+
pull_request: "this pull request's branch",
|
|
26348
|
+
task: "this task's branch",
|
|
26349
|
+
chat_selection: "the branch the user selected for this chat",
|
|
26350
|
+
environment_default: "the environment's default branch"
|
|
26351
|
+
};
|
|
26352
|
+
PLAIN_SCALAR = /^[A-Za-z0-9_./@~+-][A-Za-z0-9_./@~+:-]*$/;
|
|
26353
|
+
COMMAND_PREVIEW_CHARS = 200;
|
|
25922
26354
|
MAX_PARSED_ATTACHMENTS = 3;
|
|
25923
26355
|
MAX_PARSED_ATTACHMENT_CHARS = 12e3;
|
|
25924
26356
|
MAX_METADATA_CHARS = 240;
|
|
@@ -26356,16 +26788,16 @@ function parseClaudeEvent(event, state) {
|
|
|
26356
26788
|
}
|
|
26357
26789
|
function thoughtsOf(event, content, messageId, state) {
|
|
26358
26790
|
const texts = content.flatMap((raw) => {
|
|
26359
|
-
const
|
|
26360
|
-
if (!
|
|
26361
|
-
return [asString(
|
|
26791
|
+
const block2 = asRecord(raw);
|
|
26792
|
+
if (!block2 || asString(block2.type) !== "thinking") return [];
|
|
26793
|
+
return [asString(block2.thinking) || asString(block2.text)];
|
|
26362
26794
|
});
|
|
26363
26795
|
if (texts.length === 0) return [];
|
|
26364
26796
|
const frameId = asString(event.uuid) || synthId(state, "claude-thought-frame");
|
|
26365
26797
|
return thoughtBlocksFor(state, messageId).complete(frameId, texts);
|
|
26366
26798
|
}
|
|
26367
|
-
function textUpdates(frame,
|
|
26368
|
-
const text2 = asString(
|
|
26799
|
+
function textUpdates(frame, block2) {
|
|
26800
|
+
const text2 = asString(block2.text);
|
|
26369
26801
|
if (!text2 || frame.alreadyStreamed) return [];
|
|
26370
26802
|
const content = textBlock(frame.previousBlockWasText ? `
|
|
26371
26803
|
${text2}` : text2);
|
|
@@ -26386,12 +26818,12 @@ function thoughtUpdates(frame) {
|
|
|
26386
26818
|
}
|
|
26387
26819
|
];
|
|
26388
26820
|
}
|
|
26389
|
-
function blockUpdates(frame,
|
|
26390
|
-
const blockType = asString(
|
|
26391
|
-
if (blockType === "text") return textUpdates(frame,
|
|
26821
|
+
function blockUpdates(frame, block2) {
|
|
26822
|
+
const blockType = asString(block2.type);
|
|
26823
|
+
if (blockType === "text") return textUpdates(frame, block2);
|
|
26392
26824
|
frame.previousBlockWasText = false;
|
|
26393
26825
|
if (blockType === "thinking") return thoughtUpdates(frame);
|
|
26394
|
-
if (blockType === "tool_use") return parseToolUse(
|
|
26826
|
+
if (blockType === "tool_use") return parseToolUse(block2, frame.meta);
|
|
26395
26827
|
return [];
|
|
26396
26828
|
}
|
|
26397
26829
|
function parseAssistant(event, state) {
|
|
@@ -26409,8 +26841,8 @@ function parseAssistant(event, state) {
|
|
|
26409
26841
|
previousBlockWasText: false
|
|
26410
26842
|
};
|
|
26411
26843
|
return content.flatMap((raw) => {
|
|
26412
|
-
const
|
|
26413
|
-
return
|
|
26844
|
+
const block2 = asRecord(raw);
|
|
26845
|
+
return block2 ? blockUpdates(frame, block2) : [];
|
|
26414
26846
|
});
|
|
26415
26847
|
}
|
|
26416
26848
|
function toolUseMeta(name, input2, meta3) {
|
|
@@ -26423,11 +26855,11 @@ function toolUseMeta(name, input2, meta3) {
|
|
|
26423
26855
|
...!isAsk && normalizeToolName2(name) === "exitplanmode" ? { [EXIT_PLAN_MODE_INPUT_META]: input2 } : {}
|
|
26424
26856
|
};
|
|
26425
26857
|
}
|
|
26426
|
-
function parseToolUse(
|
|
26427
|
-
const toolCallId = asString(
|
|
26858
|
+
function parseToolUse(block2, meta3) {
|
|
26859
|
+
const toolCallId = asString(block2.id);
|
|
26428
26860
|
if (!toolCallId) return [];
|
|
26429
|
-
const name = canonicalizeManagedMcpToolName(asString(
|
|
26430
|
-
const input2 =
|
|
26861
|
+
const name = canonicalizeManagedMcpToolName(asString(block2.name));
|
|
26862
|
+
const input2 = block2.input;
|
|
26431
26863
|
const inputRecord = asRecord(input2) ?? {};
|
|
26432
26864
|
const pendingFileChange = claudeToolInputDiffContent(name, input2);
|
|
26433
26865
|
const updates = [
|
|
@@ -26469,21 +26901,21 @@ function parseUser(event) {
|
|
|
26469
26901
|
if (!message) return [];
|
|
26470
26902
|
const meta3 = nesting(event);
|
|
26471
26903
|
return asArray(message.content).flatMap((raw) => {
|
|
26472
|
-
const
|
|
26473
|
-
if (!
|
|
26474
|
-
const toolCallId = asString(
|
|
26904
|
+
const block2 = asRecord(raw);
|
|
26905
|
+
if (!block2 || asString(block2.type) !== "tool_result") return [];
|
|
26906
|
+
const toolCallId = asString(block2.tool_use_id);
|
|
26475
26907
|
if (!toolCallId) return [];
|
|
26476
|
-
const text2 = flattenToolResult(
|
|
26908
|
+
const text2 = flattenToolResult(block2.content);
|
|
26477
26909
|
const content = outputContent(text2);
|
|
26478
26910
|
const diffs = claudeFileChangeContents(event.tool_use_result);
|
|
26479
26911
|
return [
|
|
26480
26912
|
{
|
|
26481
26913
|
sessionUpdate: "tool_call_update",
|
|
26482
26914
|
toolCallId,
|
|
26483
|
-
status:
|
|
26915
|
+
status: block2.is_error === true ? "failed" : "completed",
|
|
26484
26916
|
...content || diffs.length ? { content: [...diffs, ...content ?? []] } : {},
|
|
26485
26917
|
rawOutput: text2,
|
|
26486
|
-
_meta: { ...meta3._meta, [PROVIDER_PAYLOAD_META]: event.tool_use_result ??
|
|
26918
|
+
_meta: { ...meta3._meta, [PROVIDER_PAYLOAD_META]: event.tool_use_result ?? block2 }
|
|
26487
26919
|
}
|
|
26488
26920
|
];
|
|
26489
26921
|
});
|
|
@@ -26997,12 +27429,12 @@ var init_claude = __esm({
|
|
|
26997
27429
|
"../agent-core/dist/providers/claude.js"() {
|
|
26998
27430
|
"use strict";
|
|
26999
27431
|
init_chunk_SBT5W7L4();
|
|
27000
|
-
|
|
27432
|
+
init_chunk_A2TG6ROT();
|
|
27001
27433
|
init_chunk_XC5676SG();
|
|
27002
|
-
|
|
27434
|
+
init_chunk_ZCTKXKYY();
|
|
27003
27435
|
init_chunk_J2KTV5FP();
|
|
27004
|
-
|
|
27005
|
-
|
|
27436
|
+
init_chunk_XE7BX6YP();
|
|
27437
|
+
init_chunk_GI3ZGXTY();
|
|
27006
27438
|
init_chunk_YXWJW7I5();
|
|
27007
27439
|
init_effort();
|
|
27008
27440
|
import_crypto6 = require("crypto");
|
|
@@ -27525,11 +27957,11 @@ var init_claude = __esm({
|
|
|
27525
27957
|
}
|
|
27526
27958
|
this.#iterations += 1;
|
|
27527
27959
|
for (const raw of asArray(asRecord(event.message)?.content)) {
|
|
27528
|
-
const
|
|
27529
|
-
if (!
|
|
27530
|
-
const id = asString(
|
|
27960
|
+
const block2 = asRecord(raw);
|
|
27961
|
+
if (!block2 || asString(block2.type) !== "tool_use") continue;
|
|
27962
|
+
const id = asString(block2.id);
|
|
27531
27963
|
if (!id) continue;
|
|
27532
|
-
const name = canonicalizeManagedMcpToolName(asString(
|
|
27964
|
+
const name = canonicalizeManagedMcpToolName(asString(block2.name));
|
|
27533
27965
|
if (isInteractiveToolName(name) || INTERACTIVE_TOOL_NAMES.has(normalizeToolName2(name))) {
|
|
27534
27966
|
this.#suppressedResults.add(id);
|
|
27535
27967
|
}
|
|
@@ -27651,6 +28083,9 @@ var init_claude = __esm({
|
|
|
27651
28083
|
get pid() {
|
|
27652
28084
|
return this.#host.pid;
|
|
27653
28085
|
}
|
|
28086
|
+
get lastOutputAt() {
|
|
28087
|
+
return this.#host.lastOutputAt;
|
|
28088
|
+
}
|
|
27654
28089
|
onEvent(listener) {
|
|
27655
28090
|
return this.#listeners.add(listener);
|
|
27656
28091
|
}
|
|
@@ -29212,12 +29647,12 @@ var init_codex = __esm({
|
|
|
29212
29647
|
"../agent-core/dist/providers/codex.js"() {
|
|
29213
29648
|
"use strict";
|
|
29214
29649
|
init_chunk_SBT5W7L4();
|
|
29215
|
-
|
|
29650
|
+
init_chunk_A2TG6ROT();
|
|
29216
29651
|
init_chunk_XC5676SG();
|
|
29217
|
-
|
|
29652
|
+
init_chunk_ZCTKXKYY();
|
|
29218
29653
|
init_chunk_J2KTV5FP();
|
|
29219
|
-
|
|
29220
|
-
|
|
29654
|
+
init_chunk_XE7BX6YP();
|
|
29655
|
+
init_chunk_GI3ZGXTY();
|
|
29221
29656
|
init_chunk_YXWJW7I5();
|
|
29222
29657
|
import_fs6 = require("fs");
|
|
29223
29658
|
import_path6 = require("path");
|
|
@@ -29765,6 +30200,9 @@ var init_codex = __esm({
|
|
|
29765
30200
|
get pid() {
|
|
29766
30201
|
return this.#host.pid;
|
|
29767
30202
|
}
|
|
30203
|
+
get lastOutputAt() {
|
|
30204
|
+
return this.#host.lastOutputAt;
|
|
30205
|
+
}
|
|
29768
30206
|
get exited() {
|
|
29769
30207
|
return this.#host.exited;
|
|
29770
30208
|
}
|
|
@@ -30373,7 +30811,8 @@ function alanCodeConfigContent(existing, input2) {
|
|
|
30373
30811
|
baseURL: input2.baseURL,
|
|
30374
30812
|
apiKey: `{env:${ALAN_CODE_API_KEY_ENV}}`,
|
|
30375
30813
|
headers: { [MANAGED_MCP_CONVERSATION_HEADER]: `{env:${ALAN_CODE_CONVERSATION_ID_ENV}}` },
|
|
30376
|
-
setCacheKey: true
|
|
30814
|
+
setCacheKey: true,
|
|
30815
|
+
chunkTimeout: ALAN_CODE_CHUNK_TIMEOUT_MS
|
|
30377
30816
|
},
|
|
30378
30817
|
models: Object.fromEntries(input2.models.map((model) => [model.id, engineModel(model)]))
|
|
30379
30818
|
}
|
|
@@ -30665,7 +31104,7 @@ function alanCodeSystemPrompt(alanSystemPrompt) {
|
|
|
30665
31104
|
|
|
30666
31105
|
${instructions}` : ALAN_CODE_TOOL_NAMING_PROMPT;
|
|
30667
31106
|
}
|
|
30668
|
-
var import_http3, import_https, import_fs7, import_path7, import_crypto12, import_promises16, import_path8, import_url, ALAN_CODE_BASELINE_PROMPT, ALAN_CODE_ENGINE_PROVIDER_ID, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_OUTPUT_TOKENS, ALAN_CODE_API_KEY_ENV, ALAN_CODE_CONVERSATION_ID_ENV, ALAN_CODE_PROXY_PATH, ALAN_CODE_WEBSEARCH_PATH, ALAN_CODE_CATALOG_PATH, CATALOG_TIMEOUT_MS, MAX_CATALOG_BYTES, ACTIVATION_WAIT_MS, ACTIVATION_POLL_MS, CatalogResponseError, ALAN_CODE_ENGINE_PATH_ENV, ALAN_CODE_ENGINE_COMMAND, ALAN_CODE_ENGINE_NAME, WINDOWS_RUNNABLE_EXTENSION, ALAN_CODE_ENGINE_PLUGIN_VERSION, ALAN_CODE_TOOL_NAMING_PROMPT;
|
|
31107
|
+
var import_http3, import_https, import_fs7, import_path7, import_crypto12, import_promises16, import_path8, import_url, ALAN_CODE_BASELINE_PROMPT, ALAN_CODE_ENGINE_PROVIDER_ID, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_OUTPUT_TOKENS, ALAN_CODE_API_KEY_ENV, ALAN_CODE_CONVERSATION_ID_ENV, ALAN_CODE_PROXY_PATH, ALAN_CODE_WEBSEARCH_PATH, ALAN_CODE_CATALOG_PATH, ALAN_CODE_CHUNK_TIMEOUT_MS, CATALOG_TIMEOUT_MS, MAX_CATALOG_BYTES, ACTIVATION_WAIT_MS, ACTIVATION_POLL_MS, CatalogResponseError, ALAN_CODE_ENGINE_PATH_ENV, ALAN_CODE_ENGINE_COMMAND, ALAN_CODE_ENGINE_NAME, WINDOWS_RUNNABLE_EXTENSION, ALAN_CODE_ENGINE_PLUGIN_VERSION, ALAN_CODE_TOOL_NAMING_PROMPT;
|
|
30669
31108
|
var init_alan_code = __esm({
|
|
30670
31109
|
"../agent-core/dist/providers/alan-code.js"() {
|
|
30671
31110
|
"use strict";
|
|
@@ -30691,6 +31130,7 @@ var init_alan_code = __esm({
|
|
|
30691
31130
|
ALAN_CODE_PROXY_PATH = "/public/harness/v1";
|
|
30692
31131
|
ALAN_CODE_WEBSEARCH_PATH = "/public/harness/v1/websearch";
|
|
30693
31132
|
ALAN_CODE_CATALOG_PATH = "/public/harness/models";
|
|
31133
|
+
ALAN_CODE_CHUNK_TIMEOUT_MS = 18e4;
|
|
30694
31134
|
CATALOG_TIMEOUT_MS = 5e3;
|
|
30695
31135
|
MAX_CATALOG_BYTES = 1024 * 1024;
|
|
30696
31136
|
ACTIVATION_WAIT_MS = 1e4;
|
|
@@ -30732,7 +31172,7 @@ var require_identity = __commonJS({
|
|
|
30732
31172
|
var isDocument = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === DOC;
|
|
30733
31173
|
var isMap = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === MAP;
|
|
30734
31174
|
var isPair = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === PAIR;
|
|
30735
|
-
var
|
|
31175
|
+
var isScalar2 = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === SCALAR;
|
|
30736
31176
|
var isSeq = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === SEQ;
|
|
30737
31177
|
function isCollection(node2) {
|
|
30738
31178
|
if (node2 && typeof node2 === "object")
|
|
@@ -30754,7 +31194,7 @@ var require_identity = __commonJS({
|
|
|
30754
31194
|
}
|
|
30755
31195
|
return false;
|
|
30756
31196
|
}
|
|
30757
|
-
var hasAnchor = (node2) => (
|
|
31197
|
+
var hasAnchor = (node2) => (isScalar2(node2) || isCollection(node2)) && !!node2.anchor;
|
|
30758
31198
|
exports2.ALIAS = ALIAS;
|
|
30759
31199
|
exports2.DOC = DOC;
|
|
30760
31200
|
exports2.MAP = MAP;
|
|
@@ -30769,7 +31209,7 @@ var require_identity = __commonJS({
|
|
|
30769
31209
|
exports2.isMap = isMap;
|
|
30770
31210
|
exports2.isNode = isNode;
|
|
30771
31211
|
exports2.isPair = isPair;
|
|
30772
|
-
exports2.isScalar =
|
|
31212
|
+
exports2.isScalar = isScalar2;
|
|
30773
31213
|
exports2.isSeq = isSeq;
|
|
30774
31214
|
}
|
|
30775
31215
|
});
|
|
@@ -35125,13 +35565,13 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
35125
35565
|
"../../node_modules/yaml/dist/compose/resolve-block-scalar.js"(exports2) {
|
|
35126
35566
|
"use strict";
|
|
35127
35567
|
var Scalar = require_Scalar();
|
|
35128
|
-
function resolveBlockScalar(ctx,
|
|
35129
|
-
const start =
|
|
35130
|
-
const header = parseBlockScalarHeader(
|
|
35568
|
+
function resolveBlockScalar(ctx, scalar2, onError) {
|
|
35569
|
+
const start = scalar2.offset;
|
|
35570
|
+
const header = parseBlockScalarHeader(scalar2, ctx.options.strict, onError);
|
|
35131
35571
|
if (!header)
|
|
35132
35572
|
return { value: "", type: null, comment: "", range: [start, start, start] };
|
|
35133
35573
|
const type = header.mode === ">" ? Scalar.Scalar.BLOCK_FOLDED : Scalar.Scalar.BLOCK_LITERAL;
|
|
35134
|
-
const lines =
|
|
35574
|
+
const lines = scalar2.source ? splitLines(scalar2.source) : [];
|
|
35135
35575
|
let chompStart = lines.length;
|
|
35136
35576
|
for (let i = lines.length - 1; i >= 0; --i) {
|
|
35137
35577
|
const content = lines[i][1];
|
|
@@ -35143,12 +35583,12 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
35143
35583
|
if (chompStart === 0) {
|
|
35144
35584
|
const value2 = header.chomp === "+" && lines.length > 0 ? "\n".repeat(Math.max(1, lines.length - 1)) : "";
|
|
35145
35585
|
let end2 = start + header.length;
|
|
35146
|
-
if (
|
|
35147
|
-
end2 +=
|
|
35586
|
+
if (scalar2.source)
|
|
35587
|
+
end2 += scalar2.source.length;
|
|
35148
35588
|
return { value: value2, type, comment: header.comment, range: [start, end2, end2] };
|
|
35149
35589
|
}
|
|
35150
|
-
let trimIndent =
|
|
35151
|
-
let offset =
|
|
35590
|
+
let trimIndent = scalar2.indent + header.indent;
|
|
35591
|
+
let offset = scalar2.offset + header.length;
|
|
35152
35592
|
let contentStart = 0;
|
|
35153
35593
|
for (let i = 0; i < chompStart; ++i) {
|
|
35154
35594
|
const [indent, content] = lines[i];
|
|
@@ -35226,7 +35666,7 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
35226
35666
|
default:
|
|
35227
35667
|
value += "\n";
|
|
35228
35668
|
}
|
|
35229
|
-
const end = start + header.length +
|
|
35669
|
+
const end = start + header.length + scalar2.source.length;
|
|
35230
35670
|
return { value, type, comment: header.comment, range: [start, end, end] };
|
|
35231
35671
|
}
|
|
35232
35672
|
function parseBlockScalarHeader({ offset, props }, strict, onError) {
|
|
@@ -35309,8 +35749,8 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
35309
35749
|
"use strict";
|
|
35310
35750
|
var Scalar = require_Scalar();
|
|
35311
35751
|
var resolveEnd = require_resolve_end();
|
|
35312
|
-
function resolveFlowScalar(
|
|
35313
|
-
const { offset, type, source, end } =
|
|
35752
|
+
function resolveFlowScalar(scalar2, strict, onError) {
|
|
35753
|
+
const { offset, type, source, end } = scalar2;
|
|
35314
35754
|
let _type;
|
|
35315
35755
|
let value;
|
|
35316
35756
|
const _onError = (rel, code, msg) => onError(offset + rel, code, msg);
|
|
@@ -35329,7 +35769,7 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
35329
35769
|
break;
|
|
35330
35770
|
/* istanbul ignore next should not happen */
|
|
35331
35771
|
default:
|
|
35332
|
-
onError(
|
|
35772
|
+
onError(scalar2, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${type}`);
|
|
35333
35773
|
return {
|
|
35334
35774
|
value: "",
|
|
35335
35775
|
type: null,
|
|
@@ -35543,26 +35983,26 @@ var require_compose_scalar = __commonJS({
|
|
|
35543
35983
|
tag = findScalarTagByTest(ctx, value, token, onError);
|
|
35544
35984
|
else
|
|
35545
35985
|
tag = ctx.schema[identity.SCALAR];
|
|
35546
|
-
let
|
|
35986
|
+
let scalar2;
|
|
35547
35987
|
try {
|
|
35548
35988
|
const res = tag.resolve(value, (msg) => onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg), ctx.options);
|
|
35549
|
-
|
|
35989
|
+
scalar2 = identity.isScalar(res) ? res : new Scalar.Scalar(res);
|
|
35550
35990
|
} catch (error61) {
|
|
35551
35991
|
const msg = error61 instanceof Error ? error61.message : String(error61);
|
|
35552
35992
|
onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg);
|
|
35553
|
-
|
|
35993
|
+
scalar2 = new Scalar.Scalar(value);
|
|
35554
35994
|
}
|
|
35555
|
-
|
|
35556
|
-
|
|
35995
|
+
scalar2.range = range;
|
|
35996
|
+
scalar2.source = value;
|
|
35557
35997
|
if (type)
|
|
35558
|
-
|
|
35998
|
+
scalar2.type = type;
|
|
35559
35999
|
if (tagName)
|
|
35560
|
-
|
|
36000
|
+
scalar2.tag = tagName;
|
|
35561
36001
|
if (tag.format)
|
|
35562
|
-
|
|
36002
|
+
scalar2.format = tag.format;
|
|
35563
36003
|
if (comment)
|
|
35564
|
-
|
|
35565
|
-
return
|
|
36004
|
+
scalar2.comment = comment;
|
|
36005
|
+
return scalar2;
|
|
35566
36006
|
}
|
|
35567
36007
|
function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
35568
36008
|
if (tagName === "!")
|
|
@@ -36311,7 +36751,7 @@ var require_cst = __commonJS({
|
|
|
36311
36751
|
var FLOW_END = "";
|
|
36312
36752
|
var SCALAR = "";
|
|
36313
36753
|
var isCollection = (token) => !!token && "items" in token;
|
|
36314
|
-
var
|
|
36754
|
+
var isScalar2 = (token) => !!token && (token.type === "scalar" || token.type === "single-quoted-scalar" || token.type === "double-quoted-scalar" || token.type === "block-scalar");
|
|
36315
36755
|
function prettyToken(token) {
|
|
36316
36756
|
switch (token) {
|
|
36317
36757
|
case BOM:
|
|
@@ -36395,7 +36835,7 @@ var require_cst = __commonJS({
|
|
|
36395
36835
|
exports2.FLOW_END = FLOW_END;
|
|
36396
36836
|
exports2.SCALAR = SCALAR;
|
|
36397
36837
|
exports2.isCollection = isCollection;
|
|
36398
|
-
exports2.isScalar =
|
|
36838
|
+
exports2.isScalar = isScalar2;
|
|
36399
36839
|
exports2.prettyToken = prettyToken;
|
|
36400
36840
|
exports2.tokenType = tokenType;
|
|
36401
36841
|
}
|
|
@@ -37390,37 +37830,37 @@ var require_parser = __commonJS({
|
|
|
37390
37830
|
};
|
|
37391
37831
|
}
|
|
37392
37832
|
}
|
|
37393
|
-
*scalar(
|
|
37833
|
+
*scalar(scalar2) {
|
|
37394
37834
|
if (this.type === "map-value-ind") {
|
|
37395
37835
|
const prev = getPrevProps(this.peek(2));
|
|
37396
37836
|
const start = getFirstKeyStartProps(prev);
|
|
37397
37837
|
let sep4;
|
|
37398
|
-
if (
|
|
37399
|
-
sep4 =
|
|
37838
|
+
if (scalar2.end) {
|
|
37839
|
+
sep4 = scalar2.end;
|
|
37400
37840
|
sep4.push(this.sourceToken);
|
|
37401
|
-
delete
|
|
37841
|
+
delete scalar2.end;
|
|
37402
37842
|
} else
|
|
37403
37843
|
sep4 = [this.sourceToken];
|
|
37404
37844
|
const map2 = {
|
|
37405
37845
|
type: "block-map",
|
|
37406
|
-
offset:
|
|
37407
|
-
indent:
|
|
37408
|
-
items: [{ start, key:
|
|
37846
|
+
offset: scalar2.offset,
|
|
37847
|
+
indent: scalar2.indent,
|
|
37848
|
+
items: [{ start, key: scalar2, sep: sep4 }]
|
|
37409
37849
|
};
|
|
37410
37850
|
this.onKeyLine = true;
|
|
37411
37851
|
this.stack[this.stack.length - 1] = map2;
|
|
37412
37852
|
} else
|
|
37413
|
-
yield* this.lineEnd(
|
|
37853
|
+
yield* this.lineEnd(scalar2);
|
|
37414
37854
|
}
|
|
37415
|
-
*blockScalar(
|
|
37855
|
+
*blockScalar(scalar2) {
|
|
37416
37856
|
switch (this.type) {
|
|
37417
37857
|
case "space":
|
|
37418
37858
|
case "comment":
|
|
37419
37859
|
case "newline":
|
|
37420
|
-
|
|
37860
|
+
scalar2.props.push(this.sourceToken);
|
|
37421
37861
|
return;
|
|
37422
37862
|
case "scalar":
|
|
37423
|
-
|
|
37863
|
+
scalar2.source = this.source;
|
|
37424
37864
|
this.atNewLine = true;
|
|
37425
37865
|
this.indent = 0;
|
|
37426
37866
|
if (this.onNewLine) {
|
|
@@ -38048,10 +38488,10 @@ var require_dist = __commonJS({
|
|
|
38048
38488
|
var init_dist = __esm({
|
|
38049
38489
|
"../agent-core/dist/index.js"() {
|
|
38050
38490
|
"use strict";
|
|
38051
|
-
|
|
38491
|
+
init_chunk_A2TG6ROT();
|
|
38052
38492
|
init_chunk_XC5676SG();
|
|
38053
|
-
|
|
38054
|
-
|
|
38493
|
+
init_chunk_ZCTKXKYY();
|
|
38494
|
+
init_chunk_XE7BX6YP();
|
|
38055
38495
|
init_chunk_YXWJW7I5();
|
|
38056
38496
|
}
|
|
38057
38497
|
});
|
|
@@ -38276,8 +38716,8 @@ function refusal(error61, displayName) {
|
|
|
38276
38716
|
return failure2("failed", String(error61));
|
|
38277
38717
|
}
|
|
38278
38718
|
function toolResultText(update) {
|
|
38279
|
-
const texts = (update.content ?? []).flatMap((
|
|
38280
|
-
const text2 = asString(asRecord(asRecord(
|
|
38719
|
+
const texts = (update.content ?? []).flatMap((block2) => {
|
|
38720
|
+
const text2 = asString(asRecord(asRecord(block2)?.content)?.text);
|
|
38281
38721
|
return text2 ? [text2] : [];
|
|
38282
38722
|
});
|
|
38283
38723
|
if (typeof update.rawOutput === "string" && update.rawOutput) texts.push(update.rawOutput);
|
|
@@ -38373,11 +38813,11 @@ function isStopReason(value) {
|
|
|
38373
38813
|
function v2ToolContent(content) {
|
|
38374
38814
|
if (!Array.isArray(content)) return void 0;
|
|
38375
38815
|
return content.map((item) => {
|
|
38376
|
-
const
|
|
38377
|
-
if (!
|
|
38378
|
-
const path = asString(
|
|
38379
|
-
const oldText = typeof
|
|
38380
|
-
const newText = typeof
|
|
38816
|
+
const block2 = asRecord(item);
|
|
38817
|
+
if (!block2 || asString(block2.type) !== "diff" || asRecord(block2.diff)) return item;
|
|
38818
|
+
const path = asString(block2.path);
|
|
38819
|
+
const oldText = typeof block2.oldText === "string" ? block2.oldText : null;
|
|
38820
|
+
const newText = typeof block2.newText === "string" ? block2.newText : null;
|
|
38381
38821
|
const operation = oldText === null ? "add" : newText === null ? "delete" : "modify";
|
|
38382
38822
|
return {
|
|
38383
38823
|
type: "diff",
|
|
@@ -38795,12 +39235,12 @@ var import_promises24, import_path9, import_crypto13, import_promises25, CURSOR_
|
|
|
38795
39235
|
var init_acp3 = __esm({
|
|
38796
39236
|
"../agent-core/dist/providers/acp.js"() {
|
|
38797
39237
|
"use strict";
|
|
38798
|
-
|
|
39238
|
+
init_chunk_A2TG6ROT();
|
|
38799
39239
|
init_chunk_XC5676SG();
|
|
38800
|
-
|
|
39240
|
+
init_chunk_ZCTKXKYY();
|
|
38801
39241
|
init_chunk_J2KTV5FP();
|
|
38802
|
-
|
|
38803
|
-
|
|
39242
|
+
init_chunk_XE7BX6YP();
|
|
39243
|
+
init_chunk_GI3ZGXTY();
|
|
38804
39244
|
init_chunk_YXWJW7I5();
|
|
38805
39245
|
import_promises24 = require("fs/promises");
|
|
38806
39246
|
import_path9 = require("path");
|
|
@@ -39138,6 +39578,9 @@ var init_acp3 = __esm({
|
|
|
39138
39578
|
get pid() {
|
|
39139
39579
|
return this.#host.pid;
|
|
39140
39580
|
}
|
|
39581
|
+
get lastOutputAt() {
|
|
39582
|
+
return this.#host.lastOutputAt;
|
|
39583
|
+
}
|
|
39141
39584
|
get exited() {
|
|
39142
39585
|
return this.#host.exited;
|
|
39143
39586
|
}
|
|
@@ -39612,7 +40055,7 @@ var init_acp3 = __esm({
|
|
|
39612
40055
|
var init_classify = __esm({
|
|
39613
40056
|
"../agent-core/dist/classify.js"() {
|
|
39614
40057
|
"use strict";
|
|
39615
|
-
|
|
40058
|
+
init_chunk_ZCTKXKYY();
|
|
39616
40059
|
init_chunk_YXWJW7I5();
|
|
39617
40060
|
}
|
|
39618
40061
|
});
|
|
@@ -39627,6 +40070,68 @@ var init_driver = __esm({
|
|
|
39627
40070
|
});
|
|
39628
40071
|
|
|
39629
40072
|
// src/holder/drivers/persistent.ts
|
|
40073
|
+
function sessionContextFor(opened, inputs) {
|
|
40074
|
+
return opened.fresh ? inputs.agentContext?.full : inputs.agentContext?.update;
|
|
40075
|
+
}
|
|
40076
|
+
function autoRetryDelayMs(attempt) {
|
|
40077
|
+
return AUTO_RETRY_BASE_DELAY_MS * 2 ** (attempt - 1);
|
|
40078
|
+
}
|
|
40079
|
+
function isAutoRecoverable(error61) {
|
|
40080
|
+
return error61.recoveryClass === "auto_recovering";
|
|
40081
|
+
}
|
|
40082
|
+
function countsAsProviderWork(update) {
|
|
40083
|
+
return !NON_WORK_UPDATE_KINDS.has(update.sessionUpdate);
|
|
40084
|
+
}
|
|
40085
|
+
function silentTurnError(displayName, timeoutMs) {
|
|
40086
|
+
return {
|
|
40087
|
+
...specForErrorKind("provider_timeout"),
|
|
40088
|
+
message: `${displayName} printed nothing for ${Math.round(timeoutMs / 1e3)}s after the message was sent and was stopped. Send your message again.`
|
|
40089
|
+
};
|
|
40090
|
+
}
|
|
40091
|
+
async function sendWithFirstOutputDeadline(deadline, send2) {
|
|
40092
|
+
const { session, clock, timeoutMs } = deadline;
|
|
40093
|
+
const startedAt = clock.monotonic();
|
|
40094
|
+
const stop = new AbortController();
|
|
40095
|
+
const state = { expired: false };
|
|
40096
|
+
const silent = () => !deadline.heard() && !deadline.signal.aborted && (session.lastOutputAt === void 0 || session.lastOutputAt <= startedAt);
|
|
40097
|
+
void clock.sleep(timeoutMs, stop.signal).then(() => {
|
|
40098
|
+
if (clock.monotonic() - startedAt < timeoutMs || !silent()) return;
|
|
40099
|
+
state.expired = true;
|
|
40100
|
+
deadline.onExpired();
|
|
40101
|
+
void session.cancel();
|
|
40102
|
+
}).catch(() => void 0);
|
|
40103
|
+
try {
|
|
40104
|
+
const result = await send2();
|
|
40105
|
+
if (!state.expired) return result;
|
|
40106
|
+
await session.suspend().catch(() => void 0);
|
|
40107
|
+
return {
|
|
40108
|
+
...result,
|
|
40109
|
+
outcome: { status: "failed", error: silentTurnError(deadline.displayName, timeoutMs) }
|
|
40110
|
+
};
|
|
40111
|
+
} finally {
|
|
40112
|
+
stop.abort();
|
|
40113
|
+
}
|
|
40114
|
+
}
|
|
40115
|
+
async function sendTurnWithRetry(options) {
|
|
40116
|
+
let result = await options.send();
|
|
40117
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
40118
|
+
const failure5 = result.outcome.status === "failed" ? result.outcome.error : void 0;
|
|
40119
|
+
if (failure5 === void 0 || !isAutoRecoverable(failure5) || options.sawWork() || options.signal.aborted || attempt > MAX_AUTO_RETRIES) {
|
|
40120
|
+
return result;
|
|
40121
|
+
}
|
|
40122
|
+
options.log.info("holder.turn_auto_retry", {
|
|
40123
|
+
harness: options.harness,
|
|
40124
|
+
runId: options.runId,
|
|
40125
|
+
attempt,
|
|
40126
|
+
errorKind: failure5.errorKind
|
|
40127
|
+
});
|
|
40128
|
+
options.reportRetry(attempt);
|
|
40129
|
+
options.beginRetry();
|
|
40130
|
+
await options.clock.sleep(autoRetryDelayMs(attempt), options.signal).catch(() => void 0);
|
|
40131
|
+
if (options.signal.aborted) return { ...result, outcome: { status: "cancelled" } };
|
|
40132
|
+
result = await options.send();
|
|
40133
|
+
}
|
|
40134
|
+
}
|
|
39630
40135
|
function errorMessage(error61) {
|
|
39631
40136
|
return error61 instanceof Error ? error61.message : String(error61);
|
|
39632
40137
|
}
|
|
@@ -39682,14 +40187,14 @@ function createPersistentDriver(provider4, options) {
|
|
|
39682
40187
|
const resumeNotice = (spec, session, sink) => {
|
|
39683
40188
|
if (spec.resumeFallbackContext) {
|
|
39684
40189
|
log.info("holder.session_resume_fallback", { harness: provider4.harness, runId: spec.runId });
|
|
39685
|
-
return { session, contextPrefix: spec.resumeFallbackContext };
|
|
40190
|
+
return { session, fresh: true, contextPrefix: spec.resumeFallbackContext };
|
|
39686
40191
|
}
|
|
39687
40192
|
sink.onEvent({
|
|
39688
40193
|
seq: 0,
|
|
39689
40194
|
at: clock.now(),
|
|
39690
40195
|
update: noticeUpdate("warning", "session_resume_failed", RESUME_UNAVAILABLE)
|
|
39691
40196
|
});
|
|
39692
|
-
return { session };
|
|
40197
|
+
return { session, fresh: true };
|
|
39693
40198
|
};
|
|
39694
40199
|
const managedMcpAccess = async (signal) => {
|
|
39695
40200
|
const managed = options.managedMcp;
|
|
@@ -39700,7 +40205,7 @@ function createPersistentDriver(provider4, options) {
|
|
|
39700
40205
|
const ensureSession = async (spec, inputs, sink, managedMcp) => {
|
|
39701
40206
|
const wanted = provider4.plan(spec, inputs, void 0, managedMcp);
|
|
39702
40207
|
const reused = await reuseLive(spec, wanted.key);
|
|
39703
|
-
if (reused) return { session: reused };
|
|
40208
|
+
if (reused) return { session: reused, fresh: false };
|
|
39704
40209
|
const requested = live.providerSessionId ?? spec.providerSessionId;
|
|
39705
40210
|
const resumeId = requested !== void 0 && requested !== live.rejectedSessionId && provider4.canResume(wanted, requested) ? requested : void 0;
|
|
39706
40211
|
const planned = provider4.plan(spec, inputs, resumeId, managedMcp);
|
|
@@ -39719,7 +40224,7 @@ function createPersistentDriver(provider4, options) {
|
|
|
39719
40224
|
requested
|
|
39720
40225
|
});
|
|
39721
40226
|
const resumed = resumeId !== void 0 && !opened.resumeFailed;
|
|
39722
|
-
if (requested === void 0 || resumed) return { session: opened.session };
|
|
40227
|
+
if (requested === void 0 || resumed) return { session: opened.session, fresh: !resumed };
|
|
39723
40228
|
return resumeNotice(spec, opened.session, sink);
|
|
39724
40229
|
};
|
|
39725
40230
|
const runOnSession = async (opened, spec, sink, signal, inputs) => {
|
|
@@ -39727,7 +40232,16 @@ function createPersistentDriver(provider4, options) {
|
|
|
39727
40232
|
try {
|
|
39728
40233
|
const { session } = opened;
|
|
39729
40234
|
const seq = { next: 1 };
|
|
40235
|
+
let sawWork = false;
|
|
40236
|
+
let heardFromProvider = false;
|
|
40237
|
+
let announcedSpawn = false;
|
|
40238
|
+
const announceSpawn = (pid) => {
|
|
40239
|
+
if (announcedSpawn) return;
|
|
40240
|
+
announcedSpawn = true;
|
|
40241
|
+
sink.onSpawned(pid);
|
|
40242
|
+
};
|
|
39730
40243
|
const record2 = (update) => {
|
|
40244
|
+
if (countsAsProviderWork(update)) sawWork = true;
|
|
39731
40245
|
sink.onEvent({
|
|
39732
40246
|
seq: seq.next++,
|
|
39733
40247
|
at: clock.now(),
|
|
@@ -39749,13 +40263,16 @@ function createPersistentDriver(provider4, options) {
|
|
|
39749
40263
|
if (!("turnId" in event) || event.turnId !== spec.runId) return;
|
|
39750
40264
|
switch (event.type) {
|
|
39751
40265
|
case "spawned":
|
|
39752
|
-
|
|
40266
|
+
announceSpawn(event.pid);
|
|
39753
40267
|
return;
|
|
39754
40268
|
case "awaiting_input":
|
|
40269
|
+
heardFromProvider = true;
|
|
40270
|
+
sawWork = true;
|
|
39755
40271
|
for (const toolCallId of event.toolCallIds) turn.waiting.add(toolCallId);
|
|
39756
40272
|
record2(awaitingUpdate(turn.waiting));
|
|
39757
40273
|
return;
|
|
39758
40274
|
case "update":
|
|
40275
|
+
heardFromProvider = true;
|
|
39759
40276
|
recordWithMedia(event.update);
|
|
39760
40277
|
return;
|
|
39761
40278
|
default:
|
|
@@ -39765,16 +40282,53 @@ function createPersistentDriver(provider4, options) {
|
|
|
39765
40282
|
const _events = __using(_stack, session.onEvent(forward));
|
|
39766
40283
|
live.turn = turn;
|
|
39767
40284
|
record2({ sessionUpdate: "state_update", state: "running" });
|
|
39768
|
-
if (session.pid !== void 0)
|
|
40285
|
+
if (session.pid !== void 0) announceSpawn(session.pid);
|
|
39769
40286
|
const onAbort = () => {
|
|
39770
40287
|
void session.cancel();
|
|
39771
40288
|
};
|
|
39772
40289
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
39773
40290
|
try {
|
|
39774
|
-
const contextPrefix = [inputs
|
|
40291
|
+
const contextPrefix = [sessionContextFor(opened, inputs), opened.contextPrefix].filter((part) => part !== void 0).join("\n\n");
|
|
39775
40292
|
const input2 = await provider4.turnInput(spec, inputs, contextPrefix || void 0);
|
|
39776
40293
|
if (signal.aborted) return { outcome: "aborted" };
|
|
39777
|
-
const
|
|
40294
|
+
const timeoutMs = options.firstOutputTimeoutMs ?? FIRST_OUTPUT_TIMEOUT_MS;
|
|
40295
|
+
const deadline = {
|
|
40296
|
+
session,
|
|
40297
|
+
displayName: provider4.displayName,
|
|
40298
|
+
clock,
|
|
40299
|
+
signal,
|
|
40300
|
+
timeoutMs,
|
|
40301
|
+
heard: () => heardFromProvider,
|
|
40302
|
+
onExpired: () => log.warn("holder.first_output_timeout", {
|
|
40303
|
+
harness: provider4.harness,
|
|
40304
|
+
runId: spec.runId,
|
|
40305
|
+
pid: session.pid,
|
|
40306
|
+
timeoutMs
|
|
40307
|
+
})
|
|
40308
|
+
};
|
|
40309
|
+
const result = await sendWithFirstOutputDeadline(
|
|
40310
|
+
deadline,
|
|
40311
|
+
() => sendTurnWithRetry({
|
|
40312
|
+
harness: provider4.harness,
|
|
40313
|
+
runId: spec.runId,
|
|
40314
|
+
log,
|
|
40315
|
+
clock,
|
|
40316
|
+
signal,
|
|
40317
|
+
send: () => session.sendTurn(input2),
|
|
40318
|
+
sawWork: () => sawWork,
|
|
40319
|
+
beginRetry: () => {
|
|
40320
|
+
sawWork = false;
|
|
40321
|
+
turn.waiting.clear();
|
|
40322
|
+
},
|
|
40323
|
+
reportRetry: (attempt) => record2(
|
|
40324
|
+
noticeUpdate(
|
|
40325
|
+
"info",
|
|
40326
|
+
"provider_retry",
|
|
40327
|
+
`Provider error \u2014 retrying (attempt ${attempt + 1} of ${MAX_AUTO_RETRIES + 1}).`
|
|
40328
|
+
)
|
|
40329
|
+
)
|
|
40330
|
+
})
|
|
40331
|
+
);
|
|
39778
40332
|
live.providerSessionId = result.providerSessionId ?? live.providerSessionId;
|
|
39779
40333
|
if (result.outcome.status === "failed" && result.outcome.error.errorKind === "history_rejected") {
|
|
39780
40334
|
await forgetRejectedSession(session);
|
|
@@ -39881,7 +40435,7 @@ function awaitingUpdate(waiting) {
|
|
|
39881
40435
|
_meta: { [AWAITING_TOOL_CALLS_META]: [...waiting] }
|
|
39882
40436
|
};
|
|
39883
40437
|
}
|
|
39884
|
-
var RESUME_UNAVAILABLE;
|
|
40438
|
+
var RESUME_UNAVAILABLE, MAX_AUTO_RETRIES, AUTO_RETRY_BASE_DELAY_MS, NON_WORK_UPDATE_KINDS, FIRST_OUTPUT_TIMEOUT_MS;
|
|
39885
40439
|
var init_persistent = __esm({
|
|
39886
40440
|
"src/holder/drivers/persistent.ts"() {
|
|
39887
40441
|
"use strict";
|
|
@@ -39890,6 +40444,21 @@ var init_persistent = __esm({
|
|
|
39890
40444
|
init_classify();
|
|
39891
40445
|
init_driver();
|
|
39892
40446
|
RESUME_UNAVAILABLE = "The previous session could not be resumed on this machine, so a fresh session was started.";
|
|
40447
|
+
MAX_AUTO_RETRIES = 2;
|
|
40448
|
+
AUTO_RETRY_BASE_DELAY_MS = 1e3;
|
|
40449
|
+
NON_WORK_UPDATE_KINDS = /* @__PURE__ */ new Set([
|
|
40450
|
+
"notice",
|
|
40451
|
+
"usage_update",
|
|
40452
|
+
"state_update",
|
|
40453
|
+
"session_info_update",
|
|
40454
|
+
"available_commands_update",
|
|
40455
|
+
"config_option_update",
|
|
40456
|
+
"user_message",
|
|
40457
|
+
"user_message_chunk",
|
|
40458
|
+
"_alan/log",
|
|
40459
|
+
"_alan/thinking_tokens"
|
|
40460
|
+
]);
|
|
40461
|
+
FIRST_OUTPUT_TIMEOUT_MS = 3e5;
|
|
39893
40462
|
}
|
|
39894
40463
|
});
|
|
39895
40464
|
|
|
@@ -39952,8 +40521,8 @@ var init_acp4 = __esm({
|
|
|
39952
40521
|
});
|
|
39953
40522
|
|
|
39954
40523
|
// ../agent-core/dist/providers/opencode.js
|
|
39955
|
-
function parseSseBlock(
|
|
39956
|
-
const data =
|
|
40524
|
+
function parseSseBlock(block2) {
|
|
40525
|
+
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");
|
|
39957
40526
|
if (!data) return void 0;
|
|
39958
40527
|
let parsed;
|
|
39959
40528
|
try {
|
|
@@ -40528,16 +41097,16 @@ function openCodeTurnInput(run, context) {
|
|
|
40528
41097
|
...images.length ? { imagePaths: images.map((image) => image.path) } : {}
|
|
40529
41098
|
};
|
|
40530
41099
|
}
|
|
40531
|
-
var import_http4, import_crypto14, import_promises26, import_path10, import_path11, import_url2, import_crypto15, IDLE_SOCKET_MS2, 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_OPERATIONS, 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;
|
|
41100
|
+
var import_http4, import_crypto14, import_promises26, import_path10, import_path11, import_url2, import_crypto15, IDLE_SOCKET_MS2, 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_OPERATIONS, PartReader, NOTHING, NON_INTERACTIVE_PERMISSIONS, CONTENT_FILTER_FINISHES, TRUNCATED_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;
|
|
40532
41101
|
var init_opencode = __esm({
|
|
40533
41102
|
"../agent-core/dist/providers/opencode.js"() {
|
|
40534
41103
|
"use strict";
|
|
40535
|
-
|
|
41104
|
+
init_chunk_A2TG6ROT();
|
|
40536
41105
|
init_chunk_XC5676SG();
|
|
40537
|
-
|
|
41106
|
+
init_chunk_ZCTKXKYY();
|
|
40538
41107
|
init_chunk_J2KTV5FP();
|
|
40539
|
-
|
|
40540
|
-
|
|
41108
|
+
init_chunk_XE7BX6YP();
|
|
41109
|
+
init_chunk_GI3ZGXTY();
|
|
40541
41110
|
init_chunk_YXWJW7I5();
|
|
40542
41111
|
import_http4 = require("http");
|
|
40543
41112
|
init_runtime_v2();
|
|
@@ -41014,6 +41583,7 @@ var init_opencode = __esm({
|
|
|
41014
41583
|
"plan_exit"
|
|
41015
41584
|
]);
|
|
41016
41585
|
CONTENT_FILTER_FINISHES = /* @__PURE__ */ new Set(["content-filter", "content_filter"]);
|
|
41586
|
+
TRUNCATED_FINISHES = /* @__PURE__ */ new Set(["unknown", "error"]);
|
|
41017
41587
|
OUTPUT_PARTS = /* @__PURE__ */ new Set(["text", "reasoning", "thinking", "tool"]);
|
|
41018
41588
|
OpenCodeTurn = class {
|
|
41019
41589
|
#root;
|
|
@@ -41228,6 +41798,15 @@ var init_opencode = __esm({
|
|
|
41228
41798
|
}
|
|
41229
41799
|
};
|
|
41230
41800
|
}
|
|
41801
|
+
if (this.#finish && TRUNCATED_FINISHES.has(this.#finish)) {
|
|
41802
|
+
return {
|
|
41803
|
+
status: "failed",
|
|
41804
|
+
error: {
|
|
41805
|
+
...specForErrorKind("provider_error"),
|
|
41806
|
+
message: "The model's response stream ended before the turn finished. Send your message again to continue."
|
|
41807
|
+
}
|
|
41808
|
+
};
|
|
41809
|
+
}
|
|
41231
41810
|
if (this.#finish && this.#outputParts.size === 0) {
|
|
41232
41811
|
return {
|
|
41233
41812
|
status: "failed",
|
|
@@ -41351,6 +41930,9 @@ var init_opencode = __esm({
|
|
|
41351
41930
|
get pid() {
|
|
41352
41931
|
return this.#host.pid;
|
|
41353
41932
|
}
|
|
41933
|
+
get lastOutputAt() {
|
|
41934
|
+
return this.#host.lastOutputAt;
|
|
41935
|
+
}
|
|
41354
41936
|
get exited() {
|
|
41355
41937
|
return this.#host.exited;
|
|
41356
41938
|
}
|
|
@@ -41567,6 +42149,7 @@ var init_opencode = __esm({
|
|
|
41567
42149
|
const info = asRecord(last?.info);
|
|
41568
42150
|
if (asString(info?.role) !== "assistant" || this.#current !== active) return;
|
|
41569
42151
|
if (asFiniteNumber(asRecord(info?.time)?.completed) === void 0) return;
|
|
42152
|
+
if (asString(info?.finish) === "tool-calls") return;
|
|
41570
42153
|
if (active.earlierUserMessages.has(asString(info?.parentID))) return;
|
|
41571
42154
|
const parts22 = asArray(last?.parts).flatMap((part) => {
|
|
41572
42155
|
const record2 = asRecord(part);
|
|
@@ -42093,7 +42676,7 @@ function droidToolCall(toolUse) {
|
|
|
42093
42676
|
function droidResultText(result) {
|
|
42094
42677
|
const blocks = asArray(result.content);
|
|
42095
42678
|
if (blocks.length) {
|
|
42096
|
-
return blocks.map((
|
|
42679
|
+
return blocks.map((block2) => asString(asRecord(block2)?.text)).filter(Boolean).join("\n");
|
|
42097
42680
|
}
|
|
42098
42681
|
const value = result.value;
|
|
42099
42682
|
if (typeof value === "string") return value;
|
|
@@ -42352,12 +42935,12 @@ var import_crypto16, import_promises27, FACTORY_API_VERSION, FACTORY_PROTOCOL_VE
|
|
|
42352
42935
|
var init_droid = __esm({
|
|
42353
42936
|
"../agent-core/dist/providers/droid.js"() {
|
|
42354
42937
|
"use strict";
|
|
42355
|
-
|
|
42938
|
+
init_chunk_A2TG6ROT();
|
|
42356
42939
|
init_chunk_XC5676SG();
|
|
42357
|
-
|
|
42940
|
+
init_chunk_ZCTKXKYY();
|
|
42358
42941
|
init_chunk_J2KTV5FP();
|
|
42359
|
-
|
|
42360
|
-
|
|
42942
|
+
init_chunk_XE7BX6YP();
|
|
42943
|
+
init_chunk_GI3ZGXTY();
|
|
42361
42944
|
init_chunk_YXWJW7I5();
|
|
42362
42945
|
init_runtime_v2();
|
|
42363
42946
|
import_crypto16 = require("crypto");
|
|
@@ -42543,6 +43126,9 @@ var init_droid = __esm({
|
|
|
42543
43126
|
get pid() {
|
|
42544
43127
|
return this.#host.pid;
|
|
42545
43128
|
}
|
|
43129
|
+
get lastOutputAt() {
|
|
43130
|
+
return this.#host.lastOutputAt;
|
|
43131
|
+
}
|
|
42546
43132
|
get exited() {
|
|
42547
43133
|
return this.#host.exited;
|
|
42548
43134
|
}
|
|
@@ -43459,11 +44045,11 @@ var init_antigravity = __esm({
|
|
|
43459
44045
|
"../agent-core/dist/providers/antigravity.js"() {
|
|
43460
44046
|
"use strict";
|
|
43461
44047
|
init_chunk_SBT5W7L4();
|
|
43462
|
-
|
|
44048
|
+
init_chunk_A2TG6ROT();
|
|
43463
44049
|
init_chunk_XC5676SG();
|
|
43464
|
-
|
|
43465
|
-
|
|
43466
|
-
|
|
44050
|
+
init_chunk_ZCTKXKYY();
|
|
44051
|
+
init_chunk_XE7BX6YP();
|
|
44052
|
+
init_chunk_GI3ZGXTY();
|
|
43467
44053
|
init_chunk_YXWJW7I5();
|
|
43468
44054
|
import_promises28 = require("fs/promises");
|
|
43469
44055
|
import_path12 = require("path");
|
|
@@ -44163,12 +44749,12 @@ var import_promises29, import_path15, import_crypto18, COMMAND_CODE_GRAMMAR_NAME
|
|
|
44163
44749
|
var init_command_code = __esm({
|
|
44164
44750
|
"../agent-core/dist/providers/command-code.js"() {
|
|
44165
44751
|
"use strict";
|
|
44166
|
-
|
|
44752
|
+
init_chunk_A2TG6ROT();
|
|
44167
44753
|
init_chunk_XC5676SG();
|
|
44168
|
-
|
|
44754
|
+
init_chunk_ZCTKXKYY();
|
|
44169
44755
|
init_chunk_J2KTV5FP();
|
|
44170
|
-
|
|
44171
|
-
|
|
44756
|
+
init_chunk_XE7BX6YP();
|
|
44757
|
+
init_chunk_GI3ZGXTY();
|
|
44172
44758
|
init_chunk_YXWJW7I5();
|
|
44173
44759
|
import_promises29 = require("fs/promises");
|
|
44174
44760
|
import_path15 = require("path");
|
|
@@ -45286,7 +45872,7 @@ async function assertValidBranch(git, repoRoot, branch, signal) {
|
|
|
45286
45872
|
var import_node_child_process = require("child_process");
|
|
45287
45873
|
|
|
45288
45874
|
// ../agent-core/dist/process.js
|
|
45289
|
-
|
|
45875
|
+
init_chunk_XE7BX6YP();
|
|
45290
45876
|
init_chunk_YXWJW7I5();
|
|
45291
45877
|
|
|
45292
45878
|
// src/capabilities/git/run-git.ts
|
|
@@ -46921,7 +47507,7 @@ function openRepositoryLocks(options) {
|
|
|
46921
47507
|
|
|
46922
47508
|
// src/cli/config.ts
|
|
46923
47509
|
var import_node_os7 = require("os");
|
|
46924
|
-
var
|
|
47510
|
+
var import_node_path33 = require("path");
|
|
46925
47511
|
init_zod();
|
|
46926
47512
|
|
|
46927
47513
|
// src/client/locate.ts
|
|
@@ -46942,9 +47528,9 @@ function defaultInstallDir({ platform, home, env }) {
|
|
|
46942
47528
|
|
|
46943
47529
|
// src/sessions/index.ts
|
|
46944
47530
|
var import_node_crypto16 = require("crypto");
|
|
46945
|
-
var
|
|
47531
|
+
var import_promises41 = require("fs/promises");
|
|
46946
47532
|
var import_node_os6 = require("os");
|
|
46947
|
-
var
|
|
47533
|
+
var import_node_path32 = require("path");
|
|
46948
47534
|
|
|
46949
47535
|
// src/holder/control-client.ts
|
|
46950
47536
|
var import_node_crypto12 = require("crypto");
|
|
@@ -47258,14 +47844,14 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
|
47258
47844
|
var import_node_crypto15 = require("crypto");
|
|
47259
47845
|
var import_node_fs11 = require("fs");
|
|
47260
47846
|
var import_node_net2 = require("net");
|
|
47261
|
-
var
|
|
47847
|
+
var import_node_path31 = require("path");
|
|
47262
47848
|
init_runtime_v2();
|
|
47263
47849
|
|
|
47264
47850
|
// src/holder/admission.ts
|
|
47265
47851
|
var import_node_fs9 = require("fs");
|
|
47266
|
-
var
|
|
47852
|
+
var import_promises37 = require("fs/promises");
|
|
47267
47853
|
var import_node_os5 = require("os");
|
|
47268
|
-
var
|
|
47854
|
+
var import_node_path27 = require("path");
|
|
47269
47855
|
init_constants();
|
|
47270
47856
|
|
|
47271
47857
|
// ../shared/dist/node/local-workspace.js
|
|
@@ -47348,29 +47934,79 @@ async function discoverRelocatedWorkspace(search) {
|
|
|
47348
47934
|
return matches[0] ?? null;
|
|
47349
47935
|
}
|
|
47350
47936
|
|
|
47937
|
+
// src/holder/agent-context.ts
|
|
47938
|
+
var import_promises33 = require("fs/promises");
|
|
47939
|
+
var import_node_path22 = require("path");
|
|
47940
|
+
|
|
47941
|
+
// ../agent-core/dist/prompt.js
|
|
47942
|
+
init_chunk_GI3ZGXTY();
|
|
47943
|
+
|
|
47944
|
+
// src/holder/agent-context.ts
|
|
47945
|
+
async function readText2(path) {
|
|
47946
|
+
return (0, import_promises33.readFile)(path, "utf8").then(
|
|
47947
|
+
(text2) => text2.trim(),
|
|
47948
|
+
() => null
|
|
47949
|
+
);
|
|
47950
|
+
}
|
|
47951
|
+
async function startCommandState(statusPath) {
|
|
47952
|
+
const [status, exit] = await Promise.all([readText2(statusPath), readText2(`${statusPath}.exit`)]);
|
|
47953
|
+
if (status === null || status === "started") return { state: "pending" };
|
|
47954
|
+
const failed = /^failed (\d+)$/.exec(status);
|
|
47955
|
+
if (failed) return { state: "failed", exitCode: Number(failed[1]) };
|
|
47956
|
+
if (exit === null) return { state: "running" };
|
|
47957
|
+
const code = Number(exit);
|
|
47958
|
+
return code === 0 ? { state: "exited_ok" } : { state: "failed", exitCode: code };
|
|
47959
|
+
}
|
|
47960
|
+
function createAgentContext(deps) {
|
|
47961
|
+
const statusPath = (0, import_node_path22.join)(deps.homeDir, ".alan", "start-commands.status");
|
|
47962
|
+
const logPath = (0, import_node_path22.join)(deps.homeDir, ".alan", "start-commands.log");
|
|
47963
|
+
return async (spec, problems) => {
|
|
47964
|
+
const file2 = (0, import_node_path22.join)(deps.dir, `${spec.conversationId}.json`);
|
|
47965
|
+
const saved = await readJsonFile(file2, agentContextSnapshotSchema);
|
|
47966
|
+
const known = saved.kind === "ok" ? saved.value : void 0;
|
|
47967
|
+
const hasEnvironment = (spec.agentContext ?? known)?.environment !== void 0;
|
|
47968
|
+
const start = hasEnvironment ? await startCommandState(statusPath) : void 0;
|
|
47969
|
+
const snapshot2 = agentContextSnapshot({
|
|
47970
|
+
spec,
|
|
47971
|
+
...spec.approvedWorkspacePaths?.[0] ? { workspaceRoot: spec.approvedWorkspacePaths[0] } : {},
|
|
47972
|
+
problems,
|
|
47973
|
+
...start ? { start } : {},
|
|
47974
|
+
startLogPath: logPath,
|
|
47975
|
+
...known ? { known } : {}
|
|
47976
|
+
});
|
|
47977
|
+
if (snapshot2 === null) return void 0;
|
|
47978
|
+
const rendered = renderAgentContext(snapshot2, known);
|
|
47979
|
+
return {
|
|
47980
|
+
full: rendered.full,
|
|
47981
|
+
...rendered.update ? { update: rendered.update } : {},
|
|
47982
|
+
save: () => writeJsonFileAtomic(file2, snapshot2)
|
|
47983
|
+
};
|
|
47984
|
+
};
|
|
47985
|
+
}
|
|
47986
|
+
|
|
47351
47987
|
// src/holder/checkout-refresh.ts
|
|
47352
|
-
var
|
|
47988
|
+
var import_node_path25 = require("path");
|
|
47353
47989
|
|
|
47354
47990
|
// src/holder/claim-once.ts
|
|
47355
47991
|
var import_node_crypto14 = require("crypto");
|
|
47356
|
-
var
|
|
47357
|
-
var
|
|
47992
|
+
var import_promises34 = require("fs/promises");
|
|
47993
|
+
var import_node_path23 = require("path");
|
|
47358
47994
|
async function claimOnce(dir, name) {
|
|
47359
47995
|
try {
|
|
47360
|
-
await (0,
|
|
47361
|
-
await (await (0,
|
|
47996
|
+
await (0, import_promises34.mkdir)(dir, { recursive: true, mode: 448 });
|
|
47997
|
+
await (await (0, import_promises34.open)((0, import_node_path23.join)(dir, name), "wx")).close();
|
|
47362
47998
|
return true;
|
|
47363
47999
|
} catch {
|
|
47364
48000
|
return false;
|
|
47365
48001
|
}
|
|
47366
48002
|
}
|
|
47367
48003
|
function claimFirstLease(freshnessDir, path) {
|
|
47368
|
-
return claimOnce((0,
|
|
48004
|
+
return claimOnce((0, import_node_path23.join)(freshnessDir, "leased"), (0, import_node_crypto14.createHash)("sha256").update(path).digest("hex"));
|
|
47369
48005
|
}
|
|
47370
48006
|
|
|
47371
48007
|
// src/holder/requested-checkout.ts
|
|
47372
|
-
var
|
|
47373
|
-
var
|
|
48008
|
+
var import_promises35 = require("fs/promises");
|
|
48009
|
+
var import_node_path24 = require("path");
|
|
47374
48010
|
var REMOTE2 = "origin";
|
|
47375
48011
|
var REASON_MAX_CHARS = 200;
|
|
47376
48012
|
function firstLine2(text2) {
|
|
@@ -47379,24 +48015,20 @@ function firstLine2(text2) {
|
|
|
47379
48015
|
function reasonOf(output2, command) {
|
|
47380
48016
|
return firstLine2(output2.stderr) || `git ${command} exited ${output2.exitCode}`;
|
|
47381
48017
|
}
|
|
47382
|
-
function noted(
|
|
47383
|
-
return {
|
|
47384
|
-
kind: "noted",
|
|
47385
|
-
line: `Note: ${checkout.path} ${situation}: ${reason}. ${action} before relying on its files.`
|
|
47386
|
-
};
|
|
48018
|
+
function noted(situation, reason, action) {
|
|
48019
|
+
return { kind: "noted", problem: `${situation}: ${reason}`, action };
|
|
47387
48020
|
}
|
|
47388
48021
|
function notSwitched(checkout, current, reason) {
|
|
47389
48022
|
const on = current ?? "a detached HEAD";
|
|
47390
48023
|
return noted(
|
|
47391
|
-
checkout,
|
|
47392
48024
|
`is on ${on}, not ${checkout.branch}, the branch picked for this chat`,
|
|
47393
48025
|
reason,
|
|
47394
48026
|
`Switch it to ${checkout.branch}`
|
|
47395
48027
|
);
|
|
47396
48028
|
}
|
|
47397
48029
|
async function clone2(checkout, deps, signal) {
|
|
47398
|
-
const parent = (0,
|
|
47399
|
-
await (0,
|
|
48030
|
+
const parent = (0, import_node_path24.dirname)(checkout.path);
|
|
48031
|
+
await (0, import_promises35.mkdir)(parent, { recursive: true });
|
|
47400
48032
|
await assertValidBranch(deps.git, parent, checkout.branch, signal);
|
|
47401
48033
|
const output2 = await deps.git.run(
|
|
47402
48034
|
{
|
|
@@ -47418,7 +48050,6 @@ async function clone2(checkout, deps, signal) {
|
|
|
47418
48050
|
);
|
|
47419
48051
|
if (output2.exitCode === 0) return { kind: "moved", how: "cloned" };
|
|
47420
48052
|
return noted(
|
|
47421
|
-
checkout,
|
|
47422
48053
|
`is missing, and cloning it on ${checkout.branch}, the branch picked for this chat, failed`,
|
|
47423
48054
|
reasonOf(output2, "clone"),
|
|
47424
48055
|
`Clone ${checkout.repoUrl} there`
|
|
@@ -47480,7 +48111,6 @@ async function moveOnto(checkout, git, tip, current) {
|
|
|
47480
48111
|
if (localHead === tip) return SWITCHED;
|
|
47481
48112
|
const merged = await git(["merge", "--quiet", "--ff-only", tip]);
|
|
47482
48113
|
return merged.exitCode === 0 ? SWITCHED : noted(
|
|
47483
|
-
checkout,
|
|
47484
48114
|
`is on ${branch} but behind ${REMOTE2}/${branch}`,
|
|
47485
48115
|
reasonOf(merged, "merge"),
|
|
47486
48116
|
"Run `git pull --ff-only` there"
|
|
@@ -47539,7 +48169,6 @@ async function applyRequestedCheckout(checkout, spec, deps, signal) {
|
|
|
47539
48169
|
return await switchTo(checkout, status.branch, `checkout-${spec.runId}`, deps, signal);
|
|
47540
48170
|
} catch (error61) {
|
|
47541
48171
|
return noted(
|
|
47542
|
-
checkout,
|
|
47543
48172
|
`could not be put on ${checkout.branch}, the branch picked for this chat`,
|
|
47544
48173
|
firstLine2(error61 instanceof Error ? error61.message : String(error61)) || "unknown error",
|
|
47545
48174
|
"Check it"
|
|
@@ -47551,11 +48180,15 @@ async function applyRequestedCheckout(checkout, spec, deps, signal) {
|
|
|
47551
48180
|
function short(sha) {
|
|
47552
48181
|
return sha.slice(0, 12);
|
|
47553
48182
|
}
|
|
47554
|
-
function
|
|
48183
|
+
function staleCheckout(path, snapshot2, tip) {
|
|
47555
48184
|
const checkout = snapshot2 === void 0 ? "is the environment snapshot's checkout" : `is the environment snapshot's checkout of ${snapshot2.branch} (commit ${short(snapshot2.head)})`;
|
|
47556
48185
|
const base = snapshot2 === void 0 ? "its upstream" : `origin/${snapshot2.base}`;
|
|
47557
48186
|
const remote = tip === void 0 ? "may be ahead" : `is ahead at ${short(tip)}`;
|
|
47558
|
-
return
|
|
48187
|
+
return {
|
|
48188
|
+
path,
|
|
48189
|
+
problem: `${checkout}; ${base} ${remote}`,
|
|
48190
|
+
action: "Run `git pull --ff-only` there"
|
|
48191
|
+
};
|
|
47559
48192
|
}
|
|
47560
48193
|
async function fastForward(freshness, operationId, deps, signal) {
|
|
47561
48194
|
var _stack = [];
|
|
@@ -47593,14 +48226,14 @@ async function atFirstLease(freshness, spec, deps, signal) {
|
|
|
47593
48226
|
return first && freshness.fetched && await fastForward(freshness, `refresh-${spec.runId}`, deps, signal) ? "moved" : "noted";
|
|
47594
48227
|
}
|
|
47595
48228
|
}
|
|
47596
|
-
function
|
|
48229
|
+
function problemFor(freshness) {
|
|
47597
48230
|
switch (freshness.state) {
|
|
47598
48231
|
case "behind":
|
|
47599
|
-
return
|
|
48232
|
+
return staleCheckout(freshness.path, freshness.snapshot, freshness.tip);
|
|
47600
48233
|
case "failed":
|
|
47601
|
-
return
|
|
48234
|
+
return staleCheckout(freshness.path, freshness.snapshot);
|
|
47602
48235
|
default:
|
|
47603
|
-
return
|
|
48236
|
+
return staleCheckout(freshness.path, void 0);
|
|
47604
48237
|
}
|
|
47605
48238
|
}
|
|
47606
48239
|
async function checkoutsOf(spec, leaseTargets) {
|
|
@@ -47622,7 +48255,7 @@ function requestedCheckoutsOf(spec, log) {
|
|
|
47622
48255
|
}
|
|
47623
48256
|
async function applyRequestedCheckouts(spec, deps, signal) {
|
|
47624
48257
|
const settled2 = /* @__PURE__ */ new Set();
|
|
47625
|
-
const
|
|
48258
|
+
const problems = [];
|
|
47626
48259
|
for (const checkout of requestedCheckoutsOf(spec, deps.log)) {
|
|
47627
48260
|
const outcome2 = await applyRequestedCheckout(checkout, spec, deps, signal);
|
|
47628
48261
|
deps.log.info("workspace.requested_checkout", {
|
|
@@ -47633,21 +48266,23 @@ async function applyRequestedCheckouts(spec, deps, signal) {
|
|
|
47633
48266
|
...outcome2.kind === "moved" ? { how: outcome2.how } : {}
|
|
47634
48267
|
});
|
|
47635
48268
|
if (outcome2.kind === "on_branch") continue;
|
|
47636
|
-
settled2.add((0,
|
|
47637
|
-
if (outcome2.kind === "noted")
|
|
48269
|
+
settled2.add((0, import_node_path25.resolve)(checkout.path));
|
|
48270
|
+
if (outcome2.kind === "noted") {
|
|
48271
|
+
problems.push({ path: checkout.path, problem: outcome2.problem, action: outcome2.action });
|
|
48272
|
+
}
|
|
47638
48273
|
}
|
|
47639
|
-
return { settled: settled2,
|
|
48274
|
+
return { settled: settled2, problems };
|
|
47640
48275
|
}
|
|
47641
48276
|
async function refreshSnapshotCheckouts(spec, targets, settled2, deps, signal) {
|
|
47642
|
-
const
|
|
48277
|
+
const problems = [];
|
|
47643
48278
|
for (const target of targets) {
|
|
47644
|
-
if (settled2.has((0,
|
|
48279
|
+
if (settled2.has((0, import_node_path25.resolve)(target))) continue;
|
|
47645
48280
|
const freshness = await readCheckoutFreshness(deps.dir, target);
|
|
47646
48281
|
if (freshness === null) continue;
|
|
47647
48282
|
const outcome2 = await atFirstLease(freshness, spec, deps, signal).catch(
|
|
47648
48283
|
() => "noted"
|
|
47649
48284
|
);
|
|
47650
|
-
if (outcome2 === "noted")
|
|
48285
|
+
if (outcome2 === "noted") problems.push(problemFor(freshness));
|
|
47651
48286
|
deps.log.info("workspace.refresh", {
|
|
47652
48287
|
runId: spec.runId,
|
|
47653
48288
|
path: freshness.path,
|
|
@@ -47655,25 +48290,24 @@ async function refreshSnapshotCheckouts(spec, targets, settled2, deps, signal) {
|
|
|
47655
48290
|
outcome: outcome2
|
|
47656
48291
|
});
|
|
47657
48292
|
}
|
|
47658
|
-
return
|
|
48293
|
+
return problems;
|
|
47659
48294
|
}
|
|
47660
48295
|
function createCheckoutRefresh(deps) {
|
|
47661
48296
|
return async (spec, leaseTargets, signal) => {
|
|
47662
|
-
if (spec.providerSessionId !== void 0) return
|
|
47663
|
-
if (!await claimOnce((0,
|
|
48297
|
+
if (spec.providerSessionId !== void 0) return [];
|
|
48298
|
+
if (!await claimOnce((0, import_node_path25.join)(deps.dir, "conversations"), spec.conversationId)) return [];
|
|
47664
48299
|
const requested = await applyRequestedCheckouts(spec, deps, signal);
|
|
47665
48300
|
const targets = await checkoutsOf(spec, leaseTargets);
|
|
47666
|
-
|
|
47667
|
-
...requested.
|
|
48301
|
+
return [
|
|
48302
|
+
...requested.problems,
|
|
47668
48303
|
...await refreshSnapshotCheckouts(spec, targets, requested.settled, deps, signal)
|
|
47669
48304
|
];
|
|
47670
|
-
return lines.length === 0 ? void 0 : lines.join("\n");
|
|
47671
48305
|
};
|
|
47672
48306
|
}
|
|
47673
48307
|
|
|
47674
48308
|
// src/holder/lease.ts
|
|
47675
|
-
var
|
|
47676
|
-
var
|
|
48309
|
+
var import_promises36 = require("fs/promises");
|
|
48310
|
+
var import_node_path26 = require("path");
|
|
47677
48311
|
var LEASE_CHECK_EVERY_MS = 5e3;
|
|
47678
48312
|
var MAX_TRANSIENT_FAILURES = 3;
|
|
47679
48313
|
var BACKOFF_BASE_MS = 1e3;
|
|
@@ -47687,8 +48321,8 @@ function identityFailure(code, workspacePath) {
|
|
|
47687
48321
|
return { code, problemCode: "app.workspace.missing", message: MESSAGES[code], workspacePath };
|
|
47688
48322
|
}
|
|
47689
48323
|
async function fileIdentity(path) {
|
|
47690
|
-
const canonical = await (0,
|
|
47691
|
-
const info = await (0,
|
|
48324
|
+
const canonical = await (0, import_promises36.realpath)(path);
|
|
48325
|
+
const info = await (0, import_promises36.stat)(canonical, { bigint: true });
|
|
47692
48326
|
return `${canonical}:${info.dev}:${info.ino}`;
|
|
47693
48327
|
}
|
|
47694
48328
|
async function snapshot(git, path, signal) {
|
|
@@ -47707,7 +48341,7 @@ async function snapshot(git, path, signal) {
|
|
|
47707
48341
|
workspace: await fileIdentity(path),
|
|
47708
48342
|
repository: await fileIdentity(commonDir),
|
|
47709
48343
|
worktree: await fileIdentity(gitDir),
|
|
47710
|
-
commonDir: await (0,
|
|
48344
|
+
commonDir: await (0, import_promises36.realpath)(commonDir)
|
|
47711
48345
|
};
|
|
47712
48346
|
} catch {
|
|
47713
48347
|
return null;
|
|
@@ -47720,7 +48354,7 @@ async function gitValue(git, path, args, signal) {
|
|
|
47720
48354
|
}
|
|
47721
48355
|
async function pathExists(path) {
|
|
47722
48356
|
try {
|
|
47723
|
-
await (0,
|
|
48357
|
+
await (0, import_promises36.stat)(path);
|
|
47724
48358
|
return true;
|
|
47725
48359
|
} catch (error61) {
|
|
47726
48360
|
return errnoCode(error61) !== "ENOENT" && errnoCode(error61) !== "ENOTDIR";
|
|
@@ -47729,19 +48363,19 @@ async function pathExists(path) {
|
|
|
47729
48363
|
async function hasGitMarker(path) {
|
|
47730
48364
|
let directory;
|
|
47731
48365
|
try {
|
|
47732
|
-
directory = await (0,
|
|
48366
|
+
directory = await (0, import_promises36.realpath)(path);
|
|
47733
48367
|
} catch {
|
|
47734
48368
|
return true;
|
|
47735
48369
|
}
|
|
47736
48370
|
for (; ; ) {
|
|
47737
48371
|
try {
|
|
47738
|
-
await (0,
|
|
48372
|
+
await (0, import_promises36.stat)((0, import_node_path26.join)(directory, ".git"));
|
|
47739
48373
|
return true;
|
|
47740
48374
|
} catch (error61) {
|
|
47741
48375
|
const code = errnoCode(error61);
|
|
47742
48376
|
if (code !== "ENOENT" && code !== "ENOTDIR") return true;
|
|
47743
48377
|
}
|
|
47744
|
-
const parent = (0,
|
|
48378
|
+
const parent = (0, import_node_path26.dirname)(directory);
|
|
47745
48379
|
if (parent === directory) return false;
|
|
47746
48380
|
directory = parent;
|
|
47747
48381
|
}
|
|
@@ -47905,7 +48539,7 @@ function volumeRoot(path) {
|
|
|
47905
48539
|
}
|
|
47906
48540
|
async function exists(path) {
|
|
47907
48541
|
try {
|
|
47908
|
-
await (0,
|
|
48542
|
+
await (0, import_promises37.stat)(path);
|
|
47909
48543
|
return true;
|
|
47910
48544
|
} catch {
|
|
47911
48545
|
return false;
|
|
@@ -47913,10 +48547,10 @@ async function exists(path) {
|
|
|
47913
48547
|
}
|
|
47914
48548
|
async function inspectReadiness(path) {
|
|
47915
48549
|
try {
|
|
47916
|
-
if (!(await (0,
|
|
48550
|
+
if (!(await (0, import_promises37.stat)(path)).isDirectory()) {
|
|
47917
48551
|
return { ready: false, missing: true, message: MESSAGES2.missing };
|
|
47918
48552
|
}
|
|
47919
|
-
await (0,
|
|
48553
|
+
await (0, import_promises37.access)(path, import_node_fs9.constants.R_OK | import_node_fs9.constants.W_OK | import_node_fs9.constants.X_OK);
|
|
47920
48554
|
return { ready: true };
|
|
47921
48555
|
} catch (error61) {
|
|
47922
48556
|
const code = errnoCode(error61) ?? "";
|
|
@@ -47994,8 +48628,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
|
|
|
47994
48628
|
const { env } = context;
|
|
47995
48629
|
const path = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os5.homedir)());
|
|
47996
48630
|
try {
|
|
47997
|
-
await (0,
|
|
47998
|
-
await (0,
|
|
48631
|
+
await (0, import_promises37.mkdir)(path, { recursive: true, mode: 448 });
|
|
48632
|
+
await (0, import_promises37.access)(path, import_node_fs9.constants.R_OK | import_node_fs9.constants.W_OK | import_node_fs9.constants.X_OK);
|
|
47999
48633
|
return {
|
|
48000
48634
|
kind: "admitted",
|
|
48001
48635
|
spec: { ...spec, projectPath: path },
|
|
@@ -48073,7 +48707,7 @@ var CHECKOUT_NETWORK_TIMEOUT_MS = 12e4;
|
|
|
48073
48707
|
function createHolderWorkspace(machine, clock, log) {
|
|
48074
48708
|
const platform = machine.platform ?? process.platform;
|
|
48075
48709
|
const git = createGitRunner({ env: machine.env, platform, localTimeoutMs: PROBE_TIMEOUT_MS2 });
|
|
48076
|
-
const locks = openRepositoryLocks({ dir: (0,
|
|
48710
|
+
const locks = openRepositoryLocks({ dir: (0, import_node_path27.join)(machine.stateDir, "locks"), clock, platform });
|
|
48077
48711
|
return {
|
|
48078
48712
|
admission: {
|
|
48079
48713
|
env: machine.env,
|
|
@@ -48085,7 +48719,7 @@ function createHolderWorkspace(machine, clock, log) {
|
|
|
48085
48719
|
),
|
|
48086
48720
|
approvedRoots: async () => {
|
|
48087
48721
|
const approved = await openApprovedPaths({
|
|
48088
|
-
file: (0,
|
|
48722
|
+
file: (0, import_node_path27.join)(machine.stateDir, "workspaces.json"),
|
|
48089
48723
|
log,
|
|
48090
48724
|
platform
|
|
48091
48725
|
});
|
|
@@ -48103,7 +48737,11 @@ function createHolderWorkspace(machine, clock, log) {
|
|
|
48103
48737
|
}),
|
|
48104
48738
|
locks,
|
|
48105
48739
|
log,
|
|
48106
|
-
dir: (0,
|
|
48740
|
+
dir: (0, import_node_path27.join)(machine.stateDir, "checkout-freshness")
|
|
48741
|
+
}),
|
|
48742
|
+
prepareAgentContext: createAgentContext({
|
|
48743
|
+
dir: (0, import_node_path27.join)(machine.stateDir, "agent-context"),
|
|
48744
|
+
homeDir: machine.env.HOME || (0, import_node_os5.homedir)()
|
|
48107
48745
|
})
|
|
48108
48746
|
} : {}
|
|
48109
48747
|
};
|
|
@@ -48131,7 +48769,7 @@ async function respondToTurn(runningRunId, gate, driver, request2) {
|
|
|
48131
48769
|
}
|
|
48132
48770
|
|
|
48133
48771
|
// src/holder/session-facts.ts
|
|
48134
|
-
var
|
|
48772
|
+
var import_promises38 = require("fs/promises");
|
|
48135
48773
|
var CLI_RSS_CACHE_MS = 1e4;
|
|
48136
48774
|
var LOGIN_PROBLEM_PREFIX = "cli.auth.";
|
|
48137
48775
|
function isLoginFailure(result) {
|
|
@@ -48157,8 +48795,8 @@ function createSessionFacts(options) {
|
|
|
48157
48795
|
const path = await resolveCommandOnPath(command, env, platform);
|
|
48158
48796
|
if (path === null) return null;
|
|
48159
48797
|
try {
|
|
48160
|
-
const real = await (0,
|
|
48161
|
-
const info = await (0,
|
|
48798
|
+
const real = await (0, import_promises38.realpath)(path);
|
|
48799
|
+
const info = await (0, import_promises38.stat)(real);
|
|
48162
48800
|
return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
|
|
48163
48801
|
} catch {
|
|
48164
48802
|
return null;
|
|
@@ -48245,8 +48883,8 @@ function createSessionFacts(options) {
|
|
|
48245
48883
|
init_acp2();
|
|
48246
48884
|
|
|
48247
48885
|
// src/run-log/directory.ts
|
|
48248
|
-
var
|
|
48249
|
-
var
|
|
48886
|
+
var import_promises39 = require("fs/promises");
|
|
48887
|
+
var import_node_path28 = require("path");
|
|
48250
48888
|
init_runtime_v2();
|
|
48251
48889
|
init_zod();
|
|
48252
48890
|
var runMetaSchema = external_exports.object({
|
|
@@ -48268,17 +48906,17 @@ var runMetaSchema = external_exports.object({
|
|
|
48268
48906
|
}).optional()
|
|
48269
48907
|
});
|
|
48270
48908
|
function runDirectory(runsDir, runId) {
|
|
48271
|
-
const dir = (0,
|
|
48909
|
+
const dir = (0, import_node_path28.join)(runsDir, runId);
|
|
48272
48910
|
return {
|
|
48273
48911
|
dir,
|
|
48274
|
-
log: (0,
|
|
48275
|
-
upload: (0,
|
|
48276
|
-
meta: (0,
|
|
48912
|
+
log: (0, import_node_path28.join)(dir, "log.jsonl"),
|
|
48913
|
+
upload: (0, import_node_path28.join)(dir, "upload.json"),
|
|
48914
|
+
meta: (0, import_node_path28.join)(dir, "run.json")
|
|
48277
48915
|
};
|
|
48278
48916
|
}
|
|
48279
48917
|
async function isRunClaimed(runsDir, runId) {
|
|
48280
48918
|
try {
|
|
48281
|
-
return (await (0,
|
|
48919
|
+
return (await (0, import_promises39.stat)(runDirectory(runsDir, runId).log)).size > 0;
|
|
48282
48920
|
} catch (error61) {
|
|
48283
48921
|
if (errnoCode(error61) === "ENOENT") return false;
|
|
48284
48922
|
throw error61;
|
|
@@ -48286,8 +48924,8 @@ async function isRunClaimed(runsDir, runId) {
|
|
|
48286
48924
|
}
|
|
48287
48925
|
|
|
48288
48926
|
// src/run-log/conversation-index.ts
|
|
48289
|
-
var
|
|
48290
|
-
var
|
|
48927
|
+
var import_promises40 = require("fs/promises");
|
|
48928
|
+
var import_node_path29 = require("path");
|
|
48291
48929
|
init_runtime_v2();
|
|
48292
48930
|
init_zod();
|
|
48293
48931
|
var ORDINALS_PER_SHARD = 1e3;
|
|
@@ -48303,13 +48941,13 @@ var coverageSchema = external_exports.object({
|
|
|
48303
48941
|
nextExpectedOrdinal: external_exports.number().int().positive()
|
|
48304
48942
|
});
|
|
48305
48943
|
function conversationsDirectory(runsDir) {
|
|
48306
|
-
return (0,
|
|
48944
|
+
return (0, import_node_path29.join)((0, import_node_path29.dirname)(runsDir), "conversations");
|
|
48307
48945
|
}
|
|
48308
48946
|
function indexDirectory(runsDir, conversationId) {
|
|
48309
|
-
return (0,
|
|
48947
|
+
return (0, import_node_path29.join)(conversationsDirectory(runsDir), conversationId, "turn-index");
|
|
48310
48948
|
}
|
|
48311
48949
|
function shardPath(runsDir, conversationId, ordinal) {
|
|
48312
|
-
return (0,
|
|
48950
|
+
return (0, import_node_path29.join)(
|
|
48313
48951
|
indexDirectory(runsDir, conversationId),
|
|
48314
48952
|
`${Math.floor(ordinal / ORDINALS_PER_SHARD)}.jsonl`
|
|
48315
48953
|
);
|
|
@@ -48318,10 +48956,10 @@ async function indexConversationRun(runsDir, conversationId, ordinal, assistantO
|
|
|
48318
48956
|
const nextOrdinal = assistantOrdinal + 1;
|
|
48319
48957
|
if (nextOrdinal <= ordinal) throw new Error("Assistant order must follow the prompt");
|
|
48320
48958
|
const path = shardPath(runsDir, conversationId, ordinal);
|
|
48321
|
-
await (0,
|
|
48322
|
-
await (0,
|
|
48959
|
+
await (0, import_promises40.mkdir)((0, import_node_path29.dirname)(path), { recursive: true, mode: 448 });
|
|
48960
|
+
await (0, import_promises40.appendFile)(path, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
|
|
48323
48961
|
`, { mode: 384 });
|
|
48324
|
-
const coveragePath = (0,
|
|
48962
|
+
const coveragePath = (0, import_node_path29.join)((0, import_node_path29.dirname)((0, import_node_path29.dirname)(path)), "coverage.json");
|
|
48325
48963
|
const coverage = await readJsonFile(coveragePath, coverageSchema);
|
|
48326
48964
|
const current = coverage.kind === "ok" ? coverage.value : null;
|
|
48327
48965
|
const next = nextCoverage(current, ordinal, nextOrdinal);
|
|
@@ -48365,7 +49003,7 @@ var decoder = new TextDecoder();
|
|
|
48365
49003
|
|
|
48366
49004
|
// src/run-log/writer.ts
|
|
48367
49005
|
var import_node_fs10 = require("fs");
|
|
48368
|
-
var
|
|
49006
|
+
var import_node_path30 = require("path");
|
|
48369
49007
|
init_runtime_v2();
|
|
48370
49008
|
function lastSeq(fd, size) {
|
|
48371
49009
|
for (const length of tailWindows(size)) {
|
|
@@ -48381,7 +49019,7 @@ function lastSeq(fd, size) {
|
|
|
48381
49019
|
throw new RuntimeFault("record_too_large", "Run log tail record is larger than any record");
|
|
48382
49020
|
}
|
|
48383
49021
|
function openRunLog(path, clock) {
|
|
48384
|
-
(0, import_node_fs10.mkdirSync)((0,
|
|
49022
|
+
(0, import_node_fs10.mkdirSync)((0, import_node_path30.dirname)(path), { recursive: true, mode: 448 });
|
|
48385
49023
|
const fd = (0, import_node_fs10.openSync)(path, "a+", 384);
|
|
48386
49024
|
let size = (0, import_node_fs10.fstatSync)(fd).size;
|
|
48387
49025
|
let seq = lastSeq(fd, size);
|
|
@@ -48559,8 +49197,12 @@ function fitForRunLog(update) {
|
|
|
48559
49197
|
async function runWithInputs({ spec, leaseTargets, skills }, context, sink, signal) {
|
|
48560
49198
|
var _stack = [];
|
|
48561
49199
|
try {
|
|
48562
|
-
const
|
|
49200
|
+
const workspace = context.workspace;
|
|
49201
|
+
const sessionContext = (workspace?.refreshFirstCheckout?.(spec, leaseTargets, signal) ?? Promise.resolve([])).catch((error61) => {
|
|
48563
49202
|
context.log.warn("workspace.refresh_failed", { runId: spec.runId, error: error61 });
|
|
49203
|
+
return [];
|
|
49204
|
+
}).then((problems) => workspace?.prepareAgentContext?.(spec, problems)).catch((error61) => {
|
|
49205
|
+
context.log.warn("holder.agent_context_failed", { runId: spec.runId, error: error61 });
|
|
48564
49206
|
return void 0;
|
|
48565
49207
|
});
|
|
48566
49208
|
let inputs;
|
|
@@ -48573,17 +49215,37 @@ async function runWithInputs({ spec, leaseTargets, skills }, context, sink, sign
|
|
|
48573
49215
|
message: `Could not fetch this run's attachments or provider credential: ${error61 instanceof Error ? error61.message : String(error61)}`
|
|
48574
49216
|
};
|
|
48575
49217
|
}
|
|
48576
|
-
const
|
|
49218
|
+
const agentContext = await sessionContext;
|
|
48577
49219
|
const prepared = __using(_stack, inputs, true);
|
|
48578
|
-
const run = (turnSink, turnSignal) =>
|
|
49220
|
+
const run = async (turnSink, turnSignal) => {
|
|
49221
|
+
const result = await context.driver.runTurn(
|
|
49222
|
+
spec,
|
|
49223
|
+
turnSink,
|
|
49224
|
+
turnSignal,
|
|
49225
|
+
agentContext === void 0 ? prepared : {
|
|
49226
|
+
...prepared,
|
|
49227
|
+
agentContext: {
|
|
49228
|
+
full: agentContext.full,
|
|
49229
|
+
...agentContext.update ? { update: agentContext.update } : {}
|
|
49230
|
+
}
|
|
49231
|
+
}
|
|
49232
|
+
);
|
|
49233
|
+
if (agentContext !== void 0 && result.outcome !== "rejected") {
|
|
49234
|
+
await agentContext.save().catch((error61) => {
|
|
49235
|
+
context.log.warn("holder.agent_context_save_failed", { runId: spec.runId, error: error61 });
|
|
49236
|
+
});
|
|
49237
|
+
}
|
|
49238
|
+
return result;
|
|
49239
|
+
};
|
|
49240
|
+
if (workspace === void 0) return await run(sink, signal);
|
|
49241
|
+
return await runLeased(
|
|
48579
49242
|
spec,
|
|
48580
|
-
|
|
48581
|
-
|
|
48582
|
-
|
|
49243
|
+
leaseTargets,
|
|
49244
|
+
{ ...context, lease: workspace.lease },
|
|
49245
|
+
sink,
|
|
49246
|
+
signal,
|
|
49247
|
+
run
|
|
48583
49248
|
);
|
|
48584
|
-
if (context.workspace === void 0) return await run(sink, signal);
|
|
48585
|
-
const leased = { ...context, lease: context.workspace.lease };
|
|
48586
|
-
return await runLeased(spec, leaseTargets, leased, sink, signal, run);
|
|
48587
49249
|
} catch (_) {
|
|
48588
49250
|
var _error = _, _hasError = true;
|
|
48589
49251
|
} finally {
|
|
@@ -48717,7 +49379,7 @@ async function runHolder({
|
|
|
48717
49379
|
try {
|
|
48718
49380
|
const identity = await readProcessIdentity(process.pid);
|
|
48719
49381
|
if (identity === null) throw new RuntimeFault("internal", "Cannot read own process identity");
|
|
48720
|
-
const _engines = __using(_stack, recordSpawnedEngines(engineRecordsPath((0,
|
|
49382
|
+
const _engines = __using(_stack, recordSpawnedEngines(engineRecordsPath((0, import_node_path31.dirname)(launch.statusPath)), clock, log));
|
|
48721
49383
|
const holder = {
|
|
48722
49384
|
state: "idle",
|
|
48723
49385
|
runId: null,
|
|
@@ -49062,7 +49724,7 @@ function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node
|
|
|
49062
49724
|
providerProbes: ALAN_RUNTIME_PROVIDER_PROBES === "on",
|
|
49063
49725
|
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,
|
|
49064
49726
|
home,
|
|
49065
|
-
configHome: XDG_CONFIG_HOME ?? (0,
|
|
49727
|
+
configHome: XDG_CONFIG_HOME ?? (0, import_node_path33.join)(home, ".config"),
|
|
49066
49728
|
codexHome: resolveCodexHome(CODEX_HOME, home),
|
|
49067
49729
|
...githubProxyConfig({ ALAN_RUNTIME_GITHUB_PROXY, XDG_CONFIG_HOME, GH_CONFIG_DIR }, home),
|
|
49068
49730
|
gitGatewayUrl: ALAN_RUNTIME_GIT_GATEWAY_URL ?? null,
|
|
@@ -49072,13 +49734,13 @@ function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node
|
|
|
49072
49734
|
};
|
|
49073
49735
|
}
|
|
49074
49736
|
function resolveCodexHome(configuredHome, home) {
|
|
49075
|
-
return configuredHome ?? (0,
|
|
49737
|
+
return configuredHome ?? (0, import_node_path33.join)(home, ".codex");
|
|
49076
49738
|
}
|
|
49077
49739
|
function githubProxyConfig(env, home) {
|
|
49078
|
-
const configHome = env.XDG_CONFIG_HOME ?? (0,
|
|
49740
|
+
const configHome = env.XDG_CONFIG_HOME ?? (0, import_node_path33.join)(home, ".config");
|
|
49079
49741
|
return {
|
|
49080
49742
|
githubProxy: env.ALAN_RUNTIME_GITHUB_PROXY === "on",
|
|
49081
|
-
ghConfigDir: env.GH_CONFIG_DIR ?? (0,
|
|
49743
|
+
ghConfigDir: env.GH_CONFIG_DIR ?? (0, import_node_path33.join)(configHome, "gh")
|
|
49082
49744
|
};
|
|
49083
49745
|
}
|
|
49084
49746
|
function serviceEnvironment(env, profile) {
|
|
@@ -49177,7 +49839,7 @@ async function loadStoredAccess(paths, access3 = { exec: systemExec }) {
|
|
|
49177
49839
|
}
|
|
49178
49840
|
|
|
49179
49841
|
// src/cli/commands/hold.ts
|
|
49180
|
-
var
|
|
49842
|
+
var import_node_path34 = require("path");
|
|
49181
49843
|
init_agent2();
|
|
49182
49844
|
init_runtime_v2();
|
|
49183
49845
|
async function machineAccess(paths, log, conversationId, transport) {
|
|
@@ -49235,7 +49897,7 @@ async function runHold(argv) {
|
|
|
49235
49897
|
const config2 = loadRuntimeConfig();
|
|
49236
49898
|
const paths = runtimePaths(config2.stateDir);
|
|
49237
49899
|
const log = __using(_stack, openFileLog(
|
|
49238
|
-
(0,
|
|
49900
|
+
(0, import_node_path34.join)(paths.logs, `holder-${launch.value.conversationId}.jsonl`),
|
|
49239
49901
|
config2.logLevel,
|
|
49240
49902
|
systemClock
|
|
49241
49903
|
));
|
|
@@ -49246,7 +49908,7 @@ async function runHold(argv) {
|
|
|
49246
49908
|
);
|
|
49247
49909
|
const transport = __using(_stack, createHttpTransport());
|
|
49248
49910
|
const access3 = await machineAccess(paths, log, launch.value.conversationId, transport);
|
|
49249
|
-
const credentialPath = (0,
|
|
49911
|
+
const credentialPath = (0, import_node_path34.join)(paths.tmp, "mcp", `${launch.value.conversationId}.json`);
|
|
49250
49912
|
const managedMcp = __using(_stack, access3.managedMcp === void 0 ? void 0 : createHelperMcpAccess({
|
|
49251
49913
|
managedMcp: access3.managedMcp,
|
|
49252
49914
|
conversationId: launch.value.conversationId,
|