@sema-agent/core 7.62.0 → 7.63.0

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 (193) hide show
  1. package/CHANGELOG.md +528 -0
  2. package/dist/agents/subagent-transcript-placement.d.ts +23 -0
  3. package/dist/agents/subagent-transcript-placement.js +14 -0
  4. package/dist/agents/subagent.js +82 -51
  5. package/dist/brain/route-adjudicator.js +9 -4
  6. package/dist/core/approval-object.js +1 -1
  7. package/dist/core/arg-summary.js +1 -1
  8. package/dist/core/ask-question.d.ts +2 -2
  9. package/dist/core/canonical-json.d.ts +23 -13
  10. package/dist/core/canonical-json.js +4 -4
  11. package/dist/core/checkpoint-queries.d.ts +47 -4
  12. package/dist/core/checkpoint-queries.js +36 -16
  13. package/dist/core/checkpoint-requirements.d.ts +3 -3
  14. package/dist/core/checkpoint-requirements.js +2 -1
  15. package/dist/core/checkpoint-row-verdict.d.ts +15 -4
  16. package/dist/core/checkpoint-row-verdict.js +22 -2
  17. package/dist/core/checkpoint-store.d.ts +23 -10
  18. package/dist/core/checkpoint-store.js +45 -4
  19. package/dist/core/compliance.d.ts +6 -2
  20. package/dist/core/compliance.js +3 -3
  21. package/dist/core/engine-attestation.d.ts +1 -1
  22. package/dist/core/engine-notice.d.ts +19 -4
  23. package/dist/core/git-worktree-env.d.ts +62 -3
  24. package/dist/core/git-worktree-env.js +91 -30
  25. package/dist/core/governance-codes.d.ts +7 -3
  26. package/dist/core/governance-codes.js +13 -3
  27. package/dist/core/memory-engine/consolidation-driver.d.ts +32 -17
  28. package/dist/core/memory-engine/consolidation-driver.js +99 -98
  29. package/dist/core/memory-engine/consolidation.d.ts +73 -10
  30. package/dist/core/memory-engine/consolidation.js +167 -11
  31. package/dist/core/memory-engine/data-plane.d.ts +8 -4
  32. package/dist/core/memory-engine/data-plane.js +11 -6
  33. package/dist/core/memory-engine/delegation-settlement.d.ts +37 -35
  34. package/dist/core/memory-engine/delegation-settlement.js +53 -59
  35. package/dist/core/memory-engine/dual-root.d.ts +12 -6
  36. package/dist/core/memory-engine/dual-root.js +9 -5
  37. package/dist/core/memory-engine/engine.d.ts +98 -35
  38. package/dist/core/memory-engine/engine.js +477 -380
  39. package/dist/core/memory-engine/entry-scan.d.ts +8 -0
  40. package/dist/core/memory-engine/entry-scan.js +3 -0
  41. package/dist/core/memory-engine/file-backend.d.ts +29 -3
  42. package/dist/core/memory-engine/file-backend.js +66 -35
  43. package/dist/core/memory-engine/index.d.ts +7 -7
  44. package/dist/core/memory-engine/index.js +6 -6
  45. package/dist/core/memory-engine/landing-admission.d.ts +5 -3
  46. package/dist/core/memory-engine/landing-admission.js +3 -3
  47. package/dist/core/memory-engine/layout.d.ts +121 -45
  48. package/dist/core/memory-engine/layout.js +252 -102
  49. package/dist/core/memory-engine/memory-backend-contract.d.ts +19 -1
  50. package/dist/core/memory-engine/memory-backend-contract.js +320 -0
  51. package/dist/core/memory-engine/memory-deployment.d.ts +31 -8
  52. package/dist/core/memory-engine/memory-deployment.js +26 -12
  53. package/dist/core/memory-engine/scope-contract.d.ts +52 -11
  54. package/dist/core/memory-engine/scope-contract.js +68 -19
  55. package/dist/core/memory-engine/session-write-home.d.ts +3 -1
  56. package/dist/core/memory-engine/session-write-home.js +1 -1
  57. package/dist/core/memory-engine/sync-client.d.ts +3 -1
  58. package/dist/core/memory-engine/sync-client.js +7 -0
  59. package/dist/core/memory-engine/sync-report.d.ts +3 -2
  60. package/dist/core/memory-engine/sync-report.js +6 -2
  61. package/dist/core/memory-engine/tools.d.ts +2 -2
  62. package/dist/core/memory-engine/tools.js +10 -10
  63. package/dist/core/memory-engine/types.d.ts +118 -19
  64. package/dist/core/memory-engine/types.js +1 -0
  65. package/dist/core/memory.js +15 -6
  66. package/dist/core/mods/stations.d.ts +20 -1
  67. package/dist/core/mods/stations.js +21 -2
  68. package/dist/core/park-selfcheck.js +2 -2
  69. package/dist/core/pause-registry.d.ts +2 -0
  70. package/dist/core/pause-registry.js +3 -0
  71. package/dist/core/permission-rule-consent.d.ts +10 -3
  72. package/dist/core/permission-rule-consent.js +37 -24
  73. package/dist/core/permission-rule-store.d.ts +35 -1
  74. package/dist/core/permission-rule-store.js +27 -8
  75. package/dist/core/read-only-shell.js +3 -2
  76. package/dist/core/redaction-marks.d.ts +8 -0
  77. package/dist/core/redaction-marks.js +6 -0
  78. package/dist/core/remote-env.d.ts +12 -1
  79. package/dist/core/remote-env.js +3 -0
  80. package/dist/core/runner/child-tree.d.ts +29 -3
  81. package/dist/core/runner/child-tree.js +39 -16
  82. package/dist/core/runner/contracts.d.ts +18 -9
  83. package/dist/core/runner/gate-exit.js +2 -2
  84. package/dist/core/runner/inherited-ask-grants.js +1 -1
  85. package/dist/core/runner/memory-consolidation-driver.d.ts +6 -3
  86. package/dist/core/runner/memory-consolidation-driver.js +4 -4
  87. package/dist/core/runner/memory-consolidation-write-judge.d.ts +2 -1
  88. package/dist/core/runner/memory-consolidation-write-judge.js +3 -2
  89. package/dist/core/runner/person-path-rows.d.ts +8 -3
  90. package/dist/core/runner/person-path-rows.js +5 -1
  91. package/dist/core/runner/placement-fence.d.ts +12 -0
  92. package/dist/core/runner/placement-fence.js +20 -6
  93. package/dist/core/runner/prepare-ask-lane.js +2 -2
  94. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -1
  95. package/dist/core/runner/prepare-caps-and-workflow.js +5 -2
  96. package/dist/core/runner/prepare-execution-env.js +17 -6
  97. package/dist/core/runner/prepare-hands-readface.d.ts +2 -1
  98. package/dist/core/runner/prepare-hands-readface.js +4 -3
  99. package/dist/core/runner/prepare-inherited-gate.d.ts +10 -8
  100. package/dist/core/runner/prepare-inherited-gate.js +8 -4
  101. package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -4
  102. package/dist/core/runner/prepare-memory-engine-session.js +4 -4
  103. package/dist/core/runner/prepare-memory.d.ts +3 -2
  104. package/dist/core/runner/prepare-memory.js +28 -20
  105. package/dist/core/runner/prepare-park-ask.js +4 -3
  106. package/dist/core/runner/prepare-task.js +15 -12
  107. package/dist/core/runner/prepare-workspace-restore.js +3 -6
  108. package/dist/core/runner/run-leg.js +1 -1
  109. package/dist/core/runner/run-settle-and-teardown.js +3 -2
  110. package/dist/core/runner/terminal-account.js +1 -1
  111. package/dist/core/runner-deps.d.ts +6 -2
  112. package/dist/core/secret-env.d.ts +1 -1
  113. package/dist/core/secret-env.js +4 -4
  114. package/dist/core/session-checkout.d.ts +108 -0
  115. package/dist/core/session-checkout.js +485 -0
  116. package/dist/core/session-store.d.ts +12 -4
  117. package/dist/core/session-store.js +23 -3
  118. package/dist/core/session.d.ts +16 -2
  119. package/dist/core/session.js +3 -0
  120. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +0 -12
  121. package/dist/core/store-contracts/checkpoint-store-contract.js +6 -7
  122. package/dist/core/store-contracts/session-store-contract.js +39 -0
  123. package/dist/core/task-event.d.ts +21 -0
  124. package/dist/core/task-notification.d.ts +9 -1
  125. package/dist/core/task-notification.js +6 -0
  126. package/dist/core/task-registry-agent.d.ts +14 -2
  127. package/dist/core/task-registry-agent.js +45 -19
  128. package/dist/core/task-registry-shared.d.ts +26 -11
  129. package/dist/core/task-registry.d.ts +15 -9
  130. package/dist/core/task-registry.js +9 -10
  131. package/dist/core/task-spec-members.js +1 -1
  132. package/dist/core/task-spec.d.ts +20 -0
  133. package/dist/core/tool-policy.d.ts +14 -12
  134. package/dist/core/tool-policy.js +11 -10
  135. package/dist/core/tool-spec.d.ts +38 -19
  136. package/dist/core/types.d.ts +1 -1
  137. package/dist/core/untrusted-egress.d.ts +15 -4
  138. package/dist/core/untrusted-egress.js +23 -22
  139. package/dist/core/workspace-snapshot.d.ts +3 -1
  140. package/dist/core/workspace-snapshot.js +1 -0
  141. package/dist/engine/harness/types.d.ts +66 -1
  142. package/dist/engine/harness/types.js +108 -0
  143. package/dist/engine/session/import-validate.js +6 -1
  144. package/dist/engine/session/session.d.ts +24 -1
  145. package/dist/engine/session/session.js +45 -1
  146. package/dist/index.d.ts +7 -4
  147. package/dist/index.js +7 -4
  148. package/dist/internal/harness-types.d.ts +1 -1
  149. package/dist/orchestration/run-workflow-tool.d.ts +4 -1
  150. package/dist/orchestration/run-workflow-tool.js +1 -0
  151. package/dist/orchestration/workflow.d.ts +3 -0
  152. package/dist/orchestration/workflow.js +3 -1
  153. package/dist/stores/file/session-store.js +2 -1
  154. package/dist/tools/fs/bash-program-position.js +3 -3
  155. package/dist/tools/fs/program-read-model.d.ts +34 -10
  156. package/dist/tools/fs/program-read-model.js +37 -7
  157. package/dist/tools/fs/program-read-model.rows.js +13 -2
  158. package/dist/tools/fs/read-deny.d.ts +13 -1
  159. package/dist/tools/fs/read-deny.js +10 -2
  160. package/dist/tools/fs/removal-targets.js +3 -3
  161. package/dist/tools/fs/safety.d.ts +2 -0
  162. package/dist/tools/fs/safety.js +1 -1
  163. package/dist/tools/fs/shell-read-argv.d.ts +8 -1
  164. package/dist/tools/fs/shell-read-argv.js +34 -29
  165. package/dist/tools/fs/shell-read-bindings.d.ts +2 -0
  166. package/dist/tools/fs/shell-read-bindings.js +5 -1
  167. package/dist/tools/fs/shell-read-brace.d.ts +18 -0
  168. package/dist/tools/fs/shell-read-brace.js +79 -0
  169. package/dist/tools/fs/shell-read-check.js +10 -8
  170. package/dist/tools/fs/shell-read-establish.js +23 -16
  171. package/dist/tools/fs/shell-read-judge.d.ts +11 -0
  172. package/dist/tools/fs/shell-read-judge.js +3 -3
  173. package/dist/tools/fs/shell-read-plan.d.ts +10 -0
  174. package/dist/tools/fs/shell-read-plan.js +189 -93
  175. package/dist/tools/fs/shell-read-start.d.ts +19 -9
  176. package/dist/tools/fs/shell-read-start.js +20 -12
  177. package/dist/tools/fs/shell-read-word.d.ts +10 -0
  178. package/dist/tools/fs/shell-read-word.js +9 -5
  179. package/dist/tools/fs/shell-read-workdir.d.ts +26 -7
  180. package/dist/tools/fs/shell-read-workdir.js +73 -12
  181. package/dist/tools/fs/shell-read-write-targets.js +13 -8
  182. package/dist/tools/worktree.d.ts +3 -2
  183. package/dist/tools/worktree.js +7 -35
  184. package/package.json +3 -2
  185. package/test/export-surface.snapshot.json +73 -11
  186. package/wire-changes/core-stores-sql@7.63.0.json +30 -0
  187. package/wire-changes/core@7.63.0.json +3523 -0
  188. package/wire-changes/mods-kernel@7.63.0.json +30 -0
  189. package/wire-changes/primitives@7.63.0.json +445 -0
  190. package/dist/core/credential-vocabulary.d.ts +0 -176
  191. package/dist/core/credential-vocabulary.js +0 -190
  192. package/dist/core/redaction-passes.d.ts +0 -82
  193. package/dist/core/redaction-passes.js +0 -377
@@ -222,8 +222,9 @@ export async function runSettleAndTeardown(input) {
222
222
  const mes = prepared.memoryEngineSession;
223
223
  await settleTeardownLeg(() => mes.harvest(), "memoryEngineSession.harvest (settle leg)", (e) => runner.deps.onError?.(e, { phase: "config", sessionId: prepared.sessionId }));
224
224
  const scope = mes.handle.writeScope;
225
- if (scope !== null && autoRunOnRecommendationEffective(runner.deps) && scopeHasUnconsumedRecommendation(mes.engine, scope)) {
226
- void autoRunConsolidationFromRecommendation({ deps: runner.deps, engine: mes.engine, scope, sessionId: prepared.sessionId, writeJudge: prepared.consolidationWriteJudge, onNotice: runner.deps.onNotice, onError: runner.deps.onError });
225
+ if (scope !== null && autoRunOnRecommendationEffective(runner.deps) && (await scopeHasUnconsumedRecommendation(mes.engine, scope))) {
226
+ const compliance = { postureOf: runner.deps.compliancePostureResolver, scopeContract: mes.scopeContract, denies: spec.complianceAdditionalDenies };
227
+ void autoRunConsolidationFromRecommendation({ deps: runner.deps, engine: mes.engine, scope, sessionId: prepared.sessionId, writeJudge: prepared.consolidationWriteJudge, compliance, onNotice: runner.deps.onNotice, onError: runner.deps.onError });
227
228
  }
228
229
  }
229
230
  emitTrace(rs.telemetry.tracer, () => ({
@@ -7,7 +7,7 @@ import { readMember } from "../thrown-value.js";
7
7
  import { egressText } from "../untrusted-egress.js";
8
8
  import { REDACTION_MARK } from "../redaction-marks.js";
9
9
  import { isSensitiveName, looksLikeCredentialValue } from "../secret-env.js";
10
- import { isSensitiveRecordKey } from "../credential-vocabulary.js";
10
+ import { isSensitiveRecordKey } from "@sema-agent/primitives";
11
11
  const LOOP_EXIT_FAILURE = {
12
12
  completed: undefined,
13
13
  aborted_before_stream: undefined,
@@ -377,7 +377,9 @@ export interface RunnerDeps {
377
377
  * stays host-owned (the four verbs are engine host API; nothing in a task can trigger a run).
378
378
  * `provenance: "off"` beside this refuses loudly at prepare
379
379
  * (`config.memory_consolidation_provenance_off` — the fold law must be able to mint);
380
- * `multiNode: true` without a lease refuses (`config.memory_consolidation_lease_required`);
380
+ * `multiNode: true` without a lease refuses (`config.memory_consolidation_lease_required`), and over a backend whose
381
+ * consolidation state is replica-local (`memoryGovernanceDurability`) it refuses
382
+ * (`config.memory_consolidation_replica_local`);
381
383
  * every other bad value refuses under `config.memory_consolidation` (#123). DEPLOYMENT seat
382
384
  * ONLY (no TaskSpec twin, not in the governed workflow whitelist), same law as
383
385
  * {@link memoryProvenance}.
@@ -703,8 +705,10 @@ export interface RunnerDeps {
703
705
  * resolver fault rather than an adjudicated posture). `undefined` (no resolver / no posture for
704
706
  * the principal) = no compliance restriction from the deployment — existing deployments are untouched. The run's deny
705
707
  * set is this posture's UNION the request's own denies ({@link TaskSpec.complianceAdditionalDenies}, add-only).
708
+ * One seat is asked a second question: the automatic consolidation run a settled leg fires asks it for the posture of the
709
+ * consolidated scope's OWNER (`memory_consolidation`, read by the consolidation verb at its start, not frozen at prepare).
706
710
  */
707
- compliancePostureResolver?: (principal: string | undefined) => import("./compliance.js").CompliancePosture | undefined | Promise<import("./compliance.js").CompliancePosture | undefined>;
711
+ compliancePostureResolver?: import("./compliance.js").CompliancePostureSeat;
708
712
  /**
709
713
  * Org-memory tenant admission (ruled 2026-08-05) — the fail-closed adjudicator for REQUEST-origin
710
714
  * `org:` memory scopes (`TaskSpec.memory` / a subagent's `AgentDefinition.memory`, under the v2
@@ -19,7 +19,7 @@
19
19
  * as written, three ways stricter: plural `TOKENS` is a credential word unless a count word touches it, the GitHub
20
20
  * token names are not held back from the name shape, and the name shape always runs.
21
21
  */
22
- import { type RedactionConfidence, type RedactionSource } from "./credential-vocabulary.js";
22
+ import { type RedactionConfidence, type RedactionSource } from "@sema-agent/primitives";
23
23
  import { type EngineNotice } from "./engine-notice.js";
24
24
  /** Does a value carry a credential? A URL userinfo (after every `scheme://`, and a leading `//`) with a password or a
25
25
  * token-like user; a scheme-less `user:password@host`; a credential assignment; a webhook URL; a Sonar login; a
@@ -1,6 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { types } from "node:util";
3
- import { CREDENTIAL_MIN_CHARS, CREDENTIAL_VOCABULARY, envNameView, isSensitiveHeaderName, splitCamelCase } from "./credential-vocabulary.js";
3
+ import { CREDENTIAL_MIN_CHARS, envNameView, isSensitiveHeaderName, splitCamelCase } from "@sema-agent/primitives";
4
4
  import { DEFAULT_INHERITED_ENV_VARS } from "@modelcontextprotocol/client/stdio";
5
5
  import { deliverEngineNotice } from "./engine-notice.js";
6
6
  import { optionKeys, receiveMembers } from "./own-property-receipt.js";
@@ -9,9 +9,9 @@ const PROXY_ENV_RE = /^(?:(?:https?|ftp|all|no)_proxy|npm_config_(?:https?_)?pro
9
9
  function isExemptEnvName(name) {
10
10
  return GIT_CONFIG_ENV_RE.test(name) || PROXY_ENV_RE.test(name);
11
11
  }
12
- const ENV_NAMES = envNameView(CREDENTIAL_VOCABULARY);
12
+ const ENV_NAMES = envNameView();
13
13
  const OTEL_ENV_RE = /^(?:INPUT_)?OTEL_/i;
14
- const SEMA_NAMESPACE_SECRET_RE = new RegExp(`^SEMA_(?:.*_)?${ENV_NAMES.segmentWord}(?:_|$)`, "is");
14
+ const SEMA_NAMESPACE_SECRET_RE = ENV_NAMES.anySegmentUnder("SEMA_");
15
15
  const BUNDLER_SETTINGS = ["BUILD", "LOCAL", "MIRROR", "PATH", "WITH", "WITHOUT", "CACHE", "DISABLE", "IGNORE", "ONLY"];
16
16
  const BUNDLER_HOST = "(?:[A-Za-z0-9]+(?:___[A-Za-z0-9]+)*__)+[A-Za-z]{2,}";
17
17
  const BUNDLER_CREDENTIAL_RE = new RegExp(`^(?:INPUT_)?BUNDLE_(?!(?:${BUNDLER_SETTINGS.join("|")})__(?!${BUNDLER_HOST}$))\\w*__`, "i");
@@ -210,7 +210,7 @@ function notACredentialReason(value) {
210
210
  return `a string of fewer than ${CREDENTIAL_MIN_CHARS} characters, which names no secret`;
211
211
  if (PLACEHOLDER_KEY_WORDS.has(text.toLowerCase()))
212
212
  return "a flag or placeholder word, which names no secret";
213
- if (ONE_REPEATED_CHARACTER_RE.test(text.replace(CREDENTIAL_VOCABULARY.tokenPrefix, "")))
213
+ if (ONE_REPEATED_CHARACTER_RE.test(text.replace(ENV_NAMES.tokenPrefix, "")))
214
214
  return "one character repeated, which names no secret";
215
215
  return undefined;
216
216
  }
@@ -0,0 +1,108 @@
1
+ import type { ExecutionEnv, Session, SessionCheckoutCell, SessionCheckoutDeclared, SessionCheckoutRecord } from "../internal/harness-types.js";
2
+ /** One declared code source: the root it is for, the repository URL (`https` only), the full commit id the session's code
3
+ * starts from, and a display label. */
4
+ export interface WorkspaceSourceDeclaration {
5
+ /** `"taskRoot"`, or `{ directory }` naming an entry of `TaskSpec.additionalDirectories` (the same spelling). */
6
+ readonly root: "taskRoot" | {
7
+ readonly directory: string;
8
+ };
9
+ /** The repository URL. `https` only; normalized (host lowercased, a trailing `/` or `.git` dropped). A user name or password in
10
+ * it, or a query / fragment parameter whose name reads as a credential, is refused, and the refusal echoes only the origin. */
11
+ readonly remote: string;
12
+ /** The full commit id (40 or 64 lowercase hex). The engine checks it on the session's first leg. */
13
+ readonly sha: string;
14
+ /** A display / continuation label (a branch name); never resolved. */
15
+ readonly ref?: string;
16
+ }
17
+ /** `TaskSpec.workspace`: the session's workspace declaration. */
18
+ export interface WorkspaceDeclaration {
19
+ /** `"worktree"`: the session works in its own managed tree of the task root's repository, minted on its first leg. */
20
+ readonly isolation?: "worktree";
21
+ /** Where the tree starts: `"fresh"` (default — the default branch tip) or `"head"` (the current local HEAD). Only with
22
+ * `isolation`, and not with a source for the task root (the source's commit is the start). */
23
+ readonly baseRef?: "fresh" | "head";
24
+ /** The tree's managed name (the EnterWorktree name grammar); absent ⇒ derived from the session id. Only with `isolation`. */
25
+ readonly name?: string;
26
+ /** The code sources, one per repository. */
27
+ readonly sources?: readonly WorkspaceSourceDeclaration[];
28
+ }
29
+ /** Why a checkout cannot get a managed tree here — the probe's closed set. */
30
+ export declare const WORKTREE_INCAPABLE_REASONS: readonly ["git_unavailable", "not_a_repository", "bare_repository", "no_commit", "managed_parent_symlinked", "parent_not_writable", "name_in_use"];
31
+ export type WorktreeIncapableReason = (typeof WORKTREE_INCAPABLE_REASONS)[number];
32
+ /** What {@link probeWorktreeCapability} answered. `gitRoot` = the repository root the managed parent hangs at (present once
33
+ * the location is known to be a repository). */
34
+ export interface WorktreeCapability {
35
+ readonly worktreeCapable: boolean;
36
+ readonly gitRoot?: string;
37
+ readonly reason?: WorktreeIncapableReason;
38
+ /** One human sentence for the refusal; absent when capable. */
39
+ readonly detail?: string;
40
+ }
41
+ /** The release outcome of one tree. `branch` is present while the tree's branch still exists after the release. */
42
+ export interface ReleasedTree {
43
+ readonly path: string;
44
+ readonly removed: boolean;
45
+ readonly branch?: string;
46
+ readonly kept?: "dirty" | "ignored" | "commits" | "unverifiable" | "requested" | "not_owned";
47
+ readonly detail?: string;
48
+ }
49
+ /**
50
+ * THE shape judge of `TaskSpec.workspace` — `undefined` for an absent declaration, else the normalized declaration the record
51
+ * stores and every later leg is compared on. Refused (`config.session_workspace_invalid`): a non-object, an unknown key, a word
52
+ * outside a closed set, `baseRef` / `name` without `isolation`, a name outside the managed grammar, an empty or oversized
53
+ * `sources`, two sources for one root, a source for the isolated task root together with `baseRef`, a declaration that declares
54
+ * nothing.
55
+ */
56
+ export declare function screenWorkspaceDeclaration(value: unknown): SessionCheckoutDeclared | undefined;
57
+ /**
58
+ * THE capability judge of a managed tree for the checkout at `cwd`: git runs, `cwd` is inside a non-bare work tree with a
59
+ * commit, no level of the managed parent is a symlink, the managed parent can be written, and — with `name` — that name's
60
+ * directory and branch are free. The first failing check answers, in that order. Reads only (no git write); a host calls it
61
+ * before offering isolation, and a session's first leg calls it before minting.
62
+ */
63
+ export declare function probeWorktreeCapability(env: ExecutionEnv, cwd: string, opts?: {
64
+ readonly name?: string;
65
+ }): Promise<WorktreeCapability>;
66
+ export interface OpenSessionCheckoutInput {
67
+ /** The leg's hands environment (the one git runs in). */
68
+ readonly env: ExecutionEnv;
69
+ readonly session: Session;
70
+ readonly sessionId: string;
71
+ /** The leg's raw `TaskSpec.workspace`. */
72
+ readonly declaration: unknown;
73
+ /** The leg's task root as the deployment and the workspace restore settled it (the base checkout's location). */
74
+ readonly baseRoot: string;
75
+ /** The leg's `TaskSpec.additionalDirectories` (declared spellings). */
76
+ readonly additionalDirectories: readonly string[] | undefined;
77
+ }
78
+ export interface OpenedSessionCheckout {
79
+ /** The leg's task root: the task root's place in the session's tree when the task root's repository is isolated, else `baseRoot`. */
80
+ readonly taskRoot: string;
81
+ /** The session's checkout record, when it has one. */
82
+ readonly record?: SessionCheckoutRecord;
83
+ }
84
+ /**
85
+ * THE per-leg judge of a session's checkout (see the module header): reads the record, compares the leg's declaration with it,
86
+ * mints the allocation on the session's first leg, and answers the leg's task root. Throws a coded refusal; the first leg's
87
+ * allocation is all or nothing (every check runs before the mint, a tree minted for a refused allocation is removed while it is
88
+ * still clean, and the record is written only once everything succeeded — immediately, not at settle).
89
+ */
90
+ export declare function openSessionCheckout(input: OpenSessionCheckoutInput): Promise<OpenedSessionCheckout>;
91
+ /**
92
+ * Release a session's checkout — the host's door when it archives or deletes a session. Each of the session's trees is removed
93
+ * only when it is clean (no uncommitted file, no file git ignores, no commit past its base, its state readable) AND its birth record names this
94
+ * allocation; the removal itself runs without `--force`, so a write landing after the check keeps the tree. Everything else
95
+ * is kept and reported with its path and why. The tree's branch is deleted with it only while the branch still sits at the
96
+ * base commit. Then the release is recorded once (`released: true`), after which the session runs no further leg. Calling it
97
+ * again re-reports and never removes a tree another allocation took over.
98
+ *
99
+ * `onExit`: `"keep-if-dirty"` (default) | `"keep"` (keep every tree; only record the release). A discarding removal is not
100
+ * offered. A session with no checkout answers an empty list.
101
+ */
102
+ export declare function releaseSessionCheckout(env: ExecutionEnv, session: Session, opts?: {
103
+ readonly onExit?: "keep-if-dirty" | "keep";
104
+ }): Promise<{
105
+ readonly trees: readonly ReleasedTree[];
106
+ }>;
107
+ /** The frame's `session` member: the record's cells as the leg reports them (`undefined` when the session has no checkout). */
108
+ export declare function sessionFrameOf(record: SessionCheckoutRecord | undefined): ReadonlyArray<SessionCheckoutCell> | undefined;