@haikeilabs/agentware 0.1.0 → 0.2.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 (63) hide show
  1. package/README.md +19 -0
  2. package/dist/executor/agent_loop.d.ts +50 -0
  3. package/dist/executor/agent_loop.d.ts.map +1 -0
  4. package/dist/executor/agent_loop.js +255 -0
  5. package/dist/executor/executor.d.ts.map +1 -1
  6. package/dist/executor/executor.js +6 -2
  7. package/dist/executor/index.d.ts +2 -1
  8. package/dist/executor/index.d.ts.map +1 -1
  9. package/dist/executor/index.js +2 -1
  10. package/dist/index.d.ts +2 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +2 -0
  13. package/dist/kei/index.d.ts +2 -0
  14. package/dist/kei/index.d.ts.map +1 -0
  15. package/dist/kei/index.js +1 -0
  16. package/dist/kei/runtimeLink.d.ts +281 -0
  17. package/dist/kei/runtimeLink.d.ts.map +1 -0
  18. package/dist/kei/runtimeLink.js +591 -0
  19. package/dist/llm/backend.d.ts +7 -0
  20. package/dist/llm/backend.d.ts.map +1 -1
  21. package/dist/llm/index.d.ts +2 -1
  22. package/dist/llm/index.d.ts.map +1 -1
  23. package/dist/llm/index.js +1 -0
  24. package/dist/llm/openai_backend.d.ts +51 -0
  25. package/dist/llm/openai_backend.d.ts.map +1 -0
  26. package/dist/llm/openai_backend.js +203 -0
  27. package/dist/llm/response.d.ts +5 -0
  28. package/dist/llm/response.d.ts.map +1 -1
  29. package/dist/middleware/guardrails/response_validator.d.ts +1 -1
  30. package/dist/middleware/guardrails/response_validator.d.ts.map +1 -1
  31. package/dist/middleware/guardrails/response_validator.js +1 -1
  32. package/dist/middleware/index.d.ts +5 -0
  33. package/dist/middleware/index.d.ts.map +1 -1
  34. package/dist/middleware/index.js +5 -0
  35. package/dist/middleware/inference.d.ts +8 -0
  36. package/dist/middleware/inference.d.ts.map +1 -1
  37. package/dist/middleware/inference.js +73 -31
  38. package/dist/reasoning/adapter.d.ts +33 -0
  39. package/dist/reasoning/adapter.d.ts.map +1 -0
  40. package/dist/reasoning/adapter.js +365 -0
  41. package/dist/reasoning/errors.d.ts +28 -0
  42. package/dist/reasoning/errors.d.ts.map +1 -0
  43. package/dist/reasoning/errors.js +57 -0
  44. package/dist/reasoning/index.d.ts +6 -0
  45. package/dist/reasoning/index.d.ts.map +1 -0
  46. package/dist/reasoning/index.js +4 -0
  47. package/dist/reasoning/options.d.ts +18 -0
  48. package/dist/reasoning/options.d.ts.map +1 -0
  49. package/dist/reasoning/options.js +18 -0
  50. package/dist/reasoning/types.d.ts +44 -0
  51. package/dist/reasoning/types.d.ts.map +1 -0
  52. package/dist/reasoning/types.js +32 -0
  53. package/dist/toolformat/formatter.d.ts +3 -3
  54. package/dist/toolformat/formatter.d.ts.map +1 -1
  55. package/dist/tools/index.d.ts +2 -2
  56. package/dist/tools/index.d.ts.map +1 -1
  57. package/dist/tools/index.js +2 -2
  58. package/dist/tools/registry.d.ts +4 -4
  59. package/dist/tools/registry.d.ts.map +1 -1
  60. package/dist/tools/tool.d.ts +8 -1
  61. package/dist/tools/tool.d.ts.map +1 -1
  62. package/dist/tools/tool.js +7 -0
  63. package/package.json +17 -1
package/README.md CHANGED
@@ -43,3 +43,22 @@ Register only the wrapped handler with an agent framework or tool registry.
43
43
  Keep channel ingress, identity verification, delegated credentials, and
44
44
  domain-specific authorization in the host application. Agentware is not a
45
45
  policy engine; a policy gate can wrap this same boundary later.
46
+
47
+ ## Maintainer releases
48
+
49
+ Releases are deliberately manual and use npm staged publishing. Do not run
50
+ `npm publish` from a workstation or add a registry token to CI.
51
+
52
+ 1. Update `typescript/package.json` and `typescript/package-lock.json` to the
53
+ intended semantic version in a pull request, then merge it to `main`.
54
+ 2. In GitHub Actions, run **Stage Agentware npm package** from `main`, entering
55
+ that exact version (for example, `0.1.1`). The workflow verifies the version,
56
+ creates the immutable `agentware-v<version>` tag, runs checks, and submits
57
+ the package with `npm stage publish`.
58
+ 3. Approve the GitHub `release` environment when prompted.
59
+ 4. Review the staged package in npm and approve it. The approving maintainer
60
+ needs npm publish access and 2FA enabled for write actions; a WebAuthn
61
+ security key is supported.
62
+
63
+ The final npm approval is intentional: it is the human gate that makes the
64
+ staged version publicly available.
@@ -0,0 +1,50 @@
1
+ import type { AsyncBackend, Message, ToolDefinition } from "../llm/index.js";
2
+ import type { ToolRegistry } from "../tools/index.js";
3
+ import type { ResponseValidator } from "../middleware/guardrails/response_validator.js";
4
+ import { ErrorTracker, ErrorCategory } from "../middleware/guardrails/error_tracker.js";
5
+ import { StepEnforcer } from "../middleware/guardrails/step_enforcer.js";
6
+ import { ReasoningAdapter, type ContextTree } from "../reasoning/index.js";
7
+ export declare enum AgentTerminationReason {
8
+ COMPLETE = "complete",
9
+ MAX_ITERATIONS = "max_iterations",
10
+ NUDGES_EXHAUSTED = "nudges_exhausted",
11
+ ERROR = "error"
12
+ }
13
+ export interface AgentLoopConfig {
14
+ backend: AsyncBackend;
15
+ registry: ToolRegistry;
16
+ validator: ResponseValidator;
17
+ error_tracker?: ErrorTracker;
18
+ step_enforcer?: StepEnforcer;
19
+ max_iterations?: number;
20
+ max_nudges?: number;
21
+ require_tool_call?: boolean;
22
+ /** Optional reasoning adapter override for limits and registered model
23
+ * fields. */
24
+ reasoning?: ReasoningAdapter;
25
+ }
26
+ export interface AgentResult {
27
+ final_response: string;
28
+ iterations: number;
29
+ tool_calls_made: number;
30
+ nudges: number;
31
+ termination_reason: AgentTerminationReason;
32
+ conversation: Message[];
33
+ /** Normalized context tree for the last turn that carried reasoning
34
+ * (native reasoning_content and/or thinking tags). Null when no turn
35
+ * carried reasoning. Holds bounded summaries only; raw reasoning is never
36
+ * attached. */
37
+ reasoning_tree: ContextTree | null;
38
+ }
39
+ export declare function registryToolDefinitions(registry: ToolRegistry): ToolDefinition[];
40
+ export declare function categorizeError(message: string): ErrorCategory;
41
+ export declare class AgentLoop {
42
+ private readonly config;
43
+ private readonly maxIterations;
44
+ private readonly maxNudges;
45
+ constructor(config: AgentLoopConfig);
46
+ run(system_prompt: string, user_message: string, history?: Message[], session_id?: string): Promise<AgentResult>;
47
+ private validate;
48
+ private finish;
49
+ }
50
+ //# sourceMappingURL=agent_loop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent_loop.d.ts","sourceRoot":"","sources":["../../src/executor/agent_loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAG7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EACV,iBAAiB,EAElB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,YAAY,EACZ,aAAa,EACd,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAOzE,OAAO,EACL,gBAAgB,EAGhB,KAAK,WAAW,EACjB,MAAM,uBAAuB,CAAC;AAE/B,oBAAY,sBAAsB;IAChC,QAAQ,aAAa;IACrB,cAAc,mBAAmB;IACjC,gBAAgB,qBAAqB;IACrC,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;iBACa;IACb,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED,MAAM,WAAW,WAAW;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,sBAAsB,CAAC;IAC3C,YAAY,EAAE,OAAO,EAAE,CAAC;IACxB;;;mBAGe;IACf,cAAc,EAAE,WAAW,GAAG,IAAI,CAAC;CACpC;AAKD,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,YAAY,GACrB,cAAc,EAAE,CASlB;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CA0B9D;AAiBD,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,MAAM,EAAE,eAAe;IAU7B,GAAG,CACP,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,OAAO,EAAO,EACvB,UAAU,GAAE,MAAW,GACtB,OAAO,CAAC,WAAW,CAAC;IA2OvB,OAAO,CAAC,QAAQ;IAiBhB,OAAO,CAAC,MAAM;CAmBf"}
@@ -0,0 +1,255 @@
1
+ import { Role } from "../llm/index.js";
2
+ import { executeTool, Result } from "../tools/index.js";
3
+ import { ErrorCategory, } from "../middleware/guardrails/error_tracker.js";
4
+ import { NudgeKind, stepNudge, } from "../middleware/guardrails/nudge.js";
5
+ import { MessageType } from "../middleware/types.js";
6
+ import { ReasoningAdapter, ReasoningError, isContextTreeEmpty, } from "../reasoning/index.js";
7
+ export var AgentTerminationReason;
8
+ (function (AgentTerminationReason) {
9
+ AgentTerminationReason["COMPLETE"] = "complete";
10
+ AgentTerminationReason["MAX_ITERATIONS"] = "max_iterations";
11
+ AgentTerminationReason["NUDGES_EXHAUSTED"] = "nudges_exhausted";
12
+ AgentTerminationReason["ERROR"] = "error";
13
+ })(AgentTerminationReason || (AgentTerminationReason = {}));
14
+ // Default adapter strips and normalizes reasoning in the agent loop.
15
+ const defaultAdapter = new ReasoningAdapter();
16
+ export function registryToolDefinitions(registry) {
17
+ return registry.all().map((tool) => ({
18
+ name: tool.name,
19
+ description: tool.description,
20
+ input_schema: "inputSchema" in tool
21
+ ? tool.inputSchema()
22
+ : {},
23
+ }));
24
+ }
25
+ export function categorizeError(message) {
26
+ const m = message.toLowerCase();
27
+ if (m.includes("timeout") || m.includes("timed out")) {
28
+ return ErrorCategory.TIMEOUT;
29
+ }
30
+ if (m.includes("not found") || m.includes("unknown tool")) {
31
+ return ErrorCategory.NOT_FOUND;
32
+ }
33
+ if (m.includes("invalid arg") ||
34
+ m.includes("schema") ||
35
+ m.includes("validation")) {
36
+ return ErrorCategory.INVALID_ARGS;
37
+ }
38
+ if (m.includes("permission") ||
39
+ m.includes("denied") ||
40
+ m.includes("forbidden")) {
41
+ return ErrorCategory.PERMISSION;
42
+ }
43
+ if (m.includes("rate limit") || m.includes("rate_limit")) {
44
+ return ErrorCategory.RATE_LIMIT;
45
+ }
46
+ return ErrorCategory.UNKNOWN;
47
+ }
48
+ function nudgeMetaType(kind) {
49
+ switch (kind) {
50
+ case NudgeKind.STEP:
51
+ return MessageType.STEP_NUDGE;
52
+ case NudgeKind.PREREQUISITE:
53
+ return MessageType.PREREQUISITE_NUDGE;
54
+ default:
55
+ return MessageType.RETRY_NUDGE;
56
+ }
57
+ }
58
+ function toError(err) {
59
+ return err instanceof Error ? err : new Error(String(err));
60
+ }
61
+ export class AgentLoop {
62
+ config;
63
+ maxIterations;
64
+ maxNudges;
65
+ constructor(config) {
66
+ this.config = config;
67
+ this.maxIterations =
68
+ config.max_iterations && config.max_iterations > 0
69
+ ? config.max_iterations
70
+ : 20;
71
+ this.maxNudges =
72
+ config.max_nudges && config.max_nudges > 0 ? config.max_nudges : 3;
73
+ }
74
+ async run(system_prompt, user_message, history = [], session_id = "") {
75
+ // Cross-language contract: the system prompt leads the conversation,
76
+ // ahead of any caller-supplied history (mirrors Go buildConversation).
77
+ const conversation = [
78
+ { role: Role.SYSTEM, content: system_prompt },
79
+ ...history,
80
+ ];
81
+ conversation.push({ role: Role.USER, content: user_message });
82
+ const toolDefs = registryToolDefinitions(this.config.registry);
83
+ let iterations = 0;
84
+ let toolCallsMade = 0;
85
+ let nudges = 0;
86
+ let finalResponse = "";
87
+ let reasoningTree = null;
88
+ while (iterations < this.maxIterations) {
89
+ iterations++;
90
+ let resp;
91
+ try {
92
+ resp = await this.config.backend.complete(conversation, toolDefs);
93
+ }
94
+ catch (err) {
95
+ this.config.error_tracker?.recordError(session_id, "", {}, toError(err), ErrorCategory.UNKNOWN);
96
+ return this.finish(finalResponse, iterations, toolCallsMade, nudges, AgentTerminationReason.ERROR, conversation, reasoningTree);
97
+ }
98
+ // AR-1 parity: normalize reasoning and strip it before validation.
99
+ // Reasoning can arrive as a native reasoning_content field or as
100
+ // embedded thinking tags in content; both are combined into a synthetic
101
+ // structured input so the adapter sees the full picture. Malformed or
102
+ // unbounded reasoning fails closed: this turn is treated as invalid and
103
+ // retried rather than parsed partially.
104
+ let turnTree = null;
105
+ let cleanContent = resp.content;
106
+ let reasoningFailed = false;
107
+ if (resp.content || resp.reasoning) {
108
+ const reasoningInput = {
109
+ content: resp.content,
110
+ };
111
+ if (resp.reasoning) {
112
+ reasoningInput["reasoning_content"] = resp.reasoning;
113
+ }
114
+ const adapter = this.config.reasoning ?? defaultAdapter;
115
+ try {
116
+ turnTree = adapter.extract(reasoningInput, this.config.backend.modelName(), "agent-loop");
117
+ cleanContent = adapter.strip(reasoningInput);
118
+ }
119
+ catch (e) {
120
+ if (e instanceof ReasoningError) {
121
+ reasoningFailed = true;
122
+ // Fail closed: never echo content that may carry reasoning we
123
+ // could not parse.
124
+ cleanContent = "";
125
+ }
126
+ else {
127
+ throw e;
128
+ }
129
+ }
130
+ }
131
+ // Keep the last turn that actually carried reasoning; a later plain
132
+ // turn must not blank out the tree the consumer is after.
133
+ if (!isContextTreeEmpty(turnTree)) {
134
+ reasoningTree = turnTree;
135
+ }
136
+ const validation = reasoningFailed
137
+ ? { toolCalls: [], nudge: null, needsRetry: true }
138
+ : this.validate(resp, cleanContent);
139
+ if (validation.needsRetry) {
140
+ if (nudges >= this.maxNudges) {
141
+ return this.finish(cleanContent, iterations, toolCallsMade, nudges, AgentTerminationReason.NUDGES_EXHAUSTED, conversation, reasoningTree);
142
+ }
143
+ nudges++;
144
+ conversation.push({
145
+ role: Role.ASSISTANT,
146
+ content: cleanContent,
147
+ meta: { type: MessageType.TEXT_RESPONSE },
148
+ });
149
+ if (validation.nudge) {
150
+ conversation.push({
151
+ role: Role.USER,
152
+ content: validation.nudge.content,
153
+ meta: { type: nudgeMetaType(validation.nudge.kind) },
154
+ });
155
+ }
156
+ continue;
157
+ }
158
+ if (validation.toolCalls.length === 0) {
159
+ finalResponse = cleanContent;
160
+ return this.finish(finalResponse, iterations, toolCallsMade, nudges, AgentTerminationReason.COMPLETE, conversation, reasoningTree);
161
+ }
162
+ let stepNudged = false;
163
+ for (const call of validation.toolCalls) {
164
+ if (this.config.step_enforcer) {
165
+ const [allowed, missing] = this.config.step_enforcer.canExecute(session_id, call.tool);
166
+ if (!allowed) {
167
+ if (nudges >= this.maxNudges) {
168
+ return this.finish(cleanContent, iterations, toolCallsMade, nudges, AgentTerminationReason.NUDGES_EXHAUSTED, conversation, reasoningTree);
169
+ }
170
+ nudges++;
171
+ stepNudged = true;
172
+ const nudge = stepNudge(call.tool, missing, Math.min(3, nudges));
173
+ conversation.push({
174
+ role: Role.USER,
175
+ content: nudge.content,
176
+ meta: { type: MessageType.STEP_NUDGE },
177
+ });
178
+ continue;
179
+ }
180
+ }
181
+ if (this.config.error_tracker &&
182
+ this.config.error_tracker.shouldBlockTool(session_id, call.tool)) {
183
+ conversation.push({
184
+ role: Role.TOOL,
185
+ content: `Tool ${call.tool} error: blocked after repeated errors`,
186
+ meta: { type: MessageType.TOOL_RESULT },
187
+ });
188
+ continue;
189
+ }
190
+ const tool = this.config.registry.get(call.tool);
191
+ if (!tool) {
192
+ conversation.push({
193
+ role: Role.TOOL,
194
+ content: `Tool ${call.tool} error: unknown tool`,
195
+ meta: { type: MessageType.TOOL_RESULT },
196
+ });
197
+ continue;
198
+ }
199
+ toolCallsMade++;
200
+ let result;
201
+ try {
202
+ result = await executeTool(tool, call.args);
203
+ }
204
+ catch (err) {
205
+ result = new Result(false, null, toError(err).message);
206
+ }
207
+ if (result.success) {
208
+ this.config.step_enforcer?.markStepComplete(session_id, call.tool);
209
+ conversation.push({
210
+ role: Role.TOOL,
211
+ content: `Tool ${call.tool} result: ${JSON.stringify(result.data)}`,
212
+ meta: { type: MessageType.TOOL_RESULT },
213
+ });
214
+ }
215
+ else {
216
+ const message = result.error ?? "tool failed";
217
+ this.config.error_tracker?.recordError(session_id, call.tool, call.args, new Error(message), categorizeError(message));
218
+ conversation.push({
219
+ role: Role.TOOL,
220
+ content: `Tool ${call.tool} error: ${message}`,
221
+ meta: { type: MessageType.TOOL_RESULT },
222
+ });
223
+ }
224
+ }
225
+ if (stepNudged) {
226
+ continue;
227
+ }
228
+ }
229
+ return this.finish(finalResponse, iterations, toolCallsMade, nudges, AgentTerminationReason.MAX_ITERATIONS, conversation, reasoningTree);
230
+ }
231
+ validate(resp, cleanContent) {
232
+ if (resp.tool_calls.length > 0) {
233
+ return this.config.validator.validateToolCalls(resp.tool_calls.map((tc) => ({ tool: tc.name, args: tc.arguments })));
234
+ }
235
+ const textValidation = this.config.validator.validateTextResponse(cleanContent);
236
+ if (textValidation.toolCalls.length > 0) {
237
+ return textValidation;
238
+ }
239
+ if (this.config.require_tool_call) {
240
+ return textValidation;
241
+ }
242
+ return { toolCalls: [], nudge: null, needsRetry: false };
243
+ }
244
+ finish(finalResponse, iterations, toolCallsMade, nudges, termination, conversation, reasoningTree) {
245
+ return {
246
+ final_response: finalResponse,
247
+ iterations,
248
+ tool_calls_made: toolCallsMade,
249
+ nudges,
250
+ termination_reason: termination,
251
+ conversation,
252
+ reasoning_tree: reasoningTree,
253
+ };
254
+ }
255
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"executor.d.ts","sourceRoot":"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0B;gBAE5B,MAAM,EAAE,uBAAuB;IAQ3C,OAAO,CAAC,GAAG,EAAE,cAAc,GAAG,aAAa;CA+D5C"}
@@ -16,8 +16,12 @@ export class InferenceExecutor {
16
16
  };
17
17
  }
18
18
  execute(req) {
19
- const conversation = [...req.history];
20
- conversation.push({ role: Role.SYSTEM, content: req.system_prompt });
19
+ // Cross-language contract: the system prompt leads the conversation,
20
+ // ahead of any caller-supplied history (mirrors Go buildConversation).
21
+ const conversation = [
22
+ { role: Role.SYSTEM, content: req.system_prompt },
23
+ ...req.history,
24
+ ];
21
25
  conversation.push({ role: Role.USER, content: req.user_message });
22
26
  let iterations = 0;
23
27
  let tool_calls_made = 0;
@@ -1,2 +1,3 @@
1
- export { Executor, ExecuteRequest, ExecuteResult, TerminationReason, InferenceExecutor, InferenceExecutorConfig } from "./executor.js";
1
+ export { Executor, ExecuteRequest, ExecuteResult, TerminationReason, InferenceExecutor, InferenceExecutorConfig, } from "./executor.js";
2
+ export { AgentLoop, AgentLoopConfig, AgentResult, AgentTerminationReason, registryToolDefinitions, categorizeError, } from "./agent_loop.js";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/executor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/executor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EACT,eAAe,EACf,WAAW,EACX,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,GAChB,MAAM,iBAAiB,CAAC"}
@@ -1 +1,2 @@
1
- export { TerminationReason, InferenceExecutor } from "./executor.js";
1
+ export { TerminationReason, InferenceExecutor, } from "./executor.js";
2
+ export { AgentLoop, AgentTerminationReason, registryToolDefinitions, categorizeError, } from "./agent_loop.js";
package/dist/index.d.ts CHANGED
@@ -7,4 +7,6 @@ export * from "./llmcontext/index.js";
7
7
  export * from "./prompts/index.js";
8
8
  export * from "./toolformat/index.js";
9
9
  export * from "./memory/index.js";
10
+ export * from "./reasoning/index.js";
11
+ export * from "./kei/index.js";
10
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -7,3 +7,5 @@ export * from "./llmcontext/index.js";
7
7
  export * from "./prompts/index.js";
8
8
  export * from "./toolformat/index.js";
9
9
  export * from "./memory/index.js";
10
+ export * from "./reasoning/index.js";
11
+ export * from "./kei/index.js";
@@ -0,0 +1,2 @@
1
+ export * from "./runtimeLink.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/kei/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./runtimeLink.js";