wicked-crew 0.5.0 → 0.6.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 (116) hide show
  1. package/dist/api/audit.d.ts +57 -0
  2. package/dist/api/audit.d.ts.map +1 -0
  3. package/dist/api/audit.js +115 -0
  4. package/dist/api/audit.js.map +1 -0
  5. package/dist/api/auth.d.ts +192 -0
  6. package/dist/api/auth.d.ts.map +1 -0
  7. package/dist/api/auth.js +515 -0
  8. package/dist/api/auth.js.map +1 -0
  9. package/dist/api/gate-cache.d.ts +8 -0
  10. package/dist/api/gate-cache.d.ts.map +1 -1
  11. package/dist/api/gate-cache.js +10 -0
  12. package/dist/api/gate-cache.js.map +1 -1
  13. package/dist/api/open-path.d.ts +18 -0
  14. package/dist/api/open-path.d.ts.map +1 -0
  15. package/dist/api/open-path.js +79 -0
  16. package/dist/api/open-path.js.map +1 -0
  17. package/dist/api/routes.d.ts +112 -1
  18. package/dist/api/routes.d.ts.map +1 -1
  19. package/dist/api/routes.js +435 -16
  20. package/dist/api/routes.js.map +1 -1
  21. package/dist/api/seat-health.d.ts +55 -0
  22. package/dist/api/seat-health.d.ts.map +1 -0
  23. package/dist/api/seat-health.js +273 -0
  24. package/dist/api/seat-health.js.map +1 -0
  25. package/dist/api/seat-signin.d.ts +27 -0
  26. package/dist/api/seat-signin.d.ts.map +1 -0
  27. package/dist/api/seat-signin.js +143 -0
  28. package/dist/api/seat-signin.js.map +1 -0
  29. package/dist/api/server.d.ts +111 -3
  30. package/dist/api/server.d.ts.map +1 -1
  31. package/dist/api/server.js +236 -11
  32. package/dist/api/server.js.map +1 -1
  33. package/dist/cli/index.js +97 -3
  34. package/dist/cli/index.js.map +1 -1
  35. package/dist/cli/mcp.d.ts +14 -0
  36. package/dist/cli/mcp.d.ts.map +1 -0
  37. package/dist/cli/mcp.js +119 -0
  38. package/dist/cli/mcp.js.map +1 -0
  39. package/dist/core/adapter.d.ts +64 -1
  40. package/dist/core/adapter.d.ts.map +1 -1
  41. package/dist/core/adapter.js +162 -4
  42. package/dist/core/adapter.js.map +1 -1
  43. package/dist/core/types.d.ts +23 -361
  44. package/dist/core/types.d.ts.map +1 -1
  45. package/dist/core/types.js +11 -4
  46. package/dist/core/types.js.map +1 -1
  47. package/dist/interactive/bridge-pool.d.ts +71 -0
  48. package/dist/interactive/bridge-pool.d.ts.map +1 -0
  49. package/dist/interactive/bridge-pool.js +187 -0
  50. package/dist/interactive/bridge-pool.js.map +1 -0
  51. package/dist/interactive/bridge-root.d.ts +36 -0
  52. package/dist/interactive/bridge-root.d.ts.map +1 -0
  53. package/dist/interactive/bridge-root.js +48 -0
  54. package/dist/interactive/bridge-root.js.map +1 -0
  55. package/dist/interactive/draft-events.d.ts +144 -0
  56. package/dist/interactive/draft-events.d.ts.map +1 -0
  57. package/dist/interactive/draft-events.js +490 -0
  58. package/dist/interactive/draft-events.js.map +1 -0
  59. package/dist/interactive/edit-events.d.ts +172 -0
  60. package/dist/interactive/edit-events.d.ts.map +1 -0
  61. package/dist/interactive/edit-events.js +530 -0
  62. package/dist/interactive/edit-events.js.map +1 -0
  63. package/dist/interactive/ledger.d.ts +39 -0
  64. package/dist/interactive/ledger.d.ts.map +1 -0
  65. package/dist/interactive/ledger.js +93 -0
  66. package/dist/interactive/ledger.js.map +1 -0
  67. package/dist/interactive/proxy-routes.d.ts +39 -0
  68. package/dist/interactive/proxy-routes.d.ts.map +1 -0
  69. package/dist/interactive/proxy-routes.js +189 -0
  70. package/dist/interactive/proxy-routes.js.map +1 -0
  71. package/dist/interactive/ws-relay.d.ts +85 -0
  72. package/dist/interactive/ws-relay.d.ts.map +1 -0
  73. package/dist/interactive/ws-relay.js +191 -0
  74. package/dist/interactive/ws-relay.js.map +1 -0
  75. package/dist/projects/activity.d.ts +29 -0
  76. package/dist/projects/activity.d.ts.map +1 -0
  77. package/dist/projects/activity.js +172 -0
  78. package/dist/projects/activity.js.map +1 -0
  79. package/dist/projects/charter.d.ts +28 -0
  80. package/dist/projects/charter.d.ts.map +1 -0
  81. package/dist/projects/charter.js +53 -0
  82. package/dist/projects/charter.js.map +1 -0
  83. package/dist/projects/events.d.ts +55 -0
  84. package/dist/projects/events.d.ts.map +1 -0
  85. package/dist/projects/events.js +141 -0
  86. package/dist/projects/events.js.map +1 -0
  87. package/dist/projects/membership-index.d.ts +25 -0
  88. package/dist/projects/membership-index.d.ts.map +1 -0
  89. package/dist/projects/membership-index.js +46 -0
  90. package/dist/projects/membership-index.js.map +1 -0
  91. package/dist/projects/routes.d.ts +90 -0
  92. package/dist/projects/routes.d.ts.map +1 -0
  93. package/dist/projects/routes.js +388 -0
  94. package/dist/projects/routes.js.map +1 -0
  95. package/dist/projects/settings.d.ts +32 -0
  96. package/dist/projects/settings.d.ts.map +1 -0
  97. package/dist/projects/settings.js +64 -0
  98. package/dist/projects/settings.js.map +1 -0
  99. package/dist/qe/acceptance.d.ts +137 -0
  100. package/dist/qe/acceptance.d.ts.map +1 -0
  101. package/dist/qe/acceptance.js +249 -0
  102. package/dist/qe/acceptance.js.map +1 -0
  103. package/dist/qe/gate-events.d.ts +111 -0
  104. package/dist/qe/gate-events.d.ts.map +1 -0
  105. package/dist/qe/gate-events.js +168 -0
  106. package/dist/qe/gate-events.js.map +1 -0
  107. package/dist/qe/ledger.d.ts +100 -0
  108. package/dist/qe/ledger.d.ts.map +1 -0
  109. package/dist/qe/ledger.js +154 -0
  110. package/dist/qe/ledger.js.map +1 -0
  111. package/dist/studio/assets/index-CCwXa1cn.js +428 -0
  112. package/dist/studio/assets/index-HWxo0h41.css +32 -0
  113. package/dist/studio/index.html +2 -2
  114. package/package.json +10 -4
  115. package/dist/studio/assets/index-DaaUU8Ep.css +0 -32
  116. package/dist/studio/assets/index-Fu5DRC00.js +0 -423
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Opt-in governed answering of wicked-interactive's STRUCTURAL edits (task #86, Phase 7c
3
+ * final leg — the draft leg's sibling, see draft-events.ts).
4
+ *
5
+ * wicked-interactive's service is model-free: a feedback batch's deterministic items
6
+ * (content/style/remove) are applied instantly by the service and NEVER reach this seam —
7
+ * only `structural-change` items climb. The service lands the deterministic partial as
8
+ * `_v{N}.html`, then emits `wicked.interactive.feedback.processed` with `awaiting_structural > 0`
9
+ * and the structural items INLINE (selector + instruction + the element's CURRENT fragment),
10
+ * expecting *something with intelligence* to answer with `wicked.interactive.edit.completed`
11
+ * carrying the edited fragments. Today that answerer is an ad-hoc `assist` agent session
12
+ * (assist skill Step 3); this module makes a crew-governed run the answerer instead.
13
+ *
14
+ * Same shape as the draft leg, with the structural deltas:
15
+ *
16
+ * - VERSIONED TARGETING: the dedupe unit is the HANDOFF — `<doc>:v<version>` — not the doc
17
+ * (one doc produces many structural handoffs over its life). The durable ledger keys on the
18
+ * handoff, and the closing emit's idempotency key carries doc+version.
19
+ * - INV-2 AT SCALE: unlike a first draft (no pre-existing anchors), an edited fragment MUST
20
+ * retain every pre-existing `data-wid` BYTE-EXACT — the service silently rejects violations
21
+ * (regenerate.js Inv2Error → the user's edit dies with no version landed). So this seam runs
22
+ * a deterministic PRE-EMIT SELF-CHECK mirroring the assist skill's Step 2/Step 3c discipline:
23
+ * parse the handed-off fragment's data-wids, verify the worker's fragment retains all of
24
+ * them, and fail HONEST (error status, no emit) on any violation — a loud crew-side rejection
25
+ * instead of a silent service-side one.
26
+ * - HANDOFF BY FILE: fragments can be arbitrarily large and the PTY seat runner's prompt is
27
+ * single-line, so the seam writes the items to a handoff JSON on disk and names its path in
28
+ * the problem; the worker writes each edited fragment to a per-item output file (never JSON
29
+ * with hand-escaped HTML — the exact failure the assist skill's Step 3c warns about).
30
+ * - PROJECT ATTRIBUTION (the 7b surface): a project-bound doc's events carry `project_id`
31
+ * (interactive's DES-PROJECT-001 enrichment); the governed run is launched with
32
+ * `LaunchOptions.projectId` so the edit shows up in the project's activity feed.
33
+ */
34
+ import { InteractiveHandoffLedger } from './ledger.js';
35
+ import type { CoreAdapter } from '../core/adapter.js';
36
+ import type { WorkflowDef } from '../core/types.js';
37
+ export declare const FEEDBACK_PROCESSED = "wicked.interactive.feedback.processed";
38
+ export declare const EDIT_COMPLETED = "wicked.interactive.edit.completed";
39
+ /** Exact-type filter with a domain guard — no wildcard, one event type is the whole trigger. */
40
+ export declare const INTERACTIVE_EDIT_BUS_FILTER = "wicked.interactive.feedback.processed@wicked-interactive";
41
+ /** Dedicated durable-cursor identity — NOT the draft seam's, so the two interactive seams
42
+ * advance independent cursors and stopping one never strands the other. */
43
+ export declare const INTERACTIVE_EDIT_BUS_PLUGIN = "wicked-crew-interactive-edit";
44
+ export declare const INTERACTIVE_EDIT_WORKFLOW = "interactive-edit";
45
+ /**
46
+ * The governed workflow that fulfils a structural handoff. ONE agent phase — `edit` (build,
47
+ * creator role): the target fragments are already extracted and the instructions already
48
+ * written, so unlike the draft leg there is nothing left to plan; a recon phase would only
49
+ * burn a council turn re-reading a handoff the edit phase reads anyway.
50
+ *
51
+ * The phase `instructions` adapt the fragment-edit contract from interactive's assist skill
52
+ * (Step 2 + Step 3): rewrite each handed-off fragment per its instruction, preserve every
53
+ * pre-existing `data-wid` byte-for-byte, never mint new anchors, keep the markup well-formed,
54
+ * and never fabricate facts. SINGLE-LINE by contract (PTY seat runner, wicked-core FINDING-011).
55
+ *
56
+ * The gate is `auto` with `validator_pin: null` — no human gate, no deterministic floor —
57
+ * because this seam runs its own deterministic pre-emit self-check (INV-2) and interactive's
58
+ * apply path re-checks the same invariant; a wrong-but-anchor-safe edit is the user's to judge
59
+ * on the canvas, exactly as with the assist session it replaces.
60
+ */
61
+ export declare const INTERACTIVE_EDIT_WORKFLOW_DEF: WorkflowDef;
62
+ /** One structural item as handed off by the service (fragment = current outerHTML). */
63
+ export interface StructuralItem {
64
+ selector: string;
65
+ instruction: string;
66
+ fragment: string;
67
+ }
68
+ /** The feedback-processed fields this seam acts on. */
69
+ export interface StructuralHandoff {
70
+ documentId: string;
71
+ /** The partial version the service just landed — the PARENT of the version this edit makes. */
72
+ version: number;
73
+ items: StructuralItem[];
74
+ /** Present when the doc is project-bound (interactive's DES-PROJECT-001 enrichment). */
75
+ projectId?: string;
76
+ }
77
+ /**
78
+ * Parse a bus frame into a {@link StructuralHandoff}, or `null` when it is not an actionable
79
+ * structural handoff: wrong type, malformed payload, slug-invalid document_id, non-integer
80
+ * version, or NO usable structural items. Deterministic-only batches (`awaiting_structural: 0`)
81
+ * return `null` by construction — those edits already landed inside the service (edit-routing
82
+ * rung 1) and must never climb to a crew. Items whose `fragment` is missing/null (the service
83
+ * could not extract the element) are dropped: there is no current markup to edit.
84
+ */
85
+ export declare function parseStructuralFeedback(eventType: string, payload: unknown): StructuralHandoff | null;
86
+ /** The one dedupe unit of this seam: a handoff is doc+version, NOT doc-lifetime. */
87
+ export declare function handoffKey(documentId: string, version: number): string;
88
+ /** Deterministic bus idempotency key for the one edit this seam may land per handoff. */
89
+ export declare function editIdempotencyKey(documentId: string, version: number): string;
90
+ /** One row of the on-disk handoff file the worker reads. */
91
+ export interface HandoffFileItem extends StructuralItem {
92
+ /** Absolute path the worker must write the edited fragment to. */
93
+ output_path: string;
94
+ }
95
+ /** Per-item output paths are INDEX-named (`fragment-1.html`, …), never selector-named — a
96
+ * selector is bus-supplied data and must not name a filesystem path. */
97
+ export declare function handoffFileItems(handoff: StructuralHandoff, outDir: string): HandoffFileItem[];
98
+ /**
99
+ * The run's problem statement. Single-line (PTY contract); the bulky fragments ride in the
100
+ * handoff FILE, so only identity, the capped instruction gist, and the file path ride here.
101
+ */
102
+ export declare function editProblem(handoff: StructuralHandoff, handoffPath: string): string;
103
+ /** Every `data-wid` value in a fragment, in document order (duplicates preserved). */
104
+ export declare function fragmentWids(fragment: string): string[];
105
+ /** The data-wids of `before` missing from `after`, byte-exact. Non-empty = INV-2 violation.
106
+ * Deliberately conservative: a wid that survives with different quoting/escaping counts as
107
+ * dropped — the service compares exact attribute values, and fail-closed here beats a silent
108
+ * Inv2Error rejection there. */
109
+ export declare function droppedWids(before: string, after: string): string[];
110
+ /** One rejected item of a self-check. */
111
+ export interface EditViolation {
112
+ selector: string;
113
+ reason: string;
114
+ }
115
+ /** The self-check verdict over a whole handoff's worker output. */
116
+ export interface EditCollection {
117
+ results: Array<{
118
+ selector: string;
119
+ fragment: string;
120
+ }>;
121
+ violations: EditViolation[];
122
+ }
123
+ /**
124
+ * Read the worker's per-item output files and verify each against the handed-off fragment:
125
+ * the file must exist non-empty, and every pre-existing `data-wid` must survive byte-exact.
126
+ * ANY violation fails the whole handoff (all-or-nothing): a partial apply would land a version
127
+ * the user believes complete, and the violating item would die silently service-side.
128
+ */
129
+ export declare function collectEditResults(items: HandoffFileItem[]): EditCollection;
130
+ /** Options for {@link startInteractiveEditSubscriber}. */
131
+ export interface InteractiveEditOptions {
132
+ /** Bus SQLite db path. Omit to let wicked-bus resolve its own default
133
+ * (honors `WICKED_BUS_DATA_DIR`) — where interactive's service emits unless redirected. */
134
+ dbPath?: string;
135
+ /** Poll cadence, ms (default 2000; tests shorten it). */
136
+ pollIntervalMs?: number;
137
+ /** Heartbeat narration cadence while a run is in flight, ms (default 15000 — inside the
138
+ * UI's ~20s `status.requested` window so the canvas never reads frozen). */
139
+ heartbeatMs?: number;
140
+ /** Ledger file (default `~/.wicked-crew/interactive-edit-ledger.json`). */
141
+ ledgerPath?: string;
142
+ /** Where handoff files land and workers write edited fragments
143
+ * (default `~/.wicked-crew/interactive-edits`). */
144
+ editDir?: string;
145
+ /** Seat roster JSON for the governed run (default: the production council roster).
146
+ * The functional-test harness passes a deterministic stub seat here. */
147
+ clisJson?: string;
148
+ /** Called after a launch that FILED the run into a project (the handoff carried
149
+ * `project_id`). The server wires this to the same post-commit half the launch route
150
+ * performs: tag the run in the live membership index + emit `wicked.crew.membership.attached`
151
+ * (the engine already attached the crew.run membership atomically with the launch). */
152
+ onRunFiled?: (runId: string, projectId: string) => void;
153
+ /** Diagnostics sink (default: console.error). */
154
+ log?: (message: string) => void;
155
+ }
156
+ /** Handle for a running subscription. */
157
+ export interface InteractiveEditSubscription {
158
+ stop(): Promise<void> | void;
159
+ /** The durable ledger (diagnostics / tests). */
160
+ ledger: InteractiveHandoffLedger;
161
+ }
162
+ /**
163
+ * Arm the seam: register the `interactive-edit` workflow, open a durable
164
+ * `wicked.interactive.feedback.processed` subscription, and answer each handoff carrying
165
+ * structural items with a governed run that ends in `wicked.interactive.edit.completed`.
166
+ *
167
+ * Graceful degradation mirrors the draft seam: a missing wicked-bus package or an unopenable
168
+ * db LOGS and returns `null` — the daemon must still boot on a machine whose bus is broken;
169
+ * interactive's assist loop remains the (always-available) fallback answerer.
170
+ */
171
+ export declare function startInteractiveEditSubscriber(adapter: CoreAdapter, opts?: InteractiveEditOptions): Promise<InteractiveEditSubscription | null>;
172
+ //# sourceMappingURL=edit-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit-events.d.ts","sourceRoot":"","sources":["../../src/interactive/edit-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAcH,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAA6B,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI/E,eAAO,MAAM,kBAAkB,0CAA0C,CAAC;AAC1E,eAAO,MAAM,cAAc,sCAAsC,CAAC;AAElE,gGAAgG;AAChG,eAAO,MAAM,2BAA2B,6DAAgD,CAAC;AAEzF;4EAC4E;AAC5E,eAAO,MAAM,2BAA2B,iCAAiC,CAAC;AAI1E,eAAO,MAAM,yBAAyB,qBAAqB,CAAC;AAE5D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,6BAA6B,EAAE,WAqB3C,CAAC;AAIF,uFAAuF;AACvF,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE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