@sixb/agent 0.1.0 → 0.2.1

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 (102) hide show
  1. package/dist/agent-prompt.d.ts +34 -28
  2. package/dist/agent-prompt.d.ts.map +1 -1
  3. package/dist/artifacts/publish-tool.d.ts +1 -1
  4. package/dist/attachments.d.ts +42 -1
  5. package/dist/attachments.d.ts.map +1 -1
  6. package/dist/child-files.d.ts +0 -5
  7. package/dist/child-files.d.ts.map +1 -1
  8. package/dist/computer-runner.d.ts +16 -7
  9. package/dist/computer-runner.d.ts.map +1 -1
  10. package/dist/context-budget.d.ts +23 -17
  11. package/dist/context-budget.d.ts.map +1 -1
  12. package/dist/context-compaction.d.ts +118 -18
  13. package/dist/context-compaction.d.ts.map +1 -1
  14. package/dist/context-guard.d.ts +69 -0
  15. package/dist/context-guard.d.ts.map +1 -0
  16. package/dist/conversation-messages.d.ts +33 -0
  17. package/dist/conversation-messages.d.ts.map +1 -0
  18. package/dist/execution-plan.d.ts +5 -1
  19. package/dist/execution-plan.d.ts.map +1 -1
  20. package/dist/failure.d.ts.map +1 -1
  21. package/dist/index.js +4916 -2697
  22. package/dist/index.js.map +41 -34
  23. package/dist/inline-images.d.ts +28 -0
  24. package/dist/inline-images.d.ts.map +1 -0
  25. package/dist/message-authors.d.ts +4 -4
  26. package/dist/message-authors.d.ts.map +1 -1
  27. package/dist/message-times.d.ts +4 -3
  28. package/dist/message-times.d.ts.map +1 -1
  29. package/dist/model-adapters.d.ts +6 -2
  30. package/dist/model-adapters.d.ts.map +1 -1
  31. package/dist/prompt-cache.d.ts +28 -0
  32. package/dist/prompt-cache.d.ts.map +1 -0
  33. package/dist/run-agent-turn.d.ts +33 -3
  34. package/dist/run-agent-turn.d.ts.map +1 -1
  35. package/dist/run-child.d.ts.map +1 -1
  36. package/dist/run-conversation-turn.d.ts.map +1 -1
  37. package/dist/run-environment.d.ts +35 -5
  38. package/dist/run-environment.d.ts.map +1 -1
  39. package/dist/run-files-lock.d.ts +16 -0
  40. package/dist/run-files-lock.d.ts.map +1 -0
  41. package/dist/run-subagent.d.ts +15 -1
  42. package/dist/run-subagent.d.ts.map +1 -1
  43. package/dist/run-workflow-agent-node.d.ts +5 -0
  44. package/dist/run-workflow-agent-node.d.ts.map +1 -1
  45. package/dist/sandbox-api-context.d.ts.map +1 -1
  46. package/dist/subagent-context.d.ts +50 -0
  47. package/dist/subagent-context.d.ts.map +1 -0
  48. package/dist/subagent-continuation.d.ts +10 -4
  49. package/dist/subagent-continuation.d.ts.map +1 -1
  50. package/dist/subagent-tools.d.ts +11 -0
  51. package/dist/subagent-tools.d.ts.map +1 -1
  52. package/dist/thread-context.d.ts +7 -2
  53. package/dist/thread-context.d.ts.map +1 -1
  54. package/dist/tools/bash.d.ts +8 -0
  55. package/dist/tools/bash.d.ts.map +1 -1
  56. package/dist/tools/model-spec.d.ts +7 -2
  57. package/dist/tools/model-spec.d.ts.map +1 -1
  58. package/dist/tools/result-media.d.ts +53 -10
  59. package/dist/tools/result-media.d.ts.map +1 -1
  60. package/dist/tools/result-output.d.ts +1 -1
  61. package/dist/tools/result-output.d.ts.map +1 -1
  62. package/dist/tools/tool-outputs.d.ts +63 -0
  63. package/dist/tools/tool-outputs.d.ts.map +1 -0
  64. package/dist/types.d.ts +9 -2
  65. package/dist/types.d.ts.map +1 -1
  66. package/package.json +4 -4
  67. package/src/agent-prompt.ts +178 -76
  68. package/src/attachments.ts +275 -84
  69. package/src/child-files.ts +1 -6
  70. package/src/computer-runner.ts +75 -23
  71. package/src/context-budget.ts +110 -94
  72. package/src/context-compaction.ts +1007 -187
  73. package/src/context-guard.ts +826 -0
  74. package/src/conversation-messages.ts +86 -0
  75. package/src/execution-plan.ts +22 -2
  76. package/src/failure.ts +11 -0
  77. package/src/inline-images.ts +69 -0
  78. package/src/message-authors.ts +5 -5
  79. package/src/message-times.ts +8 -5
  80. package/src/model-adapters.ts +59 -13
  81. package/src/prompt-cache.ts +40 -0
  82. package/src/run-agent-turn.ts +234 -72
  83. package/src/run-child.ts +30 -5
  84. package/src/run-conversation-turn.ts +16 -1
  85. package/src/run-environment.ts +553 -106
  86. package/src/run-files-lock.ts +118 -0
  87. package/src/run-subagent.ts +132 -46
  88. package/src/run-workflow-agent-node.ts +84 -10
  89. package/src/sandbox-api-context.ts +3 -0
  90. package/src/skills/sixb-artifacts/canvas.md +1 -1
  91. package/src/skills/sixb-artifacts/page.md +1 -1
  92. package/src/skills/sixb-artifacts/slides.md +1 -1
  93. package/src/subagent-context.ts +182 -0
  94. package/src/subagent-continuation.ts +11 -6
  95. package/src/subagent-tools.ts +73 -11
  96. package/src/thread-context.ts +9 -3
  97. package/src/tools/bash.ts +17 -1
  98. package/src/tools/model-spec.ts +9 -4
  99. package/src/tools/result-media.ts +286 -82
  100. package/src/tools/result-output.ts +4 -2
  101. package/src/tools/tool-outputs.ts +464 -0
  102. package/src/types.ts +14 -2
@@ -1,5 +1,5 @@
1
1
  import type { AgentSkillDefinition } from "@sixb/core";
2
- import type { SandboxModel } from "@sixb/core/internal/agents";
2
+ import type { AgentSystemPromptSize, SandboxModel } from "@sixb/core/internal/agents";
3
3
  import type { OntologyDocsIndexEntry } from "@sixb/core/internal/ontology";
4
4
  import type { ModelMessage } from "@sixb/core/models";
5
5
  import type { SubagentRunFile } from "@sixb/core/storage";
@@ -17,8 +17,15 @@ export interface RenderAgentSystemPromptInput {
17
17
  /** Ontology reference files to list; omitted, the prompt does not mention them. */
18
18
  readonly ontologyIndex?: readonly OntologyDocsIndexEntry[];
19
19
  readonly sandboxResetAt?: string;
20
+ /** When the conversation's turns moved to this workspace, from a computer or another folder. */
21
+ readonly workspaceMovedAt?: string;
20
22
  readonly workspace?: AgentWorkspacePromptContext;
21
23
  readonly facts?: AgentRuntimeFacts;
24
+ /**
25
+ * Who takes part in a conversation several people write in ({@link renderConversationPeople});
26
+ * omitted in one its owner holds alone.
27
+ */
28
+ readonly conversation?: string;
22
29
  /** Models the sandbox CLI can call; omitted, the prompt does not mention them. */
23
30
  readonly sandboxModels?: readonly SandboxModel[];
24
31
  readonly memory?: AgentMemoryPromptContext;
@@ -34,17 +41,20 @@ export interface AgentMemoryPromptContext {
34
41
  }[];
35
42
  }
36
43
  /**
37
- * For whom the run happens: the requester, and their settings, else the project's. Time is not a
38
- * fact of the prompt: each user message carries its own send time instead (see
39
- * {@link renderCurrentTime}), so the prompt and the replayed history stay byte-stable across runs.
44
+ * For whom the run happens. Neither the time nor the requester's settings are facts of the prompt:
45
+ * each user message carries when it was sent, in its sender's time zone and locale (see
46
+ * {@link renderCurrentTime}), so the prompt stays byte-stable across runs and senders.
40
47
  */
41
48
  export interface AgentRuntimeFacts {
49
+ /** Absent when no principal started the run's chain of executions. */
50
+ readonly requester?: AgentRequester;
51
+ }
52
+ /** The time zone and locale a user message was sent in, as its run captured them. */
53
+ export interface SentSettings {
42
54
  /** Canonical IANA time zone. */
43
55
  readonly timeZone: string;
44
56
  /** Canonical BCP 47 language tag. */
45
57
  readonly locale: string;
46
- /** Absent when no principal started the run's chain of executions. */
47
- readonly requester?: AgentRequester;
48
58
  }
49
59
  /** Only non-secret facts about the environment actually prepared for this run. */
50
60
  export interface AgentWorkspacePromptContext {
@@ -66,29 +76,25 @@ export interface RenderWorkflowOutputFinalizerPromptInput {
66
76
  }
67
77
  /** Render the worker-owned system prompt, with task-specific instructions when supplied. */
68
78
  export declare function renderAgentSystemPrompt(input: RenderAgentSystemPromptInput): string;
69
- /** Render the worker-owned prompt for the tool-free workflow output projection call. */
70
- export declare function renderWorkflowOutputFinalizerPrompt(input: RenderWorkflowOutputFinalizerPromptInput): string;
71
79
  /**
72
- * The facts a run's prompt states: who requested it, when a principal did, and the time zone and
73
- * locale the run captured from them, else the project's.
80
+ * The system prompt with each section's bytes, as a step records what its request carried: the
81
+ * project's instructions, the memory indexes, the skills catalog and the ontology index apart
82
+ * from Sixb's own text.
74
83
  */
75
- export declare function agentRuntimeFacts(input: {
76
- /** The settings the run captured from its requester, if any. */
77
- readonly settings: {
78
- readonly timeZone?: string;
79
- readonly locale?: string;
80
- };
81
- readonly project: {
82
- readonly timeZone: string;
83
- readonly locale: string;
84
- };
85
- readonly requester: AgentRequester | undefined;
86
- }): AgentRuntimeFacts;
84
+ export declare function measureAgentSystemPrompt(input: RenderAgentSystemPromptInput): AgentSystemPromptSize;
85
+ /** Render the worker-owned prompt for the tool-free workflow output projection call. */
86
+ export declare function renderWorkflowOutputFinalizerPrompt(input: RenderWorkflowOutputFinalizerPromptInput): string;
87
+ /** The settings a run captured from its requester, else the project's. */
88
+ export declare function sentSettings(settings: {
89
+ readonly timeZone?: string;
90
+ readonly locale?: string;
91
+ }, project: SentSettings): SentSettings;
87
92
  /**
88
- * When a user message was sent, read in the time zone of the run that answered it. Derived from
89
- * stored data only — never from the clock — so a replayed message always renders the same bytes.
93
+ * When a user message was sent, read in the time zone of the run that answered it, with that run's
94
+ * time zone and locale. Derived from stored data only — never from the clock — so a replayed
95
+ * message always renders the same bytes.
90
96
  */
91
- export declare function renderCurrentTime(sentAt: Date, timeZone: string): string;
97
+ export declare function renderCurrentTime(sentAt: Date, settings: SentSettings): string;
92
98
  /** Someone who writes in a conversation, as the model reads them. */
93
99
  export interface ConversationPerson {
94
100
  readonly id: string;
@@ -102,8 +108,8 @@ export interface ConversationPerson {
102
108
  */
103
109
  export declare function renderMessageAuthor(author: ConversationPerson): string;
104
110
  /**
105
- * Who takes part in a shared conversation, as the newest user message carries it: in the user's
106
- * turn, as data, rather than in the system prompt, which stays the same for every conversation.
111
+ * Who takes part in a shared conversation, in its system prompt: it stays the same whoever sends a
112
+ * turn, and changes only with who takes part, never in front of history already cached.
107
113
  */
108
114
  export declare function renderConversationPeople(input: {
109
115
  readonly owner: ConversationPerson;
@@ -112,7 +118,7 @@ export declare function renderConversationPeople(input: {
112
118
  /** Close a headless run's only user message with the time its run was created. */
113
119
  export declare function withCurrentTime(message: Extract<ModelMessage, {
114
120
  role: "user";
115
- }>, createdAt: Date, timeZone: string): Extract<ModelMessage, {
121
+ }>, createdAt: Date, settings: SentSettings): Extract<ModelMessage, {
116
122
  role: "user";
117
123
  }>;
118
124
  /** Where the files a parent handed its child are: in the child's task, so it needs no lookup. */
@@ -1 +1 @@
1
- {"version":3,"file":"agent-prompt.d.ts","sourceRoot":"","sources":["../src/agent-prompt.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAIzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,MAAM,MAAM,kBAAkB,GAAG,cAAc,GAAG,UAAU,GAAG,eAAe,CAAA;AA6E9E,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAA;IACjC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,oBAAoB,EAAE,CAAA;IAChD,mFAAmF;IACnF,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAA;IAC1D,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,2BAA2B,CAAA;IAChD,QAAQ,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAA;IAClC,kFAAkF;IAClF,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,YAAY,EAAE,CAAA;IAChD,QAAQ,CAAC,MAAM,CAAC,EAAE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 enum: ("file" | "document" | "sheet" | "slides" | "page" | "canvas")[];
21
21
  };
22
22
  title: {
23
23
  readonly type: "string";
@@ -1,7 +1,12 @@
1
1
  import type { AgentFileDataProjection, FileRef } from "@sixb/core";
2
2
  import { type AgentRunFileStore } from "@sixb/core/internal/agents";
3
- import type { LanguageModel } from "@sixb/core/models";
3
+ import type { LanguageModel, ModelMessage } from "@sixb/core/models";
4
4
  import type { AgentMessageRecord } from "@sixb/core/storage";
5
+ /**
6
+ * Where a parent finds what its children wrote to `out/`, a directory per spawn key, in the context
7
+ * directory: `wait_agent` copies them there, and later turns materialize them there again.
8
+ */
9
+ export declare const CHILD_FILES_DIRECTORY = "children";
5
10
  /**
6
11
  * How many files, and bytes, a sandbox receives of a run's attachments: also what a parent Agent
7
12
  * and its child hand each other.
@@ -17,6 +22,37 @@ export interface PreparedAgentAttachmentContext {
17
22
  readonly modelFileDataByPartKey: ReadonlyMap<string, AgentFileDataProjection>;
18
23
  readonly sandboxFiles: readonly PreparedSandboxAttachmentFile[];
19
24
  readonly manifestJson: string;
25
+ /** The images each stored step's tools returned, as the model read them after that step. */
26
+ readonly toolFilesByStep?: ReadonlyMap<string, ModelMessage>;
27
+ /**
28
+ * The user attachments the request may inline as images, projected only once the request's
29
+ * inline image budget decides them ({@link settleAttachmentImages}). Until then each reads as
30
+ * the budget had no room for it.
31
+ */
32
+ readonly pendingImages?: ReadonlyMap<string, PendingAttachmentImage>;
33
+ }
34
+ /** What projecting an attachment as an image gave: its inline data, or why there is none. */
35
+ export type AttachmentImageProjection = {
36
+ readonly kind: "inline";
37
+ readonly data: AgentFileDataProjection;
38
+ readonly notes: readonly string[];
39
+ } | {
40
+ readonly kind: "not-inlined";
41
+ readonly notes: readonly string[];
42
+ };
43
+ /** An image's fate in the request: projected, or left out because the budget was used up. */
44
+ export type AttachmentImageOutcome = AttachmentImageProjection | {
45
+ readonly kind: "budget";
46
+ };
47
+ /** A user attachment the request may inline as an image, decoded and encoded only on demand. */
48
+ export interface PendingAttachmentImage {
49
+ project(signal: AbortSignal): Promise<AttachmentImageProjection>;
50
+ /** The attachment as the request reads it once its image's fate is known. */
51
+ settle(outcome: AttachmentImageOutcome): {
52
+ readonly entry: PreparedAgentAttachment;
53
+ readonly promptText: string;
54
+ readonly modelFileData?: AgentFileDataProjection;
55
+ };
20
56
  }
21
57
  export interface PreparedAgentAttachment {
22
58
  readonly key: string;
@@ -63,6 +99,11 @@ export declare function prepareAgentToolFileProjection(input: {
63
99
  readonly imageOmissionNote?: string;
64
100
  }): Promise<PreparedAgentToolFileProjection>;
65
101
  export declare function modelSupportsInlineImages(model: LanguageModel): boolean;
102
+ /**
103
+ * The context once the request's inline image budget decided its pending images: each reads inline,
104
+ * or as metadata with the note that says why, in the prompt and in the manifest.
105
+ */
106
+ export declare function settleAttachmentImages(context: PreparedAgentAttachmentContext, outcomes: ReadonlyMap<string, AttachmentImageOutcome>): PreparedAgentAttachmentContext;
66
107
  export declare function formatBytes(bytes: number): string;
67
108
  export { attachmentKey, attachmentKeyMessageId, findMessageAttachment, toolResultAttachmentKey, } from "@sixb/core/internal/agents";
68
109
  //# sourceMappingURL=attachments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"attachments.d.ts","sourceRoot":"","sources":["../src/attachments.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAY,OAAO,EAAE,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAE,KAAK,iBAAiB,EAA0B,MAAM,4BAA4B,CAAA;AAC3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAkB5D;;;GAGG;AACH,eAAO,MAAM,yBAAyB;;;;CAI5B,CAAA;AAEV,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,OAAO,EAAE,SAAS,uBAAuB,EAAE,CAAA;IACpD,QAAQ,CAAC,mBAAmB,EAAE,WAAW,CA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B,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,4BAA4B,CAAA"}
@@ -2,11 +2,6 @@ import type { AgentRunFileStore } from "@sixb/core/internal/agents";
2
2
  import type { SubagentRunFile } from "@sixb/core/storage";
3
3
  import { type PreparedAgentAttachmentContext } from "./attachments";
4
4
  import type { AgentRunFiles } from "./types";
5
- /**
6
- * Where a parent finds them, a directory per spawn key, in the context directory. They last for
7
- * the turn, like the run's attachments and artifacts.
8
- */
9
- export declare const CHILD_FILES_DIRECTORY = "children";
10
5
  /** A file a child returned, copied into its parent's sandbox for the turn. */
11
6
  export interface InstalledChildFile extends SubagentRunFile {
12
7
  /** As the agent names it: relative to the working directory, or absolute. */
@@ -1 +1 @@
1
- {"version":3,"file":"child-files.d.ts","sourceRoot":"","sources":["../src/child-files.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAEnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAGzD,OAAO,EAEL,KAAK,8BAA8B,EAEpC,MAAM,eAAe,CAAA;AAatB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAS5C;;;GAGG;AACH,eAAO,MAAM,qBAAqB,aAAa,CAAA;AAe/C,8EAA8E;AAC9E,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,6EAA6E;IAC7E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B;AAED,iEAAiE;AACjE,MAAM,WAAW,YAAY;IAC3B,8FAA8F;IAC9F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,wDAAwD;IACxD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE;IAC7C,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAC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iBAAiB,CAAA;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAC9B,GAAG,OAAO,CAAC,8BAA8B,CAAC,CA6C1C;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE;IAC7C,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAA;IAC3C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;CAC7B,GAAG,OAAO,CAAC;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAuDnF;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE;IAC/C,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAA;IAC5C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;CAC7B,GAAG,OAAO,CAAC,SAAS,kBAAkB,EAAE,CAAC,CA2BzC"}
@@ -1,4 +1,5 @@
1
1
  import type { Sandbox, SandboxRequestCredential } from "@sixb/core";
2
+ import type { ConversationAgentRunRecord } from "@sixb/core/storage";
2
3
  /** Opens the sandbox a computer's run works in. */
3
4
  export type OpenComputerSandbox = (input: {
4
5
  /** The user's folder, for a turn; absent for a child, which works in a folder of its own. */
@@ -15,13 +16,20 @@ export interface ComputerRunnerOptions {
15
16
  /** The user's own credential, as an `Authorization` header value, read for each claim. */
16
17
  authorization(): Promise<string>;
17
18
  /**
18
- * This computer's id, which each claim names: a thread runs on one of its owner's computers, and
19
- * only that one claims its turns.
19
+ * This computer, as each claim names it with the folder: a thread runs on one of its owner's
20
+ * computers, in one folder there, and only `sixb` open there claims its turns.
20
21
  */
21
- computerId(): Promise<string>;
22
- /** The folder the user's turns work in. */
22
+ computer(): Promise<{
23
+ readonly id: string;
24
+ readonly name: string;
25
+ }>;
26
+ /** The folder the user's turns work in: its real path. */
23
27
  readonly folder: string;
24
- /** Where each run's own files go, a directory per run, removed when the run ends. */
28
+ /**
29
+ * Where each run's own files go: a directory per thread, so every turn's prompt names the same
30
+ * paths, emptied when a run starts and removed when it ends. Shared by every runner on the
31
+ * computer, which hold a thread's directory one run at a time.
32
+ */
25
33
  readonly runFilesRoot: string;
26
34
  readonly openSandbox: OpenComputerSandbox;
27
35
  /** How many children of one turn run at once. Defaults to 4. */
@@ -41,7 +49,7 @@ export declare class ComputerRunner {
41
49
  * ended already, or another runner holds it. `signal` stops the runner: the turn ends
42
50
  * interrupted, its end recorded.
43
51
  */
44
- runTurn(runId: string, signal: AbortSignal): Promise<boolean>;
52
+ runTurn(runId: string, signal: AbortSignal, onClaimed?: (run: ConversationAgentRunRecord) => void): Promise<boolean>;
45
53
  /**
46
54
  * Renew a running turn's lease now rather than at its next renewal: its answer carries a cancel
47
55
  * just asked for, so a stop from this computer takes effect at once.
@@ -57,7 +65,8 @@ export declare class ComputerRunner {
57
65
  private childRunner;
58
66
  /**
59
67
  * A run's sandbox: the user's folder for a turn, which the prompt describes, or a blank folder
60
- * of its own for a child. Its own files go in a directory of their own, outside the folder.
68
+ * of its own for a child. Its own files go in its thread's directory, outside the folder: the
69
+ * prompt names them, so each run of the thread names the same paths.
61
70
  */
62
71
  private sandbox;
63
72
  private track;
@@ -1 +1 @@
1
- {"version":3,"file":"computer-runner.d.ts","sourceRoot":"","sources":["../src/computer-runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAqBnE,mDAAmD;AACnD,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE;IACxC,6FAA6F;IAC7F,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAClC,0FA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AC/B,mDAAmD;IACnD,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAC7C,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CACzD;AAOD,qBAAa,cAAc;IAKb,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2B;IACrD,gEAAgE;IAChE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgC;gBAE5B,OAAO,EAAE,qBAAqB;IAE3D;;;;OAIG;IACG,OAAO,CACX,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,WAAW,EACnB,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,0BAA0B,KAAK,IAAI,GACpD,OAAO,CAAC,OAAO,CAAC;IA+EnB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI7B,2DAA2D;IACrD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;;OAGG;IACH,OAAO,CAAC,KAAK;IAsBb,OAAO,CAAC,WAAW;IAkCnB;;;;OAIG;IACH,OAAO,CAAC,OAAO;IA8Df,OAAO,CAAC,KAAK;CAId"}
@@ -1,15 +1,5 @@
1
- import { type LanguageModel, type LanguageModelDefinition, type ModelReasoning } from "@sixb/core/models";
2
- export interface AgentContextBudget {
3
- readonly windowTokens: number;
4
- readonly inputBudgetTokens: number;
5
- readonly reserveTokens: number;
6
- readonly keepRecentTokens: number;
7
- readonly source: "model" | "fallback";
8
- }
9
- interface AgentModelSelection {
10
- readonly model: LanguageModel;
11
- readonly reasoning?: ModelReasoning;
12
- }
1
+ import { type AgentContextBudget, type AgentModelSelection } from "@sixb/core/internal/agents";
2
+ import { type LanguageModel, type LanguageModelRequest } from "@sixb/core/models";
13
3
  /**
14
4
  * Derive the model's input and output budgets from its definition, and cap each call's output to
15
5
  * them. The model comes pinned: whoever hands it over resolved it once for the run.
@@ -17,12 +7,28 @@ interface AgentModelSelection {
17
7
  export declare function prepareAgentModel(selection: AgentModelSelection): {
18
8
  readonly model: LanguageModel;
19
9
  readonly budget: AgentContextBudget;
10
+ /**
11
+ * The bytes per token the run's latest counted call measured, bounded around the run's rate (the
12
+ * project's measurements and its own calls'), as calibration and the output ceiling read it.
13
+ * Undefined until a call is counted.
14
+ */
15
+ readonly measuredBytesPerToken: () => number | undefined;
20
16
  };
21
17
  /**
22
- * Input-only limits are a conservative window: leave the same reserve without inventing a total.
23
- * The reserve is the output every call is guaranteed, not its ceiling, so it stays small and a
24
- * larger output limit never shrinks the input budget.
18
+ * What a call may write for what its input weighs: the room it leaves of the window, up to
19
+ * `capTokens`. The one measure the output ceiling and the guard size a call's answer by.
20
+ */
21
+ export declare function agentOutputRoomTokens(inputTokens: number, budget: AgentContextBudget, capTokens: number): number;
22
+ /**
23
+ * The least room a request past its model's limit is still sent with: what a compaction summary
24
+ * may write (see contextSummaryOutputTokens), the answer the framework already sizes as enough to
25
+ * carry a conversation on. With less, the turn ends with the context error rather than send a
26
+ * call whose answer would be cut off almost at once.
27
+ */
28
+ export declare function agentMinimumAnswerTokens(budget: AgentContextBudget): number;
29
+ /**
30
+ * A call's request as the conversation estimator weighs it (see measureAgentModelRequest), at
31
+ * `bytesPerToken`.
25
32
  */
26
- export declare function resolveAgentContextBudget(selection: AgentModelSelection, definition?: LanguageModelDefinition): AgentContextBudget;
27
- export {};
33
+ export declare function estimateAgentRequestTokens(request: Pick<LanguageModelRequest, "messages" | "tools" | "responseFormat">, bytesPerToken: number): number;
28
34
  //# sourceMappingURL=context-budget.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-budget.d.ts","sourceRoot":"","sources":["../src/context-budget.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAE5B,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAA;A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M,EAAE,kBAAkB,EAC1B,SAAS,EAAE,MAAM,GAChB,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAE3E;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,UAAU,GAAG,OAAO,GAAG,gBAAgB,CAAC,EAC5E,aAAa,EAAE,MAAM,GACpB,MAAM,CAER"}
@@ -1,48 +1,148 @@
1
- import { type AgentContextEstimateTool, type AgentRunSession, type AgentTurnHistory } from "@sixb/core/internal/agents";
1
+ import { type AgentContextBudget, type AgentContextEstimateTool, type AgentRunSession, type AgentSystemPromptSize, type AgentThreadModelContextMessage, type AgentToolSpec, type AgentTurnHistory } from "@sixb/core/internal/agents";
2
2
  import type { OntologyDocsIndexEntry } from "@sixb/core/internal/ontology";
3
- import type { ModelTool } from "@sixb/core/models";
4
- import type { ConversationAgentRunRecord } from "@sixb/core/storage";
5
- import type { AgentContextBudget } from "./context-budget";
3
+ import type { ModelCachingIntent, ModelMessage, ModelTool } from "@sixb/core/models";
4
+ import type { AgentContextCheckpointReason, ConversationAgentRunRecord, SubagentRunRecord } from "@sixb/core/storage";
6
5
  import type { ConversationMemory } from "./conversation-memory";
7
6
  import type { ResolvedAgentExecutionPlan } from "./execution-plan";
8
7
  import { type ConversationReaders } from "./message-authors";
9
8
  import { type LoadedAgentThreadModelContext } from "./thread-context";
10
9
  import type { AgentTurnRuntime } from "./turn-runtime";
11
10
  import type { AgentExecutionContext } from "./types";
11
+ /** What a turn's model calls start with: the prefix a summary of the conversation continues. */
12
+ export interface ConversationRequest {
13
+ readonly systemPrompt: string;
14
+ /** The same prompt with each section's bytes, when the environment rendered it. */
15
+ readonly systemPromptSize?: AgentSystemPromptSize;
16
+ readonly tools: readonly Pick<ModelTool, "name" | "description" | "inputSchema">[];
17
+ readonly messages: readonly ModelMessage[];
18
+ }
19
+ /**
20
+ * The request a turn's calls send for a history, built as the run's environment and its turn
21
+ * build it, with the memory its prompt shows.
22
+ */
23
+ export type BuildConversationRequest = (input: {
24
+ readonly threadContext: LoadedAgentThreadModelContext;
25
+ readonly memory: ConversationMemory | undefined;
26
+ }) => Promise<ConversationRequest>;
12
27
  export interface PreparedAgentConversationContext {
13
28
  readonly threadContext: LoadedAgentThreadModelContext;
14
29
  /** The memory the run's prompt shows, as of the active checkpoint. */
15
30
  readonly memory?: ConversationMemory;
31
+ /** The bytes per token the turn's history was measured at, when the preflight measured it. */
32
+ readonly bytesPerToken?: number;
16
33
  }
17
34
  /** Memory as of a checkpoint's creation, or of the thread's start when there is none. */
18
35
  export type LoadConversationMemory = (checkpoint: {
19
36
  readonly createdAt: Date;
20
37
  } | null) => Promise<ConversationMemory | undefined>;
21
- /** Load, estimate, and—when required—compact one admitted conversational run before setup. */
22
- export declare function prepareAgentConversationContext(input: {
23
- readonly context: AgentExecutionContext;
24
- /** The turn's session: its history, the checkpoint it writes, and the records it publishes. */
38
+ /** What a request carries besides its history, as an estimate counts it. */
39
+ export interface AgentContextEstimateShape {
40
+ readonly systemPrompt: string;
41
+ readonly tools: readonly AgentContextEstimateTool[];
42
+ /** Messages every request sends ahead of the history: a child's task, once summarized. */
43
+ readonly head?: readonly AgentThreadModelContextMessage[];
44
+ }
45
+ /**
46
+ * What a thread's compaction reads and writes through, before a run or during it: a
47
+ * conversation's, or a child's, whose thread is its history.
48
+ */
49
+ export interface AgentThreadCompactionInput {
50
+ readonly context: Pick<AgentExecutionContext, "id">;
51
+ /** The run's session: its history, the checkpoint it writes, and the records it publishes. */
25
52
  readonly session: AgentRunSession;
26
53
  readonly plan: ResolvedAgentExecutionPlan;
54
+ readonly budget: AgentContextBudget;
55
+ readonly run: ConversationAgentRunRecord | SubagentRunRecord;
56
+ readonly runtime: AgentTurnRuntime;
57
+ readonly loadMemory?: LoadConversationMemory;
58
+ /** The request the run would send for a history: what its summary continues. */
59
+ readonly conversationRequest: BuildConversationRequest;
60
+ /** What the run's requests carry besides a history, with the memory its prompt shows. */
61
+ readonly estimateShape: (threadContext: LoadedAgentThreadModelContext, memory: ConversationMemory | undefined) => AgentContextEstimateShape;
62
+ /** How the run's calls are cached: the summary is read as their continuation. */
63
+ readonly caching: ModelCachingIntent;
64
+ }
65
+ /** What a conversation's compaction reads and writes through, before its turn or during it. */
66
+ interface ConversationCompactionInput extends Omit<AgentThreadCompactionInput, "context" | "run" | "estimateShape" | "caching"> {
67
+ readonly context: AgentExecutionContext;
68
+ readonly run: ConversationAgentRunRecord;
27
69
  /** The ontology files listed in the conversation's prompt. */
28
70
  readonly ontologyIndex?: readonly OntologyDocsIndexEntry[];
29
71
  /** Where the run's files go, as the prompt names them. */
30
72
  readonly contextDirectory: string;
31
- readonly budget: AgentContextBudget;
32
- readonly run: ConversationAgentRunRecord;
33
- /** The conversation's history as the turn started. */
34
- readonly history: AgentTurnHistory;
35
73
  /** Who can read the run's thread: in a shared one, who wrote what counts toward the estimate. */
36
74
  readonly conversation?: ConversationReaders;
37
- readonly runtime: AgentTurnRuntime;
38
75
  readonly frameworkTools?: readonly ModelTool[];
39
- readonly loadMemory?: LoadConversationMemory;
76
+ }
77
+ /** Load, estimate, and—when required—compact one admitted conversational run before setup. */
78
+ export declare function prepareAgentConversationContext(input: ConversationCompactionInput & {
79
+ /** The conversation's history as the turn started. */
80
+ readonly history: AgentTurnHistory;
40
81
  }): Promise<PreparedAgentConversationContext>;
41
- /** Conservatively combine matching provider usage with the current deterministic request shape. */
42
- export declare function estimateAgentConversationInputTokens(input: {
82
+ /** What compacting a thread from within the run in flight is given. */
83
+ interface InRunCompaction {
84
+ /** The history the run works on: as it started, or as its compaction left it. */
85
+ readonly threadContext: LoadedAgentThreadModelContext;
86
+ /** The memory the run's prompt shows. */
87
+ readonly memory: ConversationMemory | undefined;
88
+ readonly reason: AgentContextCheckpointReason;
89
+ /** Whether the thread came back idle, its cache expired: see summarize. */
90
+ readonly coldCache: boolean;
91
+ }
92
+ /**
93
+ * Compact the conversation before the turn in flight, from within it: everything before the
94
+ * turn's own message is summarized, and the turn, its message and the steps it has taken, stays
95
+ * as it is. Undefined when there is nothing before the turn to summarize, when the run already
96
+ * compacted the thread (a run writes one checkpoint), or when the compaction failed: the turn
97
+ * then goes on with what it has.
98
+ */
99
+ export declare function compactAgentConversationInTurn(input: ConversationCompactionInput & InRunCompaction): Promise<PreparedAgentConversationContext | undefined>;
100
+ /**
101
+ * Compact a thread before the run in flight, from within it: everything before the message the
102
+ * run started from is summarized, and that message and the steps it took stay as they are. A
103
+ * conversation's turn, or a child continuing its thread. Undefined as for
104
+ * {@link compactAgentConversationInTurn}.
105
+ *
106
+ * Its estimates before and after weigh the same request, the history with the run's message,
107
+ * without the steps it keeps: what the summary replaced, not what the run is about to send.
108
+ */
109
+ export declare function compactAgentThreadInRun(input: AgentThreadCompactionInput & InRunCompaction): Promise<PreparedAgentConversationContext | undefined>;
110
+ /**
111
+ * Whether a run starts on a thread worth compacting though it fits: its last model call is older
112
+ * than the cache its calls ask for, so the next one rewrites the whole prompt anyway, the prompt
113
+ * is large enough for a summary to make that rewrite much smaller, and compacting brings it under
114
+ * that size, rather than summarize at every idle turn. A thread whose last call the session cannot
115
+ * date (none since its checkpoint) is not compacted for it.
116
+ */
117
+ export declare function shouldCompactIdleContext(input: {
118
+ readonly history: AgentTurnHistory;
119
+ readonly caching: ModelCachingIntent;
120
+ readonly estimatedInputTokens: number;
121
+ /** What the next request weighs once compacted: see compactedRequestTokens. */
122
+ readonly compactedTokens: number;
123
+ }): boolean;
124
+ /** What a thread weighs once compacted from within its run (see compactAgentThreadInRun). */
125
+ export declare function inRunCompactedTokens(input: {
43
126
  readonly plan: ResolvedAgentExecutionPlan;
127
+ readonly budget: AgentContextBudget;
44
128
  readonly threadContext: LoadedAgentThreadModelContext;
45
- readonly systemPrompt: string;
46
- readonly tools: readonly AgentContextEstimateTool[];
129
+ readonly estimateShape: AgentContextEstimateShape;
130
+ readonly bytesPerToken: number;
47
131
  }): number;
132
+ /**
133
+ * The conversation's next request as the model will count it, and the bytes per token it was
134
+ * counted at (see estimateAgentThreadRequest): the run's history, at the rate its run started
135
+ * from, with the system prompt and tools its requests send.
136
+ */
137
+ export declare function estimateAgentConversation(input: AgentContextEstimateShape & {
138
+ readonly plan: ResolvedAgentExecutionPlan;
139
+ readonly budget: AgentContextBudget;
140
+ readonly threadContext: LoadedAgentThreadModelContext;
141
+ }): {
142
+ readonly tokens: number;
143
+ readonly bytesPerToken: number;
144
+ };
145
+ /** Tools as an estimate counts them: their schemas serialized as they are sent. */
146
+ export declare function contextEstimateTools(specs: readonly Pick<AgentToolSpec, "name" | "description" | "inputSchema">[]): readonly AgentContextEstimateTool[];
147
+ export {};
48
148
  //# sourceMappingURL=context-compaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-compaction.d.ts","sourceRoot":"","sources":["../src/context-compaction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,wBAAwB,EAE7B,KAAK,eAAe,EAEpB,KAAK,gBAAgB,EAStB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EAIV,0BAA0B,EAC3B,MAAM,oBAAoB,CAAA;AAG3B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAE/D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAClE,OAAO,EACL,KAAK,mBAAmB,EAGzB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAA2B,KAAK,6BAA6B,EAAE,MAAM,kBAAkB,CAAA;AAE9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,KAAK,EAAE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