@wowok/agent-mcp 2.4.3 → 2.5.0
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/runtime.d.ts +4 -0
- package/dist/config/runtime.js +29 -5
- package/dist/harness/auto-escalation.d.ts +27 -0
- package/dist/harness/auto-escalation.js +68 -0
- package/dist/index.js +21 -0
- package/dist/knowledge/allocation-confirm.d.ts +115 -0
- package/dist/knowledge/allocation-confirm.js +534 -0
- package/dist/knowledge/allocation-context.d.ts +58 -0
- package/dist/knowledge/allocation-context.js +249 -0
- package/dist/knowledge/allocation-ledger.d.ts +67 -0
- package/dist/knowledge/allocation-ledger.js +463 -0
- package/dist/knowledge/allocation-puzzle.d.ts +135 -0
- package/dist/knowledge/allocation-puzzle.js +298 -0
- package/dist/knowledge/allocation-risk.d.ts +78 -0
- package/dist/knowledge/allocation-risk.js +568 -0
- package/dist/knowledge/allocation-templates.d.ts +38 -0
- package/dist/knowledge/allocation-templates.js +970 -0
- package/dist/knowledge/allocation-translation.d.ts +72 -0
- package/dist/knowledge/allocation-translation.js +585 -0
- package/dist/knowledge/arb-risk.d.ts +37 -0
- package/dist/knowledge/arb-risk.js +210 -0
- package/dist/knowledge/arbitration-confirm.d.ts +135 -0
- package/dist/knowledge/arbitration-confirm.js +559 -0
- package/dist/knowledge/arbitration-context.d.ts +81 -0
- package/dist/knowledge/arbitration-context.js +505 -0
- package/dist/knowledge/arbitration-ledger.d.ts +62 -0
- package/dist/knowledge/arbitration-ledger.js +521 -0
- package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
- package/dist/knowledge/arbitration-puzzle.js +304 -0
- package/dist/knowledge/arbitration-risk.d.ts +112 -0
- package/dist/knowledge/arbitration-risk.js +433 -0
- package/dist/knowledge/arbitration-templates.d.ts +38 -0
- package/dist/knowledge/arbitration-templates.js +276 -0
- package/dist/knowledge/arbitration-translation.d.ts +91 -0
- package/dist/knowledge/arbitration-translation.js +487 -0
- package/dist/knowledge/bridge-risk.d.ts +36 -0
- package/dist/knowledge/bridge-risk.js +263 -0
- package/dist/knowledge/contact-risk.d.ts +32 -0
- package/dist/knowledge/contact-risk.js +200 -0
- package/dist/knowledge/demand-confirm.d.ts +32 -0
- package/dist/knowledge/demand-confirm.js +206 -0
- package/dist/knowledge/demand-risk.d.ts +30 -0
- package/dist/knowledge/demand-risk.js +240 -0
- package/dist/knowledge/demand-translation.d.ts +55 -0
- package/dist/knowledge/demand-translation.js +354 -0
- package/dist/knowledge/deployment-scanner.d.ts +63 -0
- package/dist/knowledge/deployment-scanner.js +762 -0
- package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
- package/dist/knowledge/examples-scanner-cli.js +26 -0
- package/dist/knowledge/examples-scanner.d.ts +121 -0
- package/dist/knowledge/examples-scanner.js +825 -0
- package/dist/knowledge/flywheel-loop.d.ts +3 -0
- package/dist/knowledge/flywheel-loop.js +32 -3
- package/dist/knowledge/glossary.js +3 -1
- package/dist/knowledge/guard-confirm.d.ts +86 -0
- package/dist/knowledge/guard-confirm.js +406 -0
- package/dist/knowledge/guard-context.d.ts +56 -0
- package/dist/knowledge/guard-context.js +287 -0
- package/dist/knowledge/guard-design-patterns.d.ts +37 -0
- package/dist/knowledge/guard-design-patterns.js +257 -0
- package/dist/knowledge/guard-puzzle.js +3 -2
- package/dist/knowledge/guard-risk.d.ts +1 -1
- package/dist/knowledge/guard-risk.js +12 -14
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +6 -5
- package/dist/knowledge/index.d.ts +342 -0
- package/dist/knowledge/index.js +344 -0
- package/dist/knowledge/machine-confirm.d.ts +102 -0
- package/dist/knowledge/machine-confirm.js +559 -0
- package/dist/knowledge/machine-context.d.ts +160 -0
- package/dist/knowledge/machine-context.js +812 -0
- package/dist/knowledge/machine-ledger.d.ts +41 -0
- package/dist/knowledge/machine-ledger.js +315 -0
- package/dist/knowledge/machine-puzzle.d.ts +206 -0
- package/dist/knowledge/machine-puzzle.js +494 -0
- package/dist/knowledge/machine-risk.d.ts +75 -0
- package/dist/knowledge/machine-risk.js +644 -0
- package/dist/knowledge/machine-templates.d.ts +92 -0
- package/dist/knowledge/machine-templates.js +1592 -0
- package/dist/knowledge/machine-topology.d.ts +57 -0
- package/dist/knowledge/machine-topology.js +234 -0
- package/dist/knowledge/machine-translation.d.ts +96 -0
- package/dist/knowledge/machine-translation.js +513 -0
- package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
- package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
- package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
- package/dist/knowledge/mcp-schema-audit.js +772 -0
- package/dist/knowledge/onchain-constants.d.ts +4 -0
- package/dist/knowledge/onchain-constants.js +35 -0
- package/dist/knowledge/order-confirm.d.ts +115 -0
- package/dist/knowledge/order-confirm.js +573 -0
- package/dist/knowledge/order-context.d.ts +66 -0
- package/dist/knowledge/order-context.js +390 -0
- package/dist/knowledge/order-ledger.d.ts +69 -0
- package/dist/knowledge/order-ledger.js +341 -0
- package/dist/knowledge/order-puzzle.d.ts +159 -0
- package/dist/knowledge/order-puzzle.js +255 -0
- package/dist/knowledge/order-risk.d.ts +66 -0
- package/dist/knowledge/order-risk.js +653 -0
- package/dist/knowledge/order-templates.d.ts +50 -0
- package/dist/knowledge/order-templates.js +368 -0
- package/dist/knowledge/order-translation.d.ts +78 -0
- package/dist/knowledge/order-translation.js +550 -0
- package/dist/knowledge/passport-confirm.d.ts +130 -0
- package/dist/knowledge/passport-confirm.js +531 -0
- package/dist/knowledge/passport-context.d.ts +59 -0
- package/dist/knowledge/passport-context.js +306 -0
- package/dist/knowledge/passport-ledger.d.ts +48 -0
- package/dist/knowledge/passport-ledger.js +282 -0
- package/dist/knowledge/passport-puzzle.d.ts +108 -0
- package/dist/knowledge/passport-puzzle.js +333 -0
- package/dist/knowledge/passport-risk.d.ts +70 -0
- package/dist/knowledge/passport-risk.js +450 -0
- package/dist/knowledge/passport-templates.d.ts +40 -0
- package/dist/knowledge/passport-templates.js +568 -0
- package/dist/knowledge/passport-translation.d.ts +68 -0
- package/dist/knowledge/passport-translation.js +516 -0
- package/dist/knowledge/payment-risk.d.ts +33 -0
- package/dist/knowledge/payment-risk.js +182 -0
- package/dist/knowledge/permission-confirm.d.ts +110 -0
- package/dist/knowledge/permission-confirm.js +426 -0
- package/dist/knowledge/permission-context.d.ts +58 -0
- package/dist/knowledge/permission-context.js +224 -0
- package/dist/knowledge/permission-ledger.d.ts +38 -0
- package/dist/knowledge/permission-ledger.js +403 -0
- package/dist/knowledge/permission-puzzle.d.ts +122 -0
- package/dist/knowledge/permission-puzzle.js +173 -0
- package/dist/knowledge/permission-risk.d.ts +76 -0
- package/dist/knowledge/permission-risk.js +411 -0
- package/dist/knowledge/permission-templates.d.ts +38 -0
- package/dist/knowledge/permission-templates.js +234 -0
- package/dist/knowledge/permission-translation.d.ts +57 -0
- package/dist/knowledge/permission-translation.js +350 -0
- package/dist/knowledge/personal-risk.d.ts +36 -0
- package/dist/knowledge/personal-risk.js +212 -0
- package/dist/knowledge/progress-confirm.d.ts +108 -0
- package/dist/knowledge/progress-confirm.js +456 -0
- package/dist/knowledge/progress-context.d.ts +123 -0
- package/dist/knowledge/progress-context.js +452 -0
- package/dist/knowledge/progress-ledger.d.ts +63 -0
- package/dist/knowledge/progress-ledger.js +327 -0
- package/dist/knowledge/progress-puzzle.d.ts +82 -0
- package/dist/knowledge/progress-puzzle.js +219 -0
- package/dist/knowledge/progress-risk.d.ts +74 -0
- package/dist/knowledge/progress-risk.js +461 -0
- package/dist/knowledge/progress-templates.d.ts +38 -0
- package/dist/knowledge/progress-templates.js +228 -0
- package/dist/knowledge/progress-translation.d.ts +52 -0
- package/dist/knowledge/progress-translation.js +401 -0
- package/dist/knowledge/proof-confirm.d.ts +31 -0
- package/dist/knowledge/proof-confirm.js +187 -0
- package/dist/knowledge/proof-risk.d.ts +33 -0
- package/dist/knowledge/proof-risk.js +207 -0
- package/dist/knowledge/proof-translation.d.ts +52 -0
- package/dist/knowledge/proof-translation.js +283 -0
- package/dist/knowledge/registrar-risk.d.ts +34 -0
- package/dist/knowledge/registrar-risk.js +217 -0
- package/dist/knowledge/repository-confirm.d.ts +36 -0
- package/dist/knowledge/repository-confirm.js +242 -0
- package/dist/knowledge/repository-risk.d.ts +40 -0
- package/dist/knowledge/repository-risk.js +312 -0
- package/dist/knowledge/repository-translation.d.ts +58 -0
- package/dist/knowledge/repository-translation.js +422 -0
- package/dist/knowledge/resource-risk.d.ts +32 -0
- package/dist/knowledge/resource-risk.js +157 -0
- package/dist/knowledge/reward-confirm.d.ts +113 -0
- package/dist/knowledge/reward-confirm.js +496 -0
- package/dist/knowledge/reward-context.d.ts +127 -0
- package/dist/knowledge/reward-context.js +504 -0
- package/dist/knowledge/reward-ledger.d.ts +96 -0
- package/dist/knowledge/reward-ledger.js +502 -0
- package/dist/knowledge/reward-puzzle.d.ts +97 -0
- package/dist/knowledge/reward-puzzle.js +288 -0
- package/dist/knowledge/reward-risk.d.ts +84 -0
- package/dist/knowledge/reward-risk.js +545 -0
- package/dist/knowledge/reward-translation.d.ts +58 -0
- package/dist/knowledge/reward-translation.js +501 -0
- package/dist/knowledge/safety-rules.js +11 -3
- package/dist/knowledge/scenario-modes.d.ts +53 -0
- package/dist/knowledge/scenario-modes.js +302 -0
- package/dist/knowledge/service-confirm.d.ts +152 -0
- package/dist/knowledge/service-confirm.js +699 -0
- package/dist/knowledge/service-context.d.ts +66 -0
- package/dist/knowledge/service-context.js +403 -0
- package/dist/knowledge/service-ledger.d.ts +71 -0
- package/dist/knowledge/service-ledger.js +609 -0
- package/dist/knowledge/service-puzzle.d.ts +158 -0
- package/dist/knowledge/service-puzzle.js +236 -0
- package/dist/knowledge/service-risk.d.ts +108 -0
- package/dist/knowledge/service-risk.js +615 -0
- package/dist/knowledge/service-templates.d.ts +39 -0
- package/dist/knowledge/service-templates.js +418 -0
- package/dist/knowledge/service-translation.d.ts +103 -0
- package/dist/knowledge/service-translation.js +622 -0
- package/dist/knowledge/tools-reference.d.ts +17 -0
- package/dist/knowledge/tools-reference.js +151 -0
- package/dist/knowledge/treasury-confirm.d.ts +133 -0
- package/dist/knowledge/treasury-confirm.js +512 -0
- package/dist/knowledge/treasury-context.d.ts +64 -0
- package/dist/knowledge/treasury-context.js +363 -0
- package/dist/knowledge/treasury-ledger.d.ts +42 -0
- package/dist/knowledge/treasury-ledger.js +300 -0
- package/dist/knowledge/treasury-puzzle.d.ts +163 -0
- package/dist/knowledge/treasury-puzzle.js +216 -0
- package/dist/knowledge/treasury-risk.d.ts +86 -0
- package/dist/knowledge/treasury-risk.js +440 -0
- package/dist/knowledge/treasury-templates.d.ts +38 -0
- package/dist/knowledge/treasury-templates.js +316 -0
- package/dist/knowledge/treasury-translation.d.ts +78 -0
- package/dist/knowledge/treasury-translation.js +498 -0
- package/dist/knowledge/util-risk.d.ts +30 -0
- package/dist/knowledge/util-risk.js +135 -0
- package/dist/project/business-puzzle.d.ts +47 -0
- package/dist/project/business-puzzle.js +372 -0
- package/dist/project/deployment-doc.d.ts +61 -0
- package/dist/project/deployment-doc.js +432 -0
- package/dist/project/risk-aggregator.d.ts +50 -0
- package/dist/project/risk-aggregator.js +280 -0
- package/dist/project/substep-trace.d.ts +130 -0
- package/dist/project/substep-trace.js +332 -0
- package/dist/schema/call/allocation.d.ts +34 -34
- package/dist/schema/call/arbitration.d.ts +141 -141
- package/dist/schema/call/base.d.ts +386 -386
- package/dist/schema/call/base.js +3 -3
- package/dist/schema/call/bridge-handler.d.ts +5 -2
- package/dist/schema/call/bridge.d.ts +159 -159
- package/dist/schema/call/contact.d.ts +110 -110
- package/dist/schema/call/demand.d.ts +76 -76
- package/dist/schema/call/handler.d.ts +2 -3
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +58 -58
- package/dist/schema/call/order.d.ts +98 -110
- package/dist/schema/call/permission-handler.d.ts +5 -0
- package/dist/schema/call/permission-handler.js +54 -0
- package/dist/schema/call/permission.d.ts +108 -108
- package/dist/schema/call/personal.d.ts +14 -14
- package/dist/schema/call/progress.d.ts +57 -72
- package/dist/schema/call/progress.js +7 -4
- package/dist/schema/call/proof.d.ts +18 -18
- package/dist/schema/call/proof.js +12 -7
- package/dist/schema/call/repository.d.ts +154 -154
- package/dist/schema/call/reward.d.ts +55 -55
- package/dist/schema/call/service.d.ts +231 -231
- package/dist/schema/call/treasury.d.ts +93 -93
- package/dist/schema/config/index.d.ts +178 -5
- package/dist/schema/config/index.js +52 -1
- package/dist/schema/local/index.d.ts +3554 -836
- package/dist/schema/local/index.js +2 -1
- package/dist/schema/messenger/index.d.ts +162 -162
- package/dist/schema/operations.d.ts +1058 -1074
- package/dist/schema/operations.js +7 -1
- package/dist/schema/project/index.d.ts +1392 -6
- package/dist/schema/project/index.js +426 -2
- package/dist/schema/query/index.d.ts +672 -672
- package/dist/schema/schema-query/index.d.ts +23 -3
- package/dist/schema/schema-query/index.js +13 -2
- package/dist/schema/sync-layer4.d.ts +21 -0
- package/dist/schema/sync-layer4.js +261 -0
- package/dist/schema/trust/index.d.ts +26 -26
- package/dist/schemas/account_operation.output.json +718 -0
- package/dist/schemas/config_operation.output.json +173 -0
- package/dist/schemas/index.json +9 -1
- package/dist/schemas/local_info_operation.output.json +718 -0
- package/dist/schemas/local_mark_operation.output.json +718 -0
- package/dist/schemas/onchain_operations.output.json +3 -2
- package/dist/schemas/onchain_operations.schema.json +1802 -313
- package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
- package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
- package/dist/schemas/onchain_operations_contact.schema.json +2 -1
- package/dist/schemas/onchain_operations_demand.schema.json +2 -1
- package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
- package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
- package/dist/schemas/onchain_operations_guard.schema.json +584 -70
- package/dist/schemas/onchain_operations_machine.schema.json +2 -1
- package/dist/schemas/onchain_operations_order.schema.json +13 -9
- package/dist/schemas/onchain_operations_payment.schema.json +2 -1
- package/dist/schemas/onchain_operations_permission.schema.json +2 -1
- package/dist/schemas/onchain_operations_personal.schema.json +2 -1
- package/dist/schemas/onchain_operations_progress.schema.json +14 -10
- package/dist/schemas/onchain_operations_proof.schema.json +699 -0
- package/dist/schemas/onchain_operations_repository.schema.json +2 -1
- package/dist/schemas/onchain_operations_reward.schema.json +2 -1
- package/dist/schemas/onchain_operations_service.schema.json +2 -1
- package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
- package/dist/schemas/onchain_table_data.schema.json +32 -1
- package/dist/schemas/project_operation.output.json +879 -0
- package/dist/schemas/project_operation.schema.json +473 -2
- package/dist/schemas/query_toolkit.output.json +14906 -6
- package/dist/schemas/schema_query.output.json +38 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/tools/handlers/config.d.ts +1 -1
- package/dist/tools/handlers/config.js +21 -18
- package/dist/tools/handlers/file-export.d.ts +2 -2
- package/dist/tools/handlers/local.d.ts +3 -30
- package/dist/tools/handlers/local.js +14 -3
- package/dist/tools/handlers/messenger.d.ts +1 -1
- package/dist/tools/handlers/messenger.js +2 -1
- package/dist/tools/handlers/onchain.d.ts +1 -1
- package/dist/tools/handlers/onchain.js +24 -22
- package/dist/tools/handlers/project.d.ts +1 -1
- package/dist/tools/handlers/project.js +258 -18
- package/dist/tools/handlers/query.d.ts +4 -4
- package/dist/tools/handlers/schema-query.d.ts +1 -1
- package/dist/tools/handlers/schema-query.js +21 -20
- package/dist/tools/handlers/trust.d.ts +1 -1
- package/dist/tools/handlers/trust.js +2 -2
- package/dist/tools/handlers/wip.d.ts +1 -1
- package/dist/tools/handlers/wip.js +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +55 -8
- package/dist/tools/rules-hook.d.ts +1 -1
- package/dist/tools/rules-hook.js +3 -2
- package/dist/tools/shared.d.ts +13 -22
- package/dist/tools/types.d.ts +5 -5
- package/dist/tools/wrap.d.ts +10 -2
- package/dist/tools/wrap.js +212 -0
- package/package.json +3 -3
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type ServiceScene, type ServicePermissionEntry, type ServiceCrossObjectBinding, type ServiceOrderFlowStage } from "./service-ledger.js";
|
|
2
|
+
import { type ServiceTemplate } from "./service-templates.js";
|
|
3
|
+
import { type SemanticToSchemaRule } from "./service-translation.js";
|
|
4
|
+
import { type ServiceRiskRule, type ServiceRiskAssessment, type ServiceStakeholder } from "./service-risk.js";
|
|
5
|
+
import { type ServicePuzzle, type ServicePuzzleCompleteness } from "./service-puzzle.js";
|
|
6
|
+
import { type ServiceChecklistItem, type ServiceJsonForConfirm, type ServiceConfirmationQuestion } from "./service-confirm.js";
|
|
7
|
+
export declare const SERVICE_CONTEXT_VERSION = "1.0.0";
|
|
8
|
+
export type ServiceInjectionMode = "initial_design" | "mid_design_review" | "pre_publish" | "post_publish_modify" | "stakeholder_review" | "order_flow_check";
|
|
9
|
+
export type ServiceStakeholderPerspective = ServiceStakeholder | "system";
|
|
10
|
+
export interface ServiceContextBundle {
|
|
11
|
+
version: string;
|
|
12
|
+
mode: ServiceInjectionMode;
|
|
13
|
+
stakeholder_perspective?: ServiceStakeholderPerspective;
|
|
14
|
+
matched_scene?: ServiceScene;
|
|
15
|
+
matched_template?: ServiceTemplate;
|
|
16
|
+
matched_pattern?: SemanticToSchemaRule;
|
|
17
|
+
puzzle_state?: ServicePuzzle;
|
|
18
|
+
puzzle_completeness?: ServicePuzzleCompleteness;
|
|
19
|
+
relevant_risks: ServiceRiskRule[];
|
|
20
|
+
risk_assessment?: ServiceRiskAssessment;
|
|
21
|
+
relevant_checklist: ServiceChecklistItem[];
|
|
22
|
+
relevant_questions: ServiceConfirmationQuestion[];
|
|
23
|
+
relevant_builtin_permissions: ServicePermissionEntry[];
|
|
24
|
+
relevant_order_flow_stages: ServiceOrderFlowStage[];
|
|
25
|
+
cross_object_bindings: ServiceCrossObjectBinding[];
|
|
26
|
+
cross_object_refs: ServiceCrossObjectRef[];
|
|
27
|
+
onchain_constraints: ServiceOnchainConstraint[];
|
|
28
|
+
rendering_hints: ServiceRenderingHints;
|
|
29
|
+
}
|
|
30
|
+
export interface ServiceCrossObjectRef {
|
|
31
|
+
object: "Machine" | "Allocation" | "Arbitration" | "Repository" | "Reward" | "Treasury" | "Progress" | "Guard" | "Contact" | "Permission";
|
|
32
|
+
field: string;
|
|
33
|
+
scene_id: string;
|
|
34
|
+
description: string;
|
|
35
|
+
locked_after_publish: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface ServiceOnchainConstraint {
|
|
38
|
+
name: string;
|
|
39
|
+
value: string | number;
|
|
40
|
+
description: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ServiceRenderingHints {
|
|
43
|
+
include_puzzle_template: boolean;
|
|
44
|
+
include_risk_details: boolean;
|
|
45
|
+
include_questions: boolean;
|
|
46
|
+
include_publish_warning: boolean;
|
|
47
|
+
include_transfer_warning: boolean;
|
|
48
|
+
include_order_flow_warning: boolean;
|
|
49
|
+
include_immutability_matrix: boolean;
|
|
50
|
+
max_length: number;
|
|
51
|
+
}
|
|
52
|
+
export interface BuildServiceContextInput {
|
|
53
|
+
mode: ServiceInjectionMode;
|
|
54
|
+
intent?: string;
|
|
55
|
+
service_json?: ServiceJsonForConfirm;
|
|
56
|
+
stakeholder?: ServiceStakeholderPerspective;
|
|
57
|
+
target_scene_id?: string;
|
|
58
|
+
target_permission_index?: number;
|
|
59
|
+
target_category?: ServiceScene["category"];
|
|
60
|
+
current_bPublished?: boolean;
|
|
61
|
+
current_bPaused?: boolean;
|
|
62
|
+
max_length?: number;
|
|
63
|
+
}
|
|
64
|
+
export declare function buildServiceContext(input: BuildServiceContextInput): ServiceContextBundle;
|
|
65
|
+
export declare function buildPromptFromServiceContext(bundle: ServiceContextBundle): string;
|
|
66
|
+
export declare function getServiceContextSummary(bundle: ServiceContextBundle): string;
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import { MAX_SALE_COUNT, MAX_REPOSITORY_COUNT, MAX_ARBITRATION_COUNT, MAX_DISCOUNT_COUNT_ONCE, MAX_DISCOUNT_TOTAL_COUNT, MAX_WIP_LENGTH, MAX_WIP_HASH_LENGTH, DEFAULT_LOCK_DURATION, } from "@wowok/wowok";
|
|
2
|
+
import { findSceneById, inferSceneFromIntent, getScenesByCategory, isServicePermission, SERVICE_PERMISSIONS, SERVICE_ORDER_FLOW_STAGES, SERVICE_CROSS_OBJECT_BINDINGS, } from "./service-ledger.js";
|
|
3
|
+
import { getServiceTemplatesByScene, } from "./service-templates.js";
|
|
4
|
+
import { matchSemanticPattern, } from "./service-translation.js";
|
|
5
|
+
import { getAllServiceRiskRules, assessServiceRisks, } from "./service-risk.js";
|
|
6
|
+
import { initPuzzleFromIntent, checkPuzzleCompleteness, } from "./service-puzzle.js";
|
|
7
|
+
import { SERVICE_PUBLISH_CHECKLIST, SERVICE_CONFIRMATION_QUESTIONS, } from "./service-confirm.js";
|
|
8
|
+
export const SERVICE_CONTEXT_VERSION = "1.0.0";
|
|
9
|
+
export function buildServiceContext(input) {
|
|
10
|
+
const max_length = input.max_length ?? 6000;
|
|
11
|
+
let matched_scene;
|
|
12
|
+
if (input.intent) {
|
|
13
|
+
matched_scene = inferSceneFromIntent(input.intent);
|
|
14
|
+
}
|
|
15
|
+
if (!matched_scene && input.target_scene_id) {
|
|
16
|
+
matched_scene = findSceneById(input.target_scene_id);
|
|
17
|
+
}
|
|
18
|
+
if (!matched_scene && input.target_category) {
|
|
19
|
+
const scenes = getScenesByCategory(input.target_category);
|
|
20
|
+
if (scenes.length > 0)
|
|
21
|
+
matched_scene = scenes[0];
|
|
22
|
+
}
|
|
23
|
+
if (!matched_scene && input.target_permission_index !== undefined && isServicePermission(input.target_permission_index)) {
|
|
24
|
+
matched_scene = findSceneById("service_retail");
|
|
25
|
+
}
|
|
26
|
+
let matched_template;
|
|
27
|
+
if (matched_scene) {
|
|
28
|
+
const templates = getServiceTemplatesByScene(matched_scene.id);
|
|
29
|
+
if (templates.length > 0)
|
|
30
|
+
matched_template = templates[0];
|
|
31
|
+
}
|
|
32
|
+
let matched_pattern;
|
|
33
|
+
if (input.intent) {
|
|
34
|
+
const patterns = matchSemanticPattern(input.intent);
|
|
35
|
+
if (patterns.length > 0)
|
|
36
|
+
matched_pattern = patterns[0];
|
|
37
|
+
}
|
|
38
|
+
let puzzle_state;
|
|
39
|
+
let puzzle_completeness;
|
|
40
|
+
if (input.mode === "initial_design" && input.intent) {
|
|
41
|
+
puzzle_state = initPuzzleFromIntent({ primary_goal: input.intent });
|
|
42
|
+
puzzle_completeness = checkPuzzleCompleteness(puzzle_state);
|
|
43
|
+
}
|
|
44
|
+
const relevant_risks = filterRiskRules(input.mode, input.stakeholder, matched_scene);
|
|
45
|
+
let risk_assessment;
|
|
46
|
+
if ((input.mode === "pre_publish" || input.mode === "post_publish_modify" || input.mode === "order_flow_check") && input.service_json) {
|
|
47
|
+
const ctx = {
|
|
48
|
+
object: input.service_json.object,
|
|
49
|
+
description: input.service_json.description,
|
|
50
|
+
location: input.service_json.location,
|
|
51
|
+
sales: input.service_json.sales,
|
|
52
|
+
repositories: input.service_json.repositories,
|
|
53
|
+
rewards: input.service_json.rewards,
|
|
54
|
+
arbitrations: input.service_json.arbitrations,
|
|
55
|
+
machine: input.service_json.machine,
|
|
56
|
+
discount: input.service_json.discount,
|
|
57
|
+
customer_required: input.service_json.customer_required,
|
|
58
|
+
order_allocators: input.service_json.order_allocators,
|
|
59
|
+
buy_guard: input.service_json.buy_guard,
|
|
60
|
+
compensation_fund_add: input.service_json.compensation_fund_add,
|
|
61
|
+
setting_locked_time_add: input.service_json.setting_locked_time_add,
|
|
62
|
+
compensation_fund_receive: input.service_json.compensation_fund_receive,
|
|
63
|
+
owner_receive: input.service_json.owner_receive,
|
|
64
|
+
pause: input.service_json.pause,
|
|
65
|
+
publish: input.service_json.publish,
|
|
66
|
+
um: input.service_json.um,
|
|
67
|
+
order_new: input.service_json.order_new,
|
|
68
|
+
current_bPublished: input.current_bPublished,
|
|
69
|
+
current_bPaused: input.current_bPaused,
|
|
70
|
+
current_machine_bound: input.current_bPublished,
|
|
71
|
+
};
|
|
72
|
+
risk_assessment = assessServiceRisks(ctx);
|
|
73
|
+
}
|
|
74
|
+
const relevant_checklist = filterChecklist(input.mode);
|
|
75
|
+
const relevant_questions = filterQuestions(input.mode);
|
|
76
|
+
const relevant_builtin_permissions = matched_scene
|
|
77
|
+
? matched_scene.builtin_indexes
|
|
78
|
+
: [...SERVICE_PERMISSIONS];
|
|
79
|
+
const relevant_order_flow_stages = input.mode === "order_flow_check"
|
|
80
|
+
? [...SERVICE_ORDER_FLOW_STAGES]
|
|
81
|
+
: [];
|
|
82
|
+
const cross_object_bindings = [...SERVICE_CROSS_OBJECT_BINDINGS];
|
|
83
|
+
const cross_object_refs = buildCrossObjectRefs(matched_scene);
|
|
84
|
+
const onchain_constraints = buildOnchainConstraints();
|
|
85
|
+
const rendering_hints = buildRenderingHints(input.mode, max_length, !!input.service_json?.publish, !!input.service_json?.builder, !!input.service_json?.order_new, input.current_bPublished ?? false);
|
|
86
|
+
return {
|
|
87
|
+
version: SERVICE_CONTEXT_VERSION,
|
|
88
|
+
mode: input.mode,
|
|
89
|
+
stakeholder_perspective: input.stakeholder,
|
|
90
|
+
matched_scene,
|
|
91
|
+
matched_template,
|
|
92
|
+
matched_pattern,
|
|
93
|
+
puzzle_state,
|
|
94
|
+
puzzle_completeness,
|
|
95
|
+
relevant_risks,
|
|
96
|
+
risk_assessment,
|
|
97
|
+
relevant_checklist,
|
|
98
|
+
relevant_questions,
|
|
99
|
+
relevant_builtin_permissions,
|
|
100
|
+
relevant_order_flow_stages,
|
|
101
|
+
cross_object_bindings,
|
|
102
|
+
cross_object_refs,
|
|
103
|
+
onchain_constraints,
|
|
104
|
+
rendering_hints,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function filterRiskRules(mode, stakeholder, scene) {
|
|
108
|
+
let rules = getAllServiceRiskRules();
|
|
109
|
+
if (mode === "initial_design") {
|
|
110
|
+
return rules.filter(r => r.category === "structural" || r.category === "authority");
|
|
111
|
+
}
|
|
112
|
+
if (mode === "pre_publish") {
|
|
113
|
+
return rules;
|
|
114
|
+
}
|
|
115
|
+
if (mode === "post_publish_modify") {
|
|
116
|
+
return rules.filter(r => r.category === "lifecycle" || r.category === "cross_object");
|
|
117
|
+
}
|
|
118
|
+
if (mode === "order_flow_check") {
|
|
119
|
+
return rules.filter(r => r.category === "semantic" || r.id.startsWith("R-S-2"));
|
|
120
|
+
}
|
|
121
|
+
if (mode === "stakeholder_review" && stakeholder) {
|
|
122
|
+
if (stakeholder === "owner") {
|
|
123
|
+
return rules.filter(r => r.category === "authority" || r.category === "lifecycle");
|
|
124
|
+
}
|
|
125
|
+
if (stakeholder === "customer") {
|
|
126
|
+
return rules.filter(r => r.category === "semantic" || r.id.startsWith("R-S-2"));
|
|
127
|
+
}
|
|
128
|
+
if (stakeholder === "provider") {
|
|
129
|
+
return rules.filter(r => r.category === "cross_object" || r.id.startsWith("R-S-5-01"));
|
|
130
|
+
}
|
|
131
|
+
if (stakeholder === "arbitrator") {
|
|
132
|
+
return rules.filter(r => r.id.startsWith("R-S-5-02") || r.id.startsWith("R-S-2-02"));
|
|
133
|
+
}
|
|
134
|
+
if (stakeholder === "system") {
|
|
135
|
+
return rules.filter(r => r.category === "lifecycle");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return rules;
|
|
139
|
+
}
|
|
140
|
+
function filterChecklist(mode) {
|
|
141
|
+
if (mode === "initial_design") {
|
|
142
|
+
return SERVICE_PUBLISH_CHECKLIST.filter(i => ["C-S-01", "C-S-02", "C-S-03", "C-S-04", "C-S-05", "C-S-06", "C-S-07"].includes(i.id));
|
|
143
|
+
}
|
|
144
|
+
if (mode === "pre_publish") {
|
|
145
|
+
return SERVICE_PUBLISH_CHECKLIST;
|
|
146
|
+
}
|
|
147
|
+
if (mode === "post_publish_modify") {
|
|
148
|
+
return SERVICE_PUBLISH_CHECKLIST.filter(i => ["C-S-12", "C-S-13", "C-S-14", "C-S-15", "C-S-16"].includes(i.id));
|
|
149
|
+
}
|
|
150
|
+
if (mode === "order_flow_check") {
|
|
151
|
+
return SERVICE_PUBLISH_CHECKLIST.filter(i => ["C-S-07"].includes(i.id));
|
|
152
|
+
}
|
|
153
|
+
return SERVICE_PUBLISH_CHECKLIST;
|
|
154
|
+
}
|
|
155
|
+
function filterQuestions(mode) {
|
|
156
|
+
if (mode === "pre_publish") {
|
|
157
|
+
return SERVICE_CONFIRMATION_QUESTIONS;
|
|
158
|
+
}
|
|
159
|
+
if (mode === "post_publish_modify") {
|
|
160
|
+
return SERVICE_CONFIRMATION_QUESTIONS.filter(q => !["QS1", "QS2", "QS5"].includes(q.id));
|
|
161
|
+
}
|
|
162
|
+
if (mode === "order_flow_check") {
|
|
163
|
+
return SERVICE_CONFIRMATION_QUESTIONS.filter(q => q.id === "QS9");
|
|
164
|
+
}
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
function buildCrossObjectRefs(scene) {
|
|
168
|
+
return [
|
|
169
|
+
{
|
|
170
|
+
object: "Machine",
|
|
171
|
+
field: "machine",
|
|
172
|
+
scene_id: "service_workflow",
|
|
173
|
+
description: "Machine workflow template — post-publish immutable. Progress inherits this binding.",
|
|
174
|
+
locked_after_publish: true,
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
object: "Allocation",
|
|
178
|
+
field: "order_allocators",
|
|
179
|
+
scene_id: "service_order_allocator",
|
|
180
|
+
description: "Fund distribution strategy — publish prerequisite, post-publish immutable.",
|
|
181
|
+
locked_after_publish: true,
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
object: "Arbitration",
|
|
185
|
+
field: "arbitrations",
|
|
186
|
+
scene_id: "service_arbitration",
|
|
187
|
+
description: "Dispute handlers — required when compensation_fund > 0, post-publish immutable.",
|
|
188
|
+
locked_after_publish: true,
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
object: "Repository",
|
|
192
|
+
field: "repositories",
|
|
193
|
+
scene_id: "service_retail",
|
|
194
|
+
description: "Shared data stores — mutable post-publish.",
|
|
195
|
+
locked_after_publish: false,
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
object: "Reward",
|
|
199
|
+
field: "rewards",
|
|
200
|
+
scene_id: "service_reward",
|
|
201
|
+
description: "Marketing incentives — mutable but locked by setting_lock_duration.",
|
|
202
|
+
locked_after_publish: false,
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
object: "Guard",
|
|
206
|
+
field: "buy_guard",
|
|
207
|
+
scene_id: "service_buy_guard",
|
|
208
|
+
description: "Buyer eligibility Guard — UNUSUAL: still mutable post-publish.",
|
|
209
|
+
locked_after_publish: false,
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
object: "Contact",
|
|
213
|
+
field: "um",
|
|
214
|
+
scene_id: "service_retail",
|
|
215
|
+
description: "User Manager (Contact object) — mutable post-publish.",
|
|
216
|
+
locked_after_publish: false,
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
object: "Treasury",
|
|
220
|
+
field: "(indirect via order_allocators.sharing.who=Entity)",
|
|
221
|
+
scene_id: "service_multi_allocator",
|
|
222
|
+
description: "Treasury referenced by Allocation.sharing.who=Entity (Treasury address). Not directly bound to Service.",
|
|
223
|
+
locked_after_publish: false,
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
object: "Progress",
|
|
227
|
+
field: "(created at order time)",
|
|
228
|
+
scene_id: "service_workflow",
|
|
229
|
+
description: "Progress object created per order (Stage 6 of buy flow). Inherits Machine from Service.",
|
|
230
|
+
locked_after_publish: false,
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
object: "Permission",
|
|
234
|
+
field: "permission",
|
|
235
|
+
scene_id: "service_retail",
|
|
236
|
+
description: "Permission object governing 21 SERVICE_* indexes (300-320). Bound at Service creation, immutable.",
|
|
237
|
+
locked_after_publish: true,
|
|
238
|
+
},
|
|
239
|
+
];
|
|
240
|
+
}
|
|
241
|
+
function buildOnchainConstraints() {
|
|
242
|
+
return [
|
|
243
|
+
{ name: "MAX_SALE_COUNT", value: MAX_SALE_COUNT, description: "Maximum sales items per Service" },
|
|
244
|
+
{ name: "MAX_REPOSITORY_COUNT", value: MAX_REPOSITORY_COUNT, description: "Maximum repositories per Service" },
|
|
245
|
+
{ name: "MAX_ARBITRATION_COUNT", value: MAX_ARBITRATION_COUNT, description: "Maximum arbitrations per Service" },
|
|
246
|
+
{ name: "MAX_REWARD_COUNT", value: 20, description: "Maximum rewards per Service" },
|
|
247
|
+
{ name: "MAX_DISCOUNT_COUNT_ONCE", value: MAX_DISCOUNT_COUNT_ONCE, description: "Maximum discount coupons per issue call" },
|
|
248
|
+
{ name: "MAX_DISCOUNT_TOTAL_COUNT", value: MAX_DISCOUNT_TOTAL_COUNT, description: "Maximum total discount coupons per Service" },
|
|
249
|
+
{ name: "MAX_WIP_LENGTH", value: MAX_WIP_LENGTH, description: "Maximum WIP URL length" },
|
|
250
|
+
{ name: "MAX_WIP_HASH_LENGTH", value: MAX_WIP_HASH_LENGTH, description: "Maximum WIP hash length (sha256 hex)" },
|
|
251
|
+
{ name: "DEFAULT_LOCK_DURATION", value: DEFAULT_LOCK_DURATION, description: "Default setting_lock_duration (30 days in ms)" },
|
|
252
|
+
];
|
|
253
|
+
}
|
|
254
|
+
function buildRenderingHints(mode, max_length, hasPublish, hasTransfer, hasOrder, isPublished) {
|
|
255
|
+
return {
|
|
256
|
+
include_puzzle_template: mode === "initial_design",
|
|
257
|
+
include_risk_details: mode === "pre_publish" || mode === "stakeholder_review" || mode === "order_flow_check",
|
|
258
|
+
include_questions: mode === "pre_publish" || mode === "order_flow_check",
|
|
259
|
+
include_publish_warning: hasPublish,
|
|
260
|
+
include_transfer_warning: hasTransfer,
|
|
261
|
+
include_order_flow_warning: hasOrder,
|
|
262
|
+
include_immutability_matrix: mode === "post_publish_modify" || mode === "pre_publish" || isPublished,
|
|
263
|
+
max_length,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
export function buildPromptFromServiceContext(bundle) {
|
|
267
|
+
const lines = [];
|
|
268
|
+
const h = bundle.rendering_hints;
|
|
269
|
+
lines.push(`═══ Service Context (mode: ${bundle.mode}) ═══`);
|
|
270
|
+
lines.push("");
|
|
271
|
+
if (bundle.matched_scene) {
|
|
272
|
+
lines.push(`Scene: ${bundle.matched_scene.name}`);
|
|
273
|
+
lines.push(`Category: ${bundle.matched_scene.category}`);
|
|
274
|
+
lines.push(`Permission range: ${bundle.matched_scene.permission_index_range}`);
|
|
275
|
+
lines.push("");
|
|
276
|
+
}
|
|
277
|
+
if (bundle.matched_template) {
|
|
278
|
+
lines.push(`Suggested template: ${bundle.matched_template.id} — ${bundle.matched_template.name}`);
|
|
279
|
+
if (bundle.matched_template.notes && bundle.matched_template.notes.length > 0) {
|
|
280
|
+
lines.push("Notes:");
|
|
281
|
+
for (const note of bundle.matched_template.notes.slice(0, 3)) {
|
|
282
|
+
lines.push(` - ${note}`);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
lines.push("");
|
|
286
|
+
}
|
|
287
|
+
if (h.include_puzzle_template && bundle.puzzle_completeness) {
|
|
288
|
+
const c = bundle.puzzle_completeness;
|
|
289
|
+
lines.push("─ Puzzle Completeness ──────────────");
|
|
290
|
+
lines.push(`Complete: ${c.complete ? "YES" : "NO"}`);
|
|
291
|
+
if (c.missing.length > 0) {
|
|
292
|
+
lines.push(`Missing dimensions: ${c.missing.join(", ")}`);
|
|
293
|
+
for (const md of c.missing_details.slice(0, 3)) {
|
|
294
|
+
lines.push(` - ${md.dimension}: ${md.reason}`);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
lines.push(`Next: ${c.next_step}`);
|
|
298
|
+
lines.push("");
|
|
299
|
+
}
|
|
300
|
+
if (h.include_risk_details && bundle.relevant_risks.length > 0) {
|
|
301
|
+
lines.push(`─ Relevant Risk Rules (${bundle.relevant_risks.length}) ──────────────`);
|
|
302
|
+
for (const r of bundle.relevant_risks.slice(0, 8)) {
|
|
303
|
+
lines.push(` ${r.id} [${r.category}] — ${r.trigger}`);
|
|
304
|
+
}
|
|
305
|
+
if (bundle.relevant_risks.length > 8) {
|
|
306
|
+
lines.push(` ... and ${bundle.relevant_risks.length - 8} more`);
|
|
307
|
+
}
|
|
308
|
+
lines.push("");
|
|
309
|
+
}
|
|
310
|
+
if (bundle.risk_assessment) {
|
|
311
|
+
lines.push("─ Risk Assessment ──────────────");
|
|
312
|
+
lines.push(`Overall: ${bundle.risk_assessment.overall_risk}`);
|
|
313
|
+
lines.push(`Detected: ${bundle.risk_assessment.risks.length} risk(s)`);
|
|
314
|
+
if (bundle.risk_assessment.risks.length > 0) {
|
|
315
|
+
for (const r of bundle.risk_assessment.risks.slice(0, 5)) {
|
|
316
|
+
lines.push(` [${r.level}] ${r.id}: ${r.title}`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
lines.push("");
|
|
320
|
+
}
|
|
321
|
+
if (bundle.relevant_builtin_permissions.length > 0) {
|
|
322
|
+
lines.push(`─ Builtin Permissions (${bundle.relevant_builtin_permissions.length}) ──────────────`);
|
|
323
|
+
for (const p of bundle.relevant_builtin_permissions.slice(0, 10)) {
|
|
324
|
+
const mut = p.post_publish_mutability === "immutable" ? " [IMMUTABLE]"
|
|
325
|
+
: p.post_publish_mutability === "one_shot" ? " [ONE-SHOT]"
|
|
326
|
+
: p.post_publish_mutability === "locked_by_duration" ? " [LOCKED]"
|
|
327
|
+
: "";
|
|
328
|
+
lines.push(` [${p.index}] ${p.name}: ${p.description}${mut}`);
|
|
329
|
+
}
|
|
330
|
+
if (bundle.relevant_builtin_permissions.length > 10) {
|
|
331
|
+
lines.push(` ... and ${bundle.relevant_builtin_permissions.length - 10} more`);
|
|
332
|
+
}
|
|
333
|
+
lines.push("");
|
|
334
|
+
}
|
|
335
|
+
if (bundle.relevant_order_flow_stages.length > 0) {
|
|
336
|
+
lines.push("─ 8-Stage Order Flow ──────────────");
|
|
337
|
+
for (const stage of bundle.relevant_order_flow_stages) {
|
|
338
|
+
lines.push(` Stage ${stage.stage}: ${stage.name} ${stage.always_executed ? "(always)" : "(conditional)"}`);
|
|
339
|
+
if (stage.side_effects.length > 0) {
|
|
340
|
+
lines.push(` Side effects: ${stage.side_effects[0]}`);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
lines.push("");
|
|
344
|
+
}
|
|
345
|
+
if (h.include_publish_warning) {
|
|
346
|
+
lines.push("⚠️ PUBLISH OPERATION DETECTED — IRREVERSIBLE");
|
|
347
|
+
lines.push(" Once published: machine/arbitrations/order_allocators become PERMANENTLY immutable");
|
|
348
|
+
lines.push(" bPublished cannot be reset to false — clone Service to 'reset'");
|
|
349
|
+
lines.push("");
|
|
350
|
+
}
|
|
351
|
+
if (h.include_transfer_warning) {
|
|
352
|
+
lines.push("⚠️ TRANSFER OPERATION DETECTED — IRREVERSIBLE");
|
|
353
|
+
lines.push(" Original owner loses ALL control. New owner inherits everything.");
|
|
354
|
+
lines.push("");
|
|
355
|
+
}
|
|
356
|
+
if (h.include_order_flow_warning) {
|
|
357
|
+
lines.push("⚠️ ORDER FLOW — 8 STAGES, stock deducted at quote (Stage 3)");
|
|
358
|
+
lines.push(" If Stages 4-7 fail, stock remains deducted (not rolled back)");
|
|
359
|
+
lines.push("");
|
|
360
|
+
}
|
|
361
|
+
if (h.include_immutability_matrix && bundle.cross_object_bindings.length > 0) {
|
|
362
|
+
lines.push("─ Post-publish Immutability Matrix ──────────────");
|
|
363
|
+
for (const b of bundle.cross_object_bindings) {
|
|
364
|
+
const status = b.locked_after_publish ? "🔒 IMMUTABLE" : "🔓 mutable";
|
|
365
|
+
lines.push(` ${b.object} (${b.field}): ${status}`);
|
|
366
|
+
}
|
|
367
|
+
lines.push("");
|
|
368
|
+
}
|
|
369
|
+
if (bundle.onchain_constraints.length > 0) {
|
|
370
|
+
lines.push("─ On-chain Constraints ──────────────");
|
|
371
|
+
for (const c of bundle.onchain_constraints) {
|
|
372
|
+
lines.push(` ${c.name} = ${c.value} — ${c.description}`);
|
|
373
|
+
}
|
|
374
|
+
lines.push("");
|
|
375
|
+
}
|
|
376
|
+
if (bundle.cross_object_refs.length > 0) {
|
|
377
|
+
lines.push(`─ Cross-object References (${bundle.cross_object_refs.length}) ──────────────`);
|
|
378
|
+
for (const ref of bundle.cross_object_refs.slice(0, 6)) {
|
|
379
|
+
const lock = ref.locked_after_publish ? " [locked]" : "";
|
|
380
|
+
lines.push(` ${ref.object} (${ref.field})${lock}: ${ref.description}`);
|
|
381
|
+
}
|
|
382
|
+
if (bundle.cross_object_refs.length > 6) {
|
|
383
|
+
lines.push(` ... and ${bundle.cross_object_refs.length - 6} more`);
|
|
384
|
+
}
|
|
385
|
+
lines.push("");
|
|
386
|
+
}
|
|
387
|
+
return lines.join("\n");
|
|
388
|
+
}
|
|
389
|
+
export function getServiceContextSummary(bundle) {
|
|
390
|
+
const parts = [
|
|
391
|
+
`mode=${bundle.mode}`,
|
|
392
|
+
`scene=${bundle.matched_scene?.id ?? "none"}`,
|
|
393
|
+
`risks=${bundle.relevant_risks.length}`,
|
|
394
|
+
`permissions=${bundle.relevant_builtin_permissions.length}`,
|
|
395
|
+
];
|
|
396
|
+
if (bundle.risk_assessment)
|
|
397
|
+
parts.push(`overall_risk=${bundle.risk_assessment.overall_risk}`);
|
|
398
|
+
if (bundle.matched_template)
|
|
399
|
+
parts.push(`template=${bundle.matched_template.id}`);
|
|
400
|
+
if (bundle.relevant_order_flow_stages.length > 0)
|
|
401
|
+
parts.push(`order_flow=8-stages`);
|
|
402
|
+
return parts.join(", ");
|
|
403
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export interface ServiceScene {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
category: "retail" | "rental" | "subscription" | "workflow" | "arbitration" | "compensation_fund" | "reward" | "dynamic_pricing" | "multi_allocator" | "buy_guard" | "order_allocator" | "general";
|
|
5
|
+
permission_index_range: string;
|
|
6
|
+
builtin_indexes: ServicePermissionEntry[];
|
|
7
|
+
cross_object_bindings: ServiceCrossObjectBinding[];
|
|
8
|
+
order_flow_stages: ServiceOrderFlowStage[];
|
|
9
|
+
owner_operations: string[];
|
|
10
|
+
admin_operations: string[];
|
|
11
|
+
permission_index_operations: string[];
|
|
12
|
+
mutable_after_publish: {
|
|
13
|
+
machine: boolean;
|
|
14
|
+
arbitrations: boolean;
|
|
15
|
+
order_allocators: boolean;
|
|
16
|
+
buy_guard: boolean;
|
|
17
|
+
rewards: "mutable" | "locked_by_duration";
|
|
18
|
+
compensation_fund_withdraw: "mutable" | "locked_by_duration";
|
|
19
|
+
compensation_fund_receive: "mutable" | "locked_by_duration";
|
|
20
|
+
sales: boolean;
|
|
21
|
+
description: boolean;
|
|
22
|
+
location: boolean;
|
|
23
|
+
repositories: boolean;
|
|
24
|
+
customer_required: boolean;
|
|
25
|
+
discount: boolean;
|
|
26
|
+
um: boolean;
|
|
27
|
+
pause: boolean;
|
|
28
|
+
};
|
|
29
|
+
publish_prerequisites: string[];
|
|
30
|
+
common_patterns: string[];
|
|
31
|
+
recommended_templates: string[];
|
|
32
|
+
}
|
|
33
|
+
export interface ServicePermissionEntry {
|
|
34
|
+
index: number;
|
|
35
|
+
name: string;
|
|
36
|
+
description: string;
|
|
37
|
+
governed_operation: string;
|
|
38
|
+
post_publish_mutability: "mutable" | "immutable" | "one_shot" | "locked_by_duration" | "na";
|
|
39
|
+
}
|
|
40
|
+
export interface ServiceCrossObjectBinding {
|
|
41
|
+
object: "Machine" | "Allocation" | "Arbitration" | "Repository" | "Reward" | "Guard" | "Treasury" | "Contact" | "Progress";
|
|
42
|
+
field: string;
|
|
43
|
+
required: boolean;
|
|
44
|
+
locked_after_publish: boolean;
|
|
45
|
+
notes: string;
|
|
46
|
+
}
|
|
47
|
+
export interface ServiceOrderFlowStage {
|
|
48
|
+
stage: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
|
49
|
+
name: "pre_check" | "wip_verify" | "quote" | "create_order" | "create_allocation" | "create_progress" | "post_actions" | "return_result";
|
|
50
|
+
preconditions: string[];
|
|
51
|
+
side_effects: string[];
|
|
52
|
+
always_executed: boolean;
|
|
53
|
+
}
|
|
54
|
+
export declare const SERVICE_PERMISSIONS: ServicePermissionEntry[];
|
|
55
|
+
export declare const SERVICE_ORDER_FLOW_STAGES: ServiceOrderFlowStage[];
|
|
56
|
+
export declare const SERVICE_CROSS_OBJECT_BINDINGS: ServiceCrossObjectBinding[];
|
|
57
|
+
export declare const SERVICE_SCENES: ServiceScene[];
|
|
58
|
+
export declare const SERVICE_LEDGER_VERSION = "1.0.0";
|
|
59
|
+
export declare function getScenesByCategory(category: ServiceScene["category"]): ServiceScene[];
|
|
60
|
+
export declare function findSceneById(id: string): ServiceScene | undefined;
|
|
61
|
+
export declare function getServicePermissionByIndex(index: number): ServicePermissionEntry | undefined;
|
|
62
|
+
export declare function isServicePermission(index: number): boolean;
|
|
63
|
+
export declare function getPermissionsByMutability(mutability: ServicePermissionEntry["post_publish_mutability"]): ServicePermissionEntry[];
|
|
64
|
+
export declare function getImmutablePostPublishPermissions(): ServicePermissionEntry[];
|
|
65
|
+
export declare function getLockedByDurationPermissions(): ServicePermissionEntry[];
|
|
66
|
+
export declare function inferSceneFromIntent(intent: string): ServiceScene | undefined;
|
|
67
|
+
export declare function getAllServiceScenes(): ServiceScene[];
|
|
68
|
+
export declare function getServiceScenesCount(): number;
|
|
69
|
+
export declare function getServicePermissionsCount(): number;
|
|
70
|
+
export declare function getOrderFlowStage(stage: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8): ServiceOrderFlowStage | undefined;
|
|
71
|
+
export declare function getCrossObjectBindings(): ServiceCrossObjectBinding[];
|