@springbrand/agent-runtime 0.1.3-alpha.8 → 0.2.0-alpha.14

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 (50) hide show
  1. package/package.json +4 -3
  2. package/src/adapter/cloudflare/index.ts +1 -0
  3. package/src/adapter/cloudflare/sandbox/adapter.ts +4 -0
  4. package/src/adapter/cloudflare/subagent/definition.ts +60 -5
  5. package/src/adapter/cloudflare/universal-agent/hooks.ts +23 -1
  6. package/src/adapter/cloudflare/universal-agent/preparation.ts +36 -2
  7. package/src/adapter/cloudflare/universal-agent/tools.ts +9 -12
  8. package/src/adapter/cloudflare/workspace/git-fs.ts +178 -0
  9. package/src/adapter/cloudflare/workspace/version-control.ts +374 -0
  10. package/src/db/index.ts +4 -0
  11. package/src/db/runtime-event-outbox.repo.ts +34 -1
  12. package/src/db/schema.ts +42 -0
  13. package/src/db/submission-admission.repo.ts +127 -0
  14. package/src/db/submission.repo.ts +54 -3
  15. package/src/index.ts +5 -2
  16. package/src/kernel/bindings.ts +52 -0
  17. package/src/kernel/durable-lifecycle.ts +100 -0
  18. package/src/kernel/public-contracts.ts +11 -0
  19. package/src/kernel/receipts.ts +1 -0
  20. package/src/kernel/recoverable-chat-agent.ts +0 -19
  21. package/src/kernel/subagent-runtime.ts +137 -0
  22. package/src/kernel/submission-authority.ts +114 -0
  23. package/src/kernel/submission-lifecycle.ts +35 -10
  24. package/src/layers/context/budget/gate.ts +99 -0
  25. package/src/lib/prompt.ts +7 -3
  26. package/src/pi/message/projection.ts +2 -2
  27. package/src/pi/runtime-adapter/assembly.ts +4 -3
  28. package/src/pi/runtime-adapter/execution.ts +55 -16
  29. package/src/pi/runtime-adapter/index.ts +34 -0
  30. package/src/pi/runtime-adapter/models.ts +10 -1
  31. package/src/pi/runtime-adapter/recovery.ts +17 -17
  32. package/src/pi/runtime-adapter/transcript.ts +2 -2
  33. package/src/pi/tool/base.ts +113 -27
  34. package/src/pi/tool/compiler.ts +66 -6
  35. package/src/pi/tool/core-host.ts +50 -23
  36. package/src/pi/tool/core.ts +2 -23
  37. package/src/pi/tool/index.ts +1 -0
  38. package/src/pi/tool/mcp.ts +2 -2
  39. package/src/pi/tool/skill.ts +78 -3
  40. package/src/pi/tool/subagent.ts +142 -16
  41. package/src/pi/tool/workspace-revision.ts +64 -0
  42. package/src/pi/tool/workspace-sandbox.ts +4 -4
  43. package/src/pi/turn/tool-recovery.ts +7 -7
  44. package/src/runtime-agent-context.ts +1 -0
  45. package/src/runtime-agent.ts +8 -3
  46. package/src/runtime-assembler.ts +61 -9
  47. package/src/runtime-definition.ts +12 -0
  48. package/src/runtime.ts +485 -66
  49. package/src/tool-registry.ts +10 -1
  50. package/src/workspace-versioning.ts +46 -0
@@ -1,6 +1,8 @@
1
1
  import type { ExecutionLevel } from "./lib/execution-level";
2
2
  import type {
3
+ RuntimeCodeExecutionPort,
3
4
  RuntimeMemoryPort,
5
+ RuntimeSubagentPort,
4
6
  WorkspacePort,
5
7
  } from "./kernel/bindings";
6
8
  import type { RuntimeExtensionConfig } from "./kernel/extensions";
@@ -36,6 +38,11 @@ export interface ToolSpec {
36
38
  /** 一次装配声明的全部 Tool,键即模型可见的工具名。 */
37
39
  export type ToolRegistry = Record<string, ToolSpec>;
38
40
 
41
+ /** 延迟到最终 Tool Surface 完成后再创建 Code Mode 执行能力。 */
42
+ export interface RuntimeCodeExecutionFactory {
43
+ create(tools: ToolRegistry): RuntimeCodeExecutionPort;
44
+ }
45
+
39
46
  export function emptyToolRegistry(): ToolRegistry {
40
47
  return {};
41
48
  }
@@ -65,7 +72,7 @@ export function toolRegistryFromPiCandidates(
65
72
  for (const candidate of list) {
66
73
  const name = candidate.tool.name;
67
74
  if (!name.trim()) {
68
- throw new Error("Pi Tool name must not be empty");
75
+ throw new Error("SpringBrand Tool name must not be empty");
69
76
  }
70
77
  registry[name] = piCandidateToToolSpec(candidate);
71
78
  }
@@ -101,7 +108,9 @@ export function piCandidateToToolSpec(candidate: PiToolCandidate): ToolSpec {
101
108
  /** Kernel 绑定仍需要的执行后端;不出现在 Definition 公开类型里。 */
102
109
  export interface RuntimeToolBindings {
103
110
  readonly workspace?: WorkspacePort;
111
+ readonly codeExecution?: RuntimeCodeExecutionFactory;
104
112
  readonly memory?: RuntimeMemoryPort;
113
+ readonly subagents?: RuntimeSubagentPort;
105
114
  }
106
115
 
107
116
  /**
@@ -0,0 +1,46 @@
1
+ export type WorkspaceRevision = {
2
+ revision: string;
3
+ treeHash: string;
4
+ reason: string;
5
+ createdAt: number;
6
+ };
7
+
8
+ export type WorkspaceRevisionManifest = {
9
+ revision: string;
10
+ treeHash: string;
11
+ files: readonly {
12
+ path: string;
13
+ size: number;
14
+ }[];
15
+ };
16
+
17
+ export interface WorkspaceVersionPort {
18
+ current(): Promise<WorkspaceRevision | null>;
19
+ checkpoint(input: { reason: string }): Promise<{
20
+ revision: string | null;
21
+ treeHash: string | null;
22
+ changed: boolean;
23
+ }>;
24
+ list(input?: { limit?: number }): Promise<readonly WorkspaceRevision[]>;
25
+ manifest(revision: string): Promise<WorkspaceRevisionManifest>;
26
+ readFile(revision: string, path: string): Promise<Uint8Array>;
27
+ restore(input: { revision: string; reason: string }): Promise<{
28
+ revision: string;
29
+ treeHash: string;
30
+ }>;
31
+ }
32
+
33
+ /** Host-scoped restore action exposed to the Agent Runtime. */
34
+ export interface WorkspaceRevisionRestorePort {
35
+ restore(target: string): Promise<{
36
+ restoredFrom: string;
37
+ revision: string;
38
+ treeHash: string;
39
+ }>;
40
+ }
41
+
42
+ export class WorkspaceRevisionNotFoundError extends Error {
43
+ constructor() {
44
+ super("workspace_revision_not_found");
45
+ }
46
+ }