@wowok/agent-mcp 2.6.1 → 2.6.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.
Files changed (246) hide show
  1. package/dist/customer/customer-advice.d.ts +31 -0
  2. package/dist/customer/customer-advice.js +129 -0
  3. package/dist/customer/index.d.ts +2 -0
  4. package/dist/customer/index.js +2 -0
  5. package/dist/customer/info-puzzle.d.ts +9 -2
  6. package/dist/customer/info-puzzle.js +34 -7
  7. package/dist/customer/order-monitor.d.ts +2 -0
  8. package/dist/customer/order-monitor.js +3 -2
  9. package/dist/customer/post-purchase.d.ts +2 -0
  10. package/dist/customer/post-purchase.js +6 -5
  11. package/dist/customer/preorder-compare.d.ts +24 -0
  12. package/dist/customer/preorder-compare.js +34 -0
  13. package/dist/customer/reminder-system.d.ts +2 -0
  14. package/dist/customer/reminder-system.js +2 -1
  15. package/dist/customer/risk-assessment.js +30 -7
  16. package/dist/customer/types.d.ts +7 -0
  17. package/dist/examples/arbitration-dispute-create.json +41 -0
  18. package/dist/examples/arbitration-vote-weighted.json +35 -0
  19. package/dist/examples/arbitration-voting-guard-add.json +38 -0
  20. package/dist/examples/demand-present-service.json +33 -0
  21. package/dist/examples/gen-passport-verify-guard.json +48 -0
  22. package/dist/examples/guard-template-balance-check.json +59 -0
  23. package/dist/examples/guard-template-time-lock.json +60 -0
  24. package/dist/examples/insurance-guard-claim-timelock.json +75 -0
  25. package/dist/examples/insurance-guard-withdraw-allocation.json +96 -0
  26. package/dist/examples/insurance-machine-create-publish.json +75 -0
  27. package/dist/examples/insurance-service-allocators-publish.json +56 -0
  28. package/dist/examples/machine-multisig-threshold.json +86 -0
  29. package/dist/examples/machine-template-7node-rental.json +119 -0
  30. package/dist/examples/payment-scenario-bound.json +45 -0
  31. package/dist/examples/rental-ziroom-machine-create.json +149 -0
  32. package/dist/examples/rental-ziroom-permission-create.json +42 -0
  33. package/dist/examples/rental-ziroom-service-create.json +89 -0
  34. package/dist/examples/retail-adv-guard-customer-win-create.json +80 -0
  35. package/dist/examples/retail-adv-guard-messenger-proof-create.json +65 -0
  36. package/dist/examples/retail-adv-guard-reward-timeout-create.json +92 -0
  37. package/dist/examples/retail-adv-reward-guard-add.json +51 -0
  38. package/dist/examples/retail-myshop-allocation-activate.json +55 -0
  39. package/dist/examples/retail-myshop-arbitration-create.json +40 -0
  40. package/dist/examples/retail-myshop-contact-create.json +43 -0
  41. package/dist/examples/retail-myshop-order-create.json +56 -0
  42. package/dist/examples/retail-myshop-progress-operate.json +38 -0
  43. package/dist/examples/retail-myshop-reward-create.json +35 -0
  44. package/dist/examples/retail-myshop-service-create.json +88 -0
  45. package/dist/examples/service-discount-issue.json +46 -0
  46. package/dist/examples/threebody-guard-create.json +56 -0
  47. package/dist/examples/threebody-machine-create.json +72 -0
  48. package/dist/examples/threebody-permission-create.json +38 -0
  49. package/dist/examples/threebody-service-allocators.json +49 -0
  50. package/dist/examples/travel-guard-time-lock.json +69 -0
  51. package/dist/examples/travel-guard-weather-oracle.json +70 -0
  52. package/dist/examples/travel-machine-create.json +136 -0
  53. package/dist/examples/travel-repository-create.json +47 -0
  54. package/dist/examples/travel-service-create.json +102 -0
  55. package/dist/examples/travel-treasury-create.json +34 -0
  56. package/dist/examples/treasury-deposit.json +37 -0
  57. package/dist/examples/treasury-withdraw.json +38 -0
  58. package/dist/extensions/business-modules.d.ts +49 -0
  59. package/dist/extensions/business-modules.js +287 -0
  60. package/dist/extensions/capability-manifest.js +216 -29
  61. package/dist/extensions/constraint-registry.js +21 -19
  62. package/dist/extensions/metric-registry.js +14 -14
  63. package/dist/extensions/mode-evaluator.js +16 -16
  64. package/dist/extensions/modes.js +141 -49
  65. package/dist/extensions/registry.d.ts +16 -9
  66. package/dist/extensions/registry.js +132 -44
  67. package/dist/extensions/types.d.ts +2 -0
  68. package/dist/index.js +50 -0
  69. package/dist/knowledge/deployment-scanner.js +1 -1
  70. package/dist/knowledge/fund-layer.d.ts +138 -0
  71. package/dist/knowledge/fund-layer.js +969 -0
  72. package/dist/knowledge/guard-render.d.ts +57 -0
  73. package/dist/knowledge/guard-render.js +700 -0
  74. package/dist/knowledge/guard-submission-prompt.d.ts +31 -0
  75. package/dist/knowledge/guard-submission-prompt.js +171 -0
  76. package/dist/knowledge/guard-templates.d.ts +10 -0
  77. package/dist/knowledge/guard-templates.js +50 -0
  78. package/dist/knowledge/index.d.ts +2 -2
  79. package/dist/knowledge/index.js +2 -2
  80. package/dist/knowledge/machine-ledger.js +1 -1
  81. package/dist/knowledge/machine-render.d.ts +41 -0
  82. package/dist/knowledge/machine-render.js +565 -0
  83. package/dist/knowledge/machine-risk.js +4 -1
  84. package/dist/knowledge/machine-templates.js +4 -4
  85. package/dist/knowledge/progress-context.js +1 -1
  86. package/dist/knowledge/progress-ledger.js +3 -3
  87. package/dist/knowledge/progress-templates.js +1 -1
  88. package/dist/knowledge/progress-translation.js +1 -1
  89. package/dist/knowledge/reward-confirm.js +2 -2
  90. package/dist/knowledge/reward-puzzle.js +1 -1
  91. package/dist/knowledge/reward-risk.js +9 -9
  92. package/dist/knowledge/reward-templates.js +2 -2
  93. package/dist/knowledge/safety-rules.d.ts +83 -1
  94. package/dist/knowledge/safety-rules.js +166 -2
  95. package/dist/knowledge/scenario-modes.d.ts +1 -1
  96. package/dist/knowledge/scenario-modes.js +13 -11
  97. package/dist/knowledge/service-confirm.d.ts +1 -1
  98. package/dist/knowledge/service-confirm.js +3 -3
  99. package/dist/knowledge/service-context.js +1 -1
  100. package/dist/knowledge/service-ledger.js +1 -1
  101. package/dist/knowledge/service-risk.d.ts +1 -1
  102. package/dist/knowledge/service-risk.js +3 -3
  103. package/dist/knowledge/service-templates.js +2 -2
  104. package/dist/knowledge/service-translation.d.ts +1 -1
  105. package/dist/knowledge/service-translation.js +7 -7
  106. package/dist/knowledge/template-registry.d.ts +48 -0
  107. package/dist/knowledge/template-registry.js +341 -0
  108. package/dist/knowledge/tool-constraints.js +6 -6
  109. package/dist/knowledge/tools-reference.js +11 -8
  110. package/dist/participation/merchant-interest.d.ts +32 -0
  111. package/dist/participation/merchant-interest.js +100 -0
  112. package/dist/participation/radar-core.d.ts +104 -0
  113. package/dist/participation/radar-core.js +269 -0
  114. package/dist/project/context-assembly.js +8 -0
  115. package/dist/project/deployment-bridge.js +6 -5
  116. package/dist/project/deployment-doc.js +5 -5
  117. package/dist/project/edit-planner.d.ts +123 -0
  118. package/dist/project/edit-planner.js +1342 -0
  119. package/dist/project/evaluation.d.ts +36 -0
  120. package/dist/project/evaluation.js +734 -68
  121. package/dist/project/game-theory.d.ts +43 -0
  122. package/dist/project/game-theory.js +177 -0
  123. package/dist/project/graph-builder.js +7 -1
  124. package/dist/project/handlers.d.ts +137 -2
  125. package/dist/project/handlers.js +423 -51
  126. package/dist/project/intent-analyzer.d.ts +71 -0
  127. package/dist/project/intent-analyzer.js +149 -0
  128. package/dist/project/machine-nodes.d.ts +2 -0
  129. package/dist/project/machine-nodes.js +36 -0
  130. package/dist/project/merchant-guide.d.ts +165 -0
  131. package/dist/project/merchant-guide.js +264 -0
  132. package/dist/project/mode-actions.d.ts +199 -0
  133. package/dist/project/mode-actions.js +309 -0
  134. package/dist/project/participation-radar.d.ts +18 -0
  135. package/dist/project/participation-radar.js +428 -0
  136. package/dist/project/pipeline-actions.d.ts +101 -0
  137. package/dist/project/pipeline-actions.js +109 -0
  138. package/dist/project/semantic-graph.d.ts +95 -0
  139. package/dist/project/semantic-graph.js +245 -0
  140. package/dist/project/stage-gate.js +4 -4
  141. package/dist/schema/call/allocation.d.ts +11 -11
  142. package/dist/schema/call/allocation.js +13 -3
  143. package/dist/schema/call/arbitration.d.ts +21 -21
  144. package/dist/schema/call/arbitration.js +30 -9
  145. package/dist/schema/call/base.d.ts +2 -2
  146. package/dist/schema/call/base.js +1 -1
  147. package/dist/schema/call/bridge.d.ts +127 -127
  148. package/dist/schema/call/bridge.js +12 -12
  149. package/dist/schema/call/contact.d.ts +3 -3
  150. package/dist/schema/call/contact.js +2 -2
  151. package/dist/schema/call/demand.d.ts +3 -3
  152. package/dist/schema/call/demand.js +2 -2
  153. package/dist/schema/call/guard.d.ts +11 -11
  154. package/dist/schema/call/guard.js +2 -2
  155. package/dist/schema/call/machine.d.ts +2072 -679
  156. package/dist/schema/call/machine.js +51 -5
  157. package/dist/schema/call/order.d.ts +7 -7
  158. package/dist/schema/call/order.js +3 -6
  159. package/dist/schema/call/payment.d.ts +3 -3
  160. package/dist/schema/call/permission.d.ts +3 -3
  161. package/dist/schema/call/permission.js +2 -2
  162. package/dist/schema/call/personal.d.ts +337 -3
  163. package/dist/schema/call/personal.js +10 -0
  164. package/dist/schema/call/progress.d.ts +177 -9
  165. package/dist/schema/call/progress.js +7 -3
  166. package/dist/schema/call/proof.d.ts +6 -6
  167. package/dist/schema/call/repository.d.ts +3 -3
  168. package/dist/schema/call/repository.js +2 -2
  169. package/dist/schema/call/reward.d.ts +57 -57
  170. package/dist/schema/call/reward.js +3 -3
  171. package/dist/schema/call/semantic.js +48 -2
  172. package/dist/schema/call/service.d.ts +285 -113
  173. package/dist/schema/call/service.js +92 -28
  174. package/dist/schema/call/treasury.d.ts +57 -57
  175. package/dist/schema/call/treasury.js +3 -3
  176. package/dist/schema/common/index.d.ts +2 -0
  177. package/dist/schema/common/index.js +46 -10
  178. package/dist/schema/local/index.js +5 -1
  179. package/dist/schema/messenger/index.js +4 -1
  180. package/dist/schema/operations.d.ts +1318 -317
  181. package/dist/schema/operations.js +76 -7
  182. package/dist/schema/project/index.d.ts +5662 -164
  183. package/dist/schema/project/index.js +1136 -5
  184. package/dist/schema/query/index.d.ts +580 -19
  185. package/dist/schema/query/index.js +88 -36
  186. package/dist/schema/schema-query/index.d.ts +59 -3
  187. package/dist/schema/schema-query/index.js +45 -6
  188. package/dist/schema/trust/index.d.ts +1012 -6
  189. package/dist/schema/trust/index.js +212 -11
  190. package/dist/schema/utils/node-parser.js +13 -0
  191. package/dist/schema/utils/object-type-utils.d.ts +12 -0
  192. package/dist/schema/utils/object-type-utils.js +35 -0
  193. package/dist/schema/utils/permission-machine-check.d.ts +49 -0
  194. package/dist/schema/utils/permission-machine-check.js +121 -0
  195. package/dist/schema/utils/skills-recommendation.d.ts +2 -0
  196. package/dist/schema/utils/skills-recommendation.js +77 -0
  197. package/dist/schema-query/index.d.ts +17 -1
  198. package/dist/schema-query/index.js +359 -3
  199. package/dist/schemas/account_operation.schema.json +1 -1
  200. package/dist/schemas/bridge_operation.schema.json +14 -7
  201. package/dist/schemas/guard2file.schema.json +2 -0
  202. package/dist/schemas/index.json +1 -1
  203. package/dist/schemas/machineNode2file.schema.json +2 -0
  204. package/dist/schemas/messenger_operation.schema.json +1 -1
  205. package/dist/schemas/onchain_events.output.json +1 -1
  206. package/dist/schemas/onchain_operations.output.json +2820 -0
  207. package/dist/schemas/onchain_operations.schema.json +255 -65
  208. package/dist/schemas/onchain_operations_allocation.schema.json +7 -6
  209. package/dist/schemas/onchain_operations_arbitration.schema.json +14 -10
  210. package/dist/schemas/onchain_operations_contact.schema.json +4 -3
  211. package/dist/schemas/onchain_operations_demand.schema.json +4 -3
  212. package/dist/schemas/onchain_operations_gen_passport.schema.json +4 -2
  213. package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -0
  214. package/dist/schemas/onchain_operations_guard.schema.json +579 -1
  215. package/dist/schemas/onchain_operations_machine.schema.json +5 -4
  216. package/dist/schemas/onchain_operations_order.schema.json +7 -6
  217. package/dist/schemas/onchain_operations_payment.schema.json +2 -1
  218. package/dist/schemas/onchain_operations_permission.schema.json +3 -2
  219. package/dist/schemas/onchain_operations_personal.schema.json +37 -0
  220. package/dist/schemas/onchain_operations_progress.schema.json +91 -4
  221. package/dist/schemas/onchain_operations_proof.schema.json +2 -1
  222. package/dist/schemas/onchain_operations_repository.schema.json +4 -3
  223. package/dist/schemas/onchain_operations_reward.schema.json +7 -6
  224. package/dist/schemas/onchain_operations_service.schema.json +80 -19
  225. package/dist/schemas/onchain_operations_treasury.schema.json +5 -4
  226. package/dist/schemas/onchain_table_data.output.json +1 -1
  227. package/dist/schemas/onchain_table_data.schema.json +10 -9
  228. package/dist/schemas/project_operation.output.json +3318 -57
  229. package/dist/schemas/project_operation.schema.json +728 -4
  230. package/dist/schemas/query_toolkit.output.json +16 -16
  231. package/dist/schemas/query_toolkit.schema.json +40 -3
  232. package/dist/schemas/schema_query.output.json +65 -2
  233. package/dist/schemas/schema_query.schema.json +31 -5
  234. package/dist/schemas/trust_score.output.json +392 -1
  235. package/dist/schemas/trust_score.schema.json +275 -1
  236. package/dist/schemas/wowok_buildin_info.output.json +81 -8
  237. package/dist/schemas/wowok_buildin_info.schema.json +46 -2
  238. package/dist/tools/handlers/onchain.js +636 -6
  239. package/dist/tools/handlers/project.js +71 -2
  240. package/dist/tools/handlers/query.js +117 -2
  241. package/dist/tools/handlers/schema-query.js +65 -1
  242. package/dist/tools/handlers/trust.js +192 -6
  243. package/dist/tools/index.d.ts +8 -0
  244. package/dist/tools/index.js +229 -15
  245. package/dist/tools/wrap.js +194 -15
  246. package/package.json +2 -2
@@ -0,0 +1,31 @@
1
+ export interface SubmissionFieldPrompt {
2
+ identifier: number;
3
+ name: string;
4
+ value_type: string;
5
+ required: boolean;
6
+ suggested_value?: string;
7
+ suggestion_reason?: string;
8
+ description: string;
9
+ }
10
+ export interface GuardSubmissionPrompt {
11
+ guard_address: string;
12
+ guard_name?: string;
13
+ operation: string;
14
+ required_fields: SubmissionFieldPrompt[];
15
+ context: string;
16
+ fill_example: string;
17
+ }
18
+ export interface SubmissionContext {
19
+ operation: string;
20
+ network?: string;
21
+ signer?: string;
22
+ progress_address?: string;
23
+ progress_current?: string;
24
+ order_address?: string;
25
+ service_address?: string;
26
+ machine_address?: string;
27
+ allocation_address?: string;
28
+ extra?: Record<string, string>;
29
+ }
30
+ export declare function generateGuardSubmissionPrompt(guardRef: string, ctx: SubmissionContext): Promise<GuardSubmissionPrompt | undefined>;
31
+ export declare function formatSubmissionPrompt(prompt: GuardSubmissionPrompt): string;
@@ -0,0 +1,171 @@
1
+ import { query_objects, LocalMark } from "@wowok/wowok";
2
+ function inferValue(fieldName, valueType, ctx) {
3
+ const name = fieldName.toLowerCase();
4
+ if (name.includes("order") || name.includes("task")) {
5
+ if (ctx.order_address) {
6
+ return { value: ctx.order_address, reason: "Inferred from operation's order_address context" };
7
+ }
8
+ if (ctx.progress_address) {
9
+ return { value: ctx.progress_address, reason: "Progress.task is typically the order — query Progress to get the actual task address" };
10
+ }
11
+ }
12
+ if (name.includes("signer") || name.includes("sender") || name.includes("caller")) {
13
+ if (ctx.signer) {
14
+ return { value: ctx.signer, reason: "Inferred from env.account (the signing account)" };
15
+ }
16
+ }
17
+ if (name.includes("service")) {
18
+ if (ctx.service_address) {
19
+ return { value: ctx.service_address, reason: "Inferred from operation's service_address context" };
20
+ }
21
+ }
22
+ if (name.includes("machine")) {
23
+ if (ctx.machine_address) {
24
+ return { value: ctx.machine_address, reason: "Inferred from operation's machine_address context" };
25
+ }
26
+ }
27
+ if (name.includes("progress") || name.includes("node") || name.includes("current")) {
28
+ if (ctx.progress_current) {
29
+ return { value: ctx.progress_current, reason: "Inferred from Progress.current node name" };
30
+ }
31
+ }
32
+ if (name.includes("allocation") || name.includes("allocator")) {
33
+ if (ctx.allocation_address) {
34
+ return { value: ctx.allocation_address, reason: "Inferred from operation's allocation_address context" };
35
+ }
36
+ }
37
+ if (ctx.extra) {
38
+ for (const [key, val] of Object.entries(ctx.extra)) {
39
+ if (name.includes(key.toLowerCase())) {
40
+ return { value: val, reason: `Inferred from extra context: ${key}` };
41
+ }
42
+ }
43
+ }
44
+ return undefined;
45
+ }
46
+ function describeField(name, valueType) {
47
+ const n = name.toLowerCase();
48
+ if (n.includes("order"))
49
+ return `Order object address (type: ${valueType})`;
50
+ if (n.includes("signer") || n.includes("sender"))
51
+ return `Transaction signer address (type: ${valueType})`;
52
+ if (n.includes("service"))
53
+ return `Service object address (type: ${valueType})`;
54
+ if (n.includes("machine"))
55
+ return `Machine object address (type: ${valueType})`;
56
+ if (n.includes("progress"))
57
+ return `Progress object address (type: ${valueType})`;
58
+ if (n.includes("node") || n.includes("current"))
59
+ return `Current node name (type: ${valueType})`;
60
+ if (n.includes("amount") || n.includes("price") || n.includes("balance"))
61
+ return `Amount in smallest unit (type: ${valueType})`;
62
+ if (n.includes("allocation"))
63
+ return `Allocation object address (type: ${valueType})`;
64
+ return `Field "${name}" (type: ${valueType})`;
65
+ }
66
+ export async function generateGuardSubmissionPrompt(guardRef, ctx) {
67
+ let guardAddress = guardRef;
68
+ let guardName;
69
+ if (!guardRef.startsWith("0x")) {
70
+ try {
71
+ const mark = await LocalMark.Instance().get(guardRef);
72
+ if (mark?.address) {
73
+ guardAddress = mark.address;
74
+ guardName = guardRef;
75
+ }
76
+ else {
77
+ return undefined;
78
+ }
79
+ }
80
+ catch {
81
+ return undefined;
82
+ }
83
+ }
84
+ let guardObj;
85
+ try {
86
+ const result = await query_objects({
87
+ objects: [guardAddress],
88
+ network: ctx.network,
89
+ });
90
+ guardObj = result?.objects?.[0];
91
+ }
92
+ catch {
93
+ return undefined;
94
+ }
95
+ if (!guardObj)
96
+ return undefined;
97
+ const table = guardObj.table ?? guardObj.b_table ?? [];
98
+ if (!Array.isArray(table) || table.length === 0)
99
+ return undefined;
100
+ const submissionItems = table.filter((item) => item.b_submission === true);
101
+ if (submissionItems.length === 0)
102
+ return undefined;
103
+ const requiredFields = submissionItems.map((item) => {
104
+ const fieldName = item.name ?? `identifier_${item.identifier}`;
105
+ const valueType = typeof item.value_type === "number"
106
+ ? ValueTypeNames[item.value_type] ?? String(item.value_type)
107
+ : String(item.value_type);
108
+ const inferred = inferValue(fieldName, valueType, ctx);
109
+ return {
110
+ identifier: item.identifier,
111
+ name: fieldName,
112
+ value_type: valueType,
113
+ required: true,
114
+ suggested_value: inferred?.value,
115
+ suggestion_reason: inferred?.reason,
116
+ description: describeField(fieldName, valueType),
117
+ };
118
+ });
119
+ const fillLines = requiredFields.map((f) => {
120
+ const val = f.suggested_value ?? `<${f.value_type}_value>`;
121
+ return ` { identifier: ${f.identifier}, name: "${f.name}", value_type: "${f.value_type}", value: ${val} }`;
122
+ });
123
+ const fillExample = `submission: {
124
+ guard: "${guardName ?? guardAddress}",
125
+ submission: [
126
+ ${fillLines.join(",\n")}
127
+ ]
128
+ }`;
129
+ return {
130
+ guard_address: guardAddress,
131
+ guard_name: guardName,
132
+ operation: ctx.operation,
133
+ required_fields: requiredFields,
134
+ context: `Operation "${ctx.operation}" requires Guard "${guardName ?? guardAddress}" verification. ` +
135
+ `The Guard has ${requiredFields.length} field(s) that need submission data (b_submission=true). ` +
136
+ `Fill the submission with the required values and retry the operation using call_with_submission. ` +
137
+ `Each field has an identifier (number), name, and expected value_type. ` +
138
+ `The suggested_value (if provided) is inferred from the operation context — verify before using.`,
139
+ fill_example: fillExample,
140
+ };
141
+ }
142
+ export function formatSubmissionPrompt(prompt) {
143
+ const lines = [];
144
+ lines.push("GUARD SUBMISSION REQUIRED — operation cannot proceed without submission data.");
145
+ lines.push(`Guard: ${prompt.guard_name ?? prompt.guard_address} (${prompt.guard_address})`);
146
+ lines.push(`Operation: ${prompt.operation}`);
147
+ lines.push("");
148
+ lines.push("Required fields (fill these in the submission):");
149
+ for (const f of prompt.required_fields) {
150
+ lines.push(` [${f.identifier}] ${f.name} (${f.value_type}) — ${f.description}`);
151
+ if (f.suggested_value) {
152
+ lines.push(` Suggested: ${f.suggested_value} (${f.suggestion_reason})`);
153
+ }
154
+ else {
155
+ lines.push(` No suggestion — derive value from context or ask user.`);
156
+ }
157
+ }
158
+ lines.push("");
159
+ lines.push("Fill example (use in the next call with submission):");
160
+ lines.push(prompt.fill_example);
161
+ return lines.join("\n");
162
+ }
163
+ const ValueTypeNames = {
164
+ 0: "Bool",
165
+ 1: "Address",
166
+ 2: "U64",
167
+ 3: "String",
168
+ 4: "Vec",
169
+ 5: "U256",
170
+ 6: "Object",
171
+ };
@@ -34,5 +34,15 @@ export declare function validateTemplateParams(templateId: string, params: Recor
34
34
  valid: boolean;
35
35
  missing: string[];
36
36
  };
37
+ export type FillGuardTemplateResult = {
38
+ ok: true;
39
+ table: unknown;
40
+ root: unknown;
41
+ } | {
42
+ ok: false;
43
+ error: string;
44
+ missing?: string[];
45
+ };
46
+ export declare function fillGuardTemplate(templateId: string, params: Record<string, unknown>): FillGuardTemplateResult;
37
47
  export declare const GUARD_TEMPLATES_VERSION = "1.0.0";
38
48
  export declare const GUARD_TEMPLATES_COUNT: number;
@@ -1051,5 +1051,55 @@ export function validateTemplateParams(templateId, params) {
1051
1051
  .map((p) => p.name);
1052
1052
  return { valid: missing.length === 0, missing };
1053
1053
  }
1054
+ function deepSubstitute(obj, params) {
1055
+ if (typeof obj === "string") {
1056
+ const full = obj.match(/^\$\{(\w+)\}$/);
1057
+ if (full && full[1] in params) {
1058
+ return params[full[1]];
1059
+ }
1060
+ return obj.replace(/\$\{(\w+)\}/g, (_, key) => key in params ? String(params[key]) : `\${${key}}`);
1061
+ }
1062
+ if (Array.isArray(obj)) {
1063
+ return obj.map((item) => deepSubstitute(item, params));
1064
+ }
1065
+ if (obj && typeof obj === "object") {
1066
+ const result = {};
1067
+ for (const [k, v] of Object.entries(obj)) {
1068
+ result[k] = deepSubstitute(v, params);
1069
+ }
1070
+ return result;
1071
+ }
1072
+ return obj;
1073
+ }
1074
+ export function fillGuardTemplate(templateId, params) {
1075
+ const template = getTemplateById(templateId);
1076
+ if (!template) {
1077
+ return { ok: false, error: `Template not found: ${templateId}` };
1078
+ }
1079
+ const { valid, missing } = validateTemplateParams(templateId, params);
1080
+ if (!valid) {
1081
+ return {
1082
+ ok: false,
1083
+ error: `Missing required parameters: ${missing.join(", ")}`,
1084
+ missing,
1085
+ };
1086
+ }
1087
+ const filled = { ...params };
1088
+ for (const p of template.parameters) {
1089
+ if (!(p.name in filled) && p.default !== undefined) {
1090
+ filled[p.name] = p.default;
1091
+ }
1092
+ }
1093
+ const table = deepSubstitute(template.example_table, filled);
1094
+ const root = deepSubstitute(template.example_root, filled);
1095
+ const leftover = JSON.stringify({ table, root }).match(/\$\{(\w+)\}/);
1096
+ if (leftover) {
1097
+ return {
1098
+ ok: false,
1099
+ error: `Unresolved placeholder \${${leftover[1]}} — not declared in template parameters`,
1100
+ };
1101
+ }
1102
+ return { ok: true, table, root };
1103
+ }
1054
1104
  export const GUARD_TEMPLATES_VERSION = "1.0.0";
1055
1105
  export const GUARD_TEMPLATES_COUNT = GUARD_TEMPLATES.length;
@@ -1,5 +1,5 @@
1
1
  import { CONCEPT_GLOSSARY, CONCEPT_GLOSSARY_VERSION, resolveTerm, lookupEntry, validateText, auditSchemaFields, type GlossaryEntry, type GlossaryCategory, type GlossaryDrift } from "./glossary.js";
2
- import { CONFIRMATION_RULES, SAFETY_RULES_VERSION, type ConfirmationRule, type OperationPreview, type ConfirmLevel } from "./safety-rules.js";
2
+ import { CONFIRMATION_RULES, SAFETY_RULES_VERSION, OBJECT_REUSE_RULES, CREATE_VS_MODIFY_PATTERN, IMMUTABILITY_RULES, OPERATION_TYPE_CLASSIFICATION, OPERATION_CLASS_META, classifyTool, NAMING_CONVENTIONS, checkObjectReuseRules, checkImmutabilityRules, type ConfirmationRule, type OperationPreview, type ConfirmLevel, type ReuseRecommendation, type ObjectReuseRule, type ImmutabilityRule, type OperationClass, type OperationClassMeta, type SafetyRiskItem } from "./safety-rules.js";
3
3
  import { TOOL_CONSTRAINTS, TOOL_CONSTRAINTS_VERSION, validateOperation, hasBlockingViolations, getWarningViolations, type ConstraintSeverity, type FieldConstraint, type OperationConstraint, type ConstraintViolation } from "./tool-constraints.js";
4
4
  import { PERMISSION_TYPES, GAME_ELEMENTS, getPermissionType, getGameElement, getGameElementsByType, PROCESS_MODEL_VERSION, type PermissionScope, type PermissionTypeDef, type GameElementType, type GameElementDef } from "./process-model.js";
5
5
  import { computeTrustScore, quickRiskAssessment, ARBITRATION_TRUST_VERSION, type ArbMetrics, type TrustScore, type TrustComponent } from "./arbitration-trust.js";
@@ -105,7 +105,7 @@ import { TOOLS_REFERENCE, getToolReference, searchToolReference, getToolSequence
105
105
  import { SCENARIO_MODES, SCENARIO_MODES_VERSION, MODE_COMPOSITIONS, matchScenarioMode, inferScenarioTraits, getScenarioMode, listScenarioModes, getShippedModes, getModeCompositions, type IndustryModeName, type ScenarioTraits, type ModeAllocatorStrategy, type ModeGuardRef, type ModeMachineNode, type ScenarioMode, type ModeComposition } from "./scenario-modes.js";
106
106
  import { GUARD_DESIGN_PATTERNS, GUARD_DESIGN_PATTERNS_VERSION, VERIFIER_LEVEL_GUIDANCE, getGuardDesignPattern, searchGuardDesignPatterns, getPatternsByHost, getPatternsByIndustry, getPatternsByDataSourceClass, getVerifierLevelGuidance, suggestPatternForRequirement, type GuardDataSourceClass, type VerifierConstraintLevel, type GuardHostObject, type GuardDesignPattern, type VerifierLevelGuidance } from "./guard-design-patterns.js";
107
107
  export { CONCEPT_GLOSSARY, CONCEPT_GLOSSARY_VERSION, resolveTerm, lookupEntry, validateText, auditSchemaFields, type GlossaryEntry, type GlossaryCategory, type GlossaryDrift, };
108
- export { CONFIRMATION_RULES, SAFETY_RULES_VERSION, type ConfirmationRule, type OperationPreview, type ConfirmLevel, };
108
+ export { CONFIRMATION_RULES, SAFETY_RULES_VERSION, OBJECT_REUSE_RULES, CREATE_VS_MODIFY_PATTERN, IMMUTABILITY_RULES, OPERATION_TYPE_CLASSIFICATION, OPERATION_CLASS_META, classifyTool, NAMING_CONVENTIONS, checkObjectReuseRules, checkImmutabilityRules, type ConfirmationRule, type OperationPreview, type ConfirmLevel, type ReuseRecommendation, type ObjectReuseRule, type ImmutabilityRule, type OperationClass, type OperationClassMeta, type SafetyRiskItem, };
109
109
  export { TOOL_CONSTRAINTS, TOOL_CONSTRAINTS_VERSION, validateOperation, hasBlockingViolations, getWarningViolations, type ConstraintSeverity, type FieldConstraint, type OperationConstraint, type ConstraintViolation, };
110
110
  export { PERMISSION_TYPES, GAME_ELEMENTS, getPermissionType, getGameElement, getGameElementsByType, PROCESS_MODEL_VERSION, type PermissionScope, type PermissionTypeDef, type GameElementType, type GameElementDef, };
111
111
  export { computeTrustScore, quickRiskAssessment, ARBITRATION_TRUST_VERSION, type ArbMetrics, type TrustScore, type TrustComponent, };
@@ -1,5 +1,5 @@
1
1
  import { CONCEPT_GLOSSARY, CONCEPT_GLOSSARY_VERSION, resolveTerm, lookupEntry, validateText, auditSchemaFields } from "./glossary.js";
2
- import { CONFIRMATION_RULES, SAFETY_RULES_VERSION } from "./safety-rules.js";
2
+ import { CONFIRMATION_RULES, SAFETY_RULES_VERSION, OBJECT_REUSE_RULES, CREATE_VS_MODIFY_PATTERN, IMMUTABILITY_RULES, OPERATION_TYPE_CLASSIFICATION, OPERATION_CLASS_META, classifyTool, NAMING_CONVENTIONS, checkObjectReuseRules, checkImmutabilityRules } from "./safety-rules.js";
3
3
  import { TOOL_CONSTRAINTS, TOOL_CONSTRAINTS_VERSION, validateOperation, hasBlockingViolations, getWarningViolations, } from "./tool-constraints.js";
4
4
  import { PERMISSION_TYPES, GAME_ELEMENTS, getPermissionType, getGameElement, getGameElementsByType, PROCESS_MODEL_VERSION, } from "./process-model.js";
5
5
  import { computeTrustScore, quickRiskAssessment, ARBITRATION_TRUST_VERSION, } from "./arbitration-trust.js";
@@ -105,7 +105,7 @@ import { TOOLS_REFERENCE, getToolReference, searchToolReference, getToolSequence
105
105
  import { SCENARIO_MODES, SCENARIO_MODES_VERSION, MODE_COMPOSITIONS, matchScenarioMode, inferScenarioTraits, getScenarioMode, listScenarioModes, getShippedModes, getModeCompositions, } from "./scenario-modes.js";
106
106
  import { GUARD_DESIGN_PATTERNS, GUARD_DESIGN_PATTERNS_VERSION, VERIFIER_LEVEL_GUIDANCE, getGuardDesignPattern, searchGuardDesignPatterns, getPatternsByHost, getPatternsByIndustry, getPatternsByDataSourceClass, getVerifierLevelGuidance, suggestPatternForRequirement, } from "./guard-design-patterns.js";
107
107
  export { CONCEPT_GLOSSARY, CONCEPT_GLOSSARY_VERSION, resolveTerm, lookupEntry, validateText, auditSchemaFields, };
108
- export { CONFIRMATION_RULES, SAFETY_RULES_VERSION, };
108
+ export { CONFIRMATION_RULES, SAFETY_RULES_VERSION, OBJECT_REUSE_RULES, CREATE_VS_MODIFY_PATTERN, IMMUTABILITY_RULES, OPERATION_TYPE_CLASSIFICATION, OPERATION_CLASS_META, classifyTool, NAMING_CONVENTIONS, checkObjectReuseRules, checkImmutabilityRules, };
109
109
  export { TOOL_CONSTRAINTS, TOOL_CONSTRAINTS_VERSION, validateOperation, hasBlockingViolations, getWarningViolations, };
110
110
  export { PERMISSION_TYPES, GAME_ELEMENTS, getPermissionType, getGameElement, getGameElementsByType, PROCESS_MODEL_VERSION, };
111
111
  export { computeTrustScore, quickRiskAssessment, ARBITRATION_TRUST_VERSION, };
@@ -284,7 +284,7 @@ export function inferSceneFromFlow(description) {
284
284
  if (lower.includes("wonder") || lower.includes("praise") || lower.includes("complain")
285
285
  || lower.includes("thumbs_up") || lower.includes("thumbs_down")
286
286
  || lower.includes("rating") || lower.includes("feedback")
287
- || lower.includes("好评") || lower.includes("差评")) {
287
+ || lower.includes("praise") || lower.includes("complaint")) {
288
288
  return findScene("wonder_feedback");
289
289
  }
290
290
  if (lower.includes("reward") || lower.includes("incentive")) {
@@ -0,0 +1,41 @@
1
+ export interface MachineNodeForRender {
2
+ name: string;
3
+ description?: string | null;
4
+ }
5
+ export interface MachineForwardForRender {
6
+ name: string;
7
+ weight: number;
8
+ named_operator?: string | null;
9
+ permission_index?: number | null;
10
+ guard?: string | null;
11
+ retained_submission?: number[] | string | null;
12
+ }
13
+ export interface MachineEdgeForRender {
14
+ from: string;
15
+ to: string;
16
+ threshold: number;
17
+ forwards: MachineForwardForRender[];
18
+ }
19
+ export interface MachineRenderInput {
20
+ nodes: MachineNodeForRender[];
21
+ edges: MachineEdgeForRender[];
22
+ machineName?: string | null;
23
+ machineAddress?: string | null;
24
+ published?: boolean | null;
25
+ paused?: boolean | null;
26
+ }
27
+ export declare function sanitizeMermaidNodeId(name: string): string;
28
+ export declare function renderMachineMermaid(nodes: MachineNodeForRender[], edges: MachineEdgeForRender[], options?: {
29
+ colored?: boolean;
30
+ }): string;
31
+ export declare function renderMachineTreeIndented(input: MachineRenderInput): string;
32
+ export declare function parseMachineTreeIndented(text: string): {
33
+ success: boolean;
34
+ data?: {
35
+ nodes: MachineNodeForRender[];
36
+ edges: MachineEdgeForRender[];
37
+ };
38
+ errors: string[];
39
+ };
40
+ export declare function renderMachineAscii(input: MachineRenderInput): string;
41
+ export declare function renderMachineMarkmap(input: MachineRenderInput): string;