@wowok/agent-mcp 2.3.16 → 2.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/customer/index.d.ts +9 -0
- package/dist/customer/index.js +9 -0
- package/dist/customer/industry-risks.d.ts +4 -0
- package/dist/customer/industry-risks.js +14 -0
- package/dist/customer/user-preferences.d.ts +3 -0
- package/dist/customer/user-preferences.js +9 -0
- package/dist/experience/realtime-feedback.js +17 -0
- package/dist/index.js +360 -273
- package/dist/knowledge/acquisition-flywheel.d.ts +3 -0
- package/dist/knowledge/acquisition-flywheel.js +9 -0
- package/dist/knowledge/guard-ledger.d.ts +19 -0
- package/dist/knowledge/guard-ledger.js +219 -0
- package/dist/knowledge/guard-puzzle.d.ts +93 -0
- package/dist/knowledge/guard-puzzle.js +278 -0
- package/dist/knowledge/guard-risk.d.ts +60 -0
- package/dist/knowledge/guard-risk.js +474 -0
- package/dist/knowledge/guard-translation.d.ts +46 -0
- package/dist/knowledge/guard-translation.js +487 -0
- package/dist/knowledge/index.d.ts +13 -0
- package/dist/knowledge/index.js +13 -0
- package/dist/knowledge/industry-registry.d.ts +1 -2
- package/dist/knowledge/industry-registry.js +23 -3
- package/dist/knowledge/safety-rules.js +61 -0
- package/dist/knowledge/tool-constraints.js +12 -22
- package/dist/safety/confirm-gate.d.ts +4 -2
- package/dist/safety/confirm-gate.js +48 -4
- package/dist/schema/call/allocation.d.ts +24 -14
- package/dist/schema/call/arbitration.d.ts +142 -132
- package/dist/schema/call/base.d.ts +901 -43
- package/dist/schema/call/base.js +66 -2
- package/dist/schema/call/bridge-handler.js +15 -2
- package/dist/schema/call/bridge.d.ts +769 -1
- package/dist/schema/call/bridge.js +37 -0
- package/dist/schema/call/contact.d.ts +10 -0
- package/dist/schema/call/demand.d.ts +10 -0
- package/dist/schema/call/guard.d.ts +76 -46
- package/dist/schema/call/handler.js +46 -14
- package/dist/schema/call/machine.d.ts +158 -138
- package/dist/schema/call/order.d.ts +10 -0
- package/dist/schema/call/payment.d.ts +10 -0
- package/dist/schema/call/permission.d.ts +232 -222
- package/dist/schema/call/personal.d.ts +10 -0
- package/dist/schema/call/progress.d.ts +10 -0
- package/dist/schema/call/proof.d.ts +20 -0
- package/dist/schema/call/repository.d.ts +32 -22
- package/dist/schema/call/reward.d.ts +10 -0
- package/dist/schema/call/semantic.d.ts +9 -2
- package/dist/schema/call/semantic.js +409 -21
- package/dist/schema/call/service.d.ts +20 -10
- package/dist/schema/call/treasury.d.ts +10 -0
- package/dist/schema/config/index.d.ts +18 -0
- package/dist/schema/config/index.js +17 -0
- package/dist/schema/index.d.ts +6 -0
- package/dist/schema/index.js +5 -0
- package/dist/schema/local/index.d.ts +9 -9
- package/dist/schema/local/index.js +9 -0
- package/dist/schema/messenger/index.d.ts +350 -29
- package/dist/schema/messenger/index.js +17 -17
- package/dist/schema/operations.d.ts +1667 -545
- package/dist/schema/operations.js +91 -96
- package/dist/schema/project/index.d.ts +21 -0
- package/dist/schema/project/index.js +32 -0
- package/dist/schema/query/index.d.ts +1074 -168
- package/dist/schema/query/index.js +8 -8
- package/dist/schema/schema-query/index.d.ts +33 -0
- package/dist/schema/schema-query/index.js +36 -0
- package/dist/schema/schema-version.d.ts +25 -0
- package/dist/schema/schema-version.js +76 -0
- package/dist/schema/trust/index.d.ts +407 -0
- package/dist/schema/trust/index.js +113 -0
- package/dist/schemas/bridge_operation.output.json +224 -0
- package/dist/schemas/bridge_operation.schema.json +67 -8
- package/dist/schemas/config_operation.output.json +18 -0
- package/dist/schemas/config_operation.schema.json +34 -0
- package/dist/schemas/guard-node-schema.json +82 -0
- package/dist/schemas/guard2file.schema.json +8 -0
- package/dist/schemas/index.json +19 -1
- package/dist/schemas/machineNode2file.schema.json +8 -0
- package/dist/schemas/messenger_operation.output.json +224 -0
- package/dist/schemas/onchain_events.output.json +718 -0
- package/dist/schemas/onchain_operations.output.json +277 -2
- package/dist/schemas/onchain_operations.schema.json +19 -16
- package/dist/schemas/onchain_operations_allocation.schema.json +8 -0
- package/dist/schemas/onchain_operations_arbitration.schema.json +8 -0
- package/dist/schemas/onchain_operations_contact.schema.json +8 -0
- package/dist/schemas/onchain_operations_demand.schema.json +8 -0
- package/dist/schemas/onchain_operations_gen_passport.schema.json +16 -0
- package/dist/schemas/onchain_operations_guard.schema.json +11 -16
- package/dist/schemas/onchain_operations_machine.schema.json +8 -0
- package/dist/schemas/onchain_operations_order.schema.json +8 -0
- package/dist/schemas/onchain_operations_payment.schema.json +8 -0
- package/dist/schemas/onchain_operations_permission.schema.json +8 -0
- package/dist/schemas/onchain_operations_personal.schema.json +8 -0
- package/dist/schemas/onchain_operations_progress.schema.json +8 -0
- package/dist/schemas/onchain_operations_repository.schema.json +8 -0
- package/dist/schemas/onchain_operations_reward.schema.json +8 -0
- package/dist/schemas/onchain_operations_service.schema.json +8 -0
- package/dist/schemas/onchain_operations_treasury.schema.json +8 -0
- package/dist/schemas/onchain_table_data.output.json +718 -0
- package/dist/schemas/project_operation.output.json +18 -0
- package/dist/schemas/project_operation.schema.json +42 -0
- package/dist/schemas/query_toolkit.schema.json +360 -368
- package/dist/schemas/schema_query.schema.json +6 -3
- package/dist/schemas/trust_score.output.json +327 -0
- package/dist/schemas/trust_score.schema.json +46 -0
- package/package.json +2 -2
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { auditService } from "../../knowledge/index.js";
|
|
2
2
|
import { getExperienceFeedback, recordOperationOutcome } from "../../experience/index.js";
|
|
3
3
|
import { isEnabled as isRuntimeEnabled, listServices } from "../../config/index.js";
|
|
4
|
-
import { generateReminders } from "../../customer/
|
|
4
|
+
import { generateReminders } from "../../customer/index.js";
|
|
5
5
|
import { getProfile } from "../../experience/user-profile.js";
|
|
6
6
|
import { injectEvolutionContext, recordIndustrySignal } from "../../knowledge/flywheel-loop.js";
|
|
7
|
+
import { WException, getMoveErrorDescription, WErrors } from "@wowok/wowok";
|
|
8
|
+
import { assessGuardRisksForOperation, getRiskSummary } from "../../knowledge/guard-risk.js";
|
|
7
9
|
function booleanFromSignals(positive, negative) {
|
|
8
10
|
if (positive)
|
|
9
11
|
return true;
|
|
@@ -13,78 +15,405 @@ function booleanFromSignals(positive, negative) {
|
|
|
13
15
|
}
|
|
14
16
|
const ERROR_RULES = [
|
|
15
17
|
{
|
|
16
|
-
patterns: [
|
|
18
|
+
patterns: [
|
|
19
|
+
/too\s*many\s*requests/i,
|
|
20
|
+
/rate\s*limit/i,
|
|
21
|
+
/429/i,
|
|
22
|
+
/throttl/i,
|
|
23
|
+
/faucet.*rate/i,
|
|
24
|
+
/request.*limit.*exceeded/i,
|
|
25
|
+
],
|
|
26
|
+
error_code: "rate_limit",
|
|
27
|
+
retryable: true,
|
|
28
|
+
recovery_hint: "Rate limit hit (HTTP 429). Wait with exponential backoff and retry. To check existing balance, use account_balance query.",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
patterns: [
|
|
32
|
+
/gas.*budget.*exceeded/i,
|
|
33
|
+
/out\s*of\s*gas/i,
|
|
34
|
+
/gas\s*exceeded/i,
|
|
35
|
+
/insufficient\s*gas/i,
|
|
36
|
+
/not\s*enough\s*gas/i,
|
|
37
|
+
/could not automatically determine a budget/i,
|
|
38
|
+
/dry run failed.*budget/i,
|
|
39
|
+
/Maximum gas/i,
|
|
40
|
+
],
|
|
41
|
+
error_code: "gas_exceeded",
|
|
42
|
+
retryable: true,
|
|
43
|
+
recovery_hint: "Gas budget exceeded. Increase the gas_budget parameter or claim more gas tokens, then retry",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
patterns: [
|
|
47
|
+
/insufficient\s*(balance|coin|fund)/i,
|
|
48
|
+
/ENOTENOUGH/i,
|
|
49
|
+
/not\s*enough\s*(coin|balance)/i,
|
|
50
|
+
/coin\s*not\s*enough/i,
|
|
51
|
+
/balance\s*not\s*enough/i,
|
|
52
|
+
/stock\s*not\s*enough/i,
|
|
53
|
+
/fee\s*not\s*enough/i,
|
|
54
|
+
/Insufficient balance/i,
|
|
55
|
+
],
|
|
17
56
|
error_code: "insufficient_balance",
|
|
18
57
|
retryable: true,
|
|
19
58
|
recovery_hint: "Claim faucet tokens via account_operation (faucet) then retry the call",
|
|
20
59
|
},
|
|
21
60
|
{
|
|
22
|
-
patterns: [
|
|
61
|
+
patterns: [
|
|
62
|
+
/bcs.*(error|fail|invalid)/i,
|
|
63
|
+
/BCS serialization/i,
|
|
64
|
+
/serialization\s*(failure|error)/i,
|
|
65
|
+
/deserialization\s*(failure|error)/i,
|
|
66
|
+
/invalid bcs type/i,
|
|
67
|
+
/Out of range.*bcs/i,
|
|
68
|
+
/Length out of range/i,
|
|
69
|
+
/parse object content failed/i,
|
|
70
|
+
],
|
|
71
|
+
error_code: "bcs_error",
|
|
72
|
+
retryable: false,
|
|
73
|
+
recovery_hint: "BCS serialization/deserialization error. Verify data types and structure match the expected schema",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
patterns: [
|
|
77
|
+
/signature.*(invalid|fail|error|verif)/i,
|
|
78
|
+
/invalid\s*signature/i,
|
|
79
|
+
/signature\s*verification\s*failed/i,
|
|
80
|
+
/bad\s*signature/i,
|
|
81
|
+
/signing\s*fail/i,
|
|
82
|
+
/crypto.*signature/i,
|
|
83
|
+
/ed25519.*(fail|error|invalid)/i,
|
|
84
|
+
/secp256k1.*(fail|error|invalid)/i,
|
|
85
|
+
],
|
|
86
|
+
error_code: "signature_error",
|
|
87
|
+
retryable: false,
|
|
88
|
+
recovery_hint: "Signature verification failed. Check that the correct private key and network configuration are correct",
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
patterns: [
|
|
92
|
+
/config.*(not set|not found|invalid|missing)/i,
|
|
93
|
+
/RPC\s*not\s*configured/i,
|
|
94
|
+
/network.*not\s*specified/i,
|
|
95
|
+
/protocol network not specified/i,
|
|
96
|
+
/account persistent storage not set/i,
|
|
97
|
+
/config persistent storage not set/i,
|
|
98
|
+
/account persistent storage not found/i,
|
|
99
|
+
/no\s*rpc\s*url/i,
|
|
100
|
+
],
|
|
101
|
+
error_code: "config_error",
|
|
102
|
+
retryable: false,
|
|
103
|
+
recovery_hint: "Configuration error. Verify that network, RPC endpoints, and required environment variables are properly configured",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
patterns: [
|
|
107
|
+
/network/i,
|
|
108
|
+
/timeout/i,
|
|
109
|
+
/ECONNRESET/i,
|
|
110
|
+
/ETIMEDOUT/i,
|
|
111
|
+
/ECONNREFUSED/i,
|
|
112
|
+
/EAI_AGAIN/i,
|
|
113
|
+
/RPC\s*(error|failed|unreachable)/i,
|
|
114
|
+
/socket\s*hang\s*up/i,
|
|
115
|
+
/fetch\s*failed/i,
|
|
116
|
+
/connection\s*(refused|reset|lost)/i,
|
|
117
|
+
/dns\s*(error|fail)/i,
|
|
118
|
+
],
|
|
23
119
|
error_code: "network_error",
|
|
24
120
|
retryable: true,
|
|
25
121
|
recovery_hint: "Retry the call; if it persists, switch RPC endpoint or check connectivity",
|
|
26
122
|
},
|
|
27
123
|
{
|
|
28
|
-
patterns: [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
124
|
+
patterns: [
|
|
125
|
+
/guard.*(reject|fail|denied|verif)/i,
|
|
126
|
+
/verification\s*failed/i,
|
|
127
|
+
/submission.*(invalid|fail|required)/i,
|
|
128
|
+
/passport.*(invalid|fail|verif)/i,
|
|
129
|
+
/move[._-]?abort.*guard/i,
|
|
130
|
+
/Guard count exceeded limit/i,
|
|
131
|
+
/Submission size exceeded limit/i,
|
|
132
|
+
/Submission not found/i,
|
|
133
|
+
/Guard not found/i,
|
|
134
|
+
/Impact guard not found/i,
|
|
135
|
+
],
|
|
35
136
|
error_code: "guard_rejected",
|
|
36
137
|
retryable: false,
|
|
37
138
|
recovery_hint: "Fill the Guard submission data (see the 'submission' field) and resubmit via call_with_submission",
|
|
38
139
|
},
|
|
39
140
|
{
|
|
40
|
-
patterns: [
|
|
141
|
+
patterns: [
|
|
142
|
+
/already\s*publish/i,
|
|
143
|
+
/immutable/i,
|
|
144
|
+
/cannot\s*(modify|change|mutate)/i,
|
|
145
|
+
/locked/i,
|
|
146
|
+
/is\s*published/i,
|
|
147
|
+
/Service already published/i,
|
|
148
|
+
/Machine already published/i,
|
|
149
|
+
/setting lock duration not exceeded/i,
|
|
150
|
+
],
|
|
41
151
|
error_code: "immutable_violation",
|
|
42
152
|
retryable: false,
|
|
43
153
|
recovery_hint: "Object is in an immutable state (e.g. Service already published). Recreate the object if a different config is needed",
|
|
44
154
|
},
|
|
45
155
|
{
|
|
46
|
-
patterns: [
|
|
156
|
+
patterns: [
|
|
157
|
+
/permission/i,
|
|
158
|
+
/unauthorized/i,
|
|
159
|
+
/forbidden/i,
|
|
160
|
+
/not\s*(the\s*)?owner/i,
|
|
161
|
+
/access\s*denied/i,
|
|
162
|
+
/no permission/i,
|
|
163
|
+
/Permission denied/i,
|
|
164
|
+
/Not the builder/i,
|
|
165
|
+
/Not admin/i,
|
|
166
|
+
/No operation permission/i,
|
|
167
|
+
/Not the holder/i,
|
|
168
|
+
],
|
|
47
169
|
error_code: "permission_denied",
|
|
48
170
|
retryable: false,
|
|
49
171
|
recovery_hint: "Use an account with the required permission, or pass permission_guard IDs via env.permission_guard",
|
|
50
172
|
},
|
|
51
173
|
{
|
|
52
|
-
patterns: [
|
|
174
|
+
patterns: [
|
|
175
|
+
/not\s*found/i,
|
|
176
|
+
/does\s*not\s*exist/i,
|
|
177
|
+
/ENOTFOUND/i,
|
|
178
|
+
/no\s*such\s*object/i,
|
|
179
|
+
/unknown\s*object/i,
|
|
180
|
+
/account not found/i,
|
|
181
|
+
/address not found/i,
|
|
182
|
+
/token not found/i,
|
|
183
|
+
/Node not found/i,
|
|
184
|
+
/Policy not found/i,
|
|
185
|
+
/Reward not found/i,
|
|
186
|
+
],
|
|
53
187
|
error_code: "object_not_found",
|
|
54
188
|
retryable: false,
|
|
55
189
|
recovery_hint: "Verify the object ID/name with query_toolkit; local_mark names are case-sensitive",
|
|
56
190
|
},
|
|
57
191
|
{
|
|
58
|
-
patterns: [
|
|
192
|
+
patterns: [
|
|
193
|
+
/state\s*(conflict|mismatch)/i,
|
|
194
|
+
/already\s*exist/i,
|
|
195
|
+
/conflict/i,
|
|
196
|
+
/duplicate/i,
|
|
197
|
+
/version\s*mismatch/i,
|
|
198
|
+
/name exist/i,
|
|
199
|
+
/Duplicate forward name/i,
|
|
200
|
+
/Duplicate node previous/i,
|
|
201
|
+
/already claimed/i,
|
|
202
|
+
/already specified/i,
|
|
203
|
+
/already accomplished/i,
|
|
204
|
+
/already used/i,
|
|
205
|
+
/Status does not match/i,
|
|
206
|
+
/does not match/i,
|
|
207
|
+
],
|
|
59
208
|
error_code: "state_conflict",
|
|
60
209
|
retryable: false,
|
|
61
210
|
recovery_hint: "Object state conflicts with the operation. Query the current state with query_toolkit and adjust parameters",
|
|
62
211
|
},
|
|
63
212
|
{
|
|
64
|
-
patterns: [
|
|
213
|
+
patterns: [
|
|
214
|
+
/invalid/i,
|
|
215
|
+
/missing\s*(field|param|required)/i,
|
|
216
|
+
/required/i,
|
|
217
|
+
/expected/i,
|
|
218
|
+
/malformed/i,
|
|
219
|
+
/parse\s*error/i,
|
|
220
|
+
/type\s*mismatch/i,
|
|
221
|
+
/invalid argument/i,
|
|
222
|
+
/Invalid value/i,
|
|
223
|
+
/Invalid data value/i,
|
|
224
|
+
/Invalid string value/i,
|
|
225
|
+
/Invalid argument/i,
|
|
226
|
+
/IsValid/i,
|
|
227
|
+
/type does not match/i,
|
|
228
|
+
/value type/i,
|
|
229
|
+
],
|
|
65
230
|
error_code: "invalid_parameter",
|
|
66
231
|
retryable: false,
|
|
67
232
|
recovery_hint: "Check parameter format against the tool schema; consult wowok-tools Skill for the operation's requirements",
|
|
68
233
|
},
|
|
69
234
|
];
|
|
70
|
-
|
|
235
|
+
const WERROR_MAPPINGS = [
|
|
236
|
+
{
|
|
237
|
+
codes: [WErrors.AccountNotFound, WErrors.AddressNotFound, WErrors.TokenNotFoundLocally],
|
|
238
|
+
error_code: "object_not_found",
|
|
239
|
+
retryable: false,
|
|
240
|
+
recovery_hint: "Verify the object ID/name with query_toolkit; local_mark names are case-sensitive",
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
codes: [WErrors.NoPermission],
|
|
244
|
+
error_code: "permission_denied",
|
|
245
|
+
retryable: false,
|
|
246
|
+
recovery_hint: "Use an account with the required permission, or pass permission_guard IDs via env.permission_guard",
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
codes: [
|
|
250
|
+
WErrors.IsValidDescription,
|
|
251
|
+
WErrors.IsValidName,
|
|
252
|
+
WErrors.IsValidName_AllowEmpty,
|
|
253
|
+
WErrors.IsValidEndpoint,
|
|
254
|
+
WErrors.IsValidAddress,
|
|
255
|
+
WErrors.IsValidArgType,
|
|
256
|
+
WErrors.IsValidTokenType,
|
|
257
|
+
WErrors.IsValidUint,
|
|
258
|
+
WErrors.IsValidInt,
|
|
259
|
+
WErrors.IsValidU8,
|
|
260
|
+
WErrors.IsValidU16,
|
|
261
|
+
WErrors.IsValidU32,
|
|
262
|
+
WErrors.IsValidU64,
|
|
263
|
+
WErrors.IsValidU128,
|
|
264
|
+
WErrors.IsValidU256,
|
|
265
|
+
WErrors.IsValidRate,
|
|
266
|
+
WErrors.IsValidArray,
|
|
267
|
+
WErrors.IsValidObjects,
|
|
268
|
+
WErrors.AllInvalid,
|
|
269
|
+
WErrors.InvalidParam,
|
|
270
|
+
WErrors.IsValidPermissionIndex,
|
|
271
|
+
WErrors.IsValidKey,
|
|
272
|
+
WErrors.IsValidIdentifier,
|
|
273
|
+
WErrors.IsValidHttpUrl,
|
|
274
|
+
WErrors.IsValidBizPermissionIndex,
|
|
275
|
+
WErrors.IsValidServiceItemName,
|
|
276
|
+
WErrors.IsValidCoinType,
|
|
277
|
+
WErrors.IsValidGuardIdentifier,
|
|
278
|
+
WErrors.IsValidValue,
|
|
279
|
+
WErrors.IsValidValueType,
|
|
280
|
+
WErrors.IsValidLocation,
|
|
281
|
+
WErrors.WitnessTypeInvalid,
|
|
282
|
+
],
|
|
283
|
+
error_code: "invalid_parameter",
|
|
284
|
+
retryable: false,
|
|
285
|
+
recovery_hint: "Check parameter format against the tool schema; consult wowok-tools Skill for the operation's requirements",
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
codes: [WErrors.BcsTypeInvalid, WErrors.ParseObjectContentFailed],
|
|
289
|
+
error_code: "bcs_error",
|
|
290
|
+
retryable: false,
|
|
291
|
+
recovery_hint: "BCS serialization/deserialization error. Verify data types and structure match the expected schema",
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
codes: [WErrors.NetworkInvalid],
|
|
295
|
+
error_code: "config_error",
|
|
296
|
+
retryable: false,
|
|
297
|
+
recovery_hint: "Configuration error. Verify that network, RPC endpoints, and required environment variables are properly configured",
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
codes: [
|
|
301
|
+
WErrors.AccountPersistentStorageNotSet,
|
|
302
|
+
WErrors.ConfigPersistentStorageNotSet,
|
|
303
|
+
WErrors.AccountPersistentStorageNotFound,
|
|
304
|
+
],
|
|
305
|
+
error_code: "config_error",
|
|
306
|
+
retryable: false,
|
|
307
|
+
recovery_hint: "Persistent storage not configured. Initialize account storage before performing this operation",
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
codes: [WErrors.AccountNameExist, WErrors.LocalMarkNameExist],
|
|
311
|
+
error_code: "state_conflict",
|
|
312
|
+
retryable: false,
|
|
313
|
+
recovery_hint: "Object state conflicts with the operation. Query the current state with query_toolkit and adjust parameters",
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
codes: [WErrors.MaxObjectsPerQuery, WErrors.ResourceTagCountExceeded, WErrors.AddressCountExceeded, WErrors.NumberCountExceeded],
|
|
317
|
+
error_code: "invalid_parameter",
|
|
318
|
+
retryable: false,
|
|
319
|
+
recovery_hint: "Count limit exceeded. Reduce the number of items per request and retry",
|
|
320
|
+
},
|
|
321
|
+
];
|
|
322
|
+
function isWException(value) {
|
|
323
|
+
return value instanceof WException;
|
|
324
|
+
}
|
|
325
|
+
function classifyWException(exception) {
|
|
326
|
+
const code = exception.getErrorCode();
|
|
327
|
+
const mapping = WERROR_MAPPINGS.find((m) => m.codes.includes(code));
|
|
328
|
+
if (!mapping)
|
|
329
|
+
return undefined;
|
|
330
|
+
const result = {
|
|
331
|
+
error_code: mapping.error_code,
|
|
332
|
+
retryable: mapping.retryable,
|
|
333
|
+
recovery_hint: mapping.recovery_hint,
|
|
334
|
+
};
|
|
335
|
+
return result;
|
|
336
|
+
}
|
|
337
|
+
const WOWOK_ADDRESSES = new Set([
|
|
338
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
339
|
+
"0x2",
|
|
340
|
+
]);
|
|
341
|
+
function extractMoveAbortInfo(errorMsg) {
|
|
342
|
+
if (!errorMsg)
|
|
343
|
+
return undefined;
|
|
344
|
+
const abortCodeMatch = errorMsg.match(/MoveAbort\([^,]+,\s*(\d+)\)/);
|
|
345
|
+
const moduleNameMatch = errorMsg.match(/name:\s*Identifier\("([^"]+)"\)/);
|
|
346
|
+
const addressMatch = errorMsg.match(/address:\s*([0-9a-fA-Fx]+)/);
|
|
347
|
+
if (abortCodeMatch && moduleNameMatch && addressMatch) {
|
|
348
|
+
const code = parseInt(abortCodeMatch[1], 10);
|
|
349
|
+
const module = moduleNameMatch[1].toLowerCase();
|
|
350
|
+
const address = addressMatch[1].toLowerCase();
|
|
351
|
+
if (WOWOK_ADDRESSES.has(address)) {
|
|
352
|
+
const description = getMoveErrorDescription(module, code) ?? undefined;
|
|
353
|
+
return { module, code, description };
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
const formattedAbortCode = errorMsg.match(/abort code:\s*(\d+)/);
|
|
357
|
+
const formattedModule = errorMsg.match(/'0x[0-9a-fA-F]+::([^:]+)::[^']+'/);
|
|
358
|
+
const formattedAddress = errorMsg.match(/'(0x[0-9a-fA-F]+)::/);
|
|
359
|
+
if (formattedAbortCode && formattedModule && formattedAddress) {
|
|
360
|
+
const code = parseInt(formattedAbortCode[1], 10);
|
|
361
|
+
const module = formattedModule[1].toLowerCase();
|
|
362
|
+
const address = formattedAddress[1].toLowerCase();
|
|
363
|
+
if (WOWOK_ADDRESSES.has(address)) {
|
|
364
|
+
const description = getMoveErrorDescription(module, code) ?? undefined;
|
|
365
|
+
return { module, code, description };
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return undefined;
|
|
369
|
+
}
|
|
370
|
+
export function classifyError(errorMsg, error) {
|
|
371
|
+
if (error !== undefined && isWException(error)) {
|
|
372
|
+
const fromWException = classifyWException(error);
|
|
373
|
+
if (fromWException) {
|
|
374
|
+
const abortInfo = extractMoveAbortInfo(errorMsg);
|
|
375
|
+
if (abortInfo) {
|
|
376
|
+
fromWException.move_abort_info = abortInfo;
|
|
377
|
+
if (abortInfo.description && fromWException.recovery_hint && !fromWException.recovery_hint.includes(abortInfo.description)) {
|
|
378
|
+
fromWException.recovery_hint = `${fromWException.recovery_hint}. Details: ${abortInfo.description}`;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return fromWException;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
71
384
|
if (!errorMsg) {
|
|
72
385
|
return { error_code: "unknown", retryable: false };
|
|
73
386
|
}
|
|
74
387
|
for (const rule of ERROR_RULES) {
|
|
75
388
|
if (rule.patterns.some((p) => p.test(errorMsg))) {
|
|
76
|
-
|
|
389
|
+
const result = {
|
|
77
390
|
error_code: rule.error_code,
|
|
78
391
|
retryable: rule.retryable,
|
|
79
392
|
recovery_hint: rule.recovery_hint,
|
|
80
393
|
};
|
|
394
|
+
const abortInfo = extractMoveAbortInfo(errorMsg);
|
|
395
|
+
if (abortInfo) {
|
|
396
|
+
result.move_abort_info = abortInfo;
|
|
397
|
+
if (abortInfo.description) {
|
|
398
|
+
result.recovery_hint = `${result.recovery_hint}. Details: ${abortInfo.description}`;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return result;
|
|
81
402
|
}
|
|
82
403
|
}
|
|
83
|
-
|
|
404
|
+
const abortInfo = extractMoveAbortInfo(errorMsg);
|
|
405
|
+
const fallback = {
|
|
84
406
|
error_code: "unknown",
|
|
85
407
|
retryable: false,
|
|
86
408
|
recovery_hint: "Inspect the full error message; consult wowok-tools Skill for the operation's requirements",
|
|
87
409
|
};
|
|
410
|
+
if (abortInfo) {
|
|
411
|
+
fallback.move_abort_info = abortInfo;
|
|
412
|
+
if (abortInfo.description) {
|
|
413
|
+
fallback.recovery_hint = `${abortInfo.description}. ${fallback.recovery_hint}`;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return fallback;
|
|
88
417
|
}
|
|
89
418
|
const INTENT_RULES = [
|
|
90
419
|
{ operation_type: "service", signals: (d) => d?.publish === true, intent: "publish_service", confidence: 0.95 },
|
|
@@ -795,6 +1124,56 @@ function buildCustomerAdvice(operation_type, data, safeResult) {
|
|
|
795
1124
|
advice.risk_level = riskLevel;
|
|
796
1125
|
return advice;
|
|
797
1126
|
}
|
|
1127
|
+
function buildGuardAdvice(operation_type, data, safeResult) {
|
|
1128
|
+
try {
|
|
1129
|
+
if (operation_type === "guard") {
|
|
1130
|
+
const assessment = assessGuardRisksForOperation(operation_type, data);
|
|
1131
|
+
if (assessment) {
|
|
1132
|
+
const summary = getRiskSummary(assessment);
|
|
1133
|
+
const riskWarnings = assessment.risks.map((r) => `[${r.level.toUpperCase()}] ${r.title}: ${r.description}`);
|
|
1134
|
+
return {
|
|
1135
|
+
current_round: "R7",
|
|
1136
|
+
risk_assessment: {
|
|
1137
|
+
overall_risk: summary.risk_count > 0 ? assessment.overall_risk : "info",
|
|
1138
|
+
risk_count: summary.risk_count,
|
|
1139
|
+
critical_count: summary.critical_count,
|
|
1140
|
+
high_count: summary.high_count,
|
|
1141
|
+
needs_human_review: summary.needs_human_review,
|
|
1142
|
+
top_risks: summary.top_risks,
|
|
1143
|
+
stakeholder_advice: assessment.stakeholder_advice,
|
|
1144
|
+
},
|
|
1145
|
+
risk_warnings: riskWarnings.length > 0 ? riskWarnings : undefined,
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
if (operation_type === "gen_passport") {
|
|
1150
|
+
const status = safeResult?.error ? "fail" : "pass";
|
|
1151
|
+
return {
|
|
1152
|
+
current_round: "R8",
|
|
1153
|
+
test_result: {
|
|
1154
|
+
status: status,
|
|
1155
|
+
passport_id: status === "pass" ? safeResult?.passport : undefined,
|
|
1156
|
+
failure_node: status === "fail"
|
|
1157
|
+
? (typeof safeResult?.error === "string" ? safeResult.error.slice(0, 120) : undefined)
|
|
1158
|
+
: undefined,
|
|
1159
|
+
},
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1162
|
+
const errorStr = typeof safeResult?.error === "string" ? safeResult.error : "";
|
|
1163
|
+
if (errorStr.includes("GUARD") || errorStr.includes("Guard") || errorStr.includes("guard")) {
|
|
1164
|
+
return {
|
|
1165
|
+
risk_warnings: [
|
|
1166
|
+
`Guard 验证失败: ${errorStr.slice(0, 200)}`,
|
|
1167
|
+
"建议: 检查提交数据是否符合 Guard table 声明,或查询 Guard 定义了解所需 submission",
|
|
1168
|
+
],
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
return undefined;
|
|
1172
|
+
}
|
|
1173
|
+
catch {
|
|
1174
|
+
return undefined;
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
798
1177
|
export function buildSemantic(safeResult, context) {
|
|
799
1178
|
if (!context)
|
|
800
1179
|
return undefined;
|
|
@@ -820,7 +1199,8 @@ export function buildSemantic(safeResult, context) {
|
|
|
820
1199
|
}
|
|
821
1200
|
}
|
|
822
1201
|
let experience;
|
|
823
|
-
|
|
1202
|
+
const experienceLayerEnabled = isRuntimeEnabled("experience_layer");
|
|
1203
|
+
if (experienceLayerEnabled) {
|
|
824
1204
|
try {
|
|
825
1205
|
const feedback = getExperienceFeedback(context.operation_type, context.data, intent);
|
|
826
1206
|
if (feedback) {
|
|
@@ -828,7 +1208,8 @@ export function buildSemantic(safeResult, context) {
|
|
|
828
1208
|
}
|
|
829
1209
|
const outcome = status === "success" ? "success" : status === "failed" ? "failed" : "partial";
|
|
830
1210
|
const referencedObjects = [...created, ...modified].map((o) => o.id).filter(Boolean);
|
|
831
|
-
|
|
1211
|
+
const errCode = inferErrorCodeForSignal(safeResult);
|
|
1212
|
+
recordOperationOutcome(context.operation_type, context.data, intent, outcome, errCode, referencedObjects);
|
|
832
1213
|
}
|
|
833
1214
|
catch {
|
|
834
1215
|
}
|
|
@@ -839,7 +1220,7 @@ export function buildSemantic(safeResult, context) {
|
|
|
839
1220
|
const industryHint = (typeof context.data?.industry === "string" && context.data.industry.trim())
|
|
840
1221
|
? context.data.industry.trim()
|
|
841
1222
|
: undefined;
|
|
842
|
-
if (industryHint) {
|
|
1223
|
+
if (industryHint && !experienceLayerEnabled) {
|
|
843
1224
|
const outcome = status === "success"
|
|
844
1225
|
? { success: true }
|
|
845
1226
|
: { success: false, error_code: inferErrorCodeForSignal(safeResult) };
|
|
@@ -875,6 +1256,12 @@ export function buildSemantic(safeResult, context) {
|
|
|
875
1256
|
}
|
|
876
1257
|
catch {
|
|
877
1258
|
}
|
|
1259
|
+
let guard_advice;
|
|
1260
|
+
try {
|
|
1261
|
+
guard_advice = buildGuardAdvice(context.operation_type, context.data, safeResult);
|
|
1262
|
+
}
|
|
1263
|
+
catch {
|
|
1264
|
+
}
|
|
878
1265
|
return {
|
|
879
1266
|
intent,
|
|
880
1267
|
status,
|
|
@@ -889,6 +1276,7 @@ export function buildSemantic(safeResult, context) {
|
|
|
889
1276
|
service_status,
|
|
890
1277
|
customer_advice,
|
|
891
1278
|
evolution_context,
|
|
1279
|
+
guard_advice,
|
|
892
1280
|
};
|
|
893
1281
|
}
|
|
894
1282
|
function inferErrorCodeForSignal(safeResult) {
|