@wowok/agent-mcp 3.0.2 → 3.0.4
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/LICENSE +0 -3
- package/dist/harness/recover.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/knowledge/account-marks.js +1 -1
- package/dist/knowledge/arbitration-risk.js +1 -1
- package/dist/knowledge/event-semantics.js +1 -1
- package/dist/knowledge/flywheel-loop.d.ts +4 -52
- package/dist/knowledge/flywheel-loop.js +1 -1
- package/dist/knowledge/guard-lint.js +1 -1
- package/dist/knowledge/guard-puzzle.js +1 -1
- package/dist/knowledge/index.d.ts +2 -225
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/machine-risk.js +1 -1
- package/dist/knowledge/machine-translation.js +1 -1
- package/dist/knowledge/onchain-constants.js +1 -1
- package/dist/knowledge/order-ledger.d.ts +2 -2
- package/dist/knowledge/order-ledger.js +1 -1
- package/dist/knowledge/order-puzzle.d.ts +4 -4
- package/dist/knowledge/order-puzzle.js +1 -1
- package/dist/knowledge/order-risk.d.ts +1 -0
- package/dist/knowledge/order-risk.js +1 -1
- package/dist/knowledge/order-templates.d.ts +1 -1
- package/dist/knowledge/order-templates.js +1 -1
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/service-risk.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/workspace-lists.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/context-assembly.d.ts +3 -1
- package/dist/playbooks/service-build/context-assembly.js +1 -1
- package/dist/playbooks/service-build/machine-nodes.d.ts +2 -0
- package/dist/playbooks/service-build/machine-nodes.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.d.ts +7 -0
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/review/machine.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/allocation.d.ts +5 -0
- package/dist/schema/call/arbitration.d.ts +5 -0
- package/dist/schema/call/base.d.ts +17 -3
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +29 -0
- package/dist/schema/call/bridge.js +1 -1
- package/dist/schema/call/contact.d.ts +5 -0
- package/dist/schema/call/demand.d.ts +5 -0
- package/dist/schema/call/error-codes.d.ts +2 -0
- package/dist/schema/call/error-codes.js +1 -0
- package/dist/schema/call/guard.d.ts +19 -4
- package/dist/schema/call/machine.d.ts +10 -0
- package/dist/schema/call/order.d.ts +5 -0
- package/dist/schema/call/payment.d.ts +5 -0
- package/dist/schema/call/permission.d.ts +5 -0
- package/dist/schema/call/personal.d.ts +5 -0
- package/dist/schema/call/progress.d.ts +5 -0
- package/dist/schema/call/proof.d.ts +10 -0
- package/dist/schema/call/repository.d.ts +5 -0
- package/dist/schema/call/reward.d.ts +5 -0
- package/dist/schema/call/semantic.d.ts +9 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +5 -0
- package/dist/schema/call/treasury.d.ts +5 -0
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/goal/index.d.ts +3 -3
- package/dist/schema/goal/planning.d.ts +2 -2
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +4 -4
- package/dist/schema/industry-pack/modes.d.ts +4 -4
- package/dist/schema/interaction/index.d.ts +34 -0
- package/dist/schema/interaction/index.js +1 -0
- package/dist/schema/local/index.d.ts +558 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +31 -25
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +91 -1
- package/dist/schema/operations.js +1 -1
- package/dist/schema/persona/index.d.ts +2 -2
- package/dist/schema/query/bi.d.ts +0 -4
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-query/index.d.ts +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/trust/index.d.ts +3 -3
- package/dist/schema/workspace/index.d.ts +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +4 -0
- package/dist/schemas/ask_user.output.json +54 -0
- package/dist/schemas/ask_user.schema.json +78 -0
- package/dist/schemas/bridge_operation.output.json +4 -0
- package/dist/schemas/bridge_operation.schema.json +50 -5
- package/dist/schemas/guard2file.schema.json +10 -1
- package/dist/schemas/index.json +13 -1
- package/dist/schemas/local_history_operation.output.json +1458 -0
- package/dist/schemas/local_history_operation.schema.json +105 -0
- package/dist/schemas/local_info_operation.output.json +4 -0
- package/dist/schemas/local_mark_operation.output.json +4 -0
- package/dist/schemas/machineNode2file.schema.json +10 -1
- package/dist/schemas/messenger_operation.output.json +8 -0
- package/dist/schemas/messenger_operation.schema.json +8 -0
- package/dist/schemas/onchain_events.output.json +2 -2
- package/dist/schemas/onchain_operations.output.json +4 -1
- package/dist/schemas/onchain_operations.schema.json +210 -28
- package/dist/schemas/onchain_operations_allocation.schema.json +10 -1
- package/dist/schemas/onchain_operations_arbitration.schema.json +10 -1
- package/dist/schemas/onchain_operations_contact.schema.json +10 -1
- package/dist/schemas/onchain_operations_demand.schema.json +10 -1
- package/dist/schemas/onchain_operations_gen_passport.schema.json +10 -1
- package/dist/schemas/onchain_operations_gen_proof.schema.json +10 -1
- package/dist/schemas/onchain_operations_guard.schema.json +40 -11
- package/dist/schemas/onchain_operations_machine.schema.json +10 -1
- package/dist/schemas/onchain_operations_order.schema.json +10 -1
- package/dist/schemas/onchain_operations_payment.schema.json +10 -1
- package/dist/schemas/onchain_operations_permission.schema.json +10 -1
- package/dist/schemas/onchain_operations_personal.schema.json +10 -1
- package/dist/schemas/onchain_operations_progress.schema.json +10 -1
- package/dist/schemas/onchain_operations_proof.schema.json +10 -1
- package/dist/schemas/onchain_operations_repository.schema.json +10 -1
- package/dist/schemas/onchain_operations_reward.schema.json +10 -1
- package/dist/schemas/onchain_operations_service.schema.json +10 -1
- package/dist/schemas/onchain_operations_treasury.schema.json +10 -1
- package/dist/schemas/query_toolkit.output.json +17 -16
- package/dist/schemas/query_toolkit.schema.json +1 -1
- package/dist/tools/handlers/ask-user.d.ts +3 -0
- package/dist/tools/handlers/ask-user.js +1 -0
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/local.d.ts +1 -0
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry/bridge.js +1 -1
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/registry/interaction.d.ts +2 -0
- package/dist/tools/registry/interaction.js +1 -0
- package/dist/tools/registry/local.js +1 -1
- package/dist/tools/registry/monitor.js +1 -1
- package/dist/tools/registry/onchain.js +1 -1
- package/dist/tools/registry/query.js +1 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/types.d.ts +7 -1
- package/dist/tools/wrap.d.ts +3 -3
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
- package/dist/knowledge/allocation-confirm.d.ts +0 -115
- package/dist/knowledge/allocation-confirm.js +0 -1
- package/dist/knowledge/allocation-context.d.ts +0 -58
- package/dist/knowledge/allocation-context.js +0 -1
- package/dist/knowledge/allocation-translation.d.ts +0 -72
- package/dist/knowledge/allocation-translation.js +0 -1
- package/dist/knowledge/arb-confirm.d.ts +0 -28
- package/dist/knowledge/arb-confirm.js +0 -1
- package/dist/knowledge/arb-translation.d.ts +0 -48
- package/dist/knowledge/arb-translation.js +0 -1
- package/dist/knowledge/arbitration-confirm.d.ts +0 -135
- package/dist/knowledge/arbitration-confirm.js +0 -1
- package/dist/knowledge/arbitration-context.d.ts +0 -81
- package/dist/knowledge/arbitration-context.js +0 -1
- package/dist/knowledge/arbitration-translation.d.ts +0 -91
- package/dist/knowledge/arbitration-translation.js +0 -1
- package/dist/knowledge/bridge-confirm.d.ts +0 -26
- package/dist/knowledge/bridge-confirm.js +0 -1
- package/dist/knowledge/bridge-translation.d.ts +0 -37
- package/dist/knowledge/bridge-translation.js +0 -1
- package/dist/knowledge/contact-confirm.d.ts +0 -27
- package/dist/knowledge/contact-confirm.js +0 -1
- package/dist/knowledge/contact-translation.d.ts +0 -39
- package/dist/knowledge/contact-translation.js +0 -1
- package/dist/knowledge/demand-confirm.d.ts +0 -32
- package/dist/knowledge/demand-confirm.js +0 -1
- package/dist/knowledge/demand-context.d.ts +0 -17
- package/dist/knowledge/demand-context.js +0 -1
- package/dist/knowledge/demand-ledger.d.ts +0 -26
- package/dist/knowledge/demand-ledger.js +0 -1
- package/dist/knowledge/demand-puzzle.d.ts +0 -29
- package/dist/knowledge/demand-puzzle.js +0 -1
- package/dist/knowledge/demand-templates.d.ts +0 -12
- package/dist/knowledge/demand-templates.js +0 -1
- package/dist/knowledge/demand-translation.d.ts +0 -55
- package/dist/knowledge/demand-translation.js +0 -1
- package/dist/knowledge/examples-scanner-cli.d.ts +0 -1
- package/dist/knowledge/examples-scanner-cli.js +0 -1
- package/dist/knowledge/examples-scanner.d.ts +0 -121
- package/dist/knowledge/examples-scanner.js +0 -1
- package/dist/knowledge/glossary.d.ts +0 -18
- package/dist/knowledge/glossary.js +0 -1
- package/dist/knowledge/guard-bytecode-spec.d.ts +0 -82
- package/dist/knowledge/guard-bytecode-spec.js +0 -1
- package/dist/knowledge/guard-confirm.d.ts +0 -86
- package/dist/knowledge/guard-confirm.js +0 -1
- package/dist/knowledge/immutability.d.ts +0 -11
- package/dist/knowledge/immutability.js +0 -1
- package/dist/knowledge/machine-confirm.d.ts +0 -102
- package/dist/knowledge/machine-confirm.js +0 -1
- package/dist/knowledge/machine-context.d.ts +0 -160
- package/dist/knowledge/machine-context.js +0 -1
- package/dist/knowledge/machine-render.d.ts +0 -41
- package/dist/knowledge/machine-render.js +0 -1
- package/dist/knowledge/mcp-schema-audit-cli.d.ts +0 -1
- package/dist/knowledge/mcp-schema-audit-cli.js +0 -1
- package/dist/knowledge/mcp-schema-audit.d.ts +0 -91
- package/dist/knowledge/mcp-schema-audit.js +0 -1
- package/dist/knowledge/messenger-guard-guidance.d.ts +0 -17
- package/dist/knowledge/messenger-guard-guidance.js +0 -1
- package/dist/knowledge/order-confirm.d.ts +0 -115
- package/dist/knowledge/order-confirm.js +0 -1
- package/dist/knowledge/order-context.d.ts +0 -66
- package/dist/knowledge/order-context.js +0 -1
- package/dist/knowledge/order-translation.d.ts +0 -78
- package/dist/knowledge/order-translation.js +0 -1
- package/dist/knowledge/overrides-loader.d.ts +0 -13
- package/dist/knowledge/overrides-loader.js +0 -1
- package/dist/knowledge/passport-confirm.d.ts +0 -130
- package/dist/knowledge/passport-confirm.js +0 -1
- package/dist/knowledge/passport-context.d.ts +0 -59
- package/dist/knowledge/passport-context.js +0 -1
- package/dist/knowledge/passport-puzzle.d.ts +0 -108
- package/dist/knowledge/passport-puzzle.js +0 -1
- package/dist/knowledge/passport-risk.d.ts +0 -70
- package/dist/knowledge/passport-risk.js +0 -1
- package/dist/knowledge/passport-translation.d.ts +0 -68
- package/dist/knowledge/passport-translation.js +0 -1
- package/dist/knowledge/payment-confirm.d.ts +0 -26
- package/dist/knowledge/payment-confirm.js +0 -1
- package/dist/knowledge/payment-translation.d.ts +0 -37
- package/dist/knowledge/payment-translation.js +0 -1
- package/dist/knowledge/permission-confirm.d.ts +0 -110
- package/dist/knowledge/permission-confirm.js +0 -1
- package/dist/knowledge/permission-context.d.ts +0 -69
- package/dist/knowledge/permission-context.js +0 -1
- package/dist/knowledge/permission-translation.d.ts +0 -57
- package/dist/knowledge/permission-translation.js +0 -1
- package/dist/knowledge/personal-confirm.d.ts +0 -29
- package/dist/knowledge/personal-confirm.js +0 -1
- package/dist/knowledge/personal-translation.d.ts +0 -37
- package/dist/knowledge/personal-translation.js +0 -1
- package/dist/knowledge/process-model.d.ts +0 -14
- package/dist/knowledge/process-model.js +0 -1
- package/dist/knowledge/progress-confirm.d.ts +0 -108
- package/dist/knowledge/progress-confirm.js +0 -1
- package/dist/knowledge/progress-context.d.ts +0 -123
- package/dist/knowledge/progress-context.js +0 -1
- package/dist/knowledge/progress-translation.d.ts +0 -52
- package/dist/knowledge/progress-translation.js +0 -1
- package/dist/knowledge/proof-confirm.d.ts +0 -31
- package/dist/knowledge/proof-confirm.js +0 -1
- package/dist/knowledge/proof-context.d.ts +0 -17
- package/dist/knowledge/proof-context.js +0 -1
- package/dist/knowledge/proof-ledger.d.ts +0 -34
- package/dist/knowledge/proof-ledger.js +0 -1
- package/dist/knowledge/proof-puzzle.d.ts +0 -35
- package/dist/knowledge/proof-puzzle.js +0 -1
- package/dist/knowledge/proof-templates.d.ts +0 -22
- package/dist/knowledge/proof-templates.js +0 -1
- package/dist/knowledge/proof-translation.d.ts +0 -52
- package/dist/knowledge/proof-translation.js +0 -1
- package/dist/knowledge/registrar-confirm.d.ts +0 -26
- package/dist/knowledge/registrar-confirm.js +0 -1
- package/dist/knowledge/registrar-translation.d.ts +0 -37
- package/dist/knowledge/registrar-translation.js +0 -1
- package/dist/knowledge/repository-confirm.d.ts +0 -40
- package/dist/knowledge/repository-confirm.js +0 -1
- package/dist/knowledge/repository-context.d.ts +0 -12
- package/dist/knowledge/repository-context.js +0 -1
- package/dist/knowledge/repository-ledger.d.ts +0 -25
- package/dist/knowledge/repository-ledger.js +0 -1
- package/dist/knowledge/repository-puzzle.d.ts +0 -30
- package/dist/knowledge/repository-puzzle.js +0 -1
- package/dist/knowledge/repository-templates.d.ts +0 -14
- package/dist/knowledge/repository-templates.js +0 -1
- package/dist/knowledge/repository-translation.d.ts +0 -58
- package/dist/knowledge/repository-translation.js +0 -1
- package/dist/knowledge/resource-confirm.d.ts +0 -25
- package/dist/knowledge/resource-confirm.js +0 -1
- package/dist/knowledge/resource-translation.d.ts +0 -37
- package/dist/knowledge/resource-translation.js +0 -1
- package/dist/knowledge/reward-confirm.d.ts +0 -116
- package/dist/knowledge/reward-confirm.js +0 -1
- package/dist/knowledge/reward-context.d.ts +0 -127
- package/dist/knowledge/reward-context.js +0 -1
- package/dist/knowledge/reward-translation.d.ts +0 -58
- package/dist/knowledge/reward-translation.js +0 -1
- package/dist/knowledge/service-confirm.d.ts +0 -161
- package/dist/knowledge/service-confirm.js +0 -1
- package/dist/knowledge/service-context.d.ts +0 -66
- package/dist/knowledge/service-context.js +0 -1
- package/dist/knowledge/service-translation.d.ts +0 -103
- package/dist/knowledge/service-translation.js +0 -1
- package/dist/knowledge/treasury-confirm.d.ts +0 -133
- package/dist/knowledge/treasury-confirm.js +0 -1
- package/dist/knowledge/treasury-context.d.ts +0 -64
- package/dist/knowledge/treasury-context.js +0 -1
- package/dist/knowledge/treasury-translation.d.ts +0 -78
- package/dist/knowledge/treasury-translation.js +0 -1
- package/dist/knowledge/util-confirm.d.ts +0 -24
- package/dist/knowledge/util-confirm.js +0 -1
- package/dist/knowledge/util-translation.d.ts +0 -39
- package/dist/knowledge/util-translation.js +0 -1
- package/dist/loop-engineering/aggregate.d.ts +0 -50
- package/dist/loop-engineering/aggregate.js +0 -1
- package/dist/loop-engineering/context-collect.d.ts +0 -7
- package/dist/loop-engineering/context-collect.js +0 -1
- package/dist/loop-engineering/diagnose.d.ts +0 -22
- package/dist/loop-engineering/diagnose.js +0 -1
- package/dist/loop-engineering/improve.d.ts +0 -55
- package/dist/loop-engineering/improve.js +0 -1
- package/dist/loop-engineering/index.d.ts +0 -4
- package/dist/loop-engineering/index.js +0 -1
- package/dist/loop-engineering/pipeline.d.ts +0 -17
- package/dist/loop-engineering/pipeline.js +0 -1
- package/dist/schema/utils/object-type-utils.d.ts +0 -12
- package/dist/schema/utils/object-type-utils.js +0 -1
- package/dist/telemetry/index.d.ts +0 -19
- package/dist/telemetry/index.js +0 -1
- package/dist/telemetry/redact.d.ts +0 -2
- package/dist/telemetry/redact.js +0 -1
- package/dist/telemetry/storage.d.ts +0 -8
- package/dist/telemetry/storage.js +0 -1
|
@@ -22,13 +22,13 @@ export declare const SchemaQueryInputSchema: z.ZodObject<{
|
|
|
22
22
|
reward: "reward";
|
|
23
23
|
permission: "permission";
|
|
24
24
|
guard: "guard";
|
|
25
|
-
allocation: "allocation";
|
|
26
25
|
order: "order";
|
|
27
26
|
service: "service";
|
|
28
27
|
machine: "machine";
|
|
29
28
|
treasury: "treasury";
|
|
30
29
|
arbitration: "arbitration";
|
|
31
30
|
progress: "progress";
|
|
31
|
+
allocation: "allocation";
|
|
32
32
|
passport: "passport";
|
|
33
33
|
}>>;
|
|
34
34
|
params: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as a299a from'@wowok/wowok';const SDK_SCHEMA_VERSION=a299a['SCHEMA_VERSION']??'1.0.0',checkSchemaCompatibility=a299a['checkSchemaCompatibility']??((a,b)=>({'compatible':!![]}));export const MCP_SCHEMA_VERSION='1.0.0';export function getSchemaVersions(){return{'sdk':SDK_SCHEMA_VERSION,'mcp':MCP_SCHEMA_VERSION};}export function checkClientSchemaCompatibility(a,b={}){const c=getSchemaVersions(),d={'compatible':!![],'warnings':[],'errors':[],'versions':c,'client_version':a};if(!a)return d;const e=checkSchemaCompatibility(a,c['sdk']);if(!e['compatible']){d['compatible']=![];const g='SDK\x20schema\x20incompatibility:\x20'+e['reason'];b['mode']==='strict'?d['errors']['push'](g):d['warnings']['push'](g);}const f=checkSchemaCompatibility(a,c['mcp']);if(!f['compatible']){d['compatible']=![];const h='MCP\x20schema\x20incompatibility:\x20'+f['reason'];b['mode']==='strict'?d['errors']['push'](h):d['warnings']['push'](h);}return d;}export function attachSchemaWarning(a,b){if(b['warnings']['length']===0x0&&b['errors']['length']===0x0)return a;const c=[];b['warnings']['length']>0x0&&c['push'](...b['warnings']);b['errors']['length']>0x0&&c['push'](...b['errors']);const d=a['semantic']?{...a['semantic'],'warnings':[...a['semantic']['warnings']||[],...c]}:undefined;return{...a,'semantic':d,'schema_warning':{'compatible':b['compatible'],'warnings':c,'client_version':b['client_version'],'server_versions':b['versions']}};}
|
|
@@ -166,8 +166,8 @@ export declare const TrustScoreOutputSchema: z.ZodObject<{
|
|
|
166
166
|
advice: z.ZodArray<z.ZodString>;
|
|
167
167
|
dimensions: z.ZodArray<z.ZodObject<{
|
|
168
168
|
name: z.ZodEnum<{
|
|
169
|
-
fund: "fund";
|
|
170
169
|
workflow: "workflow";
|
|
170
|
+
fund: "fund";
|
|
171
171
|
trust: "trust";
|
|
172
172
|
behavior: "behavior";
|
|
173
173
|
}>;
|
|
@@ -176,8 +176,8 @@ export declare const TrustScoreOutputSchema: z.ZodObject<{
|
|
|
176
176
|
checks: z.ZodArray<z.ZodObject<{
|
|
177
177
|
id: z.ZodString;
|
|
178
178
|
dimension: z.ZodEnum<{
|
|
179
|
-
fund: "fund";
|
|
180
179
|
workflow: "workflow";
|
|
180
|
+
fund: "fund";
|
|
181
181
|
trust: "trust";
|
|
182
182
|
behavior: "behavior";
|
|
183
183
|
}>;
|
|
@@ -240,8 +240,8 @@ export declare const TrustScoreOutputSchema: z.ZodObject<{
|
|
|
240
240
|
checks: z.ZodArray<z.ZodObject<{
|
|
241
241
|
id: z.ZodString;
|
|
242
242
|
dimension: z.ZodEnum<{
|
|
243
|
-
fund: "fund";
|
|
244
243
|
workflow: "workflow";
|
|
244
|
+
fund: "fund";
|
|
245
245
|
trust: "trust";
|
|
246
246
|
behavior: "behavior";
|
|
247
247
|
}>;
|
|
@@ -3,13 +3,13 @@ export declare const WorkspaceOperationInputSchema: z.ZodObject<{
|
|
|
3
3
|
action: z.ZodEnum<{
|
|
4
4
|
rename: "rename";
|
|
5
5
|
list: "list";
|
|
6
|
-
read: "read";
|
|
7
6
|
delete: "delete";
|
|
8
7
|
resolve: "resolve";
|
|
9
8
|
create_file: "create_file";
|
|
10
9
|
create_dir: "create_dir";
|
|
11
10
|
copy: "copy";
|
|
12
11
|
move: "move";
|
|
12
|
+
read: "read";
|
|
13
13
|
write: "write";
|
|
14
14
|
}>;
|
|
15
15
|
path: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync,existsSync,writeFileSync,mkdirSync}from'fs';import{resolve,join,dirname}from'path';import{fileURLToPath}from'url';import{TOOLS_REFERENCE,getToolReference,searchToolReference,getToolSequence}from'../knowledge/tools-reference.js';import{GUARD_DESIGN_PATTERNS,getGuardDesignPattern,GUARD_DESIGN_PATTERNS_VERSION}from'../knowledge/guard-design-patterns.js';import{OBJECT_REUSE_RULES,CREATE_VS_MODIFY_PATTERN,IMMUTABILITY_RULES,OPERATION_TYPE_CLASSIFICATION,OPERATION_CLASS_META,NAMING_CONVENTIONS,SAFETY_RULES_VERSION}from'../knowledge/safety-rules.js';import{listTemplates as a392a,getTemplateDetail,instantiateTemplate,getTemplateCounts,TEMPLATE_OBJECT_TYPES}from'../knowledge/template-registry.js';import{lintGuard,formatLintResult}from'../knowledge/guard-lint.js';import{renderGuardTreeIndented,renderGuardMermaid}from'../knowledge/guard-render.js';const __filename=fileURLToPath(import.meta.url),__dirname=fileURLToPath(new URL('.',import.meta.url)),SCHEMAS_DIR=resolve(__dirname,'../../dist/schemas'),GUARD_TEMPLATES_PATH_SCRIPTS=resolve(__dirname,'../../scripts/guard-templates.json'),GUARD_TEMPLATES_PATH_DIST=resolve(__dirname,'../../dist/schemas/guard-templates.json'),GUARD_TEMPLATES_PATH=existsSync(GUARD_TEMPLATES_PATH_SCRIPTS)?GUARD_TEMPLATES_PATH_SCRIPTS:GUARD_TEMPLATES_PATH_DIST,WORKSPACE_TMP_DIR=resolve(process['cwd'](),'.trae','tmp');export function areSchemasAvailable(){return existsSync(SCHEMAS_DIR)&&existsSync(join(SCHEMAS_DIR,'index.json'));}export function getSchemaIndex(){try{const a=join(SCHEMAS_DIR,'index.json');if(!existsSync(a))return null;const b=readFileSync(a,'utf-8');return JSON['parse'](b);}catch{return null;}}export function listSchemas(){const a=getSchemaIndex();if(!a)return[];return[...a['tools']||[],...a['operations']||[]];}export function getSchema(a){try{let b=join(SCHEMAS_DIR,a+'.schema.json');!existsSync(b)&&(b=join(SCHEMAS_DIR,a+'.json'));if(!existsSync(b))return null;const c=readFileSync(b,'utf-8'),d=JSON['parse'](c);return resolveSchemaRefs(d);}catch{return null;}}export function getOutputSchema(a){try{const b=join(SCHEMAS_DIR,a+'.output.json');if(!existsSync(b))return null;const c=readFileSync(b,'utf-8'),d=JSON['parse'](c);return resolveSchemaRefs(d);}catch{return null;}}export function getGuardTemplates(a){try{if(!existsSync(GUARD_TEMPLATES_PATH))return null;const b=readFileSync(GUARD_TEMPLATES_PATH,'utf-8'),c=JSON['parse'](b);if(!a)return{'version':c['version'],'description':c['description'],'templates':(c['templates']||[])['map'](e=>({'name':e['name'],'title':e['title'],'description':e['description'],'use_case':e['use_case']})),'query_reference':c['query_reference'],'node_return_types':c['node_return_types']};const d=(c['templates']||[])['find'](e=>e['name']===a);if(!d)return null;return d;}catch{return null;}}export function getSchemaField(a,b){const c=getSchema(a);if(!c)return null;const d=b['split']('.')['filter'](Boolean);let e=c;for(const f of d){if(!e||typeof e!=='object')return null;if(e['properties']&&f in e['properties']){e=e['properties'][f];continue;}if(e['items']&&typeof e['items']==='object'){if(/^\d+$/['test'](f)){e=e['items'];continue;}if(e['items']['properties']&&f in e['items']['properties']){e=e['items']['properties'][f];continue;}}if(Array['isArray'](e['oneOf'])||Array['isArray'](e['anyOf'])){const g=e['oneOf']??e['anyOf'];for(const h of g){if(h&&typeof h==='object'&&h['properties']&&f in h['properties']){e=h['properties'][f];break;}}continue;}if(f in e){e=e[f];continue;}return null;}return e;}function resolveSchemaRefs(a,b=new Set()){if(!a||typeof a!=='object')return a;if(Array['isArray'](a))return a['map'](d=>resolveSchemaRefs(d,b));const c={};for(const [d,e]of Object['entries'](a)){if(d==='$ref'&&typeof e==='string'){if(e['startsWith']('#'))c[d]=e;else{const f=loadRefSchema(e,b);f&&Object['assign'](c,resolveSchemaRefs(f,b));}}else typeof e==='object'?c[d]=resolveSchemaRefs(e,b):c[d]=e;}return c;}function loadRefSchema(a,b){if(a['startsWith']('#'))return null;if(b['has'](a))return{'description':'Circular\x20reference\x20to\x20'+a};b['add'](a);try{const c=join(SCHEMAS_DIR,a);if(!existsSync(c))return null;const d=readFileSync(c,'utf-8');return JSON['parse'](d);}catch{return null;}}export function searchSchemas(a){const b=listSchemas(),c=a['toLowerCase']();return b['filter'](d=>{const e=d['name']['toLowerCase']()['includes'](c),f=d['title']?.['toLowerCase']()['includes'](c),g=d['description']?.['toLowerCase']()['includes'](c);return e||f||g;});}export function listOperations(){const a=getSchemaIndex();if(!a)return[];return(a['operations']||[])['filter'](b=>b['name']['startsWith']('onchain_operations_'));}function writeResponseToFile(a,b){try{let c;if(b)c=resolve(process['cwd'](),b);else{!existsSync(WORKSPACE_TMP_DIR)&&mkdirSync(WORKSPACE_TMP_DIR,{'recursive':!![]});const g=Date['now']();c=join(WORKSPACE_TMP_DIR,'schema-'+g+'.json');}const d=dirname(c);!existsSync(d)&&mkdirSync(d,{'recursive':!![]});const f=typeof a==='string'?a:JSON['stringify'](a,null,0x2);return writeFileSync(c,f,'utf-8'),c;}catch(h){return null;}}export function processSchemaQuery(a){const {action:b,name:c,query:d,field_path:f,template:g,output_file:h,object_type:i,params:j}=a;if(b==='get_guard_templates'){const k=getGuardTemplates(g);if(!k)return{'success':![],'action':b,'data':null,'message':g?'Guard\x20template\x20\x27'+g+'\x27\x20not\x20found.\x20Omit\x20\x27template\x27\x20to\x20list\x20all\x20available\x20templates.':'Guard\x20templates\x20file\x20not\x20found.\x20Ensure\x20scripts/guard-templates.json\x20exists.','suggestions':['Omit\x20\x27template\x27\x20to\x20list\x20all\x20available\x20templates.','Available\x20template\x20names:\x20signer_verification,\x20progress_node_check,\x20order_owner_verification,\x20service_belonging_check,\x20reward_not_claimed,\x20combined_reward_guard']};if(h){const l=writeResponseToFile(k,h);if(l)return{'success':!![],'action':b,'data':null,'message':'Guard\x20template'+(g?'\x20\x27'+g+'\x27':'s')+'\x20written\x20to\x20file:\x20'+l,'output_file_path':l,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+l]};}return{'success':!![],'action':b,'data':k,'message':g?'Retrieved\x20Guard\x20template:\x20'+g:'Retrieved\x20'+(Array['isArray'](k['templates'])?k['templates']['length']:0x0)+'\x20Guard\x20templates'};}if(b==='get_templates'){if(!g){const p=a392a(i),q=getTemplateCounts(),r={'total':p['length'],'filter':i??null,'counts_by_object_type':q,'templates':p};if(h){const s=writeResponseToFile(r,h);if(s)return{'success':!![],'action':b,'data':null,'message':p['length']+'\x20templates\x20written\x20to\x20file:\x20'+s,'output_file_path':s,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+s]};}return{'success':!![],'action':b,'data':r,'message':p['length']+'\x20template(s)'+(i?'\x20for\x20object_type=\x27'+i+'\x27':'')+'\x20'+('(total\x20registry:\x20'+Object['values'](q)['reduce']((t,u)=>t+u,0x0)+'\x20across\x20'+TEMPLATE_OBJECT_TYPES['length']+'\x20object\x20types).\x20')+'Provide\x20\x27template\x27\x20(id)\x20for\x20full\x20detail;\x20add\x20\x27params\x27\x20(JSON\x20string)\x20to\x20instantiate.'};}if(!j){const t=getTemplateDetail(g);if(!t)return{'success':![],'action':b,'data':null,'message':'Template\x20\x27'+g+'\x27\x20not\x20found\x20in\x20the\x20unified\x20registry.','suggestions':['Omit\x20\x27template\x27\x20to\x20list\x20all\x20template\x20metadata\x20(id\x20+\x20object_type\x20+\x20parameters).','Filter\x20by\x20object_type:\x20'+TEMPLATE_OBJECT_TYPES['join'](',\x20')]};if(h){const u=writeResponseToFile(t,h);if(u)return{'success':!![],'action':b,'data':null,'message':'Template\x20\x27'+g+'\x27\x20detail\x20written\x20to\x20file:\x20'+u,'output_file_path':u,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+u]};}return{'success':!![],'action':b,'data':t,'message':'Template\x20\x27'+g+'\x27\x20('+t['object_type']+',\x20'+(t['instantiable']?'instantiable':'guidance-only')+').\x20'+'To\x20instantiate,\x20call\x20again\x20with\x20\x27params\x27\x20=\x20JSON\x20object\x20of\x20the\x20declared\x20parameters.'};}let m;try{const v=JSON['parse'](j);if(!v||typeof v!=='object'||Array['isArray'](v))return{'success':![],'action':b,'data':null,'message':'\x27params\x27\x20must\x20be\x20a\x20JSON\x20object\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27),\x20got\x20'+(Array['isArray'](v)?'array':typeof v)+'.'};m=v;}catch(w){return{'success':![],'action':b,'data':null,'message':'Failed\x20to\x20parse\x20\x27params\x27\x20as\x20JSON:\x20'+(w instanceof Error?w['message']:String(w)),'suggestions':['Example:\x20params=\x27{\x22whitelist\x22:[\x220xabc...\x22]}\x27']};}const n=instantiateTemplate(g,m);if(!n['ok'])return{'success':![],'action':b,'data':n['guidance']!==undefined?{'guidance':n['guidance']}:null,'message':'Instantiation\x20failed\x20for\x20\x27'+g+'\x27:\x20'+n['error'],'suggestions':n['missing_params']?['Missing\x20required\x20params:\x20'+n['missing_params']['join'](',\x20'),'Call\x20with\x20\x27template\x27\x20only\x20(no\x20\x27params\x27)\x20to\x20see\x20full\x20parameter\x20declarations.']:['Call\x20with\x20\x27template\x27\x20only\x20(no\x20\x27params\x27)\x20to\x20see\x20full\x20parameter\x20declarations.']};const o={'object_type':n['object_type'],'template_id':n['template_id'],'body':n['body'],...n['notes']?{'notes':n['notes']}:{}};if(h){const x=writeResponseToFile(o,h);if(x)return{'success':!![],'action':b,'data':null,'message':'Instantiated\x20template\x20\x27'+g+'\x27\x20written\x20to\x20file:\x20'+x,'output_file_path':x,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+x]};}return{'success':!![],'action':b,'data':o,'message':'Instantiated\x20\x27'+g+'\x27\x20('+n['object_type']+').\x20'+'Review\x20the\x20body\x20against\x20the\x20onchain_operations\x20schema\x20before\x20submitting.'};}if(b==='get_tool_reference'){if(c){const z=getToolReference(c);if(!z)return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20not\x20found\x20in\x20the\x20tool\x20reference.','suggestions':['Omit\x20\x27name\x27\x20to\x20list\x20all\x20tools.','Available\x20tools:\x20'+TOOLS_REFERENCE['map'](B=>B['name'])['join'](',\x20')]};const A=getToolSequence(c);return{'success':!![],'action':b,'data':{'tool':z,'call_sequence':A??null},'message':'Retrieved\x20tool\x20reference:\x20'+c};}if(d){const B=searchToolReference(d);return{'success':!![],'action':b,'data':{'tools':B,'count':B['length']},'message':'Found\x20'+B['length']+'\x20tool(s)\x20matching\x20\x27'+d+'\x27','suggestions':B['length']===0x0?['Try\x20a\x20broader\x20keyword\x20(e.g.\x20\x27onchain\x27,\x20\x27guard\x27,\x20\x27schema\x27),\x20or\x20omit\x20\x27query\x27\x20to\x20list\x20all\x20tools.']:undefined};}const y=TOOLS_REFERENCE['map'](C=>({'name':C['name'],'summary':C['summary'],'actions':C['actions']??[],'notes':C['notes']??[]}));return{'success':!![],'action':b,'data':{'tools':y,'count':y['length']},'message':'Retrieved\x20reference\x20for\x20'+y['length']+'\x20MCP\x20tools.\x20Pass\x20name=\x27<tool>\x27\x20for\x20full\x20detail\x20(params,\x20prerequisites,\x20follow-ups).'};}if(b==='get_guard_design_patterns'){if(c){const D=getGuardDesignPattern(c);if(!D)return{'success':![],'action':b,'data':null,'message':'Guard\x20design\x20pattern\x20\x27'+c+'\x27\x20not\x20found.','suggestions':['Omit\x20\x27name\x27\x20to\x20list\x20the\x20full\x20catalog.','Available\x20pattern\x20ids:\x20'+GUARD_DESIGN_PATTERNS['map'](E=>E['id'])['join'](',\x20')]};return{'success':!![],'action':b,'data':{'pattern':D},'message':'Retrieved\x20Guard\x20design\x20pattern:\x20'+c};}if(d){const E=GUARD_DESIGN_PATTERNS['filter'](G=>G['host']===d),F=E['length']>0x0?E:GUARD_DESIGN_PATTERNS['filter'](G=>G['business_requirement']['toLowerCase']()['includes'](d['toLowerCase']())||G['logic_summary']['toLowerCase']()['includes'](d['toLowerCase']()));return{'success':!![],'action':b,'data':{'patterns':F,'count':F['length'],'filtered_by':E['length']>0x0?'host':'keyword'},'message':'Found\x20'+F['length']+'\x20Guard\x20design\x20pattern(s)\x20matching\x20\x27'+d+'\x27','suggestions':F['length']===0x0?['Filter\x20by\x20host:\x20service_buy_guard,\x20service_allocator_guard,\x20machine_forward,\x20progress_submission,\x20reward_claim,\x20repository_write,\x20arbitration_usage,\x20arbitration_voting,\x20gen_passport']:undefined};}const C=GUARD_DESIGN_PATTERNS['map'](G=>({'id':G['id'],'business_requirement':G['business_requirement'],'host':G['host'],'data_source':G['data_source'],'verifier_level':G['verifier_level'],'logic_summary':G['logic_summary'],'key_queries':G['key_queries'],'notes':G['notes']??[]}));return{'success':!![],'action':b,'data':{'patterns':C,'count':C['length'],'version':GUARD_DESIGN_PATTERNS_VERSION},'message':'Retrieved\x20'+C['length']+'\x20Guard\x20design\x20patterns.\x20Pass\x20name=\x27<pattern_id>\x27\x20for\x20full\x20detail\x20(witness\x20types,\x20mitigated\x20risks,\x20industries).'};}if(b==='get_safety_rules')return{'success':!![],'action':b,'data':{'version':SAFETY_RULES_VERSION,'object_reuse_rules':OBJECT_REUSE_RULES,'create_vs_modify_pattern':CREATE_VS_MODIFY_PATTERN,'immutability_rules':IMMUTABILITY_RULES,'operation_type_classification':OPERATION_TYPE_CLASSIFICATION,'operation_class_meta':OPERATION_CLASS_META,'naming_conventions':NAMING_CONVENTIONS},'message':'Retrieved\x20safety\x20rule\x20tables\x20(reuse\x20/\x20immutability\x20/\x20operation\x20classification\x20/\x20naming).\x20'+'Key\x20points:\x20prefer\x20REUSING\x20existing\x20objects\x20(string\x20reference\x20=\x20reuse,\x20object\x20shape\x20=\x20create);\x20'+'Machine\x20publish\x20locks\x20nodes/pairs/forwards,\x20Service\x20publish\x20locks\x20machine/order_allocators/arbitrations\x20(sales\x20stays\x20mutable);\x20'+'Guard\x20is\x20CREATE-only\x20immutable;\x20on-chain\x20writes\x20require\x20explicit\x20user\x20confirmation.'};if(!areSchemasAvailable())return{'success':![],'action':b,'data':null,'message':'Schema\x20files\x20are\x20not\x20available.\x20Please\x20run\x20\x27npm\x20run\x20generate:schemas\x27\x20first.','suggestions':['Run\x20\x27npm\x20run\x20generate:schemas\x27\x20to\x20generate\x20schema\x20files','Ensure\x20the\x20dist/schemas\x20directory\x20exists']};switch(b){case'list':{const G=listSchemas();return{'success':!![],'action':b,'data':G,'message':'Found\x20'+G['length']+'\x20available\x20schemas'};}case'get':{if(!c)return{'success':![],'action':b,'data':null,'message':'Schema\x20name\x20is\x20required\x20for\x20\x27get\x27\x20action','suggestions':['Provide\x20a\x20schema\x20name','Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20schemas']};const H=getSchema(c);if(!H){const I=searchSchemas(c)['slice'](0x0,0x5);return{'success':![],'action':b,'data':null,'message':'Schema\x20\x27'+c+'\x27\x20not\x20found','suggestions':I['length']>0x0?I['map'](J=>'Did\x20you\x20mean:\x20'+J['name']+'?'):['Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20schemas']};}if(h){const J=writeResponseToFile(H,h);if(J)return{'success':!![],'action':b,'data':null,'message':'Schema\x20\x27'+c+'\x27\x20written\x20to\x20file:\x20'+J,'output_file_path':J,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+J]};}return{'success':!![],'action':b,'data':H,'message':'Retrieved\x20schema:\x20'+c};}case'get_field':{if(!c||!f)return{'success':![],'action':b,'data':null,'message':'Both\x20\x27name\x27\x20and\x20\x27field_path\x27\x20are\x20required\x20for\x20\x27get_field\x27\x20action','suggestions':['Example:\x20{action:\x20\x27get_field\x27,\x20name:\x20\x27onchain_operations_machine\x27,\x20field_path:\x20\x27data.node\x27}','Use\x20\x27get\x27\x20action\x20to\x20retrieve\x20the\x20full\x20schema']};const K=getSchemaField(c,f);if(!K)return{'success':![],'action':b,'data':null,'message':'Field\x20path\x20\x27'+f+'\x27\x20not\x20found\x20in\x20schema\x20\x27'+c+'\x27','suggestions':['Check\x20the\x20field\x20path\x20(dot-separated,\x20e.g.\x20\x27data.node\x27)','Use\x20\x27get\x27\x20action\x20to\x20see\x20the\x20full\x20schema\x20structure']};return{'success':!![],'action':b,'data':K,'message':'Retrieved\x20field\x20\x27'+f+'\x27\x20from\x20schema\x20\x27'+c+'\x27'};}case'search':{if(!d)return{'success':![],'action':b,'data':null,'message':'Search\x20query\x20is\x20required\x20for\x20\x27search\x27\x20action'};const L=searchSchemas(d);return{'success':!![],'action':b,'data':L,'message':'Found\x20'+L['length']+'\x20schemas\x20matching\x20\x27'+d+'\x27'};}case'list_operations':{const M=listOperations();return{'success':!![],'action':b,'data':M,'message':'Found\x20'+M['length']+'\x20on-chain\x20operations'};}case'get_output':{if(!c)return{'success':![],'action':b,'data':null,'message':'Tool\x20name\x20is\x20required\x20for\x20\x27get_output\x27\x20action','suggestions':['Provide\x20a\x20tool\x20name','Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20tools\x20and\x20their\x20outputPath']};const N=getOutputSchema(c);if(!N){const O=listSchemas(),P=O['find'](R=>R['name']===c);if(P)return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20exists\x20but\x20has\x20no\x20output\x20schema\x20file.\x20The\x20tool\x20may\x20not\x20declare\x20an\x20outputSchema,\x20or\x20the\x20schema\x20file\x20was\x20not\x20generated.','suggestions':['Use\x20\x27get\x27\x20action\x20with\x20name=\x27'+c+'\x27\x20to\x20retrieve\x20its\x20input\x20schema']};const Q=searchSchemas(c)['slice'](0x0,0x5);return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20not\x20found','suggestions':Q['length']>0x0?Q['map'](R=>'Did\x20you\x20mean:\x20'+R['name']+'?'):['Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20tools']};}if(h){const R=writeResponseToFile(N,h);if(R)return{'success':!![],'action':b,'data':null,'message':'Output\x20schema\x20\x27'+c+'\x27\x20written\x20to\x20file:\x20'+R,'output_file_path':R,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+R]};}return{'success':!![],'action':b,'data':N,'message':'Retrieved\x20output\x20schema:\x20'+c};}default:return{'success':![],'action':b,'data':null,'message':'Unknown\x20action:\x20'+b,'suggestions':['Use\x20\x27list\x27,\x20\x27get\x27,\x20\x27get_field\x27,\x20\x27get_output\x27,\x20\x27search\x27,\x20\x27list_operations\x27,\x20\x27get_guard_templates\x27,\x20\x27get_tool_reference\x27,\x20\x27get_guard_design_patterns\x27,\x20\x27get_safety_rules\x27,\x20\x27get_templates\x27,\x20or\x20\x27analyze_guard_semantics\x27']};}}const GUARD_SEMANTICS_READING_CHECKLIST=['WHO\x20can\x20satisfy\x20this\x20Guard\x20(identity:\x20Signer\x20bindings,\x20Entity\x20membership,\x20allowlists)?','WHEN\x20can\x20it\x20be\x20satisfied\x20(time:\x20Clock\x20comparisons,\x20deadlines,\x20windows)?','WHAT\x20evidence\x20must\x20the\x20caller\x20submit\x20(b_submission\x20table\x20entries\x20—\x20Payment/Order/Proof\x20objects)?','WHICH\x20on-chain\x20data\x20does\x20it\x20read,\x20and\x20can\x20that\x20data\x20change\x20(Repository\x20entries\x20are\x20MUTABLE\x20—\x20who\x20controls\x20the\x20writes)?','WHAT\x20does\x20the\x20counterparty\x20gain/lose\x20in\x20each\x20branch\x20of\x20the\x20logic\x20tree?','ARE\x20there\x20error-level\x20diagnostics\x20or\x20critical\x20risks\x20(they\x20block\x20or\x20endanger\x20execution)?'];function walkGuardTree(a,b){const c=[a];while(c['length']>0x0){const d=c['pop']();if(!d||typeof d!=='object')continue;b(d);if(Array['isArray'](d['nodes']))c['push'](...d['nodes']);if(d['node'])c['push'](d['node']);if(d['nodeLeft'])c['push'](d['nodeLeft']);if(d['nodeRight'])c['push'](d['nodeRight']);if(Array['isArray'](d['parameters']))c['push'](...d['parameters']);if(d['historyIdx'])c['push'](d['historyIdx']);if(d['sessionIdx'])c['push'](d['sessionIdx']);if(d['forwardIdx'])c['push'](d['forwardIdx']);if(d['where'])c['push'](d['where']);if(d['find'])c['push'](d['find']);if(d['objectLeft'])c['push'](d['objectLeft']);if(d['objectRight'])c['push'](d['objectRight']);if(d['recipient'])c['push'](d['recipient']);}}export async function analyzeGuardSemantics(a){const b=await lintGuard(a,{'auto_fix':![]}),c={'root':a['root'],'table':(a['table']??[])['map'](j=>({'identifier':j['identifier'],'name':j['name'],'value_type':j['value_type']??'Address','b_submission':j['b_submission']??![],'value':j['value']})),'guardName':a['description']??null,'rely':a['rely']??null},d=renderGuardTreeIndented(c),e=renderGuardMermaid(a['root']),f=new Set();let g=![],h=![];walkGuardTree(a['root'],j=>{if(j['type']==='context'){if(j['context']==='Clock')g=!![];if(j['context']==='Signer')h=!![];}j['type']==='query'&&typeof j['query']==='number'&&f['add'](j['query']);});const i={'submission_requirements':(a['table']??[])['filter'](j=>j['b_submission']===!![])['map'](j=>({'identifier':j['identifier'],'value_type':j['value_type'],'object_type':j['object_type'],'name':j['name']})),'data_sources':(a['table']??[])['filter'](j=>j['b_submission']!==!![])['map'](j=>({'identifier':j['identifier'],'kind':j['is_system_address']?'system_address':j['object_type']?'object':'fixed_value','value_type':j['value_type'],'object_type':j['object_type'],'name':j['name'],'is_mutable_onchain':j['object_type']==='Repository'})),'query_dependencies':[...f]['sort']((j,k)=>j-k),'has_time_conditions':g,'has_signer_constraints':h,'has_rely_composition':Array['isArray'](a['rely']?.['guards'])&&a['rely']['guards']['length']>0x0,'reading_checklist':GUARD_SEMANTICS_READING_CHECKLIST};return{'render':{'tree_indented':d,'mermaid':e},'lint':b,'party_evaluation':i};}export{formatLintResult};
|
|
1
|
+
import{readFileSync,existsSync,writeFileSync,mkdirSync}from'fs';import{resolve,join,dirname}from'path';import{fileURLToPath}from'url';import{TOOLS_REFERENCE,getToolReference,searchToolReference,getToolSequence}from'../knowledge/tools-reference.js';import{GUARD_DESIGN_PATTERNS,getGuardDesignPattern,GUARD_DESIGN_PATTERNS_VERSION}from'../knowledge/guard-design-patterns.js';import{OBJECT_REUSE_RULES,CREATE_VS_MODIFY_PATTERN,IMMUTABILITY_RULES,OPERATION_TYPE_CLASSIFICATION,OPERATION_CLASS_META,NAMING_CONVENTIONS,SAFETY_RULES_VERSION}from'../knowledge/safety-rules.js';import{listTemplates as a310a,getTemplateDetail,instantiateTemplate,getTemplateCounts,TEMPLATE_OBJECT_TYPES}from'../knowledge/template-registry.js';import{lintGuard,formatLintResult}from'../knowledge/guard-lint.js';import{renderGuardTreeIndented,renderGuardMermaid}from'../knowledge/guard-render.js';const __filename=fileURLToPath(import.meta.url),__dirname=fileURLToPath(new URL('.',import.meta.url)),SCHEMAS_DIR=resolve(__dirname,'../../dist/schemas'),GUARD_TEMPLATES_PATH_SCRIPTS=resolve(__dirname,'../../scripts/guard-templates.json'),GUARD_TEMPLATES_PATH_DIST=resolve(__dirname,'../../dist/schemas/guard-templates.json'),GUARD_TEMPLATES_PATH=existsSync(GUARD_TEMPLATES_PATH_SCRIPTS)?GUARD_TEMPLATES_PATH_SCRIPTS:GUARD_TEMPLATES_PATH_DIST,WORKSPACE_TMP_DIR=resolve(process['cwd'](),'.trae','tmp');export function areSchemasAvailable(){return existsSync(SCHEMAS_DIR)&&existsSync(join(SCHEMAS_DIR,'index.json'));}export function getSchemaIndex(){try{const a=join(SCHEMAS_DIR,'index.json');if(!existsSync(a))return null;const b=readFileSync(a,'utf-8');return JSON['parse'](b);}catch{return null;}}export function listSchemas(){const a=getSchemaIndex();if(!a)return[];return[...a['tools']||[],...a['operations']||[]];}export function getSchema(a){try{let b=join(SCHEMAS_DIR,a+'.schema.json');!existsSync(b)&&(b=join(SCHEMAS_DIR,a+'.json'));if(!existsSync(b))return null;const c=readFileSync(b,'utf-8'),d=JSON['parse'](c);return resolveSchemaRefs(d);}catch{return null;}}export function getOutputSchema(a){try{const b=join(SCHEMAS_DIR,a+'.output.json');if(!existsSync(b))return null;const c=readFileSync(b,'utf-8'),d=JSON['parse'](c);return resolveSchemaRefs(d);}catch{return null;}}export function getGuardTemplates(a){try{if(!existsSync(GUARD_TEMPLATES_PATH))return null;const b=readFileSync(GUARD_TEMPLATES_PATH,'utf-8'),c=JSON['parse'](b);if(!a)return{'version':c['version'],'description':c['description'],'templates':(c['templates']||[])['map'](e=>({'name':e['name'],'title':e['title'],'description':e['description'],'use_case':e['use_case']})),'query_reference':c['query_reference'],'node_return_types':c['node_return_types']};const d=(c['templates']||[])['find'](e=>e['name']===a);if(!d)return null;return d;}catch{return null;}}export function getSchemaField(a,b){const c=getSchema(a);if(!c)return null;const d=b['split']('.')['filter'](Boolean);let e=c;for(const f of d){if(!e||typeof e!=='object')return null;if(e['properties']&&f in e['properties']){e=e['properties'][f];continue;}if(e['items']&&typeof e['items']==='object'){if(/^\d+$/['test'](f)){e=e['items'];continue;}if(e['items']['properties']&&f in e['items']['properties']){e=e['items']['properties'][f];continue;}}if(Array['isArray'](e['oneOf'])||Array['isArray'](e['anyOf'])){const g=e['oneOf']??e['anyOf'];for(const h of g){if(h&&typeof h==='object'&&h['properties']&&f in h['properties']){e=h['properties'][f];break;}}continue;}if(f in e){e=e[f];continue;}return null;}return e;}function resolveSchemaRefs(a,b=new Set()){if(!a||typeof a!=='object')return a;if(Array['isArray'](a))return a['map'](d=>resolveSchemaRefs(d,b));const c={};for(const [d,e]of Object['entries'](a)){if(d==='$ref'&&typeof e==='string'){if(e['startsWith']('#'))c[d]=e;else{const f=loadRefSchema(e,b);f&&Object['assign'](c,resolveSchemaRefs(f,b));}}else typeof e==='object'?c[d]=resolveSchemaRefs(e,b):c[d]=e;}return c;}function loadRefSchema(a,b){if(a['startsWith']('#'))return null;if(b['has'](a))return{'description':'Circular\x20reference\x20to\x20'+a};b['add'](a);try{const c=join(SCHEMAS_DIR,a);if(!existsSync(c))return null;const d=readFileSync(c,'utf-8');return JSON['parse'](d);}catch{return null;}}export function searchSchemas(a){const b=listSchemas(),c=a['toLowerCase']();return b['filter'](d=>{const e=d['name']['toLowerCase']()['includes'](c),f=d['title']?.['toLowerCase']()['includes'](c),g=d['description']?.['toLowerCase']()['includes'](c);return e||f||g;});}export function listOperations(){const a=getSchemaIndex();if(!a)return[];return(a['operations']||[])['filter'](b=>b['name']['startsWith']('onchain_operations_'));}function writeResponseToFile(a,b){try{let c;if(b)c=resolve(process['cwd'](),b);else{!existsSync(WORKSPACE_TMP_DIR)&&mkdirSync(WORKSPACE_TMP_DIR,{'recursive':!![]});const g=Date['now']();c=join(WORKSPACE_TMP_DIR,'schema-'+g+'.json');}const d=dirname(c);!existsSync(d)&&mkdirSync(d,{'recursive':!![]});const f=typeof a==='string'?a:JSON['stringify'](a,null,0x2);return writeFileSync(c,f,'utf-8'),c;}catch(h){return null;}}export function processSchemaQuery(a){const {action:b,name:c,query:d,field_path:f,template:g,output_file:h,object_type:i,params:j}=a;if(b==='get_guard_templates'){const k=getGuardTemplates(g);if(!k)return{'success':![],'action':b,'data':null,'message':g?'Guard\x20template\x20\x27'+g+'\x27\x20not\x20found.\x20Omit\x20\x27template\x27\x20to\x20list\x20all\x20available\x20templates.':'Guard\x20templates\x20file\x20not\x20found.\x20Ensure\x20scripts/guard-templates.json\x20exists.','suggestions':['Omit\x20\x27template\x27\x20to\x20list\x20all\x20available\x20templates.','Available\x20template\x20names:\x20signer_verification,\x20progress_node_check,\x20order_owner_verification,\x20service_belonging_check,\x20reward_not_claimed,\x20combined_reward_guard']};if(h){const l=writeResponseToFile(k,h);if(l)return{'success':!![],'action':b,'data':null,'message':'Guard\x20template'+(g?'\x20\x27'+g+'\x27':'s')+'\x20written\x20to\x20file:\x20'+l,'output_file_path':l,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+l]};}return{'success':!![],'action':b,'data':k,'message':g?'Retrieved\x20Guard\x20template:\x20'+g:'Retrieved\x20'+(Array['isArray'](k['templates'])?k['templates']['length']:0x0)+'\x20Guard\x20templates'};}if(b==='get_templates'){if(!g){const p=a310a(i),q=getTemplateCounts(),r={'total':p['length'],'filter':i??null,'counts_by_object_type':q,'templates':p};if(h){const s=writeResponseToFile(r,h);if(s)return{'success':!![],'action':b,'data':null,'message':p['length']+'\x20templates\x20written\x20to\x20file:\x20'+s,'output_file_path':s,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+s]};}return{'success':!![],'action':b,'data':r,'message':p['length']+'\x20template(s)'+(i?'\x20for\x20object_type=\x27'+i+'\x27':'')+'\x20'+('(total\x20registry:\x20'+Object['values'](q)['reduce']((t,u)=>t+u,0x0)+'\x20across\x20'+TEMPLATE_OBJECT_TYPES['length']+'\x20object\x20types).\x20')+'Provide\x20\x27template\x27\x20(id)\x20for\x20full\x20detail;\x20add\x20\x27params\x27\x20(JSON\x20string)\x20to\x20instantiate.'};}if(!j){const t=getTemplateDetail(g);if(!t)return{'success':![],'action':b,'data':null,'message':'Template\x20\x27'+g+'\x27\x20not\x20found\x20in\x20the\x20unified\x20registry.','suggestions':['Omit\x20\x27template\x27\x20to\x20list\x20all\x20template\x20metadata\x20(id\x20+\x20object_type\x20+\x20parameters).','Filter\x20by\x20object_type:\x20'+TEMPLATE_OBJECT_TYPES['join'](',\x20')]};if(h){const u=writeResponseToFile(t,h);if(u)return{'success':!![],'action':b,'data':null,'message':'Template\x20\x27'+g+'\x27\x20detail\x20written\x20to\x20file:\x20'+u,'output_file_path':u,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+u]};}return{'success':!![],'action':b,'data':t,'message':'Template\x20\x27'+g+'\x27\x20('+t['object_type']+',\x20'+(t['instantiable']?'instantiable':'guidance-only')+').\x20'+'To\x20instantiate,\x20call\x20again\x20with\x20\x27params\x27\x20=\x20JSON\x20object\x20of\x20the\x20declared\x20parameters.'};}let m;try{const v=JSON['parse'](j);if(!v||typeof v!=='object'||Array['isArray'](v))return{'success':![],'action':b,'data':null,'message':'\x27params\x27\x20must\x20be\x20a\x20JSON\x20object\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27),\x20got\x20'+(Array['isArray'](v)?'array':typeof v)+'.'};m=v;}catch(w){return{'success':![],'action':b,'data':null,'message':'Failed\x20to\x20parse\x20\x27params\x27\x20as\x20JSON:\x20'+(w instanceof Error?w['message']:String(w)),'suggestions':['Example:\x20params=\x27{\x22whitelist\x22:[\x220xabc...\x22]}\x27']};}const n=instantiateTemplate(g,m);if(!n['ok'])return{'success':![],'action':b,'data':n['guidance']!==undefined?{'guidance':n['guidance']}:null,'message':'Instantiation\x20failed\x20for\x20\x27'+g+'\x27:\x20'+n['error'],'suggestions':n['missing_params']?['Missing\x20required\x20params:\x20'+n['missing_params']['join'](',\x20'),'Call\x20with\x20\x27template\x27\x20only\x20(no\x20\x27params\x27)\x20to\x20see\x20full\x20parameter\x20declarations.']:['Call\x20with\x20\x27template\x27\x20only\x20(no\x20\x27params\x27)\x20to\x20see\x20full\x20parameter\x20declarations.']};const o={'object_type':n['object_type'],'template_id':n['template_id'],'body':n['body'],...n['notes']?{'notes':n['notes']}:{}};if(h){const x=writeResponseToFile(o,h);if(x)return{'success':!![],'action':b,'data':null,'message':'Instantiated\x20template\x20\x27'+g+'\x27\x20written\x20to\x20file:\x20'+x,'output_file_path':x,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+x]};}return{'success':!![],'action':b,'data':o,'message':'Instantiated\x20\x27'+g+'\x27\x20('+n['object_type']+').\x20'+'Review\x20the\x20body\x20against\x20the\x20onchain_operations\x20schema\x20before\x20submitting.'};}if(b==='get_tool_reference'){if(c){const z=getToolReference(c);if(!z)return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20not\x20found\x20in\x20the\x20tool\x20reference.','suggestions':['Omit\x20\x27name\x27\x20to\x20list\x20all\x20tools.','Available\x20tools:\x20'+TOOLS_REFERENCE['map'](B=>B['name'])['join'](',\x20')]};const A=getToolSequence(c);return{'success':!![],'action':b,'data':{'tool':z,'call_sequence':A??null},'message':'Retrieved\x20tool\x20reference:\x20'+c};}if(d){const B=searchToolReference(d);return{'success':!![],'action':b,'data':{'tools':B,'count':B['length']},'message':'Found\x20'+B['length']+'\x20tool(s)\x20matching\x20\x27'+d+'\x27','suggestions':B['length']===0x0?['Try\x20a\x20broader\x20keyword\x20(e.g.\x20\x27onchain\x27,\x20\x27guard\x27,\x20\x27schema\x27),\x20or\x20omit\x20\x27query\x27\x20to\x20list\x20all\x20tools.']:undefined};}const y=TOOLS_REFERENCE['map'](C=>({'name':C['name'],'summary':C['summary'],'actions':C['actions']??[],'notes':C['notes']??[]}));return{'success':!![],'action':b,'data':{'tools':y,'count':y['length']},'message':'Retrieved\x20reference\x20for\x20'+y['length']+'\x20MCP\x20tools.\x20Pass\x20name=\x27<tool>\x27\x20for\x20full\x20detail\x20(params,\x20prerequisites,\x20follow-ups).'};}if(b==='get_guard_design_patterns'){if(c){const D=getGuardDesignPattern(c);if(!D)return{'success':![],'action':b,'data':null,'message':'Guard\x20design\x20pattern\x20\x27'+c+'\x27\x20not\x20found.','suggestions':['Omit\x20\x27name\x27\x20to\x20list\x20the\x20full\x20catalog.','Available\x20pattern\x20ids:\x20'+GUARD_DESIGN_PATTERNS['map'](E=>E['id'])['join'](',\x20')]};return{'success':!![],'action':b,'data':{'pattern':D},'message':'Retrieved\x20Guard\x20design\x20pattern:\x20'+c};}if(d){const E=GUARD_DESIGN_PATTERNS['filter'](G=>G['host']===d),F=E['length']>0x0?E:GUARD_DESIGN_PATTERNS['filter'](G=>G['business_requirement']['toLowerCase']()['includes'](d['toLowerCase']())||G['logic_summary']['toLowerCase']()['includes'](d['toLowerCase']()));return{'success':!![],'action':b,'data':{'patterns':F,'count':F['length'],'filtered_by':E['length']>0x0?'host':'keyword'},'message':'Found\x20'+F['length']+'\x20Guard\x20design\x20pattern(s)\x20matching\x20\x27'+d+'\x27','suggestions':F['length']===0x0?['Filter\x20by\x20host:\x20service_buy_guard,\x20service_allocator_guard,\x20machine_forward,\x20progress_submission,\x20reward_claim,\x20repository_write,\x20arbitration_usage,\x20arbitration_voting,\x20gen_passport']:undefined};}const C=GUARD_DESIGN_PATTERNS['map'](G=>({'id':G['id'],'business_requirement':G['business_requirement'],'host':G['host'],'data_source':G['data_source'],'verifier_level':G['verifier_level'],'logic_summary':G['logic_summary'],'key_queries':G['key_queries'],'notes':G['notes']??[]}));return{'success':!![],'action':b,'data':{'patterns':C,'count':C['length'],'version':GUARD_DESIGN_PATTERNS_VERSION},'message':'Retrieved\x20'+C['length']+'\x20Guard\x20design\x20patterns.\x20Pass\x20name=\x27<pattern_id>\x27\x20for\x20full\x20detail\x20(witness\x20types,\x20mitigated\x20risks,\x20industries).'};}if(b==='get_safety_rules')return{'success':!![],'action':b,'data':{'version':SAFETY_RULES_VERSION,'object_reuse_rules':OBJECT_REUSE_RULES,'create_vs_modify_pattern':CREATE_VS_MODIFY_PATTERN,'immutability_rules':IMMUTABILITY_RULES,'operation_type_classification':OPERATION_TYPE_CLASSIFICATION,'operation_class_meta':OPERATION_CLASS_META,'naming_conventions':NAMING_CONVENTIONS},'message':'Retrieved\x20safety\x20rule\x20tables\x20(reuse\x20/\x20immutability\x20/\x20operation\x20classification\x20/\x20naming).\x20'+'Key\x20points:\x20prefer\x20REUSING\x20existing\x20objects\x20(string\x20reference\x20=\x20reuse,\x20object\x20shape\x20=\x20create);\x20'+'Machine\x20publish\x20locks\x20nodes/pairs/forwards,\x20Service\x20publish\x20locks\x20machine/order_allocators/arbitrations\x20(sales\x20stays\x20mutable);\x20'+'Guard\x20is\x20CREATE-only\x20immutable;\x20on-chain\x20writes\x20require\x20explicit\x20user\x20confirmation.'};if(!areSchemasAvailable())return{'success':![],'action':b,'data':null,'message':'Schema\x20files\x20are\x20not\x20available.\x20Please\x20run\x20\x27npm\x20run\x20generate:schemas\x27\x20first.','suggestions':['Run\x20\x27npm\x20run\x20generate:schemas\x27\x20to\x20generate\x20schema\x20files','Ensure\x20the\x20dist/schemas\x20directory\x20exists']};switch(b){case'list':{const G=listSchemas();return{'success':!![],'action':b,'data':G,'message':'Found\x20'+G['length']+'\x20available\x20schemas'};}case'get':{if(!c)return{'success':![],'action':b,'data':null,'message':'Schema\x20name\x20is\x20required\x20for\x20\x27get\x27\x20action','suggestions':['Provide\x20a\x20schema\x20name','Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20schemas']};const H=getSchema(c);if(!H){const I=searchSchemas(c)['slice'](0x0,0x5);return{'success':![],'action':b,'data':null,'message':'Schema\x20\x27'+c+'\x27\x20not\x20found','suggestions':I['length']>0x0?I['map'](J=>'Did\x20you\x20mean:\x20'+J['name']+'?'):['Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20schemas']};}if(h){const J=writeResponseToFile(H,h);if(J)return{'success':!![],'action':b,'data':null,'message':'Schema\x20\x27'+c+'\x27\x20written\x20to\x20file:\x20'+J,'output_file_path':J,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+J]};}return{'success':!![],'action':b,'data':H,'message':'Retrieved\x20schema:\x20'+c};}case'get_field':{if(!c||!f)return{'success':![],'action':b,'data':null,'message':'Both\x20\x27name\x27\x20and\x20\x27field_path\x27\x20are\x20required\x20for\x20\x27get_field\x27\x20action','suggestions':['Example:\x20{action:\x20\x27get_field\x27,\x20name:\x20\x27onchain_operations_machine\x27,\x20field_path:\x20\x27data.node\x27}','Use\x20\x27get\x27\x20action\x20to\x20retrieve\x20the\x20full\x20schema']};const K=getSchemaField(c,f);if(!K)return{'success':![],'action':b,'data':null,'message':'Field\x20path\x20\x27'+f+'\x27\x20not\x20found\x20in\x20schema\x20\x27'+c+'\x27','suggestions':['Check\x20the\x20field\x20path\x20(dot-separated,\x20e.g.\x20\x27data.node\x27)','Use\x20\x27get\x27\x20action\x20to\x20see\x20the\x20full\x20schema\x20structure']};return{'success':!![],'action':b,'data':K,'message':'Retrieved\x20field\x20\x27'+f+'\x27\x20from\x20schema\x20\x27'+c+'\x27'};}case'search':{if(!d)return{'success':![],'action':b,'data':null,'message':'Search\x20query\x20is\x20required\x20for\x20\x27search\x27\x20action'};const L=searchSchemas(d);return{'success':!![],'action':b,'data':L,'message':'Found\x20'+L['length']+'\x20schemas\x20matching\x20\x27'+d+'\x27'};}case'list_operations':{const M=listOperations();return{'success':!![],'action':b,'data':M,'message':'Found\x20'+M['length']+'\x20on-chain\x20operations'};}case'get_output':{if(!c)return{'success':![],'action':b,'data':null,'message':'Tool\x20name\x20is\x20required\x20for\x20\x27get_output\x27\x20action','suggestions':['Provide\x20a\x20tool\x20name','Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20tools\x20and\x20their\x20outputPath']};const N=getOutputSchema(c);if(!N){const O=listSchemas(),P=O['find'](R=>R['name']===c);if(P)return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20exists\x20but\x20has\x20no\x20output\x20schema\x20file.\x20The\x20tool\x20may\x20not\x20declare\x20an\x20outputSchema,\x20or\x20the\x20schema\x20file\x20was\x20not\x20generated.','suggestions':['Use\x20\x27get\x27\x20action\x20with\x20name=\x27'+c+'\x27\x20to\x20retrieve\x20its\x20input\x20schema']};const Q=searchSchemas(c)['slice'](0x0,0x5);return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20not\x20found','suggestions':Q['length']>0x0?Q['map'](R=>'Did\x20you\x20mean:\x20'+R['name']+'?'):['Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20tools']};}if(h){const R=writeResponseToFile(N,h);if(R)return{'success':!![],'action':b,'data':null,'message':'Output\x20schema\x20\x27'+c+'\x27\x20written\x20to\x20file:\x20'+R,'output_file_path':R,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+R]};}return{'success':!![],'action':b,'data':N,'message':'Retrieved\x20output\x20schema:\x20'+c};}default:return{'success':![],'action':b,'data':null,'message':'Unknown\x20action:\x20'+b,'suggestions':['Use\x20\x27list\x27,\x20\x27get\x27,\x20\x27get_field\x27,\x20\x27get_output\x27,\x20\x27search\x27,\x20\x27list_operations\x27,\x20\x27get_guard_templates\x27,\x20\x27get_tool_reference\x27,\x20\x27get_guard_design_patterns\x27,\x20\x27get_safety_rules\x27,\x20\x27get_templates\x27,\x20or\x20\x27analyze_guard_semantics\x27']};}}const GUARD_SEMANTICS_READING_CHECKLIST=['WHO\x20can\x20satisfy\x20this\x20Guard\x20(identity:\x20Signer\x20bindings,\x20Entity\x20membership,\x20allowlists)?','WHEN\x20can\x20it\x20be\x20satisfied\x20(time:\x20Clock\x20comparisons,\x20deadlines,\x20windows)?','WHAT\x20evidence\x20must\x20the\x20caller\x20submit\x20(b_submission\x20table\x20entries\x20—\x20Payment/Order/Proof\x20objects)?','WHICH\x20on-chain\x20data\x20does\x20it\x20read,\x20and\x20can\x20that\x20data\x20change\x20(Repository\x20entries\x20are\x20MUTABLE\x20—\x20who\x20controls\x20the\x20writes)?','WHAT\x20does\x20the\x20counterparty\x20gain/lose\x20in\x20each\x20branch\x20of\x20the\x20logic\x20tree?','ARE\x20there\x20error-level\x20diagnostics\x20or\x20critical\x20risks\x20(they\x20block\x20or\x20endanger\x20execution)?'];function walkGuardTree(a,b){const c=[a];while(c['length']>0x0){const d=c['pop']();if(!d||typeof d!=='object')continue;b(d);if(Array['isArray'](d['nodes']))c['push'](...d['nodes']);if(d['node'])c['push'](d['node']);if(d['nodeLeft'])c['push'](d['nodeLeft']);if(d['nodeRight'])c['push'](d['nodeRight']);if(Array['isArray'](d['parameters']))c['push'](...d['parameters']);if(d['historyIdx'])c['push'](d['historyIdx']);if(d['sessionIdx'])c['push'](d['sessionIdx']);if(d['forwardIdx'])c['push'](d['forwardIdx']);if(d['where'])c['push'](d['where']);if(d['find'])c['push'](d['find']);if(d['objectLeft'])c['push'](d['objectLeft']);if(d['objectRight'])c['push'](d['objectRight']);if(d['recipient'])c['push'](d['recipient']);}}export async function analyzeGuardSemantics(a){const b=await lintGuard(a,{'auto_fix':![]}),c={'root':a['root'],'table':(a['table']??[])['map'](j=>({'identifier':j['identifier'],'name':j['name'],'value_type':j['value_type']??'Address','b_submission':j['b_submission']??![],'value':j['value']})),'guardName':a['description']??null,'rely':a['rely']??null},d=renderGuardTreeIndented(c),e=renderGuardMermaid(a['root']),f=new Set();let g=![],h=![];walkGuardTree(a['root'],j=>{if(j['type']==='context'){if(j['context']==='Clock')g=!![];if(j['context']==='Signer')h=!![];}j['type']==='query'&&typeof j['query']==='number'&&f['add'](j['query']);});const i={'submission_requirements':(a['table']??[])['filter'](j=>j['b_submission']===!![])['map'](j=>({'identifier':j['identifier'],'value_type':j['value_type'],'object_type':j['object_type'],'name':j['name']})),'data_sources':(a['table']??[])['filter'](j=>j['b_submission']!==!![])['map'](j=>({'identifier':j['identifier'],'kind':j['is_system_address']?'system_address':j['object_type']?'object':'fixed_value','value_type':j['value_type'],'object_type':j['object_type'],'name':j['name'],'is_mutable_onchain':j['object_type']==='Repository'})),'query_dependencies':[...f]['sort']((j,k)=>j-k),'has_time_conditions':g,'has_signer_constraints':h,'has_rely_composition':Array['isArray'](a['rely']?.['guards'])&&a['rely']['guards']['length']>0x0,'reading_checklist':GUARD_SEMANTICS_READING_CHECKLIST};return{'render':{'tree_indented':d,'mermaid':e},'lint':b,'party_evaluation':i};}export{formatLintResult};
|
|
@@ -2331,8 +2331,12 @@
|
|
|
2331
2331
|
"guard_rejected",
|
|
2332
2332
|
"state_conflict",
|
|
2333
2333
|
"insufficient_balance",
|
|
2334
|
+
"stock_exhausted",
|
|
2335
|
+
"sale_suspended",
|
|
2336
|
+
"discount_invalid",
|
|
2334
2337
|
"object_not_found",
|
|
2335
2338
|
"permission_denied",
|
|
2339
|
+
"time_lock_not_elapsed",
|
|
2336
2340
|
"immutable_violation",
|
|
2337
2341
|
"network_error",
|
|
2338
2342
|
"rate_limit",
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://wowok.net/schemas/ask_user.output.json",
|
|
4
|
+
"title": "Ask User - Structured Choice Elicitation",
|
|
5
|
+
"description": "Ask the user to choose between 2-8 concrete options (one recommendation allowed; multi-select/free-text optional) and receive a structured result instead of guessing.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"status": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"const": "success"
|
|
11
|
+
},
|
|
12
|
+
"action": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"enum": [
|
|
15
|
+
"accept",
|
|
16
|
+
"decline",
|
|
17
|
+
"cancel"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
"question": {
|
|
21
|
+
"type": "string"
|
|
22
|
+
},
|
|
23
|
+
"selected_ids": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"items": {
|
|
26
|
+
"type": "string"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"selected_labels": {
|
|
30
|
+
"type": "array",
|
|
31
|
+
"items": {
|
|
32
|
+
"type": "string"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"freeform_text": {
|
|
36
|
+
"anyOf": [
|
|
37
|
+
{
|
|
38
|
+
"type": "string"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"type": "null"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"required": [
|
|
47
|
+
"status",
|
|
48
|
+
"action",
|
|
49
|
+
"question",
|
|
50
|
+
"selected_ids",
|
|
51
|
+
"selected_labels"
|
|
52
|
+
],
|
|
53
|
+
"additionalProperties": false
|
|
54
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://wowok.net/schemas/ask_user.json",
|
|
4
|
+
"title": "Ask User - Structured Choice Elicitation",
|
|
5
|
+
"description": "Ask the user to choose between concrete options before continuing.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"question": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"minLength": 1,
|
|
11
|
+
"maxLength": 1000,
|
|
12
|
+
"description": "The single decision you need from the user. Phrase as a complete question; use the user's language. Do NOT stack multiple questions into one call."
|
|
13
|
+
},
|
|
14
|
+
"options": {
|
|
15
|
+
"minItems": 2,
|
|
16
|
+
"maxItems": 8,
|
|
17
|
+
"type": "array",
|
|
18
|
+
"items": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"properties": {
|
|
21
|
+
"id": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"minLength": 1,
|
|
24
|
+
"maxLength": 40,
|
|
25
|
+
"pattern": "^[a-z0-9][a-z0-9_]{0,39}$",
|
|
26
|
+
"description": "Stable machine id returned in the result when chosen (e.g. 'strict_binding')."
|
|
27
|
+
},
|
|
28
|
+
"label": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"minLength": 1,
|
|
31
|
+
"maxLength": 120,
|
|
32
|
+
"description": "Short user-visible label (a few words)."
|
|
33
|
+
},
|
|
34
|
+
"description": {
|
|
35
|
+
"description": "Optional one-line explanation of what choosing this means.",
|
|
36
|
+
"type": "string",
|
|
37
|
+
"maxLength": 500
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"required": [
|
|
41
|
+
"id",
|
|
42
|
+
"label"
|
|
43
|
+
],
|
|
44
|
+
"additionalProperties": false
|
|
45
|
+
},
|
|
46
|
+
"description": "Concrete mutually-exclusive choices (or combinable choices with multi_select=true). Each MUST be self-contained — the user decides from these labels alone."
|
|
47
|
+
},
|
|
48
|
+
"recommended_id": {
|
|
49
|
+
"description": "id of the option you recommend (marked as suggested). Must match one of options[].id. Omit only when you genuinely have no recommendation.",
|
|
50
|
+
"type": "string",
|
|
51
|
+
"minLength": 1,
|
|
52
|
+
"maxLength": 40,
|
|
53
|
+
"pattern": "^[a-z0-9][a-z0-9_]{0,39}$"
|
|
54
|
+
},
|
|
55
|
+
"multi_select": {
|
|
56
|
+
"default": false,
|
|
57
|
+
"description": "true when several options may be combined (the result returns an id array).",
|
|
58
|
+
"type": "boolean"
|
|
59
|
+
},
|
|
60
|
+
"allow_freeform": {
|
|
61
|
+
"default": false,
|
|
62
|
+
"description": "true to additionally allow a free-text answer not covered by the options.",
|
|
63
|
+
"type": "boolean"
|
|
64
|
+
},
|
|
65
|
+
"context": {
|
|
66
|
+
"description": "Optional short explanation of WHY this decision is needed and what each path changes — shown under the question, never instead of it.",
|
|
67
|
+
"type": "string",
|
|
68
|
+
"maxLength": 800
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"required": [
|
|
72
|
+
"question",
|
|
73
|
+
"options",
|
|
74
|
+
"multi_select",
|
|
75
|
+
"allow_freeform"
|
|
76
|
+
],
|
|
77
|
+
"additionalProperties": false
|
|
78
|
+
}
|
|
@@ -48,8 +48,12 @@
|
|
|
48
48
|
"guard_rejected",
|
|
49
49
|
"state_conflict",
|
|
50
50
|
"insufficient_balance",
|
|
51
|
+
"stock_exhausted",
|
|
52
|
+
"sale_suspended",
|
|
53
|
+
"discount_invalid",
|
|
51
54
|
"object_not_found",
|
|
52
55
|
"permission_denied",
|
|
56
|
+
"time_lock_not_elapsed",
|
|
53
57
|
"immutable_violation",
|
|
54
58
|
"network_error",
|
|
55
59
|
"rate_limit",
|
|
@@ -113,8 +113,17 @@
|
|
|
113
113
|
"type": "boolean"
|
|
114
114
|
},
|
|
115
115
|
"dry_run": {
|
|
116
|
-
"description": "Phase 1 dry_run: when true, SIMULATE the transaction without signing or submitting. Returns effects + events showing what WOULD happen — no on-chain state is modified, no gas is charged. Use this to verify an operation will succeed before committing.
|
|
116
|
+
"description": "Phase 1 dry_run: when true, SIMULATE the transaction without signing or submitting. Returns effects + events showing what WOULD happen — no on-chain state is modified, no gas is charged. Use this to verify that an operation will succeed before committing. The returned digest will be 'dry_run:<timestamp>' and objectChanges will be empty (simulation only).",
|
|
117
117
|
"type": "boolean"
|
|
118
|
+
},
|
|
119
|
+
"confirm_mode": {
|
|
120
|
+
"description": "Confirmation frequency for this call. 'full': confirm every matched gate rule. 'streamlined' (client default): skip fail-open 'standard' level prompts — fail-closed levels (irreversible/publish/amount) ALWAYS still confirm. 'quiet': same hard floor as streamlined, for clients that batch/suppress repeat low-risk prompts in their own UI. This field NEVER downgrades fail-closed levels.",
|
|
121
|
+
"type": "string",
|
|
122
|
+
"enum": [
|
|
123
|
+
"full",
|
|
124
|
+
"streamlined",
|
|
125
|
+
"quiet"
|
|
126
|
+
]
|
|
118
127
|
}
|
|
119
128
|
},
|
|
120
129
|
"required": [
|
|
@@ -240,8 +249,17 @@
|
|
|
240
249
|
"type": "boolean"
|
|
241
250
|
},
|
|
242
251
|
"dry_run": {
|
|
243
|
-
"description": "Phase 1 dry_run: when true, SIMULATE the transaction without signing or submitting. Returns effects + events showing what WOULD happen — no on-chain state is modified, no gas is charged. Use this to verify an operation will succeed before committing.
|
|
252
|
+
"description": "Phase 1 dry_run: when true, SIMULATE the transaction without signing or submitting. Returns effects + events showing what WOULD happen — no on-chain state is modified, no gas is charged. Use this to verify that an operation will succeed before committing. The returned digest will be 'dry_run:<timestamp>' and objectChanges will be empty (simulation only).",
|
|
244
253
|
"type": "boolean"
|
|
254
|
+
},
|
|
255
|
+
"confirm_mode": {
|
|
256
|
+
"description": "Confirmation frequency for this call. 'full': confirm every matched gate rule. 'streamlined' (client default): skip fail-open 'standard' level prompts — fail-closed levels (irreversible/publish/amount) ALWAYS still confirm. 'quiet': same hard floor as streamlined, for clients that batch/suppress repeat low-risk prompts in their own UI. This field NEVER downgrades fail-closed levels.",
|
|
257
|
+
"type": "string",
|
|
258
|
+
"enum": [
|
|
259
|
+
"full",
|
|
260
|
+
"streamlined",
|
|
261
|
+
"quiet"
|
|
262
|
+
]
|
|
245
263
|
}
|
|
246
264
|
},
|
|
247
265
|
"required": [
|
|
@@ -341,8 +359,17 @@
|
|
|
341
359
|
"type": "boolean"
|
|
342
360
|
},
|
|
343
361
|
"dry_run": {
|
|
344
|
-
"description": "Phase 1 dry_run: when true, SIMULATE the transaction without signing or submitting. Returns effects + events showing what WOULD happen — no on-chain state is modified, no gas is charged. Use this to verify an operation will succeed before committing.
|
|
362
|
+
"description": "Phase 1 dry_run: when true, SIMULATE the transaction without signing or submitting. Returns effects + events showing what WOULD happen — no on-chain state is modified, no gas is charged. Use this to verify that an operation will succeed before committing. The returned digest will be 'dry_run:<timestamp>' and objectChanges will be empty (simulation only).",
|
|
345
363
|
"type": "boolean"
|
|
364
|
+
},
|
|
365
|
+
"confirm_mode": {
|
|
366
|
+
"description": "Confirmation frequency for this call. 'full': confirm every matched gate rule. 'streamlined' (client default): skip fail-open 'standard' level prompts — fail-closed levels (irreversible/publish/amount) ALWAYS still confirm. 'quiet': same hard floor as streamlined, for clients that batch/suppress repeat low-risk prompts in their own UI. This field NEVER downgrades fail-closed levels.",
|
|
367
|
+
"type": "string",
|
|
368
|
+
"enum": [
|
|
369
|
+
"full",
|
|
370
|
+
"streamlined",
|
|
371
|
+
"quiet"
|
|
372
|
+
]
|
|
346
373
|
}
|
|
347
374
|
},
|
|
348
375
|
"required": [
|
|
@@ -442,8 +469,17 @@
|
|
|
442
469
|
"type": "boolean"
|
|
443
470
|
},
|
|
444
471
|
"dry_run": {
|
|
445
|
-
"description": "Phase 1 dry_run: when true, SIMULATE the transaction without signing or submitting. Returns effects + events showing what WOULD happen — no on-chain state is modified, no gas is charged. Use this to verify an operation will succeed before committing.
|
|
472
|
+
"description": "Phase 1 dry_run: when true, SIMULATE the transaction without signing or submitting. Returns effects + events showing what WOULD happen — no on-chain state is modified, no gas is charged. Use this to verify that an operation will succeed before committing. The returned digest will be 'dry_run:<timestamp>' and objectChanges will be empty (simulation only).",
|
|
446
473
|
"type": "boolean"
|
|
474
|
+
},
|
|
475
|
+
"confirm_mode": {
|
|
476
|
+
"description": "Confirmation frequency for this call. 'full': confirm every matched gate rule. 'streamlined' (client default): skip fail-open 'standard' level prompts — fail-closed levels (irreversible/publish/amount) ALWAYS still confirm. 'quiet': same hard floor as streamlined, for clients that batch/suppress repeat low-risk prompts in their own UI. This field NEVER downgrades fail-closed levels.",
|
|
477
|
+
"type": "string",
|
|
478
|
+
"enum": [
|
|
479
|
+
"full",
|
|
480
|
+
"streamlined",
|
|
481
|
+
"quiet"
|
|
482
|
+
]
|
|
447
483
|
}
|
|
448
484
|
},
|
|
449
485
|
"required": [
|
|
@@ -575,8 +611,17 @@
|
|
|
575
611
|
"type": "boolean"
|
|
576
612
|
},
|
|
577
613
|
"dry_run": {
|
|
578
|
-
"description": "Phase 1 dry_run: when true, SIMULATE the transaction without signing or submitting. Returns effects + events showing what WOULD happen — no on-chain state is modified, no gas is charged. Use this to verify an operation will succeed before committing.
|
|
614
|
+
"description": "Phase 1 dry_run: when true, SIMULATE the transaction without signing or submitting. Returns effects + events showing what WOULD happen — no on-chain state is modified, no gas is charged. Use this to verify that an operation will succeed before committing. The returned digest will be 'dry_run:<timestamp>' and objectChanges will be empty (simulation only).",
|
|
579
615
|
"type": "boolean"
|
|
616
|
+
},
|
|
617
|
+
"confirm_mode": {
|
|
618
|
+
"description": "Confirmation frequency for this call. 'full': confirm every matched gate rule. 'streamlined' (client default): skip fail-open 'standard' level prompts — fail-closed levels (irreversible/publish/amount) ALWAYS still confirm. 'quiet': same hard floor as streamlined, for clients that batch/suppress repeat low-risk prompts in their own UI. This field NEVER downgrades fail-closed levels.",
|
|
619
|
+
"type": "string",
|
|
620
|
+
"enum": [
|
|
621
|
+
"full",
|
|
622
|
+
"streamlined",
|
|
623
|
+
"quiet"
|
|
624
|
+
]
|
|
580
625
|
}
|
|
581
626
|
},
|
|
582
627
|
"required": [
|
|
@@ -83,8 +83,17 @@
|
|
|
83
83
|
"type": "boolean"
|
|
84
84
|
},
|
|
85
85
|
"dry_run": {
|
|
86
|
-
"description": "Phase 1 dry_run: when true, SIMULATE the transaction without signing or submitting. Returns effects + events showing what WOULD happen — no on-chain state is modified, no gas is charged. Use this to verify an operation will succeed before committing.
|
|
86
|
+
"description": "Phase 1 dry_run: when true, SIMULATE the transaction without signing or submitting. Returns effects + events showing what WOULD happen — no on-chain state is modified, no gas is charged. Use this to verify that an operation will succeed before committing. The returned digest will be 'dry_run:<timestamp>' and objectChanges will be empty (simulation only).",
|
|
87
87
|
"type": "boolean"
|
|
88
|
+
},
|
|
89
|
+
"confirm_mode": {
|
|
90
|
+
"description": "Confirmation frequency for this call. 'full': confirm every matched gate rule. 'streamlined' (client default): skip fail-open 'standard' level prompts — fail-closed levels (irreversible/publish/amount) ALWAYS still confirm. 'quiet': same hard floor as streamlined, for clients that batch/suppress repeat low-risk prompts in their own UI. This field NEVER downgrades fail-closed levels.",
|
|
91
|
+
"type": "string",
|
|
92
|
+
"enum": [
|
|
93
|
+
"full",
|
|
94
|
+
"streamlined",
|
|
95
|
+
"quiet"
|
|
96
|
+
]
|
|
88
97
|
}
|
|
89
98
|
},
|
|
90
99
|
"required": [
|
package/dist/schemas/index.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"title": "WoWok MCP Schema Index",
|
|
4
4
|
"description": "Index of all available JSON schemas for WoWok MCP tools",
|
|
5
|
-
"generatedAt": "2026-09-
|
|
5
|
+
"generatedAt": "2026-09-15T14:55:31.384Z",
|
|
6
6
|
"tools": [
|
|
7
7
|
{
|
|
8
8
|
"name": "onchain_operations",
|
|
@@ -28,6 +28,12 @@
|
|
|
28
28
|
"path": "./local_info_operation.schema.json",
|
|
29
29
|
"outputPath": "./local_info_operation.output.json"
|
|
30
30
|
},
|
|
31
|
+
{
|
|
32
|
+
"name": "local_history_operation",
|
|
33
|
+
"title": "Local History Operations",
|
|
34
|
+
"path": "./local_history_operation.schema.json",
|
|
35
|
+
"outputPath": "./local_history_operation.output.json"
|
|
36
|
+
},
|
|
31
37
|
{
|
|
32
38
|
"name": "wip_file",
|
|
33
39
|
"title": "WIP File Operations",
|
|
@@ -100,6 +106,12 @@
|
|
|
100
106
|
"path": "./schema_query.schema.json",
|
|
101
107
|
"outputPath": "./schema_query.output.json"
|
|
102
108
|
},
|
|
109
|
+
{
|
|
110
|
+
"name": "ask_user",
|
|
111
|
+
"title": "Ask User - Structured Choice Elicitation",
|
|
112
|
+
"path": "./ask_user.schema.json",
|
|
113
|
+
"outputPath": "./ask_user.output.json"
|
|
114
|
+
},
|
|
103
115
|
{
|
|
104
116
|
"name": "bridge_operation",
|
|
105
117
|
"title": "Bridge - Cross-Chain Operations",
|