@event4u/agent-config 9.30.0 → 9.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +60 -292
  3. package/dist/agent-src/contexts/execution/host-capability-manifest.md +32 -1
  4. package/dist/agent-src/rules/delegation-policy.md +11 -1
  5. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  6. package/dist/agent-src/templates/scripts/work_engine/delivery_state.ts +6 -0
  7. package/dist/agent-src/templates/scripts/work_engine/directives/backend/_self_fix.ts +332 -0
  8. package/dist/agent-src/templates/scripts/work_engine/directives/backend/refine.ts +106 -1
  9. package/dist/agent-src/templates/scripts/work_engine/directives/backend/test.ts +50 -15
  10. package/dist/agent-src/templates/scripts/work_engine/directives/backend/verify.ts +49 -15
  11. package/dist/agent-src/templates/scripts/work_engine/state.ts +74 -0
  12. package/dist/agent-src/templates/scripts/work_engine/state_io.ts +6 -0
  13. package/dist/cli-delegate/chunk-2WELHO3P.js +582 -0
  14. package/dist/cli-delegate/{chunk-IYTGIG2Y.js → chunk-542DZR4P.js} +118 -148
  15. package/dist/cli-delegate/{chunk-66OVWGB5.js → chunk-AG47LAGQ.js} +1 -1
  16. package/dist/cli-delegate/{chunk-MP3JT3IU.js → chunk-DS6BLDMG.js} +1 -1
  17. package/dist/cli-delegate/{chunk-O3CO5BFB.js → chunk-EJITJBJX.js} +12 -1
  18. package/dist/cli-delegate/{chunk-EQY4FLJB.js → chunk-ITIQSGOQ.js} +3 -3
  19. package/dist/cli-delegate/{chunk-LCFJIQ4J.js → chunk-JEJABGKB.js} +110 -6
  20. package/dist/cli-delegate/chunk-PZWRPRWP.js +38 -0
  21. package/dist/cli-delegate/{chunk-BTJNRUX3.js → chunk-QEEB4LHO.js} +1 -1
  22. package/dist/cli-delegate/{chunk-DDUNNFYX.js → chunk-UVKNIJH2.js} +2 -2
  23. package/dist/cli-delegate/cmd_analyze_session.js +1 -1
  24. package/dist/cli-delegate/cmd_brand_status.js +1 -1
  25. package/dist/cli-delegate/cmd_conformance.js +154 -41
  26. package/dist/cli-delegate/cmd_doctor.js +4 -3
  27. package/dist/cli-delegate/cmd_explain.js +2 -2
  28. package/dist/cli-delegate/cmd_export.js +4 -4
  29. package/dist/cli-delegate/cmd_handoff.js +168 -59
  30. package/dist/cli-delegate/cmd_mcp_available.js +1 -1
  31. package/dist/cli-delegate/cmd_migrate.js +2 -2
  32. package/dist/cli-delegate/cmd_packs_active.js +2 -2
  33. package/dist/cli-delegate/cmd_prune.js +4 -4
  34. package/dist/cli-delegate/cmd_route_audit.js +2 -2
  35. package/dist/cli-delegate/cmd_route_explain.js +1 -1
  36. package/dist/cli-delegate/cmd_session_recycle.js +19 -4
  37. package/dist/cli-delegate/cmd_settings_get.js +2 -55
  38. package/dist/cli-delegate/cmd_settings_migrate.js +4 -4
  39. package/dist/cli-delegate/cmd_settings_set.js +1 -1
  40. package/dist/cli-delegate/cmd_sync.js +4 -4
  41. package/dist/cli-delegate/cmd_uninstall.js +4 -4
  42. package/dist/cli-delegate/cmd_update.js +1 -1
  43. package/dist/cli-delegate/cmd_upgrade.js +1 -1
  44. package/dist/cli-delegate/cmd_validate.js +4 -4
  45. package/dist/cli-delegate/cmd_versions.js +1 -1
  46. package/dist/discovery/deprecation-report.md +1 -1
  47. package/dist/discovery/discovery-manifest.json +3 -3
  48. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  49. package/dist/discovery/discovery-manifest.summary.md +1 -1
  50. package/dist/discovery/orphan-report.md +1 -1
  51. package/dist/discovery/packs.json +2 -2
  52. package/dist/discovery/trust-report.md +1 -1
  53. package/dist/discovery/workspaces.json +2 -2
  54. package/dist/hooks/dispatch.js +1411 -810
  55. package/dist/install/install.mjs +121 -16
  56. package/dist/mcp/registry-manifest.json +1 -1
  57. package/dist/mcp/server.json +2 -2
  58. package/dist/mcp/server.mjs +365 -143
  59. package/dist/scripts/_lib/agent_settings.js +111 -2
  60. package/dist/scripts/_lib/agent_settings.js.map +1 -1
  61. package/dist/server/schemas/settings.js +2 -2
  62. package/dist/server/schemas/settings.js.map +1 -1
  63. package/package.json +1 -1
  64. package/src/agent-src/templates/scripts/work_engine/delivery_state.ts +6 -0
  65. package/src/agent-src/templates/scripts/work_engine/directives/backend/_self_fix.ts +332 -0
  66. package/src/agent-src/templates/scripts/work_engine/directives/backend/refine.ts +106 -1
  67. package/src/agent-src/templates/scripts/work_engine/directives/backend/test.ts +50 -15
  68. package/src/agent-src/templates/scripts/work_engine/directives/backend/verify.ts +49 -15
  69. package/src/agent-src/templates/scripts/work_engine/state.ts +74 -0
  70. package/src/agent-src/templates/scripts/work_engine/state_io.ts +6 -0
  71. package/src/config/pack-size-budget.json +3 -2
  72. package/src/scripts/_cli/cmd_session_recycle.ts +25 -0
  73. package/src/scripts/_cli/explain_last/inputs.ts +13 -0
  74. package/src/scripts/_cli/handoff_generate.ts +36 -1
  75. package/src/scripts/_cli/handoff_sessions.ts +140 -9
  76. package/src/scripts/_lib/agent_settings.ts +119 -2
  77. package/src/scripts/_lib/carrier_divergence.ts +120 -2
  78. package/src/scripts/_lib/envelope_grounding.ts +206 -0
  79. package/src/scripts/_lib/host_capability.ts +79 -0
  80. package/src/scripts/_lib/session_eol.ts +85 -0
  81. package/src/scripts/_lib/subagent_capsule.ts +256 -1
  82. package/src/scripts/check_secret_leak.test.ts +43 -0
  83. package/src/scripts/check_secret_leak.ts +12 -0
  84. package/src/scripts/handoff_context_hook.ts +66 -18
  85. package/src/scripts/hooks/session_eol_hook.ts +12 -12
  86. package/src/scripts/hooks/turn_end_gate_hook.ts +296 -88
  87. package/src/scripts/language_mirror_hook.ts +69 -16
  88. package/src/scripts/measure_turn_end_gate.ts +129 -51
  89. package/src/scripts/report_carrier_divergence.ts +143 -30
  90. package/src/scripts/report_conformance_funnel.ts +18 -4
  91. package/src/scripts/routing_doctor.ts +25 -2
  92. package/src/scripts/schemas/dod.schema.json +45 -0
  93. package/src/server/schemas/settings.ts +2 -2
  94. package/dist/cli-delegate/chunk-RVGBH4XK.js +0 -142
@@ -220,6 +220,7 @@ export class WorkState {
220
220
  ui_polish: Dict | null;
221
221
  contract: Dict | null;
222
222
  stitch: Dict | null;
223
+ self_fix: Dict | null;
223
224
  halts: Dict[];
224
225
  version: number;
225
226
  persona: string;
@@ -245,6 +246,7 @@ export class WorkState {
245
246
  ui_polish?: Dict | null;
246
247
  contract?: Dict | null;
247
248
  stitch?: Dict | null;
249
+ self_fix?: Dict | null;
248
250
  halts?: Dict[];
249
251
  version?: number;
250
252
  persona?: string;
@@ -269,6 +271,7 @@ export class WorkState {
269
271
  this.ui_polish = opts.ui_polish ?? null;
270
272
  this.contract = opts.contract ?? null;
271
273
  this.stitch = opts.stitch ?? null;
274
+ this.self_fix = opts.self_fix ?? null;
272
275
  this.halts = opts.halts ?? [];
273
276
  this.version = opts.version ?? SCHEMA_VERSION;
274
277
  this.persona = opts.persona ?? 'senior-engineer';
@@ -309,6 +312,7 @@ export function to_dict(state: WorkState): Dict {
309
312
  _validate_ui_polish(state.ui_polish);
310
313
  _validate_contract(state.contract);
311
314
  _validate_stitch(state.stitch);
315
+ _validate_self_fix(state.self_fix);
312
316
  _validate_halts(state.halts);
313
317
  return {
314
318
  version: state.version,
@@ -324,6 +328,7 @@ export function to_dict(state: WorkState): Dict {
324
328
  ui_polish: state.ui_polish,
325
329
  contract: state.contract,
326
330
  stitch: state.stitch,
331
+ self_fix: state.self_fix,
327
332
  halts: [...state.halts],
328
333
  persona: state.persona,
329
334
  memory: state.memory,
@@ -406,6 +411,9 @@ export function from_dict(payload: JsonValue): WorkState {
406
411
  const stitch = payload['stitch'] ?? null;
407
412
  _validate_stitch(stitch);
408
413
 
414
+ const self_fix = payload['self_fix'] ?? null;
415
+ _validate_self_fix(self_fix);
416
+
409
417
  const halts = 'halts' in payload ? payload['halts'] : [];
410
418
  _validate_halts(halts);
411
419
 
@@ -422,6 +430,7 @@ export function from_dict(payload: JsonValue): WorkState {
422
430
  ui_polish: _isDict(ui_polish) ? { ...ui_polish } : null,
423
431
  contract: _isDict(contract) ? { ...contract } : null,
424
432
  stitch: _isDict(stitch) ? { ...stitch } : null,
433
+ self_fix: _isDict(self_fix) ? { ...self_fix } : null,
425
434
  halts: Array.isArray(halts) ? ([...halts] as Dict[]) : [],
426
435
  version: version as number,
427
436
  persona: _get(payload, 'persona', 'senior-engineer') as string,
@@ -866,6 +875,71 @@ function _validate_ui_review(ui_review: JsonValue): void {
866
875
  }
867
876
  }
868
877
 
878
+ /**
879
+ * Reject malformed `self_fix` envelopes; tolerate `null` and `{}`.
880
+ *
881
+ * `null` means no red check has been seen. Once populated, each key is a lane
882
+ * name (`test`, `verify`) whose record may carry `attempts` (a non-negative
883
+ * int) and `signatures` (a list of strings). As with `ui_polish`, the schema
884
+ * enforces only shape: the ceiling and the no-progress floor are the handler's
885
+ * business (`directives/backend/_self_fix.ts`), so a state file cannot decide
886
+ * how many attempts are allowed.
887
+ *
888
+ * `attempts` is validated but NOT bounded here on purpose. A file carrying
889
+ * `attempts: 99` is well-formed and simply exhausted — rejecting it would turn
890
+ * a spent budget into a crash, and the loop's whole point is a clean exit.
891
+ */
892
+ function _validate_self_fix(self_fix: JsonValue): void {
893
+ if (self_fix === null) {
894
+ return;
895
+ }
896
+ if (!_isDict(self_fix)) {
897
+ throw new SchemaError(
898
+ `state.self_fix must be a JSON object or null; ` +
899
+ `got ${pyTypeName(self_fix)}`,
900
+ );
901
+ }
902
+ for (const [lane, record] of Object.entries(self_fix)) {
903
+ if (!_isDict(record)) {
904
+ throw new SchemaError(
905
+ `state.self_fix.${lane} must be a JSON object; ` +
906
+ `got ${pyTypeName(record)}`,
907
+ );
908
+ }
909
+ if ('attempts' in record) {
910
+ const attempts = record['attempts'];
911
+ if (
912
+ typeof attempts !== 'number' ||
913
+ typeof attempts === 'boolean' ||
914
+ !Number.isInteger(attempts) ||
915
+ attempts < 0
916
+ ) {
917
+ throw new SchemaError(
918
+ `state.self_fix.${lane}.attempts must be a non-negative ` +
919
+ `integer when present; got ${pyRepr(attempts)}`,
920
+ );
921
+ }
922
+ }
923
+ if ('signatures' in record) {
924
+ const signatures = record['signatures'];
925
+ if (!Array.isArray(signatures)) {
926
+ throw new SchemaError(
927
+ `state.self_fix.${lane}.signatures must be a list when ` +
928
+ `present; got ${pyTypeName(signatures)}`,
929
+ );
930
+ }
931
+ for (const entry of signatures) {
932
+ if (typeof entry !== 'string') {
933
+ throw new SchemaError(
934
+ `state.self_fix.${lane}.signatures entries must be ` +
935
+ `strings; got ${pyTypeName(entry)}`,
936
+ );
937
+ }
938
+ }
939
+ }
940
+ }
941
+ }
942
+
869
943
  /**
870
944
  * Reject malformed `ui_polish` envelopes; tolerate `null` and `{}`.
871
945
  *
@@ -150,6 +150,7 @@ export function _to_delivery(work: WorkState): DeliveryState {
150
150
  contract: work.contract as Record<string, DeliveryAny> | null,
151
151
  stitch: work.stitch as Record<string, DeliveryAny> | null,
152
152
  stack: work.stack as Record<string, DeliveryAny> | null,
153
+ self_fix: work.self_fix as Record<string, DeliveryAny> | null,
153
154
  });
154
155
  }
155
156
 
@@ -182,6 +183,11 @@ export function _sync_back(work: WorkState, delivery: DeliveryState): void {
182
183
  work.contract = delivery.contract as Dict | null;
183
184
  work.stitch = delivery.stitch as Dict | null;
184
185
  work.stack = delivery.stack as Dict | null;
186
+ // Reassigned (not mutated) by `record_attempt`, so the defensive mirror
187
+ // above is load-bearing here rather than a no-op: without this line the
188
+ // attempt counter would reset on every dispatch and the loop would never
189
+ // reach either floor.
190
+ work.self_fix = delivery.self_fix as Dict | null;
185
191
  }
186
192
 
187
193
  /**