wowok_agent 2.2.0 → 2.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.
package/dist/index.js CHANGED
@@ -143,7 +143,31 @@ function transformRewardData(data) {
143
143
  }
144
144
  return transformed;
145
145
  }
146
- const OnchainOperationsSchema = z.discriminatedUnion("operation_type", [
146
+ const OnchainOperationsSchema = z.preprocess((input) => {
147
+ if (typeof input === 'object' && input !== null) {
148
+ const obj = { ...input };
149
+ if (typeof obj.data === 'string') {
150
+ try {
151
+ obj.data = JSON.parse(obj.data);
152
+ }
153
+ catch { }
154
+ }
155
+ if (typeof obj.env === 'string') {
156
+ try {
157
+ obj.env = JSON.parse(obj.env);
158
+ }
159
+ catch { }
160
+ }
161
+ if (typeof obj.submission === 'string') {
162
+ try {
163
+ obj.submission = JSON.parse(obj.submission);
164
+ }
165
+ catch { }
166
+ }
167
+ return obj;
168
+ }
169
+ return input;
170
+ }, z.discriminatedUnion("operation_type", [
147
171
  z.object({
148
172
  operation_type: z.literal("service"),
149
173
  data: CallService_DataSchema,
@@ -236,8 +260,20 @@ const OnchainOperationsSchema = z.discriminatedUnion("operation_type", [
236
260
  info: SubmissionCallSchema.optional().describe("Optional submission data. If not provided, will attempt to get existing submissions from the guard."),
237
261
  env: CallEnvSchema.optional(),
238
262
  }).describe("🛂 Generate Verified Passport Object: Create immutable verified credentials after Guard validation passes."),
239
- ]);
240
- const WipOperationsSchema = z.discriminatedUnion("type", [
263
+ ]));
264
+ const WipOperationsSchema = z.preprocess((input) => {
265
+ if (typeof input === 'object' && input !== null) {
266
+ const obj = { ...input };
267
+ if (typeof obj.options === 'string') {
268
+ try {
269
+ obj.options = JSON.parse(obj.options);
270
+ }
271
+ catch { }
272
+ }
273
+ return obj;
274
+ }
275
+ return input;
276
+ }, z.discriminatedUnion("type", [
241
277
  z.object({
242
278
  type: z.literal("generate"),
243
279
  options: WipGenerationOptionsSchema.describe("WIP generation options"),
@@ -260,8 +296,22 @@ const WipOperationsSchema = z.discriminatedUnion("type", [
260
296
  wipPath: z.string().describe("WIP file path or directory path. Supports: 1) Single WIP file (e.g., '/path/to/file.wip'), 2) Directory containing .wip files (e.g., '/path/to/wips/'), 3) Network URL (e.g., 'https://example.com/doc.wip'). When directory is provided, all .wip files in the directory will be converted to HTML"),
261
297
  options: WipToHtmlOptionsSchema.optional().describe("Conversion options"),
262
298
  }).describe("Convert WIP file to HTML format"),
263
- ]);
264
- const WatchQueryOperationsSchema = z.discriminatedUnion("query_type", [
299
+ ]));
300
+ const WatchQueryOperationsSchema = z.preprocess((input) => {
301
+ if (typeof input === 'object' && input !== null) {
302
+ const obj = { ...input };
303
+ for (const key of ['filter', 'objects', 'env', 'token_type']) {
304
+ if (typeof obj[key] === 'string') {
305
+ try {
306
+ obj[key] = JSON.parse(obj[key]);
307
+ }
308
+ catch { }
309
+ }
310
+ }
311
+ return obj;
312
+ }
313
+ return input;
314
+ }, z.discriminatedUnion("query_type", [
265
315
  z.object({
266
316
  query_type: z.literal("local_mark_list"),
267
317
  filter: LocalMarkFilterSchema.optional().describe("Local mark filter"),
@@ -350,13 +400,10 @@ const WatchQueryOperationsSchema = z.discriminatedUnion("query_type", [
350
400
  object: z.string().describe("Object ID to query"),
351
401
  all_type: z.boolean().optional().describe("Whether to query all types of received objects"),
352
402
  }).describe("Query on-chain received balance, payments, and NFTs"),
353
- ]);
403
+ ]));
354
404
  async function handleOnchainOperations(args) {
355
- console.log("=== handleOnchainOperations ===");
356
- console.log("args:", JSON.stringify(args, null, 2));
357
405
  try {
358
406
  const validated = strictParse(OnchainOperationsSchema, args, "onchain_operations input");
359
- console.log("validated:", JSON.stringify(validated, null, 2));
360
407
  const env = getEnvConfig(validated.env);
361
408
  switch (validated.operation_type) {
362
409
  case "service": {
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { ENTRYPOINT } from "wowok";
3
- export declare function strictParse<T>(schema: z.ZodType<T>, input: unknown, fieldName?: string): T;
3
+ export declare function strictParse<T extends z.ZodTypeAny>(schema: T, input: unknown, fieldName?: string): z.infer<T>;
4
4
  export declare const NamedObjectSchema: z.ZodObject<{
5
5
  name: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
6
6
  tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -3,7 +3,11 @@ import { WowTransactionBlockResponseSchema } from "../local/index.js";
3
3
  import { BalanceTypeSchema, EntrypointSchema, ObjectBaseSchema, GuardTableItemSchema, NameSchema, NameOrAddressSchema, TokenTypeWithDefaultSchema } from "../common/index.js";
4
4
  import { ENTRYPOINT } from "wowok";
5
5
  export function strictParse(schema, input, fieldName = "input") {
6
- const shape = schema._def.shape?.();
6
+ let innerSchema = schema;
7
+ while (innerSchema._def?.typeName === 'ZodEffects') {
8
+ innerSchema = innerSchema._def.schema;
9
+ }
10
+ const shape = innerSchema._def.shape?.();
7
11
  if (!shape) {
8
12
  return schema.parse(input);
9
13
  }
@@ -276,14 +276,14 @@ export declare const NodeSchema: z.ZodDiscriminatedUnion<"op", [z.ZodObject<{
276
276
  guard: z.ZodOptional<z.ZodObject<{
277
277
  guard: z.ZodString;
278
278
  retained_submission: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
279
- }, "strip", z.ZodTypeAny, {
279
+ }, "strict", z.ZodTypeAny, {
280
280
  guard: string;
281
281
  retained_submission?: number[] | undefined;
282
282
  }, {
283
283
  guard: string;
284
284
  retained_submission?: number[] | undefined;
285
285
  }>>;
286
- }, "strip", z.ZodTypeAny, {
286
+ }, "strict", z.ZodTypeAny, {
287
287
  name: string;
288
288
  weight: number;
289
289
  guard?: {
@@ -302,7 +302,7 @@ export declare const NodeSchema: z.ZodDiscriminatedUnion<"op", [z.ZodObject<{
302
302
  namedOperator?: string | undefined;
303
303
  permissionIndex?: number | undefined;
304
304
  }>, "many">;
305
- }, "strip", z.ZodTypeAny, {
305
+ }, "strict", z.ZodTypeAny, {
306
306
  forwards: {
307
307
  name: string;
308
308
  weight: number;
@@ -329,7 +329,7 @@ export declare const NodeSchema: z.ZodDiscriminatedUnion<"op", [z.ZodObject<{
329
329
  threshold: number;
330
330
  prev_node: string;
331
331
  }>, "many">;
332
- }, "strip", z.ZodTypeAny, {
332
+ }, "strict", z.ZodTypeAny, {
333
333
  name: string;
334
334
  pairs: {
335
335
  forwards: {
@@ -418,14 +418,14 @@ export declare const NodeSchema: z.ZodDiscriminatedUnion<"op", [z.ZodObject<{
418
418
  guard: z.ZodOptional<z.ZodObject<{
419
419
  guard: z.ZodString;
420
420
  retained_submission: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
421
- }, "strip", z.ZodTypeAny, {
421
+ }, "strict", z.ZodTypeAny, {
422
422
  guard: string;
423
423
  retained_submission?: number[] | undefined;
424
424
  }, {
425
425
  guard: string;
426
426
  retained_submission?: number[] | undefined;
427
427
  }>>;
428
- }, "strip", z.ZodTypeAny, {
428
+ }, "strict", z.ZodTypeAny, {
429
429
  name: string;
430
430
  weight: number;
431
431
  guard?: {
@@ -444,7 +444,7 @@ export declare const NodeSchema: z.ZodDiscriminatedUnion<"op", [z.ZodObject<{
444
444
  namedOperator?: string | undefined;
445
445
  permissionIndex?: number | undefined;
446
446
  }>, "many">;
447
- }, "strip", z.ZodTypeAny, {
447
+ }, "strict", z.ZodTypeAny, {
448
448
  forwards: {
449
449
  name: string;
450
450
  weight: number;
@@ -471,7 +471,7 @@ export declare const NodeSchema: z.ZodDiscriminatedUnion<"op", [z.ZodObject<{
471
471
  threshold: number;
472
472
  prev_node: string;
473
473
  }>, "many">;
474
- }, "strip", z.ZodTypeAny, {
474
+ }, "strict", z.ZodTypeAny, {
475
475
  name: string;
476
476
  pairs: {
477
477
  forwards: {
@@ -729,14 +729,14 @@ export declare const NodeFieldSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"op",
729
729
  guard: z.ZodOptional<z.ZodObject<{
730
730
  guard: z.ZodString;
731
731
  retained_submission: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
732
- }, "strip", z.ZodTypeAny, {
732
+ }, "strict", z.ZodTypeAny, {
733
733
  guard: string;
734
734
  retained_submission?: number[] | undefined;
735
735
  }, {
736
736
  guard: string;
737
737
  retained_submission?: number[] | undefined;
738
738
  }>>;
739
- }, "strip", z.ZodTypeAny, {
739
+ }, "strict", z.ZodTypeAny, {
740
740
  name: string;
741
741
  weight: number;
742
742
  guard?: {
@@ -755,7 +755,7 @@ export declare const NodeFieldSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"op",
755
755
  namedOperator?: string | undefined;
756
756
  permissionIndex?: number | undefined;
757
757
  }>, "many">;
758
- }, "strip", z.ZodTypeAny, {
758
+ }, "strict", z.ZodTypeAny, {
759
759
  forwards: {
760
760
  name: string;
761
761
  weight: number;
@@ -782,7 +782,7 @@ export declare const NodeFieldSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"op",
782
782
  threshold: number;
783
783
  prev_node: string;
784
784
  }>, "many">;
785
- }, "strip", z.ZodTypeAny, {
785
+ }, "strict", z.ZodTypeAny, {
786
786
  name: string;
787
787
  pairs: {
788
788
  forwards: {
@@ -871,14 +871,14 @@ export declare const NodeFieldSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"op",
871
871
  guard: z.ZodOptional<z.ZodObject<{
872
872
  guard: z.ZodString;
873
873
  retained_submission: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
874
- }, "strip", z.ZodTypeAny, {
874
+ }, "strict", z.ZodTypeAny, {
875
875
  guard: string;
876
876
  retained_submission?: number[] | undefined;
877
877
  }, {
878
878
  guard: string;
879
879
  retained_submission?: number[] | undefined;
880
880
  }>>;
881
- }, "strip", z.ZodTypeAny, {
881
+ }, "strict", z.ZodTypeAny, {
882
882
  name: string;
883
883
  weight: number;
884
884
  guard?: {
@@ -897,7 +897,7 @@ export declare const NodeFieldSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"op",
897
897
  namedOperator?: string | undefined;
898
898
  permissionIndex?: number | undefined;
899
899
  }>, "many">;
900
- }, "strip", z.ZodTypeAny, {
900
+ }, "strict", z.ZodTypeAny, {
901
901
  forwards: {
902
902
  name: string;
903
903
  weight: number;
@@ -924,7 +924,7 @@ export declare const NodeFieldSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"op",
924
924
  threshold: number;
925
925
  prev_node: string;
926
926
  }>, "many">;
927
- }, "strip", z.ZodTypeAny, {
927
+ }, "strict", z.ZodTypeAny, {
928
928
  name: string;
929
929
  pairs: {
930
930
  forwards: {
@@ -1408,14 +1408,14 @@ export declare const CallMachine_DataSchema: z.ZodObject<{
1408
1408
  guard: z.ZodOptional<z.ZodObject<{
1409
1409
  guard: z.ZodString;
1410
1410
  retained_submission: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
1411
- }, "strip", z.ZodTypeAny, {
1411
+ }, "strict", z.ZodTypeAny, {
1412
1412
  guard: string;
1413
1413
  retained_submission?: number[] | undefined;
1414
1414
  }, {
1415
1415
  guard: string;
1416
1416
  retained_submission?: number[] | undefined;
1417
1417
  }>>;
1418
- }, "strip", z.ZodTypeAny, {
1418
+ }, "strict", z.ZodTypeAny, {
1419
1419
  name: string;
1420
1420
  weight: number;
1421
1421
  guard?: {
@@ -1434,7 +1434,7 @@ export declare const CallMachine_DataSchema: z.ZodObject<{
1434
1434
  namedOperator?: string | undefined;
1435
1435
  permissionIndex?: number | undefined;
1436
1436
  }>, "many">;
1437
- }, "strip", z.ZodTypeAny, {
1437
+ }, "strict", z.ZodTypeAny, {
1438
1438
  forwards: {
1439
1439
  name: string;
1440
1440
  weight: number;
@@ -1461,7 +1461,7 @@ export declare const CallMachine_DataSchema: z.ZodObject<{
1461
1461
  threshold: number;
1462
1462
  prev_node: string;
1463
1463
  }>, "many">;
1464
- }, "strip", z.ZodTypeAny, {
1464
+ }, "strict", z.ZodTypeAny, {
1465
1465
  name: string;
1466
1466
  pairs: {
1467
1467
  forwards: {
@@ -1550,14 +1550,14 @@ export declare const CallMachine_DataSchema: z.ZodObject<{
1550
1550
  guard: z.ZodOptional<z.ZodObject<{
1551
1551
  guard: z.ZodString;
1552
1552
  retained_submission: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
1553
- }, "strip", z.ZodTypeAny, {
1553
+ }, "strict", z.ZodTypeAny, {
1554
1554
  guard: string;
1555
1555
  retained_submission?: number[] | undefined;
1556
1556
  }, {
1557
1557
  guard: string;
1558
1558
  retained_submission?: number[] | undefined;
1559
1559
  }>>;
1560
- }, "strip", z.ZodTypeAny, {
1560
+ }, "strict", z.ZodTypeAny, {
1561
1561
  name: string;
1562
1562
  weight: number;
1563
1563
  guard?: {
@@ -1576,7 +1576,7 @@ export declare const CallMachine_DataSchema: z.ZodObject<{
1576
1576
  namedOperator?: string | undefined;
1577
1577
  permissionIndex?: number | undefined;
1578
1578
  }>, "many">;
1579
- }, "strip", z.ZodTypeAny, {
1579
+ }, "strict", z.ZodTypeAny, {
1580
1580
  forwards: {
1581
1581
  name: string;
1582
1582
  weight: number;
@@ -1603,7 +1603,7 @@ export declare const CallMachine_DataSchema: z.ZodObject<{
1603
1603
  threshold: number;
1604
1604
  prev_node: string;
1605
1605
  }>, "many">;
1606
- }, "strip", z.ZodTypeAny, {
1606
+ }, "strict", z.ZodTypeAny, {
1607
1607
  name: string;
1608
1608
  pairs: {
1609
1609
  forwards: {
@@ -2434,14 +2434,14 @@ export declare const CallMachine_InputSchema: z.ZodObject<{
2434
2434
  guard: z.ZodOptional<z.ZodObject<{
2435
2435
  guard: z.ZodString;
2436
2436
  retained_submission: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
2437
- }, "strip", z.ZodTypeAny, {
2437
+ }, "strict", z.ZodTypeAny, {
2438
2438
  guard: string;
2439
2439
  retained_submission?: number[] | undefined;
2440
2440
  }, {
2441
2441
  guard: string;
2442
2442
  retained_submission?: number[] | undefined;
2443
2443
  }>>;
2444
- }, "strip", z.ZodTypeAny, {
2444
+ }, "strict", z.ZodTypeAny, {
2445
2445
  name: string;
2446
2446
  weight: number;
2447
2447
  guard?: {
@@ -2460,7 +2460,7 @@ export declare const CallMachine_InputSchema: z.ZodObject<{
2460
2460
  namedOperator?: string | undefined;
2461
2461
  permissionIndex?: number | undefined;
2462
2462
  }>, "many">;
2463
- }, "strip", z.ZodTypeAny, {
2463
+ }, "strict", z.ZodTypeAny, {
2464
2464
  forwards: {
2465
2465
  name: string;
2466
2466
  weight: number;
@@ -2487,7 +2487,7 @@ export declare const CallMachine_InputSchema: z.ZodObject<{
2487
2487
  threshold: number;
2488
2488
  prev_node: string;
2489
2489
  }>, "many">;
2490
- }, "strip", z.ZodTypeAny, {
2490
+ }, "strict", z.ZodTypeAny, {
2491
2491
  name: string;
2492
2492
  pairs: {
2493
2493
  forwards: {
@@ -2576,14 +2576,14 @@ export declare const CallMachine_InputSchema: z.ZodObject<{
2576
2576
  guard: z.ZodOptional<z.ZodObject<{
2577
2577
  guard: z.ZodString;
2578
2578
  retained_submission: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
2579
- }, "strip", z.ZodTypeAny, {
2579
+ }, "strict", z.ZodTypeAny, {
2580
2580
  guard: string;
2581
2581
  retained_submission?: number[] | undefined;
2582
2582
  }, {
2583
2583
  guard: string;
2584
2584
  retained_submission?: number[] | undefined;
2585
2585
  }>>;
2586
- }, "strip", z.ZodTypeAny, {
2586
+ }, "strict", z.ZodTypeAny, {
2587
2587
  name: string;
2588
2588
  weight: number;
2589
2589
  guard?: {
@@ -2602,7 +2602,7 @@ export declare const CallMachine_InputSchema: z.ZodObject<{
2602
2602
  namedOperator?: string | undefined;
2603
2603
  permissionIndex?: number | undefined;
2604
2604
  }>, "many">;
2605
- }, "strip", z.ZodTypeAny, {
2605
+ }, "strict", z.ZodTypeAny, {
2606
2606
  forwards: {
2607
2607
  name: string;
2608
2608
  weight: number;
@@ -2629,7 +2629,7 @@ export declare const CallMachine_InputSchema: z.ZodObject<{
2629
2629
  threshold: number;
2630
2630
  prev_node: string;
2631
2631
  }>, "many">;
2632
- }, "strip", z.ZodTypeAny, {
2632
+ }, "strict", z.ZodTypeAny, {
2633
2633
  name: string;
2634
2634
  pairs: {
2635
2635
  forwards: {