@wowok/agent-mcp 2.6.0 → 2.6.3
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/customer/info-puzzle.d.ts +1 -1
- package/dist/customer/info-puzzle.js +4 -2
- package/dist/customer/risk-assessment.js +26 -4
- package/dist/customer/types.d.ts +2 -0
- package/dist/examples/guard-template-balance-check.json +38 -0
- package/dist/examples/guard-template-time-lock.json +39 -0
- package/dist/examples/machine-template-7node-rental.json +114 -0
- package/dist/examples/rental-ziroom-machine-create.json +137 -0
- package/dist/examples/rental-ziroom-permission-create.json +35 -0
- package/dist/examples/rental-ziroom-service-create.json +80 -0
- package/dist/examples/retail-myshop-service-create.json +88 -0
- 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 +493 -0
- package/dist/extensions/registry.d.ts +50 -0
- package/dist/extensions/registry.js +662 -0
- package/dist/extensions/types.d.ts +219 -0
- package/dist/extensions/types.js +1 -0
- package/dist/index.js +50 -0
- package/dist/knowledge/deployment-scanner.d.ts +3 -0
- package/dist/knowledge/deployment-scanner.js +64 -3
- package/dist/knowledge/fund-layer.d.ts +72 -0
- package/dist/knowledge/fund-layer.js +420 -0
- package/dist/knowledge/guard-render.d.ts +57 -0
- package/dist/knowledge/guard-render.js +700 -0
- package/dist/knowledge/guard-risk.d.ts +13 -0
- package/dist/knowledge/guard-risk.js +57 -0
- package/dist/knowledge/guard-submission-prompt.d.ts +31 -0
- package/dist/knowledge/guard-submission-prompt.js +171 -0
- package/dist/knowledge/guard-templates.js +278 -0
- package/dist/knowledge/machine-ledger.js +1 -1
- package/dist/knowledge/machine-render.d.ts +41 -0
- package/dist/knowledge/machine-render.js +565 -0
- package/dist/knowledge/machine-templates.js +24 -5
- package/dist/knowledge/reward-confirm.js +2 -2
- package/dist/knowledge/reward-puzzle.js +1 -1
- package/dist/knowledge/reward-risk.js +9 -9
- package/dist/knowledge/reward-templates.js +2 -2
- package/dist/knowledge/service-confirm.d.ts +15 -6
- package/dist/knowledge/service-confirm.js +119 -11
- package/dist/knowledge/service-context.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/service-risk.d.ts +1 -1
- package/dist/knowledge/service-risk.js +3 -3
- package/dist/knowledge/service-templates.js +2 -2
- package/dist/knowledge/service-translation.d.ts +1 -1
- package/dist/knowledge/service-translation.js +7 -7
- package/dist/knowledge/tool-constraints.js +6 -2
- package/dist/project/deployment-bridge.d.ts +1 -1
- package/dist/project/deployment-bridge.js +31 -7
- package/dist/project/deployment-doc.d.ts +3 -0
- package/dist/project/deployment-doc.js +76 -14
- package/dist/project/edit-planner.d.ts +123 -0
- package/dist/project/edit-planner.js +1371 -0
- package/dist/project/evaluation.d.ts +2 -0
- package/dist/project/evaluation.js +873 -88
- package/dist/project/graph-builder.d.ts +4 -1
- package/dist/project/graph-builder.js +132 -62
- package/dist/project/graph.d.ts +1 -0
- package/dist/project/handlers.d.ts +317 -6
- package/dist/project/handlers.js +1171 -19
- 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/allocation.js +2 -2
- package/dist/schema/call/arbitration.js +19 -6
- 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/contact.js +2 -2
- package/dist/schema/call/demand.d.ts +23 -31
- package/dist/schema/call/demand.js +2 -2
- package/dist/schema/call/guard.js +2 -2
- package/dist/schema/call/machine.d.ts +1976 -752
- package/dist/schema/call/machine.js +50 -4
- package/dist/schema/call/order.d.ts +149 -228
- package/dist/schema/call/order.js +4 -3
- package/dist/schema/call/payment.d.ts +183 -3
- package/dist/schema/call/payment.js +21 -3
- package/dist/schema/call/permission.js +2 -2
- 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/repository.js +2 -2
- package/dist/schema/call/reward.js +3 -3
- package/dist/schema/call/semantic.d.ts +1 -1
- package/dist/schema/call/semantic.js +37 -2
- package/dist/schema/call/service.d.ts +275 -127
- package/dist/schema/call/service.js +89 -13
- package/dist/schema/call/treasury.js +3 -3
- package/dist/schema/common/index.d.ts +13 -2
- package/dist/schema/common/index.js +80 -15
- package/dist/schema/local/index.d.ts +32 -35
- package/dist/schema/local/index.js +28 -6
- package/dist/schema/messenger/index.d.ts +274 -46
- package/dist/schema/operations.d.ts +1264 -544
- package/dist/schema/operations.js +65 -7
- package/dist/schema/project/index.d.ts +2846 -167
- package/dist/schema/project/index.js +570 -16
- package/dist/schema/query/index.d.ts +922 -349
- package/dist/schema/query/index.js +205 -42
- package/dist/schema/schema-query/index.d.ts +65 -3
- package/dist/schema/schema-query/index.js +38 -5
- package/dist/schema/utils/node-parser.js +20 -4
- package/dist/schema/utils/object-type-utils.d.ts +12 -0
- package/dist/schema/utils/object-type-utils.js +35 -0
- package/dist/schema/utils/permission-machine-check.d.ts +49 -0
- package/dist/schema/utils/permission-machine-check.js +121 -0
- package/dist/schema/utils/skills-recommendation.d.ts +2 -0
- package/dist/schema/utils/skills-recommendation.js +76 -0
- package/dist/schema-query/index.d.ts +20 -1
- package/dist/schema-query/index.js +306 -4
- package/dist/schemas/account_operation.output.json +7 -1
- package/dist/schemas/account_operation.schema.json +3 -3
- 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.output.json +2820 -0
- package/dist/schemas/onchain_operations.schema.json +444 -330
- package/dist/schemas/onchain_operations_allocation.schema.json +37 -28
- package/dist/schemas/onchain_operations_arbitration.schema.json +16 -14
- package/dist/schemas/onchain_operations_contact.schema.json +10 -10
- package/dist/schemas/onchain_operations_demand.schema.json +10 -10
- package/dist/schemas/onchain_operations_gen_passport.schema.json +16 -16
- package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -2
- package/dist/schemas/onchain_operations_guard.schema.json +2 -2
- package/dist/schemas/onchain_operations_machine.schema.json +43 -35
- package/dist/schemas/onchain_operations_order.schema.json +72 -78
- package/dist/schemas/onchain_operations_payment.schema.json +141 -111
- package/dist/schemas/onchain_operations_permission.schema.json +3 -3
- package/dist/schemas/onchain_operations_personal.schema.json +7 -7
- package/dist/schemas/onchain_operations_progress.schema.json +9 -9
- package/dist/schemas/onchain_operations_proof.schema.json +8 -8
- package/dist/schemas/onchain_operations_repository.schema.json +10 -10
- package/dist/schemas/onchain_operations_reward.schema.json +14 -14
- package/dist/schemas/onchain_operations_service.schema.json +119 -48
- package/dist/schemas/onchain_operations_treasury.schema.json +11 -11
- package/dist/schemas/onchain_table_data.output.json +33 -25
- package/dist/schemas/onchain_table_data.schema.json +22 -21
- package/dist/schemas/project_operation.output.json +2194 -23
- package/dist/schemas/project_operation.schema.json +84 -6
- package/dist/schemas/query_toolkit.output.json +108 -80
- package/dist/schemas/query_toolkit.schema.json +12 -12
- package/dist/schemas/schema_query.output.json +70 -3
- package/dist/schemas/schema_query.schema.json +18 -3
- package/dist/schemas/wowok_buildin_info.output.json +81 -8
- package/dist/schemas/wowok_buildin_info.schema.json +46 -2
- package/dist/tools/handlers/local.js +20 -5
- package/dist/tools/handlers/onchain.js +594 -6
- package/dist/tools/handlers/project.js +76 -4
- package/dist/tools/handlers/query.js +27 -0
- package/dist/tools/handlers/schema-query.js +43 -1
- 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.d.ts +8 -0
- package/dist/tools/index.js +387 -12
- 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,14 @@ 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("
|
|
33
|
-
|
|
34
|
-
|
|
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."),
|
|
43
|
+
z.object({ Signer: z.literal("signer") }).describe("Current transaction signer (tx_context::sender) at the time of the alloc() call. " +
|
|
44
|
+
"For refunds, the Order owner must call alloc_by_guard themselves to receive the funds."),
|
|
45
|
+
]).describe("Recipient ID. Three forms:\n" +
|
|
46
|
+
" - {GuardIdentifier: u8} — DYNAMIC address resolved from Passport at alloc() time\n" +
|
|
47
|
+
" - {Entity: {name_or_address: 'mark_name'}} — FIXED static address via LocalMark (recommended)\n" +
|
|
48
|
+
" - {Signer: 'signer'} — transaction sender at alloc() time (e.g. self-refund; customer must call alloc_by_guard themselves)");
|
|
35
49
|
export const RecordsInEntitySchema = z.object({
|
|
36
50
|
name: z.string().describe("Record name"),
|
|
37
51
|
value_type: ValueTypeSchema.describe("Value type"),
|
|
@@ -104,8 +118,11 @@ export const ServiceSaleSchema = z.object({
|
|
|
104
118
|
price: BalanceTypeSchema.describe("Price of the product or service"),
|
|
105
119
|
stock: BalanceTypeSchema.describe("Stock of the product or service"),
|
|
106
120
|
suspension: z.boolean().describe("Whether sale is suspended"),
|
|
107
|
-
wip: z.string().describe("
|
|
108
|
-
|
|
121
|
+
wip: z.string().describe("WIP file URL. EMPTY string \"\" skips verification (TESTING ONLY). " +
|
|
122
|
+
"Production MUST use a real HTTP URL pointing to a .wip file generated by the wip_file tool. " +
|
|
123
|
+
"Example: \"https://cdn.example.com/products/phone_v1.wip\""),
|
|
124
|
+
wip_hash: z.string().describe("WIP file hash (hex string). EMPTY string \"\" skips hash comparison (TESTING ONLY). " +
|
|
125
|
+
"Production: fill with the hash you saw when viewing the product, to prevent merchant replacing the WIP file before order."),
|
|
109
126
|
}).describe("Service sale");
|
|
110
127
|
export const PurchasedItemSchema = z.object({
|
|
111
128
|
name: LongNameSchema.describe("Name of the product or service"),
|
|
@@ -182,23 +199,99 @@ export const ObjectRewardSchema = ObjectBaseSchema.extend({
|
|
|
182
199
|
um: z.union([z.string(), z.null()]).describe("Contact object"),
|
|
183
200
|
permission: z.string().describe("Permission object ID"),
|
|
184
201
|
}).describe("Reward object");
|
|
185
|
-
export const AllocationModeSchema = z.
|
|
202
|
+
export const AllocationModeSchema = z.union([
|
|
203
|
+
z.enum(["Amount", "Rate", "Surplus"]),
|
|
204
|
+
z.number().int().min(0).max(2).transform((n) => n === 0 ? "Amount" :
|
|
205
|
+
n === 1 ? "Rate" :
|
|
206
|
+
n === 2 ? "Surplus" :
|
|
207
|
+
"Amount"),
|
|
208
|
+
]).describe("Allocation mode — determines how the `sharing` field is interpreted. " +
|
|
209
|
+
"Three modes can be used individually OR combined within a single Allocator; " +
|
|
210
|
+
"when combined, allocation order is strictly: Amount first, then Rate, then Surplus. " +
|
|
211
|
+
"Understanding these modes allows modeling almost any fund distribution pattern.\n" +
|
|
212
|
+
"• Amount (0): `sharing` is a FIXED amount in smallest unit (e.g., '750000000' = 0.75 WOW). " +
|
|
213
|
+
"Allocated FIRST; sum of all Amount items is cached as `fix` by the contract. " +
|
|
214
|
+
"Validation: when no Rate and no Surplus items exist, sum of Amount items must be >= allocators.threshold (EAMOUNT_BELOW_THRESHOLD=12); " +
|
|
215
|
+
"when `max` is set, sum of Amount items must be <= max (EAMOUNT_EXCEEDS_MAX=13).\n" +
|
|
216
|
+
"• Rate (1): `sharing` is a basis-points rate (10000 = 100%). " +
|
|
217
|
+
"Allocated AFTER Amount; formula: allocated = (sharing × total_rates) / 10000, " +
|
|
218
|
+
"where total_rates = balance - fix (or max - fix if `max` is set). " +
|
|
219
|
+
"Validation: when no Surplus items exist, sum of all Rate items must be EXACTLY 10000 (ERATE_NOT_10000=4); " +
|
|
220
|
+
"when Surplus items exist, sum of all Rate items must be <= 10000 (ERATE_EXCEEDS_10000=6).\n" +
|
|
221
|
+
"• Surplus (2): `sharing` is IGNORED (contract forces it to 0). " +
|
|
222
|
+
"Allocated LAST; receives the remaining balance after Amount + Rate allocations. " +
|
|
223
|
+
"Validation: MAX ONE Surplus item per Allocator (EMULTIPLE_SURPLUS=5). " +
|
|
224
|
+
"When Surplus exists, Rate sum constraint relaxes from == 10000 to <= 10000.\n" +
|
|
225
|
+
"ALLOCATION ORDER (strict): Amount items (fixed, cached as fix) → Rate items (proportional to balance-fix) → Surplus item (remaining).\n" +
|
|
226
|
+
"RECOMMENDATION: Use Amount mode for known fixed amounts (clearer, no sum constraint). " +
|
|
227
|
+
"Use Rate mode for proportional splits (requires sum == 10000 unless Surplus present). " +
|
|
228
|
+
"Use Surplus to capture remainder (e.g., platform fee + host gets rest). " +
|
|
229
|
+
"Accepts string ('Amount'/'Rate'/'Surplus', recommended) or number (0/1/2).");
|
|
186
230
|
export const AllocationSharingSchema = z.object({
|
|
187
|
-
who: RecipientSchema.describe("Recipient
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
231
|
+
who: RecipientSchema.describe("Recipient of this allocation. Three forms — each resolves the address at a DIFFERENT time:\n" +
|
|
232
|
+
"• { GuardIdentifier: u8 } — DYNAMIC address resolved from Passport at alloc() time (contract calls passport::submission_get). " +
|
|
233
|
+
"Use 0 for Order owner in Service-integrated mode (Customer who created the Order). " +
|
|
234
|
+
"The identifier must match a Guard table entry with b_submission=true. " +
|
|
235
|
+
"If Passport has no matching submission, contract aborts with E_VERIFY_FAILED. " +
|
|
236
|
+
"Use when the recipient address is not known at config time and must be supplied via Guard submission data.\n" +
|
|
237
|
+
"• { Entity: { name_or_address: '...' } } — FIXED address resolved via LocalMark at SDK build time (passed to contract as a literal address). " +
|
|
238
|
+
"Use for known recipients (e.g., 'turo_host', or a Treasury object address). " +
|
|
239
|
+
"Use when the recipient is a stable, known address (e.g., operator receives rent, platform fee to treasury).\n" +
|
|
240
|
+
"• 'Signer' — the transaction sender at the time of the alloc() call (tx_context::sender). " +
|
|
241
|
+
"RESOLVED AT EXECUTION TIME, not at config time. " +
|
|
242
|
+
"For refunds: the customer (Order owner) must call alloc_by_guard THEMSELVES so that tx_context::sender resolves to THEIR address — " +
|
|
243
|
+
"if the operator calls alloc_by_guard, the operator becomes the recipient (Signer = operator), NOT the customer. " +
|
|
244
|
+
"Use when the recipient is whoever submits the allocation transaction (e.g., customer receives refund)."),
|
|
245
|
+
sharing: BalanceTypeSchema.describe("Allocation value. SEMANTICS DEPEND ON `mode`:\n" +
|
|
246
|
+
"• mode='Amount': absolute amount in smallest unit (e.g., '750000000' for 0.75 WOW, '250000000' for 0.25 WOW). " +
|
|
247
|
+
"Allocated first; sum of Amount items cached as `fix`.\n" +
|
|
248
|
+
"• mode='Rate': basis-points rate, 10000 = 100% (e.g., '7500' for 75%, '2500' for 25%). " +
|
|
249
|
+
"When no Surplus in same Allocator, sum MUST == 10000; when Surplus present, sum MUST <= 10000.\n" +
|
|
250
|
+
"• mode='Surplus': IGNORED (contract forces to 0). Set to '0' for clarity. " +
|
|
251
|
+
"Receives remaining balance after Amount + Rate allocations."),
|
|
252
|
+
mode: AllocationModeSchema,
|
|
253
|
+
}).describe("Fund allocation item — one recipient's share of the Allocation balance. " +
|
|
254
|
+
"The `sharing` value's meaning depends on `mode` (see AllocationModeSchema). " +
|
|
255
|
+
"Multiple items in the same Allocator are evaluated together: Amount items first, Rate items second, Surplus last.");
|
|
191
256
|
export const AllocatorSchema = z.object({
|
|
192
|
-
guard: NameOrAddressSchema.describe("Guard object ID. If Guard verification passes, fund allocation
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
257
|
+
guard: NameOrAddressSchema.describe("Guard object ID or name. If Guard verification passes (via Passport), fund allocation for THIS Allocator fires. " +
|
|
258
|
+
"Each Allocator in an Allocators list can have a different Guard — the first Allocator whose Guard returns true wins. " +
|
|
259
|
+
"This enables mutually exclusive allocation paths (e.g., refund Guard on 'return_approved' node vs damage Guard on 'damage_confirmed' node)."),
|
|
260
|
+
sharing: z.array(AllocationSharingSchema).describe("Fund allocation item list. Each item specifies a recipient (who), a value (sharing), and a mode. " +
|
|
261
|
+
"Items can mix modes (Amount + Rate + Surplus) within the same Allocator. " +
|
|
262
|
+
"ALLOCATION ORDER: Amount items first (cached as fix) → Rate items (proportional to balance - fix) → Surplus item (remaining). " +
|
|
263
|
+
"CONSTRAINTS: max ONE Surplus item per Allocator; Rate sum must == 10000 (no Surplus) or <= 10000 (with Surplus); " +
|
|
264
|
+
"Amount sum must >= threshold (no Rate and no Surplus) and <= max (if max set)."),
|
|
265
|
+
fix: BalanceTypeSchema.optional().describe("OUTPUT-ONLY (query result). Cached sum of all Amount-mode `sharing` values in this Allocator. " +
|
|
266
|
+
"Computed by the contract during `allocator_add` — DO NOT set this field at creation. " +
|
|
267
|
+
"Used internally to compute `total_rates = balance - fix` for Rate allocation."),
|
|
268
|
+
max: z.union([BalanceTypeSchema, z.null()]).optional().describe("Maximum allocation cap (OPTIONAL — omit the field or set to null to disable the cap; do NOT set to 0 as that means a cap of zero). " +
|
|
269
|
+
"Passed through to the contract as Option<u64> via allocator_add(): when null/omitted the contract treats it as `none` (no cap); " +
|
|
270
|
+
"when set, the contract enforces it. Has THREE effects when set:\n" +
|
|
271
|
+
"1. Construction: sum of Amount items must be <= max (EAMOUNT_EXCEEDS_MAX=13)\n" +
|
|
272
|
+
"2. Rate execution: total_rates = max - fix (instead of balance - fix)\n" +
|
|
273
|
+
"3. Surplus execution: surplus_amount = max - alloced_amount (instead of balance - alloced_amount)\n" +
|
|
274
|
+
"Use when you want to cap total allocation regardless of Order balance (e.g., cap payout to declared amount). " +
|
|
275
|
+
"SDK pre-validates Amount sum <= max at build time to give actionable error messages before on-chain abort."),
|
|
276
|
+
}).describe("Fund allocator — a complete allocation strategy triggered by a Guard. " +
|
|
277
|
+
"Contains a sharing[] array where items can mix Amount/Rate/Surplus modes. " +
|
|
278
|
+
"When the Guard passes, the contract allocates funds in strict order: Amount → Rate → Surplus.");
|
|
197
279
|
export const AllocatorsSchema = z.object({
|
|
198
280
|
description: DescriptionSchema.describe("Description of fund allocator list"),
|
|
199
|
-
threshold: BalanceTypeSchema.default(0).describe("
|
|
200
|
-
|
|
201
|
-
|
|
281
|
+
threshold: BalanceTypeSchema.default(0).describe("Minimum balance required for allocation to fire. " +
|
|
282
|
+
"When the Allocation object's balance < threshold, allocation aborts with EINSUFFICIENT_BALANCE=7. " +
|
|
283
|
+
"Also: when an Allocator has only Amount items (no Rate, no Surplus), the sum of Amount items must be >= threshold (EAMOUNT_BELOW_THRESHOLD=12). " +
|
|
284
|
+
"Set to 0 (default) to allow any balance."),
|
|
285
|
+
allocators: z.array(AllocatorSchema).describe("Fund allocator list. Each allocator is evaluated in order; the FIRST allocator whose Guard passes wins. " +
|
|
286
|
+
"This enables mutually exclusive allocation paths (e.g., 3 allocators for 3 forward paths: refund / damage-deduct / arbitrate)."),
|
|
287
|
+
}).describe("Fund allocator list — the top-level allocation configuration attached to an Order. " +
|
|
288
|
+
"Contains a threshold and a list of Allocators. When funds arrive at the Order, " +
|
|
289
|
+
"the first Allocator whose Guard passes executes its sharing[] in strict order: Amount → Rate → Surplus. " +
|
|
290
|
+
"MULTI-TIER ALLOCATION (DOC-04): Each Order binds ONE Allocators template (set on Service.order_allocators before publish). " +
|
|
291
|
+
"For multi-tier distribution (e.g., customer→agency→suppliers), use a two-phase approach: " +
|
|
292
|
+
"(1) Tier-1 Allocators on the customer's Order (allocates to agency + refund fund); " +
|
|
293
|
+
"(2) Tier-2 Allocators on a NEW Order created by the agency (allocates agency's received funds to suppliers). " +
|
|
294
|
+
"Each tier's Rate-mode sharing[] must independently sum to 10000 (or <= 10000 with Surplus).");
|
|
202
295
|
export const ObjectServiceSchema = ObjectBaseSchema.extend({
|
|
203
296
|
description: z.string().describe("Service object description"),
|
|
204
297
|
location: z.string().describe("Service object location"),
|
|
@@ -210,7 +303,11 @@ export const ObjectServiceSchema = ObjectBaseSchema.extend({
|
|
|
210
303
|
bPaused: z.boolean().describe("Whether service purchase is paused"),
|
|
211
304
|
customer_required: z.array(z.string()).describe("Information required from customer. Such as phone, email, etc."),
|
|
212
305
|
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
|
|
306
|
+
compensation_fund: BalanceTypeSchema.describe("Compensation fund BALANCE (NOT a Treasury address). " +
|
|
307
|
+
"This field reports the total amount of funds currently held in the Service's compensation pool. " +
|
|
308
|
+
"To ADD funds, use `service.compensation_fund_add`. To RECEIVE funds (as order owner after arbitration), use `service.compensation_fund_receive`. " +
|
|
309
|
+
"P2-03 clarification: this is a balance value (e.g. {balance: '1000000000', token_type: '0x2::wow::WOW'}), NOT the Treasury object address. " +
|
|
310
|
+
"The Treasury address (if bound) is queried separately via the Service's `repositories` or `order_allocators` configuration."),
|
|
214
311
|
paused_time: z.union([z.number(), z.null()]).describe("Service purchase pause time. If not paused, it is null."),
|
|
215
312
|
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
313
|
order_allocators: z.union([AllocatorsSchema, z.null()]).describe("Order fund allocator list."),
|
|
@@ -257,9 +354,11 @@ export const ObjectArbSchema = ObjectBaseSchema.extend({
|
|
|
257
354
|
time: z.number().describe("Arbitration time"),
|
|
258
355
|
}).describe("Arb object");
|
|
259
356
|
export const DiscountTypeSchema = z.union([
|
|
260
|
-
z.
|
|
261
|
-
z.
|
|
262
|
-
|
|
357
|
+
z.enum(["RATES", "FIXED"]),
|
|
358
|
+
z.number().int().min(0).max(1).transform((n) => n === 0 ? "RATES" :
|
|
359
|
+
n === 1 ? "FIXED" :
|
|
360
|
+
"RATES"),
|
|
361
|
+
]).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
362
|
export const ObjectDiscountSchema = ObjectBaseSchema.extend({
|
|
264
363
|
name: z.string().describe("Discount name"),
|
|
265
364
|
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)."),
|
|
@@ -429,7 +528,7 @@ export const GuardNodeSchema = z.lazy(() => z.discriminatedUnion('type', [
|
|
|
429
528
|
identifier: GuardIdentifierSchema,
|
|
430
529
|
convert_witness: WitnessTypeSchema.optional(),
|
|
431
530
|
}).strict().describe("The object to query from the Guard table."),
|
|
432
|
-
parameters: z.array(GuardNodeSchema).describe("Parameters required by the query (
|
|
531
|
+
parameters: z.array(GuardNodeSchema).optional().describe("Parameters required by the query. Optional — defaults to empty array []. Many queries (e.g. progress.current, order.service) take no parameters; for those, this field can be omitted."),
|
|
433
532
|
}).strict().describe(`Returns the result of executing a data query instruction on the specified object. The return type depends on the query being executed. SPECIAL NOTE for EntityLinker/EntityRegistrar queries: Use system addresses in the Guard table -${ENTITY_LINKER_ADDRESS} for EntityLinker queries, ${ENTITY_REGISTRAR_ADDRESS} for EntityRegistrar queries.`),
|
|
434
533
|
z.object({
|
|
435
534
|
type: z.literal('logic_as_u256_greater_or_equal'),
|
|
@@ -461,11 +560,11 @@ export const GuardNodeSchema = z.lazy(() => z.discriminatedUnion('type', [
|
|
|
461
560
|
}).strict().describe("Returns Bool. Computed by inverting the boolean value of the child node (true -> false, false -> true)."),
|
|
462
561
|
z.object({
|
|
463
562
|
type: z.literal('logic_and'),
|
|
464
|
-
nodes: z.array(GuardNodeSchema),
|
|
563
|
+
nodes: z.array(GuardNodeSchema).min(2, `logic_and requires at least 2 child nodes. For a single condition, use the comparison node directly as root (e.g. logic_equal), do NOT wrap with logic_and.`).max(MAX_MULTI_OPERANDS, `logic_and allows at most ${MAX_MULTI_OPERANDS} child nodes.`),
|
|
465
564
|
}).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.`),
|
|
466
565
|
z.object({
|
|
467
566
|
type: z.literal('logic_or'),
|
|
468
|
-
nodes: z.array(GuardNodeSchema),
|
|
567
|
+
nodes: z.array(GuardNodeSchema).min(2, `logic_or requires at least 2 child nodes. For a single condition, use the comparison node directly as root (e.g. logic_equal), do NOT wrap with logic_or.`).max(MAX_MULTI_OPERANDS, `logic_or allows at most ${MAX_MULTI_OPERANDS} child nodes.`),
|
|
469
568
|
}).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.`),
|
|
470
569
|
z.object({
|
|
471
570
|
type: z.literal('logic_string_contains'),
|
|
@@ -842,21 +941,61 @@ export const TableItem_DemandPresenterSchema = ObjectBaseSchema.extend({
|
|
|
842
941
|
feedback_time: tolerantNumber.describe("Demand object feedback time"),
|
|
843
942
|
}).describe("Demand object's Service recommendation record");
|
|
844
943
|
export const MachineForwardGuardSchema = z.object({
|
|
845
|
-
guard: z.string().describe("Guard object
|
|
944
|
+
guard: z.string().describe("Guard object name or address (string). Example: 'my_attendance_guard' or '0x1234...'"),
|
|
846
945
|
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");
|
|
946
|
+
}).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
947
|
export const MachineForwardSchema = z.object({
|
|
849
948
|
name: z.string().describe("Forward name"),
|
|
850
949
|
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
950
|
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
951
|
weight: tolerantNumber.describe("Forward weight"),
|
|
853
|
-
guard:
|
|
952
|
+
guard: z.preprocess((val) => {
|
|
953
|
+
if (typeof val === "string") {
|
|
954
|
+
return { guard: val };
|
|
955
|
+
}
|
|
956
|
+
return val;
|
|
957
|
+
}, z.union([
|
|
958
|
+
MachineForwardGuardSchema.describe("OBJECT form: {guard: '<guard_name_or_address>', retained_submission?: number[]}. " +
|
|
959
|
+
"Use this form when you need to pass retained_submission data alongside the Guard reference."),
|
|
960
|
+
z.string().describe("STRING form (shorthand): the Guard object's name or address as a plain string. " +
|
|
961
|
+
"Auto-wrapped to {guard: <string>} at runtime. Use this when you only need to reference a Guard without retained_submission."),
|
|
962
|
+
]).nullable().optional()).describe("Guard reference for this forward. Accepts TWO formats:\n" +
|
|
963
|
+
"• STRING (preferred): \"my_guard_name\" — the Guard's name or address as a plain string.\n" +
|
|
964
|
+
"• OBJECT (only when retained_submission is needed): {guard: \"my_guard_name\", retained_submission: [1,2,3]}.\n" +
|
|
965
|
+
"FOLLOW THE SCHEMA FIELD STRUCTURE: A Guard reference is fundamentally a STRING (the Guard object's name or address). " +
|
|
966
|
+
"Provide a string when you only need to reference a Guard — do NOT wrap a bare string in an object structure. " +
|
|
967
|
+
"The OBJECT form {guard: \"...\", retained_submission: [...]} exists ONLY to carry additional `retained_submission` data " +
|
|
968
|
+
"alongside the string reference; inside the object, the `guard` field is STILL a string. " +
|
|
969
|
+
"In short: string-in for a string reference, object-in only when you need to pass extra data.\n" +
|
|
970
|
+
"COGNITIVE PRINCIPLE: Guard validation ALWAYS occurs BEFORE the forward operation. " +
|
|
971
|
+
"A Guard that queries state of the SAME Progress object this forward operates on " +
|
|
972
|
+
"(e.g. progress.current) will see the PRE-transition value (source node), NOT the target node. " +
|
|
973
|
+
"If the Guard checks progress.current == target_node, it will ALWAYS FAIL. " +
|
|
974
|
+
"Querying a DIFFERENT Progress object (cross-machine) is safe and reasonable — " +
|
|
975
|
+
"that progress is not modified by this forward. " +
|
|
976
|
+
"For target-node verification after transition, bind the Guard to the Allocator instead " +
|
|
977
|
+
"(allocation.alloc runs AFTER the state transition completes)."),
|
|
854
978
|
}).strict().describe("Forward in Machine object");
|
|
855
979
|
export const MachineNodePairSchema = z.object({
|
|
856
|
-
prev_node: z.string().describe("Previous node name"),
|
|
980
|
+
prev_node: z.string().describe("Previous node name. Empty string '' means initial entry node (the first node in the workflow)."),
|
|
857
981
|
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
|
-
|
|
982
|
+
forwards: z.array(MachineForwardSchema).describe("Forward list — operations to ENTER THIS NODE from prev_node. " +
|
|
983
|
+
"SEMANTIC CLARIFICATION: forwards describe INCOMING transitions (how to ARRIVE at this node), " +
|
|
984
|
+
"NOT outgoing transitions. Think of each forward as an 'entry door' to this node. " +
|
|
985
|
+
"Example: pair {prev_node:'A', forwards:[{name:'Go'}]} means 'use Go to advance FROM A TO THIS NODE'. " +
|
|
986
|
+
"For initial node (prev_node=''), forwards are operations to enter this node from the start state. " +
|
|
987
|
+
"DIAGRAM: A --[Go]--> B means the pair belongs to node B (destination), with prev_node='A'. " +
|
|
988
|
+
"WARNING: forwards belong to the DESTINATION node's pair, NOT the source node. " +
|
|
989
|
+
"Placing a forward on the wrong pair will cause Progress to get stuck."),
|
|
990
|
+
}).strict().describe("Node pair in Machine object")
|
|
991
|
+
.refine((pair) => {
|
|
992
|
+
if (pair.prev_node === "" && pair.forwards.length === 0) {
|
|
993
|
+
return false;
|
|
994
|
+
}
|
|
995
|
+
return true;
|
|
996
|
+
}, {
|
|
997
|
+
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.",
|
|
998
|
+
});
|
|
860
999
|
export const MachineNodeSchema = z.object({
|
|
861
1000
|
name: z.string().describe("Node name"),
|
|
862
1001
|
pairs: z.array(MachineNodePairSchema).describe("Node pair list"),
|
|
@@ -1161,11 +1300,12 @@ export const ConstantItemSchema = z.object({
|
|
|
1161
1300
|
description: z.string().describe('Description')
|
|
1162
1301
|
}).describe('Constant item');
|
|
1163
1302
|
export const PermissionInfoTypeSchema = z.object({
|
|
1164
|
-
index: z.number().describe('Permission index'),
|
|
1165
|
-
name: z.string().describe('
|
|
1166
|
-
description: z.string().describe('Description'),
|
|
1167
|
-
object_type: z.string().describe('Object type')
|
|
1168
|
-
|
|
1303
|
+
index: z.number().describe('Permission index (e.g. 315 for service.compensation_fund_deposit)'),
|
|
1304
|
+
name: z.string().describe('Permission name (e.g. "service.compensation_fund_deposit")'),
|
|
1305
|
+
description: z.string().describe('Description of what this permission allows'),
|
|
1306
|
+
object_type: z.string().describe('Object type this permission belongs to (e.g. "Service", "Arbitration")'),
|
|
1307
|
+
operation: z.optional(z.string()).describe('The SDK/MCP operation field name that triggers this permission check (e.g. "compensation_fund_add", "publish", "pause"). Undefined for permissions with no direct Call*_Data field (e.g. "*.new" permissions). Use this to answer: "What permission does operation X require?" by filtering with {operation: "compensation_fund_add"}.')
|
|
1308
|
+
}).describe('Permission info type — includes the operation field name that maps to this permission, so AI can look up required permissions by operation name.');
|
|
1169
1309
|
export const GuardInstructSchema = z.object({
|
|
1170
1310
|
name: z.string().describe('Name of the guard instruction'),
|
|
1171
1311
|
id: z.number().int().describe('ID of the guard instruction (OperatorType or ContextType)'),
|
|
@@ -1194,8 +1334,23 @@ export const PermissionFilterSchema = z.object({
|
|
|
1194
1334
|
objectType: z.optional(ObjectTypeSchema).describe('Object type filter'),
|
|
1195
1335
|
name: z.optional(z.string()).describe('Name filter'),
|
|
1196
1336
|
index: z.optional(PermissionIndexTypeSchema).describe('Index filter'),
|
|
1197
|
-
description: z.optional(z.string()).describe('Description filter')
|
|
1337
|
+
description: z.optional(z.string()).describe('Description filter'),
|
|
1338
|
+
operation: z.optional(z.string()).describe('Filter by SDK/MCP operation field name (e.g. "compensation_fund_add"). Returns only permissions triggered by this operation. Use this to answer: "What permission does operation X require?"')
|
|
1198
1339
|
}).describe('Permission filter');
|
|
1340
|
+
export const CommonMistakeInfoSchema = z.object({
|
|
1341
|
+
object_type: z.string().describe('The object type this mistake applies to (e.g. "Service", "Arbitration")'),
|
|
1342
|
+
operation: z.string().describe('The operation field name this mistake applies to (e.g. "compensation_fund_add", "voting_deadline")'),
|
|
1343
|
+
category: z.enum(['field_name', 'unit', 'value_range', 'workflow', 'timing']).describe('Category of the mistake: field_name (wrong field name), unit (wrong unit like seconds vs ms), value_range (wrong expected value), workflow (wrong operation order), timing (wrong time constraint)'),
|
|
1344
|
+
mistake: z.string().describe('Short description of the mistake'),
|
|
1345
|
+
correct_usage: z.string().describe('The correct usage pattern'),
|
|
1346
|
+
wrong_example: z.string().describe('Example of the wrong usage'),
|
|
1347
|
+
correct_example: z.string().describe('Example of the correct usage')
|
|
1348
|
+
}).describe('A known common mistake for an on-chain operation. Use this to proactively warn users before they submit a transaction.');
|
|
1349
|
+
export const CommonMistakeFilterSchema = z.object({
|
|
1350
|
+
object_type: z.optional(z.string()).describe('Filter by object type (e.g. "Service")'),
|
|
1351
|
+
operation: z.optional(z.string()).describe('Filter by operation field name (e.g. "compensation_fund_add")'),
|
|
1352
|
+
category: z.optional(z.enum(['field_name', 'unit', 'value_range', 'workflow', 'timing'])).describe('Filter by category (e.g. "field_name" for field-name mistakes, "unit" for unit mistakes)')
|
|
1353
|
+
}).describe('Filter for common mistakes. Use operation:"compensation_fund_add" to find mistakes for a specific operation.');
|
|
1199
1354
|
export const BridgeTokenInfoSchema = z.object({
|
|
1200
1355
|
tokenId: z.number().describe('On-chain token ID (mainnet: WBTC=1, ETH/WETH=2, USDC=3, USDT=4)'),
|
|
1201
1356
|
symbol: z.string().describe('Token symbol/abbreviation (ETH, WETH, WBTC, USDC, USDT)'),
|
|
@@ -1212,8 +1367,12 @@ export const ProtocolInfoQuerySchema = z.discriminatedUnion('info', [
|
|
|
1212
1367
|
}).strict().describe('Constants query'),
|
|
1213
1368
|
z.object({
|
|
1214
1369
|
info: z.literal('built-in permissions'),
|
|
1215
|
-
filter: z.optional(PermissionFilterSchema).describe('Filter for built-in permissions')
|
|
1216
|
-
}).strict().describe('Built-in permissions query'),
|
|
1370
|
+
filter: z.optional(PermissionFilterSchema).describe('Filter for built-in permissions. Use operation:"compensation_fund_add" to find which permission a specific operation requires.')
|
|
1371
|
+
}).strict().describe('Built-in permissions query. Each permission includes an optional "operation" field that maps to the SDK/MCP Call*_Data field name triggering it. Use this to answer: "What permission does operation X require?" — e.g. filter operation:"compensation_fund_add" returns permission index 315 (service.compensation_fund_deposit).'),
|
|
1372
|
+
z.object({
|
|
1373
|
+
info: z.literal('common mistakes'),
|
|
1374
|
+
filter: z.optional(CommonMistakeFilterSchema).describe('Filter for common mistakes. Use operation:"compensation_fund_add" to find mistakes for a specific operation, or category:"field_name" for all field-name mistakes.')
|
|
1375
|
+
}).strict().describe('Common mistakes query. Returns known field-name, unit, value-range, workflow, and timing pitfalls for on-chain operations. Use this to proactively warn users before submitting a transaction. Example: query operation:"compensation_fund_add" to learn about the {amount} vs {balance} field name mistake.'),
|
|
1217
1376
|
z.object({
|
|
1218
1377
|
info: z.literal('guard instructions'),
|
|
1219
1378
|
filter: z.optional(GuardInstructFilterOptionsSchema).describe('Filter for guard instructions')
|
|
@@ -1238,7 +1397,11 @@ export const ProtocolInfoResultWrappedSchema = z.discriminatedUnion('info', [
|
|
|
1238
1397
|
}),
|
|
1239
1398
|
z.object({
|
|
1240
1399
|
info: z.literal('built-in permissions'),
|
|
1241
|
-
result: z.array(PermissionInfoTypeSchema).describe('Built-in permissions result')
|
|
1400
|
+
result: z.array(PermissionInfoTypeSchema).describe('Built-in permissions result. Each item includes an optional "operation" field mapping to the SDK/MCP field name that triggers this permission.')
|
|
1401
|
+
}),
|
|
1402
|
+
z.object({
|
|
1403
|
+
info: z.literal('common mistakes'),
|
|
1404
|
+
result: z.array(CommonMistakeInfoSchema).describe('Common mistakes result. Each item documents a known pitfall (wrong field name, wrong unit, wrong workflow order, etc.) with wrong/correct examples.')
|
|
1242
1405
|
}),
|
|
1243
1406
|
z.object({
|
|
1244
1407
|
info: z.literal('guard instructions'),
|
|
@@ -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", "search_examples"]>;
|
|
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" | "search_examples";
|
|
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" | "search_examples";
|
|
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;
|
|
@@ -27,27 +36,80 @@ export declare const SchemaQueryOutputSchema: z.ZodObject<{
|
|
|
27
36
|
name: string;
|
|
28
37
|
description?: string | undefined;
|
|
29
38
|
title?: string | undefined;
|
|
39
|
+
}>, "many">, z.ZodArray<z.ZodObject<{
|
|
40
|
+
file: z.ZodString;
|
|
41
|
+
title: z.ZodString;
|
|
42
|
+
description: z.ZodString;
|
|
43
|
+
tags: z.ZodArray<z.ZodString, "many">;
|
|
44
|
+
industry: z.ZodString;
|
|
45
|
+
operation_type: z.ZodString;
|
|
46
|
+
verified: z.ZodBoolean;
|
|
47
|
+
score: z.ZodNumber;
|
|
48
|
+
matched_fields: z.ZodArray<z.ZodString, "many">;
|
|
49
|
+
}, "strict", z.ZodTypeAny, {
|
|
50
|
+
description: string;
|
|
51
|
+
title: string;
|
|
52
|
+
score: number;
|
|
53
|
+
tags: string[];
|
|
54
|
+
file: string;
|
|
55
|
+
industry: string;
|
|
56
|
+
operation_type: string;
|
|
57
|
+
verified: boolean;
|
|
58
|
+
matched_fields: string[];
|
|
59
|
+
}, {
|
|
60
|
+
description: string;
|
|
61
|
+
title: string;
|
|
62
|
+
score: number;
|
|
63
|
+
tags: string[];
|
|
64
|
+
file: string;
|
|
65
|
+
industry: string;
|
|
66
|
+
operation_type: string;
|
|
67
|
+
verified: boolean;
|
|
68
|
+
matched_fields: string[];
|
|
30
69
|
}>, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodNull]>;
|
|
31
70
|
message: z.ZodString;
|
|
32
71
|
suggestions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
72
|
+
output_file_path: z.ZodOptional<z.ZodString>;
|
|
33
73
|
}, "strict", z.ZodTypeAny, {
|
|
34
74
|
message: string;
|
|
35
75
|
data: Record<string, unknown> | {
|
|
36
76
|
name: string;
|
|
37
77
|
description?: string | undefined;
|
|
38
78
|
title?: string | undefined;
|
|
79
|
+
}[] | {
|
|
80
|
+
description: string;
|
|
81
|
+
title: string;
|
|
82
|
+
score: number;
|
|
83
|
+
tags: string[];
|
|
84
|
+
file: string;
|
|
85
|
+
industry: string;
|
|
86
|
+
operation_type: string;
|
|
87
|
+
verified: boolean;
|
|
88
|
+
matched_fields: string[];
|
|
39
89
|
}[] | null;
|
|
40
90
|
success: boolean;
|
|
41
91
|
action: string;
|
|
42
92
|
suggestions?: string[] | undefined;
|
|
93
|
+
output_file_path?: string | undefined;
|
|
43
94
|
}, {
|
|
44
95
|
message: string;
|
|
45
96
|
data: Record<string, unknown> | {
|
|
46
97
|
name: string;
|
|
47
98
|
description?: string | undefined;
|
|
48
99
|
title?: string | undefined;
|
|
100
|
+
}[] | {
|
|
101
|
+
description: string;
|
|
102
|
+
title: string;
|
|
103
|
+
score: number;
|
|
104
|
+
tags: string[];
|
|
105
|
+
file: string;
|
|
106
|
+
industry: string;
|
|
107
|
+
operation_type: string;
|
|
108
|
+
verified: boolean;
|
|
109
|
+
matched_fields: string[];
|
|
49
110
|
}[] | null;
|
|
50
111
|
success: boolean;
|
|
51
112
|
action: string;
|
|
52
113
|
suggestions?: string[] | undefined;
|
|
114
|
+
output_file_path?: string | undefined;
|
|
53
115
|
}>;
|
|
@@ -8,16 +8,31 @@ export const SchemaQueryInputSchema = z
|
|
|
8
8
|
"get_output",
|
|
9
9
|
"search",
|
|
10
10
|
"list_operations",
|
|
11
|
+
"get_guard_templates",
|
|
12
|
+
"get_field",
|
|
13
|
+
"search_examples",
|
|
11
14
|
])
|
|
12
|
-
.describe("Action to perform: 'list'
|
|
15
|
+
.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), 'search_examples' (search verified example files by keyword — matches title, description, tags, operation_type, industry)."),
|
|
13
16
|
name: z
|
|
14
17
|
.string()
|
|
15
18
|
.optional()
|
|
16
|
-
.describe("Schema/tool name for 'get'/'get_output' action (e.g., 'onchain_operations', '
|
|
19
|
+
.describe("Schema/tool name for 'get'/'get_output'/'get_field' action (e.g., 'onchain_operations', 'onchain_operations_machine')."),
|
|
17
20
|
query: z
|
|
18
21
|
.string()
|
|
19
22
|
.optional()
|
|
20
23
|
.describe("Search query for 'search' action"),
|
|
24
|
+
field_path: z
|
|
25
|
+
.string()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe("Dot-separated field path for 'get_field' action (e.g. 'data.node', 'data.node.nodes.0.pairs'). Navigates schema.properties.* and schema.items.*."),
|
|
28
|
+
template: z
|
|
29
|
+
.string()
|
|
30
|
+
.optional()
|
|
31
|
+
.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."),
|
|
32
|
+
output_file: z
|
|
33
|
+
.string()
|
|
34
|
+
.optional()
|
|
35
|
+
.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
36
|
})
|
|
22
37
|
.strict();
|
|
23
38
|
const SchemaListItemSchema = z
|
|
@@ -27,6 +42,19 @@ const SchemaListItemSchema = z
|
|
|
27
42
|
description: z.string().optional().describe("Short description, if known."),
|
|
28
43
|
})
|
|
29
44
|
.strict();
|
|
45
|
+
const ExampleSearchResultSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
file: z.string().describe("Example file name (e.g. 'rental-ziroom-service-create.json')."),
|
|
48
|
+
title: z.string().describe("Human-readable title from the example metadata."),
|
|
49
|
+
description: z.string().describe("Longer description from the example metadata."),
|
|
50
|
+
tags: z.array(z.string()).describe("Tags from the example metadata."),
|
|
51
|
+
industry: z.string().describe("Industry category (e.g. 'rental', 'retail', 'general')."),
|
|
52
|
+
operation_type: z.string().describe("Operation type (e.g. 'service', 'machine', 'guard', 'permission')."),
|
|
53
|
+
verified: z.boolean().describe("Whether the example is marked as verified."),
|
|
54
|
+
score: z.number().describe("Relevance score — number of fields that matched the query (0-5)."),
|
|
55
|
+
matched_fields: z.array(z.string()).describe("List of fields that matched the query."),
|
|
56
|
+
})
|
|
57
|
+
.strict();
|
|
30
58
|
export const SchemaQueryOutputSchema = z
|
|
31
59
|
.object({
|
|
32
60
|
success: z.boolean().describe("Whether the request was successful"),
|
|
@@ -34,14 +62,19 @@ export const SchemaQueryOutputSchema = z
|
|
|
34
62
|
data: z
|
|
35
63
|
.union([
|
|
36
64
|
z.array(SchemaListItemSchema).describe("List of schema summaries (list/search/list_operations)."),
|
|
37
|
-
z.
|
|
38
|
-
z.
|
|
65
|
+
z.array(ExampleSearchResultSchema).describe("List of matching examples (search_examples)."),
|
|
66
|
+
z.record(z.unknown()).describe("JSON Schema object (get/get_output/get_field) or Guard template data."),
|
|
67
|
+
z.null().describe("No data — lookup failed or returned nothing, or data was written to output_file."),
|
|
39
68
|
])
|
|
40
|
-
.describe("Response data — array of schema summaries for list-like actions, JSON Schema object for get/get_output, null on failure."),
|
|
69
|
+
.describe("Response data — array of schema summaries for list-like actions, array of example results for search_examples, 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
70
|
message: z.string().describe("Human-readable message describing the result"),
|
|
42
71
|
suggestions: z
|
|
43
72
|
.array(z.string())
|
|
44
73
|
.optional()
|
|
45
74
|
.describe("Suggested next steps or alternatives"),
|
|
75
|
+
output_file_path: z
|
|
76
|
+
.string()
|
|
77
|
+
.optional()
|
|
78
|
+
.describe("When output_file is used, contains the absolute file path where data was written."),
|
|
46
79
|
})
|
|
47
80
|
.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();
|
|
@@ -249,6 +249,19 @@ export function parseMachineNodesFromText(text) {
|
|
|
249
249
|
if (errors.length > 0) {
|
|
250
250
|
return { success: false, errors };
|
|
251
251
|
}
|
|
252
|
+
const hasEntryForward = nodes.some(node => node.pairs.some(pair => pair.prev_node === ""));
|
|
253
|
+
if (!hasEntryForward) {
|
|
254
|
+
return {
|
|
255
|
+
success: false,
|
|
256
|
+
errors: [{
|
|
257
|
+
message: 'Machine has no entry forward. At least one node must have a pair with prev_node="" (empty string), ' +
|
|
258
|
+
'which defines how Progress advances from the initial state (current="") to the first node. ' +
|
|
259
|
+
'Without an entry forward, the workflow will be permanently stuck. ' +
|
|
260
|
+
'Example: {name: "Subscribed", pairs: [{prev_node: "", forwards: [{name: "Subscribe", weight: 1}]}]}',
|
|
261
|
+
path: '/',
|
|
262
|
+
}]
|
|
263
|
+
};
|
|
264
|
+
}
|
|
252
265
|
return { success: true, data: nodes, errors: [] };
|
|
253
266
|
}
|
|
254
267
|
export function formatNodeErrors(errors) {
|
|
@@ -265,7 +278,7 @@ export function validateMachineNode(node) {
|
|
|
265
278
|
return validateWithZod(MachineNodeSchema, node);
|
|
266
279
|
}
|
|
267
280
|
export function validateMachineNodePair(pair) {
|
|
268
|
-
const result =
|
|
281
|
+
const result = MachineNodePairSchema.safeParse(pair);
|
|
269
282
|
if (result.success) {
|
|
270
283
|
return { success: true, errors: [] };
|
|
271
284
|
}
|
|
@@ -276,7 +289,7 @@ export function validateMachineNodePair(pair) {
|
|
|
276
289
|
return { success: false, errors };
|
|
277
290
|
}
|
|
278
291
|
export function validateMachineForward(forward) {
|
|
279
|
-
const result =
|
|
292
|
+
const result = MachineForwardSchema.safeParse(forward);
|
|
280
293
|
if (result.success) {
|
|
281
294
|
return { success: true, errors: [] };
|
|
282
295
|
}
|
|
@@ -325,7 +338,10 @@ export function machineNodesToMarkdown(nodes, options = {}) {
|
|
|
325
338
|
for (const forward of pair.forwards) {
|
|
326
339
|
const namedOp = forward.namedOperator || '';
|
|
327
340
|
const permIdx = forward.permissionIndex?.toString() || '';
|
|
328
|
-
const
|
|
341
|
+
const guardRaw = forward.guard;
|
|
342
|
+
const guard = typeof guardRaw === 'string'
|
|
343
|
+
? guardRaw
|
|
344
|
+
: (guardRaw?.guard || '');
|
|
329
345
|
md += `| ${forward.name} | ${forward.weight} | ${namedOp} | ${permIdx} | ${guard} |\n`;
|
|
330
346
|
}
|
|
331
347
|
md += `\n`;
|