@zmzai/agent-framework 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/dist/adapters/fs-workspace.d.ts +7 -0
  2. package/dist/adapters/fs-workspace.d.ts.map +1 -0
  3. package/dist/adapters/fs-workspace.js +91 -0
  4. package/dist/adapters/fs-workspace.js.map +1 -0
  5. package/dist/adapters/index.d.ts +46 -0
  6. package/dist/adapters/index.d.ts.map +1 -0
  7. package/dist/adapters/index.js +14 -0
  8. package/dist/adapters/index.js.map +1 -0
  9. package/dist/adapters/openai-provider.d.ts +17 -0
  10. package/dist/adapters/openai-provider.d.ts.map +1 -0
  11. package/dist/adapters/openai-provider.js +116 -0
  12. package/dist/adapters/openai-provider.js.map +1 -0
  13. package/dist/adapters/subprocess-sandbox.d.ts +7 -0
  14. package/dist/adapters/subprocess-sandbox.d.ts.map +1 -0
  15. package/dist/adapters/subprocess-sandbox.js +91 -0
  16. package/dist/adapters/subprocess-sandbox.js.map +1 -0
  17. package/dist/adapters/workspace-edit.d.ts +19 -0
  18. package/dist/adapters/workspace-edit.d.ts.map +1 -0
  19. package/dist/adapters/workspace-edit.js +36 -0
  20. package/dist/adapters/workspace-edit.js.map +1 -0
  21. package/dist/cli.d.ts +3 -0
  22. package/dist/cli.d.ts.map +1 -0
  23. package/dist/cli.js +191 -0
  24. package/dist/cli.js.map +1 -0
  25. package/dist/core/agent/loader.d.ts +17 -0
  26. package/dist/core/agent/loader.d.ts.map +1 -0
  27. package/dist/core/agent/loader.js +148 -0
  28. package/dist/core/agent/loader.js.map +1 -0
  29. package/dist/core/agent/plugin.d.ts +59 -0
  30. package/dist/core/agent/plugin.d.ts.map +1 -0
  31. package/dist/core/agent/plugin.js +125 -0
  32. package/dist/core/agent/plugin.js.map +1 -0
  33. package/dist/core/agent/registry.d.ts +45 -0
  34. package/dist/core/agent/registry.d.ts.map +1 -0
  35. package/dist/core/agent/registry.js +98 -0
  36. package/dist/core/agent/registry.js.map +1 -0
  37. package/dist/core/agent/resolver.d.ts +16 -0
  38. package/dist/core/agent/resolver.d.ts.map +1 -0
  39. package/dist/core/agent/resolver.js +2 -0
  40. package/dist/core/agent/resolver.js.map +1 -0
  41. package/dist/core/events/bus.d.ts +30 -0
  42. package/dist/core/events/bus.d.ts.map +1 -0
  43. package/dist/core/events/bus.js +112 -0
  44. package/dist/core/events/bus.js.map +1 -0
  45. package/dist/core/events/manifest.d.ts +117 -0
  46. package/dist/core/events/manifest.d.ts.map +1 -0
  47. package/dist/core/events/manifest.js +69 -0
  48. package/dist/core/events/manifest.js.map +1 -0
  49. package/dist/core/permission/engine.d.ts +84 -0
  50. package/dist/core/permission/engine.d.ts.map +1 -0
  51. package/dist/core/permission/engine.js +131 -0
  52. package/dist/core/permission/engine.js.map +1 -0
  53. package/dist/core/permission/ruleset.d.ts +30 -0
  54. package/dist/core/permission/ruleset.d.ts.map +1 -0
  55. package/dist/core/permission/ruleset.js +85 -0
  56. package/dist/core/permission/ruleset.js.map +1 -0
  57. package/dist/core/runtime/compaction.d.ts +59 -0
  58. package/dist/core/runtime/compaction.d.ts.map +1 -0
  59. package/dist/core/runtime/compaction.js +108 -0
  60. package/dist/core/runtime/compaction.js.map +1 -0
  61. package/dist/core/runtime/lease-recovery.d.ts +45 -0
  62. package/dist/core/runtime/lease-recovery.d.ts.map +1 -0
  63. package/dist/core/runtime/lease-recovery.js +112 -0
  64. package/dist/core/runtime/lease-recovery.js.map +1 -0
  65. package/dist/core/runtime/loop-guard.d.ts +51 -0
  66. package/dist/core/runtime/loop-guard.d.ts.map +1 -0
  67. package/dist/core/runtime/loop-guard.js +90 -0
  68. package/dist/core/runtime/loop-guard.js.map +1 -0
  69. package/dist/core/runtime/pi-bridge.d.ts +53 -0
  70. package/dist/core/runtime/pi-bridge.d.ts.map +1 -0
  71. package/dist/core/runtime/pi-bridge.js +259 -0
  72. package/dist/core/runtime/pi-bridge.js.map +1 -0
  73. package/dist/core/runtime/runner.d.ts +127 -0
  74. package/dist/core/runtime/runner.d.ts.map +1 -0
  75. package/dist/core/runtime/runner.js +614 -0
  76. package/dist/core/runtime/runner.js.map +1 -0
  77. package/dist/core/session/ids.d.ts +7 -0
  78. package/dist/core/session/ids.d.ts.map +1 -0
  79. package/dist/core/session/ids.js +18 -0
  80. package/dist/core/session/ids.js.map +1 -0
  81. package/dist/core/session/jsonl-store.d.ts +14 -0
  82. package/dist/core/session/jsonl-store.d.ts.map +1 -0
  83. package/dist/core/session/jsonl-store.js +142 -0
  84. package/dist/core/session/jsonl-store.js.map +1 -0
  85. package/dist/core/session/store.d.ts +25 -0
  86. package/dist/core/session/store.d.ts.map +1 -0
  87. package/dist/core/session/store.js +2 -0
  88. package/dist/core/session/store.js.map +1 -0
  89. package/dist/core/session/types.d.ts +142 -0
  90. package/dist/core/session/types.d.ts.map +1 -0
  91. package/dist/core/session/types.js +2 -0
  92. package/dist/core/session/types.js.map +1 -0
  93. package/dist/core/tools/adapter.d.ts +33 -0
  94. package/dist/core/tools/adapter.d.ts.map +1 -0
  95. package/dist/core/tools/adapter.js +87 -0
  96. package/dist/core/tools/adapter.js.map +1 -0
  97. package/dist/core/tools/builtins.d.ts +13 -0
  98. package/dist/core/tools/builtins.d.ts.map +1 -0
  99. package/dist/core/tools/builtins.js +219 -0
  100. package/dist/core/tools/builtins.js.map +1 -0
  101. package/dist/core/tools/context.d.ts +136 -0
  102. package/dist/core/tools/context.d.ts.map +1 -0
  103. package/dist/core/tools/context.js +2 -0
  104. package/dist/core/tools/context.js.map +1 -0
  105. package/dist/core/tools/def.d.ts +27 -0
  106. package/dist/core/tools/def.d.ts.map +1 -0
  107. package/dist/core/tools/def.js +2 -0
  108. package/dist/core/tools/def.js.map +1 -0
  109. package/dist/core/tools/qa-check.d.ts +30 -0
  110. package/dist/core/tools/qa-check.d.ts.map +1 -0
  111. package/dist/core/tools/qa-check.js +50 -0
  112. package/dist/core/tools/qa-check.js.map +1 -0
  113. package/dist/core/tools/task.d.ts +8 -0
  114. package/dist/core/tools/task.d.ts.map +1 -0
  115. package/dist/core/tools/task.js +33 -0
  116. package/dist/core/tools/task.js.map +1 -0
  117. package/dist/index.d.ts +38 -0
  118. package/dist/index.d.ts.map +1 -0
  119. package/dist/index.js +28 -0
  120. package/dist/index.js.map +1 -0
  121. package/dist/server/create-server.d.ts +51 -0
  122. package/dist/server/create-server.d.ts.map +1 -0
  123. package/dist/server/create-server.js +29 -0
  124. package/dist/server/create-server.js.map +1 -0
  125. package/openapi.yaml +239 -0
  126. package/package.json +32 -0
@@ -0,0 +1,219 @@
1
+ import { z } from "zod";
2
+ import { qaCheckTool } from "./qa-check.js";
3
+ import { wildcardMatch } from "../permission/ruleset.js";
4
+ /** Built-in tools (spec §7.2). These operate on the WorkspaceFiles facade, so
5
+ * the same definitions serve the Mongo cloud backend and a future local FS
6
+ * backend. */
7
+ export const readTool = {
8
+ id: "read",
9
+ label: "读取文件",
10
+ description: "读取当前 Workspace 中一个文本文件的内容。路径必须来自 glob 结果或已知 Workspace 路径。",
11
+ parameters: z.object({ path: z.string().min(1).max(512) }),
12
+ permission: (args) => ({ permission: "read", patterns: [args.path] }),
13
+ async execute(args, ctx) {
14
+ const file = await ctx.workspace.read(args.path);
15
+ if (!file)
16
+ throw new Error(`文件不存在或不可读取:${args.path}`);
17
+ return { title: `读取 ${args.path}`, output: file.content || "(空文件)", metadata: { path: args.path, bytes: Buffer.byteLength(file.content, "utf8") } };
18
+ },
19
+ };
20
+ export const globTool = {
21
+ id: "glob",
22
+ label: "按模式列文件",
23
+ description: "按 glob 模式列出 Workspace 文件路径(* 匹配任意字符序列,? 匹配单字符)。不传 pattern 则列出全部。",
24
+ parameters: z.object({ pattern: z.string().max(256).optional() }),
25
+ permission: () => ({ permission: "glob", patterns: ["*"] }),
26
+ async execute(args, ctx) {
27
+ const files = await ctx.workspace.list();
28
+ const matched = args.pattern ? files.filter((file) => wildcardMatch(args.pattern, file.path)) : files;
29
+ const limited = matched.slice(0, 200);
30
+ return {
31
+ title: `列出 ${limited.length} 个文件`,
32
+ output: limited.length ? limited.map((file) => `${file.path}(${file.bytes} B)`).join("\n") : "没有匹配的文件。",
33
+ metadata: { count: limited.length, total: matched.length },
34
+ };
35
+ },
36
+ };
37
+ export const grepTool = {
38
+ id: "grep",
39
+ label: "搜索文件内容",
40
+ description: "在 Workspace 文本文件内容中搜索关键词,最多返回 50 条匹配(path:line: 内容)。",
41
+ parameters: z.object({
42
+ query: z.string().min(1).max(256),
43
+ pathPattern: z.string().max(256).optional(),
44
+ }),
45
+ permission: (args) => ({ permission: "grep", patterns: [args.query] }),
46
+ async execute(args, ctx) {
47
+ const files = await ctx.workspace.list();
48
+ const candidates = args.pathPattern ? files.filter((file) => wildcardMatch(args.pathPattern, file.path)) : files;
49
+ const matches = [];
50
+ for (const candidate of candidates) {
51
+ if (matches.length >= 50)
52
+ break;
53
+ const file = await ctx.workspace.read(candidate.path);
54
+ if (!file)
55
+ continue;
56
+ const lines = file.content.split("\n");
57
+ for (let index = 0; index < lines.length && matches.length < 50; index++) {
58
+ if (lines[index].includes(args.query)) {
59
+ matches.push({ path: candidate.path, line: index + 1, text: lines[index].slice(0, 200) });
60
+ }
61
+ }
62
+ }
63
+ return {
64
+ title: `搜索 "${args.query}":${matches.length} 条命中`,
65
+ output: matches.length ? matches.map((match) => `${match.path}:${match.line}: ${match.text}`).join("\n") : "没有命中。",
66
+ metadata: { count: matches.length, truncated: matches.length >= 50 },
67
+ };
68
+ },
69
+ };
70
+ export const writeTool = {
71
+ id: "write",
72
+ label: "写入文件",
73
+ description: "创建或完整覆盖 Workspace 中的一个文本文件。写入立即生效并生成不可变版本(可通过 file.edited 事件审查差异)。",
74
+ parameters: z.object({
75
+ path: z.string().min(1).max(512),
76
+ content: z.string().max(512 * 1024),
77
+ summary: z.string().max(200).optional(),
78
+ }),
79
+ permission: (args) => ({ permission: "edit", patterns: [args.path], metadata: { path: args.path, bytes: Buffer.byteLength(args.content, "utf8") } }),
80
+ executionMode: "sequential",
81
+ async execute(args, ctx) {
82
+ const result = await ctx.workspace.write({ path: args.path, content: args.content, author: "agent", summary: args.summary ?? `Agent 写入 ${args.path}` });
83
+ if (!result)
84
+ throw new Error(`路径不合法或写入被拒绝:${args.path}`);
85
+ await ctx.emitFileEdited({ path: args.path, revisionId: result.revisionId, diff: result.diff });
86
+ return { title: `写入 ${args.path}`, output: `已写入 ${args.path}(版本 ${result.revisionId})。`, metadata: { path: args.path, revisionId: result.revisionId } };
87
+ },
88
+ };
89
+ export const editTool = {
90
+ id: "edit",
91
+ label: "编辑文件",
92
+ description: "对 Workspace 文件做精确文本替换:oldText 必须在文件中唯一出现。编辑立即生效并生成不可变版本。",
93
+ parameters: z.object({
94
+ path: z.string().min(1).max(512),
95
+ oldText: z.string().min(1).max(64 * 1024),
96
+ newText: z.string().max(64 * 1024),
97
+ summary: z.string().max(200).optional(),
98
+ }),
99
+ permission: (args) => ({ permission: "edit", patterns: [args.path], metadata: { path: args.path } }),
100
+ executionMode: "sequential",
101
+ async execute(args, ctx) {
102
+ const result = await ctx.workspace.edit({ path: args.path, oldText: args.oldText, newText: args.newText, author: "agent", summary: args.summary ?? `Agent 编辑 ${args.path}` });
103
+ if ("error" in result)
104
+ throw new Error(`编辑失败:${result.error}`);
105
+ await ctx.emitFileEdited({ path: args.path, revisionId: result.revisionId, diff: result.diff });
106
+ return { title: `编辑 ${args.path}`, output: `已编辑 ${args.path}(版本 ${result.revisionId})。`, metadata: { path: args.path, revisionId: result.revisionId } };
107
+ },
108
+ };
109
+ export const todoTool = {
110
+ id: "todo",
111
+ label: "更新任务清单",
112
+ description: "维护当前任务的工作清单:开始前拆解步骤(in_progress 标记进行中),每完成一步立即更新状态。让用户随时看到进度。",
113
+ parameters: z.object({
114
+ todos: z.array(z.object({
115
+ content: z.string().min(1).max(200),
116
+ status: z.enum(["pending", "in_progress", "completed", "cancelled"]),
117
+ priority: z.enum(["high", "medium", "low"]).optional(),
118
+ })).max(50),
119
+ }),
120
+ permission: () => null, // always safe: pure projection, no side effects beyond the todo event
121
+ async execute(args, ctx) {
122
+ await ctx.setTodos(args.todos);
123
+ const done = args.todos.filter((todo) => todo.status === "completed").length;
124
+ return { title: `更新清单(${done}/${args.todos.length} 完成)`, output: `清单已更新:${done}/${args.todos.length} 项完成。`, metadata: { total: args.todos.length, completed: done } };
125
+ },
126
+ };
127
+ // python/py:模型常调用 python 而非 python3(多数镜像里是同一解释器符号链接)。
128
+ const defaultAllowedPrograms = ["node", "npm", "npx", "python3", "python", "py", "bash", "sh", "git", "ls", "cat", "grep", "find", "mkdir", "cp", "mv", "rm", "echo", "printf", "unzip", "tar", "curl", "wget", "env"];
129
+ function allowedPrograms() {
130
+ const configured = process.env.EXEC_ALLOWED_PROGRAMS?.trim();
131
+ if (!configured)
132
+ return new Set(defaultAllowedPrograms);
133
+ return new Set(configured.split(",").map((item) => item.trim()).filter(Boolean));
134
+ }
135
+ /** 模型有时把完整命令直接塞进 program 参数(deepseek 行为,实测出现
136
+ * "python3 --version"、"pip list 2>/dev/null | grep -i pptx" 等):
137
+ * - 普通命令:拆出程序名与内联参数(引号感知,保留引号内空格);
138
+ * - 管道/重定向/复合命令:交给 sh -c 整串执行,保留 shell 语义。
139
+ * 避免白名单整串匹配误拒、以及把带空格字符串当程序名执行导致 exit 127。
140
+ * permission 与 execute 共用同一归一化。 */
141
+ function splitProgram(program) {
142
+ const trimmed = program.trim();
143
+ if (/[|><;&]/.test(trimmed))
144
+ return { program: "sh", args: ["-c", trimmed] };
145
+ const tokens = [];
146
+ const pattern = /"([^"]*)"|'([^']*)'|(\S+)/g;
147
+ let match;
148
+ while ((match = pattern.exec(trimmed)) !== null) {
149
+ tokens.push(match[1] ?? match[2] ?? match[3]);
150
+ }
151
+ return { program: tokens[0] ?? "", args: tokens.slice(1) };
152
+ }
153
+ export const bashTool = {
154
+ id: "bash",
155
+ label: "在沙箱中执行命令",
156
+ description: "在当前 Workspace 的快照中执行一条命令(隔离沙箱)。程序必须在允许列表内;stdout/stderr 会返回。新生成的产物文件会自动出现在用户的产物面板(可预览/下载)——回复中不要自己编造下载链接(如 sandbox: 伪协议或沙箱路径),引用产物时使用工具结果里给出的真实 URL。",
157
+ parameters: z.object({
158
+ program: z.string().min(1).max(64),
159
+ args: z.array(z.string().max(512)).max(32).optional(),
160
+ cwd: z.string().min(1).max(512).optional(),
161
+ env: z.record(z.string(), z.string().max(2048)).optional(),
162
+ }),
163
+ permission: (args) => {
164
+ const { program, args: inlineArgs } = splitProgram(args.program);
165
+ const allArgs = [...inlineArgs, ...(args.args ?? [])];
166
+ const command = [program, ...allArgs].join(" ");
167
+ return { permission: "bash", patterns: [command], always: [command, `${program} *`], metadata: { command } };
168
+ },
169
+ executionMode: "sequential",
170
+ async execute(args, ctx) {
171
+ const { program, args: inlineArgs } = splitProgram(args.program);
172
+ const allArgs = [...inlineArgs, ...(args.args ?? [])];
173
+ if (!allowedPrograms().has(program))
174
+ throw new Error(`程序 "${program}" 不在允许列表`);
175
+ const snapshot = await ctx.buildSnapshot();
176
+ const result = await ctx.runSandbox({
177
+ toolCallId: ctx.toolCallId ?? `fwcall_${Date.now()}`,
178
+ command: { program, args: allArgs, ...(args.cwd ? { cwd: args.cwd } : {}), ...(args.env ? { env: args.env } : {}) },
179
+ snapshot,
180
+ });
181
+ for (const artifact of result.artifacts) {
182
+ if (artifact.workspaceContent !== undefined) {
183
+ const written = await ctx.workspace.write({
184
+ path: artifact.path,
185
+ content: artifact.workspaceContent,
186
+ author: "agent",
187
+ summary: `同步沙箱产物 ${artifact.path}`,
188
+ });
189
+ if (written)
190
+ await ctx.emitFileEdited({ path: artifact.path, revisionId: written.revisionId, diff: written.diff });
191
+ }
192
+ await ctx.emitArtifact({
193
+ artifactId: `art_${Date.now()}_${artifact.path.replace(/[^a-zA-Z0-9]/g, "_")}`,
194
+ path: artifact.path,
195
+ bytes: artifact.bytes,
196
+ contentType: artifact.contentType,
197
+ downloadUrl: artifact.downloadUrl,
198
+ ...(artifact.previewUrl ? { previewUrl: artifact.previewUrl } : {}),
199
+ });
200
+ }
201
+ const artifactLine = result.artifacts.length
202
+ ? `\n已交付产物(已自动出现在用户的产物面板,用户可直接预览/下载;回复中不要编造下载链接,如需引用请使用下列真实 URL,不要使用 sandbox:/ 等伪协议):${result.artifacts
203
+ .map((item) => `${item.path}(${item.bytes} B,下载 ${item.downloadUrl}${item.previewUrl ? `,预览 ${item.previewUrl}` : ""})`)
204
+ .join("、")}`
205
+ : "";
206
+ // 沙箱请求失败(连接/认证/配置)时透出真实原因,而不是只有"退出码 1 无输出"。
207
+ const errorLine = result.errorMessage ? `\n沙箱错误:${result.errorMessage}` : "";
208
+ const output = [`$ ${[program, ...allArgs].join(" ")}`, `退出码 ${result.exitCode ?? "未知"} · ${result.durationMs}ms`, result.outputText || "(无输出)"].join("\n") + artifactLine + errorLine;
209
+ const outcome = result.outcome ?? (result.ok ? "succeeded" : "failed");
210
+ return {
211
+ title: `${program} ${outcome === "unknown" ? "待确认" : result.ok ? "完成" : "失败"}`,
212
+ output,
213
+ metadata: { outcome, exitCode: result.exitCode, durationMs: result.durationMs, artifacts: result.artifacts.map((item) => ({ path: item.path, bytes: item.bytes, downloadUrl: item.downloadUrl, ...(item.previewUrl ? { previewUrl: item.previewUrl } : {}) })) },
214
+ };
215
+ },
216
+ };
217
+ import { taskTool } from "../tools/task.js";
218
+ export const builtinTools = [readTool, globTool, grepTool, writeTool, editTool, todoTool, bashTool, qaCheckTool, taskTool];
219
+ //# sourceMappingURL=builtins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtins.js","sourceRoot":"","sources":["../../../src/core/tools/builtins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD;;eAEe;AAEf,MAAM,CAAC,MAAM,QAAQ,GAAY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UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE;SACjQ,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,136 @@
1
+ import type { PermissionEngine } from "../permission/engine.js";
2
+ /** Snapshot of a workspace handed to the sandbox: committed files + revision.
3
+ * Kept framework-local (was lib/sandbox-types) so the package owns its types. */
4
+ export type SandboxSnapshot = {
5
+ revisionId: string | null;
6
+ files: Array<{
7
+ path: string;
8
+ content: string;
9
+ }>;
10
+ };
11
+ /** Workspace facade: the single seam between framework tools and the file
12
+ * backend. Products implement this (Mongo) or use the package's FS/JSONL
13
+ * reference implementation. */
14
+ export interface WorkspaceFiles {
15
+ list(): Promise<{
16
+ path: string;
17
+ bytes: number;
18
+ }[]>;
19
+ read(path: string): Promise<{
20
+ path: string;
21
+ content: string;
22
+ } | null>;
23
+ /** Direct write with revision + diff. Returns null when the path is
24
+ * rejected by workspace path validation. */
25
+ write(input: {
26
+ path: string;
27
+ content: string;
28
+ author: "agent";
29
+ summary: string;
30
+ }): Promise<{
31
+ revisionId: string;
32
+ diff: string;
33
+ } | null>;
34
+ /** Direct edit (exact oldText → newText, unique occurrence). */
35
+ edit(input: {
36
+ path: string;
37
+ oldText: string;
38
+ newText: string;
39
+ author: "agent";
40
+ summary: string;
41
+ }): Promise<{
42
+ revisionId: string;
43
+ diff: string;
44
+ } | {
45
+ error: string;
46
+ }>;
47
+ }
48
+ export type SandboxExecResult = {
49
+ ok: boolean;
50
+ /** Unknown means the sandbox may have applied a side effect, but its
51
+ * terminal outcome could not be established. Callers must not retry it. */
52
+ outcome?: "succeeded" | "failed" | "unknown";
53
+ exitCode: number | null;
54
+ outputText: string;
55
+ durationMs: number;
56
+ artifacts: {
57
+ path: string;
58
+ bytes: number;
59
+ contentType: string;
60
+ downloadUrl: string;
61
+ previewUrl?: string;
62
+ /** Text deliverables are copied into the task workspace after the
63
+ * sandbox succeeds, so later tools such as qa-check see the same files. */
64
+ workspaceContent?: string;
65
+ }[];
66
+ /** 沙箱请求失败(连接/认证/配置)时的真实原因;命令失败时为 null。 */
67
+ errorMessage?: string | null;
68
+ };
69
+ export type SandboxExecInput = {
70
+ toolCallId: string;
71
+ command: {
72
+ program: string;
73
+ args: string[];
74
+ cwd?: string;
75
+ env?: Record<string, string>;
76
+ };
77
+ snapshot: SandboxSnapshot;
78
+ /** Streams raw sandbox output back (runner forwards it as tool metadata). */
79
+ onOutput?: (chunk: string) => void;
80
+ };
81
+ export interface ToolContext {
82
+ sessionId: string;
83
+ userId: string;
84
+ workspaceId: string;
85
+ agent: string;
86
+ /** Stable PI tool-call id for the current invocation. */
87
+ toolCallId?: string;
88
+ abort: AbortSignal;
89
+ /** Permission escalation from inside a tool (rare; prefer the declarative
90
+ * `permission` field on ToolDef, which the runner evaluates first). */
91
+ ask: PermissionEngine["ask"];
92
+ workspace: WorkspaceFiles;
93
+ buildSnapshot(): Promise<SandboxSnapshot>;
94
+ runSandbox(input: SandboxExecInput): Promise<SandboxExecResult>;
95
+ /** Updates the live todo projection; emits todo.updated. */
96
+ setTodos(todos: {
97
+ content: string;
98
+ status: "pending" | "in_progress" | "completed" | "cancelled";
99
+ priority?: "high" | "medium" | "low";
100
+ }[]): Promise<void>;
101
+ /** Emits file.edited after a direct write/edit lands. */
102
+ emitFileEdited(input: {
103
+ path: string;
104
+ revisionId: string;
105
+ diff: string;
106
+ }): Promise<void>;
107
+ /** Emits artifact.created for every sandbox deliverable. */
108
+ emitArtifact(input: {
109
+ artifactId: string;
110
+ path: string;
111
+ bytes: number;
112
+ contentType: string;
113
+ downloadUrl: string;
114
+ previewUrl?: string;
115
+ }): Promise<void>;
116
+ /** Spawns a subagent as a child session (spec §6.4), wired by the runner.
117
+ * Absent in contexts that can't nest (e.g. the JSONL demo without a
118
+ * subagent-capable runner). */
119
+ spawnSubagent?: (input: {
120
+ description: string;
121
+ prompt: string;
122
+ subagentType: string;
123
+ }) => Promise<{
124
+ childSessionId: string;
125
+ summary: string;
126
+ state: "completed" | "error";
127
+ }>;
128
+ /** Records a subtask part on the parent transcript (childSessionId link). */
129
+ emitSubtask?: (input: {
130
+ prompt: string;
131
+ description: string;
132
+ agent: string;
133
+ childSessionId: string;
134
+ }) => Promise<void>;
135
+ }
136
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/core/tools/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;kFACkF;AAClF,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjD,CAAC;AAEF;;gCAEgC;AAChC,MAAM,WAAW,cAAc;IAC7B,IAAI,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC,CAAC;IACnD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACtE;iDAC6C;IAC7C,KAAK,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC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K,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvJ;;oCAEgC;IAChC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAA;KAAE,CAAC,CAAC;IAC7K,6EAA6E;IAC7E,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxH"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/core/tools/context.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import type { z } from "zod";
2
+ import type { ToolContext } from "../tools/context.js";
3
+ /** Framework tool definition (spec §7.1). The permission mapping is
4
+ * declarative: the runner evaluates it in beforeToolCall (the single choke
5
+ * point, spec §5.4) before execute() ever runs. */
6
+ export type ToolDef<TSchema extends z.ZodType = z.ZodType<any>> = {
7
+ id: string;
8
+ label: string;
9
+ description: string;
10
+ parameters: TSchema;
11
+ /** Maps validated args to the permission request. Return null to skip the
12
+ * permission check entirely (e.g. todo, which is always safe). */
13
+ permission: (args: z.output<TSchema>) => {
14
+ permission: string;
15
+ patterns: string[];
16
+ always?: string[];
17
+ metadata?: unknown;
18
+ } | null;
19
+ execute(args: z.output<TSchema>, ctx: ToolContext): Promise<{
20
+ title: string;
21
+ output: string;
22
+ metadata?: Record<string, unknown>;
23
+ }>;
24
+ /** Sequential tools never run concurrently with other calls (PI executionMode). */
25
+ executionMode?: "sequential" | "parallel";
26
+ };
27
+ //# sourceMappingURL=def.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"def.d.ts","sourceRoot":"","sources":["../../../src/core/tools/def.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;oDAEoD;AAEpD,MAAM,MAAM,OAAO,CAAC,OAAO,SAAS,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI;IAChE,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB;uEACmE;IACnE,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAClI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IACnI,mFAAmF;IACnF,aAAa,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;CAC3C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=def.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"def.js","sourceRoot":"","sources":["../../../src/core/tools/def.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ import type { ToolDef } from "./def.js";
3
+ export declare const qaCheckResultSchema: z.ZodObject<{
4
+ version: z.ZodLiteral<"v1">;
5
+ status: z.ZodEnum<{
6
+ failed: "failed";
7
+ passed: "passed";
8
+ }>;
9
+ checks: z.ZodArray<z.ZodObject<{
10
+ id: z.ZodEnum<{
11
+ html_loads: "html_loads";
12
+ metrics_present: "metrics_present";
13
+ desktop_viewport: "desktop_viewport";
14
+ mobile_viewport: "mobile_viewport";
15
+ }>;
16
+ status: z.ZodEnum<{
17
+ failed: "failed";
18
+ passed: "passed";
19
+ }>;
20
+ message: z.ZodString;
21
+ }, z.core.$strip>>;
22
+ viewports: z.ZodArray<z.ZodObject<{
23
+ width: z.ZodNumber;
24
+ height: z.ZodNumber;
25
+ overflow: z.ZodBoolean;
26
+ }, z.core.$strip>>;
27
+ }, z.core.$strip>;
28
+ export type QaCheckResult = z.infer<typeof qaCheckResultSchema>;
29
+ export declare const qaCheckTool: ToolDef;
30
+ //# sourceMappingURL=qa-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qa-check.d.ts","sourceRoot":"","sources":["../../../src/core/tools/qa-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;iBAK9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAmBhE,eAAO,MAAM,WAAW,EAAE,OA4BzB,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { z } from "zod";
2
+ export const qaCheckResultSchema = z.object({
3
+ version: z.literal("v1"),
4
+ status: z.enum(["passed", "failed"]),
5
+ checks: z.array(z.object({ id: z.enum(["html_loads", "metrics_present", "desktop_viewport", "mobile_viewport"]), status: z.enum(["passed", "failed"]), message: z.string() })),
6
+ viewports: z.array(z.object({ width: z.number().int().positive(), height: z.number().int().positive(), overflow: z.boolean() })),
7
+ });
8
+ const qaCheckInputSchema = z.object({
9
+ entryPath: z.string().trim().min(1).max(512).default("index.html"),
10
+ requiredText: z.array(z.string().trim().min(1).max(120)).max(20).default([]),
11
+ });
12
+ function hasViewportMeta(html) {
13
+ return /<meta\s+[^>]*name=["']viewport["'][^>]*>/i.test(html) || /<meta\s+[^>]*content=["'][^"']*width=device-width/i.test(html);
14
+ }
15
+ function hasResponsiveStyles(styles) {
16
+ return /@media\s*\(/i.test(styles) || /\b(?:display\s*:\s*(?:grid|flex)|max-width\s*:|clamp\s*\()/i.test(styles);
17
+ }
18
+ function hasFixedOverflowRisk(styles) {
19
+ return /(?:width|min-width)\s*:\s*(?:[5-9]\d{2}|\d{4,})px/i.test(styles) && !/max-width\s*:\s*100%/i.test(styles);
20
+ }
21
+ export const qaCheckTool = {
22
+ id: "qa-check",
23
+ label: "质量检查",
24
+ description: "检查当前 Workspace 中的 web_app:HTML 是否可加载、核心内容是否存在、桌面和移动视口是否有明显布局风险。返回稳定的 v1 JSON;失败时请先修复再继续交付。",
25
+ parameters: qaCheckInputSchema,
26
+ permission: () => null,
27
+ async execute(args, ctx) {
28
+ const entry = await ctx.workspace.read(args.entryPath);
29
+ const styles = (await Promise.all((await ctx.workspace.list()).filter((file) => file.path.endsWith(".css")).slice(0, 20).map((file) => ctx.workspace.read(file.path)))).filter((file) => Boolean(file)).map((file) => file.content).join("\n");
30
+ const html = entry?.content ?? "";
31
+ const htmlLoads = Boolean(entry && /<html\b/i.test(html) && /<body\b/i.test(html));
32
+ const missingText = args.requiredText.filter((text) => !html.includes(text));
33
+ const responsive = hasViewportMeta(html) && hasResponsiveStyles(styles);
34
+ const overflowRisk = hasFixedOverflowRisk(styles);
35
+ const checks = [
36
+ { id: "html_loads", status: htmlLoads ? "passed" : "failed", message: htmlLoads ? `${args.entryPath} 可加载` : `${args.entryPath} 缺少有效 html/body` },
37
+ { id: "metrics_present", status: missingText.length === 0 ? "passed" : "failed", message: missingText.length ? `缺少核心内容:${missingText.join(", ")}` : "核心内容已存在" },
38
+ { id: "desktop_viewport", status: overflowRisk ? "failed" : "passed", message: overflowRisk ? "样式存在固定宽度溢出风险" : "桌面视口无明显固定宽度风险" },
39
+ { id: "mobile_viewport", status: responsive && !overflowRisk ? "passed" : "failed", message: !hasViewportMeta(html) ? "缺少移动端 viewport meta" : !hasResponsiveStyles(styles) ? "缺少响应式样式" : overflowRisk ? "移动视口存在固定宽度溢出风险" : "移动视口具备基础响应式约束" },
40
+ ];
41
+ const result = {
42
+ version: "v1",
43
+ status: checks.every((check) => check.status === "passed") ? "passed" : "failed",
44
+ checks,
45
+ viewports: [{ width: 1280, height: 800, overflow: overflowRisk }, { width: 390, height: 844, overflow: !responsive || overflowRisk }],
46
+ };
47
+ return { title: `质量检查:${result.status === "passed" ? "通过" : "需要修复"}`, output: JSON.stringify(result, null, 2), metadata: { qaCheck: result } };
48
+ },
49
+ };
50
+ //# sourceMappingURL=qa-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qa-check.js","sourceRoot":"","sources":["../../../src/core/tools/qa-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;IACxB,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACpC,MAAM,EAAE,CAAC,CAAC,KAA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C,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,eAAe,EAAE;SAC7O,CAAC;QACF,MAAM,MAAM,GAAkB;YAC5B,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;YAChF,MAAM;YACN,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,UAAU,IAAI,YAAY,EAAE,CAAC;SACtI,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,QAAQ,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;IACjJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { ToolDef } from "../tools/def.js";
2
+ /** task tool (spec §6.4): spawns a subagent as a child session. Depth is
3
+ * capped, the child inherits the parent workspace + a permission ruleset
4
+ * merging parent session rules and the subagent preset, and the child runs
5
+ * to completion within this tool call. The rendered <task> result goes back
6
+ * to the parent model; a subtask part is recorded in the parent transcript. */
7
+ export declare const taskTool: ToolDef;
8
+ //# sourceMappingURL=task.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../../src/core/tools/task.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;;gFAIgF;AAChF,eAAO,MAAM,QAAQ,EAAE,OAyBtB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { z } from "zod";
2
+ /** task tool (spec §6.4): spawns a subagent as a child session. Depth is
3
+ * capped, the child inherits the parent workspace + a permission ruleset
4
+ * merging parent session rules and the subagent preset, and the child runs
5
+ * to completion within this tool call. The rendered <task> result goes back
6
+ * to the parent model; a subtask part is recorded in the parent transcript. */
7
+ export const taskTool = {
8
+ id: "task",
9
+ label: "派生子代理",
10
+ description: "把一个独立的子任务交给子代理在新会话中完成。用于并行探索(explore)或隔离的通用子任务(general)。子代理有自己的上下文;你只收到它的最终结论。available subagents 见系统提示或 registry。",
11
+ parameters: z.object({
12
+ description: z.string().min(3).max(60),
13
+ prompt: z.string().min(1).max(8 * 1024),
14
+ subagent_type: z.string().min(1).max(64),
15
+ }),
16
+ permission: (args) => ({ permission: "task", patterns: [args.subagent_type], always: ["*"], metadata: { subagent: args.subagent_type, description: args.description } }),
17
+ executionMode: "sequential",
18
+ async execute(args, ctx) {
19
+ if (!ctx.spawnSubagent)
20
+ throw new Error("当前环境不支持子代理");
21
+ const result = await ctx.spawnSubagent({
22
+ description: args.description,
23
+ prompt: args.prompt,
24
+ subagentType: args.subagent_type,
25
+ });
26
+ return {
27
+ title: `子代理 ${args.subagent_type}:${args.description}`,
28
+ output: result.summary,
29
+ metadata: { childSessionId: result.childSessionId, subagent: args.subagent_type, state: result.state },
30
+ };
31
+ },
32
+ };
33
+ //# sourceMappingURL=task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.js","sourceRoot":"","sources":["../../../src/core/tools/task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;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AQ,EAAE,EAAE,cAAc,EAAE,MAAM,CAAC,cAAc,EAAE,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE;SACvG,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,38 @@
1
+ /** @zmzai/agent-framework — PI-based agent framework (OpenCode-style).
2
+ * Storage/backend-agnostic: sessions, permissions, tools, runner, events.
3
+ * Assemble with createServer() (or wire SessionRunner directly). */
4
+ export type { MessageInfo, MessageWithParts, Part, QueuedPrompt, SessionInfo, SessionStatus, ModelRef, ToolState } from "./core/session/types.js";
5
+ export type { SessionStore } from "./core/session/store.js";
6
+ export { newSessionId, newMessageId, newPartId, newPermissionRequestId, newEventId } from "./core/session/ids.js";
7
+ export { createJsonlSessionStore } from "./core/session/jsonl-store.js";
8
+ export type { FrameworkEvent, FrameworkEventType, PersistedFrameworkEvent, TodoItem } from "./core/events/manifest.js";
9
+ export { frameworkEventSchemas, parseFrameworkEvent } from "./core/events/manifest.js";
10
+ export type { EventLog, SubscribeOptions } from "./core/events/bus.js";
11
+ export { createMemoryEventLog, subscribeEventLog, notifyEventLogListeners } from "./core/events/bus.js";
12
+ export type { Action, Rule, Ruleset, PermissionConfig } from "./core/permission/ruleset.js";
13
+ export { rulesetFromConfig, evaluateRules, wildcardMatch, PERMISSIONS } from "./core/permission/ruleset.js";
14
+ export type { Reply, PermissionRequest } from "./core/permission/engine.js";
15
+ export { PermissionEngine, RejectedError } from "./core/permission/engine.js";
16
+ export type { AgentInfo, AgentDefinition } from "./core/agent/registry.js";
17
+ export { AgentRegistry, builtinAgents, builtinDefaults } from "./core/agent/registry.js";
18
+ export { loadCustomAgents } from "./core/agent/loader.js";
19
+ export type { AgentResolver, ResolvedAgent } from "./core/agent/resolver.js";
20
+ export { parseAgentPlugin, parsePluginManifest, parsePluginMcp } from "./core/agent/plugin.js";
21
+ export type { ParsedAgentPlugin, PluginFileSystem, PluginManifest, PluginMcpServer, PluginSkill } from "./core/agent/plugin.js";
22
+ export type { ToolDef } from "./core/tools/def.js";
23
+ export type { ToolContext, WorkspaceFiles, SandboxSnapshot, SandboxExecResult, SandboxExecInput } from "./core/tools/context.js";
24
+ export { adaptTool, permissionForCall } from "./core/tools/adapter.js";
25
+ export { builtinTools, readTool, globTool, grepTool, writeTool, editTool, todoTool, bashTool } from "./core/tools/builtins.js";
26
+ export { taskTool } from "./core/tools/task.js";
27
+ export { SessionRunner, createFrameworkSession, isSessionActive, type RunnerDeps } from "./core/runtime/runner.js";
28
+ export { PartProjector, serializeEmit } from "./core/runtime/pi-bridge.js";
29
+ export { buildCompactionTransform, createCompactionTransform, streamOneText } from "./core/runtime/compaction.js";
30
+ export { startLeaseRecovery, reclaimExpiredLeases, finalizeInterruptedRun, type LeaseRecoveryStore } from "./core/runtime/lease-recovery.js";
31
+ export type { ModelProvider, SandboxExecutor, LeaseStore } from "./adapters/index.js";
32
+ export { noopSandboxExecutor, leaseDurationMs } from "./adapters/index.js";
33
+ export { qaCheckResultSchema, qaCheckTool, type QaCheckResult } from "./core/tools/qa-check.js";
34
+ export { createFsWorkspaceFiles } from "./adapters/fs-workspace.js";
35
+ export { createOpenAiModelProvider } from "./adapters/openai-provider.js";
36
+ export { createSubprocessSandbox } from "./adapters/subprocess-sandbox.js";
37
+ export { createServer, type FrameworkDeps, type AgentFramework } from "./server/create-server.js";
38
+ //# sourceMappingURL=index.d.ts.map