@sixb/agent 0.0.0-stage → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +31 -2
- package/dist/abort.d.ts +6 -0
- package/dist/abort.d.ts.map +1 -0
- package/dist/agent-prompt.d.ts +126 -0
- package/dist/agent-prompt.d.ts.map +1 -0
- package/dist/agent-runtime/errors.d.ts +13 -0
- package/dist/agent-runtime/errors.d.ts.map +1 -0
- package/dist/agent-runtime/preflight.d.ts +18 -0
- package/dist/agent-runtime/preflight.d.ts.map +1 -0
- package/dist/agent-runtime/profile.d.ts +14 -0
- package/dist/agent-runtime/profile.d.ts.map +1 -0
- package/dist/artifacts/layout-check/layout-check.d.ts +87 -0
- package/dist/artifacts/layout-check/layout-check.d.ts.map +1 -0
- package/dist/artifacts/materialize.d.ts +115 -0
- package/dist/artifacts/materialize.d.ts.map +1 -0
- package/dist/artifacts/publish-tool.d.ts +86 -0
- package/dist/artifacts/publish-tool.d.ts.map +1 -0
- package/dist/ask-parent-tool.d.ts +36 -0
- package/dist/ask-parent-tool.d.ts.map +1 -0
- package/dist/attachments.d.ts +109 -0
- package/dist/attachments.d.ts.map +1 -0
- package/dist/child-files.d.ts +91 -0
- package/dist/child-files.d.ts.map +1 -0
- package/dist/child-questions.d.ts +24 -0
- package/dist/child-questions.d.ts.map +1 -0
- package/dist/computer-runner.d.ts +74 -0
- package/dist/computer-runner.d.ts.map +1 -0
- package/dist/context-budget.d.ts +34 -0
- package/dist/context-budget.d.ts.map +1 -0
- package/dist/context-compaction.d.ts +148 -0
- package/dist/context-compaction.d.ts.map +1 -0
- package/dist/context-guard.d.ts +69 -0
- package/dist/context-guard.d.ts.map +1 -0
- package/dist/conversation-memory.d.ts +21 -0
- package/dist/conversation-memory.d.ts.map +1 -0
- package/dist/conversation-messages.d.ts +33 -0
- package/dist/conversation-messages.d.ts.map +1 -0
- package/dist/errors.d.ts +46 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/execution-plan.d.ts +38 -0
- package/dist/execution-plan.d.ts.map +1 -0
- package/dist/failure.d.ts +14 -0
- package/dist/failure.d.ts.map +1 -0
- package/dist/family-mailbox.d.ts +60 -0
- package/dist/family-mailbox.d.ts.map +1 -0
- package/dist/file-ref.d.ts +6 -0
- package/dist/file-ref.d.ts.map +1 -0
- package/dist/image-attachments.d.ts +34 -0
- package/dist/image-attachments.d.ts.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14387 -0
- package/dist/index.js.map +72 -0
- package/dist/inline-images.d.ts +28 -0
- package/dist/inline-images.d.ts.map +1 -0
- package/dist/message-authors.d.ts +34 -0
- package/dist/message-authors.d.ts.map +1 -0
- package/dist/message-times.d.ts +9 -0
- package/dist/message-times.d.ts.map +1 -0
- package/dist/model-adapters.d.ts +59 -0
- package/dist/model-adapters.d.ts.map +1 -0
- package/dist/model-lines.d.ts +16 -0
- package/dist/model-lines.d.ts.map +1 -0
- package/dist/prompt-cache.d.ts +28 -0
- package/dist/prompt-cache.d.ts.map +1 -0
- package/dist/requester.d.ts +15 -0
- package/dist/requester.d.ts.map +1 -0
- package/dist/run-agent-turn.d.ts +93 -0
- package/dist/run-agent-turn.d.ts.map +1 -0
- package/dist/run-child.d.ts +77 -0
- package/dist/run-child.d.ts.map +1 -0
- package/dist/run-conversation-turn.d.ts +42 -0
- package/dist/run-conversation-turn.d.ts.map +1 -0
- package/dist/run-credential.d.ts +22 -0
- package/dist/run-credential.d.ts.map +1 -0
- package/dist/run-environment.d.ts +145 -0
- package/dist/run-environment.d.ts.map +1 -0
- package/dist/run-fate.d.ts +15 -0
- package/dist/run-fate.d.ts.map +1 -0
- package/dist/run-files-lock.d.ts +16 -0
- package/dist/run-files-lock.d.ts.map +1 -0
- package/dist/run-sandbox.d.ts +60 -0
- package/dist/run-sandbox.d.ts.map +1 -0
- package/dist/run-subagent.d.ts +65 -0
- package/dist/run-subagent.d.ts.map +1 -0
- package/dist/run-workflow-agent-node.d.ts +46 -0
- package/dist/run-workflow-agent-node.d.ts.map +1 -0
- package/dist/sandbox-api-context.d.ts +34 -0
- package/dist/sandbox-api-context.d.ts.map +1 -0
- package/dist/sandbox-file-registry.d.ts +9 -0
- package/dist/sandbox-file-registry.d.ts.map +1 -0
- package/dist/sandbox-files.d.ts +71 -0
- package/dist/sandbox-files.d.ts.map +1 -0
- package/dist/sandbox-handle.d.ts +15 -0
- package/dist/sandbox-handle.d.ts.map +1 -0
- package/dist/sandbox-readiness.d.ts +8 -0
- package/dist/sandbox-readiness.d.ts.map +1 -0
- package/dist/skills/built-in.d.ts +15 -0
- package/dist/skills/built-in.d.ts.map +1 -0
- package/dist/subagent-context.d.ts +50 -0
- package/dist/subagent-context.d.ts.map +1 -0
- package/dist/subagent-continuation.d.ts +33 -0
- package/dist/subagent-continuation.d.ts.map +1 -0
- package/dist/subagent-inbox.d.ts +53 -0
- package/dist/subagent-inbox.d.ts.map +1 -0
- package/dist/subagent-tools.d.ts +293 -0
- package/dist/subagent-tools.d.ts.map +1 -0
- package/dist/thread-context.d.ts +17 -0
- package/dist/thread-context.d.ts.map +1 -0
- package/dist/tools/attachments.d.ts +11 -0
- package/dist/tools/attachments.d.ts.map +1 -0
- package/dist/tools/bash.d.ts +68 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/model-spec.d.ts +9 -0
- package/dist/tools/model-spec.d.ts.map +1 -0
- package/dist/tools/read.d.ts +43 -0
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/result-media.d.ts +65 -0
- package/dist/tools/result-media.d.ts.map +1 -0
- package/dist/tools/result-output.d.ts +18 -0
- package/dist/tools/result-output.d.ts.map +1 -0
- package/dist/tools/tool-files.d.ts +59 -0
- package/dist/tools/tool-files.d.ts.map +1 -0
- package/dist/tools/tool-outputs.d.ts +63 -0
- package/dist/tools/tool-outputs.d.ts.map +1 -0
- package/dist/tools/view-file.d.ts +40 -0
- package/dist/tools/view-file.d.ts.map +1 -0
- package/dist/tsconfig.json +5 -0
- package/dist/turn-runtime.d.ts +19 -0
- package/dist/turn-runtime.d.ts.map +1 -0
- package/dist/types.d.ts +83 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/workflow-input-attachments.d.ts +18 -0
- package/dist/workflow-input-attachments.d.ts.map +1 -0
- package/package.json +59 -4
- package/src/abort.ts +40 -0
- package/src/agent-prompt.ts +860 -0
- package/src/agent-runtime/errors.ts +44 -0
- package/src/agent-runtime/preflight.ts +314 -0
- package/src/agent-runtime/profile.ts +23 -0
- package/src/artifacts/layout-check/check.cjs +478 -0
- package/src/artifacts/layout-check/layout-check.ts +460 -0
- package/src/artifacts/materialize.ts +380 -0
- package/src/artifacts/publish-tool.ts +700 -0
- package/src/ask-parent-tool.ts +100 -0
- package/src/attachments.ts +1041 -0
- package/src/child-files.ts +535 -0
- package/src/child-questions.ts +42 -0
- package/src/computer-runner.ts +336 -0
- package/src/context-budget.ts +177 -0
- package/src/context-compaction.ts +1349 -0
- package/src/context-guard.ts +826 -0
- package/src/conversation-memory.ts +45 -0
- package/src/conversation-messages.ts +86 -0
- package/src/errors.ts +85 -0
- package/src/execution-plan.ts +70 -0
- package/src/failure.ts +82 -0
- package/src/family-mailbox.ts +189 -0
- package/src/file-ref.ts +18 -0
- package/src/image-attachments.ts +322 -0
- package/src/index.ts +54 -0
- package/src/inline-images.ts +69 -0
- package/src/message-authors.ts +77 -0
- package/src/message-times.ts +24 -0
- package/src/model-adapters.ts +273 -0
- package/src/model-lines.ts +28 -0
- package/src/prompt-cache.ts +40 -0
- package/src/requester.ts +21 -0
- package/src/run-agent-turn.ts +509 -0
- package/src/run-child.ts +344 -0
- package/src/run-conversation-turn.ts +272 -0
- package/src/run-credential.ts +55 -0
- package/src/run-environment.ts +1216 -0
- package/src/run-fate.ts +51 -0
- package/src/run-files-lock.ts +118 -0
- package/src/run-sandbox.ts +63 -0
- package/src/run-subagent.ts +433 -0
- package/src/run-workflow-agent-node.ts +344 -0
- package/src/sandbox-api-context.ts +237 -0
- package/src/sandbox-file-registry.ts +26 -0
- package/src/sandbox-files.ts +326 -0
- package/src/sandbox-handle.ts +19 -0
- package/src/sandbox-readiness.ts +22 -0
- package/src/skills/built-in.ts +183 -0
- package/src/skills/sixb-artifacts/SKILL.md +95 -0
- package/src/skills/sixb-artifacts/canvas.md +104 -0
- package/src/skills/sixb-artifacts/document.md +63 -0
- package/src/skills/sixb-artifacts/examples/canvas/onboarding-flow/boards/first-job.html +42 -0
- package/src/skills/sixb-artifacts/examples/canvas/onboarding-flow/boards/region.html +29 -0
- package/src/skills/sixb-artifacts/examples/canvas/onboarding-flow/boards/shared.css +35 -0
- package/src/skills/sixb-artifacts/examples/canvas/onboarding-flow/boards/welcome.html +31 -0
- package/src/skills/sixb-artifacts/examples/canvas/onboarding-flow/canvas.json +107 -0
- package/src/skills/sixb-artifacts/examples/canvas/retro/canvas.json +158 -0
- package/src/skills/sixb-artifacts/examples/document/incident-report/document.md +35 -0
- package/src/skills/sixb-artifacts/examples/document/operations-review/document.md +41 -0
- package/src/skills/sixb-artifacts/examples/document/operations-review/figures/restorations.svg +1 -0
- package/src/skills/sixb-artifacts/examples/page/collections-desk/index.html +169 -0
- package/src/skills/sixb-artifacts/examples/page/collections-desk/queries/overdue.json +13 -0
- package/src/skills/sixb-artifacts/examples/page/dispatch-board/data/dispatch.json +234 -0
- package/src/skills/sixb-artifacts/examples/page/dispatch-board/index.html +245 -0
- package/src/skills/sixb-artifacts/examples/page/fleet-planner/data/plan.json +53 -0
- package/src/skills/sixb-artifacts/examples/page/fleet-planner/index.html +462 -0
- package/src/skills/sixb-artifacts/examples/page/service-explorer/data/service.json +276 -0
- package/src/skills/sixb-artifacts/examples/page/service-explorer/index.html +549 -0
- package/src/skills/sixb-artifacts/examples/sheet/overdue-invoices/queries/overdue.json +13 -0
- package/src/skills/sixb-artifacts/examples/sheet/overdue-invoices/workbook.json +30 -0
- package/src/skills/sixb-artifacts/examples/sheet/parts-inventory/sheets/Inventory.csv +13 -0
- package/src/skills/sixb-artifacts/examples/sheet/parts-inventory/sheets/Spend.csv +6 -0
- package/src/skills/sixb-artifacts/examples/sheet/parts-inventory/workbook.json +47 -0
- package/src/skills/sixb-artifacts/examples/sheet/service-metrics/sheets/Quarters.csv +5 -0
- package/src/skills/sixb-artifacts/examples/sheet/service-metrics/sheets/Regions.csv +5 -0
- package/src/skills/sixb-artifacts/examples/sheet/service-metrics/workbook.json +78 -0
- package/src/skills/sixb-artifacts/examples/slides/launch-plan/index.html +63 -0
- package/src/skills/sixb-artifacts/examples/slides/q3-review/index.html +133 -0
- package/src/skills/sixb-artifacts/file.md +17 -0
- package/src/skills/sixb-artifacts/page.md +215 -0
- package/src/skills/sixb-artifacts/queries.md +66 -0
- package/src/skills/sixb-artifacts/references.md +68 -0
- package/src/skills/sixb-artifacts/sheet.md +223 -0
- package/src/skills/sixb-artifacts/slides.md +137 -0
- package/src/skills/sixb-memory/SKILL.md +68 -0
- package/src/skills/text-assets.d.ts +25 -0
- package/src/subagent-context.ts +182 -0
- package/src/subagent-continuation.ts +56 -0
- package/src/subagent-inbox.ts +101 -0
- package/src/subagent-tools.ts +1671 -0
- package/src/thread-context.ts +31 -0
- package/src/tools/attachments.ts +28 -0
- package/src/tools/bash.ts +233 -0
- package/src/tools/model-spec.ts +27 -0
- package/src/tools/read.ts +262 -0
- package/src/tools/result-media.ts +351 -0
- package/src/tools/result-output.ts +46 -0
- package/src/tools/tool-files.ts +204 -0
- package/src/tools/tool-outputs.ts +464 -0
- package/src/tools/view-file.ts +155 -0
- package/src/turn-runtime.ts +33 -0
- package/src/types.ts +91 -0
- package/src/workflow-input-attachments.ts +140 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { Principal } from "@sixb/core";
|
|
2
|
+
import { type AgentContextBudget, type AgentRunSession, type AgentTurnHistory } from "@sixb/core/internal/agents";
|
|
3
|
+
import type { WorkflowIOSnapshot } from "@sixb/core/internal/workflows";
|
|
4
|
+
import type { ModelTool } from "@sixb/core/models";
|
|
5
|
+
import type { AgentContextCheckpointReason, AgentThreadRecord, ConversationAgentRunRecord, SubagentRunRecord, WorkflowAgentNodeRunRecord } from "@sixb/core/storage";
|
|
6
|
+
import { type ConversationRequest } from "./context-compaction";
|
|
7
|
+
import type { ResolvedAgentExecutionPlan } from "./execution-plan";
|
|
8
|
+
import { type ConversationReaders } from "./message-authors";
|
|
9
|
+
import { type AgentErrorDetails, type AgentToolCaller } from "./model-adapters";
|
|
10
|
+
import type { BeforeFinalizeOptions, RunSandbox } from "./run-sandbox";
|
|
11
|
+
import { type SubagentThreadContext } from "./subagent-context";
|
|
12
|
+
import type { SubagentHistory } from "./subagent-continuation";
|
|
13
|
+
import { type LoadedAgentThreadModelContext } from "./thread-context";
|
|
14
|
+
import type { AgentTurnRuntime } from "./turn-runtime";
|
|
15
|
+
import type { AgentExecutionContext, AgentRunFiles, AgentTurnContext } from "./types";
|
|
16
|
+
export interface AgentExecutionEnvironment {
|
|
17
|
+
readonly turnContext: AgentTurnContext;
|
|
18
|
+
/** The run's sandbox and file budget, for the files a parent and its children hand each other. */
|
|
19
|
+
readonly runFiles: AgentRunFiles;
|
|
20
|
+
/** Confirm preservation before recording success, cancellation or failure. Idempotent. */
|
|
21
|
+
beforeFinalize(options?: BeforeFinalizeOptions): Promise<void>;
|
|
22
|
+
dispose(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export interface ConversationAgentExecutionEnvironment extends AgentExecutionEnvironment {
|
|
25
|
+
/** The history the turn runs on: as it started, or as its compaction left it. */
|
|
26
|
+
readonly threadContext: LoadedAgentThreadModelContext;
|
|
27
|
+
/**
|
|
28
|
+
* Compact the history before the turn from within it, once: the request the turn's calls then
|
|
29
|
+
* start with. Undefined when it could not. Only a turn whose environment ran its preflight has
|
|
30
|
+
* it.
|
|
31
|
+
*/
|
|
32
|
+
readonly compactInTurn?: (input: {
|
|
33
|
+
readonly reason: AgentContextCheckpointReason;
|
|
34
|
+
}) => Promise<ConversationRequest | undefined>;
|
|
35
|
+
/** The bytes per token the preflight measured the history at, which the turn's calls go by. */
|
|
36
|
+
readonly bytesPerToken?: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* How a runner gives a run its environment: a cloud sandbox, or a folder on a computer. The runner
|
|
40
|
+
* closes over whatever it opens it from (a factory, the thread's recipe, the run's credentials).
|
|
41
|
+
*/
|
|
42
|
+
export type OpenRunSandbox = (lifecycle: {
|
|
43
|
+
/** Stops provisioning: cancellation, lost ownership, or shutdown. */
|
|
44
|
+
readonly signal: AbortSignal;
|
|
45
|
+
/** Ends the run when its environment can no longer serve it, such as lost source credentials. */
|
|
46
|
+
readonly onFailure: (error: Error) => void;
|
|
47
|
+
}) => Promise<OpenedRunSandbox>;
|
|
48
|
+
export interface OpenedRunSandbox {
|
|
49
|
+
readonly sandbox: RunSandbox;
|
|
50
|
+
/** The workspace the run's paused attempt left: it holds that attempt's files already. */
|
|
51
|
+
readonly resumed?: boolean;
|
|
52
|
+
}
|
|
53
|
+
interface CreateAgentEnvironmentInput {
|
|
54
|
+
readonly context: AgentExecutionContext;
|
|
55
|
+
readonly plan: ResolvedAgentExecutionPlan;
|
|
56
|
+
/** The run's environment, opened by its runner. */
|
|
57
|
+
readonly openSandbox: OpenRunSandbox;
|
|
58
|
+
readonly signal?: AbortSignal;
|
|
59
|
+
/**
|
|
60
|
+
* Sink for a sandbox teardown that outlives dispose() (the model answered before the boot
|
|
61
|
+
* finished, so dispose returns without stalling on it). The worker registers these so a graceful
|
|
62
|
+
* stop() can drain them instead of leaving orphaned machines being torn down.
|
|
63
|
+
*/
|
|
64
|
+
readonly onDetachedTeardown?: (teardown: Promise<void>) => void;
|
|
65
|
+
}
|
|
66
|
+
export interface CreateConversationAgentEnvironmentInput extends CreateAgentEnvironmentInput {
|
|
67
|
+
/** The turn's session: its workspace, conversation and checkpoint go through it. */
|
|
68
|
+
readonly session: AgentRunSession;
|
|
69
|
+
readonly thread?: AgentThreadRecord | null;
|
|
70
|
+
/** Who asked for the turn: what it publishes is theirs, in an artifact the thread's owner owns. */
|
|
71
|
+
readonly requestedBy?: Principal;
|
|
72
|
+
/** Who can read the thread now: in a shared one, who wrote what counts toward the estimate. */
|
|
73
|
+
readonly conversation?: ConversationReaders;
|
|
74
|
+
/** Others were added to the thread, so it reaches the project's memory alone. */
|
|
75
|
+
readonly shared?: boolean;
|
|
76
|
+
/** Run preflight only after current sandbox access has been resolved. */
|
|
77
|
+
readonly preflight?: {
|
|
78
|
+
readonly budget: AgentContextBudget;
|
|
79
|
+
readonly runtime: AgentTurnRuntime;
|
|
80
|
+
};
|
|
81
|
+
readonly run: ConversationAgentRunRecord;
|
|
82
|
+
/** The conversation's history as the turn started (`AgentTurnContext.history`). */
|
|
83
|
+
readonly history: AgentTurnHistory;
|
|
84
|
+
/** Framework-owned tools of the conversational Agent: delegation. */
|
|
85
|
+
readonly frameworkTools?: readonly ModelTool[];
|
|
86
|
+
}
|
|
87
|
+
export interface CreateSubagentEnvironmentInput extends CreateAgentEnvironmentInput {
|
|
88
|
+
/** The child's session: its workspace goes through it. */
|
|
89
|
+
readonly session: AgentRunSession;
|
|
90
|
+
readonly run: SubagentRunRecord;
|
|
91
|
+
/** The child's own thread: memory is read as of its creation. */
|
|
92
|
+
readonly thread: AgentThreadRecord;
|
|
93
|
+
/** The conversation: what the child publishes lands there. Absent, it publishes nothing. */
|
|
94
|
+
readonly conversation?: AgentThreadRecord | null;
|
|
95
|
+
/** Who asked for the parent turn: what the child publishes is theirs. */
|
|
96
|
+
readonly requestedBy?: Principal;
|
|
97
|
+
/** Its thread's messages, whose files are projected again, and the paused run it continues. */
|
|
98
|
+
readonly history: SubagentHistory;
|
|
99
|
+
/** Framework-owned tools of a child: `ask_parent`. */
|
|
100
|
+
readonly frameworkTools?: readonly ModelTool[];
|
|
101
|
+
/** Weigh the thread before the first call, and compact it on the child's thread when needed. */
|
|
102
|
+
readonly preflight?: {
|
|
103
|
+
readonly budget: AgentContextBudget;
|
|
104
|
+
readonly runtime: AgentTurnRuntime;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export interface SubagentAgentExecutionEnvironment extends AgentExecutionEnvironment {
|
|
108
|
+
/** The thread the child runs on: as it started, or as its compaction left it. */
|
|
109
|
+
readonly thread: SubagentThreadContext;
|
|
110
|
+
/**
|
|
111
|
+
* Compact the thread before the run from within it, once: the request the run's calls then
|
|
112
|
+
* start with. Undefined when it could not. Only a child whose environment ran its preflight has
|
|
113
|
+
* it.
|
|
114
|
+
*/
|
|
115
|
+
readonly compactInRun?: (input: {
|
|
116
|
+
readonly reason: AgentContextCheckpointReason;
|
|
117
|
+
}) => Promise<ConversationRequest | undefined>;
|
|
118
|
+
/** The bytes per token the preflight measured the thread at, which the run's calls go by. */
|
|
119
|
+
readonly bytesPerToken?: number;
|
|
120
|
+
}
|
|
121
|
+
export interface CreateWorkflowAgentNodeEnvironmentInput extends CreateAgentEnvironmentInput {
|
|
122
|
+
readonly run: WorkflowAgentNodeRunRecord;
|
|
123
|
+
readonly workflowId: string;
|
|
124
|
+
readonly stepId: string;
|
|
125
|
+
readonly nodeInput: WorkflowIOSnapshot;
|
|
126
|
+
readonly errorDetails: AgentErrorDetails;
|
|
127
|
+
/** How the step calls a project tool: it runs in the cloud, so in the worker's process. */
|
|
128
|
+
readonly callTool: AgentToolCaller;
|
|
129
|
+
}
|
|
130
|
+
/** Prepare conversation history and attachments, then start the shared agent environment. */
|
|
131
|
+
export declare function createConversationAgentEnvironment(input: CreateConversationAgentEnvironmentInput): Promise<ConversationAgentExecutionEnvironment>;
|
|
132
|
+
/**
|
|
133
|
+
* Build an isolated environment for one headless child Agent. It knows the project as its parent
|
|
134
|
+
* does (ontology docs, memory to read), holds the files its parent handed over at their paths, and
|
|
135
|
+
* publishes into its conversation, as its own run.
|
|
136
|
+
*
|
|
137
|
+
* On a provider that resumes sandboxes, its thread keeps its workspace while it pauses: the run
|
|
138
|
+
* that continues it finds every file where it was. Elsewhere, or once those files were lost, it
|
|
139
|
+
* starts blank, with the handed files and what the paused run left in `out/` given back.
|
|
140
|
+
*/
|
|
141
|
+
export declare function createSubagentEnvironment(input: CreateSubagentEnvironmentInput): Promise<SubagentAgentExecutionEnvironment>;
|
|
142
|
+
/** Build the same tool/sandbox environment for a fresh, headless workflow task. */
|
|
143
|
+
export declare function createWorkflowAgentNodeEnvironment(input: CreateWorkflowAgentNodeEnvironmentInput): Promise<AgentExecutionEnvironment>;
|
|
144
|
+
export {};
|
|
145
|
+
//# sourceMappingURL=run-environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-environment.d.ts","sourceRoot":"","sources":["../src/run-environment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EACL,KAAK,kBAAkB,EAEvB,KAAK,eAAe,EAGpB,KAAK,gBAAgB,EAGtB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EACV,4BAA4B,EAE5B,iBAAiB,EACjB,0BAA0B,EAC1B,iBAAiB,EACjB,0BAA0B,EAC3B,MAAM,oBAAoB,CAAA;AAsB3B,OAAO,EAGL,KAAK,mBAAmB,EAMzB,MAAM,sBAAsB,CAAA;AAI7B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAElE,OAAO,EAAE,KAAK,mBAAmB,EAAuB,MAAM,mBAAmB,CAAA;AACjF,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAqB,MAAM,kBAAkB,CAAA;AAClG,OAAO,KAAK,EAAsB,qBAAqB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAU1F,OAAO,EAEL,KAAK,qBAAqB,EAI3B,MAAM,oBAAo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wBAAsB,kCAAkC,CACtD,KAAK,EAAE,uCAAuC,GAC7C,OAAO,CAAC,qCAAqC,CAAC,CAgNhD;AAED;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,iCAAiC,CAAC,CAsC5C;AA4MD,mFAAmF;AACnF,wBAAsB,kCAAkC,CACtD,KAAK,EAAE,uCAAuC,GAC7C,OAAO,CAAC,yBAAyB,CAAC,CAoDpC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type AgentRunSession } from "@sixb/core/internal/agents";
|
|
2
|
+
import type { AgentRunRecord, AppendAgentMessageInput } from "@sixb/core/storage";
|
|
3
|
+
import { type AgentRunFailure } from "./failure";
|
|
4
|
+
/**
|
|
5
|
+
* End a run that failed or stopped, with what it did kept in the same transaction. Returns
|
|
6
|
+
* nothing when the run is no longer this session's; throws {@link AgentFinalizationError} when
|
|
7
|
+
* storage stays unavailable, so the job is redelivered rather than acknowledged.
|
|
8
|
+
*/
|
|
9
|
+
export declare function recordFate(session: AgentRunSession, status: "failed" | "cancelled", error: unknown, messages?: readonly AppendAgentMessageInput[]): Promise<{
|
|
10
|
+
readonly run: AgentRunRecord;
|
|
11
|
+
readonly failure: AgentRunFailure;
|
|
12
|
+
} | undefined>;
|
|
13
|
+
/** What a run's failure names: its run, and its thread or its parent. */
|
|
14
|
+
export declare function agentRunFailureDetails(run: AgentRunRecord): Readonly<Record<string, string>>;
|
|
15
|
+
//# sourceMappingURL=run-fate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-fate.d.ts","sourceRoot":"","sources":["../src/run-fate.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AACjF,OAAO,EAAE,KAAK,eAAe,EAA2B,MAAM,WAAW,CAAA;AAEzE;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,QAAQ,GAAG,WAAW,EAC9B,KAAK,EAAE,OAAO,EACd,QAAQ,CAAC,EAAE,SAAS,uBAAuB,EAAE,GAC5C,OAAO,CAAC;IAAE,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAA;CAAE,GAAG,SAAS,CAAC,CAyB1F;AAED,yEAAyE;AACzE,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAI5F"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hold a thread's files directory for one run, across every process on the computer: each `sixb`
|
|
3
|
+
* opened in the folder shares the directory, and the next turn of a thread can start in another
|
|
4
|
+
* one while the last turn's release still removes the directory. The lock is a file beside the
|
|
5
|
+
* directory, created exclusively and naming its holder; one whose process is gone is stale, and
|
|
6
|
+
* taken over. Resolves with the release, which removes the lock only while it is still this run's.
|
|
7
|
+
*
|
|
8
|
+
* Only one run of a thread is active at a time, so no two runs take a stale lock over at once.
|
|
9
|
+
*/
|
|
10
|
+
export declare function holdRunFiles(input: {
|
|
11
|
+
/** The thread's files directory. */
|
|
12
|
+
readonly directory: string;
|
|
13
|
+
readonly runId: string;
|
|
14
|
+
readonly signal: AbortSignal;
|
|
15
|
+
}): Promise<() => Promise<void>>;
|
|
16
|
+
//# sourceMappingURL=run-files-lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-files-lock.d.ts","sourceRoot":"","sources":["../src/run-files-lock.ts"],"names":[],"mappings":"AAoBA;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE;IACxC,oCAAoC;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;CAC7B,GAAG,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CA4B/B"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Sandbox } from "@sixb/core";
|
|
2
|
+
import type { AgentWorkspacePromptContext } from "./agent-prompt";
|
|
3
|
+
/**
|
|
4
|
+
* Where a provider's sandbox keeps a run's files: in its working directory, which a Git checkout
|
|
5
|
+
* excludes (see `prepareWorkspaceRunFiles`).
|
|
6
|
+
*/
|
|
7
|
+
export { SANDBOX_CONTEXT_DIRECTORY } from "@sixb/core/internal/agents";
|
|
8
|
+
/** The sandbox a run works in, with what the system prompt may say about it. */
|
|
9
|
+
export interface AcquiredRunSandbox {
|
|
10
|
+
readonly sandbox: Sandbox;
|
|
11
|
+
/** The workspace's environment; provisioning adds the run's. */
|
|
12
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
13
|
+
/** Facts about a prepared workspace; absent for a blank sandbox. */
|
|
14
|
+
readonly promptContext?: AgentWorkspacePromptContext;
|
|
15
|
+
/** When the workspace was recreated and its earlier files were lost. */
|
|
16
|
+
readonly resetAt?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* How one run obtains its sandbox and gives it back. Every run kind goes through this lifecycle,
|
|
20
|
+
* with one of two behaviors:
|
|
21
|
+
*
|
|
22
|
+
* - ephemeral (`ephemeralRunSandbox`): created for this run, blank or prepared from a recipe, and
|
|
23
|
+
* destroyed when the run releases it;
|
|
24
|
+
* - persistent (`persistentRunSandbox`): a thread's workspace, resumed for this run and saved by
|
|
25
|
+
* `beforeFinalize`. It has no `release`: only a sub-agent run that ends without pausing
|
|
26
|
+
* destroys it.
|
|
27
|
+
*
|
|
28
|
+
* Acquisition may happen before `acquire()`: a thread's workspace is acquired before compaction,
|
|
29
|
+
* so `acquire()` only hands it over. Preservation belongs to `beforeFinalize`, never `release`.
|
|
30
|
+
*/
|
|
31
|
+
export interface RunSandbox {
|
|
32
|
+
/**
|
|
33
|
+
* Whether the first model call waits for acquisition. A workspace the prompt describes must
|
|
34
|
+
* exist first; a blank sandbox boots concurrently and tools wait for it only when used.
|
|
35
|
+
*/
|
|
36
|
+
readonly waitBeforeModel: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Where the run's files go, known before acquisition so the prompt can name them. As the agent
|
|
39
|
+
* names it: relative to the working directory, or absolute.
|
|
40
|
+
*/
|
|
41
|
+
readonly contextDirectory: string;
|
|
42
|
+
/** Called once, when the run environment starts. */
|
|
43
|
+
acquire(): Promise<AcquiredRunSandbox>;
|
|
44
|
+
/**
|
|
45
|
+
* Give back an acquired sandbox, after the run or a failed provisioning. Absent when the run
|
|
46
|
+
* has nothing to give back, so teardown never waits on it.
|
|
47
|
+
*/
|
|
48
|
+
release?(acquired: AcquiredRunSandbox): Promise<void>;
|
|
49
|
+
/** Confirm preservation before the run's terminal write. Idempotent: the first call decides. */
|
|
50
|
+
beforeFinalize?(options?: BeforeFinalizeOptions): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
/** How a run's end leaves its thread's workspace. */
|
|
53
|
+
export interface BeforeFinalizeOptions {
|
|
54
|
+
/**
|
|
55
|
+
* The run leaves nothing its thread goes on from, as a sub-agent run that answered, failed or
|
|
56
|
+
* was stopped: destroy its workspace instead of saving it.
|
|
57
|
+
*/
|
|
58
|
+
readonly discard?: boolean;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=run-sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-sandbox.d.ts","sourceRoot":"","sources":["../src/run-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAA;AAEjE;;;GAGG;AACH,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAA;AAEtE,gFAAgF;AAChF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,gEAAgE;IAChE,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAC/C,oEAAoE;IACpE,QAAQ,CAAC,aAAa,CAAC,EAAE,2BAA2B,CAAA;IACpD,wEAAwE;IACxE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;IACjC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,oDAAoD;IACpD,OAAO,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAA;IACtC;;;OAGG;IACH,OAAO,CAAC,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACrD,gGAAgG;IAChG,cAAc,CAAC,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAChE;AAED,qDAAqD;AACrD,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAC3B"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type AgentContextBudget, type AgentRunSession } from "@sixb/core/internal/agents";
|
|
2
|
+
import type { ModelStep } from "@sixb/core/models";
|
|
3
|
+
import { type AgentThreadRecord, type AppendAgentMessageInput, type SubagentRunRecord } from "@sixb/core/storage";
|
|
4
|
+
import type { ResolvedAgentExecutionPlan } from "./execution-plan";
|
|
5
|
+
import type { SubagentAgentExecutionEnvironment } from "./run-environment";
|
|
6
|
+
import { type SubagentThreadContext } from "./subagent-context";
|
|
7
|
+
import type { SubagentHistory } from "./subagent-continuation";
|
|
8
|
+
import type { SubagentInbox } from "./subagent-inbox";
|
|
9
|
+
import type { AgentTurnRuntime } from "./turn-runtime";
|
|
10
|
+
import type { AgentRunFiles, AgentTurnContext } from "./types";
|
|
11
|
+
/**
|
|
12
|
+
* What a child did so far, kept in its thread however its run ends: a failed or stopped child
|
|
13
|
+
* keeps it as an interrupted turn does. Its steps, and each message its parent sent it where it
|
|
14
|
+
* read it.
|
|
15
|
+
*/
|
|
16
|
+
export interface SubagentWork {
|
|
17
|
+
messages?: readonly AppendAgentMessageInput[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Run one child in its thread. Its request is the thread's messages, the task dated at the thread's
|
|
21
|
+
* creation; what it did is the thread's next message, written with its finish. A held call stops it
|
|
22
|
+
* after that step: it pauses, and its thread's next run continues it once the call is decided.
|
|
23
|
+
*/
|
|
24
|
+
export declare function runSubagent(input: {
|
|
25
|
+
readonly context: AgentTurnContext;
|
|
26
|
+
readonly plan: ResolvedAgentExecutionPlan;
|
|
27
|
+
/**
|
|
28
|
+
* The limits every call of the child keeps under, what its environment's preflight left of its
|
|
29
|
+
* thread, and how it compacts that thread from within.
|
|
30
|
+
*/
|
|
31
|
+
readonly contextLimits: {
|
|
32
|
+
readonly budget: AgentContextBudget;
|
|
33
|
+
readonly thread: SubagentThreadContext;
|
|
34
|
+
readonly compactInRun?: SubagentAgentExecutionEnvironment["compactInRun"];
|
|
35
|
+
readonly bytesPerToken?: number;
|
|
36
|
+
/** What the child's latest counted call measured (see prepareAgentModel). */
|
|
37
|
+
readonly measuredBytesPerToken?: () => number | undefined;
|
|
38
|
+
};
|
|
39
|
+
readonly run: SubagentRunRecord;
|
|
40
|
+
/** The child's session: its finish is fenced by the run's execution token. */
|
|
41
|
+
readonly session: AgentRunSession;
|
|
42
|
+
/** The child's own thread, and what its runs before this one left there. */
|
|
43
|
+
readonly thread: AgentThreadRecord;
|
|
44
|
+
readonly history: SubagentHistory;
|
|
45
|
+
/** Created by the worker before the run's tools, which share its signal and accounting. */
|
|
46
|
+
readonly runtime: AgentTurnRuntime;
|
|
47
|
+
/** Filled once the model loop returns, for the worker to keep when the run fails afterwards. */
|
|
48
|
+
readonly work?: SubagentWork;
|
|
49
|
+
/** Where it finds the files its parent handed over, and leaves the ones it returns. */
|
|
50
|
+
readonly runFiles: AgentRunFiles;
|
|
51
|
+
/**
|
|
52
|
+
* What its parent sends it while it runs, read before its next step, and the questions it asks,
|
|
53
|
+
* through the inbox's `ask_parent` among its tools.
|
|
54
|
+
*/
|
|
55
|
+
readonly inbox: SubagentInbox;
|
|
56
|
+
}): Promise<SubagentRunRecord>;
|
|
57
|
+
/**
|
|
58
|
+
* What the child answers: the text it wrote once its last local tool returned, through any provider
|
|
59
|
+
* continuation, and after the last message its parent sent it (read after `lastMessageAt` steps),
|
|
60
|
+
* which an answer written before it no longer answers. Without any, the last text it wrote, such
|
|
61
|
+
* as an answer it gave before a final tool call. Narration written before earlier tool calls never
|
|
62
|
+
* reaches the parent.
|
|
63
|
+
*/
|
|
64
|
+
export declare function subagentAnswer(steps: readonly ModelStep[], lastMessageAt?: number): string;
|
|
65
|
+
//# sourceMappingURL=run-subagent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-subagent.d.ts","sourceRoot":"","sources":["../src/run-subagent.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EAKrB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAE5B,KAAK,iBAAiB,EACvB,MAAM,oBAAoB,CAAA;AAM3B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAOlE,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,mBAAmB,C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AY,CAAA;IAC5B,uFAAuF;IACvF,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAA;IAChC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;CAC9B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA6G7B;AAkND;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,EAAE,aAAa,SAAI,GAAG,MAAM,CASrF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AgentMessagePart, ValueType } from "@sixb/core";
|
|
2
|
+
import { type AgentContextBudget } from "@sixb/core/internal/agents";
|
|
3
|
+
import { type AgentStepDefinition, type WorkflowIOSnapshot } from "@sixb/core/internal/workflows";
|
|
4
|
+
import { type AgentRunFinishReason, coerceAgentRunFinishReason } from "@sixb/core/storage";
|
|
5
|
+
import type { ResolvedAgentExecutionPlan } from "./execution-plan";
|
|
6
|
+
import type { AgentTurnContext } from "./types";
|
|
7
|
+
export interface RunWorkflowAgentNodeInput {
|
|
8
|
+
readonly context: AgentTurnContext;
|
|
9
|
+
readonly agentStepId: string;
|
|
10
|
+
readonly plan: ResolvedAgentExecutionPlan;
|
|
11
|
+
/** The limits of the step's model, which every call of its research keeps under. */
|
|
12
|
+
readonly budget: AgentContextBudget;
|
|
13
|
+
/** What the step's latest counted call measured (see prepareAgentModel). */
|
|
14
|
+
readonly measuredBytesPerToken?: () => number | undefined;
|
|
15
|
+
readonly agentStep: AgentStepDefinition;
|
|
16
|
+
readonly workflowId: string;
|
|
17
|
+
readonly workflowRunId: string;
|
|
18
|
+
readonly nodeRunId: string;
|
|
19
|
+
readonly prompt: string;
|
|
20
|
+
/** When the node run was created; dates the prompt for the model. */
|
|
21
|
+
readonly createdAt: Date;
|
|
22
|
+
readonly valueTypesById: ReadonlyMap<string, ValueType>;
|
|
23
|
+
/** The node's signal, which the caller also applies to its tools' model calls. */
|
|
24
|
+
readonly signal: AbortSignal;
|
|
25
|
+
}
|
|
26
|
+
export interface WorkflowAgentNodeResult {
|
|
27
|
+
readonly output: WorkflowIOSnapshot;
|
|
28
|
+
readonly modelId: string;
|
|
29
|
+
readonly finishReason: NonNullable<ReturnType<typeof coerceAgentRunFinishReason>>;
|
|
30
|
+
readonly trace: readonly AgentMessagePart[];
|
|
31
|
+
}
|
|
32
|
+
export type WorkflowAgentFailurePhase = "output-preflight" | "agent-loop" | "structured-finalizer";
|
|
33
|
+
/** Carries best-effort debug context across the workflow node's terminal error boundary. */
|
|
34
|
+
export declare class WorkflowAgentNodeExecutionError extends Error {
|
|
35
|
+
readonly phase: WorkflowAgentFailurePhase;
|
|
36
|
+
readonly finishReason?: AgentRunFinishReason;
|
|
37
|
+
readonly trace: readonly AgentMessagePart[];
|
|
38
|
+
constructor(input: {
|
|
39
|
+
readonly phase: WorkflowAgentFailurePhase;
|
|
40
|
+
readonly finishReason?: AgentRunFinishReason;
|
|
41
|
+
readonly trace: readonly AgentMessagePart[];
|
|
42
|
+
readonly cause: unknown;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export declare function runWorkflowAgentNode(input: RunWorkflowAgentNodeInput): Promise<WorkflowAgentNodeResult>;
|
|
46
|
+
//# sourceMappingURL=run-workflow-agent-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-workflow-agent-node.d.ts","sourceRoot":"","sources":["../src/run-workflow-agent-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAe,SAAS,EAAE,MAAM,YAAY,CAAA;AAC1E,OAAO,EAAE,KAAK,kBAAkB,EAAgB,MAAM,4BAA4B,CAAA;AAGlF,OAAO,EACL,KAAK,mBAAmB,EAGxB,KAAK,kBAAkB,EACxB,MAAM,+BAA+B,CAAA;AAOtC,OAAO,EAAE,KAAK,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAA;AAG1F,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,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AA;IACzC,QAAQ,CAAC,YAAY,CAAC,EAAE,oBAAoB,CAAA;IAC5C,QAAQ,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAA;gBAE/B,KAAK,EAAE;QACjB,QAAQ,CAAC,KAAK,EAAE,yBAAyB,CAAA;QACzC,QAAQ,CAAC,YAAY,CAAC,EAAE,oBAAoB,CAAA;QAC5C,QAAQ,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAA;QAC3C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;KACxB;CAOF;AAED,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,uBAAuB,CAAC,CAkPlC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AgentMemoryRepoView, AgentProjectFile, AgentSkillDefinition, Sandbox } from "@sixb/core";
|
|
2
|
+
import type { MaterializedArtifacts } from "./artifacts/materialize";
|
|
3
|
+
import type { PreparedAgentAttachmentContext } from "./attachments";
|
|
4
|
+
/**
|
|
5
|
+
* Where a conversation's artifacts are installed, and their manifest, relative to the context
|
|
6
|
+
* directory. A sandbox that outlives the run clears that directory when it opens, so each run's
|
|
7
|
+
* install starts empty.
|
|
8
|
+
*/
|
|
9
|
+
export declare const AGENT_ARTIFACTS_DIRECTORY = "artifacts";
|
|
10
|
+
export declare const AGENT_ARTIFACTS_MANIFEST = "context/artifacts.json";
|
|
11
|
+
export interface AgentSandboxApiContext {
|
|
12
|
+
readonly env: Readonly<Record<string, string>>;
|
|
13
|
+
}
|
|
14
|
+
export interface PrepareAgentSandboxApiContextInput {
|
|
15
|
+
readonly sandbox: Sandbox;
|
|
16
|
+
/** Where the run's files go: relative to the working directory, or absolute. */
|
|
17
|
+
readonly contextDirectory: string;
|
|
18
|
+
/** The API origin; commands reach it at the sandbox's credentialed address for it. */
|
|
19
|
+
readonly apiBaseUrl: string;
|
|
20
|
+
readonly projectId: string;
|
|
21
|
+
readonly actorId?: string;
|
|
22
|
+
readonly threadId?: string;
|
|
23
|
+
readonly runId: string;
|
|
24
|
+
readonly attachments?: PreparedAgentAttachmentContext;
|
|
25
|
+
readonly skills: readonly AgentSkillDefinition[];
|
|
26
|
+
/** The run's ontology reference docs and scripts, by path relative to the ontology directory. */
|
|
27
|
+
readonly ontologyFiles: readonly AgentProjectFile[];
|
|
28
|
+
/** A conversation's published artifacts, under {@link AGENT_ARTIFACTS_DIRECTORY}. */
|
|
29
|
+
readonly artifacts?: MaterializedArtifacts;
|
|
30
|
+
/** A conversation's memory repos, under `$SIXB_MEMORY_DIR/<repo>/`. */
|
|
31
|
+
readonly memory?: readonly AgentMemoryRepoView[];
|
|
32
|
+
}
|
|
33
|
+
export declare function prepareAgentSandboxApiContext(input: PrepareAgentSandboxApiContextInput): Promise<AgentSandboxApiContext>;
|
|
34
|
+
//# sourceMappingURL=sandbox-api-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-api-context.d.ts","sourceRoot":"","sources":["../src/sandbox-api-context.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,OAAO,EAER,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AACpE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,eAAe,CAAA;AAGnE;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,cAAc,CAAA;AACpD,eAAO,MAAM,wBAAwB,2BAA2B,CAAA;AAGhE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAC/C;AAED,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,gFAAgF;IAChF,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,sFAAsF;IACtF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,8BAA8B,CAAA;IACrD,QAAQ,CAAC,MAAM,EAAE,SAAS,oBAAoB,EAAE,CAAA;IAChD,iGAAiG;IACjG,QAAQ,CAAC,aAAa,EAAE,SAAS,gBAAgB,EAAE,CAAA;IACnD,qFAAqF;IACrF,QAAQ,CAAC,SAAS,CAAC,EAAE,qBAAqB,CAAA;IAC1C,uEAAuE;IACvE,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAA;CACjD;AAED,wBAAsB,6BAA6B,CACjD,KAAK,EAAE,kCAAkC,GACxC,OAAO,CAAC,sBAAsB,CAAC,CAkIjC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FileRef } from "@sixb/core";
|
|
2
|
+
/** Track durable files materialized in the current run sandbox. */
|
|
3
|
+
export declare class AgentSandboxFileRegistry {
|
|
4
|
+
#private;
|
|
5
|
+
register(absolutePath: string, fileRef: FileRef): void;
|
|
6
|
+
get(absolutePath: string): FileRef | undefined;
|
|
7
|
+
pathFor(fileRef: FileRef): string | undefined;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=sandbox-file-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-file-registry.d.ts","sourceRoot":"","sources":["../src/sandbox-file-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAGzC,mEAAmE;AACnE,qBAAa,wBAAwB;;IAInC,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAStD,GAAG,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAI9C,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS;CAG9C"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type AgentSandboxHandle } from "./sandbox-handle";
|
|
2
|
+
/** Why a sandbox file could not be listed or read. The message is safe to show to the Agent. */
|
|
3
|
+
export type SandboxFileErrorReason = "invalid_path" | "outside_root" | "not_found" | "too_large" | "changed" | "failed";
|
|
4
|
+
export declare class SandboxFileError extends Error {
|
|
5
|
+
readonly reason: SandboxFileErrorReason;
|
|
6
|
+
constructor(reason: SandboxFileErrorReason, message: string, options?: ErrorOptions);
|
|
7
|
+
}
|
|
8
|
+
export interface SandboxFileEntry {
|
|
9
|
+
/** Path relative to the listed directory, with `/` separators and no `.` or `..` segments. */
|
|
10
|
+
readonly relativePath: string;
|
|
11
|
+
readonly sizeBytes: number;
|
|
12
|
+
}
|
|
13
|
+
export interface SandboxFileListing {
|
|
14
|
+
/** False when nothing is at the path, or it is not a directory: then nothing is listed. */
|
|
15
|
+
readonly directory: boolean;
|
|
16
|
+
/** Regular files under the directory, sorted by path. Symbolic links are never listed. */
|
|
17
|
+
readonly files: readonly SandboxFileEntry[];
|
|
18
|
+
/** True when the directory held more than `maxFiles` files; only the first ones are listed. */
|
|
19
|
+
readonly truncated: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface SandboxCommandOptions {
|
|
22
|
+
readonly signal: AbortSignal;
|
|
23
|
+
readonly timeoutMs: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Where a run reads files: its working directory, and its context directory when that lies
|
|
27
|
+
* elsewhere, as it does in a folder on a computer. Absolute, the working directory first.
|
|
28
|
+
*/
|
|
29
|
+
export declare function sandboxRoots(handle: AgentSandboxHandle): readonly string[];
|
|
30
|
+
/**
|
|
31
|
+
* Resolve `requestedPath` against the sandbox working directory. Throws when the path is empty or
|
|
32
|
+
* leaves both the working directory and the run's context directory; symbolic links are checked
|
|
33
|
+
* when the file is read.
|
|
34
|
+
*/
|
|
35
|
+
export declare function resolveSandboxPath(handle: AgentSandboxHandle, requestedPath: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* List the regular files under `directory`, up to `maxFiles`. A missing directory lists nothing;
|
|
38
|
+
* output that does not parse throws, since a listing that skips a line drops a file silently.
|
|
39
|
+
*/
|
|
40
|
+
export declare function listSandboxFiles(handle: AgentSandboxHandle, input: SandboxCommandOptions & {
|
|
41
|
+
readonly directory: string;
|
|
42
|
+
readonly maxFiles: number;
|
|
43
|
+
}): Promise<SandboxFileListing>;
|
|
44
|
+
/**
|
|
45
|
+
* Read one regular file inside the sandbox working directory. Refuses symbolic links, paths whose
|
|
46
|
+
* parent resolves outside the working directory, and files larger than `maxBytes`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function readSandboxFile(handle: AgentSandboxHandle, input: SandboxCommandOptions & {
|
|
49
|
+
/** An absolute path, as `resolveSandboxPath` returns it. */
|
|
50
|
+
readonly path: string;
|
|
51
|
+
readonly maxBytes: number;
|
|
52
|
+
}): Promise<Uint8Array>;
|
|
53
|
+
/** What a path names once its symbolic links are followed. */
|
|
54
|
+
export type SandboxPathEntry = {
|
|
55
|
+
readonly kind: "file" | "directory";
|
|
56
|
+
/** Absolute, every symbolic link along it followed. */
|
|
57
|
+
readonly realPath: string;
|
|
58
|
+
} | {
|
|
59
|
+
readonly kind: "missing";
|
|
60
|
+
} | {
|
|
61
|
+
readonly kind: "link";
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Follow the symbolic links along `path`, an absolute path as `resolveSandboxPath` returns it, to
|
|
65
|
+
* where it really is. A path that is itself a link is reported as one, as reads refuse it.
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolveSandboxEntry(handle: AgentSandboxHandle, input: SandboxCommandOptions & {
|
|
68
|
+
readonly path: string;
|
|
69
|
+
}): Promise<SandboxPathEntry>;
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=sandbox-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-files.d.ts","sourceRoot":"","sources":["../src/sandbox-files.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,kBAAkB,EAAe,MAAM,kBAAkB,CAAA;AAMvE,gGAAgG;AAChG,MAAM,MAAM,sBAAsB,GAC9B,cAAc,GACd,cAAc,GACd,WAAW,GACX,WAAW,GACX,SAAS,GACT,QAAQ,CAAA;AAEZ,qBAAa,gBAAiB,SAAQ,KAAK;IAEvC,QAAQ,CAAC,MAAM,EAAE,sBAAsB;gBAA9B,MAAM,EAAE,sBAAsB,EACvC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY;CAKzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,8FAA8F;IAC9F,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,2FAA2F;IAC3F,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,0FAA0F;IAC1F,QAAQ,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAA;IAC3C,+FAA+F;IAC/F,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAC5B;AAED,UAAU,qBAAqB;IAC7B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC3B;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,SAAS,MAAM,EAAE,CAI1E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAoB5F;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,qBAAqB,GAAG;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B,GACA,OAAO,CAAC,kBAAkB,CAAC,CAsC7B;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,qBAAqB,GAAG;IAC7B,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B,GACA,OAAO,CAAC,UAAU,CAAC,CAwCrB;AAED,8DAA8D;AAC9D,MAAM,MAAM,gBAAgB,GACxB;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAA;IACnC,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAE7B;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,qBAAqB,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACvD,OAAO,CAAC,gBAAgB,CAAC,CAsB3B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Sandbox } from "@sixb/core";
|
|
2
|
+
/** The sandbox plus its run-scoped environment, resolved lazily when first needed. */
|
|
3
|
+
export interface AgentSandboxHandle {
|
|
4
|
+
readonly sandbox: Sandbox;
|
|
5
|
+
/**
|
|
6
|
+
* Where the run's files are installed: skills, ontology docs, memory, attachments, artifacts,
|
|
7
|
+
* children's files and the agent's `sixb`. As the agent names it: relative to the working
|
|
8
|
+
* directory, or absolute.
|
|
9
|
+
*/
|
|
10
|
+
readonly contextDirectory: string;
|
|
11
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
12
|
+
}
|
|
13
|
+
/** A path in the run's context directory, absolute in the sandbox. */
|
|
14
|
+
export declare function contextPath(handle: AgentSandboxHandle, ...segments: string[]): string;
|
|
15
|
+
//# sourceMappingURL=sandbox-handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-handle.d.ts","sourceRoot":"","sources":["../src/sandbox-handle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,sFAAsF;AACtF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAChD;AAED,sEAAsE;AACtE,wBAAgB,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAErF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface SandboxReadinessGuard {
|
|
2
|
+
readonly signal: AbortSignal;
|
|
3
|
+
throwIfFailed(): void;
|
|
4
|
+
}
|
|
5
|
+
/** Observe concurrent sandbox provisioning without putting healthy boot on the model's critical path. */
|
|
6
|
+
export declare function monitorSandboxReadiness(ready: Promise<unknown> | undefined): SandboxReadinessGuard;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=sandbox-readiness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-readiness.d.ts","sourceRoot":"","sources":["../src/sandbox-readiness.ts"],"names":[],"mappings":"AAAA,UAAU,qBAAqB;IAC7B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAC5B,aAAa,IAAI,IAAI,CAAA;CACtB;AAED,yGAAyG;AACzG,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,SAAS,GAClC,qBAAqB,CAavB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AgentSkillDefinition } from "@sixb/core";
|
|
2
|
+
/**
|
|
3
|
+
* Skills the worker ships, in every conversation's catalog. They describe formats the publisher
|
|
4
|
+
* validates and the app renders, so they change with them. Their names start with `sixb-`, which
|
|
5
|
+
* skill discovery refuses for a project's skills, so none collides with one.
|
|
6
|
+
*/
|
|
7
|
+
export declare const BUILT_IN_SKILLS: readonly AgentSkillDefinition[];
|
|
8
|
+
/**
|
|
9
|
+
* How to write and save the Agent's memory. Installed with the memory, outside the catalog: the
|
|
10
|
+
* memory section of the prompt names it, so runs without memory never see it.
|
|
11
|
+
*/
|
|
12
|
+
export declare const MEMORY_SKILL: AgentSkillDefinition;
|
|
13
|
+
/** The project's skills, then the built-in ones. */
|
|
14
|
+
export declare function withBuiltInSkills(projectSkills: readonly AgentSkillDefinition[]): readonly AgentSkillDefinition[];
|
|
15
|
+
//# sourceMappingURL=built-in.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"built-in.d.ts","sourceRoot":"","sources":["../../src/skills/built-in.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AA2FtD;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,oBAAoB,EAsCzD,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,oBAA4D,CAAA;AAEvF,oDAAoD;AACpD,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,SAAS,oBAAoB,EAAE,GAC7C,SAAS,oBAAoB,EAAE,CAEjC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type ModelCachingIntent, type ModelMessage } from "@sixb/core/models";
|
|
2
|
+
import type { AgentMessageRecord, AgentThreadRecord, SubagentRunRecord } from "@sixb/core/storage";
|
|
3
|
+
import { type PreparedAgentAttachmentContext } from "./attachments";
|
|
4
|
+
import { type AgentThreadCompactionInput } from "./context-compaction";
|
|
5
|
+
import type { SubagentHistory } from "./subagent-continuation";
|
|
6
|
+
import { type LoadedAgentThreadModelContext } from "./thread-context";
|
|
7
|
+
/** A child's thread as its requests send it: its task, and the history after it. */
|
|
8
|
+
export interface SubagentThreadContext {
|
|
9
|
+
/** The thread's first message, which every request opens with. */
|
|
10
|
+
readonly task?: AgentMessageRecord;
|
|
11
|
+
/** The thread without its task: from the latest checkpoint's summary once it has one. */
|
|
12
|
+
readonly threadContext: LoadedAgentThreadModelContext;
|
|
13
|
+
}
|
|
14
|
+
/** Split a child's history into its task and the rest of its thread. */
|
|
15
|
+
export declare function subagentThreadContext(history: SubagentHistory): SubagentThreadContext;
|
|
16
|
+
/**
|
|
17
|
+
* The child's thread as its model reads it: the task, closed by the time the thread was created
|
|
18
|
+
* so each run of the child replays the same bytes, then the rest. Files a tool showed it are
|
|
19
|
+
* projected again as a turn projects its own.
|
|
20
|
+
*/
|
|
21
|
+
export declare function subagentModelMessages(input: {
|
|
22
|
+
readonly thread: SubagentThreadContext;
|
|
23
|
+
readonly attachmentContext?: PreparedAgentAttachmentContext;
|
|
24
|
+
/** When the thread was created, as the task closes with it. */
|
|
25
|
+
readonly createdAt: string;
|
|
26
|
+
}): ModelMessage[];
|
|
27
|
+
/** How a child's calls are cached, its summary's included (see childCacheLifetime). */
|
|
28
|
+
export declare function subagentPromptCaching(input: {
|
|
29
|
+
readonly projectId: string;
|
|
30
|
+
readonly thread: AgentThreadRecord;
|
|
31
|
+
readonly run: SubagentRunRecord;
|
|
32
|
+
readonly history: SubagentHistory;
|
|
33
|
+
}): ModelCachingIntent;
|
|
34
|
+
/**
|
|
35
|
+
* Weigh a child's thread before its first call, and compact it when it crosses the model's limit,
|
|
36
|
+
* or when it comes back idle and large (see shouldCompactIdleContext): what the run then starts
|
|
37
|
+
* from, and the bytes per token the thread was measured at.
|
|
38
|
+
*/
|
|
39
|
+
export declare function preflightSubagentContext(input: AgentThreadCompactionInput & {
|
|
40
|
+
readonly threadContext: LoadedAgentThreadModelContext;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
readonly threadContext: LoadedAgentThreadModelContext;
|
|
43
|
+
readonly bytesPerToken: number;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* The failure of a child whose call its guard reduced and the provider still refused as too long
|
|
47
|
+
* for the window: what its parent can do about it. Undefined for any other error.
|
|
48
|
+
*/
|
|
49
|
+
export declare function subagentContextFailure(error: unknown, run: SubagentRunRecord): Error | undefined;
|
|
50
|
+
//# sourceMappingURL=subagent-context.d.ts.map
|