@wowok/agent-mcp 2.7.1 → 2.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/index.js +1 -1
- package/dist/config/runtime.js +1 -238
- package/dist/customer/customer-advice.js +1 -130
- package/dist/customer/index.js +1 -11
- package/dist/customer/industry-risks.js +1 -438
- package/dist/customer/info-puzzle.js +1 -681
- package/dist/customer/order-monitor.js +1 -328
- package/dist/customer/order-strategy.js +1 -373
- package/dist/customer/post-purchase.js +1 -351
- package/dist/customer/preorder-compare.js +1 -34
- package/dist/customer/reminder-system.js +1 -316
- package/dist/customer/risk-assessment.js +1 -397
- package/dist/customer/types.js +1 -13
- package/dist/customer/user-preferences.js +1 -460
- package/dist/evaluation/arbitration-game.d.ts +9 -2
- package/dist/evaluation/arbitration-game.js +1 -48
- package/dist/evaluation/builtins/demand-match.js +1 -153
- package/dist/evaluation/builtins/index.js +1 -10
- package/dist/evaluation/builtins/service-risk.js +1 -55
- package/dist/evaluation/capability.js +1 -13
- package/dist/evaluation/composer.js +1 -40
- package/dist/evaluation/engine.js +1 -175
- package/dist/evaluation/extract.js +1 -115
- package/dist/evaluation/game-strategy.d.ts +27 -0
- package/dist/evaluation/game-strategy.js +1 -0
- package/dist/evaluation/gap.js +1 -100
- package/dist/evaluation/index.d.ts +1 -0
- package/dist/evaluation/index.js +1 -11
- package/dist/evaluation/node-game.d.ts +31 -3
- package/dist/evaluation/node-game.js +1 -57
- package/dist/evaluation/region.js +1 -36
- package/dist/evaluation/types.d.ts +1 -0
- package/dist/evaluation/types.js +1 -1
- package/dist/evaluation/user-injection.js +1 -27
- package/dist/experience/experience-reuse.js +1 -103
- package/dist/experience/index.js +1 -5
- package/dist/experience/intent-distill.js +1 -83
- package/dist/experience/realtime-feedback.js +1 -94
- package/dist/experience/types.js +1 -1
- package/dist/experience/user-profile.js +1 -171
- package/dist/extensions/business-modules.js +1 -287
- package/dist/extensions/capability-manifest.js +1 -781
- package/dist/extensions/constraint-registry.js +1 -198
- package/dist/extensions/index.js +1 -6
- package/dist/extensions/metric-registry.js +1 -257
- package/dist/extensions/mode-evaluator.js +1 -170
- package/dist/extensions/modes.js +1 -499
- package/dist/extensions/registry.js +1 -717
- package/dist/extensions/types.js +1 -1
- package/dist/harness/auto-escalation.js +1 -68
- package/dist/harness/checkpoint.js +1 -129
- package/dist/harness/index.js +1 -78
- package/dist/harness/plan.js +1 -315
- package/dist/harness/recover.js +1 -139
- package/dist/harness/types.js +1 -1
- package/dist/harness/verify.js +1 -237
- package/dist/index.js +1 -273
- package/dist/intent/enrich.js +1 -67
- package/dist/intent/index.js +1 -60
- package/dist/intent/matcher.js +1 -81
- package/dist/intent/store.js +1 -55
- package/dist/intent/types.js +1 -10
- package/dist/knowledge/acquisition-flywheel.js +1 -192
- package/dist/knowledge/allocation-confirm.js +1 -534
- package/dist/knowledge/allocation-context.js +1 -249
- package/dist/knowledge/allocation-ledger.js +1 -463
- package/dist/knowledge/allocation-puzzle.js +1 -298
- package/dist/knowledge/allocation-risk.js +1 -568
- package/dist/knowledge/allocation-templates.js +1 -970
- package/dist/knowledge/allocation-translation.js +1 -585
- package/dist/knowledge/arb-risk.js +1 -210
- package/dist/knowledge/arbitration-confirm.js +1 -559
- package/dist/knowledge/arbitration-context.js +1 -505
- package/dist/knowledge/arbitration-ledger.js +1 -521
- package/dist/knowledge/arbitration-puzzle.js +1 -304
- package/dist/knowledge/arbitration-risk.js +1 -423
- package/dist/knowledge/arbitration-templates.js +1 -276
- package/dist/knowledge/arbitration-translation.js +1 -487
- package/dist/knowledge/arbitration-trust.js +1 -117
- package/dist/knowledge/audit-rules.js +1 -141
- package/dist/knowledge/bridge-risk.js +1 -263
- package/dist/knowledge/contact-risk.js +1 -200
- package/dist/knowledge/contact-templates.js +1 -60
- package/dist/knowledge/demand-confirm.js +1 -206
- package/dist/knowledge/demand-matching.js +1 -132
- package/dist/knowledge/demand-risk.js +1 -240
- package/dist/knowledge/demand-translation.js +1 -354
- package/dist/knowledge/deployment-scanner.js +1 -823
- package/dist/knowledge/dynamic-pricing.js +1 -87
- package/dist/knowledge/examples-scanner-cli.js +1 -26
- package/dist/knowledge/examples-scanner.js +1 -843
- package/dist/knowledge/flywheel-loop.js +1 -404
- package/dist/knowledge/fund-layer.js +1 -973
- package/dist/knowledge/glossary.js +1 -211
- package/dist/knowledge/guard-confirm.js +1 -406
- package/dist/knowledge/guard-context.js +1 -287
- package/dist/knowledge/guard-design-patterns.js +1 -360
- package/dist/knowledge/guard-ledger.js +1 -260
- package/dist/knowledge/guard-lint.js +1 -670
- package/dist/knowledge/guard-migration.js +1 -228
- package/dist/knowledge/guard-puzzle.js +1 -805
- package/dist/knowledge/guard-render.js +1 -700
- package/dist/knowledge/guard-risk.js +1 -1879
- package/dist/knowledge/guard-submission-prompt.js +1 -171
- package/dist/knowledge/guard-templates.js +1 -1105
- package/dist/knowledge/guard-translation.js +1 -1119
- package/dist/knowledge/index.js +1 -436
- package/dist/knowledge/industry-evolution.js +1 -323
- package/dist/knowledge/industry-generalizer.js +1 -381
- package/dist/knowledge/industry-registry.js +1 -174
- package/dist/knowledge/intent-metrics.d.ts +4 -3
- package/dist/knowledge/intent-metrics.js +1 -566
- package/dist/knowledge/machine-confirm.js +1 -559
- package/dist/knowledge/machine-context.js +1 -833
- package/dist/knowledge/machine-ledger.js +1 -338
- package/dist/knowledge/machine-puzzle.js +1 -494
- package/dist/knowledge/machine-render.js +1 -565
- package/dist/knowledge/machine-risk.js +1 -669
- package/dist/knowledge/machine-templates.js +1 -1597
- package/dist/knowledge/machine-topology.js +1 -234
- package/dist/knowledge/machine-translation.js +1 -513
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
- package/dist/knowledge/mcp-schema-audit.js +1 -777
- package/dist/knowledge/onchain-constants.js +1 -35
- package/dist/knowledge/order-confirm.js +1 -573
- package/dist/knowledge/order-context.js +1 -390
- package/dist/knowledge/order-ledger.js +1 -341
- package/dist/knowledge/order-puzzle.js +1 -255
- package/dist/knowledge/order-risk.js +1 -653
- package/dist/knowledge/order-templates.js +1 -368
- package/dist/knowledge/order-translation.js +1 -550
- package/dist/knowledge/overrides-loader.js +1 -65
- package/dist/knowledge/passport-confirm.js +1 -531
- package/dist/knowledge/passport-context.js +1 -306
- package/dist/knowledge/passport-ledger.js +1 -282
- package/dist/knowledge/passport-puzzle.js +1 -333
- package/dist/knowledge/passport-risk.js +1 -450
- package/dist/knowledge/passport-templates.js +1 -568
- package/dist/knowledge/passport-translation.js +1 -516
- package/dist/knowledge/payment-risk.js +1 -249
- package/dist/knowledge/permission-confirm.js +1 -426
- package/dist/knowledge/permission-context.js +1 -224
- package/dist/knowledge/permission-ledger.js +1 -403
- package/dist/knowledge/permission-puzzle.js +1 -173
- package/dist/knowledge/permission-risk.js +1 -411
- package/dist/knowledge/permission-templates.js +1 -234
- package/dist/knowledge/permission-translation.js +1 -350
- package/dist/knowledge/personal-risk.js +1 -212
- package/dist/knowledge/process-model.js +1 -160
- package/dist/knowledge/progress-confirm.js +1 -456
- package/dist/knowledge/progress-context.js +1 -452
- package/dist/knowledge/progress-ledger.js +1 -330
- package/dist/knowledge/progress-puzzle.js +1 -219
- package/dist/knowledge/progress-risk.js +1 -461
- package/dist/knowledge/progress-templates.js +1 -228
- package/dist/knowledge/progress-translation.js +1 -405
- package/dist/knowledge/proof-confirm.js +1 -187
- package/dist/knowledge/proof-risk.js +1 -207
- package/dist/knowledge/proof-translation.js +1 -283
- package/dist/knowledge/registrar-risk.js +1 -217
- package/dist/knowledge/repository-confirm.js +1 -286
- package/dist/knowledge/repository-risk.js +1 -373
- package/dist/knowledge/repository-translation.js +1 -445
- package/dist/knowledge/reputation-rules.js +1 -99
- package/dist/knowledge/resource-risk.js +1 -157
- package/dist/knowledge/reward-confirm.js +1 -526
- package/dist/knowledge/reward-context.js +1 -504
- package/dist/knowledge/reward-ledger.js +1 -502
- package/dist/knowledge/reward-puzzle.js +1 -300
- package/dist/knowledge/reward-risk.js +1 -627
- package/dist/knowledge/reward-templates.js +1 -197
- package/dist/knowledge/reward-translation.js +1 -501
- package/dist/knowledge/safety-rules.js +1 -404
- package/dist/knowledge/scenario-modes.js +1 -321
- package/dist/knowledge/service-confirm.js +1 -807
- package/dist/knowledge/service-context.js +1 -403
- package/dist/knowledge/service-ledger.js +1 -609
- package/dist/knowledge/service-puzzle.js +1 -236
- package/dist/knowledge/service-risk.js +1 -651
- package/dist/knowledge/service-templates.js +1 -456
- package/dist/knowledge/service-translation.js +1 -622
- package/dist/knowledge/template-registry.js +1 -353
- package/dist/knowledge/tool-constraints.js +1 -195
- package/dist/knowledge/tools-reference.js +1 -178
- package/dist/knowledge/treasury-confirm.js +1 -512
- package/dist/knowledge/treasury-context.js +1 -363
- package/dist/knowledge/treasury-ledger.js +1 -300
- package/dist/knowledge/treasury-puzzle.js +1 -216
- package/dist/knowledge/treasury-risk.js +1 -440
- package/dist/knowledge/treasury-templates.js +1 -358
- package/dist/knowledge/treasury-translation.js +1 -498
- package/dist/knowledge/trust-metrics.js +1 -198
- package/dist/knowledge/util-risk.js +1 -135
- package/dist/loop-engineering/aggregate.js +1 -132
- package/dist/loop-engineering/context-collect.js +1 -83
- package/dist/loop-engineering/diagnose.js +1 -273
- package/dist/loop-engineering/improve.js +1 -405
- package/dist/loop-engineering/index.js +1 -4
- package/dist/loop-engineering/pipeline.js +1 -56
- package/dist/mode-market/index.js +1 -3
- package/dist/mode-market/registry.js +1 -124
- package/dist/mode-market/review.js +1 -214
- package/dist/mode-market/submission.js +1 -85
- package/dist/participation/collaborator-interest.d.ts +23 -0
- package/dist/participation/collaborator-interest.js +1 -0
- package/dist/participation/customer-interest.d.ts +25 -0
- package/dist/participation/customer-interest.js +1 -0
- package/dist/participation/merchant-interest.js +1 -100
- package/dist/participation/radar-core.d.ts +13 -3
- package/dist/participation/radar-core.js +1 -269
- package/dist/participation/supplier-interest.d.ts +25 -0
- package/dist/participation/supplier-interest.js +1 -0
- package/dist/persona/analyzer.js +1 -66
- package/dist/persona/bridge.js +1 -86
- package/dist/persona/defaults.js +1 -195
- package/dist/persona/experience-bridge.js +1 -23
- package/dist/persona/index.js +1 -71
- package/dist/persona/model.js +1 -111
- package/dist/persona/store.js +1 -62
- package/dist/persona/types.d.ts +3 -1
- package/dist/persona/types.js +1 -5
- package/dist/project/business-puzzle.js +1 -383
- package/dist/project/context-assembly.js +1 -254
- package/dist/project/deployment-bridge.js +1 -120
- package/dist/project/deployment-doc.js +1 -1126
- package/dist/project/edit-planner.js +1 -1342
- package/dist/project/evaluation.js +1 -2011
- package/dist/project/game-theory.js +1 -177
- package/dist/project/graph-builder.js +1 -656
- package/dist/project/graph.js +1 -340
- package/dist/project/handlers.js +1 -1784
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +1 -301
- package/dist/project/intent-analyzer.js +1 -149
- package/dist/project/machine-nodes.js +1 -36
- package/dist/project/merchant-guide.js +1 -264
- package/dist/project/migration.js +1 -125
- package/dist/project/mode-actions.js +1 -309
- package/dist/project/namespace.js +1 -206
- package/dist/project/participation-radar.js +1 -428
- package/dist/project/pipeline-actions.js +1 -109
- package/dist/project/project-store.js +1 -422
- package/dist/project/query.js +1 -153
- package/dist/project/reverse-mapping.d.ts +34 -0
- package/dist/project/reverse-mapping.js +1 -0
- package/dist/project/risk-aggregator.js +1 -295
- package/dist/project/rollback-policy.js +1 -290
- package/dist/project/semantic-assembler.js +1 -345
- package/dist/project/semantic-graph.js +1 -292
- package/dist/project/stage-gate.js +1 -369
- package/dist/project/substep-trace.js +1 -332
- package/dist/project/task-tracker.js +1 -78
- package/dist/role/derivation.d.ts +18 -0
- package/dist/role/derivation.js +1 -0
- package/dist/role/index.d.ts +5 -0
- package/dist/role/index.js +1 -0
- package/dist/role/model.d.ts +8 -0
- package/dist/role/model.js +1 -0
- package/dist/role/resolution.d.ts +11 -0
- package/dist/role/resolution.js +1 -0
- package/dist/role/types.d.ts +11 -0
- package/dist/role/types.js +1 -0
- package/dist/rules.js +1 -52
- package/dist/safety/confirm-gate.js +1 -88
- package/dist/safety/index.js +1 -3
- package/dist/safety/preview.js +1 -52
- package/dist/schema/call/allocation.js +1 -34
- package/dist/schema/call/arbitration.js +1 -113
- package/dist/schema/call/base.d.ts +15 -15
- package/dist/schema/call/base.js +1 -370
- package/dist/schema/call/bridge-handler.js +1 -265
- package/dist/schema/call/bridge.d.ts +7 -7
- package/dist/schema/call/bridge.js +1 -458
- package/dist/schema/call/contact.js +1 -37
- package/dist/schema/call/demand.js +1 -47
- package/dist/schema/call/guard.js +1 -161
- package/dist/schema/call/handler.js +1 -322
- package/dist/schema/call/index.js +1 -20
- package/dist/schema/call/machine.js +1 -193
- package/dist/schema/call/order.js +1 -35
- package/dist/schema/call/payment.js +1 -37
- package/dist/schema/call/permission-handler.js +1 -54
- package/dist/schema/call/permission.js +1 -105
- package/dist/schema/call/personal.js +1 -78
- package/dist/schema/call/progress.js +1 -47
- package/dist/schema/call/proof.js +1 -33
- package/dist/schema/call/repository.js +1 -77
- package/dist/schema/call/reward.js +1 -30
- package/dist/schema/call/semantic.js +1 -1679
- package/dist/schema/call/service.js +1 -184
- package/dist/schema/call/treasury.js +1 -71
- package/dist/schema/common/index.js +1 -407
- package/dist/schema/config/index.js +1 -68
- package/dist/schema/evaluation/index.d.ts +213 -16
- package/dist/schema/evaluation/index.js +1 -356
- package/dist/schema/index.js +1 -17
- package/dist/schema/intent-radar/index.d.ts +13 -13
- package/dist/schema/intent-radar/index.js +1 -89
- package/dist/schema/local/index.d.ts +21 -21
- package/dist/schema/local/index.js +1 -927
- package/dist/schema/local/wip.js +1 -187
- package/dist/schema/messenger/index.d.ts +7 -7
- package/dist/schema/messenger/index.js +1 -475
- package/dist/schema/operations.d.ts +7 -7
- package/dist/schema/operations.js +1 -520
- package/dist/schema/persona/index.d.ts +54 -54
- package/dist/schema/persona/index.js +1 -148
- package/dist/schema/project/index.d.ts +94 -48
- package/dist/schema/project/index.js +1 -2057
- package/dist/schema/query/index.d.ts +423 -7
- package/dist/schema/query/index.js +1 -1646
- package/dist/schema/schema-query/index.js +1 -104
- package/dist/schema/schema-version.js +1 -76
- package/dist/schema/sync-layer4.js +1 -286
- package/dist/schema/task-status.js +1 -36
- package/dist/schema/trust/index.js +1 -314
- package/dist/schema/utils/guard-parser.js +1 -419
- package/dist/schema/utils/guard-query-utils.js +1 -46
- package/dist/schema/utils/node-parser.js +1 -369
- package/dist/schema/utils/object-type-utils.js +1 -35
- package/dist/schema/utils/permission-index-utils.js +1 -7
- package/dist/schema/utils/permission-machine-check.js +1 -121
- package/dist/schema/utils/skills-recommendation.js +1 -77
- package/dist/schema-query/index.js +1 -810
- package/dist/schemas/account_operation.output.json +5 -2
- package/dist/schemas/bridge_operation.output.json +5 -2
- package/dist/schemas/evaluation_operation.output.json +112 -7
- package/dist/schemas/evaluation_operation.schema.json +93 -6
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/intent_radar.output.json +4 -1
- package/dist/schemas/intent_radar.schema.json +4 -1
- package/dist/schemas/local_info_operation.output.json +5 -2
- package/dist/schemas/local_mark_operation.output.json +5 -2
- package/dist/schemas/messenger_operation.output.json +5 -2
- package/dist/schemas/onchain_events.output.json +5 -2
- package/dist/schemas/onchain_operations.output.json +5 -2
- package/dist/schemas/onchain_operations.schema.json +4 -4
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_service.schema.json +1 -1
- package/dist/schemas/onchain_table_data.output.json +6 -3
- package/dist/schemas/persona_operation.output.json +4 -1
- package/dist/schemas/persona_operation.schema.json +4 -1
- package/dist/schemas/project_operation.output.json +28 -8
- package/dist/schemas/query_toolkit.output.json +8 -5
- package/dist/schemas/wowok_buildin_info.output.json +132 -0
- package/dist/schemas/wowok_buildin_info.schema.json +14 -0
- package/dist/telemetry/index.js +1 -112
- package/dist/telemetry/redact.js +1 -23
- package/dist/telemetry/storage.js +1 -80
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -74
- package/dist/tools/handlers/evaluation.js +1 -123
- package/dist/tools/handlers/file-export.js +1 -90
- package/dist/tools/handlers/intent-radar.js +1 -76
- package/dist/tools/handlers/local.js +1 -53
- package/dist/tools/handlers/messenger.js +1 -188
- package/dist/tools/handlers/onchain.js +1 -1180
- package/dist/tools/handlers/persona.js +1 -89
- package/dist/tools/handlers/project.js +1 -211
- package/dist/tools/handlers/query.js +1 -434
- package/dist/tools/handlers/schema-query.js +1 -176
- package/dist/tools/handlers/task-status.js +1 -26
- package/dist/tools/handlers/trust.js +1 -380
- package/dist/tools/handlers/wip.js +1 -90
- package/dist/tools/index.js +1 -1382
- package/dist/tools/retry.js +1 -85
- package/dist/tools/rules-hook.js +1 -23
- package/dist/tools/shared.js +1 -130
- package/dist/tools/types.js +1 -1
- package/dist/tools/upgrade-check.d.ts +19 -0
- package/dist/tools/upgrade-check.js +1 -0
- package/dist/tools/wip-deploy-assist.js +1 -306
- package/dist/tools/wrap.js +1 -500
- package/package.json +4 -2
|
@@ -1,452 +1 @@
|
|
|
1
|
-
import { MAX_NAMED_OPERATOR_COUNT, MAX_NAMED_OPERATOR_ADDRESS_COUNT, MAX_CONTEXT_REPOSITORY_COUNT, } from "@wowok/wowok";
|
|
2
|
-
import { PROGRESS_PERMISSIONS, PROGRESS_LEDGER_VERSION, PROGRESS_CROSS_OBJECT_REFS, inferSceneFromIntent, getScenesByIndustry, getScenesByPhase, getAllBuiltinPermissions, getProgressScenesCount, validateNamedOperatorAddressList, validateNamedOperatorCount, validateContextRepositoryCount, } from "./progress-ledger.js";
|
|
3
|
-
import { initPuzzleFromIntent, checkPuzzleCompleteness, } from "./progress-puzzle.js";
|
|
4
|
-
import { PROGRESS_RISK_VERSION, assessProgressRisks, getAllProgressRiskRules, getProgressRiskRulesCount, } from "./progress-risk.js";
|
|
5
|
-
import { PROGRESS_TRANSLATION_VERSION, PROGRESS_SEMANTIC_TO_SCHEMA_RULES, PROGRESS_SCHEMA_TO_SEMANTIC_RULES, PROGRESS_CONSTRAINT_RULES, matchSemanticPattern, } from "./progress-translation.js";
|
|
6
|
-
import { PROGRESS_TEMPLATES, PROGRESS_TEMPLATES_VERSION, getProgressTemplatesByScene, listProgressTemplates, } from "./progress-templates.js";
|
|
7
|
-
import { PROGRESS_CONFIRM_VERSION, PROGRESS_OPERATION_CHECKLIST, PROGRESS_CONFIRMATION_QUESTIONS, } from "./progress-confirm.js";
|
|
8
|
-
export const PROGRESS_CONTEXT_VERSION = "1.0.0";
|
|
9
|
-
export function buildProgressContext(input) {
|
|
10
|
-
const max_length = input.max_length ?? 4000;
|
|
11
|
-
let matched_scene;
|
|
12
|
-
if (input.intent) {
|
|
13
|
-
matched_scene = inferSceneFromIntent(input.intent);
|
|
14
|
-
}
|
|
15
|
-
if (!matched_scene && input.target_phase) {
|
|
16
|
-
const phaseScenes = getScenesByPhase(input.target_phase);
|
|
17
|
-
if (phaseScenes.length > 0)
|
|
18
|
-
matched_scene = phaseScenes[0];
|
|
19
|
-
}
|
|
20
|
-
if (!matched_scene && input.target_industry) {
|
|
21
|
-
const industryScenes = getScenesByIndustry(input.target_industry);
|
|
22
|
-
if (industryScenes.length > 0)
|
|
23
|
-
matched_scene = industryScenes[0];
|
|
24
|
-
}
|
|
25
|
-
let matched_template;
|
|
26
|
-
if (matched_scene) {
|
|
27
|
-
const templates = getProgressTemplatesByScene(matched_scene.id);
|
|
28
|
-
if (templates.length > 0)
|
|
29
|
-
matched_template = templates[0];
|
|
30
|
-
}
|
|
31
|
-
let matched_pattern;
|
|
32
|
-
if (input.intent) {
|
|
33
|
-
const patterns = matchSemanticPattern(input.intent);
|
|
34
|
-
if (patterns.length > 0)
|
|
35
|
-
matched_pattern = patterns[0];
|
|
36
|
-
}
|
|
37
|
-
let puzzle_state;
|
|
38
|
-
let puzzle_completeness;
|
|
39
|
-
if (input.mode === "initial_design" && input.intent) {
|
|
40
|
-
puzzle_state = initPuzzleFromIntent({ rule_sentence: input.intent });
|
|
41
|
-
puzzle_completeness = checkPuzzleCompleteness(puzzle_state);
|
|
42
|
-
}
|
|
43
|
-
const relevant_risks = filterRiskRules(input.mode, input.stakeholder, matched_scene);
|
|
44
|
-
let risk_assessment;
|
|
45
|
-
if (input.mode === "pre_advance" && input.progress_json) {
|
|
46
|
-
const ctx = {
|
|
47
|
-
object: input.progress_json.object,
|
|
48
|
-
task: input.progress_json.task,
|
|
49
|
-
repository: input.progress_json.repository,
|
|
50
|
-
progress_namedOperator: input.progress_json.progress_namedOperator,
|
|
51
|
-
operate: input.progress_json.operate,
|
|
52
|
-
current_machine: input.current_machine,
|
|
53
|
-
machine_published: input.machine_published,
|
|
54
|
-
current_task: input.current_task,
|
|
55
|
-
current_named_operator_count: input.current_named_operator_count,
|
|
56
|
-
current_context_repository_count: input.current_context_repository_count,
|
|
57
|
-
current_node: input.current_node,
|
|
58
|
-
forward_already_accomplished: input.forward_already_accomplished,
|
|
59
|
-
holder_address: input.holder_address,
|
|
60
|
-
signer: input.signer,
|
|
61
|
-
forward_named_operator: input.forward_named_operator,
|
|
62
|
-
forward_permission_index: input.forward_permission_index,
|
|
63
|
-
forward_has_guard: input.forward_has_guard,
|
|
64
|
-
target_objects_types: input.target_objects_types,
|
|
65
|
-
};
|
|
66
|
-
risk_assessment = assessProgressRisks(ctx);
|
|
67
|
-
}
|
|
68
|
-
const relevant_checklist = filterChecklist(input.mode);
|
|
69
|
-
const relevant_questions = filterQuestions(input.mode);
|
|
70
|
-
const relevant_builtin_permissions = matched_scene
|
|
71
|
-
? matched_scene.builtin_indexes_consumed
|
|
72
|
-
: getAllBuiltinPermissions();
|
|
73
|
-
const cross_object_refs = buildCrossObjectRefs(input.target_phase, matched_scene);
|
|
74
|
-
const onchain_constraints = buildOnchainConstraints();
|
|
75
|
-
const rendering_hints = buildRenderingHints(input.mode, max_length, input.progress_json?.operate?.op === "adminUnhold", !!input.progress_json?.task);
|
|
76
|
-
return {
|
|
77
|
-
version: PROGRESS_CONTEXT_VERSION,
|
|
78
|
-
mode: input.mode,
|
|
79
|
-
stakeholder_perspective: input.stakeholder,
|
|
80
|
-
matched_scene,
|
|
81
|
-
matched_template,
|
|
82
|
-
matched_pattern,
|
|
83
|
-
puzzle_state,
|
|
84
|
-
puzzle_completeness,
|
|
85
|
-
relevant_risks,
|
|
86
|
-
risk_assessment,
|
|
87
|
-
relevant_checklist,
|
|
88
|
-
relevant_questions,
|
|
89
|
-
relevant_builtin_permissions,
|
|
90
|
-
cross_object_refs,
|
|
91
|
-
onchain_constraints,
|
|
92
|
-
rendering_hints,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
function filterRiskRules(mode, stakeholder, scene) {
|
|
96
|
-
const allRules = getAllProgressRiskRules();
|
|
97
|
-
if (mode === "initial_design") {
|
|
98
|
-
return allRules.filter(r => r.category === "structural" || r.category === "lifecycle");
|
|
99
|
-
}
|
|
100
|
-
if (mode === "pre_advance") {
|
|
101
|
-
return allRules;
|
|
102
|
-
}
|
|
103
|
-
if (mode === "post_task_binding") {
|
|
104
|
-
return allRules.filter(r => r.id !== "R-PR-2-01");
|
|
105
|
-
}
|
|
106
|
-
if (mode === "stakeholder_review" && stakeholder) {
|
|
107
|
-
if (stakeholder === "owner") {
|
|
108
|
-
return allRules.filter(r => r.category === "permission" || r.category === "lifecycle" || r.category === "cross_object");
|
|
109
|
-
}
|
|
110
|
-
if (stakeholder === "named_operator") {
|
|
111
|
-
return allRules.filter(r => r.category === "permission" || r.id === "R-PR-4-02" || r.id === "R-PR-4-03");
|
|
112
|
-
}
|
|
113
|
-
if (stakeholder === "submitter") {
|
|
114
|
-
return allRules.filter(r => r.category === "semantic" || r.id === "R-PR-3-03" || r.id === "R-PR-4-02" || r.id === "R-PR-4-03");
|
|
115
|
-
}
|
|
116
|
-
if (stakeholder === "system") {
|
|
117
|
-
return allRules.filter(r => r.category === "cross_object" || r.category === "structural");
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (mode === "apply_check") {
|
|
121
|
-
return allRules.filter(r => r.category === "cross_object" || r.id === "R-PR-4-01");
|
|
122
|
-
}
|
|
123
|
-
return allRules;
|
|
124
|
-
}
|
|
125
|
-
function filterChecklist(mode) {
|
|
126
|
-
if (mode === "initial_design") {
|
|
127
|
-
return PROGRESS_OPERATION_CHECKLIST.filter(i => ["C-PR-01", "C-PR-03", "C-PR-04", "C-PR-05"].includes(i.id));
|
|
128
|
-
}
|
|
129
|
-
if (mode === "post_task_binding") {
|
|
130
|
-
return PROGRESS_OPERATION_CHECKLIST.filter(i => i.id !== "C-PR-06");
|
|
131
|
-
}
|
|
132
|
-
if (mode === "stakeholder_review") {
|
|
133
|
-
return PROGRESS_OPERATION_CHECKLIST.filter(i => ["C-PR-01", "C-PR-02", "C-PR-07", "C-PR-09", "C-PR-10"].includes(i.id));
|
|
134
|
-
}
|
|
135
|
-
return PROGRESS_OPERATION_CHECKLIST;
|
|
136
|
-
}
|
|
137
|
-
function filterQuestions(mode) {
|
|
138
|
-
if (mode === "pre_advance") {
|
|
139
|
-
return PROGRESS_CONFIRMATION_QUESTIONS;
|
|
140
|
-
}
|
|
141
|
-
if (mode === "post_task_binding") {
|
|
142
|
-
return PROGRESS_CONFIRMATION_QUESTIONS.filter(q => q.id !== "QPR2");
|
|
143
|
-
}
|
|
144
|
-
if (mode === "initial_design") {
|
|
145
|
-
return PROGRESS_CONFIRMATION_QUESTIONS.filter(q => q.id === "QPR5");
|
|
146
|
-
}
|
|
147
|
-
return [];
|
|
148
|
-
}
|
|
149
|
-
function buildCrossObjectRefs(targetPhase, scene) {
|
|
150
|
-
const refs = PROGRESS_CROSS_OBJECT_REFS.map(r => ({
|
|
151
|
-
object: r.object,
|
|
152
|
-
phase: r.phase,
|
|
153
|
-
relationship: r.relationship,
|
|
154
|
-
description: r.relationship,
|
|
155
|
-
}));
|
|
156
|
-
if (targetPhase) {
|
|
157
|
-
return refs.filter(r => r.phase === targetPhase || r.phase === "universal");
|
|
158
|
-
}
|
|
159
|
-
if (scene) {
|
|
160
|
-
const scenePhases = scene.phases;
|
|
161
|
-
return refs.filter(r => r.phase === "universal" || scenePhases.includes(r.phase));
|
|
162
|
-
}
|
|
163
|
-
return refs;
|
|
164
|
-
}
|
|
165
|
-
function buildOnchainConstraints() {
|
|
166
|
-
return [
|
|
167
|
-
{
|
|
168
|
-
name: "MAX_NAMED_OPERATOR_COUNT",
|
|
169
|
-
value: MAX_NAMED_OPERATOR_COUNT,
|
|
170
|
-
description: "Maximum named_operator namespace entries per Progress",
|
|
171
|
-
error_code: "E_MAX_NAMED_OPERATOR_COUNT",
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
name: "MAX_NAMED_OPERATOR_ADDRESS_COUNT",
|
|
175
|
-
value: MAX_NAMED_OPERATOR_ADDRESS_COUNT,
|
|
176
|
-
description: "Maximum addresses per named_operator namespace entry",
|
|
177
|
-
error_code: "E_MAX_NAMED_OPERATOR_ADDRESS_COUNT",
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
name: "MAX_CONTEXT_REPOSITORY_COUNT",
|
|
181
|
-
value: MAX_CONTEXT_REPOSITORY_COUNT,
|
|
182
|
-
description: "Maximum context_repositories per Progress",
|
|
183
|
-
error_code: "E_MAX_CONTEXT_REPOSITORY_COUNT",
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
name: "PROGRESS_NEW (220)",
|
|
187
|
-
value: 220,
|
|
188
|
-
description: "Builtin: create new Progress (asserted by progress::new / new_with_passport; bypassed by service::buy → new_imp)",
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
name: "PROGRESS_NAMED_OPERATOR (221)",
|
|
192
|
-
value: 221,
|
|
193
|
-
description: "Builtin: manage named_operator namespace (add/set/remove)",
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
name: "PROGRESS_TASK (222)",
|
|
197
|
-
value: 222,
|
|
198
|
-
description: "Builtin: submit task (one-time, immutable — E_TASK_ALREADY_SET)",
|
|
199
|
-
error_code: "E_TASK_ALREADY_SET",
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
name: "PROGRESS_CONTEXT_REPOSITORY (223)",
|
|
203
|
-
value: 223,
|
|
204
|
-
description: "Builtin: bind/unbind context Repository (≤ 30)",
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
name: "PROGRESS_UNHOLD (224)",
|
|
208
|
-
value: 224,
|
|
209
|
-
description: "Builtin: adminUnhold (force release, bypasses holder check)",
|
|
210
|
-
error_code: "E_NOT_THE_HOLDER",
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
name: "PROGRESS_OWNER_RECEIVE (225)",
|
|
214
|
-
value: 225,
|
|
215
|
-
description: "Builtin: owner receive (unwrap Receiving<K> / CoinWrapper<T> at terminal node)",
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
name: "E_MACHINE_NOT_MATCH",
|
|
219
|
-
value: 4,
|
|
220
|
-
description: "Move error: progress.machine ≠ machine.id_address (every op asserts this)",
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
name: "E_FORWARD_ALREADY_ACCOMPLISHED",
|
|
224
|
-
value: 7,
|
|
225
|
-
description: "Move error: re-hold on completed forward is blocked",
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
name: "E_NEED_PASSPORT",
|
|
229
|
-
value: 9,
|
|
230
|
-
description: "Move error: Forward.guard is Some but plain next() called — use *_with_passport variant",
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
name: "E_ORDER_NOT_MATCH",
|
|
234
|
-
value: 10,
|
|
235
|
-
description: "Move error: order_next/order_hold called but progress.task ≠ order address",
|
|
236
|
-
},
|
|
237
|
-
];
|
|
238
|
-
}
|
|
239
|
-
function buildRenderingHints(mode, max_length, hasAdminUnhold, hasTaskSet) {
|
|
240
|
-
return {
|
|
241
|
-
include_puzzle_template: mode === "initial_design",
|
|
242
|
-
include_risk_details: mode === "pre_advance" || mode === "stakeholder_review",
|
|
243
|
-
include_questions: mode === "pre_advance",
|
|
244
|
-
include_immutability_warning: hasTaskSet || mode === "post_task_binding",
|
|
245
|
-
include_admin_unhold_warning: hasAdminUnhold,
|
|
246
|
-
include_cross_object_refs: mode === "apply_check" || mode === "initial_design",
|
|
247
|
-
include_terminal_node_note: mode === "post_task_binding" || mode === "pre_advance",
|
|
248
|
-
max_length,
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
export function buildPromptFromProgressContext(bundle) {
|
|
252
|
-
const lines = [];
|
|
253
|
-
const h = bundle.rendering_hints;
|
|
254
|
-
lines.push(`═══ Progress Context (mode: ${bundle.mode}) ═══`);
|
|
255
|
-
lines.push("");
|
|
256
|
-
if (bundle.stakeholder_perspective) {
|
|
257
|
-
lines.push(`Stakeholder perspective: ${bundle.stakeholder_perspective}`);
|
|
258
|
-
lines.push("");
|
|
259
|
-
}
|
|
260
|
-
if (bundle.matched_scene) {
|
|
261
|
-
lines.push(`Scene: ${bundle.matched_scene.name}`);
|
|
262
|
-
lines.push(`Phases: ${bundle.matched_scene.phases.join(", ")}`);
|
|
263
|
-
lines.push(`Requires published Machine: ${bundle.matched_scene.requires_published_machine ? "YES" : "NO"}`);
|
|
264
|
-
lines.push(`Requires Order bound: ${bundle.matched_scene.requires_order_bound ? "YES" : "NO"}`);
|
|
265
|
-
lines.push(`Uses hold mechanism: ${bundle.matched_scene.uses_hold_mechanism ? "YES" : "NO"}`);
|
|
266
|
-
lines.push(`Uses adminUnhold: ${bundle.matched_scene.uses_admin_unhold ? "YES" : "NO"}`);
|
|
267
|
-
lines.push("");
|
|
268
|
-
}
|
|
269
|
-
if (bundle.matched_template) {
|
|
270
|
-
lines.push(`Suggested template: ${bundle.matched_template.id} — ${bundle.matched_template.name}`);
|
|
271
|
-
lines.push("");
|
|
272
|
-
}
|
|
273
|
-
if (bundle.matched_pattern) {
|
|
274
|
-
lines.push(`Matched pattern: ${bundle.matched_pattern.id} — ${bundle.matched_pattern.pattern_name}`);
|
|
275
|
-
lines.push(`Intent: ${bundle.matched_pattern.semantic_intent}`);
|
|
276
|
-
lines.push("");
|
|
277
|
-
}
|
|
278
|
-
if (h.include_puzzle_template && bundle.puzzle_completeness) {
|
|
279
|
-
const c = bundle.puzzle_completeness;
|
|
280
|
-
lines.push("─ Puzzle Completeness ──────────────");
|
|
281
|
-
lines.push(`Complete: ${c.complete ? "YES" : "NO"}`);
|
|
282
|
-
if (c.missing.length > 0) {
|
|
283
|
-
lines.push(`Missing dimensions: ${c.missing.join(", ")}`);
|
|
284
|
-
for (const md of c.missing_details) {
|
|
285
|
-
lines.push(` - ${md.dimension}: ${md.reason}`);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
lines.push(`Next: ${c.next_step}`);
|
|
289
|
-
lines.push("");
|
|
290
|
-
}
|
|
291
|
-
if (h.include_risk_details && bundle.relevant_risks.length > 0) {
|
|
292
|
-
lines.push(`─ Relevant Risk Rules (${bundle.relevant_risks.length}) ──────────────`);
|
|
293
|
-
for (const r of bundle.relevant_risks.slice(0, 6)) {
|
|
294
|
-
lines.push(` ${r.id} [${r.category}] — ${r.trigger}`);
|
|
295
|
-
}
|
|
296
|
-
if (bundle.relevant_risks.length > 6) {
|
|
297
|
-
lines.push(` ... and ${bundle.relevant_risks.length - 6} more`);
|
|
298
|
-
}
|
|
299
|
-
lines.push("");
|
|
300
|
-
}
|
|
301
|
-
if (bundle.risk_assessment) {
|
|
302
|
-
lines.push("─ Risk Assessment ──────────────");
|
|
303
|
-
lines.push(`Overall: ${bundle.risk_assessment.overall_risk}`);
|
|
304
|
-
lines.push(`Detected: ${bundle.risk_assessment.risks.length} risk(s)`);
|
|
305
|
-
if (bundle.risk_assessment.needs_human_review) {
|
|
306
|
-
lines.push("⚠️ Needs human review (HIGH/CRITICAL risks present)");
|
|
307
|
-
}
|
|
308
|
-
lines.push("");
|
|
309
|
-
}
|
|
310
|
-
if (bundle.relevant_builtin_permissions.length > 0) {
|
|
311
|
-
lines.push(`─ Builtin Permissions (${bundle.relevant_builtin_permissions.length}) ──────────────`);
|
|
312
|
-
for (const p of bundle.relevant_builtin_permissions) {
|
|
313
|
-
lines.push(` [${p.index}] ${p.name}: ${p.description}`);
|
|
314
|
-
}
|
|
315
|
-
lines.push("");
|
|
316
|
-
}
|
|
317
|
-
if (h.include_immutability_warning) {
|
|
318
|
-
lines.push("⚠️ TASK IMMUTABILITY: task_set is ONE-TIME. E_TASK_ALREADY_SET blocks any re-assignment.");
|
|
319
|
-
lines.push(" Once Progress.task is bound to an Order/Reward, it cannot be changed.");
|
|
320
|
-
lines.push("");
|
|
321
|
-
}
|
|
322
|
-
if (h.include_admin_unhold_warning) {
|
|
323
|
-
lines.push("⚠️ ADMINUNHOLD (224): Force-release bypasses holder check.");
|
|
324
|
-
lines.push(" Grant 224 only to dedicated recovery addresses; log every invocation.");
|
|
325
|
-
lines.push("");
|
|
326
|
-
}
|
|
327
|
-
if (h.include_cross_object_refs && bundle.cross_object_refs.length > 0) {
|
|
328
|
-
lines.push(`─ Cross-Object References (${bundle.cross_object_refs.length}) ──────────────`);
|
|
329
|
-
for (const ref of bundle.cross_object_refs.slice(0, 8)) {
|
|
330
|
-
lines.push(` ${ref.object} [${ref.phase}]: ${ref.relationship}`);
|
|
331
|
-
}
|
|
332
|
-
if (bundle.cross_object_refs.length > 8) {
|
|
333
|
-
lines.push(` ... and ${bundle.cross_object_refs.length - 8} more`);
|
|
334
|
-
}
|
|
335
|
-
lines.push("");
|
|
336
|
-
}
|
|
337
|
-
if (h.include_terminal_node_note) {
|
|
338
|
-
lines.push("─ Terminal Node Note ──────────────");
|
|
339
|
-
lines.push("At terminal nodes (completed/enforced/return_approved/paid), use progress::owner_receive");
|
|
340
|
-
lines.push("to unwrap Receiving<K> / CoinWrapper<T> via Payment.unwrap_with_check.");
|
|
341
|
-
lines.push("Permission 225 (PROGRESS_OWNER_RECEIVE) required; recipient = Machine.permission owner.");
|
|
342
|
-
lines.push("");
|
|
343
|
-
}
|
|
344
|
-
if (bundle.onchain_constraints.length > 0) {
|
|
345
|
-
lines.push("─ On-chain Constraints ──────────────");
|
|
346
|
-
for (const c of bundle.onchain_constraints) {
|
|
347
|
-
const errPart = c.error_code ? ` (abort: ${c.error_code})` : "";
|
|
348
|
-
lines.push(` ${c.name} = ${c.value} — ${c.description}${errPart}`);
|
|
349
|
-
}
|
|
350
|
-
lines.push("");
|
|
351
|
-
}
|
|
352
|
-
return lines.join("\n");
|
|
353
|
-
}
|
|
354
|
-
export function getProgressContextSummary(bundle) {
|
|
355
|
-
const parts = [
|
|
356
|
-
`mode=${bundle.mode}`,
|
|
357
|
-
`scene=${bundle.matched_scene?.id ?? "none"}`,
|
|
358
|
-
`risks=${bundle.relevant_risks.length}`,
|
|
359
|
-
`permissions=${bundle.relevant_builtin_permissions.length}`,
|
|
360
|
-
`cross_refs=${bundle.cross_object_refs.length}`,
|
|
361
|
-
];
|
|
362
|
-
if (bundle.stakeholder_perspective)
|
|
363
|
-
parts.push(`stakeholder=${bundle.stakeholder_perspective}`);
|
|
364
|
-
if (bundle.risk_assessment)
|
|
365
|
-
parts.push(`overall_risk=${bundle.risk_assessment.overall_risk}`);
|
|
366
|
-
if (bundle.matched_template)
|
|
367
|
-
parts.push(`template=${bundle.matched_template.id}`);
|
|
368
|
-
if (bundle.matched_pattern)
|
|
369
|
-
parts.push(`pattern=${bundle.matched_pattern.id}`);
|
|
370
|
-
return parts.join(", ");
|
|
371
|
-
}
|
|
372
|
-
export function buildStakeholderContext(stakeholder, intent, progress_json) {
|
|
373
|
-
return buildProgressContext({
|
|
374
|
-
mode: "stakeholder_review",
|
|
375
|
-
intent,
|
|
376
|
-
progress_json,
|
|
377
|
-
stakeholder,
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
export function quickValidateProgressJson(progress_json, current_state = {}) {
|
|
381
|
-
const violations = [];
|
|
382
|
-
if (progress_json.progress_namedOperator) {
|
|
383
|
-
const check = validateNamedOperatorAddressList(progress_json.progress_namedOperator.operators);
|
|
384
|
-
if (!check.ok)
|
|
385
|
-
violations.push(...check.violations);
|
|
386
|
-
if ((progress_json.progress_namedOperator.op === "add" ||
|
|
387
|
-
progress_json.progress_namedOperator.op === "set") &&
|
|
388
|
-
current_state.current_named_operator_count !== undefined) {
|
|
389
|
-
const countCheck = validateNamedOperatorCount(current_state.current_named_operator_count);
|
|
390
|
-
if (!countCheck.ok)
|
|
391
|
-
violations.push(countCheck.violation);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
if (progress_json.repository &&
|
|
395
|
-
(progress_json.repository.op === "add" || progress_json.repository.op === "set")) {
|
|
396
|
-
const addCount = progress_json.repository.objects.length;
|
|
397
|
-
const current = current_state.current_context_repository_count ?? 0;
|
|
398
|
-
const repoCheck = validateContextRepositoryCount(current, addCount);
|
|
399
|
-
if (!repoCheck.ok)
|
|
400
|
-
violations.push(repoCheck.violation);
|
|
401
|
-
}
|
|
402
|
-
if (progress_json.task && current_state.current_task) {
|
|
403
|
-
violations.push(`task already set to ${current_state.current_task} — E_TASK_ALREADY_SET will abort`);
|
|
404
|
-
}
|
|
405
|
-
if (current_state.machine_published === false) {
|
|
406
|
-
violations.push("Machine not published — Progress requires published Machine");
|
|
407
|
-
}
|
|
408
|
-
return { ok: violations.length === 0, violations };
|
|
409
|
-
}
|
|
410
|
-
export function getProgressKnowledgeSnapshot() {
|
|
411
|
-
return {
|
|
412
|
-
version: {
|
|
413
|
-
ledger: PROGRESS_LEDGER_VERSION,
|
|
414
|
-
puzzle: "1.0.0",
|
|
415
|
-
risk: PROGRESS_RISK_VERSION,
|
|
416
|
-
translation: PROGRESS_TRANSLATION_VERSION,
|
|
417
|
-
templates: PROGRESS_TEMPLATES_VERSION,
|
|
418
|
-
confirm: PROGRESS_CONFIRM_VERSION,
|
|
419
|
-
context: PROGRESS_CONTEXT_VERSION,
|
|
420
|
-
},
|
|
421
|
-
scenes_count: getProgressScenesCount(),
|
|
422
|
-
builtin_permissions_count: PROGRESS_PERMISSIONS.length,
|
|
423
|
-
builtin_permissions: PROGRESS_PERMISSIONS.map(p => ({
|
|
424
|
-
index: p.index,
|
|
425
|
-
name: p.name,
|
|
426
|
-
sdk_exposed: p.sdk_exposed,
|
|
427
|
-
})),
|
|
428
|
-
templates_count: PROGRESS_TEMPLATES.length,
|
|
429
|
-
templates: listProgressTemplates(),
|
|
430
|
-
semantic_patterns_count: PROGRESS_SEMANTIC_TO_SCHEMA_RULES.length,
|
|
431
|
-
schema_rules_count: PROGRESS_SCHEMA_TO_SEMANTIC_RULES.length,
|
|
432
|
-
constraint_rules_count: PROGRESS_CONSTRAINT_RULES.length,
|
|
433
|
-
risk_rules_count: getProgressRiskRulesCount(),
|
|
434
|
-
checklist_count: PROGRESS_OPERATION_CHECKLIST.length,
|
|
435
|
-
confirmation_questions_count: PROGRESS_CONFIRMATION_QUESTIONS.length,
|
|
436
|
-
cross_object_refs_count: PROGRESS_CROSS_OBJECT_REFS.length,
|
|
437
|
-
onchain_limits: {
|
|
438
|
-
max_named_operator_count: MAX_NAMED_OPERATOR_COUNT,
|
|
439
|
-
max_named_operator_address_count: MAX_NAMED_OPERATOR_ADDRESS_COUNT,
|
|
440
|
-
max_context_repository_count: MAX_CONTEXT_REPOSITORY_COUNT,
|
|
441
|
-
},
|
|
442
|
-
injection_modes: [
|
|
443
|
-
"initial_design",
|
|
444
|
-
"mid_progress_review",
|
|
445
|
-
"pre_advance",
|
|
446
|
-
"post_task_binding",
|
|
447
|
-
"stakeholder_review",
|
|
448
|
-
"apply_check",
|
|
449
|
-
],
|
|
450
|
-
stakeholders: ["owner", "named_operator", "submitter", "system"],
|
|
451
|
-
};
|
|
452
|
-
}
|
|
1
|
+
import{MAX_NAMED_OPERATOR_COUNT,MAX_NAMED_OPERATOR_ADDRESS_COUNT,MAX_CONTEXT_REPOSITORY_COUNT}from'@wowok/wowok';import{PROGRESS_PERMISSIONS,PROGRESS_LEDGER_VERSION,PROGRESS_CROSS_OBJECT_REFS,inferSceneFromIntent,getScenesByIndustry,getScenesByPhase,getAllBuiltinPermissions,getProgressScenesCount,validateNamedOperatorAddressList,validateNamedOperatorCount,validateContextRepositoryCount}from'./progress-ledger.js';import{initPuzzleFromIntent,checkPuzzleCompleteness}from'./progress-puzzle.js';import{PROGRESS_RISK_VERSION,assessProgressRisks,getAllProgressRiskRules,getProgressRiskRulesCount}from'./progress-risk.js';import{PROGRESS_TRANSLATION_VERSION,PROGRESS_SEMANTIC_TO_SCHEMA_RULES,PROGRESS_SCHEMA_TO_SEMANTIC_RULES,PROGRESS_CONSTRAINT_RULES,matchSemanticPattern}from'./progress-translation.js';import{PROGRESS_TEMPLATES,PROGRESS_TEMPLATES_VERSION,getProgressTemplatesByScene,listProgressTemplates}from'./progress-templates.js';import{PROGRESS_CONFIRM_VERSION,PROGRESS_OPERATION_CHECKLIST,PROGRESS_CONFIRMATION_QUESTIONS}from'./progress-confirm.js';export const PROGRESS_CONTEXT_VERSION='1.0.0';export function buildProgressContext(a){const b=a['max_length']??0xfa0;let c;a['intent']&&(c=inferSceneFromIntent(a['intent']));if(!c&&a['target_phase']){const p=getScenesByPhase(a['target_phase']);if(p['length']>0x0)c=p[0x0];}if(!c&&a['target_industry']){const q=getScenesByIndustry(a['target_industry']);if(q['length']>0x0)c=q[0x0];}let d;if(c){const r=getProgressTemplatesByScene(c['id']);if(r['length']>0x0)d=r[0x0];}let e;if(a['intent']){const s=matchSemanticPattern(a['intent']);if(s['length']>0x0)e=s[0x0];}let f,g;a['mode']==='initial_design'&&a['intent']&&(f=initPuzzleFromIntent({'rule_sentence':a['intent']}),g=checkPuzzleCompleteness(f));const h=filterRiskRules(a['mode'],a['stakeholder'],c);let i;if(a['mode']==='pre_advance'&&a['progress_json']){const t={'object':a['progress_json']['object'],'task':a['progress_json']['task'],'repository':a['progress_json']['repository'],'progress_namedOperator':a['progress_json']['progress_namedOperator'],'operate':a['progress_json']['operate'],'current_machine':a['current_machine'],'machine_published':a['machine_published'],'current_task':a['current_task'],'current_named_operator_count':a['current_named_operator_count'],'current_context_repository_count':a['current_context_repository_count'],'current_node':a['current_node'],'forward_already_accomplished':a['forward_already_accomplished'],'holder_address':a['holder_address'],'signer':a['signer'],'forward_named_operator':a['forward_named_operator'],'forward_permission_index':a['forward_permission_index'],'forward_has_guard':a['forward_has_guard'],'target_objects_types':a['target_objects_types']};i=assessProgressRisks(t);}const j=filterChecklist(a['mode']),k=filterQuestions(a['mode']),l=c?c['builtin_indexes_consumed']:getAllBuiltinPermissions(),m=buildCrossObjectRefs(a['target_phase'],c),n=buildOnchainConstraints(),o=buildRenderingHints(a['mode'],b,a['progress_json']?.['operate']?.['op']==='adminUnhold',!!a['progress_json']?.['task']);return{'version':PROGRESS_CONTEXT_VERSION,'mode':a['mode'],'stakeholder_perspective':a['stakeholder'],'matched_scene':c,'matched_template':d,'matched_pattern':e,'puzzle_state':f,'puzzle_completeness':g,'relevant_risks':h,'risk_assessment':i,'relevant_checklist':j,'relevant_questions':k,'relevant_builtin_permissions':l,'cross_object_refs':m,'onchain_constraints':n,'rendering_hints':o};}function filterRiskRules(a,b,c){const d=getAllProgressRiskRules();if(a==='initial_design')return d['filter'](e=>e['category']==='structural'||e['category']==='lifecycle');if(a==='pre_advance')return d;if(a==='post_task_binding')return d['filter'](e=>e['id']!=='R-PR-2-01');if(a==='stakeholder_review'&&b){if(b==='owner')return d['filter'](e=>e['category']==='permission'||e['category']==='lifecycle'||e['category']==='cross_object');if(b==='named_operator')return d['filter'](e=>e['category']==='permission'||e['id']==='R-PR-4-02'||e['id']==='R-PR-4-03');if(b==='submitter')return d['filter'](e=>e['category']==='semantic'||e['id']==='R-PR-3-03'||e['id']==='R-PR-4-02'||e['id']==='R-PR-4-03');if(b==='system')return d['filter'](e=>e['category']==='cross_object'||e['category']==='structural');}if(a==='apply_check')return d['filter'](e=>e['category']==='cross_object'||e['id']==='R-PR-4-01');return d;}function filterChecklist(a){if(a==='initial_design')return PROGRESS_OPERATION_CHECKLIST['filter'](b=>['C-PR-01','C-PR-03','C-PR-04','C-PR-05']['includes'](b['id']));if(a==='post_task_binding')return PROGRESS_OPERATION_CHECKLIST['filter'](b=>b['id']!=='C-PR-06');if(a==='stakeholder_review')return PROGRESS_OPERATION_CHECKLIST['filter'](b=>['C-PR-01','C-PR-02','C-PR-07','C-PR-09','C-PR-10']['includes'](b['id']));return PROGRESS_OPERATION_CHECKLIST;}function filterQuestions(a){if(a==='pre_advance')return PROGRESS_CONFIRMATION_QUESTIONS;if(a==='post_task_binding')return PROGRESS_CONFIRMATION_QUESTIONS['filter'](b=>b['id']!=='QPR2');if(a==='initial_design')return PROGRESS_CONFIRMATION_QUESTIONS['filter'](b=>b['id']==='QPR5');return[];}function buildCrossObjectRefs(a,b){const c=PROGRESS_CROSS_OBJECT_REFS['map'](d=>({'object':d['object'],'phase':d['phase'],'relationship':d['relationship'],'description':d['relationship']}));if(a)return c['filter'](d=>d['phase']===a||d['phase']==='universal');if(b){const d=b['phases'];return c['filter'](e=>e['phase']==='universal'||d['includes'](e['phase']));}return c;}function buildOnchainConstraints(){return[{'name':'MAX_NAMED_OPERATOR_COUNT','value':MAX_NAMED_OPERATOR_COUNT,'description':'Maximum\x20named_operator\x20namespace\x20entries\x20per\x20Progress','error_code':'E_MAX_NAMED_OPERATOR_COUNT'},{'name':'MAX_NAMED_OPERATOR_ADDRESS_COUNT','value':MAX_NAMED_OPERATOR_ADDRESS_COUNT,'description':'Maximum\x20addresses\x20per\x20named_operator\x20namespace\x20entry','error_code':'E_MAX_NAMED_OPERATOR_ADDRESS_COUNT'},{'name':'MAX_CONTEXT_REPOSITORY_COUNT','value':MAX_CONTEXT_REPOSITORY_COUNT,'description':'Maximum\x20context_repositories\x20per\x20Progress','error_code':'E_MAX_CONTEXT_REPOSITORY_COUNT'},{'name':'PROGRESS_NEW\x20(220)','value':0xdc,'description':'Builtin:\x20create\x20new\x20Progress\x20(asserted\x20by\x20progress::new\x20/\x20new_with_passport;\x20bypassed\x20by\x20service::buy\x20→\x20new_imp)'},{'name':'PROGRESS_NAMED_OPERATOR\x20(221)','value':0xdd,'description':'Builtin:\x20manage\x20named_operator\x20namespace\x20(add/set/remove)'},{'name':'PROGRESS_TASK\x20(222)','value':0xde,'description':'Builtin:\x20submit\x20task\x20(one-time,\x20immutable\x20—\x20E_TASK_ALREADY_SET)','error_code':'E_TASK_ALREADY_SET'},{'name':'PROGRESS_CONTEXT_REPOSITORY\x20(223)','value':0xdf,'description':'Builtin:\x20bind/unbind\x20context\x20Repository\x20(≤\x2030)'},{'name':'PROGRESS_UNHOLD\x20(224)','value':0xe0,'description':'Builtin:\x20adminUnhold\x20(force\x20release,\x20bypasses\x20holder\x20check)','error_code':'E_NOT_THE_HOLDER'},{'name':'PROGRESS_OWNER_RECEIVE\x20(225)','value':0xe1,'description':'Builtin:\x20owner\x20receive\x20(unwrap\x20Receiving<K>\x20/\x20CoinWrapper<T>\x20at\x20terminal\x20node)'},{'name':'E_MACHINE_NOT_MATCH','value':0x4,'description':'Move\x20error:\x20progress.machine\x20≠\x20machine.id_address\x20(every\x20op\x20asserts\x20this)'},{'name':'E_FORWARD_ALREADY_ACCOMPLISHED','value':0x7,'description':'Move\x20error:\x20re-hold\x20on\x20completed\x20forward\x20is\x20blocked'},{'name':'E_NEED_PASSPORT','value':0x9,'description':'Move\x20error:\x20Forward.guard\x20is\x20Some\x20but\x20plain\x20next()\x20called\x20—\x20use\x20*_with_passport\x20variant'},{'name':'E_ORDER_NOT_MATCH','value':0xa,'description':'Move\x20error:\x20order_next/order_hold\x20called\x20but\x20progress.task\x20≠\x20order\x20address'}];}function buildRenderingHints(a,b,c,d){return{'include_puzzle_template':a==='initial_design','include_risk_details':a==='pre_advance'||a==='stakeholder_review','include_questions':a==='pre_advance','include_immutability_warning':d||a==='post_task_binding','include_admin_unhold_warning':c,'include_cross_object_refs':a==='apply_check'||a==='initial_design','include_terminal_node_note':a==='post_task_binding'||a==='pre_advance','max_length':b};}export function buildPromptFromProgressContext(a){const b=[],d=a['rendering_hints'];b['push']('═══\x20Progress\x20Context\x20(mode:\x20'+a['mode']+')\x20═══'),b['push']('');a['stakeholder_perspective']&&(b['push']('Stakeholder\x20perspective:\x20'+a['stakeholder_perspective']),b['push'](''));a['matched_scene']&&(b['push']('Scene:\x20'+a['matched_scene']['name']),b['push']('Phases:\x20'+a['matched_scene']['phases']['join'](',\x20')),b['push']('Requires\x20published\x20Machine:\x20'+(a['matched_scene']['requires_published_machine']?'YES':'NO')),b['push']('Requires\x20Order\x20bound:\x20'+(a['matched_scene']['requires_order_bound']?'YES':'NO')),b['push']('Uses\x20hold\x20mechanism:\x20'+(a['matched_scene']['uses_hold_mechanism']?'YES':'NO')),b['push']('Uses\x20adminUnhold:\x20'+(a['matched_scene']['uses_admin_unhold']?'YES':'NO')),b['push'](''));a['matched_template']&&(b['push']('Suggested\x20template:\x20'+a['matched_template']['id']+'\x20—\x20'+a['matched_template']['name']),b['push'](''));a['matched_pattern']&&(b['push']('Matched\x20pattern:\x20'+a['matched_pattern']['id']+'\x20—\x20'+a['matched_pattern']['pattern_name']),b['push']('Intent:\x20'+a['matched_pattern']['semantic_intent']),b['push'](''));if(d['include_puzzle_template']&&a['puzzle_completeness']){const e=a['puzzle_completeness'];b['push']('─\x20Puzzle\x20Completeness\x20──────────────'),b['push']('Complete:\x20'+(e['complete']?'YES':'NO'));if(e['missing']['length']>0x0){b['push']('Missing\x20dimensions:\x20'+e['missing']['join'](',\x20'));for(const f of e['missing_details']){b['push']('\x20\x20-\x20'+f['dimension']+':\x20'+f['reason']);}}b['push']('Next:\x20'+e['next_step']),b['push']('');}if(d['include_risk_details']&&a['relevant_risks']['length']>0x0){b['push']('─\x20Relevant\x20Risk\x20Rules\x20('+a['relevant_risks']['length']+')\x20──────────────');for(const g of a['relevant_risks']['slice'](0x0,0x6)){b['push']('\x20\x20'+g['id']+'\x20['+g['category']+']\x20—\x20'+g['trigger']);}a['relevant_risks']['length']>0x6&&b['push']('\x20\x20...\x20and\x20'+(a['relevant_risks']['length']-0x6)+'\x20more'),b['push']('');}a['risk_assessment']&&(b['push']('─\x20Risk\x20Assessment\x20──────────────'),b['push']('Overall:\x20'+a['risk_assessment']['overall_risk']),b['push']('Detected:\x20'+a['risk_assessment']['risks']['length']+'\x20risk(s)'),a['risk_assessment']['needs_human_review']&&b['push']('⚠️\x20Needs\x20human\x20review\x20(HIGH/CRITICAL\x20risks\x20present)'),b['push'](''));if(a['relevant_builtin_permissions']['length']>0x0){b['push']('─\x20Builtin\x20Permissions\x20('+a['relevant_builtin_permissions']['length']+')\x20──────────────');for(const i of a['relevant_builtin_permissions']){b['push']('\x20\x20['+i['index']+']\x20'+i['name']+':\x20'+i['description']);}b['push']('');}d['include_immutability_warning']&&(b['push']('⚠️\x20TASK\x20IMMUTABILITY:\x20task_set\x20is\x20ONE-TIME.\x20E_TASK_ALREADY_SET\x20blocks\x20any\x20re-assignment.'),b['push']('\x20\x20\x20Once\x20Progress.task\x20is\x20bound\x20to\x20an\x20Order/Reward,\x20it\x20cannot\x20be\x20changed.'),b['push'](''));d['include_admin_unhold_warning']&&(b['push']('⚠️\x20ADMINUNHOLD\x20(224):\x20Force-release\x20bypasses\x20holder\x20check.'),b['push']('\x20\x20\x20Grant\x20224\x20only\x20to\x20dedicated\x20recovery\x20addresses;\x20log\x20every\x20invocation.'),b['push'](''));if(d['include_cross_object_refs']&&a['cross_object_refs']['length']>0x0){b['push']('─\x20Cross-Object\x20References\x20('+a['cross_object_refs']['length']+')\x20──────────────');for(const j of a['cross_object_refs']['slice'](0x0,0x8)){b['push']('\x20\x20'+j['object']+'\x20['+j['phase']+']:\x20'+j['relationship']);}a['cross_object_refs']['length']>0x8&&b['push']('\x20\x20...\x20and\x20'+(a['cross_object_refs']['length']-0x8)+'\x20more'),b['push']('');}d['include_terminal_node_note']&&(b['push']('─\x20Terminal\x20Node\x20Note\x20──────────────'),b['push']('At\x20terminal\x20nodes\x20(completed/enforced/return_approved/paid),\x20use\x20progress::owner_receive'),b['push']('to\x20unwrap\x20Receiving<K>\x20/\x20CoinWrapper<T>\x20via\x20Payment.unwrap_with_check.'),b['push']('Permission\x20225\x20(PROGRESS_OWNER_RECEIVE)\x20required;\x20recipient\x20=\x20Machine.permission\x20owner.'),b['push'](''));if(a['onchain_constraints']['length']>0x0){b['push']('─\x20On-chain\x20Constraints\x20──────────────');for(const k of a['onchain_constraints']){const l=k['error_code']?'\x20(abort:\x20'+k['error_code']+')':'';b['push']('\x20\x20'+k['name']+'\x20=\x20'+k['value']+'\x20—\x20'+k['description']+l);}b['push']('');}return b['join']('\x0a');}export function getProgressContextSummary(a){const b=['mode='+a['mode'],'scene='+(a['matched_scene']?.['id']??'none'),'risks='+a['relevant_risks']['length'],'permissions='+a['relevant_builtin_permissions']['length'],'cross_refs='+a['cross_object_refs']['length']];if(a['stakeholder_perspective'])b['push']('stakeholder='+a['stakeholder_perspective']);if(a['risk_assessment'])b['push']('overall_risk='+a['risk_assessment']['overall_risk']);if(a['matched_template'])b['push']('template='+a['matched_template']['id']);if(a['matched_pattern'])b['push']('pattern='+a['matched_pattern']['id']);return b['join'](',\x20');}export function buildStakeholderContext(a,b,c){return buildProgressContext({'mode':'stakeholder_review','intent':b,'progress_json':c,'stakeholder':a});}export function quickValidateProgressJson(a,b={}){const c=[];if(a['progress_namedOperator']){const d=validateNamedOperatorAddressList(a['progress_namedOperator']['operators']);if(!d['ok'])c['push'](...d['violations']);if((a['progress_namedOperator']['op']==='add'||a['progress_namedOperator']['op']==='set')&&b['current_named_operator_count']!==undefined){const e=validateNamedOperatorCount(b['current_named_operator_count']);if(!e['ok'])c['push'](e['violation']);}}if(a['repository']&&(a['repository']['op']==='add'||a['repository']['op']==='set')){const f=a['repository']['objects']['length'],g=b['current_context_repository_count']??0x0,h=validateContextRepositoryCount(g,f);if(!h['ok'])c['push'](h['violation']);}return a['task']&&b['current_task']&&c['push']('task\x20already\x20set\x20to\x20'+b['current_task']+'\x20—\x20E_TASK_ALREADY_SET\x20will\x20abort'),b['machine_published']===![]&&c['push']('Machine\x20not\x20published\x20—\x20Progress\x20requires\x20published\x20Machine'),{'ok':c['length']===0x0,'violations':c};}export function getProgressKnowledgeSnapshot(){return{'version':{'ledger':PROGRESS_LEDGER_VERSION,'puzzle':'1.0.0','risk':PROGRESS_RISK_VERSION,'translation':PROGRESS_TRANSLATION_VERSION,'templates':PROGRESS_TEMPLATES_VERSION,'confirm':PROGRESS_CONFIRM_VERSION,'context':PROGRESS_CONTEXT_VERSION},'scenes_count':getProgressScenesCount(),'builtin_permissions_count':PROGRESS_PERMISSIONS['length'],'builtin_permissions':PROGRESS_PERMISSIONS['map'](a=>({'index':a['index'],'name':a['name'],'sdk_exposed':a['sdk_exposed']})),'templates_count':PROGRESS_TEMPLATES['length'],'templates':listProgressTemplates(),'semantic_patterns_count':PROGRESS_SEMANTIC_TO_SCHEMA_RULES['length'],'schema_rules_count':PROGRESS_SCHEMA_TO_SEMANTIC_RULES['length'],'constraint_rules_count':PROGRESS_CONSTRAINT_RULES['length'],'risk_rules_count':getProgressRiskRulesCount(),'checklist_count':PROGRESS_OPERATION_CHECKLIST['length'],'confirmation_questions_count':PROGRESS_CONFIRMATION_QUESTIONS['length'],'cross_object_refs_count':PROGRESS_CROSS_OBJECT_REFS['length'],'onchain_limits':{'max_named_operator_count':MAX_NAMED_OPERATOR_COUNT,'max_named_operator_address_count':MAX_NAMED_OPERATOR_ADDRESS_COUNT,'max_context_repository_count':MAX_CONTEXT_REPOSITORY_COUNT},'injection_modes':['initial_design','mid_progress_review','pre_advance','post_task_binding','stakeholder_review','apply_check'],'stakeholders':['owner','named_operator','submitter','system']};}
|