@wowok/agent-mcp 2.3.14 → 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/config/index.d.ts +1 -0
- package/dist/config/index.js +1 -0
- package/dist/config/runtime.d.ts +26 -0
- package/dist/config/runtime.js +217 -0
- package/dist/customer/index.d.ts +9 -0
- package/dist/customer/index.js +9 -0
- package/dist/customer/industry-risks.d.ts +40 -0
- package/dist/customer/industry-risks.js +438 -0
- package/dist/customer/info-puzzle.d.ts +102 -0
- package/dist/customer/info-puzzle.js +312 -0
- package/dist/customer/order-monitor.d.ts +75 -0
- package/dist/customer/order-monitor.js +327 -0
- package/dist/customer/order-strategy.d.ts +36 -0
- package/dist/customer/order-strategy.js +373 -0
- package/dist/customer/post-purchase.d.ts +42 -0
- package/dist/customer/post-purchase.js +350 -0
- package/dist/customer/reminder-system.d.ts +42 -0
- package/dist/customer/reminder-system.js +295 -0
- package/dist/customer/risk-assessment.d.ts +8 -0
- package/dist/customer/risk-assessment.js +337 -0
- package/dist/customer/types.d.ts +193 -0
- package/dist/customer/types.js +13 -0
- package/dist/customer/user-preferences.d.ts +70 -0
- package/dist/customer/user-preferences.js +460 -0
- package/dist/experience/experience-reuse.d.ts +10 -0
- package/dist/experience/experience-reuse.js +103 -0
- package/dist/experience/index.d.ts +6 -0
- package/dist/experience/index.js +5 -0
- package/dist/experience/intent-distill.d.ts +3 -0
- package/dist/experience/intent-distill.js +83 -0
- package/dist/experience/realtime-feedback.d.ts +5 -0
- package/dist/experience/realtime-feedback.js +94 -0
- package/dist/experience/types.d.ts +50 -0
- package/dist/experience/types.js +1 -0
- package/dist/experience/user-profile.d.ts +25 -0
- package/dist/experience/user-profile.js +171 -0
- package/dist/index.js +842 -371
- package/dist/knowledge/acquisition-flywheel.d.ts +53 -0
- package/dist/knowledge/acquisition-flywheel.js +192 -0
- package/dist/knowledge/arbitration-trust.d.ts +24 -0
- package/dist/knowledge/arbitration-trust.js +117 -0
- package/dist/knowledge/audit-rules.d.ts +28 -0
- package/dist/knowledge/audit-rules.js +141 -0
- package/dist/knowledge/demand-matching.d.ts +29 -0
- package/dist/knowledge/demand-matching.js +132 -0
- package/dist/knowledge/dynamic-pricing.d.ts +31 -0
- package/dist/knowledge/dynamic-pricing.js +87 -0
- package/dist/knowledge/flywheel-loop.d.ts +87 -0
- package/dist/knowledge/flywheel-loop.js +378 -0
- package/dist/knowledge/glossary.d.ts +18 -0
- package/dist/knowledge/glossary.js +209 -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 +77 -0
- package/dist/knowledge/index.js +79 -0
- package/dist/knowledge/industry-evolution.d.ts +82 -0
- package/dist/knowledge/industry-evolution.js +323 -0
- package/dist/knowledge/industry-generalizer.d.ts +17 -0
- package/dist/knowledge/industry-generalizer.js +381 -0
- package/dist/knowledge/industry-registry.d.ts +48 -0
- package/dist/knowledge/industry-registry.js +187 -0
- package/dist/knowledge/intent-metrics.d.ts +42 -0
- package/dist/knowledge/intent-metrics.js +566 -0
- package/dist/knowledge/process-model.d.ts +24 -0
- package/dist/knowledge/process-model.js +160 -0
- package/dist/knowledge/reputation-rules.d.ts +42 -0
- package/dist/knowledge/reputation-rules.js +99 -0
- package/dist/knowledge/reward-templates.d.ts +25 -0
- package/dist/knowledge/reward-templates.js +125 -0
- package/dist/knowledge/safety-rules.d.ts +36 -0
- package/dist/knowledge/safety-rules.js +232 -0
- package/dist/knowledge/tool-constraints.d.ts +30 -0
- package/dist/knowledge/tool-constraints.js +175 -0
- package/dist/knowledge/trust-metrics.d.ts +37 -0
- package/dist/knowledge/trust-metrics.js +138 -0
- package/dist/loop-engineering/diagnose.d.ts +3 -2
- package/dist/loop-engineering/diagnose.js +94 -0
- package/dist/loop-engineering/improve.d.ts +1 -1
- package/dist/loop-engineering/improve.js +52 -1
- package/dist/project/graph.d.ts +71 -0
- package/dist/project/graph.js +314 -0
- package/dist/project/index.d.ts +62 -0
- package/dist/project/index.js +167 -0
- package/dist/project/namespace.d.ts +62 -0
- package/dist/project/namespace.js +181 -0
- package/dist/project/query.d.ts +40 -0
- package/dist/project/query.js +110 -0
- package/dist/safety/confirm-gate.d.ts +17 -0
- package/dist/safety/confirm-gate.js +88 -0
- package/dist/safety/index.d.ts +3 -0
- package/dist/safety/index.js +3 -0
- package/dist/safety/preview.d.ts +2 -0
- package/dist/safety/preview.js +36 -0
- package/dist/schema/call/allocation.d.ts +39 -14
- package/dist/schema/call/arbitration.d.ts +187 -162
- package/dist/schema/call/base.d.ts +1971 -87
- package/dist/schema/call/base.js +135 -3
- package/dist/schema/call/bridge-handler.js +15 -2
- package/dist/schema/call/bridge.d.ts +1478 -53
- package/dist/schema/call/bridge.js +50 -2
- package/dist/schema/call/contact.d.ts +25 -0
- package/dist/schema/call/demand.d.ts +79 -54
- package/dist/schema/call/guard.d.ts +125 -50
- package/dist/schema/call/handler.d.ts +3 -0
- package/dist/schema/call/handler.js +60 -14
- package/dist/schema/call/machine.d.ts +988 -938
- package/dist/schema/call/order.d.ts +25 -0
- package/dist/schema/call/payment.d.ts +25 -0
- package/dist/schema/call/permission.d.ts +244 -219
- package/dist/schema/call/personal.d.ts +25 -0
- package/dist/schema/call/progress.d.ts +25 -0
- package/dist/schema/call/proof.d.ts +62 -12
- package/dist/schema/call/proof.js +3 -3
- package/dist/schema/call/repository.d.ts +101 -76
- package/dist/schema/call/reward.d.ts +55 -30
- package/dist/schema/call/semantic.d.ts +10 -2
- package/dist/schema/call/semantic.js +616 -11
- package/dist/schema/call/service.d.ts +442 -417
- package/dist/schema/call/treasury.d.ts +25 -0
- package/dist/schema/common/index.js +3 -3
- 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 +237 -81
- package/dist/schema/local/index.js +42 -6
- package/dist/schema/messenger/index.d.ts +1018 -79
- package/dist/schema/messenger/index.js +26 -17
- package/dist/schema/operations.d.ts +3192 -1746
- package/dist/schema/operations.js +93 -98
- package/dist/schema/project/index.d.ts +21 -0
- package/dist/schema/project/index.js +32 -0
- package/dist/schema/query/index.d.ts +2762 -1856
- package/dist/schema/query/index.js +38 -35
- 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/account_operation.output.json +25 -16
- package/dist/schemas/account_operation.schema.json +1 -1
- package/dist/schemas/bridge_operation.output.json +744 -0
- package/dist/schemas/bridge_operation.schema.json +82 -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 +23 -0
- package/dist/schemas/index.json +19 -1
- package/dist/schemas/local_info_operation.output.json +23 -0
- package/dist/schemas/local_info_operation.schema.json +1 -1
- package/dist/schemas/local_mark_operation.output.json +24 -1
- package/dist/schemas/local_mark_operation.schema.json +4 -4
- package/dist/schemas/machineNode2file.schema.json +23 -0
- package/dist/schemas/messenger_operation.output.json +752 -0
- package/dist/schemas/onchain_events.output.json +718 -0
- package/dist/schemas/onchain_operations.output.json +627 -18
- package/dist/schemas/onchain_operations.schema.json +115 -39
- package/dist/schemas/onchain_operations_allocation.schema.json +23 -0
- package/dist/schemas/onchain_operations_arbitration.schema.json +23 -0
- package/dist/schemas/onchain_operations_contact.schema.json +23 -0
- package/dist/schemas/onchain_operations_demand.schema.json +23 -0
- package/dist/schemas/onchain_operations_gen_passport.schema.json +46 -0
- package/dist/schemas/onchain_operations_guard.schema.json +26 -16
- package/dist/schemas/onchain_operations_machine.schema.json +89 -23
- package/dist/schemas/onchain_operations_order.schema.json +23 -0
- package/dist/schemas/onchain_operations_payment.schema.json +23 -0
- package/dist/schemas/onchain_operations_permission.schema.json +23 -0
- package/dist/schemas/onchain_operations_personal.schema.json +23 -0
- package/dist/schemas/onchain_operations_progress.schema.json +23 -0
- package/dist/schemas/onchain_operations_repository.schema.json +23 -0
- package/dist/schemas/onchain_operations_reward.schema.json +23 -0
- package/dist/schemas/onchain_operations_service.schema.json +23 -0
- package/dist/schemas/onchain_operations_treasury.schema.json +23 -0
- package/dist/schemas/onchain_table_data.output.json +939 -69
- package/dist/schemas/onchain_table_data.schema.json +2 -2
- 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,71 +1,419 @@
|
|
|
1
|
+
import { auditService } from "../../knowledge/index.js";
|
|
2
|
+
import { getExperienceFeedback, recordOperationOutcome } from "../../experience/index.js";
|
|
3
|
+
import { isEnabled as isRuntimeEnabled, listServices } from "../../config/index.js";
|
|
4
|
+
import { generateReminders } from "../../customer/index.js";
|
|
5
|
+
import { getProfile } from "../../experience/user-profile.js";
|
|
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";
|
|
9
|
+
function booleanFromSignals(positive, negative) {
|
|
10
|
+
if (positive)
|
|
11
|
+
return true;
|
|
12
|
+
if (negative)
|
|
13
|
+
return false;
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
1
16
|
const ERROR_RULES = [
|
|
2
17
|
{
|
|
3
|
-
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
|
+
],
|
|
4
56
|
error_code: "insufficient_balance",
|
|
5
57
|
retryable: true,
|
|
6
58
|
recovery_hint: "Claim faucet tokens via account_operation (faucet) then retry the call",
|
|
7
59
|
},
|
|
8
60
|
{
|
|
9
|
-
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
|
+
],
|
|
10
119
|
error_code: "network_error",
|
|
11
120
|
retryable: true,
|
|
12
121
|
recovery_hint: "Retry the call; if it persists, switch RPC endpoint or check connectivity",
|
|
13
122
|
},
|
|
14
123
|
{
|
|
15
|
-
patterns: [
|
|
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
|
+
],
|
|
16
136
|
error_code: "guard_rejected",
|
|
17
137
|
retryable: false,
|
|
18
138
|
recovery_hint: "Fill the Guard submission data (see the 'submission' field) and resubmit via call_with_submission",
|
|
19
139
|
},
|
|
20
140
|
{
|
|
21
|
-
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
|
+
],
|
|
22
151
|
error_code: "immutable_violation",
|
|
23
152
|
retryable: false,
|
|
24
153
|
recovery_hint: "Object is in an immutable state (e.g. Service already published). Recreate the object if a different config is needed",
|
|
25
154
|
},
|
|
26
155
|
{
|
|
27
|
-
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
|
+
],
|
|
28
169
|
error_code: "permission_denied",
|
|
29
170
|
retryable: false,
|
|
30
171
|
recovery_hint: "Use an account with the required permission, or pass permission_guard IDs via env.permission_guard",
|
|
31
172
|
},
|
|
32
173
|
{
|
|
33
|
-
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
|
+
],
|
|
34
187
|
error_code: "object_not_found",
|
|
35
188
|
retryable: false,
|
|
36
189
|
recovery_hint: "Verify the object ID/name with query_toolkit; local_mark names are case-sensitive",
|
|
37
190
|
},
|
|
38
191
|
{
|
|
39
|
-
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
|
+
],
|
|
40
208
|
error_code: "state_conflict",
|
|
41
209
|
retryable: false,
|
|
42
210
|
recovery_hint: "Object state conflicts with the operation. Query the current state with query_toolkit and adjust parameters",
|
|
43
211
|
},
|
|
44
212
|
{
|
|
45
|
-
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
|
+
],
|
|
46
230
|
error_code: "invalid_parameter",
|
|
47
231
|
retryable: false,
|
|
48
232
|
recovery_hint: "Check parameter format against the tool schema; consult wowok-tools Skill for the operation's requirements",
|
|
49
233
|
},
|
|
50
234
|
];
|
|
51
|
-
|
|
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
|
+
}
|
|
52
384
|
if (!errorMsg) {
|
|
53
385
|
return { error_code: "unknown", retryable: false };
|
|
54
386
|
}
|
|
55
387
|
for (const rule of ERROR_RULES) {
|
|
56
388
|
if (rule.patterns.some((p) => p.test(errorMsg))) {
|
|
57
|
-
|
|
389
|
+
const result = {
|
|
58
390
|
error_code: rule.error_code,
|
|
59
391
|
retryable: rule.retryable,
|
|
60
392
|
recovery_hint: rule.recovery_hint,
|
|
61
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;
|
|
62
402
|
}
|
|
63
403
|
}
|
|
64
|
-
|
|
404
|
+
const abortInfo = extractMoveAbortInfo(errorMsg);
|
|
405
|
+
const fallback = {
|
|
65
406
|
error_code: "unknown",
|
|
66
407
|
retryable: false,
|
|
67
408
|
recovery_hint: "Inspect the full error message; consult wowok-tools Skill for the operation's requirements",
|
|
68
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;
|
|
69
417
|
}
|
|
70
418
|
const INTENT_RULES = [
|
|
71
419
|
{ operation_type: "service", signals: (d) => d?.publish === true, intent: "publish_service", confidence: 0.95 },
|
|
@@ -553,6 +901,13 @@ const NEXT_ACTION_RULES = [
|
|
|
553
901
|
reason: "Order lifecycle: payment → allocation → completion",
|
|
554
902
|
priority: "optional",
|
|
555
903
|
},
|
|
904
|
+
{
|
|
905
|
+
when: (ot, data) => ot === "order" && data?.transfer_to !== undefined,
|
|
906
|
+
action: "inform the end customer about the supplier/sub-contractor who will fulfill this order",
|
|
907
|
+
reason: "O-5 procurement sub-order transparency: customers have the right to know who fulfills their order",
|
|
908
|
+
tool: "messenger_operation (notify customer)",
|
|
909
|
+
priority: "recommended",
|
|
910
|
+
},
|
|
556
911
|
{
|
|
557
912
|
when: (ot) => ot === "demand",
|
|
558
913
|
action: "wait for presenter submissions or evaluate existing ones",
|
|
@@ -633,6 +988,10 @@ function inferWarnings(operation_type, data, _safeResult) {
|
|
|
633
988
|
if (operation_type === "reward" && (data?.balance === "0" || data?.balance === 0)) {
|
|
634
989
|
warnings.push("Reward pool balance is zero; claimants cannot withdraw");
|
|
635
990
|
}
|
|
991
|
+
if (operation_type === "order" && data?.transfer_to !== undefined) {
|
|
992
|
+
warnings.push("[TRANSPARENCY] Order ownership is being transferred (likely to a supplier/sub-contractor). " +
|
|
993
|
+
"Ensure the end customer is informed about who fulfills their order — this builds trust and is required for procurement sub-orders.");
|
|
994
|
+
}
|
|
636
995
|
return warnings;
|
|
637
996
|
}
|
|
638
997
|
function composeSummary(intent, status, created, modified, released) {
|
|
@@ -679,6 +1038,142 @@ function shortCoinType(coinType) {
|
|
|
679
1038
|
const parts = coinType.split("::");
|
|
680
1039
|
return parts[parts.length - 1] || coinType;
|
|
681
1040
|
}
|
|
1041
|
+
function buildCustomerAdvice(operation_type, data, safeResult) {
|
|
1042
|
+
if (!isRuntimeEnabled("customer_intelligence"))
|
|
1043
|
+
return undefined;
|
|
1044
|
+
let stage;
|
|
1045
|
+
if (operation_type === "order") {
|
|
1046
|
+
stage = "preorder";
|
|
1047
|
+
}
|
|
1048
|
+
else if (operation_type === "query_toolkit" || operation_type === "onchain_table_data" || operation_type === "onchain_events") {
|
|
1049
|
+
stage = "browse";
|
|
1050
|
+
}
|
|
1051
|
+
else if (operation_type === "service") {
|
|
1052
|
+
stage = "evaluate";
|
|
1053
|
+
}
|
|
1054
|
+
else {
|
|
1055
|
+
return undefined;
|
|
1056
|
+
}
|
|
1057
|
+
const serviceId = data?.service_name ?? data?.service_id ?? data?.service ?? data?.name;
|
|
1058
|
+
const orderId = data?.order_name ?? data?.order_id ?? data?.order;
|
|
1059
|
+
let servicePrice;
|
|
1060
|
+
if (data?.price !== undefined) {
|
|
1061
|
+
try {
|
|
1062
|
+
servicePrice = BigInt(String(data.price));
|
|
1063
|
+
}
|
|
1064
|
+
catch { }
|
|
1065
|
+
}
|
|
1066
|
+
if (servicePrice === undefined && safeResult?.price !== undefined) {
|
|
1067
|
+
try {
|
|
1068
|
+
servicePrice = BigInt(String(safeResult.price));
|
|
1069
|
+
}
|
|
1070
|
+
catch { }
|
|
1071
|
+
}
|
|
1072
|
+
const hasArbitration = booleanFromSignals(data?.arb_name !== undefined || data?.arbitration !== undefined, data?.arb === false);
|
|
1073
|
+
const hasCompensation = booleanFromSignals(data?.compensation_fund !== undefined || data?.compensation !== undefined, false);
|
|
1074
|
+
const hasRefundPath = booleanFromSignals(data?.refund !== undefined, false);
|
|
1075
|
+
const hasMessenger = booleanFromSignals(data?.um_name !== undefined || data?.messenger !== undefined, false);
|
|
1076
|
+
const noArbitration = hasArbitration === false;
|
|
1077
|
+
const noCompensation = hasCompensation === false;
|
|
1078
|
+
const riskScore = typeof data?.risk_score === "number" ? data.risk_score
|
|
1079
|
+
: typeof safeResult?.risk_score === "number" ? safeResult.risk_score : undefined;
|
|
1080
|
+
const riskLevel = data?.risk_level ?? safeResult?.risk_level;
|
|
1081
|
+
const profile = getProfile();
|
|
1082
|
+
const userMinTrust = profile.risk_appetite === "conservative" ? 70
|
|
1083
|
+
: profile.risk_appetite === "aggressive" ? 30 : 50;
|
|
1084
|
+
const ctx = {
|
|
1085
|
+
stage,
|
|
1086
|
+
service_id: serviceId,
|
|
1087
|
+
order_id: orderId,
|
|
1088
|
+
service_price: servicePrice,
|
|
1089
|
+
has_arbitration: hasArbitration,
|
|
1090
|
+
has_compensation: hasCompensation,
|
|
1091
|
+
has_refund_path: hasRefundPath,
|
|
1092
|
+
has_messenger: hasMessenger,
|
|
1093
|
+
risk_score: riskScore,
|
|
1094
|
+
risk_level: riskLevel,
|
|
1095
|
+
user_min_trust_score: userMinTrust,
|
|
1096
|
+
user_require_arbitration: profile.risk_appetite === "conservative",
|
|
1097
|
+
user_require_compensation: profile.risk_appetite === "conservative",
|
|
1098
|
+
};
|
|
1099
|
+
const reminders = generateReminders(ctx);
|
|
1100
|
+
const recommendations = [];
|
|
1101
|
+
for (const r of reminders) {
|
|
1102
|
+
if (r.action)
|
|
1103
|
+
recommendations.push(r.action);
|
|
1104
|
+
}
|
|
1105
|
+
if (noArbitration && !recommendations.some((r) => r.includes("仲裁"))) {
|
|
1106
|
+
recommendations.push("要求商家配置 Arbitration 服务后再下单");
|
|
1107
|
+
}
|
|
1108
|
+
if (noCompensation && !recommendations.some((r) => r.includes("赔偿金"))) {
|
|
1109
|
+
recommendations.push("要求商家设置 compensation_fund(赔偿金)以保障订单失败时自动赔付");
|
|
1110
|
+
}
|
|
1111
|
+
const advice = {
|
|
1112
|
+
recommendations,
|
|
1113
|
+
reminders: reminders.map((r) => ({
|
|
1114
|
+
id: r.id,
|
|
1115
|
+
stage: r.stage,
|
|
1116
|
+
priority: r.priority,
|
|
1117
|
+
message: r.message,
|
|
1118
|
+
action: r.action,
|
|
1119
|
+
})),
|
|
1120
|
+
};
|
|
1121
|
+
if (riskScore !== undefined)
|
|
1122
|
+
advice.risk_score = riskScore;
|
|
1123
|
+
if (riskLevel !== undefined)
|
|
1124
|
+
advice.risk_level = riskLevel;
|
|
1125
|
+
return advice;
|
|
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
|
+
}
|
|
682
1177
|
export function buildSemantic(safeResult, context) {
|
|
683
1178
|
if (!context)
|
|
684
1179
|
return undefined;
|
|
@@ -693,6 +1188,80 @@ export function buildSemantic(safeResult, context) {
|
|
|
693
1188
|
const annotatedEvents = annotateEvents(events);
|
|
694
1189
|
const next_actions = inferNextActions(context.operation_type, context.data, status);
|
|
695
1190
|
const warnings = inferWarnings(context.operation_type, context.data, safeResult);
|
|
1191
|
+
if (context.pre_warnings && context.pre_warnings.length > 0) {
|
|
1192
|
+
warnings.push(...context.pre_warnings);
|
|
1193
|
+
}
|
|
1194
|
+
if (context.operation_type === "service" && context.data?.publish === true) {
|
|
1195
|
+
const findings = auditService(context.data);
|
|
1196
|
+
for (const f of findings) {
|
|
1197
|
+
const prefix = f.severity === "error" ? "[AUDIT ERROR] " : f.severity === "warning" ? "[AUDIT] " : "[INFO] ";
|
|
1198
|
+
warnings.push(prefix + f.message);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
let experience;
|
|
1202
|
+
const experienceLayerEnabled = isRuntimeEnabled("experience_layer");
|
|
1203
|
+
if (experienceLayerEnabled) {
|
|
1204
|
+
try {
|
|
1205
|
+
const feedback = getExperienceFeedback(context.operation_type, context.data, intent);
|
|
1206
|
+
if (feedback) {
|
|
1207
|
+
experience = feedback;
|
|
1208
|
+
}
|
|
1209
|
+
const outcome = status === "success" ? "success" : status === "failed" ? "failed" : "partial";
|
|
1210
|
+
const referencedObjects = [...created, ...modified].map((o) => o.id).filter(Boolean);
|
|
1211
|
+
const errCode = inferErrorCodeForSignal(safeResult);
|
|
1212
|
+
recordOperationOutcome(context.operation_type, context.data, intent, outcome, errCode, referencedObjects);
|
|
1213
|
+
}
|
|
1214
|
+
catch {
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
let evolution_context;
|
|
1218
|
+
if (isRuntimeEnabled("industry_evolution")) {
|
|
1219
|
+
try {
|
|
1220
|
+
const industryHint = (typeof context.data?.industry === "string" && context.data.industry.trim())
|
|
1221
|
+
? context.data.industry.trim()
|
|
1222
|
+
: undefined;
|
|
1223
|
+
if (industryHint && !experienceLayerEnabled) {
|
|
1224
|
+
const outcome = status === "success"
|
|
1225
|
+
? { success: true }
|
|
1226
|
+
: { success: false, error_code: inferErrorCodeForSignal(safeResult) };
|
|
1227
|
+
recordIndustrySignal(industryHint, { type: context.operation_type, data: context.data }, outcome);
|
|
1228
|
+
}
|
|
1229
|
+
if (industryHint) {
|
|
1230
|
+
const evoCtx = injectEvolutionContext(undefined, industryHint);
|
|
1231
|
+
if (evoCtx && (evoCtx.industry_signal || evoCtx.evolution_advice || evoCtx.confidence > 0)) {
|
|
1232
|
+
evolution_context = evoCtx;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
catch {
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
let service_status;
|
|
1240
|
+
if (isRuntimeEnabled("semantic_rich")) {
|
|
1241
|
+
try {
|
|
1242
|
+
const all = listServices();
|
|
1243
|
+
const active = all.filter((s) => s.enabled).map((s) => s.name);
|
|
1244
|
+
const inactive = all.filter((s) => !s.enabled).map((s) => s.name);
|
|
1245
|
+
service_status = {
|
|
1246
|
+
active,
|
|
1247
|
+
inactive: inactive.length ? inactive : undefined,
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1250
|
+
catch {
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
let customer_advice;
|
|
1254
|
+
try {
|
|
1255
|
+
customer_advice = buildCustomerAdvice(context.operation_type, context.data, safeResult);
|
|
1256
|
+
}
|
|
1257
|
+
catch {
|
|
1258
|
+
}
|
|
1259
|
+
let guard_advice;
|
|
1260
|
+
try {
|
|
1261
|
+
guard_advice = buildGuardAdvice(context.operation_type, context.data, safeResult);
|
|
1262
|
+
}
|
|
1263
|
+
catch {
|
|
1264
|
+
}
|
|
696
1265
|
return {
|
|
697
1266
|
intent,
|
|
698
1267
|
status,
|
|
@@ -703,8 +1272,20 @@ export function buildSemantic(safeResult, context) {
|
|
|
703
1272
|
events: annotatedEvents.length ? annotatedEvents : undefined,
|
|
704
1273
|
next_actions: next_actions.length ? next_actions : undefined,
|
|
705
1274
|
warnings: warnings.length ? warnings : undefined,
|
|
1275
|
+
experience,
|
|
1276
|
+
service_status,
|
|
1277
|
+
customer_advice,
|
|
1278
|
+
evolution_context,
|
|
1279
|
+
guard_advice,
|
|
706
1280
|
};
|
|
707
1281
|
}
|
|
1282
|
+
function inferErrorCodeForSignal(safeResult) {
|
|
1283
|
+
if (!safeResult)
|
|
1284
|
+
return undefined;
|
|
1285
|
+
if (typeof safeResult.error === "string")
|
|
1286
|
+
return safeResult.error.slice(0, 64);
|
|
1287
|
+
return undefined;
|
|
1288
|
+
}
|
|
708
1289
|
export function buildDataSemantic(data, context, isError, errorMsg) {
|
|
709
1290
|
if (!context)
|
|
710
1291
|
return undefined;
|
|
@@ -753,6 +1334,28 @@ export function buildDataSemantic(data, context, isError, errorMsg) {
|
|
|
753
1334
|
else {
|
|
754
1335
|
summary = `Successfully ${intentVerb}`;
|
|
755
1336
|
}
|
|
1337
|
+
let service_status;
|
|
1338
|
+
if (isRuntimeEnabled("semantic_rich")) {
|
|
1339
|
+
try {
|
|
1340
|
+
const all = listServices();
|
|
1341
|
+
const active = all.filter((s) => s.enabled).map((s) => s.name);
|
|
1342
|
+
const inactive = all.filter((s) => !s.enabled).map((s) => s.name);
|
|
1343
|
+
service_status = {
|
|
1344
|
+
active,
|
|
1345
|
+
inactive: inactive.length ? inactive : undefined,
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
catch {
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
let customer_advice;
|
|
1352
|
+
if (!isError) {
|
|
1353
|
+
try {
|
|
1354
|
+
customer_advice = buildCustomerAdvice(context.operation_type, context.data, data);
|
|
1355
|
+
}
|
|
1356
|
+
catch {
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
756
1359
|
return {
|
|
757
1360
|
intent,
|
|
758
1361
|
status,
|
|
@@ -760,5 +1363,7 @@ export function buildDataSemantic(data, context, isError, errorMsg) {
|
|
|
760
1363
|
events: annotatedEvents,
|
|
761
1364
|
next_actions: next_actions.length ? next_actions : undefined,
|
|
762
1365
|
warnings: warnings.length ? warnings : undefined,
|
|
1366
|
+
service_status,
|
|
1367
|
+
customer_advice,
|
|
763
1368
|
};
|
|
764
1369
|
}
|