@wowok/agent-mcp 3.1.7 → 3.2.1
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/exposure.d.ts +2 -2
- package/dist/config/judgment.d.ts +5 -5
- package/dist/config/rule-engine.d.ts +5 -5
- package/dist/customer/user-preferences.d.ts +2 -2
- package/dist/evaluation/arbitration-game.js +1 -1
- package/dist/evaluation/capability.d.ts +1 -1
- package/dist/evaluation/extract.js +1 -1
- package/dist/evaluation/match-operation.js +1 -1
- package/dist/extensions/industry-pack.d.ts +3 -2
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/modes.js +1 -1
- package/dist/extensions/registry.js +1 -1
- package/dist/extensions/types.d.ts +1 -0
- package/dist/graph/onchain/analyze.js +1 -1
- package/dist/graph/onchain/analyze.spec.js +1 -1
- package/dist/graph/onchain/edge-schema.js +1 -1
- package/dist/graph/onchain/extract.js +1 -1
- package/dist/graph/onchain/facts.js +1 -1
- package/dist/graph/onchain/field-manifest.js +1 -1
- package/dist/graph/onchain/project-relationship.js +1 -1
- package/dist/graph/onchain/sdk-batch.d.ts +1 -0
- package/dist/graph/onchain/sdk-batch.js +1 -1
- package/dist/graph/onchain/sdk-dataplane.d.ts +1 -0
- package/dist/graph/onchain/sdk-dataplane.js +1 -1
- package/dist/graph/onchain/types.d.ts +1 -1
- package/dist/harness/recover.js +1 -1
- package/dist/keeper/KeeperScan.d.ts +2 -1
- package/dist/keeper/KeeperScan.js +1 -1
- package/dist/keeper/detectors.d.ts +9 -0
- package/dist/keeper/detectors.js +1 -1
- package/dist/keeper/keeper.spec.js +1 -1
- package/dist/keeper/types.d.ts +1 -1
- package/dist/keeper/types.js +1 -1
- package/dist/knowledge/allocation-ledger.d.ts +4 -1
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/allocation-puzzle.d.ts +2 -0
- package/dist/knowledge/allocation-puzzle.js +1 -1
- package/dist/knowledge/allocation-risk.d.ts +1 -1
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/allocation-templates.d.ts +1 -1
- package/dist/knowledge/allocation-templates.js +1 -1
- package/dist/knowledge/arb-risk.d.ts +3 -1
- package/dist/knowledge/arb-risk.js +1 -1
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/arbitration-risk.js +1 -1
- package/dist/knowledge/arbitration-templates.d.ts +1 -0
- package/dist/knowledge/arbitration-templates.js +1 -1
- package/dist/knowledge/audit-rules.d.ts +13 -2
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/rules/allocation.json +50 -1
- package/dist/knowledge/baselines/rules/arb.json +20 -1
- package/dist/knowledge/baselines/rules/arbitration.json +27 -0
- package/dist/knowledge/baselines/rules/guard.json +75 -2
- package/dist/knowledge/baselines/rules/machine.json +38 -13
- package/dist/knowledge/baselines/rules/order.json +2 -2
- package/dist/knowledge/builtin-templates.d.ts +3 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/discount-threshold.d.ts +15 -0
- package/dist/knowledge/discount-threshold.js +1 -0
- package/dist/knowledge/event-semantics.js +1 -1
- package/dist/knowledge/fund-layer.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-anchor-reach.d.ts +19 -0
- package/dist/knowledge/guard-anchor-reach.js +1 -0
- package/dist/knowledge/guard-bindings.js +1 -1
- package/dist/knowledge/guard-design-patterns.d.ts +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-ledger.js +1 -1
- package/dist/knowledge/guard-lint.js +1 -1
- package/dist/knowledge/guard-render.d.ts +6 -0
- package/dist/knowledge/guard-render.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-submission-prompt.d.ts +6 -0
- package/dist/knowledge/guard-submission-prompt.js +1 -1
- package/dist/knowledge/guard-templates.d.ts +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/index.d.ts +6 -6
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-generalizer.d.ts +38 -1
- package/dist/knowledge/industry-generalizer.js +1 -1
- package/dist/knowledge/industry-registry.d.ts +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/industry-strategy.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/machine-ledger.js +1 -1
- package/dist/knowledge/machine-risk.js +1 -1
- package/dist/knowledge/machine-templates.js +1 -1
- package/dist/knowledge/onchain-constants.d.ts +2 -2
- package/dist/knowledge/onchain-constants.js +1 -1
- package/dist/knowledge/order-ledger.js +1 -1
- package/dist/knowledge/order-templates.js +1 -1
- package/dist/knowledge/permission-ledger.js +1 -1
- package/dist/knowledge/release-sentinel.d.ts +12 -0
- package/dist/knowledge/release-sentinel.js +1 -0
- package/dist/knowledge/repository-write-semantics.d.ts +27 -0
- package/dist/knowledge/repository-write-semantics.js +1 -0
- package/dist/knowledge/rule-node-analyzers.d.ts +6 -0
- package/dist/knowledge/rule-node-analyzers.js +1 -1
- package/dist/knowledge/safety-rules.d.ts +5 -1
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +20 -1
- package/dist/knowledge/scenario-modes.js +1 -1
- package/dist/knowledge/service-allocation-semantics.d.ts +36 -0
- package/dist/knowledge/service-allocation-semantics.js +1 -0
- package/dist/knowledge/strategy-manuals.d.ts +4 -6
- package/dist/knowledge/strategy-manuals.js +1 -1
- package/dist/knowledge/template-loader.d.ts +48 -12
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +26 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/participation/allocation-advice.d.ts +38 -0
- package/dist/participation/allocation-advice.js +1 -0
- package/dist/participation/arbitrator-interest.js +1 -1
- package/dist/participation/customer-interest.js +1 -1
- package/dist/participation/merchant-interest.js +1 -1
- package/dist/participation/radar-core.d.ts +2 -0
- package/dist/persona/types.d.ts +3 -2
- package/dist/persona/types.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/intent-analyzer.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +70 -63
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/migration-planner.js +1 -1
- package/dist/playbooks/service-build/mode-actions.d.ts +17 -1
- package/dist/playbooks/service-build/mode-actions.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/reverse-mapping-refund-p0-5.spec.js +1 -0
- package/dist/playbooks/service-build/reverse-mapping.js +1 -1
- package/dist/playbooks/service-build/semantic-graph.d.ts +1 -0
- package/dist/playbooks/service-build/semantic-graph.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.d.ts +2 -0
- package/dist/playbooks/service-build/service-quote.js +1 -0
- package/dist/relationship/derivation.d.ts +1 -1
- package/dist/review/index.js +1 -1
- package/dist/role/profiles.js +1 -1
- package/dist/role/types.d.ts +2 -0
- package/dist/role/types.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/benchmark-migration/index.d.ts +30 -8
- package/dist/schema/benchmark-migration/index.js +1 -1
- package/dist/schema/call/allocation.d.ts +10 -7
- package/dist/schema/call/arbitration.d.ts +1 -1
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.d.ts +5 -5
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +5 -9
- package/dist/schema/call/bridge.js +1 -1
- package/dist/schema/call/contact.d.ts +1 -1
- package/dist/schema/call/demand.d.ts +1 -1
- package/dist/schema/call/guard.d.ts +15 -15
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +58 -2
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/order.d.ts +1 -1
- package/dist/schema/call/order.js +1 -1
- package/dist/schema/call/payment.d.ts +1 -1
- package/dist/schema/call/payment.js +1 -1
- package/dist/schema/call/permission.d.ts +1 -1
- package/dist/schema/call/personal.d.ts +1 -1
- package/dist/schema/call/progress.d.ts +1 -1
- package/dist/schema/call/proof.d.ts +2 -2
- package/dist/schema/call/repository.d.ts +1 -1
- package/dist/schema/call/reward.d.ts +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +87 -25
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/call/treasury.d.ts +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/common/tokentype-short-probe.spec.js +1 -0
- package/dist/schema/evaluation/index.d.ts +14 -82
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +8 -41
- package/dist/schema/goal/planning.d.ts +22 -57
- package/dist/schema/goal/planning.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +15 -0
- package/dist/schema/industry-pack/modes.d.ts +15 -0
- package/dist/schema/industry-pack/modes.js +1 -1
- package/dist/schema/intent-radar/index.d.ts +5 -20
- package/dist/schema/intent-radar/index.js +1 -1
- package/dist/schema/interaction/index.d.ts +1 -1
- package/dist/schema/keeper/index.d.ts +3 -0
- package/dist/schema/keeper/index.js +1 -1
- package/dist/schema/local/index.d.ts +577 -18
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +140 -20
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +97 -35
- package/dist/schema/operations.js +1 -1
- package/dist/schema/persona/index.d.ts +811 -916
- package/dist/schema/persona/index.js +1 -1
- package/dist/schema/query/bi.d.ts +161 -8
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +49 -30
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-query/index.d.ts +2 -2
- package/dist/schema/workflow/index.d.ts +2 -2
- package/dist/schema-query-impl/index.d.ts +1 -0
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +8 -4
- package/dist/schemas/account_operation.schema.json +1 -1
- package/dist/schemas/benchmark_migration_operation.output.json +116 -2
- package/dist/schemas/benchmark_migration_operation.schema.json +2 -10
- package/dist/schemas/bridge_operation.output.json +2 -2
- package/dist/schemas/bridge_operation.schema.json +2 -10
- package/dist/schemas/evaluation_operation.output.json +2 -0
- package/dist/schemas/evaluation_operation.schema.json +9 -70
- package/dist/schemas/goal_operation.schema.json +6 -39
- package/dist/schemas/index.json +7 -1
- package/dist/schemas/industry_pack_operation.output.json +87 -4
- package/dist/schemas/intent_radar.output.json +6 -20
- package/dist/schemas/intent_radar.schema.json +1 -0
- package/dist/schemas/keeper_operation.output.json +2 -2
- package/dist/schemas/keeper_operation.schema.json +9 -4
- package/dist/schemas/local_cache_operation.output.json +1536 -0
- package/dist/schemas/local_cache_operation.schema.json +101 -0
- package/dist/schemas/local_history_operation.output.json +2 -2
- package/dist/schemas/local_info_operation.output.json +2 -2
- package/dist/schemas/local_mark_operation.output.json +53 -38
- package/dist/schemas/local_mark_operation.schema.json +1 -0
- package/dist/schemas/messenger_operation.output.json +2 -2
- package/dist/schemas/messenger_operation.schema.json +358 -35
- package/dist/schemas/monitor_events.output.json +2 -2
- package/dist/schemas/monitor_subscription.output.json +2 -2
- package/dist/schemas/onchain_events.output.json +2 -2
- package/dist/schemas/onchain_operations.output.json +6 -6
- package/dist/schemas/onchain_operations.schema.json +237 -64
- package/dist/schemas/onchain_operations_allocation.schema.json +12 -11
- package/dist/schemas/onchain_operations_arbitration.schema.json +16 -16
- package/dist/schemas/onchain_operations_machine.schema.json +27 -5
- package/dist/schemas/onchain_operations_order.schema.json +1 -1
- package/dist/schemas/onchain_operations_payment.schema.json +3 -3
- package/dist/schemas/onchain_operations_reward.schema.json +2 -2
- package/dist/schemas/onchain_operations_service.schema.json +174 -24
- package/dist/schemas/onchain_operations_treasury.schema.json +2 -2
- package/dist/schemas/onchain_table_data.output.json +68 -4
- package/dist/schemas/persona_operation.output.json +11 -88
- package/dist/schemas/persona_operation.schema.json +4 -32
- package/dist/schemas/query_toolkit.output.json +331 -26
- package/dist/schemas/query_toolkit.schema.json +66 -2
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/dispatch-expectations.spec.js +1 -1
- package/dist/tools/handlers/keeper.d.ts +1 -1
- package/dist/tools/handlers/local.d.ts +1 -0
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/messenger.d.ts +9 -2
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/name-resolution.d.ts +4 -0
- package/dist/tools/handlers/name-resolution.js +1 -0
- package/dist/tools/handlers/name-resolution.spec.js +1 -0
- package/dist/tools/handlers/onchain-name-registration.d.ts +37 -0
- package/dist/tools/handlers/onchain-name-registration.js +1 -0
- package/dist/tools/handlers/onchain-name-registration.spec.js +1 -0
- package/dist/tools/handlers/onchain.d.ts +1 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.d.ts +1 -0
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/schema-query.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/move-fn-index.gen.js +1 -1
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/registry/local.js +1 -1
- package/dist/tools/sanitize-description-roundtrip.spec.js +1 -0
- package/dist/tools/sanitize-output.d.ts +1 -0
- package/dist/tools/sanitize-output.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
- package/dist/knowledge/alloc-audit-policy.spec.js +0 -1
- package/dist/knowledge/event-semantics.spec.js +0 -1
- package/dist/knowledge/facts-sync.spec.js +0 -1
- package/dist/knowledge/guard-design-patterns.spec.js +0 -1
- package/dist/knowledge/guard-eval.spec.js +0 -1
- package/dist/knowledge/rule-node-analyzers.spec.d.ts +0 -1
- package/dist/knowledge/rule-node-analyzers.spec.js +0 -1
- package/dist/knowledge/safety-rules.extract-amount.spec.d.ts +0 -1
- package/dist/knowledge/safety-rules.extract-amount.spec.js +0 -1
- package/dist/knowledge/template-loader.spec.d.ts +0 -1
- package/dist/knowledge/template-loader.spec.js +0 -1
- package/dist/knowledge/template-scanner.spec.d.ts +0 -1
- package/dist/knowledge/template-scanner.spec.js +0 -1
- /package/dist/{knowledge/alloc-audit-policy.spec.d.ts → playbooks/service-build/reverse-mapping-refund-p0-5.spec.d.ts} +0 -0
- /package/dist/{knowledge/event-semantics.spec.d.ts → schema/common/tokentype-short-probe.spec.d.ts} +0 -0
- /package/dist/{knowledge/facts-sync.spec.d.ts → tools/handlers/name-resolution.spec.d.ts} +0 -0
- /package/dist/{knowledge/guard-design-patterns.spec.d.ts → tools/handlers/onchain-name-registration.spec.d.ts} +0 -0
- /package/dist/{knowledge/guard-eval.spec.d.ts → tools/sanitize-description-roundtrip.spec.d.ts} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type BusinessIntent, type DeliverableDefinition, type PaymentIntent, type TrustIntent } from "./intent-analyzer.js";
|
|
2
2
|
import { type BusinessModuleId } from "../../extensions/business-modules.js";
|
|
3
|
+
import type { IndustryMode } from "../../extensions/index.js";
|
|
3
4
|
export interface GuideState {
|
|
4
5
|
intent_text: string;
|
|
5
6
|
confirmed_industry?: string;
|
|
@@ -28,6 +29,17 @@ export interface MerchantGuideInput {
|
|
|
28
29
|
trust?: Record<string, unknown>;
|
|
29
30
|
adopted_module_ids?: string[];
|
|
30
31
|
};
|
|
32
|
+
mode_prior_override?: IndustryMode;
|
|
33
|
+
name_base?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface PostDeployStep {
|
|
36
|
+
order: number;
|
|
37
|
+
id: string;
|
|
38
|
+
title: string;
|
|
39
|
+
when: string;
|
|
40
|
+
action: string;
|
|
41
|
+
tool_hint: string;
|
|
42
|
+
failure_if_skipped: string;
|
|
31
43
|
}
|
|
32
44
|
interface CreationPlanEntry {
|
|
33
45
|
order: number;
|
|
@@ -50,70 +62,7 @@ export declare function handleMerchantGuide(v: MerchantGuideInput): Promise<{
|
|
|
50
62
|
};
|
|
51
63
|
warnings: string[];
|
|
52
64
|
next_action: string;
|
|
53
|
-
intent?: undefined;
|
|
54
|
-
adopted_modules?: undefined;
|
|
55
|
-
mode_prior?: undefined;
|
|
56
|
-
blueprint?: undefined;
|
|
57
|
-
evaluation_preview?: undefined;
|
|
58
|
-
graph_validation?: undefined;
|
|
59
|
-
harness_check?: undefined;
|
|
60
|
-
game_theory?: undefined;
|
|
61
|
-
workflow_design_assessment?: undefined;
|
|
62
|
-
creation_plan?: undefined;
|
|
63
65
|
} | {
|
|
64
|
-
action: "merchant_guide";
|
|
65
|
-
current_step: number;
|
|
66
|
-
step_name: string;
|
|
67
|
-
guide_state: {
|
|
68
|
-
adopted_module_ids: BusinessModuleId[];
|
|
69
|
-
intent_text: string;
|
|
70
|
-
confirmed_industry?: string;
|
|
71
|
-
currency?: string;
|
|
72
|
-
deliverables?: DeliverableDefinition[];
|
|
73
|
-
payment_override?: Partial<PaymentIntent>;
|
|
74
|
-
trust_override?: Partial<TrustIntent>;
|
|
75
|
-
};
|
|
76
|
-
intent: {
|
|
77
|
-
intent_type: import("./intent-analyzer.js").BusinessIntentType;
|
|
78
|
-
industry: string | undefined;
|
|
79
|
-
roles: {
|
|
80
|
-
merchant: import("./intent-analyzer.js").RoleDefinition;
|
|
81
|
-
customer: import("./intent-analyzer.js").RoleDefinition;
|
|
82
|
-
suppliers?: import("./intent-analyzer.js").RoleDefinition[];
|
|
83
|
-
arbitrators?: import("./intent-analyzer.js").RoleDefinition;
|
|
84
|
-
};
|
|
85
|
-
deliverables: DeliverableDefinition[];
|
|
86
|
-
payment: PaymentIntent;
|
|
87
|
-
trust: TrustIntent;
|
|
88
|
-
};
|
|
89
|
-
adopted_modules: {
|
|
90
|
-
id: BusinessModuleId;
|
|
91
|
-
name: string;
|
|
92
|
-
description: string;
|
|
93
|
-
requires_keeper: boolean;
|
|
94
|
-
keeper_hint: string | undefined;
|
|
95
|
-
user_protections: string[];
|
|
96
|
-
merchant_obligations: string[];
|
|
97
|
-
}[];
|
|
98
|
-
mode_prior: {
|
|
99
|
-
name: string;
|
|
100
|
-
display_name: string;
|
|
101
|
-
source: import("../../knowledge/industry-registry.js").IndustrySource;
|
|
102
|
-
risk_appetite: import("../../extensions/types.js").RiskAppetite;
|
|
103
|
-
key_risk: string;
|
|
104
|
-
machine_shape: {
|
|
105
|
-
name: string;
|
|
106
|
-
role: string;
|
|
107
|
-
}[];
|
|
108
|
-
guards: {
|
|
109
|
-
template_id: string;
|
|
110
|
-
host: "reward" | "service" | "machine" | "arbitration" | "repository";
|
|
111
|
-
purpose: string;
|
|
112
|
-
}[];
|
|
113
|
-
allocator: import("../../knowledge/scenario-modes.js").ModeAllocatorStrategy;
|
|
114
|
-
risk_constraints: import("../../extensions/types.js").ModeRiskConstraints;
|
|
115
|
-
build_notes: string[];
|
|
116
|
-
} | undefined;
|
|
117
66
|
blueprint: {
|
|
118
67
|
nodes: {
|
|
119
68
|
id: string;
|
|
@@ -195,8 +144,66 @@ export declare function handleMerchantGuide(v: MerchantGuideInput): Promise<{
|
|
|
195
144
|
}[];
|
|
196
145
|
};
|
|
197
146
|
creation_plan: CreationPlanEntry[];
|
|
147
|
+
post_deploy_steps: PostDeployStep[];
|
|
198
148
|
warnings: string[];
|
|
199
149
|
next_action: string;
|
|
150
|
+
time_anchor_instructions?: string[] | undefined;
|
|
151
|
+
action: "merchant_guide";
|
|
152
|
+
current_step: number;
|
|
153
|
+
step_name: string;
|
|
154
|
+
guide_state: {
|
|
155
|
+
adopted_module_ids: BusinessModuleId[];
|
|
156
|
+
intent_text: string;
|
|
157
|
+
confirmed_industry?: string;
|
|
158
|
+
currency?: string;
|
|
159
|
+
deliverables?: DeliverableDefinition[];
|
|
160
|
+
payment_override?: Partial<PaymentIntent>;
|
|
161
|
+
trust_override?: Partial<TrustIntent>;
|
|
162
|
+
};
|
|
163
|
+
intent: {
|
|
164
|
+
intent_type: import("./intent-analyzer.js").BusinessIntentType;
|
|
165
|
+
industry: string | undefined;
|
|
166
|
+
roles: {
|
|
167
|
+
merchant: import("./intent-analyzer.js").RoleDefinition;
|
|
168
|
+
customer: import("./intent-analyzer.js").RoleDefinition;
|
|
169
|
+
suppliers?: import("./intent-analyzer.js").RoleDefinition[];
|
|
170
|
+
arbitrators?: import("./intent-analyzer.js").RoleDefinition;
|
|
171
|
+
};
|
|
172
|
+
deliverables: DeliverableDefinition[];
|
|
173
|
+
payment: PaymentIntent;
|
|
174
|
+
trust: TrustIntent;
|
|
175
|
+
};
|
|
176
|
+
adopted_modules: {
|
|
177
|
+
id: BusinessModuleId;
|
|
178
|
+
name: string;
|
|
179
|
+
description: string;
|
|
180
|
+
requires_keeper: boolean;
|
|
181
|
+
keeper_hint: string | undefined;
|
|
182
|
+
user_protections: string[];
|
|
183
|
+
merchant_obligations: string[];
|
|
184
|
+
}[];
|
|
185
|
+
mode_prior: {
|
|
186
|
+
time_anchors?: Record<string, string> | undefined;
|
|
187
|
+
name: string;
|
|
188
|
+
display_name: string;
|
|
189
|
+
source: import("../../knowledge/industry-registry.js").IndustrySource;
|
|
190
|
+
risk_appetite: import("../../extensions/types.js").RiskAppetite;
|
|
191
|
+
key_risk: string;
|
|
192
|
+
machine_shape: {
|
|
193
|
+
semantic_role?: "active" | "draft" | "delivered" | "final" | "cancelled" | undefined;
|
|
194
|
+
operator?: "merchant" | "order_payer" | undefined;
|
|
195
|
+
name: string;
|
|
196
|
+
role: string;
|
|
197
|
+
}[];
|
|
198
|
+
guards: {
|
|
199
|
+
template_id: string;
|
|
200
|
+
host: "reward" | "service" | "arbitration" | "machine" | "repository";
|
|
201
|
+
purpose: string;
|
|
202
|
+
}[];
|
|
203
|
+
allocator: import("../../knowledge/scenario-modes.js").ModeAllocatorStrategy;
|
|
204
|
+
risk_constraints: import("../../extensions/types.js").ModeRiskConstraints;
|
|
205
|
+
build_notes: string[];
|
|
206
|
+
} | undefined;
|
|
200
207
|
intent_draft?: undefined;
|
|
201
208
|
industry_options?: undefined;
|
|
202
209
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{analyzeIntent}from'./intent-analyzer.js';import{buildSemanticGraph,validateGraph}from'./semantic-graph.js';import{checkGameTheoryConstraints}from'./game-theory.js';import{assessWorkflowDesign}from'./workflow-design-assessment.js';import{CORE_BUSINESS_MODULES,getBusinessModule,recommendModules,checkModuleConstraints}from'../../extensions/business-modules.js';import{getIndustryModeRegistry}from'../../extensions/index.js';import{LOCAL_MODE_OWNER}from'./mode-actions.js';import{recipientDesignGuidance}from'../../knowledge/recipient-constraint.js';function derivePlanSatisfiedConstraints(a,b){const c=new Set(),d=h=>a['edges']['some'](i=>i['relation']===h),e=h=>a['nodes']['some'](i=>i['id']===h),f=h=>a['nodes']['some'](i=>i['type']===h),g=h=>a['adoptedModules']['includes'](h);if(d('has_order_allocators'))c['add']('order_allocators_bound');if(d('uses_machine'))c['add']('machine_bound_before_publish');if(d('has_arbitration'))c['add']('arbitration_bound_to_service');if(e('main_machine'))c['add']('machine_published');if(e('main_repository'))c['add']('repository_published');if(e('main_service'))c['add']('service_published');e('arb_permission')&&e('main_permission')&&c['add']('arbitration_permission_independent');g('independent_arbitration')&&e('guard_independent_arbitration')&&c['add']('voting_guard_configured');g('accept_timeout_protection')&&(c['add']('time_guard_configured'),c['add']('adminUnhold_permission'));g('milestone_escrow')&&f('guard')&&c['add']('milestone_forward_guarded');if(e('main_allocation')&&b['payment']['allocation']&&b['payment']['allocation']['length']>0x0){c['add']('allocators_configured');const h=b['payment']['allocation']['reduce']((j,k)=>j+k['percentage'],0x0);if(Math['abs'](h-0x64)<0.001)c['add']('sharing_sum_100');const i=b['payment']['allocation']['find'](j=>j['recipient']==='platform');if(i&&i['percentage']===0x0)c['add']('platform_fee_zero');g('supplier_collaboration')&&(c['add']('allocation_sharing_configured'),c['add']('demand_configured'));}return g('wip_provenance')&&e('main_repository')&&c['add']('wip_hash_before_delivery'),g('subscription_with_proof')&&e('main_repository')&&(c['add']('delivery_guard_per_cycle'),c['add']('repository_updated')),g('damage_attestation')&&(c['add']('pre_rental_hash'),c['add']('post_rental_hash')),g('refund_guarantee')&&(c['add']('compensation_fund_positive'),c['add']('refund_guard_configured')),c;}function deriveDeployTimeChecks(a){const b=[];return a['nodes']['some'](c=>c['id']==='main_machine')&&b['push']('Machine\x20published\x20AND\x20bound\x20to\x20Service\x20BEFORE\x20Service.publish\x20(machine\x20is\x20immutable\x20after\x20publish)'),a['edges']['some'](c=>c['relation']==='has_order_allocators')&&b['push']('Service.order_allocators\x20bound\x20(verify\x20via\x20query_objects\x20after\x20publish\x20—\x20order_allocators\x20is\x20FROZEN\x20at\x20publish)'),a['nodes']['some'](c=>c['id']==='main_arbitration')&&b['push']('Arbitration.permission\x20!=\x20Service.permission\x20on-chain\x20(E_ARBITRATION_PERMISSION_CONFLICT=33)'),a['nodes']['some'](c=>c['id']==='main_repository')&&b['push']('Repository\x20published\x20and\x20Guard\x20write\x20validation\x20configured'),b['push']('After\x20materialization,\x20confirm\x20the\x20on-chain\x20state\x20matches\x20this\x20plan\x20(query_toolkit\x20query_type=\x27service_panorama\x27)'),b;}function buildCreationPlan(a){const b=[],c=new Map(a['nodes']['map'](i=>[i['id'],i])),f=new Map();for(const i of a['nodes'])f['set'](i['id'],new Set());for(const j of a['edges']){j['required']&&f['has'](j['from'])&&c['has'](j['to'])&&f['get'](j['from'])['add'](j['to']);}const g=[],h=new Map(f);while(h['size']>0x0){const k=[...h['entries']()]['filter'](([,l])=>l['size']===0x0)['map'](([l])=>l);if(k['length']===0x0){g['push'](...h['keys']());break;}k['sort']();for(const l of k){g['push'](l),h['delete'](l);for(const m of h['values']())m['delete'](l);}}return g['forEach']((o,p)=>{const q=c['get'](o),r=q['config']['name'];b['push']({'order':p+0x1,'node_id':o,'object_type':q['type'],'suggested_name':r?.['type']==='string'?r['value']:o,'depends_on':[...f['get'](o)??[]],'operation_hint':'Create\x20'+q['type']+'\x20via\x20onchain_operations,\x20then\x20configure.\x20Purpose:\x20'+q['purpose']});}),b;}async function resolveModePrior(a){if(!a)return undefined;const b=getIndustryModeRegistry(),c=await b['getUserMode'](a,LOCAL_MODE_OWNER);return c??b['getMode'](a);}export async function handleMerchantGuide(a){const b=a['guide_state']??{'intent_text':''},c=a['guide_confirm']??{},d={'intent_text':(a['intent']??b['intent_text']??'')['trim'](),'confirmed_industry':c['industry']??b['confirmed_industry'],'currency':c['currency']??b['currency'],'deliverables':c['deliverables']??b['deliverables'],'payment_override':c['payment']??b['payment_override'],'trust_override':c['trust']??b['trust_override'],'adopted_module_ids':c['adopted_module_ids']??b['adopted_module_ids']};for(const t of Object['keys'](d)){if(d[t]===undefined)delete d[t];}if(!d['intent_text'])throw new Error('merchant_guide\x20requires\x20\x27intent\x27\x20(business\x20description)\x20for\x20Step\x201.\x20'+'Example:\x20intent=\x27I\x20want\x20to\x20offer\x20online\x20design\x20service\x20with\x20milestone\x20payments\x27.\x20'+'Pass\x20the\x20returned\x20guide_state\x20back\x20UNCHANGED\x20on\x20subsequent\x20calls,\x20plus\x20guide_confirm\x20for\x20merchant\x20decisions.');const e=await analyzeIntent(d['intent_text'],{'preferredIndustry':d['confirmed_industry'],'currency':d['currency']});if(!d['confirmed_industry'])return{'action':'merchant_guide','current_step':0x2,'step_name':'Industry\x20Matching','guide_state':d,'intent_draft':e['intent'],'industry_options':{'inferred':e['inferredIndustry'],'confidence':e['industryConfidence'],'similar':e['similarIndustries']},'warnings':e['warnings'],'next_action':'Confirm\x20the\x20industry\x20by\x20calling\x20merchant_guide\x20again\x20with\x20guide_state\x20(UNCHANGED)\x20'+('plus\x20guide_confirm={\x20industry:\x20\x27<one\x20of:\x20'+e['similarIndustries']['join'](',\x20')+'\x20—\x20or\x20any\x20other\x20industry\x20id>\x27\x20}')};const f={...e['intent'],'industry':d['confirmed_industry'],'deliverables':d['deliverables']??e['intent']['deliverables'],'payment':{...e['intent']['payment'],...d['payment_override']??{}},'trust':{...e['intent']['trust'],...d['trust_override']??{}}},g=d['adopted_module_ids']?d['adopted_module_ids']['map'](u=>getBusinessModule(u))['filter'](u=>!!u):recommendModules(d['confirmed_industry'],d['intent_text'],{'maxModules':0x5}),h=await resolveModePrior(d['confirmed_industry']),i=buildSemanticGraph(f,g,h,{'paymentExplicit':!!(d['payment_override']||d['trust_override'])}),j=validateGraph(i),l=derivePlanSatisfiedConstraints(i,f),m=g['map'](u=>checkModuleConstraints(u,l)),n=deriveDeployTimeChecks(i),o=i['edges']['some'](u=>u['relation']==='has_order_allocators')?recipientDesignGuidance()['map'](u=>({'id':u['id'],'move_recipient':u['move_recipient'],'semantics':u['semantics'],'required_constraints':u['required_constraints'],'finding_if_unmet':u['finding_if_unmet']})):undefined,p=m['filter'](u=>!u['adopted']),q=checkGameTheoryConstraints(i,f),r=assessWorkflowDesign(i),s=buildCreationPlan(i);return{'action':'merchant_guide','current_step':p['length']>0x0?0x9:0xa,'step_name':p['length']>0x0?'Harness\x20Check\x20(issues\x20found)':'Submission\x20Plan\x20Ready','guide_state':{...d,'adopted_module_ids':g['map'](u=>u['id'])},'intent':{'intent_type':f['intent'],'industry':f['industry'],'roles':f['roles'],'deliverables':f['deliverables'],'payment':f['payment'],'trust':f['trust']},'adopted_modules':g['map'](u=>({'id':u['id'],'name':u['name'],'description':u['description'],'requires_keeper':u['requiresKeeper'],'keeper_hint':u['keeperHint'],'user_protections':u['userProtections'],'merchant_obligations':u['merchantObligations']})),'mode_prior':h?{'name':h['name'],'display_name':h['display_name'],'source':h['source'],'risk_appetite':h['risk_appetite'],'key_risk':h['key_risk'],'machine_shape':h['machine_shape']['map'](u=>({'name':u['name'],'role':u['role']})),'guards':h['guards']['map'](u=>({'template_id':u['template_id'],'host':u['host'],'purpose':u['purpose']})),'allocator':h['allocator'],'risk_constraints':h['risk_constraints'],'build_notes':h['build_notes']??[]}:undefined,'blueprint':{'nodes':i['nodes']['map'](u=>({'id':u['id'],'type':u['type'],'purpose':u['purpose']})),'edges':i['edges']['map'](u=>({'from':u['from'],'to':u['to'],'relation':u['relation'],'required':u['required']}))},'evaluation_preview':i['evaluationPreview'],'graph_validation':{'valid':j['valid'],'hard_violations':j['hardViolations']['map'](u=>({'id':u['id'],'description':u['description'],'fix':u['fixSuggestion']})),'soft_notes':j['softViolations']['map'](u=>({'id':u['id'],'description':u['description']}))},'harness_check':{'module_constraints':m['map'](u=>({'module':u['module'],'plan_satisfied':u['adopted'],'missing':u['missingConstraints'],'reason':u['reason'],'estimated_score_boost':u['estimatedScoreBoost']})),'blocking_issues':p['map'](u=>({'module':u['module'],'missing_constraints':u['missingConstraints'],'fix':u['reason']})),'deploy_time_checks':n,'recipient_design_guidance':o},'game_theory':{'summary':q['summary'],'coverage':q['coveredCount']+'/'+q['totalCount'],'exposed_scenarios':q['exposedScenarios'],'wow_alignments':q['wowAlignments'],'scenarios':q['results']['map'](u=>({'scenario':u['scenario'],'covered':u['covered'],'conflict':u['conflict'],'user_protection':u['userProtection'],'evaluation_metric':u['evaluationMetric'],'recommendation':u['recommendation']}))},'workflow_design_assessment':{'score':r['score'],'summary':r['summary'],'findings':r['findings']['map'](u=>({'kind':u['kind'],'severity':u['severity'],'message':u['message'],'fix':u['fix']})),'checks':r['checks']['map'](u=>({'id':u['id'],'dimension':u['dimension'],'passed':u['passed'],'severity':u['severity'],'message':u['message'],'fix':u['fix']}))},'creation_plan':s,'warnings':e['warnings'],'next_action':p['length']>0x0?'Resolve\x20the\x20blocking_issues\x20above\x20(adjust\x20guide_confirm\x20payment/trust/modules,\x20or\x20accept\x20and\x20drop\x20the\x20affected\x20module\x20via\x20guide_confirm.adopted_module_ids),\x20then\x20call\x20merchant_guide\x20again.':'Plan\x20ready.\x20Materialize:\x20create\x20the\x20objects\x20in\x20creation_plan\x20order\x20via\x20onchain_operations,\x20then\x20publish\x20the\x20Service\x20(machine\x20binding\x20is\x20immutable\x20after\x20publish).'};}export function listBusinessModules(){return CORE_BUSINESS_MODULES['map'](a=>({'id':a['id'],'name':a['name'],'description':a['description'],'industry_fit':a['industryFit'],'addresses_pain_points':a['addressesPainPoints'],'requires_keeper':a['requiresKeeper']}));}
|
|
1
|
+
import{analyzeIntent}from'./intent-analyzer.js';import{buildSemanticGraph,validateGraph}from'./semantic-graph.js';import{checkGameTheoryConstraints}from'./game-theory.js';import{assessWorkflowDesign}from'./workflow-design-assessment.js';import{CORE_BUSINESS_MODULES,getBusinessModule,recommendModules,checkModuleConstraints}from'../../extensions/business-modules.js';import{getIndustryModeRegistry}from'../../extensions/index.js';import{LOCAL_MODE_OWNER}from'./mode-actions.js';import{recipientDesignGuidance}from'../../knowledge/recipient-constraint.js';function derivePlanSatisfiedConstraints(a,b){const c=new Set(),d=h=>a['edges']['some'](i=>i['relation']===h),e=h=>a['nodes']['some'](i=>i['id']===h),f=h=>a['nodes']['some'](i=>i['type']===h),g=h=>a['adoptedModules']['includes'](h);if(d('has_order_allocators'))c['add']('order_allocators_bound');if(d('uses_machine'))c['add']('machine_bound_before_publish');if(d('has_arbitration'))c['add']('arbitration_bound_to_service');if(e('main_machine'))c['add']('machine_published');if(e('main_repository'))c['add']('repository_published');if(e('main_service'))c['add']('service_published');e('arb_permission')&&e('main_permission')&&c['add']('arbitration_permission_independent');g('independent_arbitration')&&e('guard_independent_arbitration')&&c['add']('voting_guard_configured');g('accept_timeout_protection')&&(c['add']('time_guard_configured'),c['add']('adminUnhold_permission'));g('milestone_escrow')&&f('guard')&&c['add']('milestone_forward_guarded');if(e('main_allocation')&&b['payment']['allocation']&&b['payment']['allocation']['length']>0x0){c['add']('allocators_configured');const h=b['payment']['allocation']['reduce']((j,k)=>j+k['percentage'],0x0);if(Math['abs'](h-0x64)<0.001)c['add']('sharing_sum_100');const i=b['payment']['allocation']['find'](j=>j['recipient']==='platform');if(i&&i['percentage']===0x0)c['add']('platform_fee_zero');g('supplier_collaboration')&&(c['add']('allocation_sharing_configured'),c['add']('demand_configured'));}return g('wip_provenance')&&e('main_repository')&&c['add']('wip_hash_before_delivery'),g('subscription_with_proof')&&e('main_repository')&&(c['add']('delivery_guard_per_cycle'),c['add']('repository_updated')),g('damage_attestation')&&(c['add']('pre_rental_hash'),c['add']('post_rental_hash')),g('refund_guarantee')&&(c['add']('compensation_fund_positive'),c['add']('refund_guard_configured')),c;}function deriveDeployTimeChecks(a){const b=[];return a['nodes']['some'](c=>c['id']==='main_machine')&&b['push']('Machine\x20published\x20AND\x20bound\x20to\x20Service\x20BEFORE\x20Service.publish\x20(machine\x20is\x20immutable\x20after\x20publish)'),a['edges']['some'](c=>c['relation']==='has_order_allocators')&&(b['push']('Service.order_allocators\x20bound\x20(verify\x20via\x20query_objects\x20after\x20publish\x20—\x20order_allocators\x20is\x20FROZEN\x20at\x20publish)'),b['push']('Settlement\x20is\x20NOT\x20triggered\x20by\x20reaching\x20a\x20Machine\x20node\x20alone\x20—\x20an\x20explicit\x20alloc_by_guard\x20call\x20(keeper\x20or\x20merchant)\x20fires\x20the\x20settlement\x20Allocator\x20once\x20its\x20Guard\x20passes.\x20Declare\x20the\x20node->allocator\x20trigger\x20(which\x20terminal\x20node\x20unlocks\x20settlement)\x20and\x20schedule\x20the\x20keeper\x20step;\x20otherwise\x20orders\x20stall\x20at\x20the\x20settle\x20node\x20with\x20allocation_state=pending')),(a['adoptedModules']['includes']('refund_guarantee')||a['nodes']['some'](c=>c['id']==='main_arbitration'))&&b['push']('compensation_fund\x20MUST\x20be\x20topped\x20up\x20BEFORE\x20any\x20payout:\x20a\x20claim\x20against\x20an\x20empty\x20fund\x20aborts\x20(service.move\x20E_COMPENSATION_NOT_MATCH).\x20Add\x20a\x20compensation_fund_add\x20step\x20sized\x20>=\x203x\x20the\x20highest\x20single\x20order\x20(3x\x20IS\x20the\x20chain\x27s\x20hard\x20award\x20ceiling,\x20MAX_INDEMNITY_MULTIPLE)\x20and\x20verify\x20the\x20on-chain\x20balance\x20before\x20going\x20live'),a['nodes']['some'](c=>c['id']==='main_arbitration')&&(b['push']('Arbitration.permission\x20!=\x20Service.permission\x20on-chain\x20(E_ARBITRATION_PERMISSION_CONFLICT=33)'),b['push']('A\x20freshly\x20created\x20Arbitration\x20defaults\x20to\x20PAUSED\x20—\x20unpause\x20it\x20(arbitration\x20activation)\x20before\x20the\x20first\x20case\x20can\x20be\x20filed,\x20otherwise\x20dispute\x20filing\x20aborts')),a['nodes']['some'](c=>c['id']==='main_repository')&&b['push']('Repository\x20published\x20and\x20Guard\x20write\x20validation\x20configured'),b['push']('After\x20materialization,\x20confirm\x20the\x20on-chain\x20state\x20matches\x20this\x20plan\x20(query_toolkit\x20query_type=\x27service_panorama\x27)'),b;}function derivePostDeploySteps(a){const b=[];return(a['adoptedModules']['includes']('refund_guarantee')||a['nodes']['some'](c=>c['id']==='main_arbitration'))&&b['push']({'order':b['length']+0x1,'id':'compensation_fund_topup','title':'Top\x20up\x20the\x20compensation\x20fund','when':'After\x20the\x20Service\x20object\x20is\x20created,\x20BEFORE\x20the\x20service\x20goes\x20live\x20(before\x20the\x20first\x20order)','action':'Call\x20compensation_fund_add\x20sized\x20>=\x203x\x20the\x20highest\x20single\x20order\x20(3x\x20=\x20the\x20chain\x27s\x20hard\x20award\x20ceiling,\x20MAX_INDEMNITY_MULTIPLE;\x20above\x203x\x20only\x20buys\x20headroom\x20for\x20concurrent\x20claims),\x20then\x20verify\x20the\x20on-chain\x20fund\x20balance\x20via\x20query_objects','tool_hint':'onchain_operations\x20(service.compensation_fund_add)','failure_if_skipped':'a\x20compensation\x20claim\x20against\x20an\x20empty\x20fund\x20aborts\x20(E_COMPENSATION_NOT_MATCH,\x20testnet\x20lesson\x20R-4)'}),a['nodes']['some'](c=>c['id']==='main_arbitration')&&b['push']({'order':b['length']+0x1,'id':'arbitration_unpause','title':'Activate\x20the\x20Arbitration\x20(unpause)','when':'Immediately\x20after\x20the\x20Arbitration\x20object\x20is\x20created,\x20before\x20the\x20first\x20dispute\x20is\x20filed','action':'Unpause/activate\x20the\x20Arbitration\x20so\x20dispute\x20filing\x20is\x20accepted;\x20keep\x20its\x20Permission\x20distinct\x20from\x20the\x20Service\x20Permission\x20(E_ARBITRATION_PERMISSION_CONFLICT=33)','tool_hint':'onchain_operations\x20(arbitration\x20activation)','failure_if_skipped':'a\x20freshly\x20created\x20Arbitration\x20defaults\x20to\x20PAUSED\x20—\x20dispute\x20filing\x20aborts\x20(testnet\x20lesson\x20R-5)'}),a['edges']['some'](c=>c['relation']==='has_order_allocators')&&b['push']({'order':b['length']+0x1,'id':'settlement_alloc_by_guard','title':'Fire\x20settlement\x20via\x20alloc_by_guard\x20(keeper/merchant\x20step)','when':'Recurring\x20—\x20after\x20EACH\x20order\x20reaches\x20its\x20settlement\x20terminal\x20node\x20(declare\x20which\x20node\x20unlocks\x20settlement)','action':'Call\x20alloc_by_guard\x20on\x20the\x20order\x27s\x20allocation\x20with\x20the\x20settlement\x20Guard;\x20reaching\x20the\x20Machine\x20node\x20alone\x20does\x20NOT\x20settle\x20(allocation_state\x20stays\x20pending)','tool_hint':'onchain_operations\x20(allocation.alloc_by_guard);\x20schedule\x20as\x20a\x20keeper\x20step','failure_if_skipped':'orders\x20stall\x20at\x20the\x20settle\x20node\x20with\x20funds\x20locked\x20in\x20escrow\x20(testnet\x20lesson\x20R-2)'}),b['push']({'order':b['length']+0x1,'id':'verify_service_panorama','title':'Verify\x20the\x20on-chain\x20state\x20matches\x20the\x20plan','when':'After\x20all\x20creation\x20steps\x20and\x20the\x20steps\x20above\x20are\x20done','action':'Run\x20the\x20service\x20panorama\x20query\x20and\x20diff\x20it\x20against\x20this\x20plan\x27s\x20blueprint/creation_plan','tool_hint':'query_toolkit\x20query_type=\x27service_panorama\x27','failure_if_skipped':'plan/chain\x20drift\x20(missing\x20binding,\x20wrong\x20allocator\x20order)\x20stays\x20undetected\x20until\x20an\x20order\x20hits\x20it'}),b;}function buildCreationPlan(a){const b=[],c=new Map(a['nodes']['map'](j=>[j['id'],j])),f=new Map();for(const j of a['nodes'])f['set'](j['id'],new Set());for(const k of a['edges']){if(!f['has'](k['from'])||!c['has'](k['to']))continue;const l=k['relation']==='has_guard'?k['to']:k['from'],m=k['relation']==='has_guard'?k['from']:k['to'];if(l===m||!f['has'](l))continue;f['get'](l)['add'](m);}for(const o of a['nodes']){for(const p of Object['values'](o['config'])){p['type']==='address_ref'&&p['targetId']!==o['id']&&f['has'](p['targetId'])&&f['get'](o['id'])['add'](p['targetId']);}}const g=new Map([...f]['map'](([q,r])=>[q,[...r]])),h=[],i=new Map(f);while(i['size']>0x0){const q=[...i['entries']()]['filter'](([,r])=>r['size']===0x0)['map'](([r])=>r);if(q['length']===0x0){h['push'](...i['keys']());break;}q['sort']();for(const r of q){h['push'](r),i['delete'](r);for(const s of i['values']())s['delete'](r);}}return h['forEach']((t,u)=>{const v=c['get'](t),w=v['config']['name'];b['push']({'order':u+0x1,'node_id':t,'object_type':v['type'],'suggested_name':w?.['type']==='string'?w['value']:t,'depends_on':g['get'](t)??[],'operation_hint':'Create\x20'+v['type']+'\x20via\x20onchain_operations,\x20then\x20configure.\x20Purpose:\x20'+v['purpose']});}),b;}async function resolveModePrior(a){if(!a)return undefined;const b=getIndustryModeRegistry(),c=await b['getUserMode'](a,LOCAL_MODE_OWNER);return c??b['getMode'](a);}export async function handleMerchantGuide(a){const b=a['guide_state']??{'intent_text':''},c=a['guide_confirm']??{},d={'intent_text':(a['intent']??b['intent_text']??'')['trim'](),'confirmed_industry':c['industry']??b['confirmed_industry'],'currency':c['currency']??b['currency'],'deliverables':c['deliverables']??b['deliverables'],'payment_override':c['payment']??b['payment_override'],'trust_override':c['trust']??b['trust_override'],'adopted_module_ids':c['adopted_module_ids']??b['adopted_module_ids']};for(const u of Object['keys'](d)){if(d[u]===undefined)delete d[u];}if(!d['intent_text'])throw new Error('merchant_guide\x20requires\x20\x27intent\x27\x20(business\x20description)\x20for\x20Step\x201.\x20'+'Example:\x20intent=\x27I\x20want\x20to\x20offer\x20online\x20design\x20service\x20with\x20milestone\x20payments\x27.\x20'+'Pass\x20the\x20returned\x20guide_state\x20back\x20UNCHANGED\x20on\x20subsequent\x20calls,\x20plus\x20guide_confirm\x20for\x20merchant\x20decisions.');const e=await analyzeIntent(d['intent_text'],{'preferredIndustry':d['confirmed_industry'],'currency':d['currency']});if(!d['confirmed_industry'])return{'action':'merchant_guide','current_step':0x2,'step_name':'Industry\x20Matching','guide_state':d,'intent_draft':e['intent'],'industry_options':{'inferred':e['inferredIndustry'],'confidence':e['industryConfidence'],'similar':e['similarIndustries']},'warnings':e['warnings'],'next_action':'Confirm\x20the\x20industry\x20by\x20calling\x20merchant_guide\x20again\x20with\x20guide_state\x20(UNCHANGED)\x20'+('plus\x20guide_confirm={\x20industry:\x20\x27<one\x20of:\x20'+e['similarIndustries']['join'](',\x20')+'\x20—\x20or\x20any\x20other\x20industry\x20id>\x27\x20}')};const f={...e['intent'],'industry':d['confirmed_industry'],'deliverables':d['deliverables']??e['intent']['deliverables'],'payment':{...e['intent']['payment'],...d['payment_override']??{}},'trust':{...e['intent']['trust'],...d['trust_override']??{}}},g=d['adopted_module_ids']?d['adopted_module_ids']['map'](w=>getBusinessModule(w))['filter'](w=>!!w):recommendModules(d['confirmed_industry'],d['intent_text'],{'maxModules':0x5}),h=a['mode_prior_override']??await resolveModePrior(d['confirmed_industry']),i=buildSemanticGraph(f,g,h,{'paymentExplicit':!!(d['payment_override']||d['trust_override']),'nameBase':a['name_base']}),j=validateGraph(i),l=derivePlanSatisfiedConstraints(i,f),m=g['map'](w=>checkModuleConstraints(w,l)),n=deriveDeployTimeChecks(i),o=derivePostDeploySteps(i),p=i['edges']['some'](w=>w['relation']==='has_order_allocators')?recipientDesignGuidance()['map'](w=>({'id':w['id'],'move_recipient':w['move_recipient'],'semantics':w['semantics'],'required_constraints':w['required_constraints'],'finding_if_unmet':w['finding_if_unmet']})):undefined,q=m['filter'](w=>!w['adopted']),r=checkGameTheoryConstraints(i,f),s=assessWorkflowDesign(i),t=buildCreationPlan(i);return{'action':'merchant_guide','current_step':q['length']>0x0?0x9:0xa,'step_name':q['length']>0x0?'Harness\x20Check\x20(issues\x20found)':'Submission\x20Plan\x20Ready','guide_state':{...d,'adopted_module_ids':g['map'](w=>w['id'])},'intent':{'intent_type':f['intent'],'industry':f['industry'],'roles':f['roles'],'deliverables':f['deliverables'],'payment':f['payment'],'trust':f['trust']},'adopted_modules':g['map'](w=>({'id':w['id'],'name':w['name'],'description':w['description'],'requires_keeper':w['requiresKeeper'],'keeper_hint':w['keeperHint'],'user_protections':w['userProtections'],'merchant_obligations':w['merchantObligations']})),'mode_prior':h?{'name':h['name'],'display_name':h['display_name'],'source':h['source'],'risk_appetite':h['risk_appetite'],'key_risk':h['key_risk'],'machine_shape':h['machine_shape']['map'](w=>({'name':w['name'],'role':w['role'],...w['operator']?{'operator':w['operator']}:{},...w['semantic_role']?{'semantic_role':w['semantic_role']}:{}})),'guards':h['guards']['map'](w=>({'template_id':w['template_id'],'host':w['host'],'purpose':w['purpose']})),'allocator':h['allocator'],'risk_constraints':h['risk_constraints'],'build_notes':h['build_notes']??[],...h['time_anchors']?{'time_anchors':h['time_anchors']}:{}}:undefined,...h?.['time_anchors']?{'time_anchor_instructions':Object['entries'](h['time_anchors'])['map'](([w,x])=>{const y=x==='order.time'?'\x20(order-creation\x20time\x20—\x20PRE-checkout\x20branches\x20only;\x20a\x20post-checkout\x20window\x20anchored\x20here\x20is\x20unreachable)':x==='progress.current_time'?'\x20(entry\x20time\x20of\x20the\x20window\x27s\x20source\x20node\x20—\x20witness-derived\x20via\x20OrderProgress,\x20one\x20Guard\x20serves\x20every\x20order)':x==='absolute_date'?'\x20(per-order\x20instance\x20Guard\x20—\x20the\x20absolute\x20date\x20differs\x20per\x20booking)':'';return'Time\x20windows\x20for\x20\x27'+w+'\x27\x20anchor\x20to\x20'+x+y;})}:{},'blueprint':{'nodes':i['nodes']['map'](w=>({'id':w['id'],'type':w['type'],'purpose':w['purpose']})),'edges':i['edges']['map'](w=>({'from':w['from'],'to':w['to'],'relation':w['relation'],'required':w['required']}))},'evaluation_preview':i['evaluationPreview'],'graph_validation':{'valid':j['valid'],'hard_violations':j['hardViolations']['map'](w=>({'id':w['id'],'description':w['description'],'fix':w['fixSuggestion']})),'soft_notes':j['softViolations']['map'](w=>({'id':w['id'],'description':w['description']}))},'harness_check':{'module_constraints':m['map'](w=>({'module':w['module'],'plan_satisfied':w['adopted'],'missing':w['missingConstraints'],'reason':w['reason'],'estimated_score_boost':w['estimatedScoreBoost']})),'blocking_issues':q['map'](w=>({'module':w['module'],'missing_constraints':w['missingConstraints'],'fix':w['reason']})),'deploy_time_checks':n,'recipient_design_guidance':p},'game_theory':{'summary':r['summary'],'coverage':r['coveredCount']+'/'+r['totalCount'],'exposed_scenarios':r['exposedScenarios'],'wow_alignments':r['wowAlignments'],'scenarios':r['results']['map'](w=>({'scenario':w['scenario'],'covered':w['covered'],'conflict':w['conflict'],'user_protection':w['userProtection'],'evaluation_metric':w['evaluationMetric'],'recommendation':w['recommendation']}))},'workflow_design_assessment':{'score':s['score'],'summary':s['summary'],'findings':s['findings']['map'](w=>({'kind':w['kind'],'severity':w['severity'],'message':w['message'],'fix':w['fix']})),'checks':s['checks']['map'](w=>({'id':w['id'],'dimension':w['dimension'],'passed':w['passed'],'severity':w['severity'],'message':w['message'],'fix':w['fix']}))},'creation_plan':t,'post_deploy_steps':o,'warnings':e['warnings'],'next_action':q['length']>0x0?'Resolve\x20the\x20blocking_issues\x20above\x20(adjust\x20guide_confirm\x20payment/trust/modules,\x20or\x20accept\x20and\x20drop\x20the\x20affected\x20module\x20via\x20guide_confirm.adopted_module_ids),\x20then\x20call\x20merchant_guide\x20again.':'Plan\x20ready.\x20Materialize:\x20create\x20the\x20objects\x20in\x20creation_plan\x20order\x20via\x20onchain_operations,\x20then\x20run\x20post_deploy_steps\x20in\x20order\x20(compensation\x20fund\x20top-up,\x20arbitration\x20unpause,\x20per-order\x20settlement\x20via\x20alloc_by_guard).'};}export function listBusinessModules(){return CORE_BUSINESS_MODULES['map'](a=>({'id':a['id'],'name':a['name'],'description':a['description'],'industry_fit':a['industryFit'],'addresses_pain_points':a['addressesPainPoints'],'requires_keeper':a['requiresKeeper']}));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{matchScenarioMode}from'../../knowledge/scenario-modes.js';import{getTemplate,listTemplates}from'../../knowledge/template-loader.js';import{TEMPLATE_KEYWORDS}from'../../knowledge/builtin-templates.js';export function matchTemplate(a){const b=a['toLowerCase'](),{templates:c}=listTemplates(),{mode:e,confidence:f}=matchScenarioMode(a);let g;for(const
|
|
1
|
+
import{matchScenarioMode}from'../../knowledge/scenario-modes.js';import{getTemplate,listTemplates}from'../../knowledge/template-loader.js';import{TEMPLATE_KEYWORDS}from'../../knowledge/builtin-templates.js';function productRefPatterns(a){const b=new Set([a]);return a['includes']('-')&&(b['add'](a['replace'](/-/g,'.')),b['add'](a['replace'](/-/g,'\x20'))),[...b]['map'](c=>new RegExp('\x5cb'+c['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&')+'\x5cb','i'));}export function matchTemplate(a){const b=a['toLowerCase'](),{templates:c}=listTemplates();for(const h of c){if(!h['product_ref'])continue;if(productRefPatterns(h['product_ref'])['some'](i=>i['test'](b)))return{'template':h,'confidence':0x1};}const {mode:e,confidence:f}=matchScenarioMode(a);let g;for(const i of c){const j=TEMPLATE_KEYWORDS[i['id']]??[];let k=0x0;for(const m of j){if(b['includes'](m))k+=0x1;}if(e['name']===i['industry'])k+=f;const l=j['length']+0x1;if(!g||k>g['score'])g={'template':i,'score':k,'max':l};}if(!g||g['score']<=0x0)return undefined;return{'template':g['template'],'confidence':Math['min'](0x1,g['score']/g['max'])};}const RM1_11_NODE_REGEX=/(^|_)(disputed?|arbitration|arb)(_|$)|^(refund|refunded|deposit_refunded|deposit_deducted|cancel|cancelled)$/i;function dryRunRiskCheck(a){const b=[];for(const e of a['machine_shape']){RM1_11_NODE_REGEX['test'](e['name'])&&b['push']('R-M1-11:\x20node\x20\x27'+e['name']+'\x27\x20models\x20dispute/refund\x20flow\x20—\x20must\x20route\x20via\x20Allocator/Arbitration');}a['machine_shape']['length']===0x0&&b['push']('machine_shape\x20is\x20empty\x20—\x20no\x20entry\x20node');const c=a['guards']['some'](f=>f['template_id']['includes']('refund')||f['template_id']['includes']('cancel'))||/refund/i['test'](a['allocator']['description']);!c&&b['push']('R1:\x20no\x20refund\x20path\x20detected\x20(no\x20refund/cancel\x20guard\x20and\x20no\x20refund\x20route\x20in\x20the\x20allocator)');const d=a['guards']['some'](f=>f['host']==='arbitration')||a['trust_mechanisms']['some'](f=>f['startsWith']('R2'));return!d&&b['push']('R2:\x20no\x20independent\x20Arbitration\x20reference\x20detected'),a['keeper_dependencies']['length']===0x0&&b['push']('R9:\x20no\x20keeper\x20dependencies\x20declared\x20for\x20time-driven\x20flows'),{'passed':b['length']===0x0,'findings':b};}function genericMappedEntries(a){return[{'source_element':'Order\x20lifecycle\x20/\x20status\x20flow','target_object':'Machine','mapping_note':a['machine_shape']['length']+'-node\x20workflow\x20adopted\x20from\x20the\x20'+a['id']+'\x20template'},{'source_element':'Business\x20rules\x20and\x20time\x20windows','target_object':'Guard','mapping_note':a['guards']['length']+'\x20guard\x20templates\x20carry\x20the\x20rule\x20parameters\x20as\x20immutable\x20on-chain\x20conditions'},{'source_element':'Payment\x20split\x20/\x20settlement','target_object':'Allocator','mapping_note':a['allocator']['description']},{'source_element':'Refund\x20policy','target_object':'Allocator\x20(refund\x20route)','mapping_note':'Refunds\x20route\x20via\x20Allocators\x20triggered\x20by\x20business\x20states\x20—\x20never\x20Machine\x20terminal\x20nodes\x20(R-M1-11)'},{'source_element':'Dispute\x20resolution','target_object':'Arbitration','mapping_note':'Independent\x20Arbitration\x20object\x20with\x20its\x20own\x20Permission\x20—\x20disputes\x20flow\x20off-Machine'},{'source_element':'Operator\x20roles\x20(staff/fulfiller/finance)','target_object':'Permission','mapping_note':'Role\x20slots\x20as\x20Permission\x20entities;\x20the\x20order\x20payer\x20acts\x20as\x20the\x20named\x20operator\x20without\x20occupying\x20a\x20slot'},{'source_element':'Evidence\x20and\x20records','target_object':'Repository','mapping_note':'Write-guarded\x20Repository\x20policies\x20anchor\x20evidence\x20hashes\x20(delivery,\x20inspection,\x20settlement\x20ledger)'},{'source_element':'Service\x20listing\x20and\x20pricing','target_object':'Service','mapping_note':'Service\x20carries\x20the\x20sale\x20structure,\x20buy\x20gate,\x20and\x20bound\x20Machine/Guards/Arbitration\x20before\x20publish'}];}function genericUnmappedEntries(a){const b=[{'source_element':'Incumbent\x20platform\x20internal\x20ranking\x20/\x20search\x20algorithm','mapping_note':'Marketplace\x20discovery\x20logic\x20has\x20no\x20on-chain\x20equivalent','reason':'Off-chain\x20platform\x20intelligence\x20—\x20use\x20the\x20WoWok\x20market\x20layer\x20(demand\x20matching)\x20instead'},{'source_element':'Incumbent\x20platform\x20user\x20account\x20/\x20login\x20system','mapping_note':'Identity\x20lives\x20in\x20wallets\x20and\x20Passports,\x20not\x20platform\x20accounts','reason':'WoWok\x20is\x20account-less\x20by\x20design\x20—\x20addresses\x20+\x20Passports\x20replace\x20platform\x20logins'},{'source_element':'Automatic\x20recurring\x20charges\x20(card\x20auto-debit)','mapping_note':'Recurring\x20charges\x20are\x20replaced\x20by\x20explicit\x20per-period\x20subscriber\x20signatures','reason':'Silent\x20auto-charge\x20is\x20an\x20anti-pattern\x20on\x20WoWok\x20—\x20renewal\x20requires\x20the\x20payer\x27s\x20signature\x20every\x20period'}];return a['industry']==='subscription'&&b['push']({'source_element':'Content\x20moderation\x20/\x20takedown\x20pipeline','mapping_note':'Only\x20content\x20hashes\x20live\x20on-chain;\x20content\x20bodies\x20stay\x20off-chain','reason':'Content\x20governance\x20is\x20structurally\x20out\x20of\x20scope\x20for\x20on-chain\x20objects\x20—\x20handle\x20it\x20at\x20the\x20hosting\x20layer'}),(a['industry']==='retail'||a['industry']==='rental')&&b['push']({'source_element':'Physical\x20logistics\x20/\x20courier\x20integration','mapping_note':'Logistics\x20stays\x20off-chain;\x20tracking\x20evidence\x20is\x20anchored\x20via\x20WIP\x20hashes','reason':'Carriers\x20are\x20external\x20systems\x20—\x20the\x20Machine\x20consumes\x20their\x20evidence,\x20not\x20their\x20API'}),b;}function manualReviewEntries(a){const b=[{'source_element':'Fee\x20and\x20split\x20parameters','mapping_note':'Template\x20defaults:\x20'+Object['entries'](a['fee_params'])['map'](([c,d])=>c+'='+d)['join'](',\x20'),'reason':'Confirm\x20or\x20override\x20each\x20parameter\x20before\x20generation'},{'source_element':'Operating\x20role','mapping_note':'Recommended:\x20'+a['recommended_role']+'\x20—\x20'+a['role_rationale'],'reason':'The\x20user\x20may\x20switch\x20role\x20(merchant\x20<->\x20supplier)\x20before\x20apply'},{'source_element':'Target\x20network','mapping_note':'Default\x20testnet\x20for\x20the\x20first\x20deployment','reason':'Mainnet\x20deployment\x20requires\x20explicit\x20user\x20confirmation'}];return a['keeper_dependencies']['length']>0x0&&b['push']({'source_element':'Off-chain\x20keeper\x20operations','mapping_note':'Declared\x20keepers:\x20'+a['keeper_dependencies']['join'](';\x20'),'reason':'Time-driven\x20transitions\x20only\x20ALLOW\x20advancement\x20—\x20someone\x20must\x20run\x20the\x20keepers'}),b;}function wowokAdvantages(a){const b=['Every\x20rule\x20is\x20an\x20immutable\x20on-chain\x20Guard\x20—\x20customers\x20can\x20verify\x20the\x20exact\x20policy\x20before\x20paying','Disputes\x20resolve\x20through\x20independent\x20Arbitration\x20with\x20a\x20funded\x20compensation\x20pool','Fund\x20splits\x20execute\x20by\x20contract\x20at\x20the\x20configured\x20release\x20points\x20—\x20no\x20platform\x20discretion'];return a['industry']==='subscription'&&b['push']('Per-period\x20explicit-signature\x20renewal\x20—\x20the\x20anti-auto-renew\x20trap\x20is\x20a\x20selling\x20point'),a['industry']==='freelance'&&b['push']('Chain-verifiable\x200%\x20(or\x20low)\x20commission\x20via\x20the\x20allocator\x20split\x20itself'),a['industry']==='travel'&&b['push']('Two-tier\x20allocation\x20pays\x20each\x20supplier\x20at\x20its\x20own\x20segment\x20release\x20—\x20multi-party\x20transparency'),a['industry']==='education'&&b['push']('Regulatory\x20prepay\x20caps\x20and\x20per-session\x20release\x20protect\x20students\x20from\x20run-away\x20institutions'),a['industry']==='rental'&&b['push']('Deposit\x20escrow\x20+\x20evidence-gated\x20deduction\x20—\x20neither\x20side\x20can\x20unilaterally\x20seize\x20the\x20deposit'),a['industry']==='retail'&&b['push']('Escrow\x20+\x20confirm-on-receipt\x20release\x20—\x20the\x20buyer\x27s\x20confirmation\x20is\x20the\x20only\x20release\x20trigger'),b;}function customizableModules(a){const b=['independent_arbitration','refund_guarantee','reputation_on_chain','wip_provenance'];switch(a['industry']){case'freelance':return[...b,'milestone_escrow','accept_timeout_protection'];case'rental':return[...b,'damage_attestation'];case'education':return[...b,'accept_timeout_protection'];case'travel':return[...b,'multi_tier_allocation','supplier_collaboration'];case'subscription':return[...b,'subscription_with_proof'];case'retail':return[...b,'accept_timeout_protection'];default:return b;}}export function planMigration(a){let b;if(a['template_id']){b=getTemplate(a['template_id']);if(b&&a['industry']&&b['industry']!==a['industry']){const c=matchTemplate(a['industry']+'\x20'+a['description']);if(c&&c['template']['industry']===a['industry'])b=c['template'];}}else{const d=a['industry']?a['industry']+'\x20'+a['description']:a['description'],e=matchTemplate(d);b=e?.['template'],!b&&a['industry']&&(b=listTemplates()['templates']['find'](f=>f['industry']===a['industry']&&f['archetype']==='leader'));}if(!b)return undefined;return{'source':{'url':a['url'],'description':a['description'],'detected_industry':b['industry'],'matched_template':b['id']},'mapped':genericMappedEntries(b),'unmapped':genericUnmappedEntries(b),'manual_review':manualReviewEntries(b),'wowok_advantages':wowokAdvantages(b),'customizable_modules':customizableModules(b),'role_assessment':{'recommended':b['recommended_role'],'rationale':b['role_rationale'],'alternatives':['merchant','supplier','both']['filter'](f=>f!==b['recommended_role'])},'risk_check':dryRunRiskCheck(b),'network':a['network']??'testnet'};}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type MetricType, type MetricScale, type ConstraintRule, type ConstraintSeverity, type ConstraintViolationAction } from "../../extensions/index.js";
|
|
2
|
+
import type { IndustryTraits } from "../../knowledge/industry-registry.js";
|
|
2
3
|
import { type InfrastructureLever } from "../../persona/strategy-intent.js";
|
|
3
4
|
import type { LocationSensitivity } from "../../evaluation/location-match.js";
|
|
4
5
|
export declare const LOCAL_MODE_OWNER = "local";
|
|
@@ -11,15 +12,21 @@ export interface RecommendIndustryInput {
|
|
|
11
12
|
export declare function handleRecommendIndustry(v: RecommendIndustryInput): {
|
|
12
13
|
action: "recommend_industry";
|
|
13
14
|
intent: string;
|
|
14
|
-
inferred_traits:
|
|
15
|
+
inferred_traits: IndustryTraits;
|
|
15
16
|
inference_confidence: number;
|
|
16
17
|
matched_keywords: string[];
|
|
18
|
+
domain_priors: import("../../knowledge/industry-generalizer.js").DomainPriorMatch[];
|
|
17
19
|
strategy_intents: import("../../persona/strategy-intent.js").StrategyIntent[];
|
|
18
20
|
lever_suggestions: import("../../persona/strategy-intent.js").LeverSuggestion[];
|
|
19
21
|
recommendations: {
|
|
20
22
|
industry: string;
|
|
21
23
|
similarity: number;
|
|
24
|
+
trait_distance: number | undefined;
|
|
22
25
|
matched_traits: string[];
|
|
26
|
+
contradicted_traits: string[];
|
|
27
|
+
evidenced_traits: string[];
|
|
28
|
+
domain_prior: boolean | undefined;
|
|
29
|
+
requirement_support: number | undefined;
|
|
23
30
|
location_sensitivity: LocationSensitivity;
|
|
24
31
|
trust_selling_points: string[];
|
|
25
32
|
build_notes: string[];
|
|
@@ -29,6 +36,10 @@ export declare function handleRecommendIndustry(v: RecommendIndustryInput): {
|
|
|
29
36
|
missing_levers: InfrastructureLever[];
|
|
30
37
|
} | undefined;
|
|
31
38
|
}[];
|
|
39
|
+
excluded_by_consistency: {
|
|
40
|
+
industry: string;
|
|
41
|
+
contradicted_requirements: string[];
|
|
42
|
+
}[];
|
|
32
43
|
hint: string;
|
|
33
44
|
};
|
|
34
45
|
export declare function handleListModes(): Promise<{
|
|
@@ -39,6 +50,7 @@ export declare function handleListModes(): Promise<{
|
|
|
39
50
|
version: string;
|
|
40
51
|
key_risk: string;
|
|
41
52
|
machine_nodes: string[];
|
|
53
|
+
buyer_action_nodes: string[];
|
|
42
54
|
similar_industries: string[];
|
|
43
55
|
location_sensitivity: LocationSensitivity;
|
|
44
56
|
trust_selling_points: string[];
|
|
@@ -51,6 +63,7 @@ export declare function handleListModes(): Promise<{
|
|
|
51
63
|
derived_from: string | null;
|
|
52
64
|
key_risk: string;
|
|
53
65
|
machine_nodes: string[];
|
|
66
|
+
buyer_action_nodes: string[];
|
|
54
67
|
location_sensitivity: LocationSensitivity;
|
|
55
68
|
trust_selling_points: string[];
|
|
56
69
|
build_notes: string[];
|
|
@@ -79,6 +92,7 @@ export declare function handleDeriveUserMode(v: DeriveUserModeInput): Promise<{
|
|
|
79
92
|
owner: string;
|
|
80
93
|
key_risk: string;
|
|
81
94
|
machine_nodes: string[];
|
|
95
|
+
buyer_action_nodes: string[];
|
|
82
96
|
location_sensitivity: LocationSensitivity;
|
|
83
97
|
trust_selling_points: string[];
|
|
84
98
|
build_notes: string[];
|
|
@@ -106,6 +120,7 @@ export declare function handleEvolveUserMode(v: EvolveUserModeInput): Promise<{
|
|
|
106
120
|
owner: string;
|
|
107
121
|
key_risk: string;
|
|
108
122
|
machine_nodes: string[];
|
|
123
|
+
buyer_action_nodes: string[];
|
|
109
124
|
location_sensitivity: LocationSensitivity;
|
|
110
125
|
trust_selling_points: string[];
|
|
111
126
|
build_notes: string[];
|
|
@@ -132,6 +147,7 @@ export declare function handleRegisterUserMode(v: RegisterUserModeInput): Promis
|
|
|
132
147
|
owner: string;
|
|
133
148
|
key_risk: string;
|
|
134
149
|
machine_nodes: string[];
|
|
150
|
+
buyer_action_nodes: string[];
|
|
135
151
|
location_sensitivity: LocationSensitivity;
|
|
136
152
|
trust_selling_points: string[];
|
|
137
153
|
build_notes: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getIndustryModeRegistry,getMetricRegistry,getConstraintRegistry}from'../../extensions/index.js';import{inferTraitsFromDescription,findSimilarIndustries}from'../../knowledge/industry-generalizer.js';import{resolveObjective,buildStrategyIntent,suggestLevers}from'../../persona/strategy-intent.js';export const LOCAL_MODE_OWNER='local';function locationSensitivity(a){if(a['has_logistics'])return'logistics';if(a['pure_digital'])return'near';return'strict';}const RM1_11_NODE_REGEX=/(^|_)(disputed?|refund(?:ed)?|arbitration|arb)(_|$)/i;function validateMachineShape(a,b){const c=[];if(!Array['isArray'](a))return c;const d=new Set();for(const e of a){const f=e?.['name'];if(typeof f!=='string'||!f){c['push'](b+':\x20every\x20node\x20must\x20have\x20a\x20non-empty\x20string\x20\x27name\x27');continue;}d['has'](f)&&c['push'](b+':\x20duplicate\x20node\x20name\x20\x27'+f+'\x27\x20(R-M1-10)'),d['add'](f),RM1_11_NODE_REGEX['test'](f)&&c['push'](b+':\x20node\x20\x27'+f+'\x27\x20violates\x20R-M1-11\x20—\x20dispute/refund\x20flows\x20must\x20NOT\x20be\x20'+'modeled\x20as\x20Machine\x20nodes.\x20Disputes\x20flow\x20through\x20Service.arbitrations\x20→\x20Arbitration.dispute()\x20'+'independently\x20of\x20the\x20Machine.\x20Use\x20business-state\x20nodes\x20(e.g.\x20\x27cancelled\x27,\x20\x27return_approved\x27)\x20'+'and\x20route\x20fund\x20refunds\x20via\x20Allocator\x20triggered\x20by\x20those\x20states.');}return c;}function modeLevers(a){const b=[];return(a['capabilities_used']['some'](d=>d['startsWith']('reward.'))||a['flywheel']?.['rewardStrategy']&&a['flywheel']['rewardStrategy']!=='User-defined')&&b['push']('reward'),(a['flywheel']?.['discountStrategy']&&a['flywheel']['discountStrategy']!=='User-defined'||a['config_overrides']?.['service']?.['first_order_discount']===!![])&&b['push']('discount'),(a['capabilities_used']['includes']('guard.validate_buy')||a['guards']['some'](c=>c['template_id']['includes']('buy')))&&b['push']('buy_guard'),a['capabilities_used']['includes']('machine.node_topology')&&a['machine_shape']['length']>0x0&&b['push']('machine_design'),b;}function resolveStrategyObjectives(a){const b=typeof a==='string'?[a]:a??[],c=new Set();for(const d of b){const e=resolveObjective(d);if(e)c['add'](e);}return[...c];}export function handleRecommendIndustry(a){const b=(a['intent']??a['project_description']??a['project_name']??'')['trim']();if(!b)throw new Error('recommend_industry\x20requires\x20\x27intent\x27\x20(business\x20description\x20text).\x20'+'Example:\x20intent=\x27I\x20rent\x20cameras\x20to\x20photographers\x20with\x20deposit\x20and\x20damage\x20inspection\x27.');const c=inferTraitsFromDescription(b),d=findSimilarIndustries(c['traits'],0x3),e=resolveStrategyObjectives(a['strategy']),f=e['map'](k=>buildStrategyIntent(k)),g=[...new Set(f['flatMap'](k=>k['levers']))],h=getIndustryModeRegistry(),i=d['map'](k=>{const l=h['getMode'](k['industry']),n=l?modeLevers(l):[],o=g['filter'](q=>n['includes'](q)),p=g['length']>0x0?{'score':o['length']/g['length'],'matched_levers':o,'missing_levers':g['filter'](q=>!n['includes'](q))}:undefined;return{'industry':k['industry'],'similarity':k['similarity'],'matched_traits':k['matched_traits'],'location_sensitivity':l?locationSensitivity(l['traits']):'strict','trust_selling_points':l?l['flywheel']?.['trustSellingPoints']??[]:[],'build_notes':l?.['build_notes']??[],'strategy_alignment':p};});g['length']>0x0&&i['sort']((k,l)=>{const m=k['similarity']*0.7+(k['strategy_alignment']?.['score']??0x0)*0.3,n=l['similarity']*0.7+(l['strategy_alignment']?.['score']??0x0)*0.3;return n-m;});const j=i[0x0];return{'action':'recommend_industry','intent':b,'inferred_traits':c['traits'],'inference_confidence':c['confidence'],'matched_keywords':c['matched_keywords'],'strategy_intents':f,'lever_suggestions':f['flatMap'](k=>suggestLevers(k)),'recommendations':i,'hint':j?'Top\x20match:\x20\x27'+j['industry']+'\x27\x20(similarity\x20'+(j['similarity']*0x64)['toFixed'](0x0)+'%'+(g['length']>0x0?',\x20strategy\x20alignment\x20'+((j['strategy_alignment']?.['score']??0x0)*0x64)['toFixed'](0x0)+'%':'')+').\x20Use\x20it\x20to\x20shape\x20the\x20build\x20—\x20run\x20goal_operation\x20action=\x27merchant_guide\x27\x20(or\x20\x27analyze_intent\x27)\x20with\x20this\x20industry\x20context,\x20'+'or\x20choose\x20another\x20industry\x20from\x20\x27recommendations\x27.':'No\x20similar\x20industry\x20found.\x20Shape\x20the\x20build\x20from\x20scratch\x20via\x20goal_operation\x20action=\x27merchant_guide\x27.'};}export async function handleListModes(){const a=getIndustryModeRegistry(),b=a['listModes']()['filter'](d=>d['source']==='builtin')['map'](d=>({'name':d['name'],'display_name':d['display_name'],'version':d['version'],'key_risk':d['key_risk'],'machine_nodes':d['machine_shape']['map'](e=>e['name']),'similar_industries':d['similar_industries']??[],'location_sensitivity':locationSensitivity(d['traits']),'trust_selling_points':d['flywheel']?.['trustSellingPoints']??[],'build_notes':d['build_notes']??[]})),c=(await a['listUserModes'](LOCAL_MODE_OWNER))['map'](d=>({'name':d['name'],'display_name':d['display_name'],'version':d['version'],'derived_from':d['derived_from']??null,'key_risk':d['key_risk'],'machine_nodes':d['machine_shape']['map'](e=>e['name']),'location_sensitivity':locationSensitivity(d['traits']),'trust_selling_points':d['flywheel']?.['trustSellingPoints']??[],'build_notes':d['build_notes']??[],'evolution_history':(d['evolution_history']??[])['map'](e=>({'version':e['version'],'changed_at':e['changed_at'],'changes':e['changes']}))}));return{'action':'list_modes','builtin_modes':b,'user_modes':c,'owner':LOCAL_MODE_OWNER,'hint':'Use\x20a\x20builtin\x20mode\x20name\x20as\x20the\x20industry/mode\x20context\x20for\x20your\x20build\x20(see\x20recommend_industry\x20/\x20merchant_guide).\x20'+'Use\x20derive_user_mode\x20to\x20customize\x20a\x20builtin\x20mode,\x20or\x20register_user_mode\x20for\x20a\x20fully\x20custom\x20mode.\x20'+'User\x20modes\x20are\x20referenced\x20as\x20\x27<name>\x27\x20in\x20derive/evolve/unregister\x20actions.'};}export async function handleDeriveUserMode(a){const b=requireField(a['mode_source'],'mode_source'),c=requireField(a['mode_name'],'mode_name'),d=a['mode_changes']??{},e=validateMachineShape(d['machine_shape'],'mode_changes.machine_shape');if(e['length']>0x0)throw new Error('derive_user_mode\x20blocked:\x0a'+e['join']('\x0a'));const f=getIndustryModeRegistry(),g=await f['deriveMode'](b,d,LOCAL_MODE_OWNER,c,a['mode_display_name']);if(!g)throw new Error('derive_user_mode\x20failed:\x20source\x20mode\x20\x27'+b+'\x27\x20not\x20found,\x20or\x20name\x20\x27'+c+'\x27\x20conflicts\x20'+'with\x20a\x20builtin/existing\x20user\x20mode.\x20Call\x20list_modes\x20to\x20see\x20available\x20names.');return{'action':'derive_user_mode','mode':summarizeUserMode(g),'hint':'Mode\x20\x27'+c+'\x27\x20derived\x20from\x20\x27'+b+'\x27.\x20Use\x20it\x20as\x20the\x20industry/mode\x20context\x20for\x20your\x20build.\x20'+'Iterate\x20with\x20evolve_user_mode.'};}export async function handleEvolveUserMode(a){const b=requireField(a['mode_name'],'mode_name'),c=requireField(a['mode_change_description'],'mode_change_description'),d=a['mode_changes']??{},e=validateMachineShape(d['machine_shape'],'mode_changes.machine_shape');if(e['length']>0x0)throw new Error('evolve_user_mode\x20blocked:\x0a'+e['join']('\x0a'));const f=getIndustryModeRegistry(),g=await f['evolveMode'](b,d,LOCAL_MODE_OWNER,c,a['mode_bump_version']??!![]);if(!g)throw new Error('evolve_user_mode\x20failed:\x20user\x20mode\x20\x27'+b+'\x27\x20not\x20found\x20for\x20owner\x20\x27'+LOCAL_MODE_OWNER+'\x27.\x20'+'Call\x20list_modes\x20to\x20see\x20your\x20modes.');return{'action':'evolve_user_mode','mode':summarizeUserMode(g),'hint':'Mode\x20\x27'+b+'\x27\x20evolved\x20to\x20'+g['version']+'.\x20Evolution\x20history\x20recorded.'};}export async function handleRegisterUserMode(a){const b=requireField(a['mode_name'],'mode_name'),c=a['mode_changes']??{},d=[];(!Array['isArray'](c['machine_shape'])||c['machine_shape']['length']===0x0)&&d['push']('machine_shape\x20(non-empty\x20array\x20of\x20{name,\x20role})');(typeof c['key_risk']!=='string'||!c['key_risk'])&&d['push']('key_risk\x20(string\x20describing\x20the\x20industry\x27s\x20key\x20risk)');if(d['length']>0x0)throw new Error('register_user_mode\x20requires\x20these\x20fields\x20in\x20mode_changes:\x20'+d['join'](',\x20')+'.\x20'+'Tip:\x20derive_user_mode\x20from\x20a\x20builtin\x20mode\x20is\x20usually\x20easier\x20than\x20registering\x20from\x20scratch.');const e=validateMachineShape(c['machine_shape'],'mode_changes.machine_shape');if(e['length']>0x0)throw new Error('register_user_mode\x20blocked:\x0a'+e['join']('\x0a'));const f=getIndustryModeRegistry(),g=f['getMode']('general');if(!g)throw new Error('Builtin\x20mode\x20\x27general\x27\x20not\x20registered\x20—\x20cannot\x20build\x20custom\x20mode\x20defaults');const h={...g,...c,'name':b,'display_name':a['mode_display_name']??b,'version':'v1','source':'custom','owner':LOCAL_MODE_OWNER,'derived_from':undefined,'evolution_history':[]},i=await f['registerUserMode'](h,LOCAL_MODE_OWNER);if(!i)throw new Error('register_user_mode\x20failed:\x20name\x20\x27'+b+'\x27\x20conflicts\x20with\x20a\x20builtin/existing\x20user\x20mode,\x20'+'or\x20payload\x20is\x20invalid.\x20Call\x20list_modes\x20to\x20see\x20available\x20names.');return{'action':'register_user_mode','mode':summarizeUserMode(h),'hint':'Custom\x20mode\x20\x27'+b+'\x27\x20registered.\x20Use\x20it\x20as\x20the\x20industry/mode\x20context\x20for\x20your\x20build.'};}export async function handleUnregisterUserMode(a){const b=requireField(a['mode_name'],'mode_name'),c=getIndustryModeRegistry(),d=await c['unregisterUserMode'](b,LOCAL_MODE_OWNER);if(!d)throw new Error('unregister_user_mode\x20failed:\x20user\x20mode\x20\x27'+b+'\x27\x20not\x20found\x20for\x20owner\x20\x27'+LOCAL_MODE_OWNER+'\x27.');return{'action':'unregister_user_mode','removed':!![],'mode_name':b};}export async function handleRegisterCustomMetric(a){const b=requireField(a['metric_id'],'metric_id'),c=requireField(a['metric_display_name'],'metric_display_name'),d=requireField(a['metric_description'],'metric_description'),e=requireField(a['metric_type'],'metric_type'),f=requireField(a['metric_scale'],'metric_scale'),g=await getMetricRegistry()['registerCustomMetric'](b,c,d,e,f,LOCAL_MODE_OWNER,a['metric_weight']);if(!g)throw new Error('register_custom_metric\x20failed:\x20metric_id\x20\x27'+b+'\x27\x20already\x20exists\x20or\x20fields\x20are\x20invalid.');return{'action':'register_custom_metric','metric':{'metric_id':b,'display_name':c,'description':d,'type':e,'scale':f,'weight':a['metric_weight']??0x1,'scope':'custom','owner':LOCAL_MODE_OWNER},'hint':'Custom\x20metric\x20\x27'+b+'\x27\x20registered\x20globally\x20and\x20persisted\x20(survives\x20restart)\x20—\x20all\x20modes\x20reference\x20it\x20in\x20evaluation.'};}export async function handleUnregisterCustomMetric(a){const b=requireField(a['metric_id'],'metric_id'),c=await getMetricRegistry()['unregisterMetric'](b,LOCAL_MODE_OWNER);if(!c)throw new Error('unregister_custom_metric\x20failed:\x20custom\x20metric\x20\x27'+b+'\x27\x20not\x20found\x20(builtin\x20metrics\x20cannot\x20be\x20deleted).\x20'+'Call\x20list_metrics_constraints\x20with\x20scope_filter=\x27custom\x27\x20to\x20see\x20deletable\x20metrics.');return{'action':'unregister_custom_metric','removed':!![],'metric_id':b};}export async function handleRegisterCustomConstraint(a){const b=requireField(a['constraint_id'],'constraint_id'),c=requireField(a['constraint_display_name'],'constraint_display_name'),d=requireField(a['constraint_description'],'constraint_description'),e=a['constraint_rule'];if(!e||typeof e!=='object'||!('type'in e))throw new Error('constraint_rule\x20is\x20required\x20and\x20must\x20be\x20one\x20of:\x20'+'{type:\x27capability_required\x27,\x20capability_id}\x20|\x20{type:\x27capability_forbidden\x27,\x20capability_id}\x20|\x20'+'{type:\x27numeric_limit\x27,\x20field,\x20max?,\x20min?}\x20|\x20{type:\x27condition_required\x27,\x20condition,\x20ai_evaluated:true}');const f=await getConstraintRegistry()['registerCustomConstraint'](b,c,d,e,LOCAL_MODE_OWNER,a['constraint_severity']??'soft',a['constraint_on_violation']??'warn');if(!f)throw new Error('register_custom_constraint\x20failed:\x20constraint_id\x20\x27'+b+'\x27\x20already\x20exists\x20or\x20rule\x20is\x20invalid.');return{'action':'register_custom_constraint','constraint':{'constraint_id':b,'display_name':c,'description':d,'rule':e,'severity':a['constraint_severity']??'soft','on_violation':a['constraint_on_violation']??'warn','scope':'custom','owner':LOCAL_MODE_OWNER},'hint':'Custom\x20constraint\x20\x27'+b+'\x27\x20registered\x20and\x20persisted\x20(survives\x20restart).\x20\x27hard\x27\x20constraints\x20mark\x20a\x20mode\x20not\x20applicable\x20on\x20violation;\x20\x27soft\x27\x20only\x20warn.'};}export async function handleUnregisterCustomConstraint(a){const b=requireField(a['constraint_id'],'constraint_id'),c=await getConstraintRegistry()['unregisterConstraint'](b,LOCAL_MODE_OWNER);if(!c)throw new Error('unregister_custom_constraint\x20failed:\x20custom\x20constraint\x20\x27'+b+'\x27\x20not\x20found\x20(builtin\x20constraints\x20cannot\x20be\x20deleted).\x20'+'Call\x20list_metrics_constraints\x20with\x20scope_filter=\x27custom\x27\x20to\x20see\x20deletable\x20constraints.');return{'action':'unregister_custom_constraint','removed':!![],'constraint_id':b};}export async function handleListMetricsConstraints(a){const b=(await getMetricRegistry()['listMetrics']({'type':a['metric_type_filter'],'scope':a['scope_filter']}))['map'](d=>({'metric_id':d['metric_id'],'display_name':d['display_name'],'description':d['description'],'type':d['type'],'scale':d['scale'],'weight':d['weight'],'scope':d['scope']})),c=(await getConstraintRegistry()['listConstraints']({'scope':a['scope_filter']}))['map'](d=>({'constraint_id':d['constraint_id'],'display_name':d['display_name'],'description':d['description'],'rule':d['rule'],'severity':d['severity'],'on_violation':d['on_violation'],'scope':d['scope']}));return{'action':'list_metrics_constraints','metrics':b,'constraints':c,'hint':'Register\x20custom\x20entries\x20via\x20register_custom_metric\x20/\x20register_custom_constraint;\x20'+'delete\x20via\x20unregister_custom_metric\x20/\x20unregister_custom_constraint\x20(custom\x20only).\x20'+'Custom\x20entries\x20are\x20persisted\x20and\x20survive\x20restart.\x20'+'Filter\x20with\x20metric_type_filter\x20(\x27risk\x27|\x27benefit\x27)\x20or\x20scope_filter\x20(\x27builtin\x27|\x27custom\x27).'};}function requireField(a,b){if(a===undefined||a===null||typeof a==='string'&&!a['trim']())throw new Error('\x27'+b+'\x27\x20is\x20required\x20for\x20this\x20action');return a;}function summarizeUserMode(a){return{'name':a['name'],'display_name':a['display_name'],'version':a['version'],'derived_from':a['derived_from']??null,'owner':a['owner'],'key_risk':a['key_risk'],'machine_nodes':a['machine_shape']['map'](b=>b['name']),'location_sensitivity':locationSensitivity(a['traits']),'trust_selling_points':a['flywheel']?.['trustSellingPoints']??[],'build_notes':a['build_notes']??[],'evolution_history':(a['evolution_history']??[])['map'](b=>({'version':b['version'],'changed_at':b['changed_at'],'changes':b['changes']}))};}
|
|
1
|
+
import{getIndustryModeRegistry,getMetricRegistry,getConstraintRegistry}from'../../extensions/index.js';import{inferTraitsFromDescription,findSimilarIndustries,detectDomainPriors,filterConsistentIndustries}from'../../knowledge/industry-generalizer.js';import{resolveObjective,buildStrategyIntent,suggestLevers}from'../../persona/strategy-intent.js';export const LOCAL_MODE_OWNER='local';function locationSensitivity(a){if(a['has_logistics'])return'logistics';if(a['pure_digital'])return'near';return'strict';}const RM1_11_NODE_REGEX=/(^|_)(disputed?|arbitration|arb)(_|$)|^(refund|refunded|deposit_refunded|deposit_deducted|cancel|cancelled)$/i;function validateMachineShape(a,b){const c=[];if(!Array['isArray'](a))return c;const d=new Set();for(const e of a){const f=e?.['name'];if(typeof f!=='string'||!f){c['push'](b+':\x20every\x20node\x20must\x20have\x20a\x20non-empty\x20string\x20\x27name\x27');continue;}d['has'](f)&&c['push'](b+':\x20duplicate\x20node\x20name\x20\x27'+f+'\x27\x20(R-M1-10)'),d['add'](f),RM1_11_NODE_REGEX['test'](f)&&c['push'](b+':\x20node\x20\x27'+f+'\x27\x20violates\x20R-M1-11\x20—\x20dispute/refund\x20flows\x20must\x20NOT\x20be\x20'+'modeled\x20as\x20Machine\x20nodes.\x20Disputes\x20flow\x20through\x20Service.arbitrations\x20→\x20Arbitration.dispute()\x20'+'independently\x20of\x20the\x20Machine.\x20Use\x20business-state\x20nodes\x20(e.g.\x20\x27cancelled\x27,\x20\x27return_approved\x27)\x20'+'and\x20route\x20fund\x20refunds\x20via\x20Allocator\x20triggered\x20by\x20those\x20states.');}return c;}function modeLevers(a){const b=[];return(a['capabilities_used']['some'](d=>d['startsWith']('reward.'))||a['flywheel']?.['rewardStrategy']&&a['flywheel']['rewardStrategy']!=='User-defined')&&b['push']('reward'),(a['flywheel']?.['discountStrategy']&&a['flywheel']['discountStrategy']!=='User-defined'||a['config_overrides']?.['service']?.['first_order_discount']===!![])&&b['push']('discount'),(a['capabilities_used']['includes']('guard.validate_buy')||a['guards']['some'](c=>c['template_id']['includes']('buy')))&&b['push']('buy_guard'),a['capabilities_used']['includes']('machine.node_topology')&&a['machine_shape']['length']>0x0&&b['push']('machine_design'),b;}function resolveStrategyObjectives(a){const b=typeof a==='string'?[a]:a??[],c=new Set();for(const d of b){const e=resolveObjective(d);if(e)c['add'](e);}return[...c];}const TRAIT_OBJECTIVE_PRIORS=[{'when':a=>a['trust_sensitivity']==='high'||a['regulatory_intensity']==='high','objective':'buyer_screening','metrics':['dispute_rate','claim_rate'],'target':'buyer\x20eligibility\x20gate\x20covers\x20every\x20party\x20whose\x20identity\x20the\x20trade\x20depends\x20on'},{'when':a=>a['long_cycle'],'objective':'gross_margin_control','metrics':['acceptance_rate','cycle_days'],'target':'margin\x20held\x20across\x20the\x20full\x20delivery\x20cycle,\x20not\x20per\x20milestone'},{'when':a=>a['consumption_frequency']==='frequent','objective':'sales_priority','metrics':['order_volume','repeat_rate'],'target':'repeat-purchase\x20order\x20volume\x20over\x20the\x20next\x2030\x20days'},{'when':a=>a['avg_ticket_size']==='large'||a['deposit_required'],'objective':'profit_priority','metrics':['gross_margin','escrow_balance'],'target':'per-order\x20margin\x20first;\x20the\x20ticket\x20is\x20large\x20enough\x20that\x20margin\x20dominates\x20volume'},{'when':a=>a['has_logistics'],'objective':'gross_margin_control','metrics':['fulfilment_cost_ratio','on_time_rate'],'target':'fulfilment\x20cost\x20held\x20inside\x20the\x20declared\x20merchant\x20share'}];function traitDerivedObjectives(a,b=0x2){const c=[],d=new Set();for(const e of TRAIT_OBJECTIVE_PRIORS){if(c['length']>=b)break;if(d['has'](e['objective']))continue;if(!e['when'](a))continue;d['add'](e['objective']),c['push']({'objective':e['objective'],'metrics':[...e['metrics']],'target':e['target']});}return c;}export function handleRecommendIndustry(a){const b=(a['intent']??a['project_description']??a['project_name']??'')['trim']();if(!b)throw new Error('recommend_industry\x20requires\x20\x27intent\x27\x20(business\x20description\x20text).\x20'+'Example:\x20intent=\x27I\x20rent\x20cameras\x20to\x20photographers\x20with\x20deposit\x20and\x20damage\x20inspection\x27.');const c=inferTraitsFromDescription(b),d=detectDomainPriors(b),e=new Set(d['flatMap'](y=>y['industries'])),f=new Map();for(const y of d){for(const z of y['industries']){f['set'](z,Math['min'](0.25,(f['get'](z)??0x0)+y['boost']));}}const g=findSimilarIndustries(c['traits'],undefined,{'trait_confidence':c['trait_confidence']}),h=g['map'](A=>{const B=f['get'](A['industry'])??0x0;if(B===0x0)return A;const C=Math['min'](0x1,Number((A['similarity']+B)['toFixed'](0x4)));return{...A,'similarity':C,'trait_distance':Number((0x1-C)['toFixed'](0x4)),'domain_prior':!![]};}),{consistent:i,inconsistent:j}=filterConsistentIndustries(h,c['traits'],c['trait_confidence']),k=j['map'](A=>({'industry':A['industry'],'contradicted_requirements':A['contradictions']['map'](B=>B['trait']+'='+String(B['value'])+'\x20('+B['reason']+')')}));i['sort']((A,B)=>B['similarity']-A['similarity']||A['industry']['localeCompare'](B['industry']));const l=i['slice'](0x0,0x3),m=resolveStrategyObjectives(a['strategy']),n=m['map'](A=>buildStrategyIntent(A)),o=n['length']>0x0||c['confidence']===0x0?[]:traitDerivedObjectives(c['traits'])['map'](A=>buildStrategyIntent(A['objective'],A['target'],A['metrics'])),q=[...n,...o],r=[...new Set(q['flatMap'](A=>A['levers']))],s=getIndustryModeRegistry(),t=l['map'](A=>{const B=s['getMode'](A['industry']),C=B?modeLevers(B):[],D=r['filter'](F=>C['includes'](F)),E=r['length']>0x0?{'score':D['length']/r['length'],'matched_levers':D,'missing_levers':r['filter'](F=>!C['includes'](F))}:undefined;return{'industry':A['industry'],'similarity':A['similarity'],'trait_distance':A['trait_distance'],'matched_traits':A['matched_traits'],'contradicted_traits':A['contradicted_traits']??[],'evidenced_traits':A['evidenced_traits']??[],'domain_prior':e['has'](A['industry'])?!![]:undefined,'requirement_support':A['requirement_support'],'location_sensitivity':B?locationSensitivity(B['traits']):'strict','trust_selling_points':B?B['flywheel']?.['trustSellingPoints']??[]:[],'build_notes':B?.['build_notes']??[],'strategy_alignment':E};});r['length']>0x0&&t['sort']((A,B)=>{const C=A['similarity']*0.7+(A['strategy_alignment']?.['score']??0x0)*0.3,D=B['similarity']*0.7+(B['strategy_alignment']?.['score']??0x0)*0.3;return D-C;});const u=t[0x0],w=d['length']>0x0?'\x20Domain\x20prior\x20applied:\x20'+d['map'](A=>A['domain']+'\x20('+A['matched_keywords']['slice'](0x0,0x6)['join']('/')+')')['join'](';\x20')+'.':'',x=k['length']>0x0?'\x20Excluded\x20'+k['length']+'\x20industry\x20mode(s)\x20whose\x20required\x20traits\x20the\x20inference\x20contradicts:\x20'+k['map'](A=>A['industry']+'\x20['+A['contradicted_requirements']['join'](';\x20')+']')['join']('\x20|\x20')+'.':'';return{'action':'recommend_industry','intent':b,'inferred_traits':c['traits'],'inference_confidence':c['confidence'],'matched_keywords':c['matched_keywords'],'domain_priors':d,'strategy_intents':q,'lever_suggestions':q['flatMap'](A=>suggestLevers(A)),'recommendations':t,'excluded_by_consistency':k,'hint':u?'Top\x20match:\x20\x27'+u['industry']+'\x27\x20(similarity\x20'+(u['similarity']*0x64)['toFixed'](0x0)+'%'+(r['length']>0x0?',\x20strategy\x20alignment\x20'+((u['strategy_alignment']?.['score']??0x0)*0x64)['toFixed'](0x0)+'%':'')+').\x20Use\x20it\x20to\x20shape\x20the\x20build\x20—\x20run\x20goal_operation\x20action=\x27merchant_guide\x27\x20(or\x20\x27analyze_intent\x27)\x20with\x20this\x20industry\x20context,\x20'+'or\x20choose\x20another\x20industry\x20from\x20\x27recommendations\x27.'+w+x:'No\x20similar\x20industry\x20found.\x20Shape\x20the\x20build\x20from\x20scratch\x20via\x20goal_operation\x20action=\x27merchant_guide\x27.'+w};}export async function handleListModes(){const a=getIndustryModeRegistry(),b=a['listModes']()['filter'](d=>d['source']==='builtin')['map'](d=>({'name':d['name'],'display_name':d['display_name'],'version':d['version'],'key_risk':d['key_risk'],'machine_nodes':d['machine_shape']['map'](e=>e['name']),'buyer_action_nodes':d['machine_shape']['filter'](e=>e['operator']==='order_payer')['map'](e=>e['name']),'similar_industries':d['similar_industries']??[],'location_sensitivity':locationSensitivity(d['traits']),'trust_selling_points':d['flywheel']?.['trustSellingPoints']??[],'build_notes':d['build_notes']??[]})),c=(await a['listUserModes'](LOCAL_MODE_OWNER))['map'](d=>({'name':d['name'],'display_name':d['display_name'],'version':d['version'],'derived_from':d['derived_from']??null,'key_risk':d['key_risk'],'machine_nodes':d['machine_shape']['map'](e=>e['name']),'buyer_action_nodes':d['machine_shape']['filter'](e=>e['operator']==='order_payer')['map'](e=>e['name']),'location_sensitivity':locationSensitivity(d['traits']),'trust_selling_points':d['flywheel']?.['trustSellingPoints']??[],'build_notes':d['build_notes']??[],'evolution_history':(d['evolution_history']??[])['map'](e=>({'version':e['version'],'changed_at':e['changed_at'],'changes':e['changes']}))}));return{'action':'list_modes','builtin_modes':b,'user_modes':c,'owner':LOCAL_MODE_OWNER,'hint':'Use\x20a\x20builtin\x20mode\x20name\x20as\x20the\x20industry/mode\x20context\x20for\x20your\x20build\x20(see\x20recommend_industry\x20/\x20merchant_guide).\x20'+'Use\x20derive_user_mode\x20to\x20customize\x20a\x20builtin\x20mode,\x20or\x20register_user_mode\x20for\x20a\x20fully\x20custom\x20mode.\x20'+'User\x20modes\x20are\x20referenced\x20as\x20\x27<name>\x27\x20in\x20derive/evolve/unregister\x20actions.'};}export async function handleDeriveUserMode(a){const b=requireField(a['mode_source'],'mode_source'),c=requireField(a['mode_name'],'mode_name'),d=a['mode_changes']??{},e=validateMachineShape(d['machine_shape'],'mode_changes.machine_shape');if(e['length']>0x0)throw new Error('derive_user_mode\x20blocked:\x0a'+e['join']('\x0a'));const f=getIndustryModeRegistry(),g=await f['deriveMode'](b,d,LOCAL_MODE_OWNER,c,a['mode_display_name']);if(!g)throw new Error('derive_user_mode\x20failed:\x20source\x20mode\x20\x27'+b+'\x27\x20not\x20found,\x20or\x20name\x20\x27'+c+'\x27\x20conflicts\x20'+'with\x20a\x20builtin/existing\x20user\x20mode.\x20Call\x20list_modes\x20to\x20see\x20available\x20names.');return{'action':'derive_user_mode','mode':summarizeUserMode(g),'hint':'Mode\x20\x27'+c+'\x27\x20derived\x20from\x20\x27'+b+'\x27.\x20Use\x20it\x20as\x20the\x20industry/mode\x20context\x20for\x20your\x20build.\x20'+'Iterate\x20with\x20evolve_user_mode.'};}export async function handleEvolveUserMode(a){const b=requireField(a['mode_name'],'mode_name'),c=requireField(a['mode_change_description'],'mode_change_description'),d=a['mode_changes']??{},e=validateMachineShape(d['machine_shape'],'mode_changes.machine_shape');if(e['length']>0x0)throw new Error('evolve_user_mode\x20blocked:\x0a'+e['join']('\x0a'));const f=getIndustryModeRegistry(),g=await f['evolveMode'](b,d,LOCAL_MODE_OWNER,c,a['mode_bump_version']??!![]);if(!g)throw new Error('evolve_user_mode\x20failed:\x20user\x20mode\x20\x27'+b+'\x27\x20not\x20found\x20for\x20owner\x20\x27'+LOCAL_MODE_OWNER+'\x27.\x20'+'Call\x20list_modes\x20to\x20see\x20your\x20modes.');return{'action':'evolve_user_mode','mode':summarizeUserMode(g),'hint':'Mode\x20\x27'+b+'\x27\x20evolved\x20to\x20'+g['version']+'.\x20Evolution\x20history\x20recorded.'};}export async function handleRegisterUserMode(a){const b=requireField(a['mode_name'],'mode_name'),c=a['mode_changes']??{},d=[];(!Array['isArray'](c['machine_shape'])||c['machine_shape']['length']===0x0)&&d['push']('machine_shape\x20(non-empty\x20array\x20of\x20{name,\x20role})');(typeof c['key_risk']!=='string'||!c['key_risk'])&&d['push']('key_risk\x20(string\x20describing\x20the\x20industry\x27s\x20key\x20risk)');if(d['length']>0x0)throw new Error('register_user_mode\x20requires\x20these\x20fields\x20in\x20mode_changes:\x20'+d['join'](',\x20')+'.\x20'+'Tip:\x20derive_user_mode\x20from\x20a\x20builtin\x20mode\x20is\x20usually\x20easier\x20than\x20registering\x20from\x20scratch.');const e=validateMachineShape(c['machine_shape'],'mode_changes.machine_shape');if(e['length']>0x0)throw new Error('register_user_mode\x20blocked:\x0a'+e['join']('\x0a'));const f=getIndustryModeRegistry(),g=f['getMode']('general');if(!g)throw new Error('Builtin\x20mode\x20\x27general\x27\x20not\x20registered\x20—\x20cannot\x20build\x20custom\x20mode\x20defaults');const h={...g,...c,'name':b,'display_name':a['mode_display_name']??b,'version':'v1','source':'custom','owner':LOCAL_MODE_OWNER,'derived_from':undefined,'evolution_history':[]},i=await f['registerUserMode'](h,LOCAL_MODE_OWNER);if(!i)throw new Error('register_user_mode\x20failed:\x20name\x20\x27'+b+'\x27\x20conflicts\x20with\x20a\x20builtin/existing\x20user\x20mode,\x20'+'or\x20payload\x20is\x20invalid.\x20Call\x20list_modes\x20to\x20see\x20available\x20names.');return{'action':'register_user_mode','mode':summarizeUserMode(h),'hint':'Custom\x20mode\x20\x27'+b+'\x27\x20registered.\x20Use\x20it\x20as\x20the\x20industry/mode\x20context\x20for\x20your\x20build.'};}export async function handleUnregisterUserMode(a){const b=requireField(a['mode_name'],'mode_name'),c=getIndustryModeRegistry(),d=await c['unregisterUserMode'](b,LOCAL_MODE_OWNER);if(!d)throw new Error('unregister_user_mode\x20failed:\x20user\x20mode\x20\x27'+b+'\x27\x20not\x20found\x20for\x20owner\x20\x27'+LOCAL_MODE_OWNER+'\x27.');return{'action':'unregister_user_mode','removed':!![],'mode_name':b};}export async function handleRegisterCustomMetric(a){const b=requireField(a['metric_id'],'metric_id'),c=requireField(a['metric_display_name'],'metric_display_name'),d=requireField(a['metric_description'],'metric_description'),e=requireField(a['metric_type'],'metric_type'),f=requireField(a['metric_scale'],'metric_scale'),g=await getMetricRegistry()['registerCustomMetric'](b,c,d,e,f,LOCAL_MODE_OWNER,a['metric_weight']);if(!g)throw new Error('register_custom_metric\x20failed:\x20metric_id\x20\x27'+b+'\x27\x20already\x20exists\x20or\x20fields\x20are\x20invalid.');return{'action':'register_custom_metric','metric':{'metric_id':b,'display_name':c,'description':d,'type':e,'scale':f,'weight':a['metric_weight']??0x1,'scope':'custom','owner':LOCAL_MODE_OWNER},'hint':'Custom\x20metric\x20\x27'+b+'\x27\x20registered\x20globally\x20and\x20persisted\x20(survives\x20restart)\x20—\x20all\x20modes\x20reference\x20it\x20in\x20evaluation.'};}export async function handleUnregisterCustomMetric(a){const b=requireField(a['metric_id'],'metric_id'),c=await getMetricRegistry()['unregisterMetric'](b,LOCAL_MODE_OWNER);if(!c)throw new Error('unregister_custom_metric\x20failed:\x20custom\x20metric\x20\x27'+b+'\x27\x20not\x20found\x20(builtin\x20metrics\x20cannot\x20be\x20deleted).\x20'+'Call\x20list_metrics_constraints\x20with\x20scope_filter=\x27custom\x27\x20to\x20see\x20deletable\x20metrics.');return{'action':'unregister_custom_metric','removed':!![],'metric_id':b};}export async function handleRegisterCustomConstraint(a){const b=requireField(a['constraint_id'],'constraint_id'),c=requireField(a['constraint_display_name'],'constraint_display_name'),d=requireField(a['constraint_description'],'constraint_description'),e=a['constraint_rule'];if(!e||typeof e!=='object'||!('type'in e))throw new Error('constraint_rule\x20is\x20required\x20and\x20must\x20be\x20one\x20of:\x20'+'{type:\x27capability_required\x27,\x20capability_id}\x20|\x20{type:\x27capability_forbidden\x27,\x20capability_id}\x20|\x20'+'{type:\x27numeric_limit\x27,\x20field,\x20max?,\x20min?}\x20|\x20{type:\x27condition_required\x27,\x20condition,\x20ai_evaluated:true}');const f=await getConstraintRegistry()['registerCustomConstraint'](b,c,d,e,LOCAL_MODE_OWNER,a['constraint_severity']??'soft',a['constraint_on_violation']??'warn');if(!f)throw new Error('register_custom_constraint\x20failed:\x20constraint_id\x20\x27'+b+'\x27\x20already\x20exists\x20or\x20rule\x20is\x20invalid.');return{'action':'register_custom_constraint','constraint':{'constraint_id':b,'display_name':c,'description':d,'rule':e,'severity':a['constraint_severity']??'soft','on_violation':a['constraint_on_violation']??'warn','scope':'custom','owner':LOCAL_MODE_OWNER},'hint':'Custom\x20constraint\x20\x27'+b+'\x27\x20registered\x20and\x20persisted\x20(survives\x20restart).\x20\x27hard\x27\x20constraints\x20mark\x20a\x20mode\x20not\x20applicable\x20on\x20violation;\x20\x27soft\x27\x20only\x20warn.'};}export async function handleUnregisterCustomConstraint(a){const b=requireField(a['constraint_id'],'constraint_id'),c=await getConstraintRegistry()['unregisterConstraint'](b,LOCAL_MODE_OWNER);if(!c)throw new Error('unregister_custom_constraint\x20failed:\x20custom\x20constraint\x20\x27'+b+'\x27\x20not\x20found\x20(builtin\x20constraints\x20cannot\x20be\x20deleted).\x20'+'Call\x20list_metrics_constraints\x20with\x20scope_filter=\x27custom\x27\x20to\x20see\x20deletable\x20constraints.');return{'action':'unregister_custom_constraint','removed':!![],'constraint_id':b};}export async function handleListMetricsConstraints(a){const b=(await getMetricRegistry()['listMetrics']({'type':a['metric_type_filter'],'scope':a['scope_filter']}))['map'](d=>({'metric_id':d['metric_id'],'display_name':d['display_name'],'description':d['description'],'type':d['type'],'scale':d['scale'],'weight':d['weight'],'scope':d['scope']})),c=(await getConstraintRegistry()['listConstraints']({'scope':a['scope_filter']}))['map'](d=>({'constraint_id':d['constraint_id'],'display_name':d['display_name'],'description':d['description'],'rule':d['rule'],'severity':d['severity'],'on_violation':d['on_violation'],'scope':d['scope']}));return{'action':'list_metrics_constraints','metrics':b,'constraints':c,'hint':'Register\x20custom\x20entries\x20via\x20register_custom_metric\x20/\x20register_custom_constraint;\x20'+'delete\x20via\x20unregister_custom_metric\x20/\x20unregister_custom_constraint\x20(custom\x20only).\x20'+'Custom\x20entries\x20are\x20persisted\x20and\x20survive\x20restart.\x20'+'Filter\x20with\x20metric_type_filter\x20(\x27risk\x27|\x27benefit\x27)\x20or\x20scope_filter\x20(\x27builtin\x27|\x27custom\x27).'};}function requireField(a,b){if(a===undefined||a===null||typeof a==='string'&&!a['trim']())throw new Error('\x27'+b+'\x27\x20is\x20required\x20for\x20this\x20action');return a;}function summarizeUserMode(a){return{'name':a['name'],'display_name':a['display_name'],'version':a['version'],'derived_from':a['derived_from']??null,'owner':a['owner'],'key_risk':a['key_risk'],'machine_nodes':a['machine_shape']['map'](b=>b['name']),'buyer_action_nodes':a['machine_shape']['filter'](b=>b['operator']==='order_payer')['map'](b=>b['name']),'location_sensitivity':locationSensitivity(a['traits']),'trust_selling_points':a['flywheel']?.['trustSellingPoints']??[],'build_notes':a['build_notes']??[],'evolution_history':(a['evolution_history']??[])['map'](b=>({'version':b['version'],'changed_at':b['changed_at'],'changes':b['changes']}))};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Config,LocalMark,query_objects,query_object_last_updated,objectTypeFromAddress,ObjectType}from'@wowok/wowok';import{batchReadAddressKeyedFields,batchQueryObjectsByIds,fetchObjectLinkerTx,ringWindowSaturated}from'../../graph/onchain/sdk-batch.js';import{formatMoneyAnnotation}from'./facet-money.js';const js=a=>{if(typeof a==='bigint')return a['toString']();if(a&&typeof a==='object'&&!Array['isArray'](a)){const b={};for(const [c,d]of Object['entries'](a)){b[c]=js(d);}return b;}if(Array['isArray'](a))return a['map'](js);return a;},str=a=>a===null||a===undefined?null:String(a),ownerAddr=a=>{if(typeof a==='string')return a;const b=a;if(b&&typeof b==='object'){if(typeof b['AddressOwner']==='string')return b['AddressOwner'];if(typeof b['ObjectOwner']==='string')return b['ObjectOwner'];const c=Object['values'](b)['find'](d=>typeof d==='string'&&d['length']>0x14);if(typeof c==='string')return c;}return null;},num=a=>{if(typeof a==='bigint')return Number(a);if(typeof a==='number')return Number['isFinite'](a)?a:null;if(typeof a==='string'&&a['trim']()!==''){const b=Number(a);return Number['isFinite'](b)?b:null;}return null;},arr=a=>Array['isArray'](a)?a:[];export function coinOfTypeRaw(a){if(typeof a!=='string'||!a)return null;const b=a['match'](/<(.+)>$/),c=b?.[0x1]?.['trim']();return c&&c['includes']('::')?c:null;}const RELATED_PREVIEW_CAP=0x32;async function buildRelatedList(a,b,c,d,e){const f={'key':a,'items':[],'count':0x0,'window_saturated':![],'preview_truncated':![]};if(!a)return f;try{const g=await fetchObjectLinkerTx(a,c,!![]),h=g?.['items']??[];f['window_saturated']=ringWindowSaturated(h['length']);const j=[];for(const k of h){const l=typeof k?.['who']==='string'?k['who']:'';if(!l||l['toLowerCase']()===b['toLowerCase']())continue;let m;try{m=objectTypeFromAddress(l);}catch{}if(!m)continue;j['push']({'address':l,'object_type':m,'time':typeof k?.['time']==='number'?k['time']:null});}f['count']=j['length'],f['items']=j['slice'](-RELATED_PREVIEW_CAP)['reverse'](),f['preview_truncated']=j['length']>f['items']['length'];}catch{d['push']('related:\x20ObjectLinkerTx('+e+')\x20lookup\x20failed');}return f;}const ARB_STATUS_NAMES={0x0:'Principal_confirming',0x1:'Arbitrator_confirming',0x2:'Voting',0x3:'Arbitrated',0x4:'Objectionable',0x5:'Finished',0x6:'Withdrawn'};async function resolveObject(a,b){let c=a;if(!/^0x[0-9a-fA-F]{32,64}$/['test'](c)){const g=await LocalMark['Instance']()['get_address'](c);if(!g)throw new Error('Cannot\x20resolve\x20\x27'+c+'\x27\x20—\x20not\x20a\x20valid\x20address\x20and\x20no\x20LocalMark\x20entry\x20found.');c=g;}let d=b??undefined,f=null;if(!d)d=await Config['Instance']()['network_get']();try{const h=await query_objects({'objects':[c],'network':d});f=h?.['objects']?.[0x0]??null;if(!f&&b){const i=await Config['Instance']()['network_get']();if(i&&i!==d){const j=await query_objects({'objects':[c],'network':i,'no_cache':!![]}),k=j?.['objects']?.[0x0]??null;k&&(f=k,d=i);}}}catch(l){throw new Error('Failed\x20to\x20query\x20'+c+'\x20on\x20'+d+':\x20'+(l instanceof Error?l['message']:String(l)));}if(!f)throw new Error(c+'\x20not\x20found\x20on\x20'+d+'.\x20It\x20may\x20not\x20exist\x20on\x20this\x20network.');return f['object']=f['object']??c,{'network':String(d),'obj':f};}async function resolveHead(a,b,c){let d=null,e=[];try{const f=await LocalMark['Instance']()['list']({'address':a});f['length']>0x0&&(d=f[0x0]['name']??null,e=(f[0x0]['tags']??[])['map'](g=>String(g)));}catch{c['push']('head:\x20LocalMark\x20lookup\x20failed');}return{'name':d,'tags':e,'description':str(b['description'])};}async function buildPresenters(a,b,c){const d=[];let e=0x0,f=![];try{const g=await fetchObjectLinkerTx(a,b,!![]),h=Array['isArray'](g?.['items'])?g['items']:[];f=ringWindowSaturated(h['length']);const i=h['map'](l=>({'service':String(l?.['who']??''),'time':typeof l?.['time']==='number'?l['time']:null}))['filter'](l=>objectTypeFromAddress(l['service'])===ObjectType['Service']);e=i['length'];const j=i['slice'](-0x32)['reverse'](),k=await batchReadAddressKeyedFields(a,j['map'](l=>l['service']),b,!![]);for(const l of j){const m=k['get'](l['service']['toLowerCase']());d['push']({'service':l['service'],'recommend':str(m?.['recommend']),'acceptance_score':num(m?.['acceptance_score']),'feedback':str(m?.['feedback']),'feedback_time':num(m?.['feedback_time']),'update_time':num(m?.['update_time'])??l['time']});}}catch{c['push']('presenters:\x20global-table\x20lookup\x20failed\x20(non-blocking)');}return{'count':e,'window_saturated':f,'preview_truncated':e>d['length'],'items':d};}async function buildRepositoryData(a,b,c){return void a,void b,c['push']('data:\x20per-key\x20enumeration\x20requires\x20the\x20{entity,name}\x20pair\x20—\x20showing\x20count\x20only'),{'count':null,'items':[]};}export async function handleObjectPanorama(b){const c=b['object_address']??b['filter'];if(!c)throw new Error('\x27object_address\x27\x20is\x20required\x20for\x20object_panorama\x20(a\x20LocalMark\x20NAME\x20is\x20also\x20accepted).\x20Example:\x20{\x22query_type\x22:\x20\x22object_panorama\x22,\x20\x22object_address\x22:\x20\x220x...\x22}');const {network:e,obj:f}=await resolveObject(c,b['context_network']),g=String(f['object']),h=[],j=await resolveHead(g,f,h),k=String(f['type']??'');if(k==='Progress'){const l=arr(f['session'])[0x0],m=l?{'next_node':str(l['next_node']),'weights':num(l['weights']),'threshold':num(l['threshold']),'forwards':arr(l['forwards'])['map'](q=>{const r=q;return{'forward':str(r['forward'])??'','who':str(r['who']),'accomplished':r['accomplished']===!![],'msg':str(r['msg']),'time':num(r['time'])};})}:null,n=await buildRelatedList(typeof f['machine']==='string'?f['machine']:null,g,e,h,'machine');return{'action':'object_panorama','object':g,'object_type':'Progress','network':e,'head':j,'fields':{'machine':str(f['machine']),'current':str(f['current']),'task':str(f['task']),'history_count':num(f['history_count']),'current_time':num(f['current_time'])},'context_repositories':arr(f['context_repositories'])['map'](q=>String(q)),'operators':arr(f['namedOperator'])['map'](q=>{const r=q;return{'name':str(r['name'])??'','operators':arr(r['operators'])['map'](t=>String(t))};}),'session':m,'related':n,'data_gaps':h};}if(k==='Demand')return{'action':'object_panorama','object':g,'object_type':'Demand','network':e,'head':j,'fields':{'location':str(f['location']),'um':str(f['um']),'permission':str(f['permission']),'presenters_count':num(f['presenters_count'])},'rewards':arr(f['rewards'])['map'](q=>String(q)),'guards':arr(f['guards'])['map'](q=>({'guard':str(q['guard'])??''})),'presenters':await buildPresenters(g,e,h),'data_gaps':h};if(k==='Order'){let q=null;try{const F=await query_object_last_updated({'object':g,'network':e,'previous_transaction':str(f['previousTransaction'])});q=F?.['timestamp_ms']?Number(F['timestamp_ms'])||null:null;}catch{}let r='none',t=null,u=null;const w=str(f['allocation']),x=str(f['progress']),y=str(f['service']),z=[w,x,y]['filter'](G=>!!G);let A=null;if(z['length']>0x0)try{const G=await query_objects({'objects':z,'network':e}),H=G?.['objects']??[];if(w){r='pending';const I=H['find'](K=>K?.['object']===w),J=Number(I?.['balance']??NaN);if(Number['isFinite'](J)&&J===0x0)r='allocated';}if(x){const K=H['find'](L=>L?.['object']===x);t=str(K?.['current']),u=num(K?.['current_time']);}if(y){const L=H['find'](M=>M?.['object']===y);A=coinOfTypeRaw(L?.['type_raw']??L?.['type']);}}catch{}const B=await buildRelatedList(g,g,e,h,'order'),C=str(f['amount']),D=await formatMoneyAnnotation(C,A,e),E=await Promise['all'](arr(f['items'])['map'](async M=>{const N=M,O=str(N['price']),P=await formatMoneyAnnotation(O,A,e);return{'name':str(N['name']),'price':O,'price_display':P['display'],'price_tip':P['tip'],'quantity':str(N['quantity']),'wip_hash':str(N['wip_hash'])};}));return{'action':'object_panorama','object':g,'object_type':'Order','network':e,'head':j,'coin_type':A,'fields':{'service':y,'machine':str(f['machine']),'progress':x,'allocation':w,'discount':str(f['discount']),'amount':C,'amount_display':D['display'],'amount_tip':D['tip'],'owner':ownerAddr(f['builder']??f['owner']),'claimed_by':str(f['claimed_by']),'required_info':str(f['required_info']),'time':num(f['time'])},'updated_ms':q,'related':B,'allocation_state':r,'progress_next':t,'progress_since':u,'items':E,'disputes':arr(f['dispute'])['map'](M=>String(M)),'agents':arr(f['agent'])['map'](M=>String(M)),'data_gaps':h};}if(k==='Arb'){const M=f['indemnity'];let N=null;try{const W=await query_object_last_updated({'object':g,'network':e,'previous_transaction':str(f['previousTransaction'])});N=W?.['timestamp_ms']?Number(W['timestamp_ms'])||null:null;}catch{}const O=str(f['order']);let P=null;if(O)try{const X=await query_objects({'objects':[O],'network':e}),Y=X?.['objects']?.[0x0];P=str(Y?.['service']);}catch{}const Q=await buildRelatedList(g,g,e,h,'arb'),R=coinOfTypeRaw(f['type_raw']),S=str(f['fee']),T=await formatMoneyAnnotation(S,R,e),U=M?str(M['amount']):null,V=await formatMoneyAnnotation(U,R,e);return{'action':'object_panorama','object':g,'object_type':'Arb','network':e,'head':j,'coin_type':R,'fields':{'arbitration':str(f['arbitration']),'order':str(f['order']),'service':P,'fee':S,'fee_display':T['display'],'fee_tip':T['tip'],'feedback':str(f['feedback']),'indemnity':M?{'amount':U,'amount_display':V['display'],'amount_tip':V['tip'],'time':num(M['time'])}:null,'voting_deadline':num(f['voting_deadline']),'objection':str(f['objection']),'status':ARB_STATUS_NAMES[num(f['status'])??-0x1]??str(f['status']),'compensation_time':num(f['compensation_time']),'time':num(f['time']),'type_raw':str(f['type_raw'])},'voted':arr(f['voted'])['map'](Z=>{const a0=Z;return{'voter':str(a0['voter'])??'','agrees':arr(a0['agrees'])['map'](a1=>Number(a1)),'weight':num(a0['weight'])??0x0,'time':num(a0['time'])??0x0};}),'proposition':arr(f['proposition'])['map'](Z=>{const a0=Z;return{'name':str(a0['name'])??'','votes':num(a0['votes'])??0x0};}),'related':Q,'updated_ms':N,'data_gaps':h};}if(k==='Arbitration'){const Z=coinOfTypeRaw(f['type_raw']??f['type']),a0=str(f['fee']),a1=await formatMoneyAnnotation(a0,Z,e),a2=str(f['balance']),a3=await formatMoneyAnnotation(a2,Z,e),a4=a7=>{if(a7&&typeof a7==='object'){const a8=a7;if(a8['GuardIdentifier']!==undefined)return'guard\x20identifier\x20#'+String(a8['GuardIdentifier']);if(a8['FixedValue']!==undefined)return'fixed\x20weight\x20'+String(a8['FixedValue']);}return typeof a7==='number'||typeof a7==='string'?String(a7):null;},a5=arr(f['voting_guard'])['map'](a7=>{const a8=a7;return{'guard':str(a8['guard'])??'','vote_weight':a4(a8['vote_weight'])};}),a6={'count':0x0,'window_saturated':![],'preview_truncated':![],'stats':{'first_created_ms':null,'last_created_ms':null},'items':[]};try{const a7=await fetchObjectLinkerTx(g,e,!![]),a8=a7?.['items']??[];a6['window_saturated']=ringWindowSaturated(a8['length']);const a9=a8['filter'](ac=>objectTypeFromAddress(typeof ac?.['who']==='string'?ac['who']:'')===ObjectType['Arb']);a6['count']=a9['length'];for(const ac of a9){if(typeof ac?.['time']==='number'){if(a6['stats']['first_created_ms']===null||ac['time']<a6['stats']['first_created_ms'])a6['stats']['first_created_ms']=ac['time'];if(a6['stats']['last_created_ms']===null||ac['time']>a6['stats']['last_created_ms'])a6['stats']['last_created_ms']=ac['time'];}}const aa=a9['slice'](-0x3)['reverse'](),ab=new Map();if(aa['length']>0x0)try{const ad=await batchQueryObjectsByIds(aa['map'](ae=>String(ae['who'])),e,!![]);for(const ae of ad){if(ae?.['object'])ab['set'](ae['object'],ae);}}catch{h['push']('cases:\x20detail\x20fetch\x20failed\x20(non-blocking)');}for(const af of aa){const ag=typeof af?.['who']==='string'?af['who']:'';if(!ag)continue;const ah=ab['get'](ag);a6['items']['push']({'arb':ag,'order':ah?str(ah['order']):null,'status':ah?ARB_STATUS_NAMES[num(ah['status'])??-0x1]??str(ah['status']):null,'time':typeof af?.['time']==='number'?af['time']:null});}a6['preview_truncated']=a6['count']>a6['items']['length'],a6['preview_truncated']&&(a6['drilldown']={'total_count':a6['count'],'analyzed_count':a6['items']['length'],'prompt':'Analyze\x20ALL\x20dispute\x20cases\x20of\x20Arbitration\x20'+g+'\x20('+e+')\x20one\x20by\x20one,\x20newest\x20first.\x20'+('The\x20cases\x20live\x20in\x20the\x20arbitration\x27s\x20FIFO\x20tx-linker\x20window\x20holding\x20at\x20most\x205200\x20newest\x20entries\x20—\x20the\x20retained\x20count\x20is\x20a\x20lower\x20bound\x20when\x20the\x20window\x20is\x20saturated\x20(currently\x20'+a6['count']+(a6['window_saturated']?',\x20saturated':'')+').\x20')+'For\x20each\x20case\x20call\x20object_panorama\x20with\x20the\x20Arb\x20case\x27s\x20FULL\x200x\x20address\x20(collect\x20the\x20addresses\x20from\x20the\x20same\x20reverse-index\x20source;\x20work\x20newest-first)\x20and\x20render\x20ONE\x20table\x20row\x20per\x20case:\x20'+'case\x20address\x20chip\x20(first\x20column)\x20|\x20disputed\x20order\x20address\x20chip\x20ON\x20THE\x20SAME\x20ROW\x20(the\x20order\x20is\x20the\x20case\x27s\x20child\x20plane)\x20|\x20status\x20|\x20created\x20(local\x20date)\x20|\x20indemnity\x20(the\x20display\x20value\x20with\x20its\x20token\x20symbol\x20—\x20never\x20reconvert\x20from\x20raw)\x20|\x20arbitrator\x20feedback.\x20'+'Close\x20with\x20the\x203\x20most\x20valuable\x20patterns\x20across\x20the\x20rows\x20(outcomes,\x20indemnity\x20distribution,\x20case\x20age).\x20Cases\x20only\x20—\x20do\x20not\x20re-analyze\x20the\x20Arbitration\x20itself.'});}catch{h['push']('cases:\x20affiliation-window\x20lookup\x20failed\x20(non-blocking)');}return{'action':'object_panorama','object':g,'object_type':'Arbitration','network':e,'head':j,'coin_type':Z,'fields':{'location':str(f['location']),'um':str(f['um']),'permission':str(f['permission']),'fee':a0,'fee_display':a1['display'],'fee_tip':a1['tip'],'balance':a2,'balance_display':a3['display'],'balance_tip':a3['tip'],'paused':typeof f['bPaused']==='boolean'?f['bPaused']:null,'usage_guard':str(f['usage_guard'])},'voting_guards':a5,'cases':a6,'data_gaps':h};}if(k==='Repository')return{'action':'object_panorama','object':g,'object_type':'Repository','network':e,'head':j,'fields':{'um':str(f['um']),'permission':str(f['permission']),'data_count':num(f['data_count'])},'policies':arr(f['policies'])['map'](ai=>{const aj=ai;return{'name':str(aj['name'])??'','description':str(aj['description']),'id_from':str(aj['id_from']),'value_type':str(aj['value_type']),'write_guards':arr(aj['write_guard'])['length'],'quote_guard':str(aj['quote_guard'])};}),'rewards':arr(f['rewards'])['map'](ai=>String(ai)),'data_entries':await buildRepositoryData(g,e,h),'data_gaps':h};throw new Error('object_panorama:\x20unsupported\x20object\x20type\x20\x27'+(k||'unknown')+'\x27\x20for\x20'+g+'.\x20'+'Supported:\x20Progress\x20/\x20Demand\x20/\x20Order\x20/\x20Arb\x20/\x20Arbitration\x20/\x20Repository.');}
|
|
1
|
+
import{Config,LocalMark,query_objects,query_object_last_updated,objectTypeFromAddress,ObjectType}from'@wowok/wowok';import{resolveAddress as a308a}from'../../tools/handlers/name-resolution.js';import{batchReadAddressKeyedFields,batchQueryObjectsByIds,fetchObjectLinkerTx,ringWindowSaturated}from'../../graph/onchain/sdk-batch.js';import{formatMoneyAnnotation}from'./facet-money.js';const js=a=>{if(typeof a==='bigint')return a['toString']();if(a&&typeof a==='object'&&!Array['isArray'](a)){const b={};for(const [c,d]of Object['entries'](a)){b[c]=js(d);}return b;}if(Array['isArray'](a))return a['map'](js);return a;},str=a=>a===null||a===undefined?null:String(a),ownerAddr=a=>{if(typeof a==='string')return a;const b=a;if(b&&typeof b==='object'){if(typeof b['AddressOwner']==='string')return b['AddressOwner'];if(typeof b['ObjectOwner']==='string')return b['ObjectOwner'];const c=Object['values'](b)['find'](d=>typeof d==='string'&&d['length']>0x14);if(typeof c==='string')return c;}return null;},num=a=>{if(typeof a==='bigint')return Number(a);if(typeof a==='number')return Number['isFinite'](a)?a:null;if(typeof a==='string'&&a['trim']()!==''){const b=Number(a);return Number['isFinite'](b)?b:null;}return null;},arr=a=>Array['isArray'](a)?a:[];export function coinOfTypeRaw(a){if(typeof a!=='string'||!a)return null;const b=a['match'](/<(.+)>$/),c=b?.[0x1]?.['trim']();return c&&c['includes']('::')?c:null;}const RELATED_PREVIEW_CAP=0x32;async function buildRelatedList(a,b,c,d,e){const f={'key':a,'items':[],'count':0x0,'window_saturated':![],'preview_truncated':![]};if(!a)return f;try{const g=await fetchObjectLinkerTx(a,c,!![]),h=g?.['items']??[];f['window_saturated']=ringWindowSaturated(h['length']);const j=[];for(const k of h){const l=typeof k?.['who']==='string'?k['who']:'';if(!l||l['toLowerCase']()===b['toLowerCase']())continue;let m;try{m=objectTypeFromAddress(l);}catch{}if(!m)continue;j['push']({'address':l,'object_type':m,'time':typeof k?.['time']==='number'?k['time']:null});}f['count']=j['length'],f['items']=j['slice'](-RELATED_PREVIEW_CAP)['reverse'](),f['preview_truncated']=j['length']>f['items']['length'];}catch{d['push']('related:\x20ObjectLinkerTx('+e+')\x20lookup\x20failed');}return f;}const ARB_STATUS_NAMES={0x0:'Principal_confirming',0x1:'Arbitrator_confirming',0x2:'Voting',0x3:'Arbitrated',0x4:'Objectionable',0x5:'Finished',0x6:'Withdrawn'};async function resolveObject(a,b){const c=await a308a(a,'object_address');let d=b??undefined,f=null;if(!d)d=await Config['Instance']()['network_get']();try{const g=await query_objects({'objects':[c],'network':d});f=g?.['objects']?.[0x0]??null;if(!f&&b){const h=await Config['Instance']()['network_get']();if(h&&h!==d){const i=await query_objects({'objects':[c],'network':h,'no_cache':!![]}),j=i?.['objects']?.[0x0]??null;j&&(f=j,d=h);}}}catch(k){throw new Error('Failed\x20to\x20query\x20'+c+'\x20on\x20'+d+':\x20'+(k instanceof Error?k['message']:String(k)));}if(!f)throw new Error(c+'\x20not\x20found\x20on\x20'+d+'.\x20It\x20may\x20not\x20exist\x20on\x20this\x20network.');return f['object']=f['object']??c,{'network':String(d),'obj':f};}async function resolveHead(a,b,c){let d=null,e=[];try{const f=await LocalMark['Instance']()['list']({'address':a});f['length']>0x0&&(d=f[0x0]['name']??null,e=(f[0x0]['tags']??[])['map'](g=>String(g)));}catch{c['push']('head:\x20LocalMark\x20lookup\x20failed');}return{'name':d,'tags':e,'description':str(b['description'])};}async function buildPresenters(a,b,c){const d=[];let e=0x0,f=![];try{const g=await fetchObjectLinkerTx(a,b,!![]),h=Array['isArray'](g?.['items'])?g['items']:[];f=ringWindowSaturated(h['length']);const i=h['map'](l=>({'service':String(l?.['who']??''),'time':typeof l?.['time']==='number'?l['time']:null}))['filter'](l=>objectTypeFromAddress(l['service'])===ObjectType['Service']);e=i['length'];const j=i['slice'](-0x32)['reverse'](),k=await batchReadAddressKeyedFields(a,j['map'](l=>l['service']),b,!![]);for(const l of j){const m=k['get'](l['service']['toLowerCase']());d['push']({'service':l['service'],'recommend':str(m?.['recommend']),'acceptance_score':num(m?.['acceptance_score']),'feedback':str(m?.['feedback']),'feedback_time':num(m?.['feedback_time']),'update_time':num(m?.['update_time'])??l['time']});}}catch{c['push']('presenters:\x20global-table\x20lookup\x20failed\x20(non-blocking)');}return{'count':e,'window_saturated':f,'preview_truncated':e>d['length'],'items':d};}async function buildRepositoryData(a,b,c){return void a,void b,c['push']('data:\x20per-key\x20enumeration\x20requires\x20the\x20{entity,name}\x20pair\x20—\x20showing\x20count\x20only'),{'count':null,'items':[]};}export async function handleObjectPanorama(b){const c=b['object_address']??b['filter'];if(!c)throw new Error('\x27object_address\x27\x20is\x20required\x20for\x20object_panorama\x20(a\x20LocalMark\x20NAME\x20is\x20also\x20accepted).\x20Example:\x20{\x22query_type\x22:\x20\x22object_panorama\x22,\x20\x22object_address\x22:\x20\x220x...\x22}');const {network:e,obj:f}=await resolveObject(c,b['context_network']),g=String(f['object']),h=[],j=await resolveHead(g,f,h),k=String(f['type']??'');if(k==='Progress'){const l=arr(f['session'])[0x0],m=l?{'next_node':str(l['next_node']),'weights':num(l['weights']),'threshold':num(l['threshold']),'forwards':arr(l['forwards'])['map'](q=>{const r=q;return{'forward':str(r['forward'])??'','who':str(r['who']),'accomplished':r['accomplished']===!![],'msg':str(r['msg']),'time':num(r['time'])};})}:null,n=await buildRelatedList(typeof f['machine']==='string'?f['machine']:null,g,e,h,'machine');return{'action':'object_panorama','object':g,'object_type':'Progress','network':e,'head':j,'fields':{'machine':str(f['machine']),'current':str(f['current']),'task':str(f['task']),'history_count':num(f['history_count']),'current_time':num(f['current_time'])},'context_repositories':arr(f['context_repositories'])['map'](q=>String(q)),'operators':arr(f['namedOperator'])['map'](q=>{const r=q;return{'name':str(r['name'])??'','operators':arr(r['operators'])['map'](t=>String(t))};}),'session':m,'related':n,'data_gaps':h};}if(k==='Demand')return{'action':'object_panorama','object':g,'object_type':'Demand','network':e,'head':j,'fields':{'location':str(f['location']),'um':str(f['um']),'permission':str(f['permission']),'presenters_count':num(f['presenters_count'])},'rewards':arr(f['rewards'])['map'](q=>String(q)),'guards':arr(f['guards'])['map'](q=>({'guard':str(q['guard'])??''})),'presenters':await buildPresenters(g,e,h),'data_gaps':h};if(k==='Order'){let q=null;try{const F=await query_object_last_updated({'object':g,'network':e,'previous_transaction':str(f['previousTransaction'])});q=F?.['timestamp_ms']?Number(F['timestamp_ms'])||null:null;}catch{}let r='none',t=null,u=null;const w=str(f['allocation']),x=str(f['progress']),y=str(f['service']),z=[w,x,y]['filter'](G=>!!G);let A=null;if(z['length']>0x0)try{const G=await query_objects({'objects':z,'network':e}),H=G?.['objects']??[];if(w){r='pending';const I=H['find'](K=>K?.['object']===w),J=Number(I?.['balance']??NaN);if(Number['isFinite'](J)&&J===0x0)r='allocated';}if(x){const K=H['find'](L=>L?.['object']===x);t=str(K?.['current']),u=num(K?.['current_time']);}if(y){const L=H['find'](M=>M?.['object']===y);A=coinOfTypeRaw(L?.['type_raw']??L?.['type']);}}catch{}const B=await buildRelatedList(g,g,e,h,'order'),C=str(f['amount']),D=await formatMoneyAnnotation(C,A,e),E=await Promise['all'](arr(f['items'])['map'](async M=>{const N=M,O=str(N['price']),P=await formatMoneyAnnotation(O,A,e);return{'name':str(N['name']),'price':O,'price_display':P['display'],'price_tip':P['tip'],'quantity':str(N['quantity']),'wip_hash':str(N['wip_hash'])};}));return{'action':'object_panorama','object':g,'object_type':'Order','network':e,'head':j,'coin_type':A,'fields':{'service':y,'machine':str(f['machine']),'progress':x,'allocation':w,'discount':str(f['discount']),'amount':C,'amount_display':D['display'],'amount_tip':D['tip'],'owner':ownerAddr(f['builder']??f['owner']),'claimed_by':str(f['claimed_by']),'required_info':str(f['required_info']),'time':num(f['time'])},'updated_ms':q,'related':B,'allocation_state':r,'progress_next':t,'progress_since':u,'items':E,'disputes':arr(f['dispute'])['map'](M=>String(M)),'agents':arr(f['agent'])['map'](M=>String(M)),'data_gaps':h};}if(k==='Arb'){const M=f['indemnity'];let N=null;try{const W=await query_object_last_updated({'object':g,'network':e,'previous_transaction':str(f['previousTransaction'])});N=W?.['timestamp_ms']?Number(W['timestamp_ms'])||null:null;}catch{}const O=str(f['order']);let P=null;if(O)try{const X=await query_objects({'objects':[O],'network':e}),Y=X?.['objects']?.[0x0];P=str(Y?.['service']);}catch{}const Q=await buildRelatedList(g,g,e,h,'arb'),R=coinOfTypeRaw(f['type_raw']),S=str(f['fee']),T=await formatMoneyAnnotation(S,R,e),U=M?str(M['amount']):null,V=await formatMoneyAnnotation(U,R,e);return{'action':'object_panorama','object':g,'object_type':'Arb','network':e,'head':j,'coin_type':R,'fields':{'arbitration':str(f['arbitration']),'order':str(f['order']),'service':P,'fee':S,'fee_display':T['display'],'fee_tip':T['tip'],'feedback':str(f['feedback']),'indemnity':M?{'amount':U,'amount_display':V['display'],'amount_tip':V['tip'],'time':num(M['time'])}:null,'voting_deadline':num(f['voting_deadline']),'objection':str(f['objection']),'status':ARB_STATUS_NAMES[num(f['status'])??-0x1]??str(f['status']),'compensation_time':num(f['compensation_time']),'time':num(f['time']),'type_raw':str(f['type_raw'])},'voted':arr(f['voted'])['map'](Z=>{const a0=Z;return{'voter':str(a0['voter'])??'','agrees':arr(a0['agrees'])['map'](a1=>Number(a1)),'weight':num(a0['weight'])??0x0,'time':num(a0['time'])??0x0};}),'proposition':arr(f['proposition'])['map'](Z=>{const a0=Z;return{'name':str(a0['name'])??'','votes':num(a0['votes'])??0x0};}),'related':Q,'updated_ms':N,'data_gaps':h};}if(k==='Arbitration'){const Z=coinOfTypeRaw(f['type_raw']??f['type']),a0=str(f['fee']),a1=await formatMoneyAnnotation(a0,Z,e),a2=str(f['balance']),a3=await formatMoneyAnnotation(a2,Z,e),a4=a7=>{if(a7&&typeof a7==='object'){const a8=a7;if(a8['GuardIdentifier']!==undefined)return'guard\x20identifier\x20#'+String(a8['GuardIdentifier']);if(a8['FixedValue']!==undefined)return'fixed\x20weight\x20'+String(a8['FixedValue']);}return typeof a7==='number'||typeof a7==='string'?String(a7):null;},a5=arr(f['voting_guard'])['map'](a7=>{const a8=a7;return{'guard':str(a8['guard'])??'','vote_weight':a4(a8['vote_weight'])};}),a6={'count':0x0,'window_saturated':![],'preview_truncated':![],'stats':{'first_created_ms':null,'last_created_ms':null},'items':[]};try{const a7=await fetchObjectLinkerTx(g,e,!![]),a8=a7?.['items']??[];a6['window_saturated']=ringWindowSaturated(a8['length']);const a9=a8['filter'](ac=>objectTypeFromAddress(typeof ac?.['who']==='string'?ac['who']:'')===ObjectType['Arb']);a6['count']=a9['length'];for(const ac of a9){if(typeof ac?.['time']==='number'){if(a6['stats']['first_created_ms']===null||ac['time']<a6['stats']['first_created_ms'])a6['stats']['first_created_ms']=ac['time'];if(a6['stats']['last_created_ms']===null||ac['time']>a6['stats']['last_created_ms'])a6['stats']['last_created_ms']=ac['time'];}}const aa=a9['slice'](-0x3)['reverse'](),ab=new Map();if(aa['length']>0x0)try{const ad=await batchQueryObjectsByIds(aa['map'](ae=>String(ae['who'])),e,!![]);for(const ae of ad){if(ae?.['object'])ab['set'](ae['object'],ae);}}catch{h['push']('cases:\x20detail\x20fetch\x20failed\x20(non-blocking)');}for(const af of aa){const ag=typeof af?.['who']==='string'?af['who']:'';if(!ag)continue;const ah=ab['get'](ag);a6['items']['push']({'arb':ag,'order':ah?str(ah['order']):null,'status':ah?ARB_STATUS_NAMES[num(ah['status'])??-0x1]??str(ah['status']):null,'time':typeof af?.['time']==='number'?af['time']:null});}a6['preview_truncated']=a6['count']>a6['items']['length'],a6['preview_truncated']&&(a6['drilldown']={'total_count':a6['count'],'analyzed_count':a6['items']['length'],'prompt':'Analyze\x20ALL\x20dispute\x20cases\x20of\x20Arbitration\x20'+g+'\x20('+e+')\x20one\x20by\x20one,\x20newest\x20first.\x20'+('The\x20cases\x20live\x20in\x20the\x20arbitration\x27s\x20FIFO\x20tx-linker\x20window\x20holding\x20at\x20most\x205200\x20newest\x20entries\x20—\x20the\x20retained\x20count\x20is\x20a\x20lower\x20bound\x20when\x20the\x20window\x20is\x20saturated\x20(currently\x20'+a6['count']+(a6['window_saturated']?',\x20saturated':'')+').\x20')+'For\x20each\x20case\x20call\x20object_panorama\x20with\x20the\x20Arb\x20case\x27s\x20FULL\x200x\x20address\x20(collect\x20the\x20addresses\x20from\x20the\x20same\x20reverse-index\x20source;\x20work\x20newest-first)\x20and\x20render\x20ONE\x20table\x20row\x20per\x20case:\x20'+'case\x20address\x20chip\x20(first\x20column)\x20|\x20disputed\x20order\x20address\x20chip\x20ON\x20THE\x20SAME\x20ROW\x20(the\x20order\x20is\x20the\x20case\x27s\x20child\x20plane)\x20|\x20status\x20|\x20created\x20(local\x20date)\x20|\x20indemnity\x20(the\x20display\x20value\x20with\x20its\x20token\x20symbol\x20—\x20never\x20reconvert\x20from\x20raw)\x20|\x20arbitrator\x20feedback.\x20'+'Close\x20with\x20the\x203\x20most\x20valuable\x20patterns\x20across\x20the\x20rows\x20(outcomes,\x20indemnity\x20distribution,\x20case\x20age).\x20Cases\x20only\x20—\x20do\x20not\x20re-analyze\x20the\x20Arbitration\x20itself.'});}catch{h['push']('cases:\x20affiliation-window\x20lookup\x20failed\x20(non-blocking)');}return{'action':'object_panorama','object':g,'object_type':'Arbitration','network':e,'head':j,'coin_type':Z,'fields':{'location':str(f['location']),'um':str(f['um']),'permission':str(f['permission']),'fee':a0,'fee_display':a1['display'],'fee_tip':a1['tip'],'balance':a2,'balance_display':a3['display'],'balance_tip':a3['tip'],'paused':typeof f['bPaused']==='boolean'?f['bPaused']:null,'usage_guard':str(f['usage_guard'])},'voting_guards':a5,'cases':a6,'data_gaps':h};}if(k==='Repository')return{'action':'object_panorama','object':g,'object_type':'Repository','network':e,'head':j,'fields':{'um':str(f['um']),'permission':str(f['permission']),'data_count':num(f['data_count'])},'policies':arr(f['policies'])['map'](ai=>{const aj=ai;return{'name':str(aj['name'])??'','description':str(aj['description']),'id_from':str(aj['id_from']),'value_type':str(aj['value_type']),'write_guards':arr(aj['write_guard'])['length'],'quote_guard':str(aj['quote_guard'])};}),'rewards':arr(f['rewards'])['map'](ai=>String(ai)),'data_entries':await buildRepositoryData(g,e,h),'data_gaps':h};throw new Error('object_panorama:\x20unsupported\x20object\x20type\x20\x27'+(k||'unknown')+'\x27\x20for\x20'+g+'.\x20'+'Supported:\x20Progress\x20/\x20Demand\x20/\x20Order\x20/\x20Arb\x20/\x20Arbitration\x20/\x20Repository.');}
|