@nebutra/agent-runtime 0.2.1 → 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 (101) hide show
  1. package/LICENSE +21 -676
  2. package/dist/adapters/index.d.ts +24 -5
  3. package/dist/adapters/index.js +27 -0
  4. package/dist/adapters/index.js.map +1 -1
  5. package/dist/chunk-Q62VKHIT.js +178 -0
  6. package/dist/chunk-Q62VKHIT.js.map +1 -0
  7. package/dist/{chunk-MUF7ZZTO.js → chunk-R5HOSQUW.js} +2 -1
  8. package/dist/{chunk-MUF7ZZTO.js.map → chunk-R5HOSQUW.js.map} +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.js +14 -17
  11. package/dist/index.js.map +1 -1
  12. package/dist/orchestration.d.ts +42 -1
  13. package/dist/orchestration.js +7 -3
  14. package/dist/sandbox.js +1 -1
  15. package/package.json +80 -30
  16. package/.turbo/turbo-build.log +0 -130
  17. package/.turbo/turbo-test.log +0 -47
  18. package/.turbo/turbo-typecheck.log +0 -4
  19. package/CHANGELOG.md +0 -250
  20. package/dist/chunk-MX2WL43P.js +0 -90
  21. package/dist/chunk-MX2WL43P.js.map +0 -1
  22. package/examples/pulsar-quickstart.ts +0 -35
  23. package/examples/resume-branch.ts +0 -45
  24. package/examples/subagent-fanout.ts +0 -20
  25. package/src/adapters/dispatcher-sse.test.ts +0 -218
  26. package/src/adapters/dispatcher-sse.ts +0 -222
  27. package/src/adapters/index.ts +0 -18
  28. package/src/adapters/mcp-catalog.test.ts +0 -213
  29. package/src/adapters/mcp-catalog.ts +0 -188
  30. package/src/adapters/prisma-rollout.test.ts +0 -153
  31. package/src/adapters/prisma-rollout.ts +0 -104
  32. package/src/agent-runtime.test.ts +0 -176
  33. package/src/artifact-stream.test.ts +0 -330
  34. package/src/artifact-stream.ts +0 -453
  35. package/src/channel-gateway.test.ts +0 -432
  36. package/src/channel-gateway.ts +0 -357
  37. package/src/cli.ts +0 -49
  38. package/src/code-review.test.ts +0 -501
  39. package/src/code-review.ts +0 -495
  40. package/src/command-suggestions.test.ts +0 -251
  41. package/src/command-suggestions.ts +0 -338
  42. package/src/commands.test.ts +0 -184
  43. package/src/commands.ts +0 -140
  44. package/src/commit-message.test.ts +0 -249
  45. package/src/commit-message.ts +0 -180
  46. package/src/context-compaction.test.ts +0 -522
  47. package/src/context-compaction.ts +0 -438
  48. package/src/definitions.test.ts +0 -78
  49. package/src/definitions.ts +0 -190
  50. package/src/deployment-status.test.ts +0 -215
  51. package/src/deployment-status.ts +0 -227
  52. package/src/design-context.test.ts +0 -195
  53. package/src/design-context.ts +0 -198
  54. package/src/dispatcher.test.ts +0 -234
  55. package/src/dispatcher.ts +0 -189
  56. package/src/durable-turn.test.ts +0 -209
  57. package/src/durable-turn.ts +0 -135
  58. package/src/edit-planner.test.ts +0 -204
  59. package/src/edit-planner.ts +0 -325
  60. package/src/fuzzy-match.test.ts +0 -311
  61. package/src/fuzzy-match.ts +0 -444
  62. package/src/hook-pipeline.test.ts +0 -279
  63. package/src/hook-pipeline.ts +0 -373
  64. package/src/inbound-admission.test.ts +0 -394
  65. package/src/inbound-admission.ts +0 -246
  66. package/src/index.ts +0 -49
  67. package/src/loop.test.ts +0 -161
  68. package/src/loop.ts +0 -211
  69. package/src/mcp-bridge.test.ts +0 -165
  70. package/src/mcp-bridge.ts +0 -81
  71. package/src/memory-provider.test.ts +0 -232
  72. package/src/memory-provider.ts +0 -257
  73. package/src/model.ts +0 -168
  74. package/src/orchestration.test.ts +0 -53
  75. package/src/orchestration.ts +0 -146
  76. package/src/permission-ruleset.test.ts +0 -301
  77. package/src/permission-ruleset.ts +0 -1
  78. package/src/policy.ts +0 -151
  79. package/src/project-repo.test.ts +0 -232
  80. package/src/project-repo.ts +0 -311
  81. package/src/protocol.ts +0 -159
  82. package/src/pulsar.test.ts +0 -156
  83. package/src/pulsar.ts +0 -322
  84. package/src/rollout-store-persistent.test.ts +0 -217
  85. package/src/rollout-store-persistent.ts +0 -166
  86. package/src/rollout.ts +0 -150
  87. package/src/sandbox.ts +0 -113
  88. package/src/session-share.test.ts +0 -360
  89. package/src/session-share.ts +0 -310
  90. package/src/skill-distillation.test.ts +0 -177
  91. package/src/skill-distillation.ts +0 -369
  92. package/src/skills.test.ts +0 -277
  93. package/src/skills.ts +0 -277
  94. package/src/subagents.test.ts +0 -290
  95. package/src/subagents.ts +0 -332
  96. package/src/tools.test.ts +0 -12
  97. package/src/tools.ts +0 -129
  98. package/src/workbench.test.ts +0 -0
  99. package/src/workbench.ts +0 -0
  100. package/tsconfig.json +0 -12
  101. package/tsup.config.ts +0 -36
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
- });