@nebutra/agent-runtime 0.2.0 → 0.2.2

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 (137) hide show
  1. package/LICENSE +21 -676
  2. package/README.md +2 -0
  3. package/dist/adapters/dispatcher-sse.js +1 -0
  4. package/dist/adapters/index.d.ts +24 -5
  5. package/dist/adapters/index.js +28 -0
  6. package/dist/adapters/index.js.map +1 -1
  7. package/dist/adapters/mcp-catalog.js +1 -0
  8. package/dist/adapters/prisma-rollout.js +1 -0
  9. package/dist/chunk-424PT5DM.js +23 -0
  10. package/dist/chunk-424PT5DM.js.map +1 -0
  11. package/dist/{chunk-NN7DATXA.js → chunk-4Y25ZTKI.js} +3 -3
  12. package/dist/chunk-4Y25ZTKI.js.map +1 -0
  13. package/dist/{chunk-BJBBR3QA.js → chunk-D4YAPLOW.js} +4 -4
  14. package/dist/chunk-D4YAPLOW.js.map +1 -0
  15. package/dist/{chunk-ZMYX5VBU.js → chunk-GQZKYWFT.js} +23 -7
  16. package/dist/chunk-GQZKYWFT.js.map +1 -0
  17. package/dist/chunk-KCNN4QUQ.js +255 -0
  18. package/dist/chunk-KCNN4QUQ.js.map +1 -0
  19. package/dist/{chunk-PGGWSUTM.js → chunk-NI4EDT4T.js} +2 -2
  20. package/dist/chunk-NI4EDT4T.js.map +1 -0
  21. package/dist/chunk-Q62VKHIT.js +178 -0
  22. package/dist/chunk-Q62VKHIT.js.map +1 -0
  23. package/dist/{chunk-MUF7ZZTO.js → chunk-R5HOSQUW.js} +2 -1
  24. package/dist/{chunk-MUF7ZZTO.js.map → chunk-R5HOSQUW.js.map} +1 -1
  25. package/dist/{chunk-5N4644PB.js → chunk-SD2ZJ7XG.js} +4 -4
  26. package/dist/cli.d.ts +2 -0
  27. package/dist/cli.js +52 -0
  28. package/dist/cli.js.map +1 -0
  29. package/dist/commands.js +1 -0
  30. package/dist/definitions.js +1 -0
  31. package/dist/dispatcher.js +1 -0
  32. package/dist/durable-turn.js +3 -2
  33. package/dist/hook-pipeline.js +1 -0
  34. package/dist/index.d.ts +8 -85
  35. package/dist/index.js +249 -134
  36. package/dist/index.js.map +1 -1
  37. package/dist/loop.d.ts +2 -2
  38. package/dist/loop.js +3 -2
  39. package/dist/mcp-bridge.d.ts +3 -3
  40. package/dist/mcp-bridge.js +3 -2
  41. package/dist/model.js +1 -0
  42. package/dist/orchestration.d.ts +84 -0
  43. package/dist/orchestration.js +16 -0
  44. package/dist/orchestration.js.map +1 -0
  45. package/dist/policy.js +1 -0
  46. package/dist/protocol.js +1 -0
  47. package/dist/pulsar.d.ts +78 -0
  48. package/dist/pulsar.js +17 -0
  49. package/dist/pulsar.js.map +1 -0
  50. package/dist/rollout-store-persistent.js +1 -0
  51. package/dist/rollout.js +1 -0
  52. package/dist/sandbox.js +2 -1
  53. package/dist/skills.js +2 -1
  54. package/dist/subagents.js +1 -0
  55. package/dist/tools.d.ts +4 -3
  56. package/dist/tools.js +5 -3
  57. package/package.json +84 -27
  58. package/.turbo/turbo-build.log +0 -115
  59. package/.turbo/turbo-test.log +0 -44
  60. package/.turbo/turbo-typecheck.log +0 -4
  61. package/CHANGELOG.md +0 -253
  62. package/dist/chunk-BJBBR3QA.js.map +0 -1
  63. package/dist/chunk-NN7DATXA.js.map +0 -1
  64. package/dist/chunk-PGGWSUTM.js.map +0 -1
  65. package/dist/chunk-ZMYX5VBU.js.map +0 -1
  66. package/src/adapters/dispatcher-sse.test.ts +0 -218
  67. package/src/adapters/dispatcher-sse.ts +0 -222
  68. package/src/adapters/index.ts +0 -18
  69. package/src/adapters/mcp-catalog.test.ts +0 -213
  70. package/src/adapters/mcp-catalog.ts +0 -188
  71. package/src/adapters/prisma-rollout.test.ts +0 -153
  72. package/src/adapters/prisma-rollout.ts +0 -104
  73. package/src/agent-runtime.test.ts +0 -176
  74. package/src/artifact-stream.test.ts +0 -330
  75. package/src/artifact-stream.ts +0 -453
  76. package/src/channel-gateway.test.ts +0 -432
  77. package/src/channel-gateway.ts +0 -357
  78. package/src/code-review.test.ts +0 -501
  79. package/src/code-review.ts +0 -495
  80. package/src/command-suggestions.test.ts +0 -251
  81. package/src/command-suggestions.ts +0 -338
  82. package/src/commands.test.ts +0 -184
  83. package/src/commands.ts +0 -140
  84. package/src/commit-message.test.ts +0 -249
  85. package/src/commit-message.ts +0 -180
  86. package/src/context-compaction.test.ts +0 -522
  87. package/src/context-compaction.ts +0 -434
  88. package/src/definitions.test.ts +0 -78
  89. package/src/definitions.ts +0 -190
  90. package/src/deployment-status.test.ts +0 -215
  91. package/src/deployment-status.ts +0 -227
  92. package/src/design-context.test.ts +0 -195
  93. package/src/design-context.ts +0 -198
  94. package/src/dispatcher.test.ts +0 -234
  95. package/src/dispatcher.ts +0 -189
  96. package/src/durable-turn.test.ts +0 -209
  97. package/src/durable-turn.ts +0 -135
  98. package/src/edit-planner.test.ts +0 -204
  99. package/src/edit-planner.ts +0 -325
  100. package/src/fuzzy-match.test.ts +0 -311
  101. package/src/fuzzy-match.ts +0 -444
  102. package/src/hook-pipeline.test.ts +0 -279
  103. package/src/hook-pipeline.ts +0 -373
  104. package/src/inbound-admission.test.ts +0 -394
  105. package/src/inbound-admission.ts +0 -246
  106. package/src/index.ts +0 -47
  107. package/src/loop.test.ts +0 -161
  108. package/src/loop.ts +0 -211
  109. package/src/mcp-bridge.test.ts +0 -165
  110. package/src/mcp-bridge.ts +0 -76
  111. package/src/memory-provider.test.ts +0 -232
  112. package/src/memory-provider.ts +0 -257
  113. package/src/model.ts +0 -168
  114. package/src/permission-ruleset.test.ts +0 -301
  115. package/src/permission-ruleset.ts +0 -200
  116. package/src/policy.ts +0 -151
  117. package/src/project-repo.test.ts +0 -232
  118. package/src/project-repo.ts +0 -311
  119. package/src/protocol.ts +0 -159
  120. package/src/rollout-store-persistent.test.ts +0 -217
  121. package/src/rollout-store-persistent.ts +0 -166
  122. package/src/rollout.ts +0 -150
  123. package/src/sandbox.ts +0 -113
  124. package/src/session-share.test.ts +0 -360
  125. package/src/session-share.ts +0 -310
  126. package/src/skill-distillation.test.ts +0 -177
  127. package/src/skill-distillation.ts +0 -369
  128. package/src/skills.test.ts +0 -277
  129. package/src/skills.ts +0 -255
  130. package/src/subagents.test.ts +0 -290
  131. package/src/subagents.ts +0 -332
  132. package/src/tools.ts +0 -126
  133. package/src/workbench.test.ts +0 -0
  134. package/src/workbench.ts +0 -0
  135. package/tsconfig.json +0 -12
  136. package/tsup.config.ts +0 -33
  137. /package/dist/{chunk-5N4644PB.js.map → chunk-SD2ZJ7XG.js.map} +0 -0
package/src/tools.ts DELETED
@@ -1,126 +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
- * registry -> router -> orchestrator pipeline. MCP tools register via
56
- * {@link adaptMcpTool} and are dispatched identically to native tools.
57
- */
58
- export class ToolRegistry {
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
- /** Minimal shape of an MCP client (satisfied by `@nebutra/mcp`'s `mcpClient`). */
99
- export interface McpClientLike {
100
- executeTool(
101
- name: string,
102
- args: unknown,
103
- ctx: { requestId: string; tenantId: string },
104
- ): Promise<unknown>;
105
- }
106
-
107
- /**
108
- * Adapt an external MCP tool into the uniform tool model. The resulting
109
- * handler delegates to the MCP client; callers cannot tell it apart from a
110
- * native tool.
111
- */
112
- export function adaptMcpTool(
113
- server: string,
114
- definition: ToolDefinition,
115
- client: McpClientLike,
116
- ): { definition: ToolDefinition; handler: ToolHandler; origin: ToolOrigin } {
117
- return {
118
- definition,
119
- origin: { kind: "mcp", server },
120
- handler: async (input, ctx) =>
121
- client.executeTool(definition.name, input, {
122
- requestId: globalThis.crypto?.randomUUID?.() ?? `${Date.now()}`,
123
- tenantId: ctx.tenantId,
124
- }),
125
- };
126
- }
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,33 +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
- definitions: "src/definitions.ts",
12
- dispatcher: "src/dispatcher.ts",
13
- "durable-turn": "src/durable-turn.ts",
14
- "hook-pipeline": "src/hook-pipeline.ts",
15
- loop: "src/loop.ts",
16
- "mcp-bridge": "src/mcp-bridge.ts",
17
- model: "src/model.ts",
18
- policy: "src/policy.ts",
19
- protocol: "src/protocol.ts",
20
- rollout: "src/rollout.ts",
21
- "rollout-store-persistent": "src/rollout-store-persistent.ts",
22
- sandbox: "src/sandbox.ts",
23
- skills: "src/skills.ts",
24
- subagents: "src/subagents.ts",
25
- tools: "src/tools.ts",
26
- },
27
- format: ["esm"],
28
- dts: true,
29
- clean: true,
30
- sourcemap: true,
31
- target: "es2022",
32
- external: ["@nebutra/mcp"],
33
- });