@nebutra/agent-runtime 0.2.1 → 2.0.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 (114) hide show
  1. package/LICENSE +21 -676
  2. package/README.md +33 -10
  3. package/dist/adapters/index.d.ts +24 -5
  4. package/dist/adapters/index.js +27 -0
  5. package/dist/adapters/index.js.map +1 -1
  6. package/dist/{chunk-KCNN4QUQ.js → chunk-5UGIUYJR.js} +4 -4
  7. package/dist/chunk-7ELA4SWE.js +73 -0
  8. package/dist/chunk-7ELA4SWE.js.map +1 -0
  9. package/dist/chunk-Q62VKHIT.js +178 -0
  10. package/dist/chunk-Q62VKHIT.js.map +1 -0
  11. package/dist/chunk-VXILZAXK.js +541 -0
  12. package/dist/chunk-VXILZAXK.js.map +1 -0
  13. package/dist/command-exec.d.ts +45 -0
  14. package/dist/command-exec.js +15 -0
  15. package/dist/command-exec.js.map +1 -0
  16. package/dist/index.d.ts +3 -2
  17. package/dist/index.js +81 -28
  18. package/dist/index.js.map +1 -1
  19. package/dist/orchestration.d.ts +42 -1
  20. package/dist/orchestration.js +7 -3
  21. package/dist/pulsar.js +2 -2
  22. package/dist/sandbox-DfcRttXt.d.ts +219 -0
  23. package/dist/sandbox.d.ts +2 -64
  24. package/dist/sandbox.js +25 -3
  25. package/package.json +81 -30
  26. package/.turbo/turbo-build.log +0 -130
  27. package/.turbo/turbo-test.log +0 -47
  28. package/.turbo/turbo-typecheck.log +0 -4
  29. package/CHANGELOG.md +0 -250
  30. package/dist/chunk-MUF7ZZTO.js +0 -57
  31. package/dist/chunk-MUF7ZZTO.js.map +0 -1
  32. package/dist/chunk-MX2WL43P.js +0 -90
  33. package/dist/chunk-MX2WL43P.js.map +0 -1
  34. package/examples/pulsar-quickstart.ts +0 -35
  35. package/examples/resume-branch.ts +0 -45
  36. package/examples/subagent-fanout.ts +0 -20
  37. package/src/adapters/dispatcher-sse.test.ts +0 -218
  38. package/src/adapters/dispatcher-sse.ts +0 -222
  39. package/src/adapters/index.ts +0 -18
  40. package/src/adapters/mcp-catalog.test.ts +0 -213
  41. package/src/adapters/mcp-catalog.ts +0 -188
  42. package/src/adapters/prisma-rollout.test.ts +0 -153
  43. package/src/adapters/prisma-rollout.ts +0 -104
  44. package/src/agent-runtime.test.ts +0 -176
  45. package/src/artifact-stream.test.ts +0 -330
  46. package/src/artifact-stream.ts +0 -453
  47. package/src/channel-gateway.test.ts +0 -432
  48. package/src/channel-gateway.ts +0 -357
  49. package/src/cli.ts +0 -49
  50. package/src/code-review.test.ts +0 -501
  51. package/src/code-review.ts +0 -495
  52. package/src/command-suggestions.test.ts +0 -251
  53. package/src/command-suggestions.ts +0 -338
  54. package/src/commands.test.ts +0 -184
  55. package/src/commands.ts +0 -140
  56. package/src/commit-message.test.ts +0 -249
  57. package/src/commit-message.ts +0 -180
  58. package/src/context-compaction.test.ts +0 -522
  59. package/src/context-compaction.ts +0 -438
  60. package/src/definitions.test.ts +0 -78
  61. package/src/definitions.ts +0 -190
  62. package/src/deployment-status.test.ts +0 -215
  63. package/src/deployment-status.ts +0 -227
  64. package/src/design-context.test.ts +0 -195
  65. package/src/design-context.ts +0 -198
  66. package/src/dispatcher.test.ts +0 -234
  67. package/src/dispatcher.ts +0 -189
  68. package/src/durable-turn.test.ts +0 -209
  69. package/src/durable-turn.ts +0 -135
  70. package/src/edit-planner.test.ts +0 -204
  71. package/src/edit-planner.ts +0 -325
  72. package/src/fuzzy-match.test.ts +0 -311
  73. package/src/fuzzy-match.ts +0 -444
  74. package/src/hook-pipeline.test.ts +0 -279
  75. package/src/hook-pipeline.ts +0 -373
  76. package/src/inbound-admission.test.ts +0 -394
  77. package/src/inbound-admission.ts +0 -246
  78. package/src/index.ts +0 -49
  79. package/src/loop.test.ts +0 -161
  80. package/src/loop.ts +0 -211
  81. package/src/mcp-bridge.test.ts +0 -165
  82. package/src/mcp-bridge.ts +0 -81
  83. package/src/memory-provider.test.ts +0 -232
  84. package/src/memory-provider.ts +0 -257
  85. package/src/model.ts +0 -168
  86. package/src/orchestration.test.ts +0 -53
  87. package/src/orchestration.ts +0 -146
  88. package/src/permission-ruleset.test.ts +0 -301
  89. package/src/permission-ruleset.ts +0 -1
  90. package/src/policy.ts +0 -151
  91. package/src/project-repo.test.ts +0 -232
  92. package/src/project-repo.ts +0 -311
  93. package/src/protocol.ts +0 -159
  94. package/src/pulsar.test.ts +0 -156
  95. package/src/pulsar.ts +0 -322
  96. package/src/rollout-store-persistent.test.ts +0 -217
  97. package/src/rollout-store-persistent.ts +0 -166
  98. package/src/rollout.ts +0 -150
  99. package/src/sandbox.ts +0 -113
  100. package/src/session-share.test.ts +0 -360
  101. package/src/session-share.ts +0 -310
  102. package/src/skill-distillation.test.ts +0 -177
  103. package/src/skill-distillation.ts +0 -369
  104. package/src/skills.test.ts +0 -277
  105. package/src/skills.ts +0 -277
  106. package/src/subagents.test.ts +0 -290
  107. package/src/subagents.ts +0 -332
  108. package/src/tools.test.ts +0 -12
  109. package/src/tools.ts +0 -129
  110. package/src/workbench.test.ts +0 -0
  111. package/src/workbench.ts +0 -0
  112. package/tsconfig.json +0 -12
  113. package/tsup.config.ts +0 -36
  114. /package/dist/{chunk-KCNN4QUQ.js.map → chunk-5UGIUYJR.js.map} +0 -0
package/src/tools.ts DELETED
@@ -1,129 +0,0 @@
1
- /**
2
- * Tool / MCP abstraction (WRAP — capability #9).
3
- *
4
- * Faithful re-expression of the upstream uniform tool model: one
5
- * `ToolDefinition` interface, JSON-schema in/out, a deferred-load flag, and
6
- * MCP-as-adapter behind the same interface (MCP tools and native tools are
7
- * indistinguishable at dispatch). Activates `@nebutra/mcp` primitives rather
8
- * than re-porting them.
9
- */
10
-
11
- import type { z } from "zod";
12
-
13
- /** A tool definition — pure data; transport-agnostic. */
14
- export interface ToolDefinition<I = unknown, O = unknown> {
15
- readonly name: string;
16
- readonly description: string;
17
- readonly inputSchema: z.ZodType<I>;
18
- readonly outputSchema?: z.ZodType<O>;
19
- /**
20
- * When true, the full schema is withheld until a `tool_search` discovery
21
- * step lazily loads it (parity with the upstream deferred-tool pattern).
22
- */
23
- readonly deferLoading?: boolean;
24
- }
25
-
26
- /** Source provenance — native vs. adapted from an MCP server. */
27
- export type ToolOrigin =
28
- | { readonly kind: "native" }
29
- | { readonly kind: "mcp"; readonly server: string };
30
-
31
- export interface RegisteredTool {
32
- readonly definition: ToolDefinition;
33
- readonly origin: ToolOrigin;
34
- }
35
-
36
- /** A tool invocation routed through the registry. */
37
- export interface ToolDispatchContext {
38
- /** Mandatory tenant scope — every dispatch is tenant-bound. */
39
- readonly tenantId: string;
40
- readonly threadId: string;
41
- }
42
-
43
- export type ToolHandler<I = unknown, O = unknown> = (
44
- input: I,
45
- ctx: ToolDispatchContext,
46
- ) => Promise<O>;
47
-
48
- /** Pre/post dispatch hooks (parity with upstream orchestrator hooks). */
49
- export interface ToolHooks {
50
- readonly preToolUse?: (name: string, input: unknown, ctx: ToolDispatchContext) => Promise<void>;
51
- readonly postToolUse?: (name: string, output: unknown, ctx: ToolDispatchContext) => Promise<void>;
52
- }
53
-
54
- /**
55
- * runtime registry -> router -> orchestrator pipeline. MCP tools register via
56
- * {@link adaptMcpTool} and are dispatched identically to native tools.
57
- */
58
- export class RuntimeToolRegistry {
59
- readonly #tools = new Map<string, { reg: RegisteredTool; handler: ToolHandler }>();
60
- readonly #hooks: ToolHooks;
61
-
62
- constructor(hooks: ToolHooks = {}) {
63
- this.#hooks = hooks;
64
- }
65
-
66
- register<I, O>(
67
- definition: ToolDefinition<I, O>,
68
- handler: ToolHandler<I, O>,
69
- origin: ToolOrigin = { kind: "native" },
70
- ): void {
71
- if (this.#tools.has(definition.name)) {
72
- throw new Error(`Tool already registered: ${definition.name}`);
73
- }
74
- this.#tools.set(definition.name, {
75
- reg: { definition: definition as ToolDefinition, origin },
76
- handler: handler as ToolHandler,
77
- });
78
- }
79
-
80
- list(): readonly RegisteredTool[] {
81
- return [...this.#tools.values()].map((e) => e.reg);
82
- }
83
-
84
- async dispatch(name: string, rawInput: unknown, ctx: ToolDispatchContext): Promise<unknown> {
85
- const entry = this.#tools.get(name);
86
- if (!entry) throw new Error(`Unknown tool: ${name}`);
87
- const input = entry.reg.definition.inputSchema.parse(rawInput);
88
- await this.#hooks.preToolUse?.(name, input, ctx);
89
- const output = await entry.handler(input, ctx);
90
- const validated = entry.reg.definition.outputSchema
91
- ? entry.reg.definition.outputSchema.parse(output)
92
- : output;
93
- await this.#hooks.postToolUse?.(name, validated, ctx);
94
- return validated;
95
- }
96
- }
97
-
98
- /** @deprecated Use RuntimeToolRegistry for new code. */
99
- export { RuntimeToolRegistry as ToolRegistry };
100
-
101
- /** Minimal shape of an MCP client (satisfied by `@nebutra/mcp`'s `mcpClient`). */
102
- export interface McpClientLike {
103
- executeTool(
104
- name: string,
105
- args: unknown,
106
- ctx: { requestId: string; tenantId: string },
107
- ): Promise<unknown>;
108
- }
109
-
110
- /**
111
- * Adapt an external MCP tool into the uniform tool model. The resulting
112
- * handler delegates to the MCP client; callers cannot tell it apart from a
113
- * native tool.
114
- */
115
- export function adaptMcpTool(
116
- server: string,
117
- definition: ToolDefinition,
118
- client: McpClientLike,
119
- ): { definition: ToolDefinition; handler: ToolHandler; origin: ToolOrigin } {
120
- return {
121
- definition,
122
- origin: { kind: "mcp", server },
123
- handler: async (input, ctx) =>
124
- client.executeTool(definition.name, input, {
125
- requestId: globalThis.crypto?.randomUUID?.() ?? `${Date.now()}`,
126
- tenantId: ctx.tenantId,
127
- }),
128
- };
129
- }
Binary file
package/src/workbench.ts DELETED
Binary file
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "target": "esnext",
7
- "types": ["node"],
8
- "incremental": false
9
- },
10
- "include": ["src"],
11
- "exclude": ["node_modules", "dist"]
12
- }
package/tsup.config.ts DELETED
@@ -1,36 +0,0 @@
1
- import { defineConfig } from "tsup";
2
-
3
- export default defineConfig({
4
- entry: {
5
- index: "src/index.ts",
6
- "adapters/index": "src/adapters/index.ts",
7
- "adapters/dispatcher-sse": "src/adapters/dispatcher-sse.ts",
8
- "adapters/mcp-catalog": "src/adapters/mcp-catalog.ts",
9
- "adapters/prisma-rollout": "src/adapters/prisma-rollout.ts",
10
- commands: "src/commands.ts",
11
- cli: "src/cli.ts",
12
- definitions: "src/definitions.ts",
13
- dispatcher: "src/dispatcher.ts",
14
- "durable-turn": "src/durable-turn.ts",
15
- "hook-pipeline": "src/hook-pipeline.ts",
16
- loop: "src/loop.ts",
17
- "mcp-bridge": "src/mcp-bridge.ts",
18
- model: "src/model.ts",
19
- orchestration: "src/orchestration.ts",
20
- policy: "src/policy.ts",
21
- protocol: "src/protocol.ts",
22
- pulsar: "src/pulsar.ts",
23
- rollout: "src/rollout.ts",
24
- "rollout-store-persistent": "src/rollout-store-persistent.ts",
25
- sandbox: "src/sandbox.ts",
26
- skills: "src/skills.ts",
27
- subagents: "src/subagents.ts",
28
- tools: "src/tools.ts",
29
- },
30
- format: ["esm"],
31
- dts: true,
32
- clean: true,
33
- sourcemap: true,
34
- target: "es2022",
35
- external: ["@nebutra/execution-policy", "@nebutra/mcp"],
36
- });