@wowok/agent-mcp 2.5.2 → 2.5.3
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/index.js +46 -6
- package/dist/knowledge/guard-design-patterns.js +104 -1
- package/dist/knowledge/guard-ledger.js +3 -3
- package/dist/knowledge/guard-lint.js +3 -3
- package/dist/knowledge/guard-risk.js +23 -15
- package/dist/knowledge/guard-templates.js +174 -2
- package/dist/knowledge/guard-translation.js +3 -3
- package/dist/knowledge/index.d.ts +3 -0
- package/dist/knowledge/index.js +9 -0
- package/dist/knowledge/machine-context.d.ts +1 -1
- package/dist/knowledge/machine-context.js +21 -0
- package/dist/knowledge/machine-ledger.d.ts +1 -0
- package/dist/knowledge/machine-ledger.js +31 -11
- package/dist/knowledge/machine-templates.js +32 -78
- package/dist/knowledge/overrides-loader.d.ts +13 -0
- package/dist/knowledge/overrides-loader.js +67 -0
- package/dist/knowledge/payment-risk.d.ts +4 -0
- package/dist/knowledge/payment-risk.js +67 -0
- package/dist/knowledge/repository-confirm.d.ts +4 -0
- package/dist/knowledge/repository-confirm.js +44 -0
- package/dist/knowledge/repository-risk.d.ts +8 -2
- package/dist/knowledge/repository-risk.js +61 -0
- package/dist/knowledge/repository-translation.js +23 -0
- package/dist/knowledge/scenario-modes.js +22 -5
- package/dist/knowledge/service-templates.js +38 -0
- package/dist/knowledge/treasury-templates.js +42 -0
- package/dist/loop-engineering/context-collect.d.ts +7 -0
- package/dist/loop-engineering/context-collect.js +83 -0
- package/dist/loop-engineering/improve.d.ts +29 -0
- package/dist/loop-engineering/improve.js +178 -0
- package/dist/project/context-assembly.d.ts +16 -0
- package/dist/project/context-assembly.js +130 -0
- package/dist/project/deployment-doc.d.ts +115 -0
- package/dist/project/deployment-doc.js +595 -0
- package/dist/project/index.js +37 -1
- package/dist/project/migration.d.ts +22 -0
- package/dist/project/migration.js +125 -0
- package/dist/project/project-store.d.ts +110 -0
- package/dist/project/project-store.js +425 -0
- package/dist/project/rollback-policy.d.ts +45 -0
- package/dist/project/rollback-policy.js +290 -0
- package/dist/project/stage-gate.d.ts +49 -0
- package/dist/project/stage-gate.js +310 -0
- package/dist/schema/call/allocation.d.ts +5 -0
- package/dist/schema/call/arbitration.d.ts +5 -0
- package/dist/schema/call/base.d.ts +3 -0
- package/dist/schema/call/base.js +1 -0
- package/dist/schema/call/bridge.d.ts +24 -0
- package/dist/schema/call/contact.d.ts +5 -0
- package/dist/schema/call/demand.d.ts +5 -0
- package/dist/schema/call/guard.d.ts +15 -0
- package/dist/schema/call/machine.d.ts +10 -0
- package/dist/schema/call/order.d.ts +5 -0
- package/dist/schema/call/payment.d.ts +5 -0
- package/dist/schema/call/permission.d.ts +5 -0
- package/dist/schema/call/personal.d.ts +5 -0
- package/dist/schema/call/progress.d.ts +5 -0
- package/dist/schema/call/proof.d.ts +10 -0
- package/dist/schema/call/repository.d.ts +5 -0
- package/dist/schema/call/reward.d.ts +5 -0
- package/dist/schema/call/service.d.ts +5 -0
- package/dist/schema/call/treasury.d.ts +5 -0
- package/dist/schema/operations.d.ts +210 -0
- package/dist/schema/operations.js +24 -0
- package/dist/schema/project/index.d.ts +2619 -106
- package/dist/schema/project/index.js +622 -2
- package/dist/schema/query/index.d.ts +601 -0
- package/dist/schema/query/index.js +61 -0
- package/dist/schemas/bridge_operation.schema.json +4 -0
- package/dist/schemas/guard2file.schema.json +4 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/machineNode2file.schema.json +4 -0
- package/dist/schemas/onchain_operations.schema.json +20 -0
- package/dist/schemas/onchain_operations_allocation.schema.json +4 -0
- package/dist/schemas/onchain_operations_arbitration.schema.json +4 -0
- package/dist/schemas/onchain_operations_contact.schema.json +4 -0
- package/dist/schemas/onchain_operations_demand.schema.json +4 -0
- package/dist/schemas/onchain_operations_gen_passport.schema.json +8 -0
- package/dist/schemas/onchain_operations_gen_proof.schema.json +8 -0
- package/dist/schemas/onchain_operations_guard.schema.json +4 -0
- package/dist/schemas/onchain_operations_machine.schema.json +4 -0
- package/dist/schemas/onchain_operations_order.schema.json +4 -0
- package/dist/schemas/onchain_operations_payment.schema.json +4 -0
- package/dist/schemas/onchain_operations_permission.schema.json +4 -0
- package/dist/schemas/onchain_operations_personal.schema.json +4 -0
- package/dist/schemas/onchain_operations_progress.schema.json +4 -0
- package/dist/schemas/onchain_operations_proof.schema.json +4 -0
- package/dist/schemas/onchain_operations_repository.schema.json +4 -0
- package/dist/schemas/onchain_operations_reward.schema.json +4 -0
- package/dist/schemas/onchain_operations_service.schema.json +4 -0
- package/dist/schemas/onchain_operations_treasury.schema.json +4 -0
- package/dist/schemas/project_operation.output.json +1798 -0
- package/dist/schemas/project_operation.schema.json +132 -2
- package/dist/schemas/query_toolkit.output.json +407 -1
- package/dist/schemas/query_toolkit.schema.json +132 -0
- package/dist/tools/handlers/project.js +742 -1
- package/dist/tools/handlers/query.js +38 -2
- package/package.json +2 -2
|
@@ -79,10 +79,31 @@ export const ProjectOperationInputSchema = z
|
|
|
79
79
|
"generate_deployment_doc",
|
|
80
80
|
"trace_substeps",
|
|
81
81
|
"get_project_status",
|
|
82
|
+
"load_project",
|
|
83
|
+
"fork_project",
|
|
84
|
+
"export_project",
|
|
85
|
+
"get_project_files",
|
|
86
|
+
"validate_stage_unit",
|
|
87
|
+
"get_stage_assessment",
|
|
88
|
+
"get_stage_risk_policy",
|
|
89
|
+
"get_doc_relations",
|
|
90
|
+
"update_deployment_doc",
|
|
91
|
+
"validate_validation_chain",
|
|
92
|
+
"apply_improvement",
|
|
93
|
+
"get_improvement_queue",
|
|
94
|
+
"get_flywheel_config",
|
|
95
|
+
"rollback_stage",
|
|
96
|
+
"get_reversibility",
|
|
97
|
+
"assemble_context",
|
|
82
98
|
])
|
|
83
|
-
.describe("Action to perform.
|
|
99
|
+
.describe("Action to perform. Six categories:\n" +
|
|
84
100
|
"1. Graph Query (10): list_projects, list_objects, shareable, dependencies, referenced_by, pre_publish_check, cross_project_refs, graph_stats, save_graph, load_graph.\n" +
|
|
85
|
-
"2. Project-Based Deployment 5-Stage (4): Call IN ORDER — analyze_intent (Stage 2) → aggregate_risks (Stage 3) → generate_deployment_doc (Stage 4) → trace_substeps (Stage 5). Each action's output includes `next_action` telling you which action to call next. Stage 1 (Project Naming) uses the `project` + `version` params
|
|
101
|
+
"2. Project-Based Deployment 5-Stage (4): Call IN ORDER — analyze_intent (Stage 2) → aggregate_risks (Stage 3) → generate_deployment_doc (Stage 4) → trace_substeps (Stage 5). Each action's output includes `next_action` telling you which action to call next. Stage 1 (Project Naming) uses the `project` + `version` params.\n" +
|
|
102
|
+
"3. Project Memory Layer (5): load_project, fork_project, export_project, get_project_files, get_project_status.\n" +
|
|
103
|
+
"4. Nested-Autonomy Stage Unit (6): validate_stage_unit, get_stage_assessment, get_stage_risk_policy, get_doc_relations, update_deployment_doc, validate_validation_chain.\n" +
|
|
104
|
+
"5. Distillation Reflow (3): apply_improvement (review + apply a proposal — config_override writes overrides/, source_patch writes patches/), get_improvement_queue (list pending/approved proposals), get_flywheel_config (query reflow loop status).\n" +
|
|
105
|
+
"6. Rollback & Reversibility (2): rollback_stage (evaluate + execute stage rollback with file cleanup — blocked if has_published_object), get_reversibility (query object lifecycle reversibility matrix for risk reminders).\n" +
|
|
106
|
+
"7. Context Assembly (1): assemble_context (query on-chain object states + extract embedded history + optional events, and assemble a structured semantic context for LLM consumption — bridges raw facts to business-understandable context). Required input: context_objects (array of object IDs/names). Optional: include_events (query recent state-transition events)."),
|
|
86
107
|
project: z
|
|
87
108
|
.string()
|
|
88
109
|
.optional()
|
|
@@ -96,6 +117,15 @@ export const ProjectOperationInputSchema = z
|
|
|
96
117
|
.string()
|
|
97
118
|
.optional()
|
|
98
119
|
.describe("Object name or address (for dependencies / referenced_by / pre_publish_check)"),
|
|
120
|
+
fork_to_version: z
|
|
121
|
+
.string()
|
|
122
|
+
.regex(/^v\d+$/)
|
|
123
|
+
.optional()
|
|
124
|
+
.describe("Target version for fork_project (e.g. 'v2'). Must differ from source 'version'."),
|
|
125
|
+
fork_to_prefix: z
|
|
126
|
+
.string()
|
|
127
|
+
.optional()
|
|
128
|
+
.describe("Target prefix for fork_project. Defaults to source 'project' prefix when omitted."),
|
|
99
129
|
user_intent: z
|
|
100
130
|
.string()
|
|
101
131
|
.min(1)
|
|
@@ -205,6 +235,28 @@ export const ProjectOperationInputSchema = z
|
|
|
205
235
|
.boolean()
|
|
206
236
|
.optional()
|
|
207
237
|
.describe("Whether to run deployment-scanner validation after generating the doc. Defaults to true."),
|
|
238
|
+
gas_budget: z
|
|
239
|
+
.object({
|
|
240
|
+
network: z.enum(["testnet", "mainnet"]),
|
|
241
|
+
already_spent_gas: z
|
|
242
|
+
.number()
|
|
243
|
+
.int()
|
|
244
|
+
.nonnegative()
|
|
245
|
+
.optional()
|
|
246
|
+
.describe("Gas already spent on-chain in MIST (from telemetry). Defaults to 0."),
|
|
247
|
+
estimated_rerun_gas: z
|
|
248
|
+
.number()
|
|
249
|
+
.int()
|
|
250
|
+
.nonnegative()
|
|
251
|
+
.optional()
|
|
252
|
+
.describe("Estimated gas to re-run remaining ops in MIST. Auto-computed from estimateDeploymentGas when omitted."),
|
|
253
|
+
warning: z
|
|
254
|
+
.string()
|
|
255
|
+
.optional()
|
|
256
|
+
.describe("Custom warning text. Defaults to a computed cost summary."),
|
|
257
|
+
})
|
|
258
|
+
.optional()
|
|
259
|
+
.describe("Gas budget input for stage 4/5 gate (§3.5). Non-blocking; only surfaces a WARN on mainnet."),
|
|
208
260
|
network: z
|
|
209
261
|
.enum(["testnet", "mainnet"])
|
|
210
262
|
.optional()
|
|
@@ -250,8 +302,81 @@ export const ProjectOperationInputSchema = z
|
|
|
250
302
|
.strict())
|
|
251
303
|
.optional()
|
|
252
304
|
.describe("Substep records for trace_substeps."),
|
|
305
|
+
target_stage: z
|
|
306
|
+
.number()
|
|
307
|
+
.int()
|
|
308
|
+
.min(1)
|
|
309
|
+
.max(5)
|
|
310
|
+
.optional()
|
|
311
|
+
.describe("Stage number (1-5) for validate_stage_unit, get_stage_assessment, get_stage_risk_policy, and rollback_stage (the stage to rollback to). Required by these 4 actions."),
|
|
312
|
+
proposal_id: z
|
|
313
|
+
.string()
|
|
314
|
+
.optional()
|
|
315
|
+
.describe("Improvement proposal ID (for apply_improvement). Required by apply_improvement."),
|
|
316
|
+
review_status: z
|
|
317
|
+
.enum(["approved", "rejected", "applied"])
|
|
318
|
+
.optional()
|
|
319
|
+
.describe("New review status to set (for apply_improvement). 'approved' triggers application (config_override or source_patch); 'rejected' marks as rejected; 'applied' marks as already applied."),
|
|
320
|
+
queue_filter_status: z
|
|
321
|
+
.enum(["pending", "approved", "rejected", "applied"])
|
|
322
|
+
.optional()
|
|
323
|
+
.describe("Filter the improvement queue by review_status (for get_improvement_queue)."),
|
|
324
|
+
queue_filter_type: z
|
|
325
|
+
.string()
|
|
326
|
+
.optional()
|
|
327
|
+
.describe("Filter the improvement queue by proposal type (for get_improvement_queue)."),
|
|
328
|
+
queue_filter_priority: z
|
|
329
|
+
.string()
|
|
330
|
+
.optional()
|
|
331
|
+
.describe("Filter the improvement queue by priority P0/P1/P2/P3 (for get_improvement_queue)."),
|
|
332
|
+
dry_run: z
|
|
333
|
+
.boolean()
|
|
334
|
+
.optional()
|
|
335
|
+
.describe("When true, rollback_stage only evaluates the policy and returns the cleanup plan WITHOUT executing the rollback. Defaults to false (execute)."),
|
|
336
|
+
query_object_type: z
|
|
337
|
+
.string()
|
|
338
|
+
.optional()
|
|
339
|
+
.describe("Object type for get_reversibility query (e.g. 'service', 'machine', 'guard'). When omitted, returns the full matrix."),
|
|
340
|
+
query_lifecycle_state: z
|
|
341
|
+
.enum(["created", "referenced", "published", "bound"])
|
|
342
|
+
.optional()
|
|
343
|
+
.describe("Object lifecycle state for get_reversibility query. When omitted, returns all lifecycle states for the given object_type."),
|
|
344
|
+
context_objects: z
|
|
345
|
+
.array(z.string())
|
|
346
|
+
.optional()
|
|
347
|
+
.describe("Object IDs (0x...) or LocalMark names to assemble context for. Required when action='assemble_context'. The current on-chain state of each object will be queried and enriched with semantic annotations."),
|
|
348
|
+
include_events: z
|
|
349
|
+
.boolean()
|
|
350
|
+
.optional()
|
|
351
|
+
.describe("When true, assemble_context also queries recent state-transition events (NewOrderEvent, ProgressEvent, ArbEvent, etc.). Events are the real-time transition log — convergent and bounded. Defaults to false. Note: object-embedded history (ProgressSession.forwards, Order.disputes) is ALWAYS extracted automatically — no flag needed."),
|
|
352
|
+
context_network: z
|
|
353
|
+
.enum(["testnet", "mainnet"])
|
|
354
|
+
.optional()
|
|
355
|
+
.describe("Network for assemble_context queries. Defaults to 'testnet' if omitted."),
|
|
253
356
|
})
|
|
254
357
|
.strict();
|
|
358
|
+
const GateValidationSchema = z
|
|
359
|
+
.object({
|
|
360
|
+
stage: z.number().int().min(1).max(5),
|
|
361
|
+
passed: z.boolean().describe("True when no FAIL checks exist."),
|
|
362
|
+
checks: z.array(z.object({
|
|
363
|
+
dimension: z.enum([
|
|
364
|
+
"semantic",
|
|
365
|
+
"tools",
|
|
366
|
+
"reversibility",
|
|
367
|
+
"risk",
|
|
368
|
+
"isolation",
|
|
369
|
+
"gas_budget",
|
|
370
|
+
]),
|
|
371
|
+
status: z.enum(["PASS", "FAIL", "WARN"]),
|
|
372
|
+
message: z.string(),
|
|
373
|
+
})),
|
|
374
|
+
blocking_issues: z.array(z.string()),
|
|
375
|
+
warnings: z.array(z.string()),
|
|
376
|
+
can_proceed: z.boolean(),
|
|
377
|
+
})
|
|
378
|
+
.optional()
|
|
379
|
+
.describe("Stage gate validation result (6 dimensions: semantic/tools/reversibility/risk/isolation/gas_budget).");
|
|
255
380
|
const ItemsResult = (action) => z.object({
|
|
256
381
|
action: z.literal(action),
|
|
257
382
|
items: z
|
|
@@ -287,6 +412,7 @@ const AnalyzeIntentResultSchema = z
|
|
|
287
412
|
.enum(["aggregate_risks", "none"])
|
|
288
413
|
.describe("Next project_operation action to call. 'aggregate_risks' when puzzles are complete enough; 'none' if user must fill missing fields first."),
|
|
289
414
|
warnings: z.array(z.string()),
|
|
415
|
+
gate_validation: GateValidationSchema,
|
|
290
416
|
})
|
|
291
417
|
.strict();
|
|
292
418
|
const AggregateRisksResultSchema = z
|
|
@@ -355,6 +481,7 @@ const AggregateRisksResultSchema = z
|
|
|
355
481
|
user_action_required: z
|
|
356
482
|
.string()
|
|
357
483
|
.describe("Human-readable next-step guidance."),
|
|
484
|
+
gate_validation: GateValidationSchema,
|
|
358
485
|
})
|
|
359
486
|
.strict();
|
|
360
487
|
const GenerateDeploymentDocResultSchema = z
|
|
@@ -394,6 +521,17 @@ const GenerateDeploymentDocResultSchema = z
|
|
|
394
521
|
})
|
|
395
522
|
.optional()
|
|
396
523
|
.describe("Gas cost estimate for deploying all objects."),
|
|
524
|
+
persisted: z
|
|
525
|
+
.object({
|
|
526
|
+
all_files: z
|
|
527
|
+
.array(z.string())
|
|
528
|
+
.describe("Project-relative paths of all generated files (27 total)."),
|
|
529
|
+
all_stages_passed: z
|
|
530
|
+
.boolean()
|
|
531
|
+
.describe("Whether all 5 stage gates passed validation."),
|
|
532
|
+
})
|
|
533
|
+
.optional()
|
|
534
|
+
.describe("Nested-autonomy doc set persistence result (§11). Present when the doc set was successfully written to disk."),
|
|
397
535
|
can_proceed: z
|
|
398
536
|
.boolean()
|
|
399
537
|
.describe("Whether the user can proceed to stage 5. False when D-errors exist."),
|
|
@@ -401,6 +539,7 @@ const GenerateDeploymentDocResultSchema = z
|
|
|
401
539
|
.enum(["trace_substeps", "fix_doc_errors", "none"])
|
|
402
540
|
.describe("Next project_operation action. 'trace_substeps' when can_proceed=true; 'fix_doc_errors' when D-errors exist; 'none' for other cases."),
|
|
403
541
|
user_action_required: z.string(),
|
|
542
|
+
gate_validation: GateValidationSchema,
|
|
404
543
|
})
|
|
405
544
|
.strict();
|
|
406
545
|
const TraceSubstepsResultSchema = z
|
|
@@ -454,6 +593,7 @@ const TraceSubstepsResultSchema = z
|
|
|
454
593
|
.enum(["deploy", "fix_substeps", "none"])
|
|
455
594
|
.describe("Next action. 'deploy' when can_proceed=true (execute substeps via onchain_operations); 'fix_substeps' when issues exist; 'none' when done."),
|
|
456
595
|
user_action_required: z.string(),
|
|
596
|
+
gate_validation: GateValidationSchema,
|
|
457
597
|
})
|
|
458
598
|
.strict();
|
|
459
599
|
const GetProjectStatusResultSchema = z
|
|
@@ -473,6 +613,470 @@ const GetProjectStatusResultSchema = z
|
|
|
473
613
|
trace_coherent: z.boolean().optional(),
|
|
474
614
|
})
|
|
475
615
|
.strict();
|
|
616
|
+
const LoadProjectListItemSchema = z.object({
|
|
617
|
+
prefix: z.string(),
|
|
618
|
+
version: z.string(),
|
|
619
|
+
dir_name: z.string(),
|
|
620
|
+
initialized: z.boolean(),
|
|
621
|
+
archived: z.boolean(),
|
|
622
|
+
needs_migration: z.boolean().describe("Whether schema_version differs from current."),
|
|
623
|
+
forked_from: z.string().optional(),
|
|
624
|
+
chain_exists: z.boolean().describe("Whether the project prefix exists on-chain."),
|
|
625
|
+
sync_status: z
|
|
626
|
+
.enum(["synced", "local_only", "archived", "uninitialized"])
|
|
627
|
+
.describe("Cross-validation of local filesystem vs chain truth."),
|
|
628
|
+
});
|
|
629
|
+
const LoadProjectResultSchema = z
|
|
630
|
+
.object({
|
|
631
|
+
action: z.literal("load_project"),
|
|
632
|
+
items: z.array(LoadProjectListItemSchema).optional(),
|
|
633
|
+
total: z.number().int().optional(),
|
|
634
|
+
project: z.string().optional(),
|
|
635
|
+
version: z.string().optional(),
|
|
636
|
+
local_exists: z.boolean().optional(),
|
|
637
|
+
manifest: z
|
|
638
|
+
.object({
|
|
639
|
+
schema_version: z.string(),
|
|
640
|
+
mcp_version: z.string(),
|
|
641
|
+
prefix: z.string(),
|
|
642
|
+
version: z.string(),
|
|
643
|
+
created_at: z.string(),
|
|
644
|
+
updated_at: z.string(),
|
|
645
|
+
forked_from: z.string().optional(),
|
|
646
|
+
needs_recalibration: z.boolean().optional(),
|
|
647
|
+
})
|
|
648
|
+
.optional(),
|
|
649
|
+
stage_state: z
|
|
650
|
+
.object({
|
|
651
|
+
stage: z.number().int().min(1).max(5),
|
|
652
|
+
updated_at: z.number().int(),
|
|
653
|
+
has_published_object: z.boolean(),
|
|
654
|
+
archived: z.boolean(),
|
|
655
|
+
})
|
|
656
|
+
.partial()
|
|
657
|
+
.optional(),
|
|
658
|
+
sync_status: z
|
|
659
|
+
.object({
|
|
660
|
+
local_exists: z.boolean(),
|
|
661
|
+
initialized: z.boolean(),
|
|
662
|
+
needs_migration: z.boolean(),
|
|
663
|
+
archived: z.boolean(),
|
|
664
|
+
})
|
|
665
|
+
.optional(),
|
|
666
|
+
migration: z
|
|
667
|
+
.object({
|
|
668
|
+
migrated: z.boolean().describe("Whether a migration was performed."),
|
|
669
|
+
from_version: z.string(),
|
|
670
|
+
to_version: z.string(),
|
|
671
|
+
steps_executed: z.array(z.string()),
|
|
672
|
+
backup_path: z.string().optional(),
|
|
673
|
+
needs_recalibration: z.boolean(),
|
|
674
|
+
message: z.string(),
|
|
675
|
+
})
|
|
676
|
+
.optional(),
|
|
677
|
+
message: z.string().optional(),
|
|
678
|
+
})
|
|
679
|
+
.strict();
|
|
680
|
+
const ForkProjectResultSchema = z
|
|
681
|
+
.object({
|
|
682
|
+
action: z.literal("fork_project"),
|
|
683
|
+
new_prefix: z.string(),
|
|
684
|
+
new_version: z.string(),
|
|
685
|
+
new_path: z.string().describe("Absolute filesystem path of the new project directory."),
|
|
686
|
+
forked_from: z
|
|
687
|
+
.string()
|
|
688
|
+
.describe("Absolute path of the source project directory."),
|
|
689
|
+
copied_files: z
|
|
690
|
+
.array(z.string())
|
|
691
|
+
.describe("Project-relative paths of copied files (excludes stage.json + audit.jsonl)."),
|
|
692
|
+
copied_file_count: z.number().int(),
|
|
693
|
+
warning: z
|
|
694
|
+
.string()
|
|
695
|
+
.describe("Project isolation notice — forked project must re-create its own objects."),
|
|
696
|
+
next_action: z
|
|
697
|
+
.literal("analyze_intent")
|
|
698
|
+
.describe("The forked project starts at stage 2 (analyze_intent)."),
|
|
699
|
+
})
|
|
700
|
+
.strict();
|
|
701
|
+
const ExportProjectResultSchema = z
|
|
702
|
+
.object({
|
|
703
|
+
action: z.literal("export_project"),
|
|
704
|
+
project: z.string(),
|
|
705
|
+
version: z.string(),
|
|
706
|
+
files: z.array(z.object({
|
|
707
|
+
path: z.string().describe("Project-relative file path."),
|
|
708
|
+
size: z.number().int().describe("File size in bytes."),
|
|
709
|
+
kind: z.enum(["json", "markdown", "jsonl", "other"]),
|
|
710
|
+
content: z.string().describe("File content (text)."),
|
|
711
|
+
})),
|
|
712
|
+
total_files: z.number().int(),
|
|
713
|
+
})
|
|
714
|
+
.strict();
|
|
715
|
+
const GetProjectFilesResultSchema = z
|
|
716
|
+
.object({
|
|
717
|
+
action: z.literal("get_project_files"),
|
|
718
|
+
project: z.string(),
|
|
719
|
+
version: z.string(),
|
|
720
|
+
files: z.array(z.object({
|
|
721
|
+
path: z.string().describe("Project-relative file path."),
|
|
722
|
+
size: z.number().int().describe("File size in bytes."),
|
|
723
|
+
kind: z.enum(["json", "markdown", "jsonl", "other"]),
|
|
724
|
+
mtime: z.number().int().describe("Last modified time (ms)."),
|
|
725
|
+
})),
|
|
726
|
+
total_files: z.number().int(),
|
|
727
|
+
})
|
|
728
|
+
.strict();
|
|
729
|
+
const ValidateStageUnitResultSchema = z
|
|
730
|
+
.object({
|
|
731
|
+
action: z.literal("validate_stage_unit"),
|
|
732
|
+
project: z.string(),
|
|
733
|
+
version: z.string(),
|
|
734
|
+
stage: z.number().int().min(1).max(5),
|
|
735
|
+
valid: z
|
|
736
|
+
.boolean()
|
|
737
|
+
.describe("True when all 4 stage unit files exist and pass consistency checks."),
|
|
738
|
+
missing_files: z
|
|
739
|
+
.array(z.string())
|
|
740
|
+
.describe("Project-relative paths of missing stage unit files (empty if all present)."),
|
|
741
|
+
checks: z.array(z.object({
|
|
742
|
+
check_id: z.string(),
|
|
743
|
+
status: z.enum(["pass", "fail", "warn"]),
|
|
744
|
+
message: z.string(),
|
|
745
|
+
})),
|
|
746
|
+
blocking_issues: z.array(z.string()),
|
|
747
|
+
stage_passed: z
|
|
748
|
+
.boolean()
|
|
749
|
+
.optional()
|
|
750
|
+
.describe("From verification.json stage_passed field (undefined if file missing)."),
|
|
751
|
+
})
|
|
752
|
+
.strict();
|
|
753
|
+
const GetStageAssessmentResultSchema = z
|
|
754
|
+
.object({
|
|
755
|
+
action: z.literal("get_stage_assessment"),
|
|
756
|
+
project: z.string(),
|
|
757
|
+
version: z.string(),
|
|
758
|
+
stage: z.number().int().min(1).max(5),
|
|
759
|
+
found: z.boolean(),
|
|
760
|
+
assessment: z
|
|
761
|
+
.object({
|
|
762
|
+
stage: z.number().int().min(1).max(5),
|
|
763
|
+
assessed_at: z.number().int(),
|
|
764
|
+
goal_completion: z.record(z.number()),
|
|
765
|
+
findings: z.array(z.object({
|
|
766
|
+
finding_id: z.string(),
|
|
767
|
+
severity: z.enum(["info", "warn", "critical"]),
|
|
768
|
+
criterion_id: z.string(),
|
|
769
|
+
description: z.string(),
|
|
770
|
+
evidence: z.unknown(),
|
|
771
|
+
})),
|
|
772
|
+
recommendations: z.array(z.string()),
|
|
773
|
+
})
|
|
774
|
+
.optional()
|
|
775
|
+
.describe("The stage assessment object (from assessment.json)."),
|
|
776
|
+
})
|
|
777
|
+
.strict();
|
|
778
|
+
const GetStageRiskPolicyResultSchema = z
|
|
779
|
+
.object({
|
|
780
|
+
action: z.literal("get_stage_risk_policy"),
|
|
781
|
+
project: z.string(),
|
|
782
|
+
version: z.string(),
|
|
783
|
+
stage: z.number().int().min(1).max(5),
|
|
784
|
+
found: z.boolean(),
|
|
785
|
+
risk_policy: z
|
|
786
|
+
.object({
|
|
787
|
+
stage: z.number().int().min(1).max(5),
|
|
788
|
+
risks: z.array(z.object({
|
|
789
|
+
risk_id: z.string(),
|
|
790
|
+
category: z.enum([
|
|
791
|
+
"naming",
|
|
792
|
+
"dependency",
|
|
793
|
+
"operational",
|
|
794
|
+
"financial",
|
|
795
|
+
"security",
|
|
796
|
+
]),
|
|
797
|
+
description: z.string(),
|
|
798
|
+
likelihood: z.enum(["low", "medium", "high"]),
|
|
799
|
+
impact: z.enum(["low", "medium", "high", "critical"]),
|
|
800
|
+
mitigation: z.string(),
|
|
801
|
+
owner: z.enum(["ai", "user", "system"]),
|
|
802
|
+
})),
|
|
803
|
+
active_controls: z.array(z.object({
|
|
804
|
+
control_id: z.string(),
|
|
805
|
+
control_type: z.enum(["preventive", "detective", "corrective"]),
|
|
806
|
+
target_risk: z.string(),
|
|
807
|
+
implementation: z.string(),
|
|
808
|
+
verified: z.boolean(),
|
|
809
|
+
})),
|
|
810
|
+
residual_risks: z.array(z.string()),
|
|
811
|
+
})
|
|
812
|
+
.optional()
|
|
813
|
+
.describe("The stage risk policy object (from risk-policy.json)."),
|
|
814
|
+
})
|
|
815
|
+
.strict();
|
|
816
|
+
const GetDocRelationsResultSchema = z
|
|
817
|
+
.object({
|
|
818
|
+
action: z.literal("get_doc_relations"),
|
|
819
|
+
project: z.string(),
|
|
820
|
+
version: z.string(),
|
|
821
|
+
found: z.boolean(),
|
|
822
|
+
relations: z
|
|
823
|
+
.object({
|
|
824
|
+
version: z.string(),
|
|
825
|
+
generated_at: z.number().int(),
|
|
826
|
+
project_invariants: z.array(z.object({
|
|
827
|
+
invariant_id: z.string(),
|
|
828
|
+
description: z.string(),
|
|
829
|
+
verified_by_stages: z.array(z.number().int()),
|
|
830
|
+
})),
|
|
831
|
+
stage_units: z.array(z.object({
|
|
832
|
+
stage: z.number().int().min(1).max(5),
|
|
833
|
+
goal_id: z.string(),
|
|
834
|
+
assessment_id: z.string(),
|
|
835
|
+
risk_policy_id: z.string(),
|
|
836
|
+
verification_id: z.string(),
|
|
837
|
+
artifacts: z.array(z.string()),
|
|
838
|
+
})),
|
|
839
|
+
derivations: z.array(z.object({
|
|
840
|
+
source_type: z.enum(["project_invariant", "project_goal"]),
|
|
841
|
+
source_id: z.string(),
|
|
842
|
+
target_type: z.enum(["stage_goal", "stage_risk", "stage_verification"]),
|
|
843
|
+
target_stage: z.number().int().min(1).max(5),
|
|
844
|
+
target_id: z.string(),
|
|
845
|
+
derivation_logic: z.string(),
|
|
846
|
+
})),
|
|
847
|
+
propagation_rules: z.array(z.object({
|
|
848
|
+
rule_id: z.string(),
|
|
849
|
+
trigger: z.object({
|
|
850
|
+
stage: z.number().int(),
|
|
851
|
+
event: z.enum(["verification_passed", "verification_failed"]),
|
|
852
|
+
}),
|
|
853
|
+
effect: z.object({
|
|
854
|
+
target: z.enum(["project_invariant", "next_stage"]),
|
|
855
|
+
action: z.enum(["verify", "block"]),
|
|
856
|
+
}),
|
|
857
|
+
})),
|
|
858
|
+
impact_map: z.record(z.array(z.string())),
|
|
859
|
+
})
|
|
860
|
+
.optional()
|
|
861
|
+
.describe("The validation chain graph (from relations.json)."),
|
|
862
|
+
})
|
|
863
|
+
.strict();
|
|
864
|
+
const UpdateDeploymentDocResultSchema = z
|
|
865
|
+
.object({
|
|
866
|
+
action: z.literal("update_deployment_doc"),
|
|
867
|
+
project: z.string(),
|
|
868
|
+
version: z.string(),
|
|
869
|
+
updated: z.boolean().describe("Whether the deployment doc set was regenerated."),
|
|
870
|
+
updated_files: z
|
|
871
|
+
.array(z.string())
|
|
872
|
+
.describe("Project-relative paths of regenerated files."),
|
|
873
|
+
updated_file_count: z.number().int(),
|
|
874
|
+
all_stages_passed: z
|
|
875
|
+
.boolean()
|
|
876
|
+
.describe("Whether all stages passed their D-checks after the update."),
|
|
877
|
+
impact_summary: z
|
|
878
|
+
.object({
|
|
879
|
+
stages_affected: z.array(z.number().int()).describe("Stage numbers whose content changed."),
|
|
880
|
+
relations_rebuilt: z.boolean().describe("Whether relations.json was regenerated."),
|
|
881
|
+
})
|
|
882
|
+
.describe("Summary of what changed (based on relations.json impact analysis)."),
|
|
883
|
+
next_action: z
|
|
884
|
+
.enum(["validate_validation_chain", "trace_substeps", "none"])
|
|
885
|
+
.describe("Next action: validate the chain after update, or proceed to trace_substeps."),
|
|
886
|
+
})
|
|
887
|
+
.strict();
|
|
888
|
+
const ValidateValidationChainResultSchema = z
|
|
889
|
+
.object({
|
|
890
|
+
action: z.literal("validate_validation_chain"),
|
|
891
|
+
project: z.string(),
|
|
892
|
+
version: z.string(),
|
|
893
|
+
valid: z
|
|
894
|
+
.boolean()
|
|
895
|
+
.describe("True when derivation, propagation, cross-stage, and impact-map checks all pass."),
|
|
896
|
+
derivation_checks: z.array(z.object({
|
|
897
|
+
check_id: z.string(),
|
|
898
|
+
status: z.enum(["pass", "fail", "warn"]),
|
|
899
|
+
message: z.string(),
|
|
900
|
+
})),
|
|
901
|
+
propagation_checks: z.array(z.object({
|
|
902
|
+
check_id: z.string(),
|
|
903
|
+
status: z.enum(["pass", "fail", "warn"]),
|
|
904
|
+
message: z.string(),
|
|
905
|
+
})),
|
|
906
|
+
cross_stage_checks: z.array(z.object({
|
|
907
|
+
check_id: z.string(),
|
|
908
|
+
status: z.enum(["pass", "fail", "warn"]),
|
|
909
|
+
message: z.string(),
|
|
910
|
+
})),
|
|
911
|
+
impact_map_checks: z.array(z.object({
|
|
912
|
+
check_id: z.string(),
|
|
913
|
+
status: z.enum(["pass", "fail", "warn"]),
|
|
914
|
+
message: z.string(),
|
|
915
|
+
})),
|
|
916
|
+
blocking_issues: z.array(z.string()),
|
|
917
|
+
warnings: z.array(z.string()),
|
|
918
|
+
})
|
|
919
|
+
.strict();
|
|
920
|
+
const ApplyImprovementResultSchema = z
|
|
921
|
+
.object({
|
|
922
|
+
action: z.literal("apply_improvement"),
|
|
923
|
+
proposal_id: z.string(),
|
|
924
|
+
previous_status: z.string(),
|
|
925
|
+
new_status: z.string(),
|
|
926
|
+
applied: z
|
|
927
|
+
.boolean()
|
|
928
|
+
.describe("Whether the proposal was applied (true for approved+config_override, true for approved+source_patch producing patch file)."),
|
|
929
|
+
apply_mode: z.enum(["config_override", "source_patch"]),
|
|
930
|
+
override_file: z
|
|
931
|
+
.string()
|
|
932
|
+
.optional()
|
|
933
|
+
.describe("Path of the override file written (config_override only)."),
|
|
934
|
+
patch_file: z
|
|
935
|
+
.string()
|
|
936
|
+
.optional()
|
|
937
|
+
.describe("Path of the patch file written (source_patch only)."),
|
|
938
|
+
message: z.string(),
|
|
939
|
+
next_action: z
|
|
940
|
+
.enum(["get_improvement_queue", "get_flywheel_config", "none"])
|
|
941
|
+
.describe("Next action: check more proposals or view flywheel status."),
|
|
942
|
+
})
|
|
943
|
+
.strict();
|
|
944
|
+
const GetImprovementQueueResultSchema = z
|
|
945
|
+
.object({
|
|
946
|
+
action: z.literal("get_improvement_queue"),
|
|
947
|
+
total: z.number().int(),
|
|
948
|
+
filtered_count: z.number().int(),
|
|
949
|
+
proposals: z.array(z.object({
|
|
950
|
+
proposal_id: z.string(),
|
|
951
|
+
source_diagnosis_id: z.string(),
|
|
952
|
+
type: z.string(),
|
|
953
|
+
priority: z.string(),
|
|
954
|
+
automation: z.enum(["full", "semi", "manual"]),
|
|
955
|
+
apply_mode: z.enum(["config_override", "source_patch"]),
|
|
956
|
+
override_category: z.string().optional(),
|
|
957
|
+
title: z.string(),
|
|
958
|
+
description: z.string(),
|
|
959
|
+
target: z.string(),
|
|
960
|
+
review_status: z.enum(["pending", "approved", "rejected", "applied"]),
|
|
961
|
+
ab_test_recommended: z.boolean(),
|
|
962
|
+
persisted_at: z.string().optional(),
|
|
963
|
+
reviewed_at: z.string().optional(),
|
|
964
|
+
})),
|
|
965
|
+
summary: z.string(),
|
|
966
|
+
})
|
|
967
|
+
.strict();
|
|
968
|
+
const GetFlywheelConfigResultSchema = z
|
|
969
|
+
.object({
|
|
970
|
+
action: z.literal("get_flywheel_config"),
|
|
971
|
+
queue_path: z.string(),
|
|
972
|
+
overrides_dir: z.string(),
|
|
973
|
+
patches_dir: z.string(),
|
|
974
|
+
total_proposals: z.number().int(),
|
|
975
|
+
pending_count: z.number().int(),
|
|
976
|
+
approved_count: z.number().int(),
|
|
977
|
+
applied_count: z.number().int(),
|
|
978
|
+
rejected_count: z.number().int(),
|
|
979
|
+
override_files: z.array(z.string()),
|
|
980
|
+
recent_proposals: z.array(z.object({
|
|
981
|
+
proposal_id: z.string(),
|
|
982
|
+
type: z.string(),
|
|
983
|
+
priority: z.string(),
|
|
984
|
+
review_status: z.enum(["pending", "approved", "rejected", "applied"]),
|
|
985
|
+
title: z.string(),
|
|
986
|
+
})),
|
|
987
|
+
reflow_status: z
|
|
988
|
+
.enum(["active", "idle", "blocked"])
|
|
989
|
+
.describe("active=pending proposals exist; idle=no proposals; blocked=approved but not applied."),
|
|
990
|
+
})
|
|
991
|
+
.strict();
|
|
992
|
+
const RollbackStageResultSchema = z
|
|
993
|
+
.object({
|
|
994
|
+
action: z.literal("rollback_stage"),
|
|
995
|
+
success: z.boolean().describe("Whether the rollback was executed (or would be, if dry_run=false)."),
|
|
996
|
+
dry_run: z.boolean().describe("Whether this was a policy evaluation only (no execution)."),
|
|
997
|
+
target_stage: z.number().int().min(1).max(5),
|
|
998
|
+
previous_stage: z.number().int().min(1).max(5),
|
|
999
|
+
allowed: z.boolean().describe("Whether the rollback is allowed by policy."),
|
|
1000
|
+
block_reason: z.string().optional().describe("Present when allowed=false — explains why rollback is blocked."),
|
|
1001
|
+
files_to_clean: z
|
|
1002
|
+
.array(z.string())
|
|
1003
|
+
.describe("Files/directories that will be (or were) deleted during rollback."),
|
|
1004
|
+
files_cleaned: z
|
|
1005
|
+
.array(z.string())
|
|
1006
|
+
.describe("Files/directories actually deleted (empty in dry_run mode)."),
|
|
1007
|
+
warnings: z.array(z.string()).describe("Non-blocking warnings (e.g., data loss reminder)."),
|
|
1008
|
+
iteration_strategy: z.object({
|
|
1009
|
+
strategy: z.enum(["in_place", "fork"]),
|
|
1010
|
+
reason: z.string(),
|
|
1011
|
+
fork_to_version: z.string().optional(),
|
|
1012
|
+
published_objects: z.array(z.string()).optional(),
|
|
1013
|
+
}),
|
|
1014
|
+
message: z.string().describe("Human-readable summary."),
|
|
1015
|
+
})
|
|
1016
|
+
.strict();
|
|
1017
|
+
const GetReversibilityResultSchema = z
|
|
1018
|
+
.object({
|
|
1019
|
+
action: z.literal("get_reversibility"),
|
|
1020
|
+
query: z
|
|
1021
|
+
.object({
|
|
1022
|
+
object_type: z.string().optional(),
|
|
1023
|
+
lifecycle_state: z.string().optional(),
|
|
1024
|
+
})
|
|
1025
|
+
.describe("The query parameters used (empty = full matrix returned)."),
|
|
1026
|
+
entries: z.array(z.object({
|
|
1027
|
+
object_type: z.string(),
|
|
1028
|
+
lifecycle_state: z.enum(["created", "referenced", "published", "bound"]),
|
|
1029
|
+
struct_reversible: z.enum(["reversible", "limited", "immutable"]),
|
|
1030
|
+
behavior_reversible: z.boolean(),
|
|
1031
|
+
gas_impact: z.enum(["low", "medium", "high", "none"]),
|
|
1032
|
+
explanation: z.string(),
|
|
1033
|
+
})),
|
|
1034
|
+
total: z.number().int().describe("Number of matrix entries returned."),
|
|
1035
|
+
})
|
|
1036
|
+
.strict();
|
|
1037
|
+
const AssembleContextResultSchema = z
|
|
1038
|
+
.object({
|
|
1039
|
+
action: z.literal("assemble_context"),
|
|
1040
|
+
objects: z
|
|
1041
|
+
.array(z.unknown())
|
|
1042
|
+
.describe("Current on-chain states of the requested objects (from query_objects)."),
|
|
1043
|
+
events: z
|
|
1044
|
+
.array(z.unknown())
|
|
1045
|
+
.optional()
|
|
1046
|
+
.describe("Recent state-transition events (only when include_events=true). " +
|
|
1047
|
+
"Includes NewOrderEvent, ProgressEvent, ArbEvent, etc."),
|
|
1048
|
+
embedded_history: z
|
|
1049
|
+
.record(z.string(), z.unknown())
|
|
1050
|
+
.optional()
|
|
1051
|
+
.describe("Operation history extracted from object states — NOT from tx queries. " +
|
|
1052
|
+
"Progress objects: session.forwards (who did what, when, accomplished). " +
|
|
1053
|
+
"Order objects: disputes, claimed_by, progress_object. " +
|
|
1054
|
+
"This is the CORRECT history source: convergent, no infinite recursion."),
|
|
1055
|
+
semantic_summary: z
|
|
1056
|
+
.unknown()
|
|
1057
|
+
.optional()
|
|
1058
|
+
.describe("Business semantic annotations generated by buildDataSemantic — " +
|
|
1059
|
+
"maps raw object fields to business-meaningful concepts for LLM consumption."),
|
|
1060
|
+
context_digest: z
|
|
1061
|
+
.string()
|
|
1062
|
+
.describe("Unique digest for this assembled context (SHA of object IDs + versions + timestamp). " +
|
|
1063
|
+
"Use for caching or to detect state changes between two assembly calls."),
|
|
1064
|
+
next_action: z
|
|
1065
|
+
.string()
|
|
1066
|
+
.describe("Suggested next action: use onchain_transaction to verify a specific past tx, " +
|
|
1067
|
+
"or proceed with onchain_operations to modify state, or re-call assemble_context " +
|
|
1068
|
+
"after state changes."),
|
|
1069
|
+
flywheel_collected: z
|
|
1070
|
+
.object({
|
|
1071
|
+
signature_recorded: z.boolean().describe("Whether the experience signature was recorded in the real-time experience layer."),
|
|
1072
|
+
proposal_created: z.boolean().describe("Whether an improvement proposal was created for the offline distillation flywheel."),
|
|
1073
|
+
proposal_id: z.string().optional().describe("The proposal ID, if created."),
|
|
1074
|
+
})
|
|
1075
|
+
.optional()
|
|
1076
|
+
.describe("Distillation flywheel collection result. Non-blocking — may be undefined if collection fails. " +
|
|
1077
|
+
"When present, the assembled context has been fed back into the experience layer and/or improvement queue."),
|
|
1078
|
+
})
|
|
1079
|
+
.strict();
|
|
476
1080
|
export const ProjectOperationOutputSchema = z
|
|
477
1081
|
.object({
|
|
478
1082
|
result: z.discriminatedUnion("action", [
|
|
@@ -510,6 +1114,22 @@ export const ProjectOperationOutputSchema = z
|
|
|
510
1114
|
GenerateDeploymentDocResultSchema,
|
|
511
1115
|
TraceSubstepsResultSchema,
|
|
512
1116
|
GetProjectStatusResultSchema,
|
|
1117
|
+
LoadProjectResultSchema,
|
|
1118
|
+
ForkProjectResultSchema,
|
|
1119
|
+
ExportProjectResultSchema,
|
|
1120
|
+
GetProjectFilesResultSchema,
|
|
1121
|
+
ValidateStageUnitResultSchema,
|
|
1122
|
+
GetStageAssessmentResultSchema,
|
|
1123
|
+
GetStageRiskPolicyResultSchema,
|
|
1124
|
+
GetDocRelationsResultSchema,
|
|
1125
|
+
UpdateDeploymentDocResultSchema,
|
|
1126
|
+
ValidateValidationChainResultSchema,
|
|
1127
|
+
ApplyImprovementResultSchema,
|
|
1128
|
+
GetImprovementQueueResultSchema,
|
|
1129
|
+
GetFlywheelConfigResultSchema,
|
|
1130
|
+
RollbackStageResultSchema,
|
|
1131
|
+
GetReversibilityResultSchema,
|
|
1132
|
+
AssembleContextResultSchema,
|
|
513
1133
|
]).describe("Query result — shape depends on action"),
|
|
514
1134
|
})
|
|
515
1135
|
.strict();
|