@alan-ai-hq/agent-manager-linux-x64 0.1.147 → 0.1.148

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/alan-agent.cjs +1271 -736
  2. package/alan-holder.cjs +950 -496
  3. 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 changed = false;
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
- changed = true;
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
- changed = true;
19075
+ changed2 = true;
19076
19076
  }
19077
- return changed ? clone(s, { ...def, shape: newShape, catchall: newCatchall }) : s;
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 changed = false;
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
- changed = true;
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
- changed = true;
19097
+ changed2 = true;
19098
19098
  }
19099
- return changed ? clone(s, { ...def, items: newItems, rest: newRest }) : s;
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 changed = false;
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
- changed = true;
19118
+ changed2 = true;
19119
19119
  newOptions.push(mapped);
19120
19120
  }
19121
- return changed ? clone(s, { ...def, options: newOptions }) : s;
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({
@@ -20007,304 +20260,110 @@ var init_run_context = __esm({
20007
20260
  }));
20008
20261
  canonicalAssistantMessageSchema = wire()(external_exports.object({
20009
20262
  id: external_exports.string().min(1),
20010
- turnOrdinal: external_exports.number().int().nullable(),
20011
- createdAt: external_exports.string().min(1)
20012
- }));
20013
- externalMcpServerSchema = wire()(external_exports.object({
20014
- type: external_exports.enum(["http", "sse", "stdio"]).optional(),
20015
- url: external_exports.string().min(1).optional(),
20016
- headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
20017
- command: external_exports.string().min(1).optional(),
20018
- args: external_exports.array(external_exports.string()).optional(),
20019
- env: external_exports.record(external_exports.string(), external_exports.string()).optional()
20020
- }));
20021
- runAttachmentSchema = external_exports.object({
20022
- id: external_exports.string().min(1),
20023
- kind: external_exports.enum(["image", "file"]),
20024
- filename: external_exports.string().min(1),
20025
- mimeType: external_exports.string().min(1),
20026
- size: external_exports.number().int().nonnegative(),
20027
- label: external_exports.string().optional(),
20028
- width: external_exports.number().int().positive().optional(),
20029
- height: external_exports.number().int().positive().optional(),
20030
- /** API path the holder GETs with the machine credential; never a pre-signed secret URL. */
20031
- downloadPath: external_exports.string().startsWith("/")
20032
- });
20033
- parsedAttachmentSchema = wire()(external_exports.object({
20034
- id: external_exports.string().min(1),
20035
- filename: external_exports.string().min(1),
20036
- mimeType: external_exports.string().min(1),
20037
- kind: external_exports.enum(["pdf", "text", "other"]),
20038
- status: external_exports.enum(["extracted", "partial", "needs_ocr", "unsupported", "too_large", "failed"]),
20039
- content: external_exports.string().nullable(),
20040
- contentTruncated: external_exports.boolean(),
20041
- pageCount: external_exports.number().int().nonnegative().optional(),
20042
- pdfType: external_exports.string().optional(),
20043
- pagesNeedingOcr: external_exports.array(external_exports.number().int()).optional(),
20044
- hasEncodingIssues: external_exports.boolean().optional(),
20045
- errorCode: external_exports.enum([
20046
- "invalid_pdf",
20047
- "encrypted_pdf",
20048
- "native_unavailable",
20049
- "decode_failed",
20050
- "download_failed"
20051
- ]).optional()
20052
- }));
20053
- taskMetaSchema = wire()(external_exports.object({
20054
- id: external_exports.string().min(1),
20055
- title: external_exports.string(),
20056
- description: external_exports.string().nullable(),
20057
- status: external_exports.string(),
20058
- priority: external_exports.string(),
20059
- labels: external_exports.array(external_exports.string()).nullable(),
20060
- assignees: external_exports.array(external_exports.object({ name: external_exports.string().nullable(), email: external_exports.string() })),
20061
- statusOptions: external_exports.array(external_exports.object({
20062
- id: external_exports.string().min(1),
20063
- label: external_exports.string(),
20064
- group: external_exports.enum(["not_started", "active", "done", "closed"])
20065
- })).optional(),
20066
- descriptionAttachmentIds: external_exports.array(external_exports.object({ id: external_exports.string().min(1), filename: external_exports.string() })).optional(),
20067
- linkedResources: external_exports.array(external_exports.object({
20068
- 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()
20263
+ turnOrdinal: external_exports.number().int().nullable(),
20264
+ createdAt: external_exports.string().min(1)
20265
+ }));
20266
+ externalMcpServerSchema = wire()(external_exports.object({
20267
+ type: external_exports.enum(["http", "sse", "stdio"]).optional(),
20268
+ url: external_exports.string().min(1).optional(),
20269
+ headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
20270
+ command: external_exports.string().min(1).optional(),
20271
+ args: external_exports.array(external_exports.string()).optional(),
20272
+ env: external_exports.record(external_exports.string(), external_exports.string()).optional()
20273
+ }));
20274
+ runAttachmentSchema = external_exports.object({
20275
+ id: external_exports.string().min(1),
20276
+ kind: external_exports.enum(["image", "file"]),
20277
+ filename: external_exports.string().min(1),
20278
+ mimeType: external_exports.string().min(1),
20279
+ size: external_exports.number().int().nonnegative(),
20280
+ label: external_exports.string().optional(),
20281
+ width: external_exports.number().int().positive().optional(),
20282
+ height: external_exports.number().int().positive().optional(),
20283
+ /** API path the holder GETs with the machine credential; never a pre-signed secret URL. */
20284
+ downloadPath: external_exports.string().startsWith("/")
20297
20285
  });
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()
20286
+ parsedAttachmentSchema = wire()(external_exports.object({
20287
+ id: external_exports.string().min(1),
20288
+ filename: external_exports.string().min(1),
20289
+ mimeType: external_exports.string().min(1),
20290
+ kind: external_exports.enum(["pdf", "text", "other"]),
20291
+ status: external_exports.enum(["extracted", "partial", "needs_ocr", "unsupported", "too_large", "failed"]),
20292
+ content: external_exports.string().nullable(),
20293
+ contentTruncated: external_exports.boolean(),
20294
+ pageCount: external_exports.number().int().nonnegative().optional(),
20295
+ pdfType: external_exports.string().optional(),
20296
+ pagesNeedingOcr: external_exports.array(external_exports.number().int()).optional(),
20297
+ hasEncodingIssues: external_exports.boolean().optional(),
20298
+ errorCode: external_exports.enum([
20299
+ "invalid_pdf",
20300
+ "encrypted_pdf",
20301
+ "native_unavailable",
20302
+ "decode_failed",
20303
+ "download_failed"
20304
+ ]).optional()
20305
+ }));
20306
+ taskMetaSchema = wire()(external_exports.object({
20307
+ id: external_exports.string().min(1),
20308
+ title: external_exports.string(),
20309
+ description: external_exports.string().nullable(),
20310
+ status: external_exports.string(),
20311
+ priority: external_exports.string(),
20312
+ labels: external_exports.array(external_exports.string()).nullable(),
20313
+ assignees: external_exports.array(external_exports.object({ name: external_exports.string().nullable(), email: external_exports.string() })),
20314
+ statusOptions: external_exports.array(external_exports.object({
20315
+ id: external_exports.string().min(1),
20316
+ label: external_exports.string(),
20317
+ group: external_exports.enum(["not_started", "active", "done", "closed"])
20318
+ })).optional(),
20319
+ descriptionAttachmentIds: external_exports.array(external_exports.object({ id: external_exports.string().min(1), filename: external_exports.string() })).optional(),
20320
+ linkedResources: external_exports.array(external_exports.object({
20321
+ id: external_exports.string().min(1),
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();
@@ -25554,7 +25616,259 @@ var init_chunk_J2KTV5FP = __esm({
25554
25616
  }
25555
25617
  });
25556
25618
 
25557
- // ../agent-core/dist/chunk-FPGAN4XO.js
25619
+ // ../agent-core/dist/chunk-GI3ZGXTY.js
25620
+ function repositories(input2, context) {
25621
+ const problems = new Map(input2.problems.map((problem) => [problem.path, problem]));
25622
+ const listed = context?.repositories ?? [];
25623
+ const known = new Set(listed.map((repository) => repository.path));
25624
+ const unlisted = input2.problems.filter((problem) => !known.has(problem.path));
25625
+ return [
25626
+ ...listed.map((repository) => {
25627
+ const problem = problems.get(repository.path);
25628
+ return {
25629
+ path: repository.path,
25630
+ name: repository.name,
25631
+ url: repository.url,
25632
+ branch: repository.branch,
25633
+ branchSource: repository.branchSource,
25634
+ base: repository.base,
25635
+ checkout: problem ? "needs_attention" : "ok",
25636
+ ...problem ? { problem: problem.problem, action: problem.action } : {}
25637
+ };
25638
+ }),
25639
+ ...unlisted.map(
25640
+ (problem) => ({
25641
+ path: problem.path,
25642
+ checkout: "needs_attention",
25643
+ problem: problem.problem,
25644
+ action: problem.action
25645
+ })
25646
+ )
25647
+ ];
25648
+ }
25649
+ function branchInstruction(repository) {
25650
+ const { path, branch, branchSource } = repository;
25651
+ if (!branch || !branchSource) return void 0;
25652
+ const reason = BRANCH_REASONS[branchSource];
25653
+ if (branchSource === "task") {
25654
+ return `Commit work in ${path} on ${branch}, ${reason}; create it from ${repository.base ?? "the default branch"} if it does not exist.`;
25655
+ }
25656
+ return `Work in ${path} on ${branch}, ${reason}.`;
25657
+ }
25658
+ function repositoryInstructions(repository) {
25659
+ const problem = repository.problem && repository.action ? `${repository.path} ${repository.problem}. ${repository.action} before relying on its files.` : void 0;
25660
+ const branch = problem && repository.branchSource !== "environment_default" ? void 0 : branchInstruction(repository);
25661
+ return [branch, problem].filter((line) => line !== void 0);
25662
+ }
25663
+ function environmentInstructions(environment, cwd) {
25664
+ const lines = [];
25665
+ const start = environment.start;
25666
+ if (start?.state === "failed") {
25667
+ lines.push(
25668
+ `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.`
25669
+ );
25670
+ } else if (start?.state === "pending") {
25671
+ lines.push(`The start command is still starting; check ${start.log} before testing the app.`);
25672
+ }
25673
+ const build = environment.pendingBuild;
25674
+ if (build?.status === "queued" || build?.status === "running") {
25675
+ lines.push(
25676
+ `Image build ${build.id} is ${build.status}; its result arrives as a message, so do not poll for it.`
25677
+ );
25678
+ } else if (build?.status === "failed") {
25679
+ lines.push(
25680
+ `The latest image build (${build.id}) failed; sessions still boot from the previous image.`
25681
+ );
25682
+ }
25683
+ if (environment.variables.length > 0) {
25684
+ lines.push("Saved variables are set in this sandbox; never print or commit their values.");
25685
+ }
25686
+ return lines;
25687
+ }
25688
+ function instructionsFor(snapshot2) {
25689
+ const cwd = snapshot2.workspace.cwd ?? snapshot2.workspace.root ?? "the workspace";
25690
+ return [
25691
+ ...snapshot2.session.trigger === "image_build" ? ["Alan sent this turn, not the user: it reports an image build result."] : [],
25692
+ ...snapshot2.environment ? environmentInstructions(snapshot2.environment, cwd) : []
25693
+ ];
25694
+ }
25695
+ function startingInstructions(snapshot2) {
25696
+ const cwd = snapshot2.workspace.cwd ?? snapshot2.workspace.root;
25697
+ return [
25698
+ ...cwd ? [`Work from ${cwd}.`] : [],
25699
+ ...snapshot2.workspace.repositories.flatMap(repositoryInstructions)
25700
+ ];
25701
+ }
25702
+ function sessionKind(input2, context) {
25703
+ if (context) return context.kind;
25704
+ if (input2.spec.workflowExecutionId) return "workflow";
25705
+ return input2.spec.taskId ? "task" : "chat";
25706
+ }
25707
+ function environmentOf(input2, context) {
25708
+ const environment = context?.environment;
25709
+ if (!environment) return void 0;
25710
+ const start = environment.startCommand === null ? { state: "not_configured" } : input2.start;
25711
+ return {
25712
+ id: environment.id,
25713
+ name: environment.name,
25714
+ installCommand: environment.installCommand,
25715
+ startCommand: environment.startCommand,
25716
+ imageBuildId: environment.imageBuildId,
25717
+ ...environment.pendingBuild ? { pendingBuild: environment.pendingBuild } : {},
25718
+ variables: environment.variables,
25719
+ ...start ? { start: start.state === "not_configured" ? start : { ...start, log: input2.startLogPath } } : {}
25720
+ };
25721
+ }
25722
+ function knownContext(snapshot2) {
25723
+ const organizationId = snapshot2?.session.organizationId;
25724
+ if (!snapshot2 || !organizationId) return void 0;
25725
+ const environment = snapshot2.environment;
25726
+ return {
25727
+ kind: snapshot2.session.kind,
25728
+ trigger: "user",
25729
+ organizationId,
25730
+ ...snapshot2.task ? { taskWorkingBranch: snapshot2.task.workingBranch } : {},
25731
+ ...snapshot2.pullRequest ? { pullRequest: snapshot2.pullRequest } : {},
25732
+ repositories: snapshot2.workspace.repositories.flatMap(
25733
+ ({ path, name, url: url2, branch, branchSource, base }) => name && url2 && branch && branchSource && base ? [{ path, name, url: url2, branch, branchSource, base }] : []
25734
+ ),
25735
+ ...environment ? {
25736
+ environment: {
25737
+ id: environment.id,
25738
+ name: environment.name,
25739
+ installCommand: environment.installCommand,
25740
+ startCommand: environment.startCommand,
25741
+ imageBuildId: environment.imageBuildId,
25742
+ ...environment.pendingBuild ? { pendingBuild: environment.pendingBuild } : {},
25743
+ variables: environment.variables
25744
+ }
25745
+ } : {}
25746
+ };
25747
+ }
25748
+ function agentContextSnapshot(input2) {
25749
+ const context = input2.spec.agentContext ?? knownContext(input2.known);
25750
+ if (!context && input2.problems.length === 0) return null;
25751
+ const environment = environmentOf(input2, context);
25752
+ const base = {
25753
+ session: {
25754
+ kind: sessionKind(input2, context),
25755
+ trigger: context?.trigger ?? "user",
25756
+ conversationId: input2.spec.conversationId,
25757
+ runId: input2.spec.runId,
25758
+ ...input2.spec.teamId ? { teamId: input2.spec.teamId } : {},
25759
+ ...input2.spec.taskId ? { taskId: input2.spec.taskId } : {},
25760
+ ...input2.spec.workflowExecutionId ? { workflowExecutionId: input2.spec.workflowExecutionId } : {},
25761
+ ...context ? { organizationId: context.organizationId } : {}
25762
+ },
25763
+ ...context?.taskWorkingBranch ? { task: { workingBranch: context.taskWorkingBranch } } : {},
25764
+ ...context?.pullRequest ? { pullRequest: context.pullRequest } : {},
25765
+ workspace: {
25766
+ ...input2.workspaceRoot ? { root: input2.workspaceRoot } : {},
25767
+ ...input2.spec.projectPath ? { cwd: input2.spec.projectPath } : {},
25768
+ repositories: repositories(input2, context)
25769
+ },
25770
+ ...environment ? { environment } : {}
25771
+ };
25772
+ return { ...base, instructions: instructionsFor(base) };
25773
+ }
25774
+ function isScalar(value) {
25775
+ return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
25776
+ }
25777
+ function scalar(value) {
25778
+ if (typeof value !== "string") return String(value);
25779
+ return PLAIN_SCALAR.test(value) ? value : JSON.stringify(value);
25780
+ }
25781
+ function snakeCase(key) {
25782
+ return key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
25783
+ }
25784
+ function yamlLines(record2, indent) {
25785
+ return Object.entries(record2).flatMap(([key, value]) => {
25786
+ const name = `${indent}${snakeCase(key)}:`;
25787
+ if (isScalar(value)) return [`${name} ${scalar(value)}`];
25788
+ if (Array.isArray(value)) {
25789
+ if (value.length === 0) return [];
25790
+ return [
25791
+ name,
25792
+ ...value.flatMap((item) => {
25793
+ if (isScalar(item)) return [`${indent} - ${scalar(item)}`];
25794
+ if (typeof item !== "object" || item === null) return [];
25795
+ const [first = "", ...rest] = yamlLines(item, `${indent} `);
25796
+ return [`${indent} - ${first.trimStart()}`, ...rest];
25797
+ })
25798
+ ];
25799
+ }
25800
+ if (typeof value === "object" && value !== null)
25801
+ return [name, ...yamlLines(value, `${indent} `)];
25802
+ return [];
25803
+ });
25804
+ }
25805
+ function block(tag, body) {
25806
+ return [`<${tag} version="${AGENT_CONTEXT_VERSION}">`, ...yamlLines(body, ""), `</${tag}>`].join(
25807
+ "\n"
25808
+ );
25809
+ }
25810
+ function stableRepository(repository) {
25811
+ const { checkout: _checkout, problem: _problem, action: _action, ...rest } = repository;
25812
+ return rest;
25813
+ }
25814
+ function commandPreview(command) {
25815
+ if (command === null || command.length <= COMMAND_PREVIEW_CHARS) return command;
25816
+ const lines = command.split("\n").length;
25817
+ return `${command.slice(0, COMMAND_PREVIEW_CHARS)}\u2026 (${lines} lines; get_cloud_machine has the full command)`;
25818
+ }
25819
+ function withCommandPreviews(environment) {
25820
+ return {
25821
+ ...environment,
25822
+ ...environment.installCommand !== void 0 ? { installCommand: commandPreview(environment.installCommand) } : {},
25823
+ ...environment.startCommand !== void 0 ? { startCommand: commandPreview(environment.startCommand) } : {}
25824
+ };
25825
+ }
25826
+ function changed(a, b) {
25827
+ return JSON.stringify(a) !== JSON.stringify(b);
25828
+ }
25829
+ function environmentUpdate(previous, next) {
25830
+ if (!next) return void 0;
25831
+ const { start: previousStart, ...previousFacts } = previous ?? {};
25832
+ const { start, ...facts } = next;
25833
+ if (changed(previousFacts, facts)) return next;
25834
+ return start?.state === "failed" && changed(previousStart, start) ? { start } : void 0;
25835
+ }
25836
+ function updateBody(previous, next) {
25837
+ const known = new Set(previous.instructions);
25838
+ const instructions = next.instructions.filter((line) => !known.has(line));
25839
+ const before = new Map(
25840
+ previous.workspace.repositories.map((repository) => [
25841
+ repository.path,
25842
+ stableRepository(repository)
25843
+ ])
25844
+ );
25845
+ const repositories2 = next.workspace.repositories.map(stableRepository).filter(
25846
+ (repository) => repository.path !== void 0 && changed(before.get(repository.path), repository)
25847
+ );
25848
+ const environment = environmentUpdate(previous.environment, next.environment);
25849
+ const facts = {
25850
+ ...changed(previous.task, next.task) && next.task ? { task: next.task } : {},
25851
+ ...changed(previous.pullRequest, next.pullRequest) && next.pullRequest ? { pullRequest: next.pullRequest } : {},
25852
+ ...repositories2.length > 0 ? { workspace: { repositories: repositories2 } } : {},
25853
+ ...environment ? { environment: withCommandPreviews(environment) } : {},
25854
+ ...instructions.length > 0 ? { instructions } : {}
25855
+ };
25856
+ if (Object.keys(facts).length === 0) return void 0;
25857
+ return next.session.trigger === "user" ? facts : { session: { trigger: next.session.trigger }, ...facts };
25858
+ }
25859
+ function renderAgentContext(snapshot2, previous) {
25860
+ const full = block("alan_agent_context", {
25861
+ ...snapshot2,
25862
+ ...snapshot2.environment ? { environment: withCommandPreviews(snapshot2.environment) } : {},
25863
+ instructions: [...startingInstructions(snapshot2), ...snapshot2.instructions]
25864
+ });
25865
+ const update = previous ? updateBody(previous, snapshot2) : void 0;
25866
+ return {
25867
+ snapshot: snapshot2,
25868
+ full,
25869
+ ...update ? { update: block("alan_agent_context_update", update) } : {}
25870
+ };
25871
+ }
25558
25872
  function truncate(value, limit) {
25559
25873
  const normalized2 = Array.from(value, (character) => {
25560
25874
  const code = character.charCodeAt(0);
@@ -25813,11 +26127,12 @@ function cloudExecutionSection(spec) {
25813
26127
  if (spec.sandboxId) lines.push(`Sandbox ID: ${spec.sandboxId}.`);
25814
26128
  if (spec.cloudEnvironmentId) lines.push(`Cloud environment ID: ${spec.cloudEnvironmentId}.`);
25815
26129
  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."
26130
+ "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.",
26131
+ "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
26132
  );
25818
26133
  if (!isReadOnlyMode(spec.mode) && !isReadOnlyAgent(spec.agentId)) {
25819
26134
  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, check the repository's setup instructions and configured start commands, 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."
26135
+ "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
26136
  );
25822
26137
  }
25823
26138
  const skills = spec.promptContext?.availableSkills ?? [];
@@ -25914,11 +26229,71 @@ function buildTurnText(input2) {
25914
26229
  ${body}` : body;
25915
26230
  return spec.mode === "plan" ? planModePrefix(prefixed) : prefixed;
25916
26231
  }
25917
- var MAX_PARSED_ATTACHMENTS, MAX_PARSED_ATTACHMENT_CHARS, MAX_METADATA_CHARS, UNAVAILABLE, READ_ONLY_MODES, AGENT_MODES;
25918
- var init_chunk_FPGAN4XO = __esm({
25919
- "../agent-core/dist/chunk-FPGAN4XO.js"() {
26232
+ 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;
26233
+ var init_chunk_GI3ZGXTY = __esm({
26234
+ "../agent-core/dist/chunk-GI3ZGXTY.js"() {
25920
26235
  "use strict";
26236
+ init_runtime_v2();
26237
+ init_zod();
25921
26238
  init_agent2();
26239
+ startCommandStateSchema = external_exports.discriminatedUnion("state", [
26240
+ external_exports.object({ state: external_exports.literal("not_configured") }),
26241
+ external_exports.object({ state: external_exports.literal("pending") }),
26242
+ external_exports.object({ state: external_exports.literal("running") }),
26243
+ external_exports.object({ state: external_exports.literal("exited_ok") }),
26244
+ external_exports.object({ state: external_exports.literal("failed"), exitCode: external_exports.number().int() })
26245
+ ]);
26246
+ repositorySnapshotSchema = external_exports.object({
26247
+ path: external_exports.string(),
26248
+ name: external_exports.string().optional(),
26249
+ url: external_exports.string().optional(),
26250
+ branch: external_exports.string().optional(),
26251
+ branchSource: agentBranchSourceSchema.optional(),
26252
+ base: external_exports.string().optional(),
26253
+ checkout: external_exports.enum(["ok", "needs_attention"]),
26254
+ problem: external_exports.string().optional(),
26255
+ action: external_exports.string().optional()
26256
+ });
26257
+ environmentSnapshotSchema = external_exports.object({
26258
+ id: external_exports.string(),
26259
+ name: external_exports.string(),
26260
+ installCommand: external_exports.string().nullable(),
26261
+ startCommand: external_exports.string().nullable(),
26262
+ imageBuildId: external_exports.string().nullable(),
26263
+ pendingBuild: agentContextBuildSchema.optional(),
26264
+ variables: external_exports.array(external_exports.string()),
26265
+ start: external_exports.intersection(startCommandStateSchema, external_exports.object({ log: external_exports.string().optional() })).optional()
26266
+ });
26267
+ agentContextSnapshotSchema = external_exports.object({
26268
+ session: external_exports.object({
26269
+ kind: agentSessionKindSchema,
26270
+ trigger: agentTurnTriggerSchema,
26271
+ conversationId: external_exports.string(),
26272
+ runId: external_exports.string(),
26273
+ teamId: external_exports.string().optional(),
26274
+ taskId: external_exports.string().optional(),
26275
+ workflowExecutionId: external_exports.string().optional(),
26276
+ organizationId: external_exports.string().optional()
26277
+ }),
26278
+ task: external_exports.object({ workingBranch: external_exports.string() }).optional(),
26279
+ pullRequest: agentContextPullRequestSchema.optional(),
26280
+ workspace: external_exports.object({
26281
+ root: external_exports.string().optional(),
26282
+ cwd: external_exports.string().optional(),
26283
+ repositories: external_exports.array(repositorySnapshotSchema)
26284
+ }),
26285
+ environment: environmentSnapshotSchema.optional(),
26286
+ instructions: external_exports.array(external_exports.string())
26287
+ });
26288
+ BRANCH_REASONS = {
26289
+ handoff: "the branch handed off from the user's computer",
26290
+ pull_request: "this pull request's branch",
26291
+ task: "this task's branch",
26292
+ chat_selection: "the branch the user selected for this chat",
26293
+ environment_default: "the environment's default branch"
26294
+ };
26295
+ PLAIN_SCALAR = /^[A-Za-z0-9_./@~+-][A-Za-z0-9_./@~+:-]*$/;
26296
+ COMMAND_PREVIEW_CHARS = 200;
25922
26297
  MAX_PARSED_ATTACHMENTS = 3;
25923
26298
  MAX_PARSED_ATTACHMENT_CHARS = 12e3;
25924
26299
  MAX_METADATA_CHARS = 240;
@@ -26356,16 +26731,16 @@ function parseClaudeEvent(event, state) {
26356
26731
  }
26357
26732
  function thoughtsOf(event, content, messageId, state) {
26358
26733
  const texts = content.flatMap((raw) => {
26359
- const block = asRecord(raw);
26360
- if (!block || asString(block.type) !== "thinking") return [];
26361
- return [asString(block.thinking) || asString(block.text)];
26734
+ const block2 = asRecord(raw);
26735
+ if (!block2 || asString(block2.type) !== "thinking") return [];
26736
+ return [asString(block2.thinking) || asString(block2.text)];
26362
26737
  });
26363
26738
  if (texts.length === 0) return [];
26364
26739
  const frameId = asString(event.uuid) || synthId(state, "claude-thought-frame");
26365
26740
  return thoughtBlocksFor(state, messageId).complete(frameId, texts);
26366
26741
  }
26367
- function textUpdates(frame, block) {
26368
- const text2 = asString(block.text);
26742
+ function textUpdates(frame, block2) {
26743
+ const text2 = asString(block2.text);
26369
26744
  if (!text2 || frame.alreadyStreamed) return [];
26370
26745
  const content = textBlock(frame.previousBlockWasText ? `
26371
26746
  ${text2}` : text2);
@@ -26386,12 +26761,12 @@ function thoughtUpdates(frame) {
26386
26761
  }
26387
26762
  ];
26388
26763
  }
26389
- function blockUpdates(frame, block) {
26390
- const blockType = asString(block.type);
26391
- if (blockType === "text") return textUpdates(frame, block);
26764
+ function blockUpdates(frame, block2) {
26765
+ const blockType = asString(block2.type);
26766
+ if (blockType === "text") return textUpdates(frame, block2);
26392
26767
  frame.previousBlockWasText = false;
26393
26768
  if (blockType === "thinking") return thoughtUpdates(frame);
26394
- if (blockType === "tool_use") return parseToolUse(block, frame.meta);
26769
+ if (blockType === "tool_use") return parseToolUse(block2, frame.meta);
26395
26770
  return [];
26396
26771
  }
26397
26772
  function parseAssistant(event, state) {
@@ -26409,8 +26784,8 @@ function parseAssistant(event, state) {
26409
26784
  previousBlockWasText: false
26410
26785
  };
26411
26786
  return content.flatMap((raw) => {
26412
- const block = asRecord(raw);
26413
- return block ? blockUpdates(frame, block) : [];
26787
+ const block2 = asRecord(raw);
26788
+ return block2 ? blockUpdates(frame, block2) : [];
26414
26789
  });
26415
26790
  }
26416
26791
  function toolUseMeta(name, input2, meta3) {
@@ -26423,11 +26798,11 @@ function toolUseMeta(name, input2, meta3) {
26423
26798
  ...!isAsk && normalizeToolName2(name) === "exitplanmode" ? { [EXIT_PLAN_MODE_INPUT_META]: input2 } : {}
26424
26799
  };
26425
26800
  }
26426
- function parseToolUse(block, meta3) {
26427
- const toolCallId = asString(block.id);
26801
+ function parseToolUse(block2, meta3) {
26802
+ const toolCallId = asString(block2.id);
26428
26803
  if (!toolCallId) return [];
26429
- const name = canonicalizeManagedMcpToolName(asString(block.name));
26430
- const input2 = block.input;
26804
+ const name = canonicalizeManagedMcpToolName(asString(block2.name));
26805
+ const input2 = block2.input;
26431
26806
  const inputRecord = asRecord(input2) ?? {};
26432
26807
  const pendingFileChange = claudeToolInputDiffContent(name, input2);
26433
26808
  const updates = [
@@ -26469,21 +26844,21 @@ function parseUser(event) {
26469
26844
  if (!message) return [];
26470
26845
  const meta3 = nesting(event);
26471
26846
  return asArray(message.content).flatMap((raw) => {
26472
- const block = asRecord(raw);
26473
- if (!block || asString(block.type) !== "tool_result") return [];
26474
- const toolCallId = asString(block.tool_use_id);
26847
+ const block2 = asRecord(raw);
26848
+ if (!block2 || asString(block2.type) !== "tool_result") return [];
26849
+ const toolCallId = asString(block2.tool_use_id);
26475
26850
  if (!toolCallId) return [];
26476
- const text2 = flattenToolResult(block.content);
26851
+ const text2 = flattenToolResult(block2.content);
26477
26852
  const content = outputContent(text2);
26478
26853
  const diffs = claudeFileChangeContents(event.tool_use_result);
26479
26854
  return [
26480
26855
  {
26481
26856
  sessionUpdate: "tool_call_update",
26482
26857
  toolCallId,
26483
- status: block.is_error === true ? "failed" : "completed",
26858
+ status: block2.is_error === true ? "failed" : "completed",
26484
26859
  ...content || diffs.length ? { content: [...diffs, ...content ?? []] } : {},
26485
26860
  rawOutput: text2,
26486
- _meta: { ...meta3._meta, [PROVIDER_PAYLOAD_META]: event.tool_use_result ?? block }
26861
+ _meta: { ...meta3._meta, [PROVIDER_PAYLOAD_META]: event.tool_use_result ?? block2 }
26487
26862
  }
26488
26863
  ];
26489
26864
  });
@@ -27002,7 +27377,7 @@ var init_claude = __esm({
27002
27377
  init_chunk_HBIPWAUI();
27003
27378
  init_chunk_J2KTV5FP();
27004
27379
  init_chunk_M6YHY2EZ();
27005
- init_chunk_FPGAN4XO();
27380
+ init_chunk_GI3ZGXTY();
27006
27381
  init_chunk_YXWJW7I5();
27007
27382
  init_effort();
27008
27383
  import_crypto6 = require("crypto");
@@ -27525,11 +27900,11 @@ var init_claude = __esm({
27525
27900
  }
27526
27901
  this.#iterations += 1;
27527
27902
  for (const raw of asArray(asRecord(event.message)?.content)) {
27528
- const block = asRecord(raw);
27529
- if (!block || asString(block.type) !== "tool_use") continue;
27530
- const id = asString(block.id);
27903
+ const block2 = asRecord(raw);
27904
+ if (!block2 || asString(block2.type) !== "tool_use") continue;
27905
+ const id = asString(block2.id);
27531
27906
  if (!id) continue;
27532
- const name = canonicalizeManagedMcpToolName(asString(block.name));
27907
+ const name = canonicalizeManagedMcpToolName(asString(block2.name));
27533
27908
  if (isInteractiveToolName(name) || INTERACTIVE_TOOL_NAMES.has(normalizeToolName2(name))) {
27534
27909
  this.#suppressedResults.add(id);
27535
27910
  }
@@ -29217,7 +29592,7 @@ var init_codex = __esm({
29217
29592
  init_chunk_HBIPWAUI();
29218
29593
  init_chunk_J2KTV5FP();
29219
29594
  init_chunk_M6YHY2EZ();
29220
- init_chunk_FPGAN4XO();
29595
+ init_chunk_GI3ZGXTY();
29221
29596
  init_chunk_YXWJW7I5();
29222
29597
  import_fs6 = require("fs");
29223
29598
  import_path6 = require("path");
@@ -30732,7 +31107,7 @@ var require_identity = __commonJS({
30732
31107
  var isDocument = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === DOC;
30733
31108
  var isMap = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === MAP;
30734
31109
  var isPair = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === PAIR;
30735
- var isScalar = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === SCALAR;
31110
+ var isScalar2 = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === SCALAR;
30736
31111
  var isSeq = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === SEQ;
30737
31112
  function isCollection(node2) {
30738
31113
  if (node2 && typeof node2 === "object")
@@ -30754,7 +31129,7 @@ var require_identity = __commonJS({
30754
31129
  }
30755
31130
  return false;
30756
31131
  }
30757
- var hasAnchor = (node2) => (isScalar(node2) || isCollection(node2)) && !!node2.anchor;
31132
+ var hasAnchor = (node2) => (isScalar2(node2) || isCollection(node2)) && !!node2.anchor;
30758
31133
  exports2.ALIAS = ALIAS;
30759
31134
  exports2.DOC = DOC;
30760
31135
  exports2.MAP = MAP;
@@ -30769,7 +31144,7 @@ var require_identity = __commonJS({
30769
31144
  exports2.isMap = isMap;
30770
31145
  exports2.isNode = isNode;
30771
31146
  exports2.isPair = isPair;
30772
- exports2.isScalar = isScalar;
31147
+ exports2.isScalar = isScalar2;
30773
31148
  exports2.isSeq = isSeq;
30774
31149
  }
30775
31150
  });
@@ -35125,13 +35500,13 @@ var require_resolve_block_scalar = __commonJS({
35125
35500
  "../../node_modules/yaml/dist/compose/resolve-block-scalar.js"(exports2) {
35126
35501
  "use strict";
35127
35502
  var Scalar = require_Scalar();
35128
- function resolveBlockScalar(ctx, scalar, onError) {
35129
- const start = scalar.offset;
35130
- const header = parseBlockScalarHeader(scalar, ctx.options.strict, onError);
35503
+ function resolveBlockScalar(ctx, scalar2, onError) {
35504
+ const start = scalar2.offset;
35505
+ const header = parseBlockScalarHeader(scalar2, ctx.options.strict, onError);
35131
35506
  if (!header)
35132
35507
  return { value: "", type: null, comment: "", range: [start, start, start] };
35133
35508
  const type = header.mode === ">" ? Scalar.Scalar.BLOCK_FOLDED : Scalar.Scalar.BLOCK_LITERAL;
35134
- const lines = scalar.source ? splitLines(scalar.source) : [];
35509
+ const lines = scalar2.source ? splitLines(scalar2.source) : [];
35135
35510
  let chompStart = lines.length;
35136
35511
  for (let i = lines.length - 1; i >= 0; --i) {
35137
35512
  const content = lines[i][1];
@@ -35143,12 +35518,12 @@ var require_resolve_block_scalar = __commonJS({
35143
35518
  if (chompStart === 0) {
35144
35519
  const value2 = header.chomp === "+" && lines.length > 0 ? "\n".repeat(Math.max(1, lines.length - 1)) : "";
35145
35520
  let end2 = start + header.length;
35146
- if (scalar.source)
35147
- end2 += scalar.source.length;
35521
+ if (scalar2.source)
35522
+ end2 += scalar2.source.length;
35148
35523
  return { value: value2, type, comment: header.comment, range: [start, end2, end2] };
35149
35524
  }
35150
- let trimIndent = scalar.indent + header.indent;
35151
- let offset = scalar.offset + header.length;
35525
+ let trimIndent = scalar2.indent + header.indent;
35526
+ let offset = scalar2.offset + header.length;
35152
35527
  let contentStart = 0;
35153
35528
  for (let i = 0; i < chompStart; ++i) {
35154
35529
  const [indent, content] = lines[i];
@@ -35226,7 +35601,7 @@ var require_resolve_block_scalar = __commonJS({
35226
35601
  default:
35227
35602
  value += "\n";
35228
35603
  }
35229
- const end = start + header.length + scalar.source.length;
35604
+ const end = start + header.length + scalar2.source.length;
35230
35605
  return { value, type, comment: header.comment, range: [start, end, end] };
35231
35606
  }
35232
35607
  function parseBlockScalarHeader({ offset, props }, strict, onError) {
@@ -35309,8 +35684,8 @@ var require_resolve_flow_scalar = __commonJS({
35309
35684
  "use strict";
35310
35685
  var Scalar = require_Scalar();
35311
35686
  var resolveEnd = require_resolve_end();
35312
- function resolveFlowScalar(scalar, strict, onError) {
35313
- const { offset, type, source, end } = scalar;
35687
+ function resolveFlowScalar(scalar2, strict, onError) {
35688
+ const { offset, type, source, end } = scalar2;
35314
35689
  let _type;
35315
35690
  let value;
35316
35691
  const _onError = (rel, code, msg) => onError(offset + rel, code, msg);
@@ -35329,7 +35704,7 @@ var require_resolve_flow_scalar = __commonJS({
35329
35704
  break;
35330
35705
  /* istanbul ignore next should not happen */
35331
35706
  default:
35332
- onError(scalar, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${type}`);
35707
+ onError(scalar2, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${type}`);
35333
35708
  return {
35334
35709
  value: "",
35335
35710
  type: null,
@@ -35543,26 +35918,26 @@ var require_compose_scalar = __commonJS({
35543
35918
  tag = findScalarTagByTest(ctx, value, token, onError);
35544
35919
  else
35545
35920
  tag = ctx.schema[identity.SCALAR];
35546
- let scalar;
35921
+ let scalar2;
35547
35922
  try {
35548
35923
  const res = tag.resolve(value, (msg) => onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg), ctx.options);
35549
- scalar = identity.isScalar(res) ? res : new Scalar.Scalar(res);
35924
+ scalar2 = identity.isScalar(res) ? res : new Scalar.Scalar(res);
35550
35925
  } catch (error61) {
35551
35926
  const msg = error61 instanceof Error ? error61.message : String(error61);
35552
35927
  onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg);
35553
- scalar = new Scalar.Scalar(value);
35928
+ scalar2 = new Scalar.Scalar(value);
35554
35929
  }
35555
- scalar.range = range;
35556
- scalar.source = value;
35930
+ scalar2.range = range;
35931
+ scalar2.source = value;
35557
35932
  if (type)
35558
- scalar.type = type;
35933
+ scalar2.type = type;
35559
35934
  if (tagName)
35560
- scalar.tag = tagName;
35935
+ scalar2.tag = tagName;
35561
35936
  if (tag.format)
35562
- scalar.format = tag.format;
35937
+ scalar2.format = tag.format;
35563
35938
  if (comment)
35564
- scalar.comment = comment;
35565
- return scalar;
35939
+ scalar2.comment = comment;
35940
+ return scalar2;
35566
35941
  }
35567
35942
  function findScalarTagByName(schema, value, tagName, tagToken, onError) {
35568
35943
  if (tagName === "!")
@@ -36311,7 +36686,7 @@ var require_cst = __commonJS({
36311
36686
  var FLOW_END = "";
36312
36687
  var SCALAR = "";
36313
36688
  var isCollection = (token) => !!token && "items" in token;
36314
- var isScalar = (token) => !!token && (token.type === "scalar" || token.type === "single-quoted-scalar" || token.type === "double-quoted-scalar" || token.type === "block-scalar");
36689
+ var isScalar2 = (token) => !!token && (token.type === "scalar" || token.type === "single-quoted-scalar" || token.type === "double-quoted-scalar" || token.type === "block-scalar");
36315
36690
  function prettyToken(token) {
36316
36691
  switch (token) {
36317
36692
  case BOM:
@@ -36395,7 +36770,7 @@ var require_cst = __commonJS({
36395
36770
  exports2.FLOW_END = FLOW_END;
36396
36771
  exports2.SCALAR = SCALAR;
36397
36772
  exports2.isCollection = isCollection;
36398
- exports2.isScalar = isScalar;
36773
+ exports2.isScalar = isScalar2;
36399
36774
  exports2.prettyToken = prettyToken;
36400
36775
  exports2.tokenType = tokenType;
36401
36776
  }
@@ -37390,37 +37765,37 @@ var require_parser = __commonJS({
37390
37765
  };
37391
37766
  }
37392
37767
  }
37393
- *scalar(scalar) {
37768
+ *scalar(scalar2) {
37394
37769
  if (this.type === "map-value-ind") {
37395
37770
  const prev = getPrevProps(this.peek(2));
37396
37771
  const start = getFirstKeyStartProps(prev);
37397
37772
  let sep4;
37398
- if (scalar.end) {
37399
- sep4 = scalar.end;
37773
+ if (scalar2.end) {
37774
+ sep4 = scalar2.end;
37400
37775
  sep4.push(this.sourceToken);
37401
- delete scalar.end;
37776
+ delete scalar2.end;
37402
37777
  } else
37403
37778
  sep4 = [this.sourceToken];
37404
37779
  const map2 = {
37405
37780
  type: "block-map",
37406
- offset: scalar.offset,
37407
- indent: scalar.indent,
37408
- items: [{ start, key: scalar, sep: sep4 }]
37781
+ offset: scalar2.offset,
37782
+ indent: scalar2.indent,
37783
+ items: [{ start, key: scalar2, sep: sep4 }]
37409
37784
  };
37410
37785
  this.onKeyLine = true;
37411
37786
  this.stack[this.stack.length - 1] = map2;
37412
37787
  } else
37413
- yield* this.lineEnd(scalar);
37788
+ yield* this.lineEnd(scalar2);
37414
37789
  }
37415
- *blockScalar(scalar) {
37790
+ *blockScalar(scalar2) {
37416
37791
  switch (this.type) {
37417
37792
  case "space":
37418
37793
  case "comment":
37419
37794
  case "newline":
37420
- scalar.props.push(this.sourceToken);
37795
+ scalar2.props.push(this.sourceToken);
37421
37796
  return;
37422
37797
  case "scalar":
37423
- scalar.source = this.source;
37798
+ scalar2.source = this.source;
37424
37799
  this.atNewLine = true;
37425
37800
  this.indent = 0;
37426
37801
  if (this.onNewLine) {
@@ -38276,8 +38651,8 @@ function refusal(error61, displayName) {
38276
38651
  return failure2("failed", String(error61));
38277
38652
  }
38278
38653
  function toolResultText(update) {
38279
- const texts = (update.content ?? []).flatMap((block) => {
38280
- const text2 = asString(asRecord(asRecord(block)?.content)?.text);
38654
+ const texts = (update.content ?? []).flatMap((block2) => {
38655
+ const text2 = asString(asRecord(asRecord(block2)?.content)?.text);
38281
38656
  return text2 ? [text2] : [];
38282
38657
  });
38283
38658
  if (typeof update.rawOutput === "string" && update.rawOutput) texts.push(update.rawOutput);
@@ -38373,11 +38748,11 @@ function isStopReason(value) {
38373
38748
  function v2ToolContent(content) {
38374
38749
  if (!Array.isArray(content)) return void 0;
38375
38750
  return content.map((item) => {
38376
- const block = asRecord(item);
38377
- if (!block || asString(block.type) !== "diff" || asRecord(block.diff)) return item;
38378
- const path = asString(block.path);
38379
- const oldText = typeof block.oldText === "string" ? block.oldText : null;
38380
- const newText = typeof block.newText === "string" ? block.newText : null;
38751
+ const block2 = asRecord(item);
38752
+ if (!block2 || asString(block2.type) !== "diff" || asRecord(block2.diff)) return item;
38753
+ const path = asString(block2.path);
38754
+ const oldText = typeof block2.oldText === "string" ? block2.oldText : null;
38755
+ const newText = typeof block2.newText === "string" ? block2.newText : null;
38381
38756
  const operation = oldText === null ? "add" : newText === null ? "delete" : "modify";
38382
38757
  return {
38383
38758
  type: "diff",
@@ -38800,7 +39175,7 @@ var init_acp3 = __esm({
38800
39175
  init_chunk_HBIPWAUI();
38801
39176
  init_chunk_J2KTV5FP();
38802
39177
  init_chunk_M6YHY2EZ();
38803
- init_chunk_FPGAN4XO();
39178
+ init_chunk_GI3ZGXTY();
38804
39179
  init_chunk_YXWJW7I5();
38805
39180
  import_promises24 = require("fs/promises");
38806
39181
  import_path9 = require("path");
@@ -39627,6 +40002,9 @@ var init_driver = __esm({
39627
40002
  });
39628
40003
 
39629
40004
  // src/holder/drivers/persistent.ts
40005
+ function sessionContextFor(opened, inputs) {
40006
+ return opened.fresh ? inputs.agentContext?.full : inputs.agentContext?.update;
40007
+ }
39630
40008
  function errorMessage(error61) {
39631
40009
  return error61 instanceof Error ? error61.message : String(error61);
39632
40010
  }
@@ -39682,14 +40060,14 @@ function createPersistentDriver(provider4, options) {
39682
40060
  const resumeNotice = (spec, session, sink) => {
39683
40061
  if (spec.resumeFallbackContext) {
39684
40062
  log.info("holder.session_resume_fallback", { harness: provider4.harness, runId: spec.runId });
39685
- return { session, contextPrefix: spec.resumeFallbackContext };
40063
+ return { session, fresh: true, contextPrefix: spec.resumeFallbackContext };
39686
40064
  }
39687
40065
  sink.onEvent({
39688
40066
  seq: 0,
39689
40067
  at: clock.now(),
39690
40068
  update: noticeUpdate("warning", "session_resume_failed", RESUME_UNAVAILABLE)
39691
40069
  });
39692
- return { session };
40070
+ return { session, fresh: true };
39693
40071
  };
39694
40072
  const managedMcpAccess = async (signal) => {
39695
40073
  const managed = options.managedMcp;
@@ -39700,7 +40078,7 @@ function createPersistentDriver(provider4, options) {
39700
40078
  const ensureSession = async (spec, inputs, sink, managedMcp) => {
39701
40079
  const wanted = provider4.plan(spec, inputs, void 0, managedMcp);
39702
40080
  const reused = await reuseLive(spec, wanted.key);
39703
- if (reused) return { session: reused };
40081
+ if (reused) return { session: reused, fresh: false };
39704
40082
  const requested = live.providerSessionId ?? spec.providerSessionId;
39705
40083
  const resumeId = requested !== void 0 && requested !== live.rejectedSessionId && provider4.canResume(wanted, requested) ? requested : void 0;
39706
40084
  const planned = provider4.plan(spec, inputs, resumeId, managedMcp);
@@ -39719,7 +40097,7 @@ function createPersistentDriver(provider4, options) {
39719
40097
  requested
39720
40098
  });
39721
40099
  const resumed = resumeId !== void 0 && !opened.resumeFailed;
39722
- if (requested === void 0 || resumed) return { session: opened.session };
40100
+ if (requested === void 0 || resumed) return { session: opened.session, fresh: !resumed };
39723
40101
  return resumeNotice(spec, opened.session, sink);
39724
40102
  };
39725
40103
  const runOnSession = async (opened, spec, sink, signal, inputs) => {
@@ -39771,7 +40149,7 @@ function createPersistentDriver(provider4, options) {
39771
40149
  };
39772
40150
  signal.addEventListener("abort", onAbort, { once: true });
39773
40151
  try {
39774
- const contextPrefix = [inputs.turnContext, opened.contextPrefix].filter((part) => part !== void 0).join("\n\n");
40152
+ const contextPrefix = [sessionContextFor(opened, inputs), opened.contextPrefix].filter((part) => part !== void 0).join("\n\n");
39775
40153
  const input2 = await provider4.turnInput(spec, inputs, contextPrefix || void 0);
39776
40154
  if (signal.aborted) return { outcome: "aborted" };
39777
40155
  const result = await session.sendTurn(input2);
@@ -39952,8 +40330,8 @@ var init_acp4 = __esm({
39952
40330
  });
39953
40331
 
39954
40332
  // ../agent-core/dist/providers/opencode.js
39955
- function parseSseBlock(block) {
39956
- const data = block.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");
40333
+ function parseSseBlock(block2) {
40334
+ 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
40335
  if (!data) return void 0;
39958
40336
  let parsed;
39959
40337
  try {
@@ -40537,7 +40915,7 @@ var init_opencode = __esm({
40537
40915
  init_chunk_HBIPWAUI();
40538
40916
  init_chunk_J2KTV5FP();
40539
40917
  init_chunk_M6YHY2EZ();
40540
- init_chunk_FPGAN4XO();
40918
+ init_chunk_GI3ZGXTY();
40541
40919
  init_chunk_YXWJW7I5();
40542
40920
  import_http4 = require("http");
40543
40921
  init_runtime_v2();
@@ -42093,7 +42471,7 @@ function droidToolCall(toolUse) {
42093
42471
  function droidResultText(result) {
42094
42472
  const blocks = asArray(result.content);
42095
42473
  if (blocks.length) {
42096
- return blocks.map((block) => asString(asRecord(block)?.text)).filter(Boolean).join("\n");
42474
+ return blocks.map((block2) => asString(asRecord(block2)?.text)).filter(Boolean).join("\n");
42097
42475
  }
42098
42476
  const value = result.value;
42099
42477
  if (typeof value === "string") return value;
@@ -42357,7 +42735,7 @@ var init_droid = __esm({
42357
42735
  init_chunk_HBIPWAUI();
42358
42736
  init_chunk_J2KTV5FP();
42359
42737
  init_chunk_M6YHY2EZ();
42360
- init_chunk_FPGAN4XO();
42738
+ init_chunk_GI3ZGXTY();
42361
42739
  init_chunk_YXWJW7I5();
42362
42740
  init_runtime_v2();
42363
42741
  import_crypto16 = require("crypto");
@@ -43463,7 +43841,7 @@ var init_antigravity = __esm({
43463
43841
  init_chunk_XC5676SG();
43464
43842
  init_chunk_HBIPWAUI();
43465
43843
  init_chunk_M6YHY2EZ();
43466
- init_chunk_FPGAN4XO();
43844
+ init_chunk_GI3ZGXTY();
43467
43845
  init_chunk_YXWJW7I5();
43468
43846
  import_promises28 = require("fs/promises");
43469
43847
  import_path12 = require("path");
@@ -44168,7 +44546,7 @@ var init_command_code = __esm({
44168
44546
  init_chunk_HBIPWAUI();
44169
44547
  init_chunk_J2KTV5FP();
44170
44548
  init_chunk_M6YHY2EZ();
44171
- init_chunk_FPGAN4XO();
44549
+ init_chunk_GI3ZGXTY();
44172
44550
  init_chunk_YXWJW7I5();
44173
44551
  import_promises29 = require("fs/promises");
44174
44552
  import_path15 = require("path");
@@ -46921,7 +47299,7 @@ function openRepositoryLocks(options) {
46921
47299
 
46922
47300
  // src/cli/config.ts
46923
47301
  var import_node_os7 = require("os");
46924
- var import_node_path32 = require("path");
47302
+ var import_node_path33 = require("path");
46925
47303
  init_zod();
46926
47304
 
46927
47305
  // src/client/locate.ts
@@ -46942,9 +47320,9 @@ function defaultInstallDir({ platform, home, env }) {
46942
47320
 
46943
47321
  // src/sessions/index.ts
46944
47322
  var import_node_crypto16 = require("crypto");
46945
- var import_promises40 = require("fs/promises");
47323
+ var import_promises41 = require("fs/promises");
46946
47324
  var import_node_os6 = require("os");
46947
- var import_node_path31 = require("path");
47325
+ var import_node_path32 = require("path");
46948
47326
 
46949
47327
  // src/holder/control-client.ts
46950
47328
  var import_node_crypto12 = require("crypto");
@@ -47258,14 +47636,14 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
47258
47636
  var import_node_crypto15 = require("crypto");
47259
47637
  var import_node_fs11 = require("fs");
47260
47638
  var import_node_net2 = require("net");
47261
- var import_node_path30 = require("path");
47639
+ var import_node_path31 = require("path");
47262
47640
  init_runtime_v2();
47263
47641
 
47264
47642
  // src/holder/admission.ts
47265
47643
  var import_node_fs9 = require("fs");
47266
- var import_promises36 = require("fs/promises");
47644
+ var import_promises37 = require("fs/promises");
47267
47645
  var import_node_os5 = require("os");
47268
- var import_node_path26 = require("path");
47646
+ var import_node_path27 = require("path");
47269
47647
  init_constants();
47270
47648
 
47271
47649
  // ../shared/dist/node/local-workspace.js
@@ -47348,29 +47726,79 @@ async function discoverRelocatedWorkspace(search) {
47348
47726
  return matches[0] ?? null;
47349
47727
  }
47350
47728
 
47729
+ // src/holder/agent-context.ts
47730
+ var import_promises33 = require("fs/promises");
47731
+ var import_node_path22 = require("path");
47732
+
47733
+ // ../agent-core/dist/prompt.js
47734
+ init_chunk_GI3ZGXTY();
47735
+
47736
+ // src/holder/agent-context.ts
47737
+ async function readText2(path) {
47738
+ return (0, import_promises33.readFile)(path, "utf8").then(
47739
+ (text2) => text2.trim(),
47740
+ () => null
47741
+ );
47742
+ }
47743
+ async function startCommandState(statusPath) {
47744
+ const [status, exit] = await Promise.all([readText2(statusPath), readText2(`${statusPath}.exit`)]);
47745
+ if (status === null || status === "started") return { state: "pending" };
47746
+ const failed = /^failed (\d+)$/.exec(status);
47747
+ if (failed) return { state: "failed", exitCode: Number(failed[1]) };
47748
+ if (exit === null) return { state: "running" };
47749
+ const code = Number(exit);
47750
+ return code === 0 ? { state: "exited_ok" } : { state: "failed", exitCode: code };
47751
+ }
47752
+ function createAgentContext(deps) {
47753
+ const statusPath = (0, import_node_path22.join)(deps.homeDir, ".alan", "start-commands.status");
47754
+ const logPath = (0, import_node_path22.join)(deps.homeDir, ".alan", "start-commands.log");
47755
+ return async (spec, problems) => {
47756
+ const file2 = (0, import_node_path22.join)(deps.dir, `${spec.conversationId}.json`);
47757
+ const saved = await readJsonFile(file2, agentContextSnapshotSchema);
47758
+ const known = saved.kind === "ok" ? saved.value : void 0;
47759
+ const hasEnvironment = (spec.agentContext ?? known)?.environment !== void 0;
47760
+ const start = hasEnvironment ? await startCommandState(statusPath) : void 0;
47761
+ const snapshot2 = agentContextSnapshot({
47762
+ spec,
47763
+ ...spec.approvedWorkspacePaths?.[0] ? { workspaceRoot: spec.approvedWorkspacePaths[0] } : {},
47764
+ problems,
47765
+ ...start ? { start } : {},
47766
+ startLogPath: logPath,
47767
+ ...known ? { known } : {}
47768
+ });
47769
+ if (snapshot2 === null) return void 0;
47770
+ const rendered = renderAgentContext(snapshot2, known);
47771
+ return {
47772
+ full: rendered.full,
47773
+ ...rendered.update ? { update: rendered.update } : {},
47774
+ save: () => writeJsonFileAtomic(file2, snapshot2)
47775
+ };
47776
+ };
47777
+ }
47778
+
47351
47779
  // src/holder/checkout-refresh.ts
47352
- var import_node_path24 = require("path");
47780
+ var import_node_path25 = require("path");
47353
47781
 
47354
47782
  // src/holder/claim-once.ts
47355
47783
  var import_node_crypto14 = require("crypto");
47356
- var import_promises33 = require("fs/promises");
47357
- var import_node_path22 = require("path");
47784
+ var import_promises34 = require("fs/promises");
47785
+ var import_node_path23 = require("path");
47358
47786
  async function claimOnce(dir, name) {
47359
47787
  try {
47360
- await (0, import_promises33.mkdir)(dir, { recursive: true, mode: 448 });
47361
- await (await (0, import_promises33.open)((0, import_node_path22.join)(dir, name), "wx")).close();
47788
+ await (0, import_promises34.mkdir)(dir, { recursive: true, mode: 448 });
47789
+ await (await (0, import_promises34.open)((0, import_node_path23.join)(dir, name), "wx")).close();
47362
47790
  return true;
47363
47791
  } catch {
47364
47792
  return false;
47365
47793
  }
47366
47794
  }
47367
47795
  function claimFirstLease(freshnessDir, path) {
47368
- return claimOnce((0, import_node_path22.join)(freshnessDir, "leased"), (0, import_node_crypto14.createHash)("sha256").update(path).digest("hex"));
47796
+ return claimOnce((0, import_node_path23.join)(freshnessDir, "leased"), (0, import_node_crypto14.createHash)("sha256").update(path).digest("hex"));
47369
47797
  }
47370
47798
 
47371
47799
  // src/holder/requested-checkout.ts
47372
- var import_promises34 = require("fs/promises");
47373
- var import_node_path23 = require("path");
47800
+ var import_promises35 = require("fs/promises");
47801
+ var import_node_path24 = require("path");
47374
47802
  var REMOTE2 = "origin";
47375
47803
  var REASON_MAX_CHARS = 200;
47376
47804
  function firstLine2(text2) {
@@ -47379,24 +47807,20 @@ function firstLine2(text2) {
47379
47807
  function reasonOf(output2, command) {
47380
47808
  return firstLine2(output2.stderr) || `git ${command} exited ${output2.exitCode}`;
47381
47809
  }
47382
- function noted(checkout, situation, reason, action) {
47383
- return {
47384
- kind: "noted",
47385
- line: `Note: ${checkout.path} ${situation}: ${reason}. ${action} before relying on its files.`
47386
- };
47810
+ function noted(situation, reason, action) {
47811
+ return { kind: "noted", problem: `${situation}: ${reason}`, action };
47387
47812
  }
47388
47813
  function notSwitched(checkout, current, reason) {
47389
47814
  const on = current ?? "a detached HEAD";
47390
47815
  return noted(
47391
- checkout,
47392
47816
  `is on ${on}, not ${checkout.branch}, the branch picked for this chat`,
47393
47817
  reason,
47394
47818
  `Switch it to ${checkout.branch}`
47395
47819
  );
47396
47820
  }
47397
47821
  async function clone2(checkout, deps, signal) {
47398
- const parent = (0, import_node_path23.dirname)(checkout.path);
47399
- await (0, import_promises34.mkdir)(parent, { recursive: true });
47822
+ const parent = (0, import_node_path24.dirname)(checkout.path);
47823
+ await (0, import_promises35.mkdir)(parent, { recursive: true });
47400
47824
  await assertValidBranch(deps.git, parent, checkout.branch, signal);
47401
47825
  const output2 = await deps.git.run(
47402
47826
  {
@@ -47418,7 +47842,6 @@ async function clone2(checkout, deps, signal) {
47418
47842
  );
47419
47843
  if (output2.exitCode === 0) return { kind: "moved", how: "cloned" };
47420
47844
  return noted(
47421
- checkout,
47422
47845
  `is missing, and cloning it on ${checkout.branch}, the branch picked for this chat, failed`,
47423
47846
  reasonOf(output2, "clone"),
47424
47847
  `Clone ${checkout.repoUrl} there`
@@ -47480,7 +47903,6 @@ async function moveOnto(checkout, git, tip, current) {
47480
47903
  if (localHead === tip) return SWITCHED;
47481
47904
  const merged = await git(["merge", "--quiet", "--ff-only", tip]);
47482
47905
  return merged.exitCode === 0 ? SWITCHED : noted(
47483
- checkout,
47484
47906
  `is on ${branch} but behind ${REMOTE2}/${branch}`,
47485
47907
  reasonOf(merged, "merge"),
47486
47908
  "Run `git pull --ff-only` there"
@@ -47539,7 +47961,6 @@ async function applyRequestedCheckout(checkout, spec, deps, signal) {
47539
47961
  return await switchTo(checkout, status.branch, `checkout-${spec.runId}`, deps, signal);
47540
47962
  } catch (error61) {
47541
47963
  return noted(
47542
- checkout,
47543
47964
  `could not be put on ${checkout.branch}, the branch picked for this chat`,
47544
47965
  firstLine2(error61 instanceof Error ? error61.message : String(error61)) || "unknown error",
47545
47966
  "Check it"
@@ -47551,11 +47972,15 @@ async function applyRequestedCheckout(checkout, spec, deps, signal) {
47551
47972
  function short(sha) {
47552
47973
  return sha.slice(0, 12);
47553
47974
  }
47554
- function staleLine(path, snapshot2, tip) {
47975
+ function staleCheckout(path, snapshot2, tip) {
47555
47976
  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
47977
  const base = snapshot2 === void 0 ? "its upstream" : `origin/${snapshot2.base}`;
47557
47978
  const remote = tip === void 0 ? "may be ahead" : `is ahead at ${short(tip)}`;
47558
- return `Note: ${path} ${checkout}; ${base} ${remote}. Run \`git pull --ff-only\` there before relying on its files.`;
47979
+ return {
47980
+ path,
47981
+ problem: `${checkout}; ${base} ${remote}`,
47982
+ action: "Run `git pull --ff-only` there"
47983
+ };
47559
47984
  }
47560
47985
  async function fastForward(freshness, operationId, deps, signal) {
47561
47986
  var _stack = [];
@@ -47593,14 +48018,14 @@ async function atFirstLease(freshness, spec, deps, signal) {
47593
48018
  return first && freshness.fetched && await fastForward(freshness, `refresh-${spec.runId}`, deps, signal) ? "moved" : "noted";
47594
48019
  }
47595
48020
  }
47596
- function lineFor(freshness) {
48021
+ function problemFor(freshness) {
47597
48022
  switch (freshness.state) {
47598
48023
  case "behind":
47599
- return staleLine(freshness.path, freshness.snapshot, freshness.tip);
48024
+ return staleCheckout(freshness.path, freshness.snapshot, freshness.tip);
47600
48025
  case "failed":
47601
- return staleLine(freshness.path, freshness.snapshot);
48026
+ return staleCheckout(freshness.path, freshness.snapshot);
47602
48027
  default:
47603
- return staleLine(freshness.path, void 0);
48028
+ return staleCheckout(freshness.path, void 0);
47604
48029
  }
47605
48030
  }
47606
48031
  async function checkoutsOf(spec, leaseTargets) {
@@ -47622,7 +48047,7 @@ function requestedCheckoutsOf(spec, log) {
47622
48047
  }
47623
48048
  async function applyRequestedCheckouts(spec, deps, signal) {
47624
48049
  const settled2 = /* @__PURE__ */ new Set();
47625
- const lines = [];
48050
+ const problems = [];
47626
48051
  for (const checkout of requestedCheckoutsOf(spec, deps.log)) {
47627
48052
  const outcome2 = await applyRequestedCheckout(checkout, spec, deps, signal);
47628
48053
  deps.log.info("workspace.requested_checkout", {
@@ -47633,21 +48058,23 @@ async function applyRequestedCheckouts(spec, deps, signal) {
47633
48058
  ...outcome2.kind === "moved" ? { how: outcome2.how } : {}
47634
48059
  });
47635
48060
  if (outcome2.kind === "on_branch") continue;
47636
- settled2.add((0, import_node_path24.resolve)(checkout.path));
47637
- if (outcome2.kind === "noted") lines.push(outcome2.line);
48061
+ settled2.add((0, import_node_path25.resolve)(checkout.path));
48062
+ if (outcome2.kind === "noted") {
48063
+ problems.push({ path: checkout.path, problem: outcome2.problem, action: outcome2.action });
48064
+ }
47638
48065
  }
47639
- return { settled: settled2, lines };
48066
+ return { settled: settled2, problems };
47640
48067
  }
47641
48068
  async function refreshSnapshotCheckouts(spec, targets, settled2, deps, signal) {
47642
- const lines = [];
48069
+ const problems = [];
47643
48070
  for (const target of targets) {
47644
- if (settled2.has((0, import_node_path24.resolve)(target))) continue;
48071
+ if (settled2.has((0, import_node_path25.resolve)(target))) continue;
47645
48072
  const freshness = await readCheckoutFreshness(deps.dir, target);
47646
48073
  if (freshness === null) continue;
47647
48074
  const outcome2 = await atFirstLease(freshness, spec, deps, signal).catch(
47648
48075
  () => "noted"
47649
48076
  );
47650
- if (outcome2 === "noted") lines.push(lineFor(freshness));
48077
+ if (outcome2 === "noted") problems.push(problemFor(freshness));
47651
48078
  deps.log.info("workspace.refresh", {
47652
48079
  runId: spec.runId,
47653
48080
  path: freshness.path,
@@ -47655,25 +48082,24 @@ async function refreshSnapshotCheckouts(spec, targets, settled2, deps, signal) {
47655
48082
  outcome: outcome2
47656
48083
  });
47657
48084
  }
47658
- return lines;
48085
+ return problems;
47659
48086
  }
47660
48087
  function createCheckoutRefresh(deps) {
47661
48088
  return async (spec, leaseTargets, signal) => {
47662
- if (spec.providerSessionId !== void 0) return void 0;
47663
- if (!await claimOnce((0, import_node_path24.join)(deps.dir, "conversations"), spec.conversationId)) return void 0;
48089
+ if (spec.providerSessionId !== void 0) return [];
48090
+ if (!await claimOnce((0, import_node_path25.join)(deps.dir, "conversations"), spec.conversationId)) return [];
47664
48091
  const requested = await applyRequestedCheckouts(spec, deps, signal);
47665
48092
  const targets = await checkoutsOf(spec, leaseTargets);
47666
- const lines = [
47667
- ...requested.lines,
48093
+ return [
48094
+ ...requested.problems,
47668
48095
  ...await refreshSnapshotCheckouts(spec, targets, requested.settled, deps, signal)
47669
48096
  ];
47670
- return lines.length === 0 ? void 0 : lines.join("\n");
47671
48097
  };
47672
48098
  }
47673
48099
 
47674
48100
  // src/holder/lease.ts
47675
- var import_promises35 = require("fs/promises");
47676
- var import_node_path25 = require("path");
48101
+ var import_promises36 = require("fs/promises");
48102
+ var import_node_path26 = require("path");
47677
48103
  var LEASE_CHECK_EVERY_MS = 5e3;
47678
48104
  var MAX_TRANSIENT_FAILURES = 3;
47679
48105
  var BACKOFF_BASE_MS = 1e3;
@@ -47687,8 +48113,8 @@ function identityFailure(code, workspacePath) {
47687
48113
  return { code, problemCode: "app.workspace.missing", message: MESSAGES[code], workspacePath };
47688
48114
  }
47689
48115
  async function fileIdentity(path) {
47690
- const canonical = await (0, import_promises35.realpath)(path);
47691
- const info = await (0, import_promises35.stat)(canonical, { bigint: true });
48116
+ const canonical = await (0, import_promises36.realpath)(path);
48117
+ const info = await (0, import_promises36.stat)(canonical, { bigint: true });
47692
48118
  return `${canonical}:${info.dev}:${info.ino}`;
47693
48119
  }
47694
48120
  async function snapshot(git, path, signal) {
@@ -47707,7 +48133,7 @@ async function snapshot(git, path, signal) {
47707
48133
  workspace: await fileIdentity(path),
47708
48134
  repository: await fileIdentity(commonDir),
47709
48135
  worktree: await fileIdentity(gitDir),
47710
- commonDir: await (0, import_promises35.realpath)(commonDir)
48136
+ commonDir: await (0, import_promises36.realpath)(commonDir)
47711
48137
  };
47712
48138
  } catch {
47713
48139
  return null;
@@ -47720,7 +48146,7 @@ async function gitValue(git, path, args, signal) {
47720
48146
  }
47721
48147
  async function pathExists(path) {
47722
48148
  try {
47723
- await (0, import_promises35.stat)(path);
48149
+ await (0, import_promises36.stat)(path);
47724
48150
  return true;
47725
48151
  } catch (error61) {
47726
48152
  return errnoCode(error61) !== "ENOENT" && errnoCode(error61) !== "ENOTDIR";
@@ -47729,19 +48155,19 @@ async function pathExists(path) {
47729
48155
  async function hasGitMarker(path) {
47730
48156
  let directory;
47731
48157
  try {
47732
- directory = await (0, import_promises35.realpath)(path);
48158
+ directory = await (0, import_promises36.realpath)(path);
47733
48159
  } catch {
47734
48160
  return true;
47735
48161
  }
47736
48162
  for (; ; ) {
47737
48163
  try {
47738
- await (0, import_promises35.stat)((0, import_node_path25.join)(directory, ".git"));
48164
+ await (0, import_promises36.stat)((0, import_node_path26.join)(directory, ".git"));
47739
48165
  return true;
47740
48166
  } catch (error61) {
47741
48167
  const code = errnoCode(error61);
47742
48168
  if (code !== "ENOENT" && code !== "ENOTDIR") return true;
47743
48169
  }
47744
- const parent = (0, import_node_path25.dirname)(directory);
48170
+ const parent = (0, import_node_path26.dirname)(directory);
47745
48171
  if (parent === directory) return false;
47746
48172
  directory = parent;
47747
48173
  }
@@ -47905,7 +48331,7 @@ function volumeRoot(path) {
47905
48331
  }
47906
48332
  async function exists(path) {
47907
48333
  try {
47908
- await (0, import_promises36.stat)(path);
48334
+ await (0, import_promises37.stat)(path);
47909
48335
  return true;
47910
48336
  } catch {
47911
48337
  return false;
@@ -47913,10 +48339,10 @@ async function exists(path) {
47913
48339
  }
47914
48340
  async function inspectReadiness(path) {
47915
48341
  try {
47916
- if (!(await (0, import_promises36.stat)(path)).isDirectory()) {
48342
+ if (!(await (0, import_promises37.stat)(path)).isDirectory()) {
47917
48343
  return { ready: false, missing: true, message: MESSAGES2.missing };
47918
48344
  }
47919
- await (0, import_promises36.access)(path, import_node_fs9.constants.R_OK | import_node_fs9.constants.W_OK | import_node_fs9.constants.X_OK);
48345
+ 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
48346
  return { ready: true };
47921
48347
  } catch (error61) {
47922
48348
  const code = errnoCode(error61) ?? "";
@@ -47994,8 +48420,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
47994
48420
  const { env } = context;
47995
48421
  const path = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os5.homedir)());
47996
48422
  try {
47997
- await (0, import_promises36.mkdir)(path, { recursive: true, mode: 448 });
47998
- await (0, import_promises36.access)(path, import_node_fs9.constants.R_OK | import_node_fs9.constants.W_OK | import_node_fs9.constants.X_OK);
48423
+ await (0, import_promises37.mkdir)(path, { recursive: true, mode: 448 });
48424
+ 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
48425
  return {
48000
48426
  kind: "admitted",
48001
48427
  spec: { ...spec, projectPath: path },
@@ -48073,7 +48499,7 @@ var CHECKOUT_NETWORK_TIMEOUT_MS = 12e4;
48073
48499
  function createHolderWorkspace(machine, clock, log) {
48074
48500
  const platform = machine.platform ?? process.platform;
48075
48501
  const git = createGitRunner({ env: machine.env, platform, localTimeoutMs: PROBE_TIMEOUT_MS2 });
48076
- const locks = openRepositoryLocks({ dir: (0, import_node_path26.join)(machine.stateDir, "locks"), clock, platform });
48502
+ const locks = openRepositoryLocks({ dir: (0, import_node_path27.join)(machine.stateDir, "locks"), clock, platform });
48077
48503
  return {
48078
48504
  admission: {
48079
48505
  env: machine.env,
@@ -48085,7 +48511,7 @@ function createHolderWorkspace(machine, clock, log) {
48085
48511
  ),
48086
48512
  approvedRoots: async () => {
48087
48513
  const approved = await openApprovedPaths({
48088
- file: (0, import_node_path26.join)(machine.stateDir, "workspaces.json"),
48514
+ file: (0, import_node_path27.join)(machine.stateDir, "workspaces.json"),
48089
48515
  log,
48090
48516
  platform
48091
48517
  });
@@ -48103,7 +48529,11 @@ function createHolderWorkspace(machine, clock, log) {
48103
48529
  }),
48104
48530
  locks,
48105
48531
  log,
48106
- dir: (0, import_node_path26.join)(machine.stateDir, "checkout-freshness")
48532
+ dir: (0, import_node_path27.join)(machine.stateDir, "checkout-freshness")
48533
+ }),
48534
+ prepareAgentContext: createAgentContext({
48535
+ dir: (0, import_node_path27.join)(machine.stateDir, "agent-context"),
48536
+ homeDir: machine.env.HOME || (0, import_node_os5.homedir)()
48107
48537
  })
48108
48538
  } : {}
48109
48539
  };
@@ -48131,7 +48561,7 @@ async function respondToTurn(runningRunId, gate, driver, request2) {
48131
48561
  }
48132
48562
 
48133
48563
  // src/holder/session-facts.ts
48134
- var import_promises37 = require("fs/promises");
48564
+ var import_promises38 = require("fs/promises");
48135
48565
  var CLI_RSS_CACHE_MS = 1e4;
48136
48566
  var LOGIN_PROBLEM_PREFIX = "cli.auth.";
48137
48567
  function isLoginFailure(result) {
@@ -48157,8 +48587,8 @@ function createSessionFacts(options) {
48157
48587
  const path = await resolveCommandOnPath(command, env, platform);
48158
48588
  if (path === null) return null;
48159
48589
  try {
48160
- const real = await (0, import_promises37.realpath)(path);
48161
- const info = await (0, import_promises37.stat)(real);
48590
+ const real = await (0, import_promises38.realpath)(path);
48591
+ const info = await (0, import_promises38.stat)(real);
48162
48592
  return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
48163
48593
  } catch {
48164
48594
  return null;
@@ -48245,8 +48675,8 @@ function createSessionFacts(options) {
48245
48675
  init_acp2();
48246
48676
 
48247
48677
  // src/run-log/directory.ts
48248
- var import_promises38 = require("fs/promises");
48249
- var import_node_path27 = require("path");
48678
+ var import_promises39 = require("fs/promises");
48679
+ var import_node_path28 = require("path");
48250
48680
  init_runtime_v2();
48251
48681
  init_zod();
48252
48682
  var runMetaSchema = external_exports.object({
@@ -48268,17 +48698,17 @@ var runMetaSchema = external_exports.object({
48268
48698
  }).optional()
48269
48699
  });
48270
48700
  function runDirectory(runsDir, runId) {
48271
- const dir = (0, import_node_path27.join)(runsDir, runId);
48701
+ const dir = (0, import_node_path28.join)(runsDir, runId);
48272
48702
  return {
48273
48703
  dir,
48274
- log: (0, import_node_path27.join)(dir, "log.jsonl"),
48275
- upload: (0, import_node_path27.join)(dir, "upload.json"),
48276
- meta: (0, import_node_path27.join)(dir, "run.json")
48704
+ log: (0, import_node_path28.join)(dir, "log.jsonl"),
48705
+ upload: (0, import_node_path28.join)(dir, "upload.json"),
48706
+ meta: (0, import_node_path28.join)(dir, "run.json")
48277
48707
  };
48278
48708
  }
48279
48709
  async function isRunClaimed(runsDir, runId) {
48280
48710
  try {
48281
- return (await (0, import_promises38.stat)(runDirectory(runsDir, runId).log)).size > 0;
48711
+ return (await (0, import_promises39.stat)(runDirectory(runsDir, runId).log)).size > 0;
48282
48712
  } catch (error61) {
48283
48713
  if (errnoCode(error61) === "ENOENT") return false;
48284
48714
  throw error61;
@@ -48286,8 +48716,8 @@ async function isRunClaimed(runsDir, runId) {
48286
48716
  }
48287
48717
 
48288
48718
  // src/run-log/conversation-index.ts
48289
- var import_promises39 = require("fs/promises");
48290
- var import_node_path28 = require("path");
48719
+ var import_promises40 = require("fs/promises");
48720
+ var import_node_path29 = require("path");
48291
48721
  init_runtime_v2();
48292
48722
  init_zod();
48293
48723
  var ORDINALS_PER_SHARD = 1e3;
@@ -48303,13 +48733,13 @@ var coverageSchema = external_exports.object({
48303
48733
  nextExpectedOrdinal: external_exports.number().int().positive()
48304
48734
  });
48305
48735
  function conversationsDirectory(runsDir) {
48306
- return (0, import_node_path28.join)((0, import_node_path28.dirname)(runsDir), "conversations");
48736
+ return (0, import_node_path29.join)((0, import_node_path29.dirname)(runsDir), "conversations");
48307
48737
  }
48308
48738
  function indexDirectory(runsDir, conversationId) {
48309
- return (0, import_node_path28.join)(conversationsDirectory(runsDir), conversationId, "turn-index");
48739
+ return (0, import_node_path29.join)(conversationsDirectory(runsDir), conversationId, "turn-index");
48310
48740
  }
48311
48741
  function shardPath(runsDir, conversationId, ordinal) {
48312
- return (0, import_node_path28.join)(
48742
+ return (0, import_node_path29.join)(
48313
48743
  indexDirectory(runsDir, conversationId),
48314
48744
  `${Math.floor(ordinal / ORDINALS_PER_SHARD)}.jsonl`
48315
48745
  );
@@ -48318,10 +48748,10 @@ async function indexConversationRun(runsDir, conversationId, ordinal, assistantO
48318
48748
  const nextOrdinal = assistantOrdinal + 1;
48319
48749
  if (nextOrdinal <= ordinal) throw new Error("Assistant order must follow the prompt");
48320
48750
  const path = shardPath(runsDir, conversationId, ordinal);
48321
- await (0, import_promises39.mkdir)((0, import_node_path28.dirname)(path), { recursive: true, mode: 448 });
48322
- await (0, import_promises39.appendFile)(path, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
48751
+ await (0, import_promises40.mkdir)((0, import_node_path29.dirname)(path), { recursive: true, mode: 448 });
48752
+ await (0, import_promises40.appendFile)(path, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
48323
48753
  `, { mode: 384 });
48324
- const coveragePath = (0, import_node_path28.join)((0, import_node_path28.dirname)((0, import_node_path28.dirname)(path)), "coverage.json");
48754
+ const coveragePath = (0, import_node_path29.join)((0, import_node_path29.dirname)((0, import_node_path29.dirname)(path)), "coverage.json");
48325
48755
  const coverage = await readJsonFile(coveragePath, coverageSchema);
48326
48756
  const current = coverage.kind === "ok" ? coverage.value : null;
48327
48757
  const next = nextCoverage(current, ordinal, nextOrdinal);
@@ -48365,7 +48795,7 @@ var decoder = new TextDecoder();
48365
48795
 
48366
48796
  // src/run-log/writer.ts
48367
48797
  var import_node_fs10 = require("fs");
48368
- var import_node_path29 = require("path");
48798
+ var import_node_path30 = require("path");
48369
48799
  init_runtime_v2();
48370
48800
  function lastSeq(fd, size) {
48371
48801
  for (const length of tailWindows(size)) {
@@ -48381,7 +48811,7 @@ function lastSeq(fd, size) {
48381
48811
  throw new RuntimeFault("record_too_large", "Run log tail record is larger than any record");
48382
48812
  }
48383
48813
  function openRunLog(path, clock) {
48384
- (0, import_node_fs10.mkdirSync)((0, import_node_path29.dirname)(path), { recursive: true, mode: 448 });
48814
+ (0, import_node_fs10.mkdirSync)((0, import_node_path30.dirname)(path), { recursive: true, mode: 448 });
48385
48815
  const fd = (0, import_node_fs10.openSync)(path, "a+", 384);
48386
48816
  let size = (0, import_node_fs10.fstatSync)(fd).size;
48387
48817
  let seq = lastSeq(fd, size);
@@ -48559,8 +48989,12 @@ function fitForRunLog(update) {
48559
48989
  async function runWithInputs({ spec, leaseTargets, skills }, context, sink, signal) {
48560
48990
  var _stack = [];
48561
48991
  try {
48562
- const refreshed = context.workspace?.refreshFirstCheckout?.(spec, leaseTargets, signal).catch((error61) => {
48992
+ const workspace = context.workspace;
48993
+ const sessionContext = (workspace?.refreshFirstCheckout?.(spec, leaseTargets, signal) ?? Promise.resolve([])).catch((error61) => {
48563
48994
  context.log.warn("workspace.refresh_failed", { runId: spec.runId, error: error61 });
48995
+ return [];
48996
+ }).then((problems) => workspace?.prepareAgentContext?.(spec, problems)).catch((error61) => {
48997
+ context.log.warn("holder.agent_context_failed", { runId: spec.runId, error: error61 });
48564
48998
  return void 0;
48565
48999
  });
48566
49000
  let inputs;
@@ -48573,17 +49007,37 @@ async function runWithInputs({ spec, leaseTargets, skills }, context, sink, sign
48573
49007
  message: `Could not fetch this run's attachments or provider credential: ${error61 instanceof Error ? error61.message : String(error61)}`
48574
49008
  };
48575
49009
  }
48576
- const turnContext = await refreshed;
49010
+ const agentContext = await sessionContext;
48577
49011
  const prepared = __using(_stack, inputs, true);
48578
- const run = (turnSink, turnSignal) => context.driver.runTurn(
49012
+ const run = async (turnSink, turnSignal) => {
49013
+ const result = await context.driver.runTurn(
49014
+ spec,
49015
+ turnSink,
49016
+ turnSignal,
49017
+ agentContext === void 0 ? prepared : {
49018
+ ...prepared,
49019
+ agentContext: {
49020
+ full: agentContext.full,
49021
+ ...agentContext.update ? { update: agentContext.update } : {}
49022
+ }
49023
+ }
49024
+ );
49025
+ if (agentContext !== void 0 && result.outcome !== "rejected") {
49026
+ await agentContext.save().catch((error61) => {
49027
+ context.log.warn("holder.agent_context_save_failed", { runId: spec.runId, error: error61 });
49028
+ });
49029
+ }
49030
+ return result;
49031
+ };
49032
+ if (workspace === void 0) return await run(sink, signal);
49033
+ return await runLeased(
48579
49034
  spec,
48580
- turnSink,
48581
- turnSignal,
48582
- turnContext === void 0 ? prepared : { ...prepared, turnContext }
49035
+ leaseTargets,
49036
+ { ...context, lease: workspace.lease },
49037
+ sink,
49038
+ signal,
49039
+ run
48583
49040
  );
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
49041
  } catch (_) {
48588
49042
  var _error = _, _hasError = true;
48589
49043
  } finally {
@@ -48717,7 +49171,7 @@ async function runHolder({
48717
49171
  try {
48718
49172
  const identity = await readProcessIdentity(process.pid);
48719
49173
  if (identity === null) throw new RuntimeFault("internal", "Cannot read own process identity");
48720
- const _engines = __using(_stack, recordSpawnedEngines(engineRecordsPath((0, import_node_path30.dirname)(launch.statusPath)), clock, log));
49174
+ const _engines = __using(_stack, recordSpawnedEngines(engineRecordsPath((0, import_node_path31.dirname)(launch.statusPath)), clock, log));
48721
49175
  const holder = {
48722
49176
  state: "idle",
48723
49177
  runId: null,
@@ -49062,7 +49516,7 @@ function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node
49062
49516
  providerProbes: ALAN_RUNTIME_PROVIDER_PROBES === "on",
49063
49517
  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
49518
  home,
49065
- configHome: XDG_CONFIG_HOME ?? (0, import_node_path32.join)(home, ".config"),
49519
+ configHome: XDG_CONFIG_HOME ?? (0, import_node_path33.join)(home, ".config"),
49066
49520
  codexHome: resolveCodexHome(CODEX_HOME, home),
49067
49521
  ...githubProxyConfig({ ALAN_RUNTIME_GITHUB_PROXY, XDG_CONFIG_HOME, GH_CONFIG_DIR }, home),
49068
49522
  gitGatewayUrl: ALAN_RUNTIME_GIT_GATEWAY_URL ?? null,
@@ -49072,13 +49526,13 @@ function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node
49072
49526
  };
49073
49527
  }
49074
49528
  function resolveCodexHome(configuredHome, home) {
49075
- return configuredHome ?? (0, import_node_path32.join)(home, ".codex");
49529
+ return configuredHome ?? (0, import_node_path33.join)(home, ".codex");
49076
49530
  }
49077
49531
  function githubProxyConfig(env, home) {
49078
- const configHome = env.XDG_CONFIG_HOME ?? (0, import_node_path32.join)(home, ".config");
49532
+ const configHome = env.XDG_CONFIG_HOME ?? (0, import_node_path33.join)(home, ".config");
49079
49533
  return {
49080
49534
  githubProxy: env.ALAN_RUNTIME_GITHUB_PROXY === "on",
49081
- ghConfigDir: env.GH_CONFIG_DIR ?? (0, import_node_path32.join)(configHome, "gh")
49535
+ ghConfigDir: env.GH_CONFIG_DIR ?? (0, import_node_path33.join)(configHome, "gh")
49082
49536
  };
49083
49537
  }
49084
49538
  function serviceEnvironment(env, profile) {
@@ -49177,7 +49631,7 @@ async function loadStoredAccess(paths, access3 = { exec: systemExec }) {
49177
49631
  }
49178
49632
 
49179
49633
  // src/cli/commands/hold.ts
49180
- var import_node_path33 = require("path");
49634
+ var import_node_path34 = require("path");
49181
49635
  init_agent2();
49182
49636
  init_runtime_v2();
49183
49637
  async function machineAccess(paths, log, conversationId, transport) {
@@ -49235,7 +49689,7 @@ async function runHold(argv) {
49235
49689
  const config2 = loadRuntimeConfig();
49236
49690
  const paths = runtimePaths(config2.stateDir);
49237
49691
  const log = __using(_stack, openFileLog(
49238
- (0, import_node_path33.join)(paths.logs, `holder-${launch.value.conversationId}.jsonl`),
49692
+ (0, import_node_path34.join)(paths.logs, `holder-${launch.value.conversationId}.jsonl`),
49239
49693
  config2.logLevel,
49240
49694
  systemClock
49241
49695
  ));
@@ -49246,7 +49700,7 @@ async function runHold(argv) {
49246
49700
  );
49247
49701
  const transport = __using(_stack, createHttpTransport());
49248
49702
  const access3 = await machineAccess(paths, log, launch.value.conversationId, transport);
49249
- const credentialPath = (0, import_node_path33.join)(paths.tmp, "mcp", `${launch.value.conversationId}.json`);
49703
+ const credentialPath = (0, import_node_path34.join)(paths.tmp, "mcp", `${launch.value.conversationId}.json`);
49250
49704
  const managedMcp = __using(_stack, access3.managedMcp === void 0 ? void 0 : createHelperMcpAccess({
49251
49705
  managedMcp: access3.managedMcp,
49252
49706
  conversationId: launch.value.conversationId,