@wowok/agent-mcp 2.6.0 → 2.6.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/README.md +5 -3
- package/dist/extensions/capability-manifest.d.ts +125 -0
- package/dist/extensions/capability-manifest.js +594 -0
- package/dist/extensions/constraint-registry.d.ts +24 -0
- package/dist/extensions/constraint-registry.js +196 -0
- package/dist/extensions/index.d.ts +12 -0
- package/dist/extensions/index.js +6 -0
- package/dist/extensions/metric-registry.d.ts +26 -0
- package/dist/extensions/metric-registry.js +257 -0
- package/dist/extensions/mode-evaluator.d.ts +15 -0
- package/dist/extensions/mode-evaluator.js +170 -0
- package/dist/extensions/modes.d.ts +2 -0
- package/dist/extensions/modes.js +407 -0
- package/dist/extensions/registry.d.ts +48 -0
- package/dist/extensions/registry.js +629 -0
- package/dist/extensions/types.d.ts +218 -0
- package/dist/extensions/types.js +1 -0
- package/dist/knowledge/deployment-scanner.d.ts +3 -0
- package/dist/knowledge/deployment-scanner.js +64 -3
- package/dist/knowledge/guard-risk.d.ts +13 -0
- package/dist/knowledge/guard-risk.js +57 -0
- package/dist/knowledge/guard-templates.js +278 -0
- package/dist/knowledge/machine-templates.js +20 -1
- package/dist/knowledge/service-confirm.d.ts +14 -5
- package/dist/knowledge/service-confirm.js +116 -8
- package/dist/knowledge/tool-constraints.js +6 -2
- package/dist/project/deployment-bridge.d.ts +1 -1
- package/dist/project/deployment-bridge.js +27 -4
- package/dist/project/deployment-doc.d.ts +3 -0
- package/dist/project/deployment-doc.js +72 -10
- package/dist/project/evaluation.d.ts +2 -0
- package/dist/project/evaluation.js +569 -84
- package/dist/project/graph-builder.d.ts +4 -1
- package/dist/project/graph-builder.js +126 -61
- package/dist/project/graph.d.ts +1 -0
- package/dist/project/handlers.d.ts +219 -5
- package/dist/project/handlers.js +819 -9
- package/dist/project/stage-gate.d.ts +4 -0
- package/dist/project/stage-gate.js +64 -5
- package/dist/project/task-tracker.d.ts +26 -0
- package/dist/project/task-tracker.js +78 -0
- package/dist/safety/preview.js +16 -0
- package/dist/schema/call/allocation.d.ts +16 -16
- package/dist/schema/call/base.d.ts +21 -13
- package/dist/schema/call/base.js +27 -6
- package/dist/schema/call/bridge.d.ts +5 -5
- package/dist/schema/call/bridge.js +3 -1
- package/dist/schema/call/demand.d.ts +23 -31
- package/dist/schema/call/guard.js +1 -1
- package/dist/schema/call/machine.d.ts +402 -376
- package/dist/schema/call/order.d.ts +149 -228
- package/dist/schema/call/order.js +7 -3
- package/dist/schema/call/payment.d.ts +183 -3
- package/dist/schema/call/payment.js +21 -3
- package/dist/schema/call/personal.d.ts +241 -52
- package/dist/schema/call/progress.d.ts +53 -61
- package/dist/schema/call/progress.js +18 -4
- package/dist/schema/call/repository.d.ts +23 -31
- package/dist/schema/call/semantic.d.ts +1 -1
- package/dist/schema/call/semantic.js +30 -1
- package/dist/schema/call/service.d.ts +95 -119
- package/dist/schema/call/service.js +22 -1
- package/dist/schema/common/index.d.ts +11 -2
- package/dist/schema/common/index.js +43 -14
- package/dist/schema/local/index.d.ts +32 -35
- package/dist/schema/local/index.js +23 -5
- package/dist/schema/messenger/index.d.ts +274 -46
- package/dist/schema/operations.d.ts +680 -539
- package/dist/schema/operations.js +22 -0
- package/dist/schema/project/index.d.ts +1796 -80
- package/dist/schema/project/index.js +304 -14
- package/dist/schema/query/index.d.ts +705 -349
- package/dist/schema/query/index.js +164 -31
- package/dist/schema/schema-query/index.d.ts +15 -3
- package/dist/schema/schema-query/index.js +23 -5
- package/dist/schema/utils/node-parser.js +7 -4
- package/dist/schema-query/index.d.ts +7 -1
- package/dist/schema-query/index.js +204 -4
- package/dist/schemas/account_operation.output.json +7 -1
- package/dist/schemas/account_operation.schema.json +2 -2
- package/dist/schemas/bridge_operation.output.json +6 -0
- package/dist/schemas/bridge_operation.schema.json +1 -1
- package/dist/schemas/guard-templates.json +379 -0
- package/dist/schemas/guard2file.schema.json +1 -1
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/local_info_operation.output.json +6 -0
- package/dist/schemas/local_mark_operation.output.json +7 -1
- package/dist/schemas/local_mark_operation.schema.json +1 -1
- package/dist/schemas/machineNode2file.schema.json +1 -1
- package/dist/schemas/messenger_operation.schema.json +4 -4
- package/dist/schemas/onchain_events.output.json +1 -1
- package/dist/schemas/onchain_operations.schema.json +348 -296
- package/dist/schemas/onchain_operations_allocation.schema.json +34 -25
- package/dist/schemas/onchain_operations_arbitration.schema.json +8 -8
- package/dist/schemas/onchain_operations_contact.schema.json +8 -8
- package/dist/schemas/onchain_operations_demand.schema.json +8 -8
- package/dist/schemas/onchain_operations_gen_passport.schema.json +14 -14
- package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -2
- package/dist/schemas/onchain_operations_guard.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +41 -33
- package/dist/schemas/onchain_operations_order.schema.json +71 -77
- package/dist/schemas/onchain_operations_payment.schema.json +141 -111
- package/dist/schemas/onchain_operations_permission.schema.json +2 -2
- package/dist/schemas/onchain_operations_personal.schema.json +7 -7
- package/dist/schemas/onchain_operations_progress.schema.json +8 -8
- package/dist/schemas/onchain_operations_proof.schema.json +7 -7
- package/dist/schemas/onchain_operations_repository.schema.json +8 -8
- package/dist/schemas/onchain_operations_reward.schema.json +10 -10
- package/dist/schemas/onchain_operations_service.schema.json +46 -35
- package/dist/schemas/onchain_operations_treasury.schema.json +8 -8
- package/dist/schemas/onchain_table_data.output.json +33 -25
- package/dist/schemas/onchain_table_data.schema.json +12 -12
- package/dist/schemas/project_operation.output.json +1175 -23
- package/dist/schemas/project_operation.schema.json +40 -4
- package/dist/schemas/query_toolkit.output.json +104 -76
- package/dist/schemas/query_toolkit.schema.json +9 -9
- package/dist/schemas/schema_query.output.json +7 -3
- package/dist/schemas/schema_query.schema.json +17 -3
- package/dist/tools/handlers/local.js +20 -5
- package/dist/tools/handlers/onchain.js +23 -0
- package/dist/tools/handlers/project.js +52 -3
- package/dist/tools/handlers/query.js +27 -0
- package/dist/tools/handlers/schema-query.js +19 -0
- package/dist/tools/handlers/task-status.d.ts +170 -0
- package/dist/tools/handlers/task-status.js +55 -0
- package/dist/tools/handlers/wip.js +47 -1
- package/dist/tools/index.js +211 -7
- package/dist/tools/retry.d.ts +8 -0
- package/dist/tools/retry.js +85 -0
- package/dist/tools/wip-deploy-assist.d.ts +28 -0
- package/dist/tools/wip-deploy-assist.js +278 -0
- package/package.json +2 -2
- package/dist/schemas/guard-node-examples.md +0 -199
|
@@ -5,14 +5,23 @@ import { SemanticSummarySchema } from "../call/index.js";
|
|
|
5
5
|
import { isValidPermissionIndex } from '../utils/permission-index-utils.js';
|
|
6
6
|
import { isValidGuardQueryId, isValidGuardQueryIdOrName, isValidWitnessType } from '../utils/guard-query-utils.js';
|
|
7
7
|
import { ENTITY_LINKER_ADDRESS, ENTITY_REGISTRAR_ADDRESS, isWitnessType, } from "@wowok/wowok";
|
|
8
|
-
import { DiscountType as WDiscountType } from "@wowok/wowok";
|
|
9
8
|
import { QueryEnvSchema } from "../common/index.js";
|
|
10
9
|
const MAX_MULTI_OPERANDS = 8;
|
|
11
10
|
const VALUE_TYPE_DESCRIPTION = "Value type: can be specified as a string name (e.g., 'U64', 'Address', 'String') or a number (0-18). Supported types: Bool=0/'Bool', Address=1/'Address', String=2/'String', U8=3/'U8', U16=4/'U16', U32=5/'U32', U64=6/'U64', U128=7/'U128', U256=8/'U256', VecBool=9/'VecBool', VecAddress=10/'VecAddress', VecString=11/'VecString', VecU8=12/'VecU8', VecU16=13/'VecU16', VecU32=14/'VecU32', VecU64=15/'VecU64', VecU128=16/'VecU128', VecU256=17/'VecU256', VecVecU8=18/'VecVecU8'. Note: Value=19 is an INTERNAL type for wowok system use only and should NOT be used directly by users. String format is recommended for better readability.";
|
|
12
11
|
const tolerantNumber = z.union([z.number(), z.string()]);
|
|
13
12
|
const tolerantStringNullable = z.union([z.string(), z.null(), z.undefined()]);
|
|
14
13
|
const tolerantNumberNullable = z.union([z.number(), z.string(), z.null(), z.undefined()]);
|
|
15
|
-
export const AmountTypeSchema = z.
|
|
14
|
+
export const AmountTypeSchema = z.union([
|
|
15
|
+
z.enum(["GuardU64Identifier", "Fixed"]),
|
|
16
|
+
z.number().int().min(0).max(1).transform((n) => n === 0 ? "GuardU64Identifier" :
|
|
17
|
+
n === 1 ? "Fixed" :
|
|
18
|
+
"GuardU64Identifier"),
|
|
19
|
+
]).describe("Amount type — determines how a payment amount is resolved. " +
|
|
20
|
+
"Accepts string ('GuardU64Identifier' or 'Fixed') or number (0='GuardU64Identifier', 1='Fixed'). String form is recommended for readability. " +
|
|
21
|
+
"• 'GuardU64Identifier' (0): the amount is NOT fixed — it is dynamically read from a U64 value stored in the Guard table at the specified Identifier index. Use this when the amount varies per order (e.g. milestone-based pricing, negotiated price). The Guard must have a matching U64 entry. " +
|
|
22
|
+
"• 'Fixed' (1): the amount is a fixed value set in the sale/price field. Use this for products with a static price (e.g. service fee = 50 SUI). " +
|
|
23
|
+
"Example: {price: 50000000000, stock: 100, amount_type: 'Fixed'} → fixed 50 SUI price. " +
|
|
24
|
+
"Example: {price: 0, stock: 100, amount_type: 'GuardU64Identifier'} → price read from Guard table U64 entry.");
|
|
16
25
|
export const GuardQuerySchema = z.object({
|
|
17
26
|
id: QueryIdSchema,
|
|
18
27
|
name: z.string().describe("Name of the query instruction."),
|
|
@@ -29,9 +38,13 @@ export const GuardSubmissionSchema = z.object({
|
|
|
29
38
|
}).describe("Guard submission");
|
|
30
39
|
export const RecipientSchema = z.union([
|
|
31
40
|
z.object({ GuardIdentifier: GuardIdentifierSchema }).describe("Guard verified recipient ID. Get recipient ID from specified data index in Guard table. The ID must be of address type."),
|
|
32
|
-
z.object({ Entity: AccountOrMark_AddressSchema }).describe("
|
|
41
|
+
z.object({ Entity: AccountOrMark_AddressSchema }).describe("Static address resolved via LocalMark. " +
|
|
42
|
+
"Format: {Entity: {name_or_address: 'mark_name'}} — NOTE: Entity is an OBJECT with name_or_address field, NOT a bare string."),
|
|
33
43
|
z.object({ Signer: z.literal("signer") }).describe("Current transaction signer ID"),
|
|
34
|
-
]).describe("Recipient ID"
|
|
44
|
+
]).describe("Recipient ID. Three forms:\n" +
|
|
45
|
+
" - {GuardIdentifier: u8} — resolved from Passport at allocation time\n" +
|
|
46
|
+
" - {Entity: {name_or_address: 'mark_name'}} — static address via LocalMark (recommended)\n" +
|
|
47
|
+
" - {Signer: 'signer'} — transaction sender (e.g. self-refund)");
|
|
35
48
|
export const RecordsInEntitySchema = z.object({
|
|
36
49
|
name: z.string().describe("Record name"),
|
|
37
50
|
value_type: ValueTypeSchema.describe("Value type"),
|
|
@@ -104,8 +117,11 @@ export const ServiceSaleSchema = z.object({
|
|
|
104
117
|
price: BalanceTypeSchema.describe("Price of the product or service"),
|
|
105
118
|
stock: BalanceTypeSchema.describe("Stock of the product or service"),
|
|
106
119
|
suspension: z.boolean().describe("Whether sale is suspended"),
|
|
107
|
-
wip: z.string().describe("
|
|
108
|
-
|
|
120
|
+
wip: z.string().describe("WIP file URL. EMPTY string \"\" skips verification (TESTING ONLY). " +
|
|
121
|
+
"Production MUST use a real HTTP URL pointing to a .wip file generated by the wip_file tool. " +
|
|
122
|
+
"Example: \"https://cdn.example.com/products/phone_v1.wip\""),
|
|
123
|
+
wip_hash: z.string().describe("WIP file hash (hex string). EMPTY string \"\" skips hash comparison (TESTING ONLY). " +
|
|
124
|
+
"Production: fill with the hash you saw when viewing the product, to prevent merchant replacing the WIP file before order."),
|
|
109
125
|
}).describe("Service sale");
|
|
110
126
|
export const PurchasedItemSchema = z.object({
|
|
111
127
|
name: LongNameSchema.describe("Name of the product or service"),
|
|
@@ -182,23 +198,91 @@ export const ObjectRewardSchema = ObjectBaseSchema.extend({
|
|
|
182
198
|
um: z.union([z.string(), z.null()]).describe("Contact object"),
|
|
183
199
|
permission: z.string().describe("Permission object ID"),
|
|
184
200
|
}).describe("Reward object");
|
|
185
|
-
export const AllocationModeSchema = z.
|
|
201
|
+
export const AllocationModeSchema = z.union([
|
|
202
|
+
z.enum(["Amount", "Rate", "Surplus"]),
|
|
203
|
+
z.number().int().min(0).max(2).transform((n) => n === 0 ? "Amount" :
|
|
204
|
+
n === 1 ? "Rate" :
|
|
205
|
+
n === 2 ? "Surplus" :
|
|
206
|
+
"Amount"),
|
|
207
|
+
]).describe("Allocation mode — determines how the `sharing` field is interpreted. " +
|
|
208
|
+
"Three modes can be used individually OR combined within a single Allocator; " +
|
|
209
|
+
"when combined, allocation order is strictly: Amount first, then Rate, then Surplus. " +
|
|
210
|
+
"Understanding these modes allows modeling almost any fund distribution pattern.\n" +
|
|
211
|
+
"• Amount (0): `sharing` is a FIXED amount in smallest unit (e.g., '750000000' = 0.75 WOW). " +
|
|
212
|
+
"Allocated FIRST; sum of all Amount items is cached as `fix` by the contract. " +
|
|
213
|
+
"Validation: when no Rate and no Surplus items exist, sum of Amount items must be >= allocators.threshold (EAMOUNT_BELOW_THRESHOLD=12); " +
|
|
214
|
+
"when `max` is set, sum of Amount items must be <= max (EAMOUNT_EXCEEDS_MAX=13).\n" +
|
|
215
|
+
"• Rate (1): `sharing` is a basis-points rate (10000 = 100%). " +
|
|
216
|
+
"Allocated AFTER Amount; formula: allocated = (sharing × total_rates) / 10000, " +
|
|
217
|
+
"where total_rates = balance - fix (or max - fix if `max` is set). " +
|
|
218
|
+
"Validation: when no Surplus items exist, sum of all Rate items must be EXACTLY 10000 (ERATE_NOT_10000=4); " +
|
|
219
|
+
"when Surplus items exist, sum of all Rate items must be <= 10000 (ERATE_EXCEEDS_10000=6).\n" +
|
|
220
|
+
"• Surplus (2): `sharing` is IGNORED (contract forces it to 0). " +
|
|
221
|
+
"Allocated LAST; receives the remaining balance after Amount + Rate allocations. " +
|
|
222
|
+
"Validation: MAX ONE Surplus item per Allocator (EMULTIPLE_SURPLUS=5). " +
|
|
223
|
+
"When Surplus exists, Rate sum constraint relaxes from == 10000 to <= 10000.\n" +
|
|
224
|
+
"ALLOCATION ORDER (strict): Amount items (fixed, cached as fix) → Rate items (proportional to balance-fix) → Surplus item (remaining).\n" +
|
|
225
|
+
"RECOMMENDATION: Use Amount mode for known fixed amounts (clearer, no sum constraint). " +
|
|
226
|
+
"Use Rate mode for proportional splits (requires sum == 10000 unless Surplus present). " +
|
|
227
|
+
"Use Surplus to capture remainder (e.g., platform fee + host gets rest). " +
|
|
228
|
+
"Accepts string ('Amount'/'Rate'/'Surplus', recommended) or number (0/1/2).");
|
|
186
229
|
export const AllocationSharingSchema = z.object({
|
|
187
|
-
who: RecipientSchema.describe("Recipient
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
230
|
+
who: RecipientSchema.describe("Recipient of this allocation. Three forms:\n" +
|
|
231
|
+
"• { GuardIdentifier: u8 } — resolved from Passport at allocation time. " +
|
|
232
|
+
"Use 0 for Order owner in Service-integrated mode (Customer who created the Order). " +
|
|
233
|
+
"The identifier must match a Guard table entry with b_submission=true. " +
|
|
234
|
+
"If Passport has no matching submission, contract aborts with E_VERIFY_FAILED.\n" +
|
|
235
|
+
"• { Entity: { name_or_address: '...' } } — static address resolved via LocalMark. " +
|
|
236
|
+
"Use for known recipients (e.g., 'turo_host', or a Treasury object address).\n" +
|
|
237
|
+
"• 'Signer' — the transaction sender (tx_context::sender). " +
|
|
238
|
+
"Use when the recipient is the current signer (e.g., self-refund scenarios)."),
|
|
239
|
+
sharing: BalanceTypeSchema.describe("Allocation value. SEMANTICS DEPEND ON `mode`:\n" +
|
|
240
|
+
"• mode='Amount': absolute amount in smallest unit (e.g., '750000000' for 0.75 WOW, '250000000' for 0.25 WOW). " +
|
|
241
|
+
"Allocated first; sum of Amount items cached as `fix`.\n" +
|
|
242
|
+
"• mode='Rate': basis-points rate, 10000 = 100% (e.g., '7500' for 75%, '2500' for 25%). " +
|
|
243
|
+
"When no Surplus in same Allocator, sum MUST == 10000; when Surplus present, sum MUST <= 10000.\n" +
|
|
244
|
+
"• mode='Surplus': IGNORED (contract forces to 0). Set to '0' for clarity. " +
|
|
245
|
+
"Receives remaining balance after Amount + Rate allocations."),
|
|
246
|
+
mode: AllocationModeSchema,
|
|
247
|
+
}).describe("Fund allocation item — one recipient's share of the Allocation balance. " +
|
|
248
|
+
"The `sharing` value's meaning depends on `mode` (see AllocationModeSchema). " +
|
|
249
|
+
"Multiple items in the same Allocator are evaluated together: Amount items first, Rate items second, Surplus last.");
|
|
191
250
|
export const AllocatorSchema = z.object({
|
|
192
|
-
guard: NameOrAddressSchema.describe("Guard object ID. If Guard verification passes, fund allocation
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
251
|
+
guard: NameOrAddressSchema.describe("Guard object ID or name. If Guard verification passes (via Passport), fund allocation for THIS Allocator fires. " +
|
|
252
|
+
"Each Allocator in an Allocators list can have a different Guard — the first Allocator whose Guard returns true wins. " +
|
|
253
|
+
"This enables mutually exclusive allocation paths (e.g., refund Guard on 'return_approved' node vs damage Guard on 'damage_confirmed' node)."),
|
|
254
|
+
sharing: z.array(AllocationSharingSchema).describe("Fund allocation item list. Each item specifies a recipient (who), a value (sharing), and a mode. " +
|
|
255
|
+
"Items can mix modes (Amount + Rate + Surplus) within the same Allocator. " +
|
|
256
|
+
"ALLOCATION ORDER: Amount items first (cached as fix) → Rate items (proportional to balance - fix) → Surplus item (remaining). " +
|
|
257
|
+
"CONSTRAINTS: max ONE Surplus item per Allocator; Rate sum must == 10000 (no Surplus) or <= 10000 (with Surplus); " +
|
|
258
|
+
"Amount sum must >= threshold (no Rate and no Surplus) and <= max (if max set)."),
|
|
259
|
+
fix: BalanceTypeSchema.optional().describe("OUTPUT-ONLY (query result). Cached sum of all Amount-mode `sharing` values in this Allocator. " +
|
|
260
|
+
"Computed by the contract during `allocator_add` — DO NOT set this field at creation. " +
|
|
261
|
+
"Used internally to compute `total_rates = balance - fix` for Rate allocation."),
|
|
262
|
+
max: z.union([BalanceTypeSchema, z.null()]).optional().describe("Maximum allocation cap (optional). Has THREE effects:\n" +
|
|
263
|
+
"1. Construction: sum of Amount items must be <= max (EAMOUNT_EXCEEDS_MAX=13)\n" +
|
|
264
|
+
"2. Rate execution: total_rates = max - fix (instead of balance - fix)\n" +
|
|
265
|
+
"3. Surplus execution: surplus_amount = max - alloced_amount (instead of balance - alloced_amount)\n" +
|
|
266
|
+
"Use when you want to cap total allocation regardless of Order balance (e.g., cap payout to declared amount)."),
|
|
267
|
+
}).describe("Fund allocator — a complete allocation strategy triggered by a Guard. " +
|
|
268
|
+
"Contains a sharing[] array where items can mix Amount/Rate/Surplus modes. " +
|
|
269
|
+
"When the Guard passes, the contract allocates funds in strict order: Amount → Rate → Surplus.");
|
|
197
270
|
export const AllocatorsSchema = z.object({
|
|
198
271
|
description: DescriptionSchema.describe("Description of fund allocator list"),
|
|
199
|
-
threshold: BalanceTypeSchema.default(0).describe("
|
|
200
|
-
|
|
201
|
-
|
|
272
|
+
threshold: BalanceTypeSchema.default(0).describe("Minimum balance required for allocation to fire. " +
|
|
273
|
+
"When the Allocation object's balance < threshold, allocation aborts with EINSUFFICIENT_BALANCE=7. " +
|
|
274
|
+
"Also: when an Allocator has only Amount items (no Rate, no Surplus), the sum of Amount items must be >= threshold (EAMOUNT_BELOW_THRESHOLD=12). " +
|
|
275
|
+
"Set to 0 (default) to allow any balance."),
|
|
276
|
+
allocators: z.array(AllocatorSchema).describe("Fund allocator list. Each allocator is evaluated in order; the FIRST allocator whose Guard passes wins. " +
|
|
277
|
+
"This enables mutually exclusive allocation paths (e.g., 3 allocators for 3 forward paths: refund / damage-deduct / arbitrate)."),
|
|
278
|
+
}).describe("Fund allocator list — the top-level allocation configuration attached to an Order. " +
|
|
279
|
+
"Contains a threshold and a list of Allocators. When funds arrive at the Order, " +
|
|
280
|
+
"the first Allocator whose Guard passes executes its sharing[] in strict order: Amount → Rate → Surplus. " +
|
|
281
|
+
"MULTI-TIER ALLOCATION (DOC-04): Each Order binds ONE Allocators template (set on Service.order_allocators before publish). " +
|
|
282
|
+
"For multi-tier distribution (e.g., customer→agency→suppliers), use a two-phase approach: " +
|
|
283
|
+
"(1) Tier-1 Allocators on the customer's Order (allocates to agency + refund fund); " +
|
|
284
|
+
"(2) Tier-2 Allocators on a NEW Order created by the agency (allocates agency's received funds to suppliers). " +
|
|
285
|
+
"Each tier's Rate-mode sharing[] must independently sum to 10000 (or <= 10000 with Surplus).");
|
|
202
286
|
export const ObjectServiceSchema = ObjectBaseSchema.extend({
|
|
203
287
|
description: z.string().describe("Service object description"),
|
|
204
288
|
location: z.string().describe("Service object location"),
|
|
@@ -210,7 +294,11 @@ export const ObjectServiceSchema = ObjectBaseSchema.extend({
|
|
|
210
294
|
bPaused: z.boolean().describe("Whether service purchase is paused"),
|
|
211
295
|
customer_required: z.array(z.string()).describe("Information required from customer. Such as phone, email, etc."),
|
|
212
296
|
arbitrations: z.array(z.string()).describe("List of Arbitration objects supported by service. When order user needs arbitration, they can apply for arbitration with any Arbitration object in the list."),
|
|
213
|
-
compensation_fund: BalanceTypeSchema.describe("Compensation fund
|
|
297
|
+
compensation_fund: BalanceTypeSchema.describe("Compensation fund BALANCE (NOT a Treasury address). " +
|
|
298
|
+
"This field reports the total amount of funds currently held in the Service's compensation pool. " +
|
|
299
|
+
"To ADD funds, use `service.compensation_fund_add`. To RECEIVE funds (as order owner after arbitration), use `service.compensation_fund_receive`. " +
|
|
300
|
+
"P2-03 clarification: this is a balance value (e.g. {balance: '1000000000', token_type: '0x2::wow::WOW'}), NOT the Treasury object address. " +
|
|
301
|
+
"The Treasury address (if bound) is queried separately via the Service's `repositories` or `order_allocators` configuration."),
|
|
214
302
|
paused_time: z.union([z.number(), z.null()]).describe("Service purchase pause time. If not paused, it is null."),
|
|
215
303
|
setting_lock_duration: z.union([z.string(), z.number(), z.bigint()]).describe("Lock duration for critical settings. After Service is published, modifications to 'order_allocators', 'rewards', 'arbitrations', 'machine', and withdrawal from 'compensation_fund' must exceed the 'setting_lock_duration' lock time."),
|
|
216
304
|
order_allocators: z.union([AllocatorsSchema, z.null()]).describe("Order fund allocator list."),
|
|
@@ -257,9 +345,11 @@ export const ObjectArbSchema = ObjectBaseSchema.extend({
|
|
|
257
345
|
time: z.number().describe("Arbitration time"),
|
|
258
346
|
}).describe("Arb object");
|
|
259
347
|
export const DiscountTypeSchema = z.union([
|
|
260
|
-
z.
|
|
261
|
-
z.
|
|
262
|
-
|
|
348
|
+
z.enum(["RATES", "FIXED"]),
|
|
349
|
+
z.number().int().min(0).max(1).transform((n) => n === 0 ? "RATES" :
|
|
350
|
+
n === 1 ? "FIXED" :
|
|
351
|
+
"RATES"),
|
|
352
|
+
]).describe("Discount type. Accepts string ('RATES' or 'FIXED') or number (0='RATES', 1='FIXED'). If rate(0/RATES), discount is based on proportion of product amount (e.g., 1000 means 10% discount); if fixed(1/FIXED), discount is based on fixed value of product amount (e.g., 100 means 100 yuan discount). String form is recommended.");
|
|
263
353
|
export const ObjectDiscountSchema = ObjectBaseSchema.extend({
|
|
264
354
|
name: z.string().describe("Discount name"),
|
|
265
355
|
discount_type: DiscountTypeSchema.describe("Discount type. If rate(0), discount is based on proportion of product amount (e.g., 1000 means 10% discount); if fixed(1), discount is based on fixed value of product amount (e.g., 100 means 100 yuan discount)."),
|
|
@@ -462,11 +552,17 @@ export const GuardNodeSchema = z.lazy(() => z.discriminatedUnion('type', [
|
|
|
462
552
|
z.object({
|
|
463
553
|
type: z.literal('logic_and'),
|
|
464
554
|
nodes: z.array(GuardNodeSchema),
|
|
465
|
-
}).strict().describe(`Returns Bool. Requires 2-${MAX_MULTI_OPERANDS} boolean nodes. Computed by performing logical AND on all child node values. Returns true if ALL are true, otherwise false.`)
|
|
555
|
+
}).strict().describe(`Returns Bool. Requires 2-${MAX_MULTI_OPERANDS} boolean nodes. Computed by performing logical AND on all child node values. Returns true if ALL are true, otherwise false.`)
|
|
556
|
+
.refine((v) => v.nodes.length >= 2 && v.nodes.length <= MAX_MULTI_OPERANDS, {
|
|
557
|
+
message: `logic_and requires 2-${MAX_MULTI_OPERANDS} child nodes. For a single condition, use the comparison node directly as root (e.g. logic_equal), do NOT wrap with logic_and.`,
|
|
558
|
+
}),
|
|
466
559
|
z.object({
|
|
467
560
|
type: z.literal('logic_or'),
|
|
468
561
|
nodes: z.array(GuardNodeSchema),
|
|
469
|
-
}).strict().describe(`Returns Bool. Requires 2-${MAX_MULTI_OPERANDS} boolean nodes. Computed by performing logical OR on all child node values. Returns true if ANY is true, otherwise false.`)
|
|
562
|
+
}).strict().describe(`Returns Bool. Requires 2-${MAX_MULTI_OPERANDS} boolean nodes. Computed by performing logical OR on all child node values. Returns true if ANY is true, otherwise false.`)
|
|
563
|
+
.refine((v) => v.nodes.length >= 2 && v.nodes.length <= MAX_MULTI_OPERANDS, {
|
|
564
|
+
message: `logic_or requires 2-${MAX_MULTI_OPERANDS} child nodes. For a single condition, use the comparison node directly as root (e.g. logic_equal), do NOT wrap with logic_or.`,
|
|
565
|
+
}),
|
|
470
566
|
z.object({
|
|
471
567
|
type: z.literal('logic_string_contains'),
|
|
472
568
|
nodes: z.array(GuardNodeSchema),
|
|
@@ -842,21 +938,58 @@ export const TableItem_DemandPresenterSchema = ObjectBaseSchema.extend({
|
|
|
842
938
|
feedback_time: tolerantNumber.describe("Demand object feedback time"),
|
|
843
939
|
}).describe("Demand object's Service recommendation record");
|
|
844
940
|
export const MachineForwardGuardSchema = z.object({
|
|
845
|
-
guard: z.string().describe("Guard object
|
|
941
|
+
guard: z.string().describe("Guard object name or address (string). Example: 'my_attendance_guard' or '0x1234...'"),
|
|
846
942
|
retained_submission: z.array(tolerantNumber).nullable().optional().describe("Data submitted by user during Guard object verification"),
|
|
847
|
-
}).strict().describe("Record of Guard object in MachineForwardGuard object");
|
|
943
|
+
}).strict().describe("Record of Guard object in MachineForwardGuard object. ALWAYS an OBJECT {guard: string, retained_submission?: number[]} — never a plain string. The inner 'guard' field is the Guard's name or address as a string.");
|
|
848
944
|
export const MachineForwardSchema = z.object({
|
|
849
945
|
name: z.string().describe("Forward name"),
|
|
850
946
|
namedOperator: tolerantStringNullable.describe("Forward operation permission 1: Namespace (one of the two must be specified); recommended if Progress object operators are different (e.g., different delivery personnel for different orders)."),
|
|
851
947
|
permissionIndex: tolerantNumberNullable.describe("Forward operation permission 2: Permission index (one of the two must be specified); recommended if all Progress object operators are the same (e.g., same reward reviewers for all orders)."),
|
|
852
948
|
weight: tolerantNumber.describe("Forward weight"),
|
|
853
|
-
guard:
|
|
949
|
+
guard: z.preprocess((val) => {
|
|
950
|
+
if (typeof val === "string") {
|
|
951
|
+
return { guard: val };
|
|
952
|
+
}
|
|
953
|
+
return val;
|
|
954
|
+
}, z.union([
|
|
955
|
+
MachineForwardGuardSchema.describe("OBJECT form: {guard: '<guard_name_or_address>', retained_submission?: number[]}. " +
|
|
956
|
+
"Use this form when you need to pass retained_submission data alongside the Guard reference."),
|
|
957
|
+
z.string().describe("STRING form (shorthand): the Guard object's name or address as a plain string. " +
|
|
958
|
+
"Auto-wrapped to {guard: <string>} at runtime. Use this when you only need to reference a Guard without retained_submission."),
|
|
959
|
+
]).nullable().optional()).describe("Guard reference for this forward. Accepts TWO formats:\n" +
|
|
960
|
+
"• STRING (preferred): \"my_guard_name\" — the Guard's name or address as a plain string.\n" +
|
|
961
|
+
"• OBJECT (only when retained_submission is needed): {guard: \"my_guard_name\", retained_submission: [1,2,3]}.\n" +
|
|
962
|
+
"FOLLOW THE SCHEMA FIELD STRUCTURE: A Guard reference is fundamentally a STRING (the Guard object's name or address). " +
|
|
963
|
+
"Provide a string when you only need to reference a Guard — do NOT wrap a bare string in an object structure. " +
|
|
964
|
+
"The OBJECT form {guard: \"...\", retained_submission: [...]} exists ONLY to carry additional `retained_submission` data " +
|
|
965
|
+
"alongside the string reference; inside the object, the `guard` field is STILL a string. " +
|
|
966
|
+
"In short: string-in for a string reference, object-in only when you need to pass extra data.\n" +
|
|
967
|
+
"COGNITIVE PRINCIPLE: Guard validation ALWAYS occurs BEFORE the forward operation. " +
|
|
968
|
+
"A Guard that queries state of the SAME Progress object this forward operates on " +
|
|
969
|
+
"(e.g. progress.current) will see the PRE-transition value (source node), NOT the target node. " +
|
|
970
|
+
"If the Guard checks progress.current == target_node, it will ALWAYS FAIL. " +
|
|
971
|
+
"Querying a DIFFERENT Progress object (cross-machine) is safe and reasonable — " +
|
|
972
|
+
"that progress is not modified by this forward. " +
|
|
973
|
+
"For target-node verification after transition, bind the Guard to the Allocator instead " +
|
|
974
|
+
"(allocation.alloc runs AFTER the state transition completes)."),
|
|
854
975
|
}).strict().describe("Forward in Machine object");
|
|
855
976
|
export const MachineNodePairSchema = z.object({
|
|
856
|
-
prev_node: z.string().describe("Previous node name"),
|
|
977
|
+
prev_node: z.string().describe("Previous node name. Empty string '' means initial entry node (the first node in the workflow)."),
|
|
857
978
|
threshold: tolerantNumber.default(0).describe("Threshold to trigger node advancement. If total Forward weight is greater than or equal to threshold, node advancement is triggered."),
|
|
858
|
-
forwards: z.array(MachineForwardSchema).describe("Forward list"
|
|
859
|
-
|
|
979
|
+
forwards: z.array(MachineForwardSchema).describe("Forward list — operations to ENTER THIS NODE from prev_node. " +
|
|
980
|
+
"Example: pair {prev_node:'A', forwards:[{name:'Go'}]} means 'use Go to advance FROM A TO THIS NODE'. " +
|
|
981
|
+
"For initial node (prev_node=''), forwards are operations to enter this node from the start state. " +
|
|
982
|
+
"WARNING: forwards belong to the DESTINATION node's pair, NOT the source node. " +
|
|
983
|
+
"Placing a forward on the wrong pair will cause Progress to get stuck."),
|
|
984
|
+
}).strict().describe("Node pair in Machine object")
|
|
985
|
+
.refine((pair) => {
|
|
986
|
+
if (pair.prev_node === "" && pair.forwards.length === 0) {
|
|
987
|
+
return false;
|
|
988
|
+
}
|
|
989
|
+
return true;
|
|
990
|
+
}, {
|
|
991
|
+
message: "Initial node (prev_node='') must have at least one forward. Without a forward, Progress cannot advance from '' to this node, causing the order workflow to be permanently stuck.",
|
|
992
|
+
});
|
|
860
993
|
export const MachineNodeSchema = z.object({
|
|
861
994
|
name: z.string().describe("Node name"),
|
|
862
995
|
pairs: z.array(MachineNodePairSchema).describe("Node pair list"),
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const SchemaQueryInputSchema: z.ZodObject<{
|
|
3
|
-
action: z.ZodEnum<["list", "get", "get_output", "search", "list_operations"]>;
|
|
3
|
+
action: z.ZodEnum<["list", "get", "get_output", "search", "list_operations", "get_guard_templates", "get_field"]>;
|
|
4
4
|
name: z.ZodOptional<z.ZodString>;
|
|
5
5
|
query: z.ZodOptional<z.ZodString>;
|
|
6
|
+
field_path: z.ZodOptional<z.ZodString>;
|
|
7
|
+
template: z.ZodOptional<z.ZodString>;
|
|
8
|
+
output_file: z.ZodOptional<z.ZodString>;
|
|
6
9
|
}, "strict", z.ZodTypeAny, {
|
|
7
|
-
action: "get" | "search" | "list" | "get_output" | "list_operations";
|
|
10
|
+
action: "get" | "search" | "list" | "get_output" | "list_operations" | "get_guard_templates" | "get_field";
|
|
8
11
|
name?: string | undefined;
|
|
9
12
|
query?: string | undefined;
|
|
13
|
+
field_path?: string | undefined;
|
|
14
|
+
template?: string | undefined;
|
|
15
|
+
output_file?: string | undefined;
|
|
10
16
|
}, {
|
|
11
|
-
action: "get" | "search" | "list" | "get_output" | "list_operations";
|
|
17
|
+
action: "get" | "search" | "list" | "get_output" | "list_operations" | "get_guard_templates" | "get_field";
|
|
12
18
|
name?: string | undefined;
|
|
13
19
|
query?: string | undefined;
|
|
20
|
+
field_path?: string | undefined;
|
|
21
|
+
template?: string | undefined;
|
|
22
|
+
output_file?: string | undefined;
|
|
14
23
|
}>;
|
|
15
24
|
export declare const SchemaQueryOutputSchema: z.ZodObject<{
|
|
16
25
|
success: z.ZodBoolean;
|
|
@@ -30,6 +39,7 @@ export declare const SchemaQueryOutputSchema: z.ZodObject<{
|
|
|
30
39
|
}>, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodNull]>;
|
|
31
40
|
message: z.ZodString;
|
|
32
41
|
suggestions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
42
|
+
output_file_path: z.ZodOptional<z.ZodString>;
|
|
33
43
|
}, "strict", z.ZodTypeAny, {
|
|
34
44
|
message: string;
|
|
35
45
|
data: Record<string, unknown> | {
|
|
@@ -40,6 +50,7 @@ export declare const SchemaQueryOutputSchema: z.ZodObject<{
|
|
|
40
50
|
success: boolean;
|
|
41
51
|
action: string;
|
|
42
52
|
suggestions?: string[] | undefined;
|
|
53
|
+
output_file_path?: string | undefined;
|
|
43
54
|
}, {
|
|
44
55
|
message: string;
|
|
45
56
|
data: Record<string, unknown> | {
|
|
@@ -50,4 +61,5 @@ export declare const SchemaQueryOutputSchema: z.ZodObject<{
|
|
|
50
61
|
success: boolean;
|
|
51
62
|
action: string;
|
|
52
63
|
suggestions?: string[] | undefined;
|
|
64
|
+
output_file_path?: string | undefined;
|
|
53
65
|
}>;
|
|
@@ -8,16 +8,30 @@ export const SchemaQueryInputSchema = z
|
|
|
8
8
|
"get_output",
|
|
9
9
|
"search",
|
|
10
10
|
"list_operations",
|
|
11
|
+
"get_guard_templates",
|
|
12
|
+
"get_field",
|
|
11
13
|
])
|
|
12
|
-
.describe("Action to perform: 'list'
|
|
14
|
+
.describe("Action to perform: 'list' (all schemas), 'get' (specific input schema), 'get_output' (tool output schema), 'get_field' (field-path query e.g. field_path='data.node'), 'search' (by keyword), 'list_operations' (on-chain operations), 'get_guard_templates' (Guard creation templates + best practices)."),
|
|
13
15
|
name: z
|
|
14
16
|
.string()
|
|
15
17
|
.optional()
|
|
16
|
-
.describe("Schema/tool name for 'get'/'get_output' action (e.g., 'onchain_operations', '
|
|
18
|
+
.describe("Schema/tool name for 'get'/'get_output'/'get_field' action (e.g., 'onchain_operations', 'onchain_operations_machine')."),
|
|
17
19
|
query: z
|
|
18
20
|
.string()
|
|
19
21
|
.optional()
|
|
20
22
|
.describe("Search query for 'search' action"),
|
|
23
|
+
field_path: z
|
|
24
|
+
.string()
|
|
25
|
+
.optional()
|
|
26
|
+
.describe("Dot-separated field path for 'get_field' action (e.g. 'data.node', 'data.node.nodes.0.pairs'). Navigates schema.properties.* and schema.items.*."),
|
|
27
|
+
template: z
|
|
28
|
+
.string()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Guard template name for 'get_guard_templates' action. Omit to list all available templates. Available: signer_verification, progress_node_check, order_owner_verification, service_belonging_check, reward_not_claimed, combined_reward_guard."),
|
|
31
|
+
output_file: z
|
|
32
|
+
.string()
|
|
33
|
+
.optional()
|
|
34
|
+
.describe("When set, writes the response data to this file path (relative to cwd) and returns the path instead of inline data. Use for large schemas that would be truncated. Prefer workspace paths like '.trae/tmp/schema.json' so the Read tool can access them."),
|
|
21
35
|
})
|
|
22
36
|
.strict();
|
|
23
37
|
const SchemaListItemSchema = z
|
|
@@ -34,14 +48,18 @@ export const SchemaQueryOutputSchema = z
|
|
|
34
48
|
data: z
|
|
35
49
|
.union([
|
|
36
50
|
z.array(SchemaListItemSchema).describe("List of schema summaries (list/search/list_operations)."),
|
|
37
|
-
z.record(z.unknown()).describe("JSON Schema object (get/get_output)."),
|
|
38
|
-
z.null().describe("No data — lookup failed or returned nothing."),
|
|
51
|
+
z.record(z.unknown()).describe("JSON Schema object (get/get_output/get_field) or Guard template data."),
|
|
52
|
+
z.null().describe("No data — lookup failed or returned nothing, or data was written to output_file."),
|
|
39
53
|
])
|
|
40
|
-
.describe("Response data — array of schema summaries for list-like actions, JSON Schema object for get/get_output, null on failure."),
|
|
54
|
+
.describe("Response data — array of schema summaries for list-like actions, JSON Schema object for get/get_output/get_field, Guard template data for get_guard_templates, null on failure or when output_file is used."),
|
|
41
55
|
message: z.string().describe("Human-readable message describing the result"),
|
|
42
56
|
suggestions: z
|
|
43
57
|
.array(z.string())
|
|
44
58
|
.optional()
|
|
45
59
|
.describe("Suggested next steps or alternatives"),
|
|
60
|
+
output_file_path: z
|
|
61
|
+
.string()
|
|
62
|
+
.optional()
|
|
63
|
+
.describe("When output_file is used, contains the absolute file path where data was written."),
|
|
46
64
|
})
|
|
47
65
|
.strict();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodeSchema } from '../call/machine.js';
|
|
2
|
-
import { MachineNodeSchema } from '../query/index.js';
|
|
2
|
+
import { MachineNodeSchema, MachineNodePairSchema, MachineForwardSchema } from '../query/index.js';
|
|
3
3
|
import { writeFileSync } from 'fs';
|
|
4
4
|
function detectFormat(text) {
|
|
5
5
|
const trimmed = text.trim();
|
|
@@ -265,7 +265,7 @@ export function validateMachineNode(node) {
|
|
|
265
265
|
return validateWithZod(MachineNodeSchema, node);
|
|
266
266
|
}
|
|
267
267
|
export function validateMachineNodePair(pair) {
|
|
268
|
-
const result =
|
|
268
|
+
const result = MachineNodePairSchema.safeParse(pair);
|
|
269
269
|
if (result.success) {
|
|
270
270
|
return { success: true, errors: [] };
|
|
271
271
|
}
|
|
@@ -276,7 +276,7 @@ export function validateMachineNodePair(pair) {
|
|
|
276
276
|
return { success: false, errors };
|
|
277
277
|
}
|
|
278
278
|
export function validateMachineForward(forward) {
|
|
279
|
-
const result =
|
|
279
|
+
const result = MachineForwardSchema.safeParse(forward);
|
|
280
280
|
if (result.success) {
|
|
281
281
|
return { success: true, errors: [] };
|
|
282
282
|
}
|
|
@@ -325,7 +325,10 @@ export function machineNodesToMarkdown(nodes, options = {}) {
|
|
|
325
325
|
for (const forward of pair.forwards) {
|
|
326
326
|
const namedOp = forward.namedOperator || '';
|
|
327
327
|
const permIdx = forward.permissionIndex?.toString() || '';
|
|
328
|
-
const
|
|
328
|
+
const guardRaw = forward.guard;
|
|
329
|
+
const guard = typeof guardRaw === 'string'
|
|
330
|
+
? guardRaw
|
|
331
|
+
: (guardRaw?.guard || '');
|
|
329
332
|
md += `| ${forward.name} | ${forward.weight} | ${namedOp} | ${permIdx} | ${guard} |\n`;
|
|
330
333
|
}
|
|
331
334
|
md += `\n`;
|
|
@@ -6,9 +6,12 @@ export interface SchemaInfo {
|
|
|
6
6
|
outputPath?: string;
|
|
7
7
|
}
|
|
8
8
|
export interface SchemaQueryRequest {
|
|
9
|
-
action: "list" | "get" | "search" | "list_operations" | "get_output";
|
|
9
|
+
action: "list" | "get" | "search" | "list_operations" | "get_output" | "get_guard_templates" | "get_field";
|
|
10
10
|
name?: string;
|
|
11
11
|
query?: string;
|
|
12
|
+
field_path?: string;
|
|
13
|
+
template?: string;
|
|
14
|
+
output_file?: string;
|
|
12
15
|
}
|
|
13
16
|
export interface SchemaQueryResponse {
|
|
14
17
|
[key: string]: unknown;
|
|
@@ -17,6 +20,7 @@ export interface SchemaQueryResponse {
|
|
|
17
20
|
data: any;
|
|
18
21
|
message: string;
|
|
19
22
|
suggestions?: string[];
|
|
23
|
+
output_file_path?: string;
|
|
20
24
|
}
|
|
21
25
|
export declare function areSchemasAvailable(): boolean;
|
|
22
26
|
export declare function getSchemaIndex(): {
|
|
@@ -26,6 +30,8 @@ export declare function getSchemaIndex(): {
|
|
|
26
30
|
export declare function listSchemas(): SchemaInfo[];
|
|
27
31
|
export declare function getSchema(name: string): any | null;
|
|
28
32
|
export declare function getOutputSchema(name: string): any | null;
|
|
33
|
+
export declare function getGuardTemplates(templateName?: string): any | null;
|
|
34
|
+
export declare function getSchemaField(name: string, fieldPath: string): any | null;
|
|
29
35
|
export declare function searchSchemas(query: string): SchemaInfo[];
|
|
30
36
|
export declare function listOperations(): SchemaInfo[];
|
|
31
37
|
export declare function processSchemaQuery(request: SchemaQueryRequest): SchemaQueryResponse;
|