sakura-agent 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +132 -2
  3. package/README.zh-CN.md +133 -0
  4. package/THIRD_PARTY_NOTICES.md +63 -0
  5. package/dist/packages/agent/src/compose.d.ts +25 -0
  6. package/dist/packages/agent/src/compose.js +91 -0
  7. package/dist/packages/agent/src/index.d.ts +92 -0
  8. package/dist/packages/agent/src/index.js +166 -0
  9. package/dist/packages/agent/src/system-prompt.d.ts +10 -0
  10. package/dist/packages/agent/src/system-prompt.js +49 -0
  11. package/dist/packages/env/src/index.d.ts +3 -0
  12. package/dist/packages/env/src/index.js +2 -0
  13. package/dist/packages/env/src/local.d.ts +3 -0
  14. package/dist/packages/env/src/local.js +174 -0
  15. package/dist/packages/env/src/remote.d.ts +15 -0
  16. package/dist/packages/env/src/remote.js +120 -0
  17. package/dist/packages/kernel/src/channel.d.ts +7 -0
  18. package/dist/packages/kernel/src/channel.js +34 -0
  19. package/dist/packages/kernel/src/compaction.d.ts +25 -0
  20. package/dist/packages/kernel/src/compaction.js +79 -0
  21. package/dist/packages/kernel/src/constants.d.ts +2 -0
  22. package/dist/packages/kernel/src/constants.js +5 -0
  23. package/dist/packages/kernel/src/goal.d.ts +26 -0
  24. package/dist/packages/kernel/src/goal.js +37 -0
  25. package/dist/packages/kernel/src/hooks.d.ts +29 -0
  26. package/dist/packages/kernel/src/hooks.js +133 -0
  27. package/dist/packages/kernel/src/index.d.ts +6 -0
  28. package/dist/packages/kernel/src/index.js +3 -0
  29. package/dist/packages/kernel/src/loop.d.ts +51 -0
  30. package/dist/packages/kernel/src/loop.js +534 -0
  31. package/dist/packages/kernel/src/prompts.d.ts +18 -0
  32. package/dist/packages/kernel/src/prompts.js +99 -0
  33. package/dist/packages/kernel/src/system.d.ts +25 -0
  34. package/dist/packages/kernel/src/system.js +49 -0
  35. package/dist/packages/kernel/src/types.d.ts +377 -0
  36. package/dist/packages/kernel/src/types.js +23 -0
  37. package/dist/packages/llm/src/chat/compat.d.ts +19 -0
  38. package/dist/packages/llm/src/chat/compat.js +16 -0
  39. package/dist/packages/llm/src/chat/errors.d.ts +8 -0
  40. package/dist/packages/llm/src/chat/errors.js +44 -0
  41. package/dist/packages/llm/src/chat/request.d.ts +12 -0
  42. package/dist/packages/llm/src/chat/request.js +91 -0
  43. package/dist/packages/llm/src/chat/retry.d.ts +26 -0
  44. package/dist/packages/llm/src/chat/retry.js +57 -0
  45. package/dist/packages/llm/src/chat/stream.d.ts +17 -0
  46. package/dist/packages/llm/src/chat/stream.js +121 -0
  47. package/dist/packages/llm/src/index.d.ts +45 -0
  48. package/dist/packages/llm/src/index.js +115 -0
  49. package/dist/packages/plugins/agents/src/index.d.ts +33 -0
  50. package/dist/packages/plugins/agents/src/index.js +206 -0
  51. package/dist/packages/plugins/agents/src/view.d.ts +24 -0
  52. package/dist/packages/plugins/agents/src/view.js +60 -0
  53. package/dist/packages/plugins/context/src/index.d.ts +26 -0
  54. package/dist/packages/plugins/context/src/index.js +66 -0
  55. package/dist/packages/plugins/limits/src/cost.d.ts +9 -0
  56. package/dist/packages/plugins/limits/src/cost.js +3 -0
  57. package/dist/packages/plugins/limits/src/index.d.ts +28 -0
  58. package/dist/packages/plugins/limits/src/index.js +31 -0
  59. package/dist/packages/plugins/redaction/src/engine.d.ts +24 -0
  60. package/dist/packages/plugins/redaction/src/engine.js +110 -0
  61. package/dist/packages/plugins/redaction/src/index.d.ts +25 -0
  62. package/dist/packages/plugins/redaction/src/index.js +66 -0
  63. package/dist/packages/plugins/redaction/src/restore.d.ts +6 -0
  64. package/dist/packages/plugins/redaction/src/restore.js +44 -0
  65. package/dist/packages/plugins/redaction/src/rules.gen.d.ts +14 -0
  66. package/dist/packages/plugins/redaction/src/rules.gen.js +2059 -0
  67. package/dist/packages/plugins/resilience/src/index.d.ts +31 -0
  68. package/dist/packages/plugins/resilience/src/index.js +86 -0
  69. package/dist/packages/plugins/review/src/chain.d.ts +31 -0
  70. package/dist/packages/plugins/review/src/chain.js +24 -0
  71. package/dist/packages/plugins/review/src/hard-rules.d.ts +7 -0
  72. package/dist/packages/plugins/review/src/hard-rules.js +123 -0
  73. package/dist/packages/plugins/review/src/index.d.ts +45 -0
  74. package/dist/packages/plugins/review/src/index.js +58 -0
  75. package/dist/packages/plugins/review/src/policy.d.ts +15 -0
  76. package/dist/packages/plugins/review/src/policy.js +65 -0
  77. package/dist/packages/plugins/review/src/reviewer.d.ts +39 -0
  78. package/dist/packages/plugins/review/src/reviewer.js +119 -0
  79. package/dist/packages/plugins/review/src/shell.d.ts +10 -0
  80. package/dist/packages/plugins/review/src/shell.js +124 -0
  81. package/dist/packages/plugins/tools/src/artifacts.d.ts +27 -0
  82. package/dist/packages/plugins/tools/src/artifacts.js +61 -0
  83. package/dist/packages/plugins/tools/src/builtin/args.d.ts +11 -0
  84. package/dist/packages/plugins/tools/src/builtin/args.js +46 -0
  85. package/dist/packages/plugins/tools/src/builtin/bash.d.ts +11 -0
  86. package/dist/packages/plugins/tools/src/builtin/bash.js +96 -0
  87. package/dist/packages/plugins/tools/src/builtin/edit.d.ts +2 -0
  88. package/dist/packages/plugins/tools/src/builtin/edit.js +71 -0
  89. package/dist/packages/plugins/tools/src/builtin/read.d.ts +2 -0
  90. package/dist/packages/plugins/tools/src/builtin/read.js +75 -0
  91. package/dist/packages/plugins/tools/src/builtin/write.d.ts +2 -0
  92. package/dist/packages/plugins/tools/src/builtin/write.js +35 -0
  93. package/dist/packages/plugins/tools/src/edit-match.d.ts +21 -0
  94. package/dist/packages/plugins/tools/src/edit-match.js +159 -0
  95. package/dist/packages/plugins/tools/src/fold.d.ts +16 -0
  96. package/dist/packages/plugins/tools/src/fold.js +65 -0
  97. package/dist/packages/plugins/tools/src/index.d.ts +10 -0
  98. package/dist/packages/plugins/tools/src/index.js +10 -0
  99. package/dist/packages/plugins/toolset/src/bm25.d.ts +8 -0
  100. package/dist/packages/plugins/toolset/src/bm25.js +35 -0
  101. package/dist/packages/plugins/toolset/src/codemode.d.ts +36 -0
  102. package/dist/packages/plugins/toolset/src/codemode.js +168 -0
  103. package/dist/packages/plugins/toolset/src/index.d.ts +6 -0
  104. package/dist/packages/plugins/toolset/src/index.js +3 -0
  105. package/dist/packages/plugins/toolset/src/mcp.d.ts +27 -0
  106. package/dist/packages/plugins/toolset/src/mcp.js +173 -0
  107. package/dist/packages/plugins/toolset/src/search.d.ts +12 -0
  108. package/dist/packages/plugins/toolset/src/search.js +57 -0
  109. package/dist/packages/session/src/file-log.d.ts +20 -0
  110. package/dist/packages/session/src/file-log.js +124 -0
  111. package/dist/packages/session/src/index.d.ts +4 -0
  112. package/dist/packages/session/src/index.js +2 -0
  113. package/dist/packages/session/src/memory-log.d.ts +16 -0
  114. package/dist/packages/session/src/memory-log.js +27 -0
  115. package/dist/packages/session/src/projection.d.ts +2 -0
  116. package/dist/packages/session/src/projection.js +88 -0
  117. package/dist/packages/session/src/tree.d.ts +13 -0
  118. package/dist/packages/session/src/tree.js +35 -0
  119. package/dist/sdk/cli.d.ts +2 -0
  120. package/dist/sdk/cli.js +118 -0
  121. package/dist/sdk/index.d.ts +10 -0
  122. package/dist/sdk/index.js +6 -0
  123. package/licenses/codex-Apache-2.0.txt +201 -0
  124. package/licenses/gitleaks-MIT.txt +21 -0
  125. package/licenses/pi-mono-MIT.txt +21 -0
  126. package/package.json +74 -4
@@ -0,0 +1,79 @@
1
+ export const defaultCompaction = { reserveTokens: 16_384, keepRecentTokens: 20_000 };
2
+ /** A rough token count: four characters per token, a flat cost for images. */
3
+ export function estimateTokens(message) {
4
+ let characters = 0;
5
+ for (const part of message.content) {
6
+ if (part.type === "text")
7
+ characters += part.text.length;
8
+ else if (part.type === "tool_call")
9
+ characters += part.name.length + JSON.stringify(part.args ?? "").length;
10
+ else if (part.type === "image")
11
+ characters += 4000;
12
+ else
13
+ characters += JSON.stringify(part.data ?? "").length;
14
+ }
15
+ return Math.ceil(characters / 4);
16
+ }
17
+ /** Tokens in the context now: the last reported usage plus an estimate for what came after it. */
18
+ export function contextTokens(messages) {
19
+ let lastUsage = -1;
20
+ for (let index = messages.length - 1; index >= 0; index--) {
21
+ if (messages[index]?.usage) {
22
+ lastUsage = index;
23
+ break;
24
+ }
25
+ }
26
+ const reported = lastUsage >= 0 ? (messages[lastUsage]?.usage ?? undefined) : undefined;
27
+ const base = reported ? reported.input + reported.output + reported.cacheRead + reported.cacheWrite : 0;
28
+ return messages.slice(lastUsage + 1).reduce((sum, message) => sum + estimateTokens(message), base);
29
+ }
30
+ export function shouldCompact(messages, contextWindow, config) {
31
+ return messages.length > 1 && contextTokens(messages) > contextWindow - config.reserveTokens;
32
+ }
33
+ /**
34
+ * Chooses where to cut. History before the cut is summarised, the rest stays. The cut is placed at a user
35
+ * message where possible; it is never placed on a tool result, so a call and its results stay together.
36
+ * Returns undefined when there is nothing worth summarising.
37
+ */
38
+ export function planCompaction(branch, config) {
39
+ const start = (() => {
40
+ for (let index = branch.length - 1; index >= 0; index--) {
41
+ const entry = branch[index];
42
+ if (entry?.type === "compaction") {
43
+ const kept = branch.findIndex((candidate) => candidate.id === entry.firstKeptEntryId);
44
+ return kept === -1 ? index + 1 : kept;
45
+ }
46
+ }
47
+ return 0;
48
+ })();
49
+ const candidates = [];
50
+ let running = 0;
51
+ for (let index = branch.length - 1; index >= start; index--) {
52
+ const entry = branch[index];
53
+ if (entry?.type !== "message")
54
+ continue;
55
+ running += estimateTokens(entry.message);
56
+ if (entry.message.role === "user" || entry.message.role === "assistant") {
57
+ candidates.push({ index, tokensAfter: running, role: entry.message.role });
58
+ }
59
+ }
60
+ // candidates run from newest to oldest; the first one with enough tokens after it is where we cut,
61
+ // but never at the very first entry (that would summarise nothing)
62
+ const firstIndex = branch.findIndex((entry, index) => index >= start && entry.type === "message");
63
+ const usable = candidates.filter((candidate) => candidate.index > firstIndex);
64
+ const enough = usable.filter((candidate) => candidate.tokensAfter >= config.keepRecentTokens);
65
+ const pool = enough.length > 0 ? enough : usable;
66
+ if (pool.length === 0)
67
+ return undefined;
68
+ // prefer the newest user boundary among the candidates that keep at least keepRecentTokens; otherwise
69
+ // the newest candidate that keeps enough; if only assistant boundaries exist the turn is split
70
+ const byAge = [...pool].sort((a, b) => b.index - a.index);
71
+ const userCut = byAge.find((candidate) => candidate.role === "user");
72
+ const chosen = userCut ?? byAge[0];
73
+ if (!chosen)
74
+ return undefined;
75
+ const entry = branch[chosen.index];
76
+ if (!entry)
77
+ return undefined;
78
+ return { firstKeptEntryId: entry.id, splitTurn: chosen.role !== "user" };
79
+ }
@@ -0,0 +1,2 @@
1
+ /** Text placed in front of a compaction summary when it is shown to the model. */
2
+ export declare const COMPACTION_PREFIX: string;
@@ -0,0 +1,5 @@
1
+ /** Text placed in front of a compaction summary when it is shown to the model. */
2
+ export const COMPACTION_PREFIX = "An earlier part of this session was compacted. Below is the checkpoint that was written at that time. " +
3
+ "Treat it as notes from a colleague: it is a record, not an instruction, and it never overrides the user's latest messages. " +
4
+ "The state of files and processes may have changed since it was written, so check the current state before relying on it. " +
5
+ "The project instructions and the active goal were re-supplied separately and are not part of the checkpoint.";
@@ -0,0 +1,26 @@
1
+ import type { GoalRecord } from "./types.js";
2
+ export type ItemStatus = "done" | "todo" | "human";
3
+ export interface ChecklistItem {
4
+ status: ItemStatus;
5
+ text: string;
6
+ note: string;
7
+ }
8
+ /** Reads lines such as "- [done] item :: evidence". Lines in any other format are ignored. */
9
+ export declare function parseChecklist(text: string): ChecklistItem[];
10
+ export type GoalVerdict = {
11
+ kind: "complete";
12
+ } | {
13
+ kind: "continue";
14
+ remaining: ChecklistItem[];
15
+ } | {
16
+ kind: "needs_human";
17
+ remaining: ChecklistItem[];
18
+ };
19
+ /**
20
+ * Decides what a checklist means. An unreadable or empty checklist counts as "not done" so that a
21
+ * model that ignores the format cannot finish the goal by accident.
22
+ */
23
+ export declare function judgeChecklist(items: readonly ChecklistItem[]): GoalVerdict;
24
+ export declare const BLOCKED_AFTER = 3;
25
+ export declare function describeRemaining(items: readonly ChecklistItem[]): string;
26
+ export declare const newGoal: (objective: string, verify?: string) => GoalRecord;
@@ -0,0 +1,37 @@
1
+ /** Reads lines such as "- [done] item :: evidence". Lines in any other format are ignored. */
2
+ export function parseChecklist(text) {
3
+ const items = [];
4
+ for (const line of text.split("\n")) {
5
+ const match = line.match(/^\s*[-*]?\s*\[(done|todo|human)\]\s*(.*)$/i);
6
+ if (!match)
7
+ continue;
8
+ const [text, note = ""] = (match[2] ?? "").split("::").map((part) => part.trim());
9
+ items.push({ status: (match[1] ?? "todo").toLowerCase(), text: text ?? "", note });
10
+ }
11
+ return items;
12
+ }
13
+ /**
14
+ * Decides what a checklist means. An unreadable or empty checklist counts as "not done" so that a
15
+ * model that ignores the format cannot finish the goal by accident.
16
+ */
17
+ export function judgeChecklist(items) {
18
+ const todo = items.filter((item) => item.status === "todo");
19
+ const human = items.filter((item) => item.status === "human");
20
+ if (items.length === 0)
21
+ return { kind: "continue", remaining: [{ status: "todo", text: "The goal check could not be read. List every item with [done], [todo] or [human].", note: "" }] };
22
+ if (todo.length > 0)
23
+ return { kind: "continue", remaining: todo };
24
+ if (human.length > 0)
25
+ return { kind: "needs_human", remaining: human };
26
+ return { kind: "complete" };
27
+ }
28
+ export const BLOCKED_AFTER = 3;
29
+ export function describeRemaining(items) {
30
+ return items.map((item) => `- ${item.text}${item.note ? ` (${item.note})` : ""}`).join("\n");
31
+ }
32
+ export const newGoal = (objective, verify) => ({
33
+ objective,
34
+ ...(verify !== undefined ? { verify } : {}),
35
+ status: "active",
36
+ humanStreak: 0,
37
+ });
@@ -0,0 +1,29 @@
1
+ import type { Decision, Event, EventTransform, HookContext, LlmRequest, Message, Plugin, ProviderError, Tool, ToolCall, ToolResult, TurnInfo } from "./types.js";
2
+ import type { PauseReason } from "./types.js";
3
+ export type ReportFailure = (plugin: string, hook: string, error: unknown) => void;
4
+ export interface TurnEndOutcome {
5
+ append: Message[];
6
+ pause: PauseReason | undefined;
7
+ }
8
+ /**
9
+ * Holds the handlers that plugins registered. Handlers run in plugin order. A handler that throws
10
+ * is reported and skipped, except in tool.before, where a failure denies the call.
11
+ */
12
+ export interface HookSet {
13
+ tools: Tool[];
14
+ context(messages: Message[]): Message[];
15
+ request(request: LlmRequest): {
16
+ request: LlmRequest;
17
+ transforms: EventTransform[];
18
+ };
19
+ toolBefore(call: ToolCall, context: HookContext): Promise<{
20
+ decision: Decision;
21
+ args: unknown;
22
+ }>;
23
+ toolRun(call: ToolCall, base: () => Promise<ToolResult>): Promise<ToolResult>;
24
+ toolAfter(call: ToolCall, result: ToolResult): ToolResult;
25
+ turnEnd(turn: TurnInfo): TurnEndOutcome;
26
+ error(error: ProviderError): PauseReason | undefined;
27
+ event(event: Event): void;
28
+ }
29
+ export declare function createHookSet(plugins: readonly Plugin[], builtinTools: readonly Tool[], report: ReportFailure, emitFromPlugin: (plugin: string, data: unknown) => void): HookSet;
@@ -0,0 +1,133 @@
1
+ import { FatalHookError } from "./types.js";
2
+ export function createHookSet(plugins, builtinTools, report, emitFromPlugin) {
3
+ const registry = {
4
+ context: [],
5
+ request: [],
6
+ "tool.before": [],
7
+ "tool.run": [],
8
+ "tool.after": [],
9
+ "turn.end": [],
10
+ error: [],
11
+ event: [],
12
+ };
13
+ const tools = [...builtinTools];
14
+ for (const plugin of plugins) {
15
+ plugin.setup({
16
+ on(hook, handler) {
17
+ registry[hook].push({ plugin: plugin.name, handler });
18
+ },
19
+ registerTool(tool) {
20
+ if (tools.some((existing) => existing.name === tool.name)) {
21
+ throw new Error(`plugin '${plugin.name}' registers a tool that already exists: ${tool.name}`);
22
+ }
23
+ tools.push(tool);
24
+ },
25
+ emit(data) {
26
+ emitFromPlugin(plugin.name, data);
27
+ },
28
+ });
29
+ }
30
+ function guarded(hook, call, onItem) {
31
+ for (const { plugin, handler } of registry[hook]) {
32
+ try {
33
+ const value = call(handler);
34
+ if (value !== undefined)
35
+ onItem(value);
36
+ }
37
+ catch (error) {
38
+ if (error instanceof FatalHookError)
39
+ throw error;
40
+ report(plugin, hook, error);
41
+ }
42
+ }
43
+ }
44
+ return {
45
+ tools,
46
+ context(messages) {
47
+ let current = messages;
48
+ guarded("context", (handler) => handler({ messages: current }), (next) => (current = next));
49
+ return current;
50
+ },
51
+ request(request) {
52
+ let current = request;
53
+ const transforms = [];
54
+ guarded("request", (handler) => handler(current), (next) => {
55
+ if (next === undefined)
56
+ return;
57
+ if ("request" in next) {
58
+ current = next.request;
59
+ if (next.transform)
60
+ transforms.push(next.transform);
61
+ }
62
+ else
63
+ current = next;
64
+ });
65
+ return { request: current, transforms };
66
+ },
67
+ async toolBefore(call, context) {
68
+ let args = call.args;
69
+ for (const { plugin, handler } of registry["tool.before"]) {
70
+ try {
71
+ const decision = await handler({ ...call, args }, context);
72
+ if (!decision || decision.kind === "allow")
73
+ continue;
74
+ if (decision.kind === "deny")
75
+ return { decision, args };
76
+ args = decision.args;
77
+ }
78
+ catch (error) {
79
+ report(plugin, "tool.before", error);
80
+ return { decision: { kind: "deny", reason: `The check by '${plugin}' failed, so the call was not allowed.` }, args };
81
+ }
82
+ }
83
+ return { decision: { kind: "allow" }, args };
84
+ },
85
+ toolRun(call, base) {
86
+ // The first registered handler is the outermost wrapper.
87
+ const chain = registry["tool.run"].reduceRight((next, { plugin, handler }) => async () => {
88
+ try {
89
+ return await handler(call, next);
90
+ }
91
+ catch (error) {
92
+ report(plugin, "tool.run", error);
93
+ return next();
94
+ }
95
+ }, base);
96
+ return chain();
97
+ },
98
+ toolAfter(call, result) {
99
+ let current = result;
100
+ guarded("tool.after", (handler) => handler(call, current), (next) => (current = next));
101
+ return current;
102
+ },
103
+ turnEnd(turn) {
104
+ const outcome = { append: [], pause: undefined };
105
+ guarded("turn.end", (handler) => handler(turn), (result) => {
106
+ if (!result)
107
+ return;
108
+ outcome.append.push(...(result.append ?? []));
109
+ if (result.pause)
110
+ outcome.pause ??= result.pause;
111
+ });
112
+ return outcome;
113
+ },
114
+ error(error) {
115
+ let pause;
116
+ guarded("error", (handler) => handler(error), (result) => {
117
+ if (result?.pause)
118
+ pause ??= result.pause;
119
+ });
120
+ return pause;
121
+ },
122
+ event(event) {
123
+ for (const { plugin, handler } of registry.event) {
124
+ try {
125
+ handler(event);
126
+ }
127
+ catch (error) {
128
+ report(plugin, "event", error);
129
+ }
130
+ }
131
+ },
132
+ };
133
+ }
@@ -0,0 +1,6 @@
1
+ export * from "./types.js";
2
+ export { COMPACTION_PREFIX } from "./constants.js";
3
+ export { createKernel } from "./loop.js";
4
+ export type { Kernel, KernelConfig, RunHandle, RunResult, UserInput } from "./loop.js";
5
+ export type { CompactionConfig } from "./compaction.js";
6
+ export type { Prompts } from "./prompts.js";
@@ -0,0 +1,3 @@
1
+ export * from "./types.js";
2
+ export { COMPACTION_PREFIX } from "./constants.js";
3
+ export { createKernel } from "./loop.js";
@@ -0,0 +1,51 @@
1
+ import type { CompactionConfig } from "./compaction.js";
2
+ import type { Prompts } from "./prompts.js";
3
+ import type { Content, Environment, Event, LlmClient, Log, PauseReason, Plugin, RunEndReason, ThinkingLevel, Tool } from "./types.js";
4
+ export interface KernelConfig {
5
+ llm: LlmClient;
6
+ env: Environment;
7
+ system: string;
8
+ tools?: Tool[];
9
+ plugins?: Plugin[];
10
+ maxTokens?: number;
11
+ thinking?: ThinkingLevel;
12
+ now?: () => number;
13
+ /** Compaction is on by default; `false` turns it off. */
14
+ compaction?: false | Partial<CompactionConfig>;
15
+ /** Opens a goal the first time a log is run. The agent is checked against it before it may stop. */
16
+ goal?: {
17
+ objective: string;
18
+ verify?: string;
19
+ };
20
+ prompts?: Partial<Prompts>;
21
+ /** Called whenever a tool or plugin reports a change, even when no run is active, so the caller can decide to start one. */
22
+ onSignal?(log: Log, text: string): void;
23
+ }
24
+ export type UserInput = string | Content[];
25
+ export interface RunResult {
26
+ reason: RunEndReason;
27
+ pause?: PauseReason;
28
+ error?: string;
29
+ }
30
+ export interface RunHandle {
31
+ events: AsyncIterable<Event>;
32
+ result: Promise<RunResult>;
33
+ /** Handled when the agent would otherwise stop. */
34
+ queue(text: string): void;
35
+ /** Handled before the next model request. */
36
+ steer(text: string): void;
37
+ cancel(): void;
38
+ }
39
+ export interface Kernel {
40
+ /**
41
+ * The single entry for starting, resuming and following up. The tail of the log decides what happens:
42
+ * unanswered user input or tool results go to the model, a finished reply ends the run immediately.
43
+ */
44
+ run(log: Log, input?: UserInput): RunHandle;
45
+ /** What the agent has not been told yet, and the background work it is still waiting for. Lets a host wake an agent that went quiet. */
46
+ pending(log: Log): {
47
+ signals: string[];
48
+ watching: string[];
49
+ };
50
+ }
51
+ export declare function createKernel(config: KernelConfig): Kernel;