wicked-crew 0.16.11 → 0.16.13
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/README.md +28 -8
- package/dist/api/artifact-outline.d.ts +64 -0
- package/dist/api/artifact-outline.d.ts.map +1 -0
- package/dist/api/artifact-outline.js +254 -0
- package/dist/api/artifact-outline.js.map +1 -0
- package/dist/api/beneath.d.ts +76 -0
- package/dist/api/beneath.d.ts.map +1 -0
- package/dist/api/beneath.js +214 -0
- package/dist/api/beneath.js.map +1 -0
- package/dist/api/capture.d.ts +2 -2
- package/dist/api/chat-citations.d.ts +25 -1
- package/dist/api/chat-citations.d.ts.map +1 -1
- package/dist/api/chat-citations.js +186 -61
- package/dist/api/chat-citations.js.map +1 -1
- package/dist/api/chat-context.d.ts +236 -0
- package/dist/api/chat-context.d.ts.map +1 -0
- package/dist/api/chat-context.js +808 -0
- package/dist/api/chat-context.js.map +1 -0
- package/dist/api/chat-history.d.ts +20 -0
- package/dist/api/chat-history.d.ts.map +1 -1
- package/dist/api/chat-history.js +46 -1
- package/dist/api/chat-history.js.map +1 -1
- package/dist/api/chat-proposals.d.ts +534 -0
- package/dist/api/chat-proposals.d.ts.map +1 -0
- package/dist/api/chat-proposals.js +1562 -0
- package/dist/api/chat-proposals.js.map +1 -0
- package/dist/api/chat-scope.d.ts +41 -0
- package/dist/api/chat-scope.d.ts.map +1 -1
- package/dist/api/chat-scope.js +87 -15
- package/dist/api/chat-scope.js.map +1 -1
- package/dist/api/chat-transcripts.d.ts +27 -2
- package/dist/api/chat-transcripts.d.ts.map +1 -1
- package/dist/api/chat-transcripts.js +105 -4
- package/dist/api/chat-transcripts.js.map +1 -1
- package/dist/api/diagnostics.d.ts +15 -0
- package/dist/api/diagnostics.d.ts.map +1 -1
- package/dist/api/diagnostics.js +56 -0
- package/dist/api/diagnostics.js.map +1 -1
- package/dist/api/elicitation-cache.d.ts +13 -0
- package/dist/api/elicitation-cache.d.ts.map +1 -1
- package/dist/api/elicitation-cache.js +12 -0
- package/dist/api/elicitation-cache.js.map +1 -1
- package/dist/api/eval-sample.d.ts +12 -12
- package/dist/api/frame-guard.d.ts +62 -0
- package/dist/api/frame-guard.d.ts.map +1 -0
- package/dist/api/frame-guard.js +97 -0
- package/dist/api/frame-guard.js.map +1 -0
- package/dist/api/governance-steering.d.ts +4 -4
- package/dist/api/multiscope.d.ts +3 -0
- package/dist/api/multiscope.d.ts.map +1 -1
- package/dist/api/multiscope.js +13 -0
- package/dist/api/multiscope.js.map +1 -1
- package/dist/api/needs.d.ts +6 -0
- package/dist/api/needs.d.ts.map +1 -1
- package/dist/api/needs.js +31 -4
- package/dist/api/needs.js.map +1 -1
- package/dist/api/product.d.ts.map +1 -1
- package/dist/api/product.js +13 -2
- package/dist/api/product.js.map +1 -1
- package/dist/api/project-aggregates.d.ts +6 -6
- package/dist/api/project-aggregates.d.ts.map +1 -1
- package/dist/api/project-aggregates.js +16 -24
- package/dist/api/project-aggregates.js.map +1 -1
- package/dist/api/requirements.d.ts +261 -6
- package/dist/api/requirements.d.ts.map +1 -1
- package/dist/api/requirements.js +344 -64
- package/dist/api/requirements.js.map +1 -1
- package/dist/api/routes.d.ts +156 -4
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +851 -78
- package/dist/api/routes.js.map +1 -1
- package/dist/api/run-brief.d.ts +78 -0
- package/dist/api/run-brief.d.ts.map +1 -0
- package/dist/api/run-brief.js +318 -0
- package/dist/api/run-brief.js.map +1 -0
- package/dist/api/run-files.d.ts.map +1 -1
- package/dist/api/run-files.js +5 -1
- package/dist/api/run-files.js.map +1 -1
- package/dist/api/run-timing-index.d.ts +27 -0
- package/dist/api/run-timing-index.d.ts.map +1 -1
- package/dist/api/run-timing-index.js +65 -0
- package/dist/api/run-timing-index.js.map +1 -1
- package/dist/api/seat-images.d.ts +102 -0
- package/dist/api/seat-images.d.ts.map +1 -0
- package/dist/api/seat-images.js +333 -0
- package/dist/api/seat-images.js.map +1 -0
- package/dist/api/server.d.ts +3 -0
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +265 -2
- package/dist/api/server.js.map +1 -1
- package/dist/api/steering-landing.d.ts +48 -1
- package/dist/api/steering-landing.d.ts.map +1 -1
- package/dist/api/steering-landing.js +116 -42
- package/dist/api/steering-landing.js.map +1 -1
- package/dist/api/system-snapshot.d.ts +51 -2
- package/dist/api/system-snapshot.d.ts.map +1 -1
- package/dist/api/system-snapshot.js +151 -15
- package/dist/api/system-snapshot.js.map +1 -1
- package/dist/api/testing.d.ts +4 -4
- package/dist/api/testing.js +2 -2
- package/dist/api/testing.js.map +1 -1
- package/dist/apps/spec.d.ts +3009 -0
- package/dist/apps/spec.d.ts.map +1 -0
- package/dist/apps/spec.js +870 -0
- package/dist/apps/spec.js.map +1 -0
- package/dist/campaigns/routes.js +1 -1
- package/dist/campaigns/routes.js.map +1 -1
- package/dist/cli/index.js +3 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/core/adapter.d.ts +12 -0
- package/dist/core/adapter.d.ts.map +1 -1
- package/dist/core/adapter.js +36 -1
- package/dist/core/adapter.js.map +1 -1
- package/dist/core/deliver-text.d.ts.map +1 -1
- package/dist/core/deliver-text.js +22 -10
- package/dist/core/deliver-text.js.map +1 -1
- package/dist/core/estate-mcp-client.d.ts +7 -1
- package/dist/core/estate-mcp-client.d.ts.map +1 -1
- package/dist/core/estate-mcp-client.js +10 -2
- package/dist/core/estate-mcp-client.js.map +1 -1
- package/dist/core/exec.d.ts +12 -0
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +23 -0
- package/dist/core/exec.js.map +1 -1
- package/dist/core/reassign-refusal.d.ts.map +1 -1
- package/dist/core/reassign-refusal.js +23 -3
- package/dist/core/reassign-refusal.js.map +1 -1
- package/dist/core/repoPaths.d.ts +32 -7
- package/dist/core/repoPaths.d.ts.map +1 -1
- package/dist/core/repoPaths.js +56 -9
- package/dist/core/repoPaths.js.map +1 -1
- package/dist/core/requirements-graph-setting.d.ts +32 -0
- package/dist/core/requirements-graph-setting.d.ts.map +1 -0
- package/dist/core/requirements-graph-setting.js +84 -0
- package/dist/core/requirements-graph-setting.js.map +1 -0
- package/dist/core/run-boot-resume.d.ts +4 -1
- package/dist/core/run-boot-resume.d.ts.map +1 -1
- package/dist/core/run-boot-resume.js +6 -1
- package/dist/core/run-boot-resume.js.map +1 -1
- package/dist/core/run-identity.d.ts.map +1 -1
- package/dist/core/run-identity.js +6 -0
- package/dist/core/run-identity.js.map +1 -1
- package/dist/core/types.d.ts +14 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/decisions/chat-recorder.d.ts +14 -3
- package/dist/decisions/chat-recorder.d.ts.map +1 -1
- package/dist/decisions/chat-recorder.js +54 -9
- package/dist/decisions/chat-recorder.js.map +1 -1
- package/dist/editors/csp.d.ts +24 -4
- package/dist/editors/csp.d.ts.map +1 -1
- package/dist/editors/csp.js +35 -8
- package/dist/editors/csp.js.map +1 -1
- package/dist/editors/registry.d.ts +46 -21
- package/dist/editors/registry.d.ts.map +1 -1
- package/dist/editors/registry.js +13 -2
- package/dist/editors/registry.js.map +1 -1
- package/dist/editors/routes.d.ts +4 -1
- package/dist/editors/routes.d.ts.map +1 -1
- package/dist/editors/routes.js +30 -3
- package/dist/editors/routes.js.map +1 -1
- package/dist/editors/visuals.d.ts +51 -0
- package/dist/editors/visuals.d.ts.map +1 -0
- package/dist/editors/visuals.js +164 -0
- package/dist/editors/visuals.js.map +1 -0
- package/dist/editors/webrtc-guard.d.ts +94 -0
- package/dist/editors/webrtc-guard.d.ts.map +1 -0
- package/dist/editors/webrtc-guard.js +506 -0
- package/dist/editors/webrtc-guard.js.map +1 -0
- package/dist/inspect/reading.d.ts +110 -0
- package/dist/inspect/reading.d.ts.map +1 -0
- package/dist/inspect/reading.js +325 -0
- package/dist/inspect/reading.js.map +1 -0
- package/dist/inspect/routes.d.ts +14 -0
- package/dist/inspect/routes.d.ts.map +1 -0
- package/dist/inspect/routes.js +44 -0
- package/dist/inspect/routes.js.map +1 -0
- package/dist/inspect/service.d.ts +161 -0
- package/dist/inspect/service.d.ts.map +1 -0
- package/dist/inspect/service.js +466 -0
- package/dist/inspect/service.js.map +1 -0
- package/dist/interactive/bridge-pool.d.ts +11 -2
- package/dist/interactive/bridge-pool.d.ts.map +1 -1
- package/dist/interactive/bridge-pool.js +10 -1
- package/dist/interactive/bridge-pool.js.map +1 -1
- package/dist/interactive/doc-binding.d.ts +156 -0
- package/dist/interactive/doc-binding.d.ts.map +1 -0
- package/dist/interactive/doc-binding.js +277 -0
- package/dist/interactive/doc-binding.js.map +1 -0
- package/dist/interactive/doc-delete-routes.d.ts +3 -0
- package/dist/interactive/doc-delete-routes.d.ts.map +1 -1
- package/dist/interactive/doc-delete-routes.js +4 -0
- package/dist/interactive/doc-delete-routes.js.map +1 -1
- package/dist/interactive/draft-events.d.ts +89 -3
- package/dist/interactive/draft-events.d.ts.map +1 -1
- package/dist/interactive/draft-events.js +441 -30
- package/dist/interactive/draft-events.js.map +1 -1
- package/dist/interactive/draft-skill.d.ts +7 -0
- package/dist/interactive/draft-skill.d.ts.map +1 -1
- package/dist/interactive/draft-skill.js +10 -3
- package/dist/interactive/draft-skill.js.map +1 -1
- package/dist/interactive/edit-events.d.ts +2 -0
- package/dist/interactive/edit-events.d.ts.map +1 -1
- package/dist/interactive/edit-events.js +11 -0
- package/dist/interactive/edit-events.js.map +1 -1
- package/dist/interactive/proposal-create.d.ts +143 -0
- package/dist/interactive/proposal-create.d.ts.map +1 -0
- package/dist/interactive/proposal-create.js +318 -0
- package/dist/interactive/proposal-create.js.map +1 -0
- package/dist/interactive/proxy-routes.d.ts +60 -3
- package/dist/interactive/proxy-routes.d.ts.map +1 -1
- package/dist/interactive/proxy-routes.js +217 -3
- package/dist/interactive/proxy-routes.js.map +1 -1
- package/dist/interactive/source-packet.d.ts +126 -0
- package/dist/interactive/source-packet.d.ts.map +1 -0
- package/dist/interactive/source-packet.js +482 -0
- package/dist/interactive/source-packet.js.map +1 -0
- package/dist/learnings/estate.d.ts +16 -0
- package/dist/learnings/estate.d.ts.map +1 -0
- package/dist/learnings/estate.js +68 -0
- package/dist/learnings/estate.js.map +1 -0
- package/dist/learnings/extract.d.ts +56 -0
- package/dist/learnings/extract.d.ts.map +1 -0
- package/dist/learnings/extract.js +252 -0
- package/dist/learnings/extract.js.map +1 -0
- package/dist/learnings/recall.d.ts +43 -0
- package/dist/learnings/recall.d.ts.map +1 -0
- package/dist/learnings/recall.js +104 -0
- package/dist/learnings/recall.js.map +1 -0
- package/dist/learnings/service.d.ts +183 -0
- package/dist/learnings/service.d.ts.map +1 -0
- package/dist/learnings/service.js +571 -0
- package/dist/learnings/service.js.map +1 -0
- package/dist/mcp/ask-server.d.ts.map +1 -1
- package/dist/mcp/ask-server.js +37 -4
- package/dist/mcp/ask-server.js.map +1 -1
- package/dist/mcp/broker.d.ts +12 -1
- package/dist/mcp/broker.d.ts.map +1 -1
- package/dist/mcp/broker.js +24 -5
- package/dist/mcp/broker.js.map +1 -1
- package/dist/mcp/invoke.d.ts +26 -2
- package/dist/mcp/invoke.d.ts.map +1 -1
- package/dist/mcp/invoke.js +51 -5
- package/dist/mcp/invoke.js.map +1 -1
- package/dist/persona/routes.d.ts +92 -0
- package/dist/persona/routes.d.ts.map +1 -0
- package/dist/persona/routes.js +69 -0
- package/dist/persona/routes.js.map +1 -0
- package/dist/persona/store.d.ts +104 -0
- package/dist/persona/store.d.ts.map +1 -0
- package/dist/persona/store.js +176 -0
- package/dist/persona/store.js.map +1 -0
- package/dist/persona/voice.d.ts +4 -0
- package/dist/persona/voice.d.ts.map +1 -0
- package/dist/persona/voice.js +58 -0
- package/dist/persona/voice.js.map +1 -0
- package/dist/projects/routes.d.ts +2 -2
- package/dist/setup/known.d.ts +56 -0
- package/dist/setup/known.d.ts.map +1 -0
- package/dist/setup/known.js +159 -0
- package/dist/setup/known.js.map +1 -0
- package/dist/setup/routes.d.ts +13 -0
- package/dist/setup/routes.d.ts.map +1 -0
- package/dist/setup/routes.js +20 -0
- package/dist/setup/routes.js.map +1 -0
- package/dist/standing-orders/history.d.ts +2 -0
- package/dist/standing-orders/history.d.ts.map +1 -1
- package/dist/standing-orders/history.js +1 -0
- package/dist/standing-orders/history.js.map +1 -1
- package/dist/studio/assets/WickedSans-Regular-fb698rcD.woff2 +0 -0
- package/dist/studio/assets/WickedSans-SemiBold-CD53n1AC.woff2 +0 -0
- package/dist/studio/assets/WickedScript-Regular-CY5juO6I.woff2 +0 -0
- package/dist/studio/assets/WickedSerif-Regular-mdPEjaVZ.woff2 +0 -0
- package/dist/studio/assets/index-BUZ_-Syk.css +32 -0
- package/dist/studio/assets/index-u4O_7N-b.js +986 -0
- package/dist/studio/editors/wicked-deck/editor.json +6 -1
- package/dist/studio/editors/wicked-deck/icon.svg +1 -0
- package/dist/studio/editors/wicked-deck/index.html +1 -1
- package/dist/studio/editors/wicked-doc/editor.json +6 -1
- package/dist/studio/editors/wicked-doc/icon.svg +1 -0
- package/dist/studio/editors/wicked-doc/index.html +1 -1
- package/dist/studio/editors/wicked-insights/editor.json +6 -1
- package/dist/studio/editors/wicked-insights/icon.svg +1 -0
- package/dist/studio/editors/wicked-insights/index.html +1 -1
- package/dist/studio/editors/wicked-page/editor.json +6 -1
- package/dist/studio/editors/wicked-page/icon.svg +1 -0
- package/dist/studio/editors/wicked-page/index.html +1 -1
- package/dist/studio/editors/wicked-video/editor.json +6 -1
- package/dist/studio/editors/wicked-video/icon.svg +1 -0
- package/dist/studio/editors/wicked-video/index.html +1 -1
- package/dist/studio/index.html +2 -2
- package/dist/studio/testid-inventory.json +5155 -2707
- package/dist/voice/dashboard.d.ts +376 -0
- package/dist/voice/dashboard.d.ts.map +1 -0
- package/dist/voice/dashboard.js +92 -0
- package/dist/voice/dashboard.js.map +1 -0
- package/dist/voice/inject-input.d.ts +51 -0
- package/dist/voice/inject-input.d.ts.map +1 -0
- package/dist/voice/inject-input.js +126 -0
- package/dist/voice/inject-input.js.map +1 -0
- package/dist/voice/routes.d.ts +41 -0
- package/dist/voice/routes.d.ts.map +1 -0
- package/dist/voice/routes.js +116 -0
- package/dist/voice/routes.js.map +1 -0
- package/dist/voice/service.d.ts +177 -0
- package/dist/voice/service.d.ts.map +1 -0
- package/dist/voice/service.js +400 -0
- package/dist/voice/service.js.map +1 -0
- package/dist/workflow-catalog/build.d.ts +35 -0
- package/dist/workflow-catalog/build.d.ts.map +1 -0
- package/dist/workflow-catalog/build.js +229 -0
- package/dist/workflow-catalog/build.js.map +1 -0
- package/dist/workflow-catalog/catalog-data.d.ts +36 -0
- package/dist/workflow-catalog/catalog-data.d.ts.map +1 -0
- package/dist/workflow-catalog/catalog-data.js +430 -0
- package/dist/workflow-catalog/catalog-data.js.map +1 -0
- package/dist/working-doc/event-lines.d.ts +76 -0
- package/dist/working-doc/event-lines.d.ts.map +1 -0
- package/dist/working-doc/event-lines.js +247 -0
- package/dist/working-doc/event-lines.js.map +1 -0
- package/dist/working-doc/routes.d.ts +1 -1
- package/dist/working-doc/routes.d.ts.map +1 -1
- package/dist/working-doc/routes.js +2 -1
- package/dist/working-doc/routes.js.map +1 -1
- package/dist/working-doc/sections.d.ts +3 -1
- package/dist/working-doc/sections.d.ts.map +1 -1
- package/dist/working-doc/sections.js +4 -2
- package/dist/working-doc/sections.js.map +1 -1
- package/dist/working-doc/service.d.ts +66 -1
- package/dist/working-doc/service.d.ts.map +1 -1
- package/dist/working-doc/service.js +298 -22
- package/dist/working-doc/service.js.map +1 -1
- package/dist/working-doc/store.d.ts +8 -2
- package/dist/working-doc/store.d.ts.map +1 -1
- package/dist/working-doc/store.js.map +1 -1
- package/endpoint-manifest.json +205 -2
- package/package.json +5 -4
- package/workflows/distill-learnings.json +27 -0
- package/workflows/inspect-unit.json +27 -0
- package/dist/studio/assets/index-B-f_VEL2.css +0 -32
- package/dist/studio/assets/index-DhkxIK-0.js +0 -845
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE `create` LAUNCHER OF A CHAT PROPOSAL (DES-CHAT-ARTIFACTS-001 §4.3 steps 2-3, §5.2; slice A3).
|
|
3
|
+
*
|
|
4
|
+
* Registered on A2's {@link LaunchOnceRegistry}: `launchOnce` holds the run id's lock, asks {@link find}, and calls
|
|
5
|
+
* {@link launch} only when the engine has no such run. `launch` makes exactly one document and one run, whatever was
|
|
6
|
+
* lost before it:
|
|
7
|
+
*
|
|
8
|
+
* 1. the document's binding and this attempt are recorded first (`doc-binding.ts`), so the bus trigger of the
|
|
9
|
+
* document knows it is a chat's and hands it back to `launchOnce` instead of launching a random-id draft;
|
|
10
|
+
* 2. the document is looked up by its derived name in its mount, and created only if it is missing, by crew itself,
|
|
11
|
+
* through the proxy's own create path with `chat_id` + `proposal_id` (so the Unfiled-repository exception goes
|
|
12
|
+
* through the accepted record, §5.2). A 409 from a create that raced is adoption, not failure;
|
|
13
|
+
* 3. the source packet is built from the stored resolution and the chat's records, joins the document's canonical
|
|
14
|
+
* packet, and the draft is launched with the DERIVED run id as its `sessionId` (never a random one).
|
|
15
|
+
*
|
|
16
|
+
* So a double click, a lost response, two tabs, a crash between launch and record, and a crash between create and
|
|
17
|
+
* draft launch all end with one document and one run. A launch that fails leaves the attempt recorded with no run:
|
|
18
|
+
* the card shows "Interrupted · Go again", which resumes the same identity.
|
|
19
|
+
*/
|
|
20
|
+
import type { ChatTranscriptRecord, ProposalIdentity, SessionView } from '../core/types.js';
|
|
21
|
+
import { type ProposalDispatch, type ProposalDispatcher } from '../api/chat-proposals.js';
|
|
22
|
+
import type { DocBinding, DocBindingAttempt, DocBindingStore } from './doc-binding.js';
|
|
23
|
+
import type { BoundDraft, BoundOutcome } from './draft-events.js';
|
|
24
|
+
import { type PacketDeps } from './source-packet.js';
|
|
25
|
+
export interface CreateLauncherDeps {
|
|
26
|
+
bindings: DocBindingStore;
|
|
27
|
+
/** Whether the engine knows this run id. */
|
|
28
|
+
runExists(runId: string): Promise<boolean>;
|
|
29
|
+
/** The docs root of a route project (`default` = Unfiled); `null` = no such project. */
|
|
30
|
+
docsRoot(projectId: string): Promise<string | null>;
|
|
31
|
+
/** Crew's in-process create through the proxy's own path (`createDocInProcess`). */
|
|
32
|
+
createDoc(projectId: string, body: Record<string, unknown>, actorId: string): Promise<{
|
|
33
|
+
status: number;
|
|
34
|
+
body: unknown;
|
|
35
|
+
}>;
|
|
36
|
+
/** The draft seam's proposal-bound launch; `null` when the seam is not armed (nothing can draft). */
|
|
37
|
+
launchBound: ((spec: BoundDraft) => Promise<void>) | null;
|
|
38
|
+
/** Remove earlier attempts' folders of the document before this attempt reads its base (`fenceBound`). */
|
|
39
|
+
fence?: (documentId: string, runIds: readonly string[]) => void;
|
|
40
|
+
/** The chat's records (live transcript or kept history). */
|
|
41
|
+
records(chatId: string): ChatTranscriptRecord[];
|
|
42
|
+
/** The chat's instance now (its history nonce), or `null`. */
|
|
43
|
+
instanceOf(chatId: string): string | null;
|
|
44
|
+
/** The id a chat instance is kept under now: its own id, or the archive id a reuse of the id moved it to; `null` when
|
|
45
|
+
* it is gone. A binding reads its chat through this, never another person's chat that reused the id. */
|
|
46
|
+
chatIdOf(chatId: string, instance: string | null): string | null;
|
|
47
|
+
/** Registered repositories by id (for their roots). */
|
|
48
|
+
repos(): Promise<Array<{
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
rootPath: string;
|
|
52
|
+
}>>;
|
|
53
|
+
/** The code graph a document in this mount gets: the project's, else the chat's own scope graph. */
|
|
54
|
+
graphFor(projectId: string | null, chatId: string): Promise<string | null>;
|
|
55
|
+
/** The launch roster of two seats, as `clisJson`; `null` when either can no longer work. */
|
|
56
|
+
clisJsonFor(seats: readonly string[]): string | null;
|
|
57
|
+
/** The style of a catalog entry (`launch.style`). */
|
|
58
|
+
styleOf(entry: string | null): string;
|
|
59
|
+
packetDeps: PacketDeps;
|
|
60
|
+
log?: (msg: string) => void;
|
|
61
|
+
}
|
|
62
|
+
export declare class CreateLauncher implements ProposalDispatcher {
|
|
63
|
+
private readonly deps;
|
|
64
|
+
constructor(deps: CreateLauncherDeps);
|
|
65
|
+
find(identity: ProposalIdentity): Promise<boolean>;
|
|
66
|
+
/** Busy until the attempt's outcome is recorded (§6.2), once its run exists. A launch that never produced a run is
|
|
67
|
+
* not busy: Go again resumes it. */
|
|
68
|
+
live(runId: string): Promise<boolean>;
|
|
69
|
+
/** A document with an attempt still without an outcome, whose run exists. */
|
|
70
|
+
docBusy(artifactRef: string): Promise<boolean>;
|
|
71
|
+
launch(d: ProposalDispatch): Promise<void>;
|
|
72
|
+
/** The resolution's repositories with their registered roots (a repository unregistered since is left out, said). */
|
|
73
|
+
private boundRepos;
|
|
74
|
+
}
|
|
75
|
+
/** The route project of a mount (`default` for Unfiled). */
|
|
76
|
+
export declare function routeProjectOf(mount: string): string;
|
|
77
|
+
export interface ReconcileDeps {
|
|
78
|
+
bindings: DocBindingStore;
|
|
79
|
+
sessions(): Promise<SessionView[]>;
|
|
80
|
+
cancelRun(runId: string): Promise<unknown>;
|
|
81
|
+
/** The document's versions now: its head and, per version, the run that made it when interactive records that (the
|
|
82
|
+
* I1 contract: `run_id` on each new entry). `provenance` = the manifest records runs at all. `null` = not readable. */
|
|
83
|
+
docVersions(projectId: string | null, doc: string): {
|
|
84
|
+
head: number;
|
|
85
|
+
byRun: Map<string, number>;
|
|
86
|
+
provenance: boolean;
|
|
87
|
+
} | null;
|
|
88
|
+
/** The id the binding's chat is kept under now (its own, or an archive id after a reuse), or `null`. */
|
|
89
|
+
chatIdOf(chatId: string, instance: string | null): string | null;
|
|
90
|
+
/** Decide an `accepting` proposal whose run exists (A2's adopt). */
|
|
91
|
+
settleAccepting(chatId: string, pid: string): Promise<boolean>;
|
|
92
|
+
/** The run's `run.launched` facts (chat, proposal, artifact, document), recorded again when a crash lost them. */
|
|
93
|
+
ensureLaunchRecord(binding: DocBinding, attempt: DocBindingAttempt): void;
|
|
94
|
+
/** An outcome this reconcile recorded, or a failure whose publication a crash cut short (release, `landing_failed`,
|
|
95
|
+
* retry card: each idempotent). */
|
|
96
|
+
onOutcome(ref: string, runId: string, outcome: BoundOutcome): void;
|
|
97
|
+
/** Whether the run's `run.landing_failed` is on record (the audit append is asynchronous: a crash can lose it after
|
|
98
|
+
* the binding said "published"). */
|
|
99
|
+
hasLandingFailed(runId: string): boolean;
|
|
100
|
+
/** Every attempt's document, every boot (a recovered run keeps its document link across restarts). */
|
|
101
|
+
linkDocument(runId: string, doc: string): void;
|
|
102
|
+
log(msg: string): void;
|
|
103
|
+
/** How long a cancelled run is waited for, ms (default 30 s). */
|
|
104
|
+
waitMs?: number;
|
|
105
|
+
sleep?: (ms: number) => Promise<void>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* DES-CHAT-ARTIFACTS-001 §6.2 (A3): at daemon start, BEFORE the generic boot resume (which skips bound runs), every
|
|
109
|
+
* proposal-bound attempt without a recorded outcome is settled. An `accepting` proposal whose run exists is decided, and
|
|
110
|
+
* the run's launch facts are recorded again if a crash lost them. An attempt crew had announced landed when the
|
|
111
|
+
* document's manifest names its run (the I1 contract); before that contract, when the head moved past its base (the
|
|
112
|
+
* best evidence there is, said in the log). Every other attempt with a run lost its seam flight in the restart: its
|
|
113
|
+
* engine run is cancelled to a CONFIRMED terminal state, then "interrupted by a restart" is recorded, and only then are
|
|
114
|
+
* the chat and the document released and Try again offered, so an old attempt never runs beside a new one (a retry
|
|
115
|
+
* also removes the old attempt's folder, so an announce of it still on the bus cannot land). Never a redispatch. An
|
|
116
|
+
* attempt with no run is left alone: its card's "Go again" resumes the same identity. A failure whose publication a
|
|
117
|
+
* crash cut short is published again.
|
|
118
|
+
*/
|
|
119
|
+
export declare function reconcileBoundAttempts(deps: ReconcileDeps): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* A document's head and which run made each version, read from its `versions.json` beneath the docs root (no link
|
|
122
|
+
* followed). `provenance` is whether the manifest records runs at all (interactive's I1 contract writes `run_id` on
|
|
123
|
+
* every new entry; an older interactive writes none). `null` when the manifest cannot be read.
|
|
124
|
+
*/
|
|
125
|
+
/**
|
|
126
|
+
* The chat a recovered attempt is filed under: the binding's own chat instance where it is kept now (its archive id after
|
|
127
|
+
* a reuse); none when that instance is gone, never the bare id a later chat may have taken since (xreview r5). A chat
|
|
128
|
+
* that had no instance when Go was pressed can only be named by its id.
|
|
129
|
+
*/
|
|
130
|
+
export declare function recoveredChatId(history: {
|
|
131
|
+
idOfInstance(id: string, instance: string | null): string | null;
|
|
132
|
+
}, b: Pick<DocBinding, 'chatId' | 'chatInstance'>): string | null;
|
|
133
|
+
/** The `run.launched` detail boot writes for a recovered attempt whose launch record is missing: the chat, proposal,
|
|
134
|
+
* artifact and document from the binding, as the draft seam would have, under the chat as it is kept now. */
|
|
135
|
+
export declare function recoveredLaunchDetail(history: {
|
|
136
|
+
idOfInstance(id: string, instance: string | null): string | null;
|
|
137
|
+
}, b: Pick<DocBinding, 'chatId' | 'chatInstance' | 'owner' | 'ref'>, a: Pick<DocBindingAttempt, 'pid'>): Record<string, unknown>;
|
|
138
|
+
export declare function docVersionsOf(docsRoot: string, doc: string): {
|
|
139
|
+
head: number;
|
|
140
|
+
byRun: Map<string, number>;
|
|
141
|
+
provenance: boolean;
|
|
142
|
+
} | null;
|
|
143
|
+
//# sourceMappingURL=proposal-create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proposal-create.d.ts","sourceRoot":"","sources":["../../src/interactive/proposal-create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAoB,oBAAoB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE9G,OAAO,EAAiB,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAMzG,OAAO,KAAK,EAAa,UAAU,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,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AAI,GAAG,MAAM,GAAG,IAAI,CAAA;CAAE,EAC7E,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,GAAG,cAAc,CAAC,GAC7C,MAAM,GAAG,IAAI,CAEf;AAED;8GAC8G;AAC9G,wBAAgB,qBAAqB,CACnC,OAAO,EAAE;IAAE,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;CAAE,EAC7E,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,GAAG,cAAc,GAAG,OAAO,GAAG,KAAK,CAAC,EAChE,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,GAChC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGzB;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAiBrI"}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE `create` LAUNCHER OF A CHAT PROPOSAL (DES-CHAT-ARTIFACTS-001 §4.3 steps 2-3, §5.2; slice A3).
|
|
3
|
+
*
|
|
4
|
+
* Registered on A2's {@link LaunchOnceRegistry}: `launchOnce` holds the run id's lock, asks {@link find}, and calls
|
|
5
|
+
* {@link launch} only when the engine has no such run. `launch` makes exactly one document and one run, whatever was
|
|
6
|
+
* lost before it:
|
|
7
|
+
*
|
|
8
|
+
* 1. the document's binding and this attempt are recorded first (`doc-binding.ts`), so the bus trigger of the
|
|
9
|
+
* document knows it is a chat's and hands it back to `launchOnce` instead of launching a random-id draft;
|
|
10
|
+
* 2. the document is looked up by its derived name in its mount, and created only if it is missing, by crew itself,
|
|
11
|
+
* through the proxy's own create path with `chat_id` + `proposal_id` (so the Unfiled-repository exception goes
|
|
12
|
+
* through the accepted record, §5.2). A 409 from a create that raced is adoption, not failure;
|
|
13
|
+
* 3. the source packet is built from the stored resolution and the chat's records, joins the document's canonical
|
|
14
|
+
* packet, and the draft is launched with the DERIVED run id as its `sessionId` (never a random one).
|
|
15
|
+
*
|
|
16
|
+
* So a double click, a lost response, two tabs, a crash between launch and record, and a crash between create and
|
|
17
|
+
* draft launch all end with one document and one run. A launch that fails leaves the attempt recorded with no run:
|
|
18
|
+
* the card shows "Interrupted · Go again", which resumes the same identity.
|
|
19
|
+
*/
|
|
20
|
+
import { parseArtifactRef, UNFILED_MOUNT } from '../api/chat-context.js';
|
|
21
|
+
import { foldProposals } from '../api/chat-proposals.js';
|
|
22
|
+
import { DEFAULT_PROJECT_ID } from '../projects/default-project.js';
|
|
23
|
+
import { realpathSync } from 'node:fs';
|
|
24
|
+
import { readBeneath } from '../api/beneath.js';
|
|
25
|
+
import { readDocHead } from './chat-events.js';
|
|
26
|
+
import { buildSourcePacket } from './source-packet.js';
|
|
27
|
+
export class CreateLauncher {
|
|
28
|
+
deps;
|
|
29
|
+
constructor(deps) {
|
|
30
|
+
this.deps = deps;
|
|
31
|
+
}
|
|
32
|
+
async find(identity) {
|
|
33
|
+
return this.deps.runExists(identity.runId);
|
|
34
|
+
}
|
|
35
|
+
/** Busy until the attempt's outcome is recorded (§6.2), once its run exists. A launch that never produced a run is
|
|
36
|
+
* not busy: Go again resumes it. */
|
|
37
|
+
async live(runId) {
|
|
38
|
+
const hit = this.deps.bindings.attemptOf(runId);
|
|
39
|
+
if (hit === null || hit.attempt.outcome !== undefined)
|
|
40
|
+
return false;
|
|
41
|
+
return hit.attempt.launchedAt !== undefined || (await this.deps.runExists(runId));
|
|
42
|
+
}
|
|
43
|
+
/** A document with an attempt still without an outcome, whose run exists. */
|
|
44
|
+
async docBusy(artifactRef) {
|
|
45
|
+
const a = this.deps.bindings.busy(artifactRef);
|
|
46
|
+
return a !== null && (a.launchedAt !== undefined || (await this.deps.runExists(a.runId)));
|
|
47
|
+
}
|
|
48
|
+
async launch(d) {
|
|
49
|
+
const launchBound = this.deps.launchBound;
|
|
50
|
+
if (launchBound === null)
|
|
51
|
+
throw new Error('documents cannot be drafted on this daemon (its draft seam is not armed)');
|
|
52
|
+
const ref = d.identity.artifactRef === null ? null : parseArtifactRef(d.identity.artifactRef);
|
|
53
|
+
if (ref === null)
|
|
54
|
+
throw new Error('the proposal names no document');
|
|
55
|
+
const res = d.resolution;
|
|
56
|
+
const projectId = ref.mount === UNFILED_MOUNT ? null : ref.mount;
|
|
57
|
+
const root = await this.deps.docsRoot(ref.projectId);
|
|
58
|
+
if (root === null)
|
|
59
|
+
throw new Error(`${projectId === null ? 'Unfiled' : `project ${projectId}`} is no longer on this daemon`);
|
|
60
|
+
// An earlier attempt's folder goes BEFORE the base is read: an announce of it still on the bus can no longer land.
|
|
61
|
+
this.deps.fence?.(ref.doc, (this.deps.bindings.get(ref.ref)?.attempts ?? []).map((a) => a.runId).filter((id) => id !== d.identity.runId));
|
|
62
|
+
const head = readDocHead(root, ref.doc);
|
|
63
|
+
// 1. Recorded before anything is created or launched. A retry keeps the binding's repositories, graph, cutoff, chat
|
|
64
|
+
// instance and the project the chat itself was in (which says whether the packet is re-checked).
|
|
65
|
+
const held = this.deps.bindings.get(ref.ref);
|
|
66
|
+
const repos = held?.repos ?? (await this.boundRepos(res));
|
|
67
|
+
// The stored graph binding. A document moved out of the chat's own scope gets none: a project graph would reach
|
|
68
|
+
// repositories the move cut (§4.2), and only the accepted ones are snapshotted.
|
|
69
|
+
const scopeProject = scopeProjectOf(this.deps.records(d.chatId), res);
|
|
70
|
+
// ...and none when the person changed the repositories either (cleared or narrowed): the graph would reach past them.
|
|
71
|
+
const accepted = foldProposals(this.deps.records(d.chatId)).get(d.pid)?.accepting?.edits ?? null;
|
|
72
|
+
const reposEdited = accepted !== null && (accepted.repos !== undefined || accepted.project !== undefined);
|
|
73
|
+
const graphDb = held !== null ? held.graphDb : scopeProject !== projectId || reposEdited || (res.repoRefs ?? []).length === 0 ? null : await this.deps.graphFor(projectId, d.chatId);
|
|
74
|
+
const base = head?.head ?? 0;
|
|
75
|
+
const binding = this.deps.bindings.begin({
|
|
76
|
+
ref: ref.ref,
|
|
77
|
+
mount: ref.mount,
|
|
78
|
+
doc: ref.doc,
|
|
79
|
+
projectId,
|
|
80
|
+
owner: d.actor.id,
|
|
81
|
+
chatId: d.chatId,
|
|
82
|
+
chatInstance: this.deps.instanceOf(d.chatId),
|
|
83
|
+
scopeProject,
|
|
84
|
+
proposalId: d.pid,
|
|
85
|
+
cutoffTurnId: res.turnId,
|
|
86
|
+
repos,
|
|
87
|
+
graphDb,
|
|
88
|
+
}, { pid: d.pid, runId: d.identity.runId, base });
|
|
89
|
+
const attempt = binding.attempts.find((a) => a.runId === d.identity.runId);
|
|
90
|
+
const clisJson = res.helpers !== null ? this.deps.clisJsonFor(res.helpers.seats) : null;
|
|
91
|
+
if (clisJson === null)
|
|
92
|
+
throw new Error('a helper on the card can no longer work; choose two helpers and Go again');
|
|
93
|
+
// 2. The document, created only if it is missing.
|
|
94
|
+
if (head === null) {
|
|
95
|
+
const r = await this.deps.createDoc(ref.projectId, {
|
|
96
|
+
name: ref.doc,
|
|
97
|
+
kind: 'source',
|
|
98
|
+
brief: res.brief ?? res.what.title,
|
|
99
|
+
style: this.deps.styleOf(res.what.entry),
|
|
100
|
+
chat_id: d.chatId,
|
|
101
|
+
proposal_id: d.pid,
|
|
102
|
+
...(binding.repos.length > 0 ? { repo_refs: binding.repos.map((r) => r.id) } : {}),
|
|
103
|
+
clisJson,
|
|
104
|
+
channel: 'studio',
|
|
105
|
+
actor: d.actor.id,
|
|
106
|
+
}, d.actor.id);
|
|
107
|
+
const answered = readDocHead(root, ref.doc);
|
|
108
|
+
if ((r.status < 200 || r.status >= 300) && !(r.status === 409 && answered !== null)) {
|
|
109
|
+
const why = r.body?.error;
|
|
110
|
+
throw new Error(`the document could not be created (${r.status}${typeof why === 'string' ? `: ${why}` : ''})`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// The document as it is now, the one just created or adopted (a 409 is someone else's create) alike: a demo or a
|
|
114
|
+
// retired document answers nothing, so a draft for it would never land and its chat would stay busy.
|
|
115
|
+
const refuseUnanswerable = () => {
|
|
116
|
+
if (readDocHead(root, ref.doc)?.kind === 'demo')
|
|
117
|
+
throw new Error(`${ref.ref} is a demo, not a document`);
|
|
118
|
+
if (docRetired(root, ref.doc))
|
|
119
|
+
throw new Error(`${ref.ref} was deleted; ask again in the chat to make a new document`);
|
|
120
|
+
};
|
|
121
|
+
refuseUnanswerable();
|
|
122
|
+
// 3. The packet, then the draft with the derived run id. The chat is read through its own instance: after a reuse of
|
|
123
|
+
// its id it is the archived chat, and when it is gone only what the canonical packet already holds is used.
|
|
124
|
+
const chatNow = this.deps.chatIdOf(binding.chatId, binding.chatInstance);
|
|
125
|
+
const packet = await buildSourcePacket({
|
|
126
|
+
runId: d.identity.runId,
|
|
127
|
+
chatId: binding.chatId,
|
|
128
|
+
pid: d.pid,
|
|
129
|
+
cutoffTurnId: binding.cutoffTurnId,
|
|
130
|
+
resolution: res,
|
|
131
|
+
records: chatNow === null ? [] : this.deps.records(chatNow),
|
|
132
|
+
...(chatNow !== null ? { storageChatId: chatNow } : {}),
|
|
133
|
+
held: { tokens: binding.tokens, bytes: (name) => this.deps.bindings.packetBytes(ref.ref, name) },
|
|
134
|
+
...(binding.scopeProject !== binding.projectId ? { recheckProject: binding.projectId } : {}),
|
|
135
|
+
}, this.deps.packetDeps);
|
|
136
|
+
// Read again after the packet's awaits: a document retired meanwhile is refused here, not drafted (xreview r5).
|
|
137
|
+
refuseUnanswerable();
|
|
138
|
+
this.deps.bindings.addPacket(ref.ref, packet.canonical, packet.tokens);
|
|
139
|
+
this.deps.log?.(`[proposals] ${d.pid}: ${ref.ref} run ${d.identity.runId} — packet ${packet.files.length} file(s)` +
|
|
140
|
+
`${packet.struck.length > 0 ? `, ${packet.struck.length} left out` : ''}`);
|
|
141
|
+
await launchBound({
|
|
142
|
+
documentId: ref.doc,
|
|
143
|
+
...(projectId !== null ? { projectId } : {}),
|
|
144
|
+
brief: res.brief ?? res.what.title,
|
|
145
|
+
style: this.deps.styleOf(res.what.entry),
|
|
146
|
+
runId: d.identity.runId,
|
|
147
|
+
// Filed under the chat as it is kept now (an archive id after a reuse), never the other chat that took the id.
|
|
148
|
+
chatId: chatNow ?? binding.chatId,
|
|
149
|
+
proposalId: d.pid,
|
|
150
|
+
artifactRef: ref.ref,
|
|
151
|
+
repos: binding.repos.map((r) => ({ repoRef: r.id, name: r.name, rootPath: r.rootPath })),
|
|
152
|
+
graphDb: binding.graphDb,
|
|
153
|
+
clisJson,
|
|
154
|
+
packet,
|
|
155
|
+
base: attempt.base,
|
|
156
|
+
actor: d.actor.id,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/** The resolution's repositories with their registered roots (a repository unregistered since is left out, said). */
|
|
160
|
+
async boundRepos(res) {
|
|
161
|
+
const want = res.repoRefs ?? [];
|
|
162
|
+
if (want.length === 0)
|
|
163
|
+
return [];
|
|
164
|
+
const all = await this.deps.repos();
|
|
165
|
+
const out = [];
|
|
166
|
+
for (const id of want) {
|
|
167
|
+
const hit = all.find((r) => r.id === id);
|
|
168
|
+
if (hit === undefined)
|
|
169
|
+
this.deps.log?.(`[proposals] ${res.pid}: repository ${id} is no longer registered — not grounded on it`);
|
|
170
|
+
else
|
|
171
|
+
out.push({ id: hit.id, name: hit.name, rootPath: hit.rootPath });
|
|
172
|
+
}
|
|
173
|
+
return out;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/** The project the chat itself was in when the proposal was made (its first record, before any edit): a resolution
|
|
177
|
+
* re-filed by an edit differs from it, and then the packet is re-checked against the document's project (§4.2). A
|
|
178
|
+
* `null` there is a real answer (a chat in no project), never "unknown". */
|
|
179
|
+
function scopeProjectOf(records, res) {
|
|
180
|
+
const first = records.find((r) => r.kind === 'proposal' && r.proposal.pid === res.pid);
|
|
181
|
+
return first !== undefined ? first.proposal.filedIn.projectId : res.filedIn.projectId;
|
|
182
|
+
}
|
|
183
|
+
/** The route project of a mount (`default` for Unfiled). */
|
|
184
|
+
export function routeProjectOf(mount) {
|
|
185
|
+
return mount === UNFILED_MOUNT ? DEFAULT_PROJECT_ID : mount;
|
|
186
|
+
}
|
|
187
|
+
const TERMINAL_STATUSES = new Set(['completed', 'cancelled', 'failed']);
|
|
188
|
+
/**
|
|
189
|
+
* DES-CHAT-ARTIFACTS-001 §6.2 (A3): at daemon start, BEFORE the generic boot resume (which skips bound runs), every
|
|
190
|
+
* proposal-bound attempt without a recorded outcome is settled. An `accepting` proposal whose run exists is decided, and
|
|
191
|
+
* the run's launch facts are recorded again if a crash lost them. An attempt crew had announced landed when the
|
|
192
|
+
* document's manifest names its run (the I1 contract); before that contract, when the head moved past its base (the
|
|
193
|
+
* best evidence there is, said in the log). Every other attempt with a run lost its seam flight in the restart: its
|
|
194
|
+
* engine run is cancelled to a CONFIRMED terminal state, then "interrupted by a restart" is recorded, and only then are
|
|
195
|
+
* the chat and the document released and Try again offered, so an old attempt never runs beside a new one (a retry
|
|
196
|
+
* also removes the old attempt's folder, so an announce of it still on the bus cannot land). Never a redispatch. An
|
|
197
|
+
* attempt with no run is left alone: its card's "Go again" resumes the same identity. A failure whose publication a
|
|
198
|
+
* crash cut short is published again.
|
|
199
|
+
*/
|
|
200
|
+
export async function reconcileBoundAttempts(deps) {
|
|
201
|
+
const all = deps.bindings.all();
|
|
202
|
+
for (const b of all) {
|
|
203
|
+
for (const a of b.attempts) {
|
|
204
|
+
deps.linkDocument(a.runId, b.doc);
|
|
205
|
+
if (a.outcome?.kind === 'failed' && (a.published !== true || !deps.hasLandingFailed(a.runId)))
|
|
206
|
+
deps.onOutcome(b.ref, a.runId, a.outcome);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
const pending = all.flatMap((b) => b.attempts.filter((a) => a.outcome === undefined).map((a) => ({ b, a })));
|
|
210
|
+
if (pending.length === 0)
|
|
211
|
+
return;
|
|
212
|
+
const sleep = deps.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
213
|
+
const views = new Map((await deps.sessions()).map((v) => [v.session.id, v]));
|
|
214
|
+
for (const { b, a } of pending) {
|
|
215
|
+
const view = views.get(a.runId);
|
|
216
|
+
if (view === undefined) {
|
|
217
|
+
// Never handed to the engine (a crash before the launch call, or a launch that failed): not busy. Go again
|
|
218
|
+
// resumes the same identity.
|
|
219
|
+
if (a.launchingAt !== undefined)
|
|
220
|
+
deps.bindings.clearLaunching(b.ref, a.runId);
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
deps.ensureLaunchRecord(b, a);
|
|
224
|
+
const chatNow = deps.chatIdOf(b.chatId, b.chatInstance);
|
|
225
|
+
if (chatNow !== null)
|
|
226
|
+
await deps.settleAccepting(chatNow, a.pid).catch(() => false);
|
|
227
|
+
if (a.emittedAt !== undefined) {
|
|
228
|
+
const v = deps.docVersions(b.projectId, b.doc);
|
|
229
|
+
const landedAt = v === null ? undefined : v.provenance ? v.byRun.get(a.runId) : v.head > a.base ? v.head : undefined;
|
|
230
|
+
if (landedAt !== undefined) {
|
|
231
|
+
if (v !== null && !v.provenance)
|
|
232
|
+
deps.log(`[proposals] boot: ${b.ref} run ${a.runId}: v${landedAt} is past the attempt's base; this interactive records no run per version, so that is taken as its landing`);
|
|
233
|
+
const landed = { kind: 'landed', version: landedAt };
|
|
234
|
+
if (deps.bindings.setOutcome(b.ref, a.runId, landed))
|
|
235
|
+
deps.onOutcome(b.ref, a.runId, landed);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
let status = String(view.session.status);
|
|
240
|
+
if (!TERMINAL_STATUSES.has(status)) {
|
|
241
|
+
try {
|
|
242
|
+
await deps.cancelRun(a.runId);
|
|
243
|
+
}
|
|
244
|
+
catch (err) {
|
|
245
|
+
deps.log(`[proposals] boot: could not stop run ${a.runId} of ${b.ref}: ${err instanceof Error ? err.message : String(err)}`);
|
|
246
|
+
}
|
|
247
|
+
const deadline = Date.now() + (deps.waitMs ?? 30_000);
|
|
248
|
+
for (;;) {
|
|
249
|
+
status = String((await deps.sessions()).find((v) => v.session.id === a.runId)?.session.status ?? status);
|
|
250
|
+
if (TERMINAL_STATUSES.has(status) || Date.now() >= deadline)
|
|
251
|
+
break;
|
|
252
|
+
await sleep(500);
|
|
253
|
+
}
|
|
254
|
+
if (!TERMINAL_STATUSES.has(status)) {
|
|
255
|
+
// Its terminal frame settles it later (the draft seam records the interruption for a run it holds no flight for).
|
|
256
|
+
deps.log(`[proposals] boot: run ${a.runId} of ${b.ref} is still ${status}; the document stays busy until it ends`);
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const outcome = { kind: 'failed', reason: 'interrupted by a restart' };
|
|
261
|
+
if (deps.bindings.setOutcome(b.ref, a.runId, outcome))
|
|
262
|
+
deps.onOutcome(b.ref, a.runId, outcome);
|
|
263
|
+
deps.log(`[proposals] boot: ${b.ref} run ${a.runId} was interrupted by the restart (engine ${status}); released, Try again offered`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* A document's head and which run made each version, read from its `versions.json` beneath the docs root (no link
|
|
268
|
+
* followed). `provenance` is whether the manifest records runs at all (interactive's I1 contract writes `run_id` on
|
|
269
|
+
* every new entry; an older interactive writes none). `null` when the manifest cannot be read.
|
|
270
|
+
*/
|
|
271
|
+
/**
|
|
272
|
+
* The chat a recovered attempt is filed under: the binding's own chat instance where it is kept now (its archive id after
|
|
273
|
+
* a reuse); none when that instance is gone, never the bare id a later chat may have taken since (xreview r5). A chat
|
|
274
|
+
* that had no instance when Go was pressed can only be named by its id.
|
|
275
|
+
*/
|
|
276
|
+
export function recoveredChatId(history, b) {
|
|
277
|
+
return b.chatInstance === null ? b.chatId : history.idOfInstance(b.chatId, b.chatInstance);
|
|
278
|
+
}
|
|
279
|
+
/** The `run.launched` detail boot writes for a recovered attempt whose launch record is missing: the chat, proposal,
|
|
280
|
+
* artifact and document from the binding, as the draft seam would have, under the chat as it is kept now. */
|
|
281
|
+
export function recoveredLaunchDetail(history, b, a) {
|
|
282
|
+
const chatNow = recoveredChatId(history, b);
|
|
283
|
+
return { deliver: 'none', channel: 'studio', actor: b.owner, ...(chatNow !== null ? { chatId: chatNow } : {}), proposalId: a.pid, artifactRef: b.ref, recoveredAtBoot: true };
|
|
284
|
+
}
|
|
285
|
+
export function docVersionsOf(docsRoot, doc) {
|
|
286
|
+
if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(doc))
|
|
287
|
+
return null;
|
|
288
|
+
try {
|
|
289
|
+
const root = realpathSync(docsRoot);
|
|
290
|
+
const m = JSON.parse(readBeneath(root, `${doc}/versions.json`, 2 * 1024 * 1024).data.toString('utf8'));
|
|
291
|
+
if (typeof m.head !== 'number' || !Number.isInteger(m.head) || m.head < 0)
|
|
292
|
+
return null;
|
|
293
|
+
const byRun = new Map();
|
|
294
|
+
let provenance = false;
|
|
295
|
+
for (const e of Array.isArray(m.versions) ? m.versions : []) {
|
|
296
|
+
if (e === null || typeof e !== 'object' || !('run_id' in e))
|
|
297
|
+
continue;
|
|
298
|
+
provenance = true;
|
|
299
|
+
if (typeof e['run_id'] === 'string' && typeof e['version'] === 'number')
|
|
300
|
+
byRun.set(e['run_id'], e['version']);
|
|
301
|
+
}
|
|
302
|
+
return { head: m.head, byRun, provenance };
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
/** Whether interactive retired (tombstoned) the document: its manifest carries `retired_at`. */
|
|
309
|
+
function docRetired(docsRoot, doc) {
|
|
310
|
+
try {
|
|
311
|
+
const m = JSON.parse(readBeneath(realpathSync(docsRoot), `${doc}/versions.json`, 2 * 1024 * 1024).data.toString('utf8'));
|
|
312
|
+
return typeof m.retired_at === 'string' && m.retired_at !== '';
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
//# sourceMappingURL=proposal-create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proposal-create.js","sourceRoot":"","sources":["../../src/interactive/proposal-create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAkD,MAAM,0BAA0B,CAAC;AACzG,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,iBAAiB,EAAmB,MAAM,oBAAoB,CAAC;AAiCxE,MAAM,OAAO,cAAc;IACI;IAA7B,YAA6B,IAAwB;QAAxB,SAAI,GAAJ,IAAI,CAAoB;IAAG,CAAC;IAEzD,KAAK,CAAC,IAAI,CAAC,QAA0B;QACnC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED;yCACqC;IACrC,KAAK,CAAC,IAAI,CAAC,KAAa;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAChD,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QACpE,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,IAAI,CAAC,MAAM,IAAI,CAA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AC,KAAK,QAAQ;gBAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;QAChH,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,gGAAgG;AAChG,SAAS,UAAU,CAAC,QAAgB,EAAE,GAAW;IAC/C,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,GAAG,GAAG,gBAAgB,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAA6B,CAAC;QACrJ,OAAO,OAAO,CAAC,CAAC,UAAU,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,KAAK,EAAE,CAAC;IACjE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -32,8 +32,9 @@
|
|
|
32
32
|
* `versions.json` under this project's docs root, for the draft/demo seams (`doc-grounding.ts`).
|
|
33
33
|
* The create response is small JSON, so it is buffered — SSE never rides this route.
|
|
34
34
|
*/
|
|
35
|
-
import type { FastifyInstance } from 'fastify';
|
|
35
|
+
import type { FastifyInstance, FastifyRequest } from 'fastify';
|
|
36
36
|
import type { InteractiveDocCreateRequest } from 'wicked-crew-api-types';
|
|
37
|
+
import { type IncomingHttpHeaders } from 'node:http';
|
|
37
38
|
import type { CoreAdapter } from '../core/adapter.js';
|
|
38
39
|
import type { ProjectSettingsStore } from '../projects/settings.js';
|
|
39
40
|
import { InteractiveBridgePool, type LiveBridge } from './bridge-pool.js';
|
|
@@ -65,8 +66,26 @@ export interface InteractiveProxyDeps {
|
|
|
65
66
|
/** The current council roster — when supplied, a doc/demo create body with a `clisJson` that
|
|
66
67
|
* names a seat not in the roster is refused 400 before the bridge sees the request (#631). */
|
|
67
68
|
roster?: () => unknown[];
|
|
69
|
+
/** DES-CHAT-ARTIFACTS-001 §5.2 (A3): the accepted proposal a create's `chat_id` + `proposal_id` names, for this actor.
|
|
70
|
+
* Absent = every `chat_id` / `proposal_id` is refused. */
|
|
71
|
+
proposalGrant?: (chatId: string, proposalId: string, actorId: string) => ProposalGrant | null;
|
|
72
|
+
/** The caller's actor id (the route's `actorOf`); absent = the local person. */
|
|
73
|
+
actorOf?: (req: FastifyRequest) => string;
|
|
68
74
|
log?: (msg: string) => void;
|
|
69
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* What an accepted proposal lets ONE create do (A3): make the document its identity derived (`doc`, in the mount whose
|
|
78
|
+
* route project is `projectId`), grounded on the repositories its stored resolution lists, filed or Unfiled.
|
|
79
|
+
*/
|
|
80
|
+
export interface ProposalGrant {
|
|
81
|
+
doc: string;
|
|
82
|
+
/** The route's project id (`default` for Unfiled). */
|
|
83
|
+
projectId: string;
|
|
84
|
+
repos: ReadonlyArray<{
|
|
85
|
+
id: string;
|
|
86
|
+
name: string;
|
|
87
|
+
}>;
|
|
88
|
+
}
|
|
70
89
|
/** The create body as `prepareDocCreate` reads it — the published `InteractiveDocCreateRequest`
|
|
71
90
|
* (wire-contract.test.ts pins the two against each other). */
|
|
72
91
|
export type DocCreateBody = InteractiveDocCreateRequest;
|
|
@@ -74,7 +93,7 @@ export type DocCreateBody = InteractiveDocCreateRequest;
|
|
|
74
93
|
* wire: crew-api-types `InteractiveDocCreateRefusal`. */
|
|
75
94
|
export interface DocCreateRefusal {
|
|
76
95
|
error: string;
|
|
77
|
-
code: 'repo_not_in_project' | 'unfiled_doc_repo' | 'invalid_repo_ref' | 'ambiguous_repo_ref' | 'project_mismatch';
|
|
96
|
+
code: 'repo_not_in_project' | 'unfiled_doc_repo' | 'invalid_repo_ref' | 'ambiguous_repo_ref' | 'project_mismatch' | 'proposal_grant_refused';
|
|
78
97
|
requested: string[];
|
|
79
98
|
missing?: string[];
|
|
80
99
|
/** `ambiguous_repo_ref`: the refs that name several repos, each with its candidates. */
|
|
@@ -121,6 +140,11 @@ export interface PreparedCreate {
|
|
|
121
140
|
channel?: 'studio' | 'cli' | 'api' | undefined;
|
|
122
141
|
actor?: string | undefined;
|
|
123
142
|
};
|
|
143
|
+
/** A3: the accepted proposal this create answers (checked through its record); never forwarded to the bridge. */
|
|
144
|
+
proposal?: {
|
|
145
|
+
chatId: string;
|
|
146
|
+
proposalId: string;
|
|
147
|
+
};
|
|
124
148
|
refusal?: DocCreateRefusal;
|
|
125
149
|
}
|
|
126
150
|
/** `true` for the bridge's doc-create request (method + exact path, query ignored). */
|
|
@@ -168,8 +192,41 @@ export declare function askOf(raw: Buffer): {
|
|
|
168
192
|
* see, and say what to record once the bridge names the doc. Pure over its inputs — the route
|
|
169
193
|
* decides what to do with a refusal; exported so the rule is unit-testable without a bridge.
|
|
170
194
|
*/
|
|
171
|
-
export declare function prepareDocCreate(raw: Buffer, contentType: string | undefined, adapter: CoreAdapter, projectId: string, log?: (msg: string) => void
|
|
195
|
+
export declare function prepareDocCreate(raw: Buffer, contentType: string | undefined, adapter: CoreAdapter, projectId: string, log?: (msg: string) => void,
|
|
196
|
+
/** A3: the accepted proposal a `chat_id` + `proposal_id` names, for the caller. Absent = refuse them. */
|
|
197
|
+
grantFor?: (chatId: string, proposalId: string) => ProposalGrant | null): Promise<PreparedCreate>;
|
|
198
|
+
/**
|
|
199
|
+
* Whether this request loads a document into a frame for a page of another site. Studio's own frames are same-origin;
|
|
200
|
+
* an editor plugin's frame is sandboxed with an opaque origin, so a navigation it starts is always `cross-site`. A
|
|
201
|
+
* document served here runs with its own policy, not an editor bundle's WebRTC guard (`editors/webrtc-guard.ts`), and
|
|
202
|
+
* studio's shell lets any of its frames point here, so an editor frame could otherwise navigate itself to a document
|
|
203
|
+
* and run that document's scripts in a fresh realm. A browser sends `Sec-Fetch-*` only to a trustworthy origin
|
|
204
|
+
* (localhost, https); without them the request is let through.
|
|
205
|
+
*/
|
|
206
|
+
export declare function isCrossSiteFrameLoad(headers: IncomingHttpHeaders): boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Whether a cross-site frame load comes from a page the daemon lets frame it: its clickjacking guard
|
|
209
|
+
* (`api/frame-guard.ts`) has already written `frame-ancestors` (studio's dev server and the operator's allowed origins)
|
|
210
|
+
* on this response. The page's own `Referer` names it; an editor frame sends none, or (if it asks for one) its own URL
|
|
211
|
+
* on the daemon's origin, which never counts.
|
|
212
|
+
*/
|
|
213
|
+
export declare function fromFramingPage(referer: string | string[] | undefined, frameGuard: unknown, ownOrigin: string, forwardedHosts?: readonly string[]): boolean;
|
|
214
|
+
/** The hosts a reverse proxy names for the original request: `X-Forwarded-Host` (each, comma-separated) and every
|
|
215
|
+
* `host=` of `Forwarded`. Only ever used to refuse more. */
|
|
216
|
+
export declare function forwardedHosts(headers: IncomingHttpHeaders): string[];
|
|
217
|
+
/** The words a refused frame shows. */
|
|
218
|
+
export declare const CROSS_SITE_FRAME_REFUSED = "This document opens only in studio, not from inside another page or an editor plugin.";
|
|
172
219
|
export declare function registerInteractiveProxy(app: FastifyInstance, adapter: CoreAdapter, deps: InteractiveProxyDeps): void;
|
|
220
|
+
/**
|
|
221
|
+
* DES-CHAT-ARTIFACTS-001 §4.3 (A3): crew's OWN create of a proposal's document, in process. It runs the same
|
|
222
|
+
* `prepareDocCreate` the proxy route runs (so the `chat_id` grant is checked through the accepted record exactly as for
|
|
223
|
+
* any caller), then posts the prepared body to the project's bridge and records the grounding sidecar. Never replayed:
|
|
224
|
+
* a connection lost after the body was sent answers 502 `create_undetermined`, and the caller looks the document up.
|
|
225
|
+
*/
|
|
226
|
+
export declare function createDocInProcess(adapter: CoreAdapter, deps: Pick<InteractiveProxyDeps, 'settings' | 'pool' | 'grounding' | 'roster' | 'proposalGrant' | 'stateHome' | 'home' | 'env' | 'log'>, projectId: string, body: Record<string, unknown>, actorId: string): Promise<{
|
|
227
|
+
status: number;
|
|
228
|
+
body: unknown;
|
|
229
|
+
}>;
|
|
173
230
|
/**
|
|
174
231
|
* Errors that mean "the upstream tore down its side after the CLIENT already left" — normal
|
|
175
232
|
* teardown noise when a browser tab closes mid-stream. Only used when `clientGone` is already
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy-routes.d.ts","sourceRoot":"","sources":["../../src/interactive/proxy-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"proxy-routes.d.ts","sourceRoot":"","sources":["../../src/interactive/proxy-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAgB,cAAc,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAA0B,KAAK,mBAAmB,EAAwB,MAAM,WAAW,CAAC;AAInG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAA0B,qBAAqB,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAOL,KAAK,iBAAiB,EACvB,MAAM,oBAAoB,CAAC;AAK5B,mGAAmG;AACnG,eAAO,MAAM,eAAe,cAAc,CAAC;AAC3C,uGAAuG;AACvG,eAAO,MAAM,mBAAmB,QAAkB,CAAC;AAEnD,iFAAiF;AACjF,eAAO,MAAM,6BAA6B,gKACgH,CAAC;AA4C3J;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAA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