llmz 0.0.35 → 0.0.36

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.
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-DOIKBDLR.js";
6
6
  import {
7
7
  Tool
8
- } from "./chunk-GXLMCQYF.js";
8
+ } from "./chunk-PUFOVD74.js";
9
9
  import {
10
10
  LoopExceededError
11
11
  } from "./chunk-WSVDMGMR.js";
@@ -415,8 +415,10 @@ var Tool = class _Tool {
415
415
  *
416
416
  * @internal This method is primarily used internally by the LLMz execution engine
417
417
  */
418
- async execute(input, ctx) {
418
+ async execute(rawInput, ctx) {
419
419
  var _a;
420
+ const isZodObject = this.zInput._def.typeName === "ZodObject";
421
+ const input = isZodObject ? rawInput ?? {} : rawInput;
420
422
  const pInput = this.zInput.safeParse(input);
421
423
  if (!pInput.success) {
422
424
  throw new Error(`Tool "${this.name}" received invalid input: ${pInput.error.message}`);
@@ -5,7 +5,7 @@
5
5
  var _chunkQRFGEFROcjs = require('./chunk-QRFGEFRO.cjs');
6
6
 
7
7
 
8
- var _chunkQR54TZ36cjs = require('./chunk-QR54TZ36.cjs');
8
+ var _chunkWP7SDPJ6cjs = require('./chunk-WP7SDPJ6.cjs');
9
9
 
10
10
 
11
11
  var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
@@ -1274,7 +1274,7 @@ var Context = (_class2 = class {
1274
1274
  var _a, _b;
1275
1275
  const instructions = await getValue(this.instructions, this);
1276
1276
  const transcript = new TranscriptArray(await getValue(_nullishCoalesce(((_a = this.chat) == null ? void 0 : _a.transcript), () => ( [])), this));
1277
- const tools = _chunkQR54TZ36cjs.Tool.withUniqueNames(await _asyncNullishCoalesce(await getValue(this.tools, this), async () => ( [])));
1277
+ const tools = _chunkWP7SDPJ6cjs.Tool.withUniqueNames(await _asyncNullishCoalesce(await getValue(this.tools, this), async () => ( [])));
1278
1278
  const objects = await _asyncNullishCoalesce(await getValue(this.objects, this), async () => ( []));
1279
1279
  const exits = await _asyncNullishCoalesce(await getValue(this.exits, this), async () => ( []));
1280
1280
  const components = await getValue(_nullishCoalesce(((_b = this.chat) == null ? void 0 : _b.components), () => ( [])), this);
@@ -1306,7 +1306,7 @@ var Context = (_class2 = class {
1306
1306
  "boolean",
1307
1307
  "array"
1308
1308
  ];
1309
- const MessageTool = this.chat && components.length ? new (0, _chunkQR54TZ36cjs.Tool)({
1309
+ const MessageTool = this.chat && components.length ? new (0, _chunkWP7SDPJ6cjs.Tool)({
1310
1310
  name: "Message",
1311
1311
  description: "Send a message to the user",
1312
1312
  aliases: Array.from(
@@ -415,8 +415,10 @@ var Tool = (_class = class _Tool {
415
415
  *
416
416
  * @internal This method is primarily used internally by the LLMz execution engine
417
417
  */
418
- async execute(input, ctx) {
418
+ async execute(rawInput, ctx) {
419
419
  var _a;
420
+ const isZodObject = this.zInput._def.typeName === "ZodObject";
421
+ const input = isZodObject ? _nullishCoalesce(rawInput, () => ( {})) : rawInput;
420
422
  const pInput = this.zInput.safeParse(input);
421
423
  if (!pInput.success) {
422
424
  throw new Error(`Tool "${this.name}" received invalid input: ${pInput.error.message}`);
package/dist/index.cjs CHANGED
@@ -9,11 +9,11 @@
9
9
 
10
10
 
11
11
 
12
- var _chunkB742DUFYcjs = require('./chunk-B742DUFY.cjs');
12
+ var _chunkRD3LPQOWcjs = require('./chunk-RD3LPQOW.cjs');
13
13
  require('./chunk-QRFGEFRO.cjs');
14
14
 
15
15
 
16
- var _chunkQR54TZ36cjs = require('./chunk-QR54TZ36.cjs');
16
+ var _chunkWP7SDPJ6cjs = require('./chunk-WP7SDPJ6.cjs');
17
17
 
18
18
 
19
19
 
@@ -428,7 +428,7 @@ var ObjectInstance = class {
428
428
  this.description = props.description;
429
429
  this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
430
430
  this.properties = props.properties;
431
- this.tools = _chunkQR54TZ36cjs.Tool.withUniqueNames(_nullishCoalesce(props.tools, () => ( [])));
431
+ this.tools = _chunkWP7SDPJ6cjs.Tool.withUniqueNames(_nullishCoalesce(props.tools, () => ( [])));
432
432
  }
433
433
  /**
434
434
  * Generates TypeScript namespace declarations for this object.
@@ -1112,13 +1112,13 @@ var utils = {
1112
1112
  truncateWrappedContent: _chunkGZPN7RGHcjs.truncateWrappedContent
1113
1113
  };
1114
1114
  var execute = async (props) => {
1115
- const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-XRJIDXIZ.cjs")));
1115
+ const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-I7RVUI6Q.cjs")));
1116
1116
  return executeContext(props);
1117
1117
  };
1118
1118
  var init = async () => {
1119
- await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-XRJIDXIZ.cjs")));
1119
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-I7RVUI6Q.cjs")));
1120
1120
  await Promise.resolve().then(() => _interopRequireWildcard(require("./component-AAEMNCHB.cjs")));
1121
- await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-JYXLFJGQ.cjs")));
1121
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-OC3QHJWX.cjs")));
1122
1122
  await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-XAYKJ6TR.cjs")));
1123
1123
  await Promise.resolve().then(() => _interopRequireWildcard(require("./jsx-AJAXBWFE.cjs")));
1124
1124
  await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-VFORKC54.cjs")));
@@ -1155,4 +1155,4 @@ var init = async () => {
1155
1155
 
1156
1156
 
1157
1157
 
1158
- exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkQY2TRWGKcjs.Component; exports.DefaultComponents = DefaultComponents; exports.DefaultExit = _chunkB742DUFYcjs.DefaultExit; exports.ErrorExecutionResult = _chunkB742DUFYcjs.ErrorExecutionResult; exports.ExecutionResult = _chunkB742DUFYcjs.ExecutionResult; exports.Exit = _chunk3G3BS5IAcjs.Exit; exports.ListenExit = _chunkB742DUFYcjs.ListenExit; exports.LoopExceededError = _chunkPK72FAKDcjs.LoopExceededError; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunkB742DUFYcjs.PartialExecutionResult; exports.Snapshot = _chunkB742DUFYcjs.Snapshot; exports.SnapshotSignal = _chunkPK72FAKDcjs.SnapshotSignal; exports.SuccessExecutionResult = _chunkB742DUFYcjs.SuccessExecutionResult; exports.ThinkExit = _chunkB742DUFYcjs.ThinkExit; exports.ThinkSignal = _chunkPK72FAKDcjs.ThinkSignal; exports.Tool = _chunkQR54TZ36cjs.Tool; exports.assertValidComponent = _chunkQY2TRWGKcjs.assertValidComponent; exports.execute = execute; exports.getValue = _chunkB742DUFYcjs.getValue; exports.init = init; exports.isAnyComponent = _chunkQY2TRWGKcjs.isAnyComponent; exports.isComponent = _chunkQY2TRWGKcjs.isComponent; exports.parseExit = _chunkB742DUFYcjs.parseExit; exports.renderToTsx = _chunkQY2TRWGKcjs.renderToTsx; exports.utils = utils;
1158
+ exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkQY2TRWGKcjs.Component; exports.DefaultComponents = DefaultComponents; exports.DefaultExit = _chunkRD3LPQOWcjs.DefaultExit; exports.ErrorExecutionResult = _chunkRD3LPQOWcjs.ErrorExecutionResult; exports.ExecutionResult = _chunkRD3LPQOWcjs.ExecutionResult; exports.Exit = _chunk3G3BS5IAcjs.Exit; exports.ListenExit = _chunkRD3LPQOWcjs.ListenExit; exports.LoopExceededError = _chunkPK72FAKDcjs.LoopExceededError; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunkRD3LPQOWcjs.PartialExecutionResult; exports.Snapshot = _chunkRD3LPQOWcjs.Snapshot; exports.SnapshotSignal = _chunkPK72FAKDcjs.SnapshotSignal; exports.SuccessExecutionResult = _chunkRD3LPQOWcjs.SuccessExecutionResult; exports.ThinkExit = _chunkRD3LPQOWcjs.ThinkExit; exports.ThinkSignal = _chunkPK72FAKDcjs.ThinkSignal; exports.Tool = _chunkWP7SDPJ6cjs.Tool; exports.assertValidComponent = _chunkQY2TRWGKcjs.assertValidComponent; exports.execute = execute; exports.getValue = _chunkRD3LPQOWcjs.getValue; exports.init = init; exports.isAnyComponent = _chunkQY2TRWGKcjs.isAnyComponent; exports.isComponent = _chunkQY2TRWGKcjs.isComponent; exports.parseExit = _chunkRD3LPQOWcjs.parseExit; exports.renderToTsx = _chunkQY2TRWGKcjs.renderToTsx; exports.utils = utils;
package/dist/index.js CHANGED
@@ -9,11 +9,11 @@ import {
9
9
  ThinkExit,
10
10
  getValue,
11
11
  parseExit
12
- } from "./chunk-RANA7NBF.js";
12
+ } from "./chunk-4KXGNHLO.js";
13
13
  import "./chunk-DOIKBDLR.js";
14
14
  import {
15
15
  Tool
16
- } from "./chunk-GXLMCQYF.js";
16
+ } from "./chunk-PUFOVD74.js";
17
17
  import {
18
18
  formatTypings,
19
19
  getTypings
@@ -1112,13 +1112,13 @@ var utils = {
1112
1112
  truncateWrappedContent
1113
1113
  };
1114
1114
  var execute = async (props) => {
1115
- const { executeContext } = await import("./llmz-NX2764TL.js");
1115
+ const { executeContext } = await import("./llmz-7KVW3LXE.js");
1116
1116
  return executeContext(props);
1117
1117
  };
1118
1118
  var init = async () => {
1119
- await import("./llmz-NX2764TL.js");
1119
+ await import("./llmz-7KVW3LXE.js");
1120
1120
  await import("./component-EOMTLA64.js");
1121
- await import("./tool-ADXBCB4R.js");
1121
+ await import("./tool-3YL3EY2R.js");
1122
1122
  await import("./exit-YLO7BY7Z.js");
1123
1123
  await import("./jsx-AEHVFB3L.js");
1124
1124
  await import("./vm-Y3WY2627.js");
@@ -8,9 +8,9 @@ import {
8
8
  Snapshot,
9
9
  SuccessExecutionResult,
10
10
  parseExit
11
- } from "./chunk-RANA7NBF.js";
11
+ } from "./chunk-4KXGNHLO.js";
12
12
  import "./chunk-DOIKBDLR.js";
13
- import "./chunk-GXLMCQYF.js";
13
+ import "./chunk-PUFOVD74.js";
14
14
  import "./chunk-B42FGPCX.js";
15
15
  import {
16
16
  AssignmentError,
@@ -8,9 +8,9 @@ var _chunk5FWOHMO4cjs = require('./chunk-5FWOHMO4.cjs');
8
8
 
9
9
 
10
10
 
11
- var _chunkB742DUFYcjs = require('./chunk-B742DUFY.cjs');
11
+ var _chunkRD3LPQOWcjs = require('./chunk-RD3LPQOW.cjs');
12
12
  require('./chunk-QRFGEFRO.cjs');
13
- require('./chunk-QR54TZ36.cjs');
13
+ require('./chunk-WP7SDPJ6.cjs');
14
14
  require('./chunk-KED57HR5.cjs');
15
15
 
16
16
 
@@ -109,7 +109,7 @@ var _executeContext = async (props) => {
109
109
  const client = _nullishCoalesce(props.client, () => ( new (0, _client.Client)()));
110
110
  const cognitive = _cognitive.Cognitive.isCognitiveClient(client) ? client : new (0, _cognitive.Cognitive)({ client });
111
111
  const cleanups = [];
112
- const ctx = new (0, _chunkB742DUFYcjs.Context)({
112
+ const ctx = new (0, _chunkRD3LPQOWcjs.Context)({
113
113
  chat: props.chat,
114
114
  instructions: props.instructions,
115
115
  objects: props.objects,
@@ -124,7 +124,7 @@ var _executeContext = async (props) => {
124
124
  try {
125
125
  while (true) {
126
126
  if (ctx.iterations.length >= ctx.loop) {
127
- return new (0, _chunkB742DUFYcjs.ErrorExecutionResult)(ctx, new (0, _chunkPK72FAKDcjs.LoopExceededError)());
127
+ return new (0, _chunkRD3LPQOWcjs.ErrorExecutionResult)(ctx, new (0, _chunkPK72FAKDcjs.LoopExceededError)());
128
128
  }
129
129
  const iteration = await ctx.nextIteration();
130
130
  try {
@@ -147,7 +147,7 @@ var _executeContext = async (props) => {
147
147
  reason: _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted"))
148
148
  }
149
149
  });
150
- return new (0, _chunkB742DUFYcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
150
+ return new (0, _chunkRD3LPQOWcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
151
151
  }
152
152
  cleanups.push(
153
153
  iteration.traces.onPush((traces) => {
@@ -183,25 +183,25 @@ var _executeContext = async (props) => {
183
183
  }
184
184
  if (iteration.status.type === "exit_success") {
185
185
  const exitName = iteration.status.exit_success.exit_name;
186
- return new (0, _chunkB742DUFYcjs.SuccessExecutionResult)(ctx, {
186
+ return new (0, _chunkRD3LPQOWcjs.SuccessExecutionResult)(ctx, {
187
187
  exit: iteration.exits.find((x) => x.name === exitName),
188
188
  result: iteration.status.exit_success.return_value
189
189
  });
190
190
  }
191
191
  if (iteration.status.type === "callback_requested") {
192
- return new (0, _chunkB742DUFYcjs.PartialExecutionResult)(
192
+ return new (0, _chunkRD3LPQOWcjs.PartialExecutionResult)(
193
193
  ctx,
194
194
  iteration.status.callback_requested.signal,
195
- _chunkB742DUFYcjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
195
+ _chunkRD3LPQOWcjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
196
196
  );
197
197
  }
198
198
  if (iteration.status.type === "thinking_requested" || iteration.status.type === "exit_error" || iteration.status.type === "execution_error" || iteration.status.type === "invalid_code_error") {
199
199
  continue;
200
200
  }
201
- return new (0, _chunkB742DUFYcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)));
201
+ return new (0, _chunkRD3LPQOWcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)));
202
202
  }
203
203
  } catch (error) {
204
- return new (0, _chunkB742DUFYcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
204
+ return new (0, _chunkRD3LPQOWcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
205
205
  } finally {
206
206
  for (const cleanup of cleanups) {
207
207
  try {
@@ -474,7 +474,7 @@ var executeIteration = async ({
474
474
  }
475
475
  });
476
476
  }
477
- const parsedExit = _chunkB742DUFYcjs.parseExit.call(void 0, returnValue, iteration.exits);
477
+ const parsedExit = _chunkRD3LPQOWcjs.parseExit.call(void 0, returnValue, iteration.exits);
478
478
  if (!parsedExit.success) {
479
479
  return iteration.end({
480
480
  type: "exit_error",
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Tool
3
- } from "./chunk-GXLMCQYF.js";
3
+ } from "./chunk-PUFOVD74.js";
4
4
  import "./chunk-B42FGPCX.js";
5
5
  import "./chunk-WSVDMGMR.js";
6
6
  import "./chunk-YEAWWJSJ.js";
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkQR54TZ36cjs = require('./chunk-QR54TZ36.cjs');
3
+ var _chunkWP7SDPJ6cjs = require('./chunk-WP7SDPJ6.cjs');
4
4
  require('./chunk-KED57HR5.cjs');
5
5
  require('./chunk-PK72FAKD.cjs');
6
6
  require('./chunk-KIN7Y247.cjs');
@@ -8,4 +8,4 @@ require('./chunk-WHNOR4ZU.cjs');
8
8
  require('./chunk-UQOBUJIQ.cjs');
9
9
 
10
10
 
11
- exports.Tool = _chunkQR54TZ36cjs.Tool;
11
+ exports.Tool = _chunkWP7SDPJ6cjs.Tool;
package/dist/tool.d.ts CHANGED
@@ -464,7 +464,7 @@ export declare class Tool<I extends ZuiType = ZuiType, O extends ZuiType = ZuiTy
464
464
  *
465
465
  * @internal This method is primarily used internally by the LLMz execution engine
466
466
  */
467
- execute(input: TypeOf<I>, ctx: ToolCallContext): Promise<TypeOf<O>>;
467
+ execute(rawInput: TypeOf<I>, ctx: ToolCallContext): Promise<TypeOf<O>>;
468
468
  /**
469
469
  * Generates TypeScript type definitions for this tool.
470
470
  *
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "llmz",
3
3
  "type": "module",
4
4
  "description": "LLMz – An LLM-native Typescript VM built on top of Zui",
5
- "version": "0.0.35",
5
+ "version": "0.0.36",
6
6
  "types": "./dist/index.d.ts",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.js",