@sema-agent/core 1.452.0 → 2.0.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 (162) hide show
  1. package/dist/agents/agent-transcript-tool.d.ts +15 -0
  2. package/dist/agents/agent-transcript-tool.js +122 -0
  3. package/dist/agents/cascade.js +5 -8
  4. package/dist/agents/repair-loop.d.ts +1 -1
  5. package/dist/agents/repair-loop.js +1 -1
  6. package/dist/agents/retain-ledger.d.ts +60 -0
  7. package/dist/agents/retain-ledger.js +225 -0
  8. package/dist/agents/roster-store.d.ts +1 -0
  9. package/dist/agents/roster-store.js +9 -0
  10. package/dist/agents/send-message-tool.d.ts +41 -0
  11. package/dist/agents/send-message-tool.js +469 -0
  12. package/dist/agents/subagent.d.ts +33 -108
  13. package/dist/agents/subagent.js +22 -834
  14. package/dist/agents/teacher.d.ts +0 -1
  15. package/dist/agents/teacher.js +0 -9
  16. package/dist/bin/sema-tb.js +3 -3
  17. package/dist/brain/anthropic.js +15 -40
  18. package/dist/brain/openai.js +15 -40
  19. package/dist/brain/reasoning.d.ts +1 -1
  20. package/dist/brain/stream-engine.js +2 -2
  21. package/dist/brain/stream-shared.d.ts +17 -0
  22. package/dist/brain/stream-shared.js +50 -0
  23. package/dist/brain/timeout.d.ts +1 -1
  24. package/dist/brain/timeout.js +1 -1
  25. package/dist/config/catalog.js +1 -3
  26. package/dist/config/defaults.d.ts +6 -0
  27. package/dist/config/defaults.js +6 -0
  28. package/dist/core/ask-question.d.ts +1 -1
  29. package/dist/core/background-shell.d.ts +1 -1
  30. package/dist/core/checkpoint-store.d.ts +0 -1
  31. package/dist/core/exec-gate.d.ts +1 -1
  32. package/dist/core/exec-output-tail.d.ts +1 -0
  33. package/dist/core/exec-output-tail.js +6 -0
  34. package/dist/core/file-snapshot-store.d.ts +1 -1
  35. package/dist/core/fs-write-gate-policy.d.ts +1 -1
  36. package/dist/core/git-worktree-env.d.ts +1 -1
  37. package/dist/core/hooks.d.ts +1 -1
  38. package/dist/core/image-downsample.d.ts +44 -0
  39. package/dist/core/image-downsample.js +97 -0
  40. package/dist/core/lsp.d.ts +1 -1
  41. package/dist/core/mcp.d.ts +3 -45
  42. package/dist/core/mcp.js +2 -97
  43. package/dist/core/media-byte-cap.d.ts +1 -1
  44. package/dist/core/memory-recall.d.ts +0 -12
  45. package/dist/core/memory-recall.js +0 -222
  46. package/dist/core/memory.d.ts +0 -6
  47. package/dist/core/memory.js +0 -88
  48. package/dist/core/message-utils.d.ts +1 -1
  49. package/dist/core/oracle-isolation.d.ts +1 -1
  50. package/dist/core/remote-env.d.ts +1 -1
  51. package/dist/core/roles.d.ts +1 -1
  52. package/dist/core/runner/active-skill-scope.d.ts +1 -1
  53. package/dist/core/runner/assemble-result.d.ts +0 -2
  54. package/dist/core/runner/memory-consolidation.d.ts +1 -1
  55. package/dist/core/runner/prepare-memory.d.ts +16 -0
  56. package/dist/core/runner/prepare-memory.js +191 -0
  57. package/dist/core/runner/prepare-task.d.ts +4 -28
  58. package/dist/core/runner/prepare-task.js +19 -207
  59. package/dist/core/runner/prompt-suggestions.d.ts +1 -1
  60. package/dist/core/runner/runtask.d.ts +2 -3
  61. package/dist/core/runner/runtask.js +337 -529
  62. package/dist/core/runner/session-rule-policy.d.ts +1 -1
  63. package/dist/core/runner/synthetic-tools.d.ts +5 -5
  64. package/dist/core/runner/synthetic-tools.js +4 -4
  65. package/dist/core/runner/tool-disclosure.d.ts +3 -3
  66. package/dist/core/runner/tool-disclosure.js +2 -2
  67. package/dist/core/runner/tool-output-projection.d.ts +6 -0
  68. package/dist/core/runner/tool-output-projection.js +81 -0
  69. package/dist/core/runtime.d.ts +1 -1
  70. package/dist/core/scheduler.d.ts +1 -1
  71. package/dist/core/sensitive-path-policy.d.ts +1 -1
  72. package/dist/core/session-reconcile.d.ts +1 -1
  73. package/dist/core/session-store.d.ts +2 -1
  74. package/dist/core/session-store.js +2 -1
  75. package/dist/core/session.d.ts +0 -1
  76. package/dist/core/task-registry-agent.d.ts +115 -0
  77. package/dist/core/task-registry-agent.js +1163 -0
  78. package/dist/core/task-registry-monitor.d.ts +13 -0
  79. package/dist/core/task-registry-monitor.js +347 -0
  80. package/dist/core/task-registry-shared.d.ts +294 -0
  81. package/dist/core/task-registry-shared.js +271 -0
  82. package/dist/core/task-registry-workflow.d.ts +5 -0
  83. package/dist/core/task-registry-workflow.js +143 -0
  84. package/dist/core/task-registry.d.ts +51 -216
  85. package/dist/core/task-registry.js +127 -1940
  86. package/dist/core/task-tool-shape.d.ts +32 -0
  87. package/dist/core/task-tool-shape.js +83 -0
  88. package/dist/core/tool-policy.d.ts +1 -2
  89. package/dist/core/tool-result-budget.d.ts +1 -1
  90. package/dist/core/tool-result-store.d.ts +2 -2
  91. package/dist/core/tool-result-store.js +1 -1
  92. package/dist/core/tools.d.ts +2 -3
  93. package/dist/core/tools.js +0 -8
  94. package/dist/core/trace.d.ts +2 -2
  95. package/dist/core/types.d.ts +0 -29
  96. package/dist/core/workflow-run-store-contract.d.ts +1 -1
  97. package/dist/core/workflow-run-store-contract.js +19 -19
  98. package/dist/engine/execution-env/node-execution-env.d.ts +13 -0
  99. package/dist/engine/execution-env/node-execution-env.js +55 -25
  100. package/dist/engine/lsp/frame-decoder.d.ts +1 -1
  101. package/dist/engine/lsp/frame-decoder.js +1 -1
  102. package/dist/engine/lsp/node-lsp-manager.d.ts +1 -1
  103. package/dist/engine/lsp/stdio-lsp-transport.js +2 -2
  104. package/dist/index.d.ts +16 -14
  105. package/dist/index.js +13 -11
  106. package/dist/internal/harness-types.d.ts +7 -0
  107. package/dist/internal/harness-types.js +1 -0
  108. package/dist/internal/harness.d.ts +1 -7
  109. package/dist/internal/harness.js +1 -0
  110. package/dist/orchestration/goal.js +2 -2
  111. package/dist/orchestration/run-workflow-tool.d.ts +1 -1
  112. package/dist/orchestration/workflow-types.d.ts +193 -0
  113. package/dist/orchestration/workflow-types.js +54 -0
  114. package/dist/orchestration/workflow.d.ts +3 -193
  115. package/dist/orchestration/workflow.js +7 -59
  116. package/dist/prompt-assembly/assemble.d.ts +3 -3
  117. package/dist/prompt-assembly/assemble.js +0 -16
  118. package/dist/prompt-assembly/explain.d.ts +1 -1
  119. package/dist/prompt-assembly/tool-catalog.d.ts +1 -1
  120. package/dist/prompts/default.d.ts +1 -6
  121. package/dist/prompts/default.js +3 -11
  122. package/dist/scenarios/env.d.ts +1 -1
  123. package/dist/scenarios/full-body.d.ts +0 -3
  124. package/dist/scenarios/full-body.js +0 -2
  125. package/dist/stores/file/background-agent-store.d.ts +2 -15
  126. package/dist/stores/file/background-agent-store.js +30 -100
  127. package/dist/stores/file/checkpoint-store.d.ts +1 -14
  128. package/dist/stores/file/checkpoint-store.js +47 -119
  129. package/dist/stores/file/file-snapshot-store.d.ts +1 -1
  130. package/dist/stores/file/shared-ledger.d.ts +35 -0
  131. package/dist/stores/file/shared-ledger.js +94 -0
  132. package/dist/stores/file/workflow-run-store.d.ts +1 -14
  133. package/dist/stores/file/workflow-run-store.js +24 -93
  134. package/dist/tools/fs/bash-readonly-classifier.d.ts +8 -0
  135. package/dist/tools/fs/bash-readonly-classifier.js +166 -0
  136. package/dist/tools/fs/fs-bash.d.ts +31 -0
  137. package/dist/tools/fs/fs-bash.js +672 -0
  138. package/dist/tools/fs/fs-pdf.d.ts +22 -0
  139. package/dist/tools/fs/fs-pdf.js +236 -0
  140. package/dist/tools/fs/fs-read.d.ts +8 -0
  141. package/dist/tools/fs/fs-read.js +286 -0
  142. package/dist/tools/fs/fs-search-tools.d.ts +5 -0
  143. package/dist/tools/fs/fs-search-tools.js +173 -0
  144. package/dist/tools/fs/fs-shared.d.ts +55 -0
  145. package/dist/tools/fs/fs-shared.js +144 -0
  146. package/dist/tools/fs/fs-write.d.ts +8 -0
  147. package/dist/tools/fs/fs-write.js +423 -0
  148. package/dist/tools/fs/index.d.ts +12 -65
  149. package/dist/tools/fs/index.js +26 -2090
  150. package/dist/tools/fs/pdf.d.ts +1 -1
  151. package/dist/tools/fs/repo-map.d.ts +3 -3
  152. package/dist/tools/fs/repo-map.js +1 -1
  153. package/dist/tools/fs/safety.d.ts +1 -1
  154. package/dist/tools/fs/search.d.ts +1 -1
  155. package/dist/tools/monitor.d.ts +1 -1
  156. package/dist/tools/scheduler-tools.d.ts +1 -1
  157. package/dist/tools/web.d.ts +2 -2
  158. package/dist/tools/web.js +1 -1
  159. package/dist/tools/worktree.d.ts +1 -1
  160. package/package.json +1 -1
  161. package/dist/core/dynamic-recall.d.ts +0 -32
  162. package/dist/core/dynamic-recall.js +0 -76
@@ -1,4 +1,4 @@
1
- import type { ExecutionEnv } from "../../internal/harness.js";
1
+ import type { ExecutionEnv } from "../../internal/harness-types.js";
2
2
  import type { ToolEffect } from "../types.js";
3
3
  import { type ToolPolicy } from "../tool-policy.js";
4
4
  import type { SessionPermissionRules } from "../session-policy-store.js";
@@ -1,5 +1,5 @@
1
1
  import { type TSchema } from "typebox";
2
- import type { AgentTool } from "../../internal/harness.js";
2
+ import type { AgentTool } from "../../internal/harness-types.js";
3
3
  import type { SkillManifest } from "../types.js";
4
4
  import type { ActiveSkillScope } from "./active-skill-scope.js";
5
5
  export declare const OUTPUT_TOOL_NAME = "StructuredOutput";
@@ -14,8 +14,8 @@ export interface OutputRef {
14
14
  value?: unknown;
15
15
  set?: boolean;
16
16
  }
17
- export declare function makeOutputTool(ref: OutputRef, schema: TSchema, strictSchema?: TSchema): AgentTool;
18
- export declare function makeReportBlockedTool(ref: BlockedRef): AgentTool;
17
+ export declare function createOutputTool(ref: OutputRef, schema: TSchema, strictSchema?: TSchema): AgentTool;
18
+ export declare function createReportBlockedTool(ref: BlockedRef): AgentTool;
19
19
  export interface ReportedFinding {
20
20
  file: string;
21
21
  line?: number;
@@ -25,7 +25,7 @@ export interface ReportedFinding {
25
25
  verdict?: "CONFIRMED" | "PLAUSIBLE";
26
26
  outcome?: "fixed" | "skipped" | "no_change_needed";
27
27
  }
28
- export declare function makeReportFindingsTool(): AgentTool;
28
+ export declare function createReportFindingsTool(): AgentTool;
29
29
  export declare const SKILL_TOOL_NAME = "Skill";
30
30
  export declare const SKILL_CONTENT_MAX_CHARS: number;
31
31
  export declare const SKILLS_BLOCK_MAX_BYTES = 8000;
@@ -52,5 +52,5 @@ export declare function normalizeSkills(skills: SkillLike[] | undefined): SkillL
52
52
  export declare const SKILLS_LISTING_PROBE_HEADER = "The following skills are available for this task.";
53
53
  export declare function skillListingLine(s: SkillListingEntry): string;
54
54
  export declare function buildSkillsBlock(skills: ReadonlyArray<SkillListingEntry>): string | undefined;
55
- export declare function makeSkillTool(skills: SkillLike[], scope?: ActiveSkillScope): AgentTool;
55
+ export declare function createSkillTool(skills: SkillLike[], scope?: ActiveSkillScope): AgentTool;
56
56
  export {};
@@ -11,7 +11,7 @@ export function resolveOutputRetries(outputRetries) {
11
11
  return OUTPUT_DEFAULT_RETRIES;
12
12
  return Math.floor(outputRetries);
13
13
  }
14
- export function makeOutputTool(ref, schema, strictSchema) {
14
+ export function createOutputTool(ref, schema, strictSchema) {
15
15
  return defineTool({
16
16
  name: OUTPUT_TOOL_NAME,
17
17
  contract: { contractId: "core.structured_output@1", implementationRevision: "1" },
@@ -26,7 +26,7 @@ export function makeOutputTool(ref, schema, strictSchema) {
26
26
  },
27
27
  });
28
28
  }
29
- export function makeReportBlockedTool(ref) {
29
+ export function createReportBlockedTool(ref) {
30
30
  return defineTool({
31
31
  name: REPORT_BLOCKED_TOOL_NAME,
32
32
  contract: { contractId: "core.report_blocked@1", implementationRevision: "1" },
@@ -55,7 +55,7 @@ const REPORT_FINDING_SCHEMA = Type.Object({
55
55
  description: "Set ONLY when re-reporting after applying fixes: what happened to this finding",
56
56
  })),
57
57
  });
58
- export function makeReportFindingsTool() {
58
+ export function createReportFindingsTool() {
59
59
  return defineTool({
60
60
  name: REPORT_FINDINGS_TOOL_NAME,
61
61
  contract: { contractId: "core.report_findings@1", implementationRevision: "1" },
@@ -167,7 +167,7 @@ export function buildSkillsBlock(skills) {
167
167
  }
168
168
  return render([SKILLS_BLOCK_CAP_MARKER, `(… +${skills.length} more skills not listed — the ${SKILL_TOOL_NAME} tool serves them all)`]);
169
169
  }
170
- export function makeSkillTool(skills, scope) {
170
+ export function createSkillTool(skills, scope) {
171
171
  const byName = new Map(skills.map((s) => [s.name, s]));
172
172
  const names = skills.map((s) => s.name).join(", ");
173
173
  return defineTool({
@@ -1,4 +1,4 @@
1
- import type { AgentMessage, AgentTool } from "../../internal/harness.js";
1
+ import type { AgentMessage, AgentTool } from "../../internal/harness-types.js";
2
2
  import type { Model } from "../../internal/llm.js";
3
3
  import type { ToolSpec } from "../types.js";
4
4
  export declare const TOOL_SEARCH_NAME = "ToolSearch";
@@ -26,7 +26,7 @@ export declare function buildDeferredRegistry(deferred: ReadonlySet<string>, too
26
26
  name: string;
27
27
  description: string;
28
28
  }>): Map<string, DeferredToolInfo>;
29
- export declare function makePlaceholderTool(info: DeferredToolInfo): AgentTool;
29
+ export declare function createPlaceholderTool(info: DeferredToolInfo): AgentTool;
30
30
  export declare function scoreToolMatch(query: string, info: DeferredToolInfo): number;
31
31
  export interface ToolSearchArgs {
32
32
  query?: string;
@@ -39,7 +39,7 @@ export declare function resolveToolSearchDetailed(args: ToolSearchArgs, registry
39
39
  };
40
40
  export declare function resolveToolSearch(args: ToolSearchArgs, registry: ReadonlyMap<string, DeferredToolInfo>): string[];
41
41
  export declare function extractDiscoveredToolNames(messages: ReadonlyArray<AgentMessage>, registry: ReadonlyMap<string, DeferredToolInfo>): string[];
42
- export declare function makeToolSearchTool(opts: {
42
+ export declare function createToolSearchTool(opts: {
43
43
  registry: ReadonlyMap<string, DeferredToolInfo>;
44
44
  active: Set<string>;
45
45
  rematerialize: (active: ReadonlySet<string>) => Promise<void>;
@@ -52,7 +52,7 @@ export function buildDeferredRegistry(deferred, tools) {
52
52
  }
53
53
  return reg;
54
54
  }
55
- export function makePlaceholderTool(info) {
55
+ export function createPlaceholderTool(info) {
56
56
  const sn = safeName(info.name);
57
57
  return defineTool({
58
58
  name: info.name,
@@ -152,7 +152,7 @@ export function extractDiscoveredToolNames(messages, registry) {
152
152
  }
153
153
  return [...names];
154
154
  }
155
- export function makeToolSearchTool(opts) {
155
+ export function createToolSearchTool(opts) {
156
156
  const { registry, active, rematerialize, listingRide, mountedNames } = opts;
157
157
  let activationChain = Promise.resolve();
158
158
  return defineTool({
@@ -0,0 +1,6 @@
1
+ export declare const toolOutputFrom: (result: unknown) => {
2
+ output: unknown;
3
+ truncated: boolean;
4
+ totalChars?: number;
5
+ } | undefined;
6
+ export declare const structuredFrom: (result: unknown) => unknown;
@@ -0,0 +1,81 @@
1
+ const MAX_TOOL_END_OUTPUT_CHARS = 16384;
2
+ const safeJsonLength = (v) => {
3
+ try {
4
+ return JSON.stringify(v)?.length;
5
+ }
6
+ catch {
7
+ return undefined;
8
+ }
9
+ };
10
+ const trunc = (s) => ({
11
+ text: s.slice(0, MAX_TOOL_END_OUTPUT_CHARS) + `…[+${s.length - MAX_TOOL_END_OUTPUT_CHARS} chars truncated]`,
12
+ totalChars: s.length,
13
+ });
14
+ export const toolOutputFrom = (result) => {
15
+ const content = result !== null && typeof result === "object" ? result.content : result;
16
+ if (content === undefined)
17
+ return undefined;
18
+ if (typeof content === "string") {
19
+ if (content.length <= MAX_TOOL_END_OUTPUT_CHARS)
20
+ return { output: content, truncated: false };
21
+ const t = trunc(content);
22
+ return { output: t.text, truncated: true, totalChars: t.totalChars };
23
+ }
24
+ let serialized;
25
+ try {
26
+ serialized = JSON.stringify(content) ?? "";
27
+ }
28
+ catch {
29
+ return { output: "[unserializable tool output]", truncated: false };
30
+ }
31
+ if (serialized.length <= MAX_TOOL_END_OUTPUT_CHARS)
32
+ return { output: content, truncated: false };
33
+ let anyNonText = false;
34
+ let trueChars = 0;
35
+ const raw = Array.isArray(content)
36
+ ? content
37
+ .map((b) => {
38
+ const block = b;
39
+ if (block?.type === "text" && typeof block.text === "string") {
40
+ trueChars += block.text.length;
41
+ return block.text;
42
+ }
43
+ anyNonText = true;
44
+ trueChars += typeof block?.data === "string" ? block.data.length : (safeJsonLength(block) ?? 0);
45
+ return `[${typeof block?.type === "string" ? block.type : "block"}${typeof block?.mimeType === "string" ? `: ${block.mimeType}` : ""}]`;
46
+ })
47
+ .join("\n")
48
+ : serialized;
49
+ const totalChars = Array.isArray(content) ? trueChars : serialized.length;
50
+ if (raw.length > MAX_TOOL_END_OUTPUT_CHARS) {
51
+ const t = trunc(raw);
52
+ return { output: t.text, truncated: true, totalChars };
53
+ }
54
+ if (!anyNonText) {
55
+ return { output: raw, truncated: false };
56
+ }
57
+ return { output: raw, truncated: true, totalChars };
58
+ };
59
+ const CC_DETAIL_TYPES = new Set([
60
+ "edit", "multiedit", "create", "update", "bash", "notebook-edit", "notebook", "text", "grep", "glob", "mcp",
61
+ "agent", "task", "task-list", "task-output", "memory-saved", "workflow-run",
62
+ "web-fetch", "web-search", "todo", "cron-create", "cron-delete", "cron-list", "image",
63
+ "task-stop", "tool-search", "memory-recall", "repo-map", "fork", "enter-plan-mode", "exit-plan-mode",
64
+ ]);
65
+ export const structuredFrom = (result) => {
66
+ const details = result !== null && typeof result === "object" ? result.details : undefined;
67
+ if (details === null || typeof details !== "object")
68
+ return undefined;
69
+ const t = details.type;
70
+ if (typeof t !== "string" || !CC_DETAIL_TYPES.has(t))
71
+ return undefined;
72
+ try {
73
+ const serialized = JSON.stringify(details) ?? "";
74
+ if (serialized.length > MAX_TOOL_END_OUTPUT_CHARS * 4)
75
+ return undefined;
76
+ }
77
+ catch {
78
+ return undefined;
79
+ }
80
+ return details;
81
+ };
@@ -1,3 +1,3 @@
1
- import type { AgentCoreRuntimeDeps } from "../internal/harness.js";
1
+ import type { AgentCoreRuntimeDeps } from "../internal/harness-types.js";
2
2
  import type { Brain } from "./types.js";
3
3
  export declare function brainToRuntime(brain: Brain): AgentCoreRuntimeDeps;
@@ -1,4 +1,4 @@
1
- import type { ExecutionEnv, Result } from "../internal/harness.js";
1
+ import type { ExecutionEnv, Result } from "../internal/harness-types.js";
2
2
  export type ScheduledTaskId = string & {
3
3
  readonly __brand: "ScheduledTaskId";
4
4
  };
@@ -1,4 +1,4 @@
1
- import type { ExecutionEnv } from "../internal/harness.js";
1
+ import type { ExecutionEnv } from "../internal/harness-types.js";
2
2
  import type { ToolPolicy } from "./tool-policy.js";
3
3
  export declare const RECOMMENDED_SENSITIVE_PATTERNS: readonly string[];
4
4
  export declare function createSensitivePathPolicy(opts: {
@@ -1,4 +1,4 @@
1
- import type { AgentMessage } from "../internal/harness.js";
1
+ import type { AgentMessage } from "../internal/harness-types.js";
2
2
  import type { Session } from "./session.js";
3
3
  import type { ToolEffect } from "./types.js";
4
4
  export interface OrphanToolCall {
@@ -1,6 +1,7 @@
1
1
  import { type SessionRepo } from "../internal/harness.js";
2
2
  import { type AcquiredSession, type SessionStore, type SessionStoreSummary } from "./session.js";
3
- export declare const SESSION_DEFAULT_TTL_DAYS = 7;
3
+ import { SESSION_DEFAULT_TTL_DAYS } from "../config/defaults.js";
4
+ export { SESSION_DEFAULT_TTL_DAYS };
4
5
  export type EvictPolicy = "delete" | "forget";
5
6
  export interface TtlSessionStoreOptions {
6
7
  defaultTtlDays?: number;
@@ -1,7 +1,8 @@
1
1
  import { InMemorySessionRepo, uuidv7, } from "../internal/harness.js";
2
2
  import { isSessionConflict } from "./session.js";
3
3
  const DAY_MS = 24 * 60 * 60 * 1000;
4
- export const SESSION_DEFAULT_TTL_DAYS = 7;
4
+ import { SESSION_DEFAULT_TTL_DAYS } from "../config/defaults.js";
5
+ export { SESSION_DEFAULT_TTL_DAYS };
5
6
  export class TtlSessionStore {
6
7
  repo;
7
8
  entries = new Map();
@@ -19,7 +19,6 @@ export interface SessionStoreSummary {
19
19
  lastTaskId?: string;
20
20
  forkedFrom?: string;
21
21
  }
22
- export type SessionSummary = SessionStoreSummary;
23
22
  export interface SessionStore {
24
23
  acquire(sessionId?: string, opts?: {
25
24
  requireExisting?: boolean;
@@ -0,0 +1,115 @@
1
+ import { type BackgroundAgentRecord, type BackgroundAgentStore } from "./background-agent-store.js";
2
+ import { type StopSource, type TaskAccess, type UnifiedTaskResult, type BackgroundAgentTaskHandle, type DurableAgentCore, type ParkedClaimTicket, type RegisterBackgroundAgentInput } from "./task-registry-shared.js";
3
+ export declare function ensureDurableHeartbeatLane(core: DurableAgentCore): void;
4
+ export declare function durableAgentWriteLane(handle: BackgroundAgentTaskHandle, patch: Partial<BackgroundAgentRecord>, clear?: (keyof BackgroundAgentRecord)[]): void;
5
+ export declare function durableAgentArmedLane(core: DurableAgentCore, id: string): boolean;
6
+ export declare function durableAgentRowProbeLane(core: DurableAgentCore, id: string): (() => Promise<boolean>) | undefined;
7
+ export declare function beginDurableClaimLane(core: DurableAgentCore, id: string): boolean;
8
+ export declare function endDurableClaimLane(core: DurableAgentCore, id: string): void;
9
+ export declare function reapDurableAgentsLane(core: DurableAgentCore, scope: string, deps: {
10
+ store: BackgroundAgentStore;
11
+ sessions?: {
12
+ unpin?(sessionId: string): unknown;
13
+ release(sessionId: string): Promise<void> | void;
14
+ };
15
+ mailbox?: {
16
+ drop(scope: string, handle: string): Promise<void>;
17
+ };
18
+ }, policy: {
19
+ now?: number;
20
+ maxAgeMs?: number;
21
+ keep?: number;
22
+ staleRunningMaxAgeMs?: number;
23
+ }): Promise<{
24
+ rowsReaped: number;
25
+ sessionsReleased: number;
26
+ skippedNoSessions: number;
27
+ }>;
28
+ export declare function releaseDurableTranscriptAnchorLane(core: DurableAgentCore, id: string): void;
29
+ export declare function bindBackgroundAgentSessionLane(core: DurableAgentCore, id: string, sessionId: string): void;
30
+ export declare function registerBackgroundAgentLane(core: DurableAgentCore, input: RegisterBackgroundAgentInput): string;
31
+ export declare function parkBackgroundAgentLane(core: DurableAgentCore, id: string, park: {
32
+ checkpointToken: string;
33
+ seq?: number;
34
+ resolveStop?: () => Promise<boolean>;
35
+ }): "parked" | undefined;
36
+ export declare function reconcileParkedAgentsLane(core: DurableAgentCore, stores: {
37
+ agentStore: import("./background-agent-store.js").BackgroundAgentStore;
38
+ checkpointStore: Pick<import("./checkpoint-store.js").CheckpointStore, "get">;
39
+ }, scope: string, now: number, opts?: {
40
+ staleClaimMaxAgeMs?: number;
41
+ }): Promise<{
42
+ failed: number;
43
+ rolledBack: number;
44
+ }>;
45
+ export declare function claimParkedAgentLane(stores: {
46
+ agentStore: import("./background-agent-store.js").BackgroundAgentStore;
47
+ checkpointStore: Pick<import("./checkpoint-store.js").CheckpointStore, "get">;
48
+ }, handle: string, access: TaskAccess): Promise<{
49
+ ok: true;
50
+ ticket: ParkedClaimTicket;
51
+ } | {
52
+ ok: false;
53
+ reason: "not_found" | "not_parked" | "binding_broken" | "checkpoint_not_pending" | "claim_lost" | "store_unreachable";
54
+ }>;
55
+ export declare function rollbackParkedClaimLane(core: DurableAgentCore, stores: {
56
+ agentStore: import("./background-agent-store.js").BackgroundAgentStore;
57
+ checkpointStore: Pick<import("./checkpoint-store.js").CheckpointStore, "get">;
58
+ }, ticket: ParkedClaimTicket): Promise<"rolled_back" | "failed" | "lost" | "retry">;
59
+ export declare function consumeParkedFlipLane(core: DurableAgentCore, id: string, stores: {
60
+ agentStore: import("./background-agent-store.js").BackgroundAgentStore;
61
+ }, ticket: ParkedClaimTicket): Promise<boolean>;
62
+ export declare function finalizeParkedResumeLane(core: DurableAgentCore, id: string): void;
63
+ export declare function settleBackgroundAgentLane(core: DurableAgentCore, id: string, outcome: {
64
+ status: "completed" | "failed" | "killed";
65
+ result?: string;
66
+ resultFull?: string;
67
+ error?: string;
68
+ stoppedBy?: StopSource;
69
+ seq?: number;
70
+ }): "completed" | "failed" | "killed" | undefined;
71
+ export declare function abortBackgroundAgentsForOwnerLane(core: DurableAgentCore, access: TaskAccess, opts?: {
72
+ skipSessionScoped?: boolean;
73
+ sessionScopedOnly?: boolean;
74
+ }): number;
75
+ export declare function resolveBackgroundAgentByNameLane(core: DurableAgentCore, name: string, access: TaskAccess, opts?: {
76
+ preferRunning?: boolean;
77
+ }): {
78
+ status: "found";
79
+ handle: BackgroundAgentTaskHandle;
80
+ } | {
81
+ status: "ambiguous";
82
+ message: string;
83
+ } | {
84
+ status: "not_found";
85
+ suggestion?: string;
86
+ };
87
+ export declare function markRetainedContinuationLane(core: DurableAgentCore, id: string): void;
88
+ export declare function reviveBackgroundAgentLane(core: DurableAgentCore, id: string, access: TaskAccess, abort?: AbortController): {
89
+ ok: true;
90
+ cycle: number;
91
+ } | {
92
+ ok: false;
93
+ reason: "not_found" | "still_running";
94
+ };
95
+ export declare function settleRevivedAgentLane(core: DurableAgentCore, id: string, cycle: number, outcome: {
96
+ status: "completed" | "failed" | "killed";
97
+ result?: string;
98
+ resultFull?: string;
99
+ error?: string;
100
+ }): "completed" | "failed" | "killed" | undefined;
101
+ export declare function unmarkRetainedContinuationLane(core: DurableAgentCore, id: string): void;
102
+ export declare function attachAgentNotifyLane(core: DurableAgentCore, id: string, notify: NonNullable<BackgroundAgentTaskHandle["notify"]>, cycle?: number): void;
103
+ export declare function deliverToRunningAgentLane(core: DurableAgentCore, id: string, access: TaskAccess, notification: import("./task-notification.js").TaskNotificationPayload, opts?: {
104
+ priority?: import("./task-notification.js").SystemInjectionPriority;
105
+ }): Promise<{
106
+ ok: true;
107
+ disposition: "queued" | "parked" | "pending";
108
+ } | {
109
+ ok: false;
110
+ reason: "not_found" | "not_running" | "no_channel";
111
+ }>;
112
+ export declare function runningBackgroundAgentLabelsLane(core: DurableAgentCore, access: TaskAccess): string[];
113
+ export declare function serveDurableAgentRowLane(row: BackgroundAgentRecord): UnifiedTaskResult;
114
+ export declare function pollBackgroundAgentLane(handle: BackgroundAgentTaskHandle, deadline?: number, signal?: AbortSignal): Promise<UnifiedTaskResult>;
115
+ export declare function stopBackgroundAgentLane(core: DurableAgentCore, handle: BackgroundAgentTaskHandle): Promise<UnifiedTaskResult>;