@rarebit-one/harness-kernel 0.5.1

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 (163) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +286 -0
  3. package/dist/agent.d.ts +71 -0
  4. package/dist/agent.d.ts.map +1 -0
  5. package/dist/agent.js +258 -0
  6. package/dist/agent.js.map +1 -0
  7. package/dist/connectors/mcpClient.d.ts +22 -0
  8. package/dist/connectors/mcpClient.d.ts.map +1 -0
  9. package/dist/connectors/mcpClient.js +63 -0
  10. package/dist/connectors/mcpClient.js.map +1 -0
  11. package/dist/context/types.d.ts +68 -0
  12. package/dist/context/types.d.ts.map +1 -0
  13. package/dist/context/types.js +43 -0
  14. package/dist/context/types.js.map +1 -0
  15. package/dist/engines/capability.d.ts +67 -0
  16. package/dist/engines/capability.d.ts.map +1 -0
  17. package/dist/engines/capability.js +73 -0
  18. package/dist/engines/capability.js.map +1 -0
  19. package/dist/engines/capabilityEmissions.d.ts +27 -0
  20. package/dist/engines/capabilityEmissions.d.ts.map +1 -0
  21. package/dist/engines/capabilityEmissions.js +37 -0
  22. package/dist/engines/capabilityEmissions.js.map +1 -0
  23. package/dist/engines/capabilityMcp.d.ts +23 -0
  24. package/dist/engines/capabilityMcp.d.ts.map +1 -0
  25. package/dist/engines/capabilityMcp.js +36 -0
  26. package/dist/engines/capabilityMcp.js.map +1 -0
  27. package/dist/engines/capabilityStdio.d.ts +46 -0
  28. package/dist/engines/capabilityStdio.d.ts.map +1 -0
  29. package/dist/engines/capabilityStdio.js +39 -0
  30. package/dist/engines/capabilityStdio.js.map +1 -0
  31. package/dist/engines/claudeCode.d.ts +73 -0
  32. package/dist/engines/claudeCode.d.ts.map +1 -0
  33. package/dist/engines/claudeCode.js +100 -0
  34. package/dist/engines/claudeCode.js.map +1 -0
  35. package/dist/engines/claudeCodeDriver.d.ts +14 -0
  36. package/dist/engines/claudeCodeDriver.d.ts.map +1 -0
  37. package/dist/engines/claudeCodeDriver.js +90 -0
  38. package/dist/engines/claudeCodeDriver.js.map +1 -0
  39. package/dist/engines/codex.d.ts +72 -0
  40. package/dist/engines/codex.d.ts.map +1 -0
  41. package/dist/engines/codex.js +157 -0
  42. package/dist/engines/codex.js.map +1 -0
  43. package/dist/engines/codexDriver.d.ts +43 -0
  44. package/dist/engines/codexDriver.d.ts.map +1 -0
  45. package/dist/engines/codexDriver.js +110 -0
  46. package/dist/engines/codexDriver.js.map +1 -0
  47. package/dist/engines/connectorMcp.d.ts +60 -0
  48. package/dist/engines/connectorMcp.d.ts.map +1 -0
  49. package/dist/engines/connectorMcp.js +137 -0
  50. package/dist/engines/connectorMcp.js.map +1 -0
  51. package/dist/engines/index.d.ts +33 -0
  52. package/dist/engines/index.d.ts.map +1 -0
  53. package/dist/engines/index.js +29 -0
  54. package/dist/engines/index.js.map +1 -0
  55. package/dist/engines/native.d.ts +55 -0
  56. package/dist/engines/native.d.ts.map +1 -0
  57. package/dist/engines/native.js +117 -0
  58. package/dist/engines/native.js.map +1 -0
  59. package/dist/engines/types.d.ts +107 -0
  60. package/dist/engines/types.d.ts.map +1 -0
  61. package/dist/engines/types.js +2 -0
  62. package/dist/engines/types.js.map +1 -0
  63. package/dist/events.d.ts +211 -0
  64. package/dist/events.d.ts.map +1 -0
  65. package/dist/events.js +69 -0
  66. package/dist/events.js.map +1 -0
  67. package/dist/index.d.ts +63 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +82 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/loop.d.ts +132 -0
  72. package/dist/loop.d.ts.map +1 -0
  73. package/dist/loop.js +77 -0
  74. package/dist/loop.js.map +1 -0
  75. package/dist/models/chat.d.ts +65 -0
  76. package/dist/models/chat.d.ts.map +1 -0
  77. package/dist/models/chat.js +66 -0
  78. package/dist/models/chat.js.map +1 -0
  79. package/dist/models/middleware.d.ts +63 -0
  80. package/dist/models/middleware.d.ts.map +1 -0
  81. package/dist/models/middleware.js +139 -0
  82. package/dist/models/middleware.js.map +1 -0
  83. package/dist/models/registry.d.ts +78 -0
  84. package/dist/models/registry.d.ts.map +1 -0
  85. package/dist/models/registry.js +0 -0
  86. package/dist/models/registry.js.map +1 -0
  87. package/dist/models/types.d.ts +149 -0
  88. package/dist/models/types.d.ts.map +1 -0
  89. package/dist/models/types.js +64 -0
  90. package/dist/models/types.js.map +1 -0
  91. package/dist/primitives/codeExec.d.ts +25 -0
  92. package/dist/primitives/codeExec.d.ts.map +1 -0
  93. package/dist/primitives/codeExec.js +69 -0
  94. package/dist/primitives/codeExec.js.map +1 -0
  95. package/dist/primitives/download.d.ts +19 -0
  96. package/dist/primitives/download.d.ts.map +1 -0
  97. package/dist/primitives/download.js +113 -0
  98. package/dist/primitives/download.js.map +1 -0
  99. package/dist/primitives/fs.d.ts +5 -0
  100. package/dist/primitives/fs.d.ts.map +1 -0
  101. package/dist/primitives/fs.js +59 -0
  102. package/dist/primitives/fs.js.map +1 -0
  103. package/dist/primitives/http.d.ts +100 -0
  104. package/dist/primitives/http.d.ts.map +1 -0
  105. package/dist/primitives/http.js +257 -0
  106. package/dist/primitives/http.js.map +1 -0
  107. package/dist/providers/anthropic.d.ts +15 -0
  108. package/dist/providers/anthropic.d.ts.map +1 -0
  109. package/dist/providers/anthropic.js +90 -0
  110. package/dist/providers/anthropic.js.map +1 -0
  111. package/dist/providers/clientOptions.d.ts +14 -0
  112. package/dist/providers/clientOptions.d.ts.map +1 -0
  113. package/dist/providers/clientOptions.js +26 -0
  114. package/dist/providers/clientOptions.js.map +1 -0
  115. package/dist/providers/index.d.ts +24 -0
  116. package/dist/providers/index.d.ts.map +1 -0
  117. package/dist/providers/index.js +51 -0
  118. package/dist/providers/index.js.map +1 -0
  119. package/dist/providers/mock.d.ts +25 -0
  120. package/dist/providers/mock.d.ts.map +1 -0
  121. package/dist/providers/mock.js +85 -0
  122. package/dist/providers/mock.js.map +1 -0
  123. package/dist/providers/openai.d.ts +32 -0
  124. package/dist/providers/openai.d.ts.map +1 -0
  125. package/dist/providers/openai.js +118 -0
  126. package/dist/providers/openai.js.map +1 -0
  127. package/dist/providers/openrouter.d.ts +29 -0
  128. package/dist/providers/openrouter.d.ts.map +1 -0
  129. package/dist/providers/openrouter.js +35 -0
  130. package/dist/providers/openrouter.js.map +1 -0
  131. package/dist/providers/types.d.ts +60 -0
  132. package/dist/providers/types.d.ts.map +1 -0
  133. package/dist/providers/types.js +2 -0
  134. package/dist/providers/types.js.map +1 -0
  135. package/dist/routing/staticResolver.d.ts +41 -0
  136. package/dist/routing/staticResolver.d.ts.map +1 -0
  137. package/dist/routing/staticResolver.js +67 -0
  138. package/dist/routing/staticResolver.js.map +1 -0
  139. package/dist/routing/types.d.ts +72 -0
  140. package/dist/routing/types.d.ts.map +1 -0
  141. package/dist/routing/types.js +11 -0
  142. package/dist/routing/types.js.map +1 -0
  143. package/dist/secrets.d.ts +8 -0
  144. package/dist/secrets.d.ts.map +1 -0
  145. package/dist/secrets.js +14 -0
  146. package/dist/secrets.js.map +1 -0
  147. package/dist/tools/metadata.d.ts +93 -0
  148. package/dist/tools/metadata.d.ts.map +1 -0
  149. package/dist/tools/metadata.js +49 -0
  150. package/dist/tools/metadata.js.map +1 -0
  151. package/dist/tools/modelTool.d.ts +35 -0
  152. package/dist/tools/modelTool.d.ts.map +1 -0
  153. package/dist/tools/modelTool.js +37 -0
  154. package/dist/tools/modelTool.js.map +1 -0
  155. package/dist/tools/registry.d.ts +65 -0
  156. package/dist/tools/registry.d.ts.map +1 -0
  157. package/dist/tools/registry.js +166 -0
  158. package/dist/tools/registry.js.map +1 -0
  159. package/dist/types.d.ts +71 -0
  160. package/dist/types.d.ts.map +1 -0
  161. package/dist/types.js +10 -0
  162. package/dist/types.js.map +1 -0
  163. package/package.json +72 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/routing/types.ts"],"names":[],"mappings":"AA+DA,kDAAkD;AAClD,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IACtC,UAAU,CAAQ;IAE3B,YAAY,UAAkB,EAAE,KAAe;QAC7C,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAA;QAC3E,KAAK,CAAC,oCAAoC,UAAU,gBAAgB,YAAY,EAAE,CAAC,CAAA;QACnF,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAA;QACpC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Turn the run payload's resolved secrets into an environment map for the
3
+ * code-exec primitive. The caller resolves secret VALUES (from its own secret
4
+ * store) before the run; the kernel treats them as opaque and only ever
5
+ * forwards them into executed code as environment variables — never logging them.
6
+ */
7
+ export declare function secretsToEnv(secrets?: Record<string, string>): NodeJS.ProcessEnv;
8
+ //# sourceMappingURL=secrets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAAG,MAAM,CAAC,UAAU,CAMpF"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Turn the run payload's resolved secrets into an environment map for the
3
+ * code-exec primitive. The caller resolves secret VALUES (from its own secret
4
+ * store) before the run; the kernel treats them as opaque and only ever
5
+ * forwards them into executed code as environment variables — never logging them.
6
+ */
7
+ export function secretsToEnv(secrets = {}) {
8
+ const env = {};
9
+ for (const [key, value] of Object.entries(secrets)) {
10
+ env[key] = value;
11
+ }
12
+ return env;
13
+ }
14
+ //# sourceMappingURL=secrets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.js","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,UAAkC,EAAE;IAC/D,MAAM,GAAG,GAAsB,EAAE,CAAA;IACjC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IAClB,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -0,0 +1,93 @@
1
+ import type { ToolSpec } from "../providers/types.js";
2
+ import type { Tool } from "./registry.js";
3
+ /**
4
+ * Generic tool metadata and the projections that narrow it.
5
+ *
6
+ * A tool descriptor carries more than a model needs to call it: who may see it,
7
+ * whether it needs confirmation, whether it can be undone, how long its result
8
+ * should be kept. None of that belongs in the JSON schema handed to a provider —
9
+ * so the metadata is rich and the **projection** to a provider is deliberately
10
+ * lossy.
11
+ *
12
+ * The metadata here is only ever *descriptive*. The kernel records that a tool
13
+ * says `requiresConfirmation`; it never implements a confirmation flow, because
14
+ * what confirmation means — a modal, a Slack approval, a second agent — is the
15
+ * application's decision. Same for undo and retention. Policy lives in the app
16
+ * layer; the vocabulary lives here so every layer agrees on the words.
17
+ */
18
+ /**
19
+ * How a turn was invoked. A tool whose surface differs by invocation path
20
+ * declares the modes it participates in, and resolution filters by the turn's
21
+ * mode.
22
+ *
23
+ * - `user_initiated` — a normal user-driven turn.
24
+ * - `system_initiated` — a turn fired by a trigger, bypassing the user.
25
+ */
26
+ export type InvocationMode = "user_initiated" | "system_initiated";
27
+ /** How long a tool's result should be retained by the caller. */
28
+ export type ResultRetention = "ephemeral" | "standard" | "persistent";
29
+ /**
30
+ * Whether a tool's raw output reaches the client. `suppressed` trims it from
31
+ * client-facing envelopes while the model still receives it unchanged — for
32
+ * tools whose output is the model's working data, not a user-facing payload.
33
+ */
34
+ export type ClientResultVisibility = "full" | "suppressed";
35
+ /**
36
+ * Optional descriptive metadata on a {@link Tool}. Every field is optional and
37
+ * an absent field always means "no restriction", so a tool that declares no
38
+ * metadata behaves exactly as it did before this existed.
39
+ */
40
+ export interface ToolMetadata {
41
+ /** Human-facing label, where a UI wants something friendlier than `name`. */
42
+ displayName?: string;
43
+ /**
44
+ * Capability scoping. When set, only the listed capabilities see the tool;
45
+ * absent or null means every capability does.
46
+ */
47
+ targetCapabilities?: string[] | null;
48
+ /**
49
+ * Invocation-mode scoping. When set, the tool is visible only in the listed
50
+ * modes; absent or null means mode-agnostic. A tool that declares modes is
51
+ * hidden from an unscoped resolution, so a system-only tool can never leak
52
+ * into a user-driven loop.
53
+ */
54
+ invocationModes?: InvocationMode[] | null;
55
+ /** The caller should confirm with a human before executing. */
56
+ requiresConfirmation?: boolean;
57
+ /** The effect can be undone. */
58
+ reversible?: boolean;
59
+ /** The tool that undoes this one, when `reversible`. */
60
+ undoToolName?: string | null;
61
+ /** How long undo stays available. */
62
+ undoWindowSeconds?: number | null;
63
+ resultRetention?: ResultRetention;
64
+ clientResultVisibility?: ClientResultVisibility;
65
+ }
66
+ /** The scope a tool surface is being resolved for. */
67
+ export interface ToolSelection {
68
+ /** Resolving capability; matched against `targetCapabilities`. */
69
+ capability?: string;
70
+ /** Invocation mode of the turn; matched against `invocationModes`. */
71
+ mode?: InvocationMode;
72
+ /** Allowlist of tool names, e.g. from a workflow's permissions. */
73
+ allowed?: string[];
74
+ }
75
+ /** Whether one tool is visible under a selection. */
76
+ export declare function isToolVisible(tool: Tool, selection?: ToolSelection): boolean;
77
+ /**
78
+ * Narrow a tool surface to what a given capability and invocation mode may see.
79
+ * This is the projection that runs *before* the model ever hears about a tool.
80
+ */
81
+ export declare function selectTools(tools: Tool[], selection?: ToolSelection): Tool[];
82
+ /**
83
+ * Project tools down to the provider-facing definitions — name, description and
84
+ * input schema, and nothing else. Everything the metadata adds is intentionally
85
+ * dropped here: a model has no use for retention policy, and leaking it into
86
+ * the schema would only spend context.
87
+ */
88
+ export declare function toToolSpecs(tools: Tool[]): ToolSpec[];
89
+ /** Tools that must not execute until a human has approved them. */
90
+ export declare function toolsRequiringConfirmation(tools: Tool[]): Tool[];
91
+ /** Look up the tool that undoes `name`, when one is declared and reversible. */
92
+ export declare function undoToolFor(tools: Tool[], name: string): Tool | undefined;
93
+ //# sourceMappingURL=metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/tools/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAEzC;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,kBAAkB,CAAA;AAElE,iEAAiE;AACjE,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,CAAA;AAErE;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,YAAY,CAAA;AAE1D;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IACpC;;;;;OAKG;IACH,eAAe,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAA;IACzC,+DAA+D;IAC/D,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,gCAAgC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,qCAAqC;IACrC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,sBAAsB,CAAC,EAAE,sBAAsB,CAAA;CAChD;AAED,sDAAsD;AACtD,MAAM,WAAW,aAAa;IAC5B,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,sEAAsE;IACtE,IAAI,CAAC,EAAE,cAAc,CAAA;IACrB,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB;AAED,qDAAqD;AACrD,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,GAAE,aAAkB,GAAG,OAAO,CAmBhF;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,SAAS,GAAE,aAAkB,GAAG,IAAI,EAAE,CAEhF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,QAAQ,EAAE,CAErD;AAED,mEAAmE;AACnE,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,CAEhE;AAED,gFAAgF;AAChF,wBAAgB,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAIzE"}
@@ -0,0 +1,49 @@
1
+ /** Whether one tool is visible under a selection. */
2
+ export function isToolVisible(tool, selection = {}) {
3
+ const meta = tool.meta;
4
+ if (selection.allowed && !selection.allowed.includes(tool.spec.name))
5
+ return false;
6
+ if (!meta)
7
+ return true;
8
+ // A tool scoped to specific capabilities is hidden unless one matches. An
9
+ // unscoped resolution (no capability given) cannot satisfy the scope, so the
10
+ // tool stays hidden — scoping fails closed.
11
+ if (meta.targetCapabilities && meta.targetCapabilities.length > 0) {
12
+ if (!selection.capability || !meta.targetCapabilities.includes(selection.capability)) {
13
+ return false;
14
+ }
15
+ }
16
+ if (meta.invocationModes && meta.invocationModes.length > 0) {
17
+ if (!selection.mode || !meta.invocationModes.includes(selection.mode))
18
+ return false;
19
+ }
20
+ return true;
21
+ }
22
+ /**
23
+ * Narrow a tool surface to what a given capability and invocation mode may see.
24
+ * This is the projection that runs *before* the model ever hears about a tool.
25
+ */
26
+ export function selectTools(tools, selection = {}) {
27
+ return tools.filter((tool) => isToolVisible(tool, selection));
28
+ }
29
+ /**
30
+ * Project tools down to the provider-facing definitions — name, description and
31
+ * input schema, and nothing else. Everything the metadata adds is intentionally
32
+ * dropped here: a model has no use for retention policy, and leaking it into
33
+ * the schema would only spend context.
34
+ */
35
+ export function toToolSpecs(tools) {
36
+ return tools.map((tool) => tool.spec);
37
+ }
38
+ /** Tools that must not execute until a human has approved them. */
39
+ export function toolsRequiringConfirmation(tools) {
40
+ return tools.filter((tool) => tool.meta?.requiresConfirmation === true);
41
+ }
42
+ /** Look up the tool that undoes `name`, when one is declared and reversible. */
43
+ export function undoToolFor(tools, name) {
44
+ const tool = tools.find((t) => t.spec.name === name);
45
+ if (!tool?.meta?.reversible || !tool.meta.undoToolName)
46
+ return undefined;
47
+ return tools.find((t) => t.spec.name === tool.meta?.undoToolName);
48
+ }
49
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/tools/metadata.ts"],"names":[],"mappings":"AAiFA,qDAAqD;AACrD,MAAM,UAAU,aAAa,CAAC,IAAU,EAAE,YAA2B,EAAE;IACrE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;IACtB,IAAI,SAAS,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAA;IAClF,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAEtB,0EAA0E;IAC1E,6EAA6E;IAC7E,4CAA4C;IAC5C,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClE,IAAI,CAAC,SAAS,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAA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,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;AACnE,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { InvokeContext, ModelInvocation, ModelResult } from "../models/types.js";
2
+ import type { ToolMetadata } from "./metadata.js";
3
+ import type { Tool } from "./registry.js";
4
+ /** How to turn one model invocation into a callable tool. */
5
+ export interface ModelToolOptions<Req, Res> {
6
+ /** Tool name the model calls. */
7
+ name: string;
8
+ description: string;
9
+ /** JSON-Schema shape advertised to the model. */
10
+ inputSchema: Record<string, unknown>;
11
+ /** Map the model's raw tool input to the invocation's request type. */
12
+ toRequest: (input: Record<string, unknown>) => Req;
13
+ /**
14
+ * Project the result down to the string the calling model sees. Defaults to
15
+ * JSON — fine for a struct, worth overriding when a short natural-language
16
+ * summary would spend less context than the full payload.
17
+ */
18
+ toContent?: (result: ModelResult<Res>) => string;
19
+ meta?: ToolMetadata;
20
+ }
21
+ /**
22
+ * Surface a {@link ModelInvocation} as a {@link Tool}.
23
+ *
24
+ * This is the cleanest form of "extension, not fork": a perception model — a
25
+ * `vision.detect` or an `audio.asr` — becomes something the chat loop can call,
26
+ * without the loop, the engines, or any kernel code learning that perception
27
+ * exists. The registry binds it, this wraps it, the agent calls it like any
28
+ * other tool.
29
+ *
30
+ * The typed result survives the trip: `content` is the model-facing projection,
31
+ * and `structured` carries the original `Res` for callers and clients that want
32
+ * the real thing rather than a re-parsed string.
33
+ */
34
+ export declare function modelAsTool<Req, Res>(model: ModelInvocation<Req, Res>, options: ModelToolOptions<Req, Res>, context?: Partial<InvokeContext>): Tool;
35
+ //# sourceMappingURL=modelTool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modelTool.d.ts","sourceRoot":"","sources":["../../src/tools/modelTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,eAAe,CAAA;AAErD,6DAA6D;AAC7D,MAAM,WAAW,gBAAgB,CAAC,GAAG,EAAE,GAAG;IACxC,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,uEAAuE;IACvE,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,GAAG,CAAA;IAClD;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,KAAK,MAAM,CAAA;IAChD,IAAI,CAAC,EAAE,YAAY,CAAA;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAClC,KAAK,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,EAChC,OAAO,EAAE,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,EACnC,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM,GACnC,IAAI,CAwBN"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Surface a {@link ModelInvocation} as a {@link Tool}.
3
+ *
4
+ * This is the cleanest form of "extension, not fork": a perception model — a
5
+ * `vision.detect` or an `audio.asr` — becomes something the chat loop can call,
6
+ * without the loop, the engines, or any kernel code learning that perception
7
+ * exists. The registry binds it, this wraps it, the agent calls it like any
8
+ * other tool.
9
+ *
10
+ * The typed result survives the trip: `content` is the model-facing projection,
11
+ * and `structured` carries the original `Res` for callers and clients that want
12
+ * the real thing rather than a re-parsed string.
13
+ */
14
+ export function modelAsTool(model, options, context = {}) {
15
+ const project = options.toContent ?? ((result) => JSON.stringify(result.value));
16
+ const run = async (input) => {
17
+ const ctx = {
18
+ log: context.log ?? (() => { }),
19
+ ...(context.signal ? { signal: context.signal } : {}),
20
+ ...(context.correlationId ? { correlationId: context.correlationId } : {}),
21
+ ...(context.budget ? { budget: context.budget } : {}),
22
+ };
23
+ const result = await model.invoke(options.toRequest(input), ctx);
24
+ return { content: project(result), structured: result.value };
25
+ };
26
+ return {
27
+ spec: {
28
+ name: options.name,
29
+ description: options.description,
30
+ inputSchema: options.inputSchema,
31
+ },
32
+ ...(options.meta ? { meta: options.meta } : {}),
33
+ execute: async (input) => (await run(input)).content,
34
+ executeStructured: run,
35
+ };
36
+ }
37
+ //# sourceMappingURL=modelTool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modelTool.js","sourceRoot":"","sources":["../../src/tools/modelTool.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CACzB,KAAgC,EAChC,OAAmC,EACnC,UAAkC,EAAE;IAEpC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,IAAI,CAAC,CAAC,MAAwB,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAEjG,MAAM,GAAG,GAAG,KAAK,EAAE,KAA8B,EAAuB,EAAE;QACxE,MAAM,GAAG,GAAkB;YACzB,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;YAC9B,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACrD,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1E,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACtD,CAAA;QACD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAA;QAChE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,KAAK,EAAE,CAAA;IAC/D,CAAC,CAAA;IAED,OAAO;QACL,IAAI,EAAE;YACJ,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC;QACD,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO;QACpD,iBAAiB,EAAE,GAAG;KACvB,CAAA;AACH,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { type McpConnection } from "../connectors/mcpClient.js";
2
+ import type { ConnectorConfig } from "../types.js";
3
+ import type { ToolSpec } from "../providers/types.js";
4
+ import type { ToolMetadata } from "./metadata.js";
5
+ /**
6
+ * What a tool produced: the string the model sees, plus the typed payload that
7
+ * string was projected from.
8
+ *
9
+ * The model can only consume text, so `content` is what goes back into the
10
+ * conversation. But a caller that JSON-stringifies a struct on the way out and
11
+ * re-parses it on the way in has lost the type for no reason — so `structured`
12
+ * carries the original alongside, untouched.
13
+ */
14
+ export interface ToolOutput {
15
+ /** The string projection fed back to the model. */
16
+ content: string;
17
+ /** The typed payload, preserved for callers and clients. */
18
+ structured?: unknown;
19
+ }
20
+ /** A tool the agent can call: its public spec plus a server-side executor. */
21
+ export interface Tool {
22
+ spec: ToolSpec;
23
+ /** Optional descriptive metadata — scoping, confirmation, undo, retention. */
24
+ meta?: ToolMetadata;
25
+ /**
26
+ * Execute and return the model-facing string. This is the required contract
27
+ * every tool implements, and the only one the loop needs.
28
+ */
29
+ execute(input: Record<string, unknown>): Promise<string>;
30
+ /**
31
+ * Optional richer executor. When present the loop calls this instead and
32
+ * keeps the typed payload alongside the string; when absent nothing changes.
33
+ *
34
+ * Two methods rather than one widened return type is a deliberate
35
+ * concession to compatibility: every existing tool and every existing caller
36
+ * types `execute` as returning a plain `string`, and widening it to a union
37
+ * would break them at the type level for a payload most tools never produce.
38
+ */
39
+ executeStructured?(input: Record<string, unknown>): Promise<ToolOutput>;
40
+ }
41
+ /** Run a tool through its richest available executor. */
42
+ export declare function executeTool(tool: Tool, input: Record<string, unknown>): Promise<ToolOutput>;
43
+ /**
44
+ * General-purpose primitives, scoped to the run sandbox. `env` carries the
45
+ * resolved secrets (see secretsToEnv) into executed code. Domain logic is the
46
+ * user's own repo code, invoked through `run_code` — never baked in here.
47
+ *
48
+ * This set is strictly generic: sandboxed shell, file reads, and HTTP. Tools
49
+ * that collect an application's *domain output* are not here at all — they are
50
+ * the application's vocabulary, injected through the engines' domain-tool seam.
51
+ *
52
+ * When `allowed` is provided it acts as an allowlist of primitive tool names
53
+ * (from the workflow's `permissions.tools`).
54
+ */
55
+ export declare function primitiveTools(sandboxDir: string, env: NodeJS.ProcessEnv, allowed?: string[], allowHosts?: string[]): Tool[];
56
+ /**
57
+ * Tools exposed by the run's MCP connectors. Each connector's tools are
58
+ * namespaced `<connector>__<tool>` to avoid collisions. Returns a `close` to
59
+ * tear down the connections when the run ends.
60
+ */
61
+ export declare function connectorTools(connectors: ConnectorConfig[], connect?: (config: ConnectorConfig) => Promise<McpConnection>): Promise<{
62
+ tools: Tool[];
63
+ close: () => Promise<void>;
64
+ }>;
65
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.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AM,EAAE,eAAe,KAAK,OAAO,CAAC,aAAa,CAAc,GACxE,OAAO,CAAC;IAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CAuCxD"}
@@ -0,0 +1,166 @@
1
+ import { runCode } from "../primitives/codeExec.js";
2
+ import { httpFetch } from "../primitives/http.js";
3
+ import { readFileSafe, listFiles } from "../primitives/fs.js";
4
+ import { connectMcp } from "../connectors/mcpClient.js";
5
+ /** Run a tool through its richest available executor. */
6
+ export async function executeTool(tool, input) {
7
+ if (tool.executeStructured)
8
+ return tool.executeStructured(input);
9
+ return { content: await tool.execute(input) };
10
+ }
11
+ const str = (v) => (typeof v === "string" ? v : "");
12
+ const strArray = (v) => (Array.isArray(v) ? v.map(String) : []);
13
+ /** Keep only string-valued headers (the model may pass arbitrary JSON). */
14
+ function stringHeaders(v) {
15
+ if (!v || typeof v !== "object")
16
+ return undefined;
17
+ const out = {};
18
+ for (const [key, value] of Object.entries(v)) {
19
+ if (typeof value === "string")
20
+ out[key] = value;
21
+ }
22
+ return out;
23
+ }
24
+ /**
25
+ * General-purpose primitives, scoped to the run sandbox. `env` carries the
26
+ * resolved secrets (see secretsToEnv) into executed code. Domain logic is the
27
+ * user's own repo code, invoked through `run_code` — never baked in here.
28
+ *
29
+ * This set is strictly generic: sandboxed shell, file reads, and HTTP. Tools
30
+ * that collect an application's *domain output* are not here at all — they are
31
+ * the application's vocabulary, injected through the engines' domain-tool seam.
32
+ *
33
+ * When `allowed` is provided it acts as an allowlist of primitive tool names
34
+ * (from the workflow's `permissions.tools`).
35
+ */
36
+ export function primitiveTools(sandboxDir, env, allowed, allowHosts) {
37
+ const all = [
38
+ {
39
+ spec: {
40
+ name: "run_code",
41
+ description: "Run a shell command in the workspace sandbox — e.g. `node scan.mjs`, `npm ci`, or a one-liner. " +
42
+ "`command` is a shell command line run via `/bin/sh -c`, so pipes, quoting and redirection work and " +
43
+ "`node`/`npm`/etc. resolve on PATH. (Advanced: pass `args` to exec `command` as a bare binary with " +
44
+ "those arguments, bypassing the shell.) Returns stdout, stderr, and the exit code.",
45
+ inputSchema: {
46
+ type: "object",
47
+ properties: {
48
+ command: { type: "string" },
49
+ args: { type: "array", items: { type: "string" } },
50
+ stdin: { type: "string" },
51
+ },
52
+ required: ["command"],
53
+ },
54
+ },
55
+ execute: async (input) => {
56
+ const command = str(input.command);
57
+ const args = strArray(input.args);
58
+ const stdin = typeof input.stdin === "string" ? input.stdin : undefined;
59
+ // Default to running the command line through a shell (mirrors the verify
60
+ // gate's `/bin/sh -c`), so an agent can hand us `node scan.mjs` as a single
61
+ // string. When explicit args are given, exec the binary directly (no shell).
62
+ const result = args.length > 0
63
+ ? await runCode({ cwd: sandboxDir, command, args, env, stdin })
64
+ : await runCode({
65
+ cwd: sandboxDir,
66
+ command: "/bin/sh",
67
+ args: ["-c", command],
68
+ env,
69
+ stdin,
70
+ });
71
+ return JSON.stringify(result);
72
+ },
73
+ },
74
+ {
75
+ spec: {
76
+ name: "read_file",
77
+ description: "Read a UTF-8 file from the workspace sandbox.",
78
+ inputSchema: {
79
+ type: "object",
80
+ properties: { path: { type: "string" } },
81
+ required: ["path"],
82
+ },
83
+ },
84
+ execute: async (input) => (await readFileSafe(sandboxDir, str(input.path))) ?? "(not found)",
85
+ },
86
+ {
87
+ spec: {
88
+ name: "list_files",
89
+ description: "List files under a directory in the workspace sandbox.",
90
+ inputSchema: {
91
+ type: "object",
92
+ properties: { dir: { type: "string" } },
93
+ },
94
+ },
95
+ execute: async (input) => (await listFiles(sandboxDir, str(input.dir) || ".")).join("\n"),
96
+ },
97
+ {
98
+ spec: {
99
+ name: "http_fetch",
100
+ description: "Make an HTTP request. Returns the status and response body.",
101
+ inputSchema: {
102
+ type: "object",
103
+ properties: {
104
+ url: { type: "string" },
105
+ method: { type: "string" },
106
+ headers: { type: "object" },
107
+ body: { type: "string" },
108
+ },
109
+ required: ["url"],
110
+ },
111
+ },
112
+ execute: async (input) => {
113
+ const res = await httpFetch({
114
+ url: str(input.url),
115
+ method: str(input.method) || "GET",
116
+ headers: stringHeaders(input.headers),
117
+ body: typeof input.body === "string" ? input.body : undefined,
118
+ allowHosts, // egress allowlist from the workflow's permissions (undefined = any public host)
119
+ });
120
+ return JSON.stringify({ status: res.status, body: res.body });
121
+ },
122
+ },
123
+ ];
124
+ return allowed ? all.filter((t) => allowed.includes(t.spec.name)) : all;
125
+ }
126
+ /**
127
+ * Tools exposed by the run's MCP connectors. Each connector's tools are
128
+ * namespaced `<connector>__<tool>` to avoid collisions. Returns a `close` to
129
+ * tear down the connections when the run ends.
130
+ */
131
+ export async function connectorTools(connectors, connect = connectMcp) {
132
+ const connections = [];
133
+ const tools = [];
134
+ const close = async () => {
135
+ await Promise.allSettled(connections.map((c) => c.close()));
136
+ };
137
+ try {
138
+ for (const config of connectors) {
139
+ if (config.kind !== "mcp")
140
+ continue;
141
+ const conn = await connect(config);
142
+ connections.push(conn);
143
+ const listed = (await conn.listTools());
144
+ for (const tool of listed.tools ?? []) {
145
+ tools.push({
146
+ spec: {
147
+ name: `${config.name}__${tool.name}`,
148
+ description: tool.description ?? `${config.name} tool ${tool.name}`,
149
+ inputSchema: tool.inputSchema ?? { type: "object" },
150
+ },
151
+ execute: async (input) => {
152
+ const result = await conn.callTool(tool.name, input);
153
+ return JSON.stringify(result);
154
+ },
155
+ });
156
+ }
157
+ }
158
+ }
159
+ catch (err) {
160
+ // Don't leak connections opened before the failing one.
161
+ await close();
162
+ throw err;
163
+ }
164
+ return { tools, close };
165
+ }
166
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,SAAS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MAAM,CAAC,CAAA;YAClC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAEtB,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE,CAErC,CAAA;YAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;gBACtC,KAAK,CAAC,IAAI,CAAC;oBACT,IAAI,EAAE;wBACJ,IAAI,EAAE,GAAG,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE;wBACpC,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,GAAG,MAAM,CAAC,IAAI,SAAS,IAAI,CAAC,IAAI,EAAE;wBACnE,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE;qBACpD;oBACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;wBACvB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;wBACpD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;oBAC/B,CAAC;iBACF,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,wDAAwD;QACxD,MAAM,KAAK,EAAE,CAAA;QACb,MAAM,GAAG,CAAA;IACX,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;AACzB,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * A single external connector the harness can talk to. `kind` distinguishes a
3
+ * Model Context Protocol server from a plain HTTP service; `transport` selects
4
+ * the wire protocol for MCP connectors.
5
+ */
6
+ export interface ConnectorConfig {
7
+ name: string;
8
+ kind: "mcp" | "http";
9
+ transport: "stdio" | "streamable_http" | "sse";
10
+ /** For streamable_http / sse transports. */
11
+ endpoint?: string;
12
+ /** For the stdio transport. */
13
+ command?: string;
14
+ args?: string[];
15
+ /** Token is already resolved by the caller; the kernel treats it as opaque. */
16
+ auth?: {
17
+ type: "bearer" | "none";
18
+ token?: string;
19
+ };
20
+ }
21
+ /**
22
+ * What a run is allowed to touch. `tools` acts as an allowlist of tool names,
23
+ * `hosts` as an egress allowlist for the http_fetch primitive; the open index
24
+ * signature lets callers carry their own policy keys through untouched.
25
+ */
26
+ export interface Permissions {
27
+ read?: string[];
28
+ write?: string[];
29
+ tools?: string[];
30
+ /** Egress allowlist (host[:port]) for the http_fetch primitive. */
31
+ hosts?: string[];
32
+ [key: string]: unknown;
33
+ }
34
+ /**
35
+ * The declarative description of the work a run performs, as parsed from the
36
+ * caller's own workflow format. The kernel reads only what it needs (the
37
+ * prompt, permissions, provider preference); the remaining fields are carried
38
+ * through for engines and callers that care.
39
+ */
40
+ export interface WorkflowDefinition {
41
+ name?: string;
42
+ trigger?: {
43
+ type?: string;
44
+ };
45
+ service?: {
46
+ exposed?: boolean;
47
+ name?: string;
48
+ };
49
+ permissions?: Permissions;
50
+ autonomy?: {
51
+ approval_required?: boolean;
52
+ };
53
+ context?: {
54
+ mode?: string;
55
+ files?: string[];
56
+ };
57
+ runner?: {
58
+ profile?: string;
59
+ };
60
+ provider?: {
61
+ preferred?: string;
62
+ };
63
+ prompt?: string;
64
+ /** Shell commands run in the sandbox BEFORE the agent, to install the run's own
65
+ * dependencies (e.g. `npm ci`). Runs with the run's secrets in env; a failure
66
+ * aborts the run (the agent must not run without its deps). */
67
+ setup?: string[];
68
+ /** Shell commands run as a deterministic audit gate after output is produced. */
69
+ verify?: string[];
70
+ }
71
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,KAAK,GAAG,MAAM,CAAA;IACpB,SAAS,EAAE,O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jC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;oEAEgE;IAChE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB"}
package/dist/types.js ADDED
@@ -0,0 +1,10 @@
1
+ // The shapes a caller hands the kernel: what a run is *given* — connectors,
2
+ // permissions, a workflow. Nothing here is application-specific.
3
+ //
4
+ // What a run *emits* used to live here too, as `KnowledgeEntry` and
5
+ // `IssueEntry`. It doesn't any more: those were one product's vocabulary, and a
6
+ // kernel that names them has already lost the argument. Emissions are opaque —
7
+ // see `EngineResult.emissions`. A host defines its own emission shapes and
8
+ // casts.
9
+ export {};
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,iEAAiE;AACjE,EAAE;AACF,oEAAoE;AACpE,gFAAgF;AAChF,+EAA+E;AAC/E,2EAA2E;AAC3E,SAAS"}