@ngockhoale/ckit 0.0.0-stage → 0.1.1
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/.env.example +21 -0
- package/README.md +70 -2
- package/dist/src/adapters/agent/claude/errors.d.ts +13 -0
- package/dist/src/adapters/agent/claude/errors.js +16 -0
- package/dist/src/adapters/agent/claude/normalize.d.ts +11 -0
- package/dist/src/adapters/agent/claude/normalize.js +83 -0
- package/dist/src/adapters/agent/errors.d.ts +13 -0
- package/dist/src/adapters/agent/errors.js +19 -0
- package/dist/src/adapters/agent/fixtures/claude-transcript.d.ts +70 -0
- package/dist/src/adapters/agent/fixtures/claude-transcript.js +15 -0
- package/dist/src/adapters/agent/fixtures/omp-transcript.d.ts +60 -0
- package/dist/src/adapters/agent/fixtures/omp-transcript.js +14 -0
- package/dist/src/adapters/agent/normalize.d.ts +18 -0
- package/dist/src/adapters/agent/normalize.js +77 -0
- package/dist/src/adapters/agent/transport.d.ts +35 -0
- package/dist/src/adapters/agent/transport.js +39 -0
- package/dist/src/adapters/agent/worker-service.d.ts +49 -0
- package/dist/src/adapters/agent/worker-service.js +77 -0
- package/dist/src/adapters/fake/fake-advisor.d.ts +15 -0
- package/dist/src/adapters/fake/fake-advisor.js +29 -0
- package/dist/src/adapters/fake/fake-agent.d.ts +12 -0
- package/dist/src/adapters/fake/fake-agent.js +21 -0
- package/dist/src/adapters/fake/fake-store.d.ts +13 -0
- package/dist/src/adapters/fake/fake-store.js +23 -0
- package/dist/src/adapters/fake/fake-web.d.ts +12 -0
- package/dist/src/adapters/fake/fake-web.js +21 -0
- package/dist/src/adapters/fake/fault-injector.d.ts +18 -0
- package/dist/src/adapters/fake/fault-injector.js +64 -0
- package/dist/src/adapters/fake/virtual-clock.d.ts +12 -0
- package/dist/src/adapters/fake/virtual-clock.js +35 -0
- package/dist/src/adapters/launch/discover.d.ts +18 -0
- package/dist/src/adapters/launch/discover.js +55 -0
- package/dist/src/adapters/launch/executor.d.ts +117 -0
- package/dist/src/adapters/launch/executor.js +383 -0
- package/dist/src/adapters/launch/profile.d.ts +35 -0
- package/dist/src/adapters/launch/profile.js +73 -0
- package/dist/src/adapters/launch/spawn.d.ts +29 -0
- package/dist/src/adapters/launch/spawn.js +18 -0
- package/dist/src/adapters/openai/openai-advisor.d.ts +56 -0
- package/dist/src/adapters/openai/openai-advisor.js +146 -0
- package/dist/src/cli/ckit.d.ts +5 -0
- package/dist/src/cli/ckit.js +384 -0
- package/dist/src/cli/demo.d.ts +1 -0
- package/dist/src/cli/demo.js +30 -0
- package/dist/src/cli/lifecycle.d.ts +19 -0
- package/dist/src/cli/lifecycle.js +90 -0
- package/dist/src/cli/sessions.d.ts +10 -0
- package/dist/src/cli/sessions.js +381 -0
- package/dist/src/cli/setup.d.ts +11 -0
- package/dist/src/cli/setup.js +115 -0
- package/dist/src/committee/decision.d.ts +84 -0
- package/dist/src/committee/decision.js +167 -0
- package/dist/src/committee/handover.d.ts +115 -0
- package/dist/src/committee/handover.js +191 -0
- package/dist/src/committee/no-progress.d.ts +44 -0
- package/dist/src/committee/no-progress.js +64 -0
- package/dist/src/committee/primary-registry.d.ts +15 -0
- package/dist/src/committee/primary-registry.js +60 -0
- package/dist/src/committee/reply-parser.d.ts +28 -0
- package/dist/src/committee/reply-parser.js +53 -0
- package/dist/src/committee/reviewer-scheduler.d.ts +101 -0
- package/dist/src/committee/reviewer-scheduler.js +163 -0
- package/dist/src/committee/role-epoch.d.ts +91 -0
- package/dist/src/committee/role-epoch.js +154 -0
- package/dist/src/core/control.d.ts +18 -0
- package/dist/src/core/control.js +29 -0
- package/dist/src/core/entities.d.ts +166 -0
- package/dist/src/core/entities.js +119 -0
- package/dist/src/core/errors.d.ts +9 -0
- package/dist/src/core/errors.js +17 -0
- package/dist/src/core/events.d.ts +72 -0
- package/dist/src/core/events.js +125 -0
- package/dist/src/core/ids.d.ts +47 -0
- package/dist/src/core/ids.js +32 -0
- package/dist/src/core/machine.d.ts +55 -0
- package/dist/src/core/machine.js +110 -0
- package/dist/src/core/policy.d.ts +34 -0
- package/dist/src/core/policy.js +59 -0
- package/dist/src/core/provenance.d.ts +20 -0
- package/dist/src/core/provenance.js +21 -0
- package/dist/src/core/record.d.ts +35 -0
- package/dist/src/core/record.js +67 -0
- package/dist/src/core/replay.d.ts +10 -0
- package/dist/src/core/replay.js +36 -0
- package/dist/src/core/run-task.d.ts +20 -0
- package/dist/src/core/run-task.js +48 -0
- package/dist/src/diagnostics/doctor.d.ts +78 -0
- package/dist/src/diagnostics/doctor.js +365 -0
- package/dist/src/diagnostics/journal-lock.d.ts +38 -0
- package/dist/src/diagnostics/journal-lock.js +181 -0
- package/dist/src/evidence/linker.d.ts +44 -0
- package/dist/src/evidence/linker.js +75 -0
- package/dist/src/evidence/report-parser.d.ts +27 -0
- package/dist/src/evidence/report-parser.js +17 -0
- package/dist/src/evidence/store.d.ts +36 -0
- package/dist/src/evidence/store.js +57 -0
- package/dist/src/gui/server.d.ts +27 -0
- package/dist/src/gui/server.js +497 -0
- package/dist/src/host/checkpoint.d.ts +22 -0
- package/dist/src/host/checkpoint.js +74 -0
- package/dist/src/host/export.d.ts +52 -0
- package/dist/src/host/export.js +45 -0
- package/dist/src/host/ipc.d.ts +57 -0
- package/dist/src/host/ipc.js +124 -0
- package/dist/src/host/leases.d.ts +27 -0
- package/dist/src/host/leases.js +40 -0
- package/dist/src/host/retention.d.ts +47 -0
- package/dist/src/host/retention.js +130 -0
- package/dist/src/host/supervisor.d.ts +59 -0
- package/dist/src/host/supervisor.js +64 -0
- package/dist/src/intake/owner-intake.d.ts +31 -0
- package/dist/src/intake/owner-intake.js +97 -0
- package/dist/src/intake/types.d.ts +46 -0
- package/dist/src/intake/types.js +2 -0
- package/dist/src/intent/context-packet.d.ts +68 -0
- package/dist/src/intent/context-packet.js +76 -0
- package/dist/src/intent/idea-ledger.d.ts +50 -0
- package/dist/src/intent/idea-ledger.js +136 -0
- package/dist/src/intent/ledger.d.ts +35 -0
- package/dist/src/intent/ledger.js +40 -0
- package/dist/src/intent/registry.d.ts +51 -0
- package/dist/src/intent/registry.js +44 -0
- package/dist/src/intent/revision.d.ts +37 -0
- package/dist/src/intent/revision.js +48 -0
- package/dist/src/orchestration/dispatcher.d.ts +32 -0
- package/dist/src/orchestration/dispatcher.js +136 -0
- package/dist/src/orchestration/milestone-loop.d.ts +149 -0
- package/dist/src/orchestration/milestone-loop.js +132 -0
- package/dist/src/orchestration/recovery-coordinator.d.ts +74 -0
- package/dist/src/orchestration/recovery-coordinator.js +180 -0
- package/dist/src/orchestration/work-order-contract.d.ts +44 -0
- package/dist/src/orchestration/work-order-contract.js +85 -0
- package/dist/src/orchestration/work-queue.d.ts +56 -0
- package/dist/src/orchestration/work-queue.js +95 -0
- package/dist/src/ports/advisor.d.ts +33 -0
- package/dist/src/ports/advisor.js +2 -0
- package/dist/src/ports/agent.d.ts +31 -0
- package/dist/src/ports/agent.js +2 -0
- package/dist/src/ports/capabilities.d.ts +3 -0
- package/dist/src/ports/capabilities.js +5 -0
- package/dist/src/ports/clock.d.ts +5 -0
- package/dist/src/ports/clock.js +5 -0
- package/dist/src/ports/store.d.ts +13 -0
- package/dist/src/ports/store.js +2 -0
- package/dist/src/ports/web.d.ts +29 -0
- package/dist/src/ports/web.js +2 -0
- package/dist/src/run/api-run.d.ts +49 -0
- package/dist/src/run/api-run.js +173 -0
- package/dist/src/run/plan-run.d.ts +22 -0
- package/dist/src/run/plan-run.js +233 -0
- package/dist/src/run/plan.d.ts +36 -0
- package/dist/src/run/plan.js +119 -0
- package/dist/src/run/verify.d.ts +25 -0
- package/dist/src/run/verify.js +81 -0
- package/dist/src/security/redact.d.ts +7 -0
- package/dist/src/security/redact.js +21 -0
- package/dist/src/settings/env-config.d.ts +64 -0
- package/dist/src/settings/env-config.js +232 -0
- package/dist/src/storage/artifacts.d.ts +30 -0
- package/dist/src/storage/artifacts.js +105 -0
- package/dist/src/storage/audit.d.ts +6 -0
- package/dist/src/storage/audit.js +6 -0
- package/dist/src/storage/db.d.ts +9 -0
- package/dist/src/storage/db.js +43 -0
- package/dist/src/storage/events.d.ts +20 -0
- package/dist/src/storage/events.js +69 -0
- package/dist/src/storage/migrations.d.ts +8 -0
- package/dist/src/storage/migrations.js +48 -0
- package/dist/src/storage/outbox.d.ts +25 -0
- package/dist/src/storage/outbox.js +40 -0
- package/dist/src/storage/projections.d.ts +18 -0
- package/dist/src/storage/projections.js +40 -0
- package/dist/src/storage/reconcile.d.ts +14 -0
- package/dist/src/storage/reconcile.js +93 -0
- package/dist/src/storage/reservations.d.ts +12 -0
- package/dist/src/storage/reservations.js +80 -0
- package/dist/src/storage/store.d.ts +34 -0
- package/dist/src/storage/store.js +105 -0
- package/dist/src/team/attachments.d.ts +22 -0
- package/dist/src/team/attachments.js +211 -0
- package/dist/src/team/cli-models.d.ts +24 -0
- package/dist/src/team/cli-models.js +72 -0
- package/dist/src/team/config.d.ts +20 -0
- package/dist/src/team/config.js +113 -0
- package/dist/src/team/engine.d.ts +28 -0
- package/dist/src/team/engine.js +443 -0
- package/dist/src/team/journal.d.ts +30 -0
- package/dist/src/team/journal.js +70 -0
- package/dist/src/team/runners.d.ts +79 -0
- package/dist/src/team/runners.js +436 -0
- package/dist/src/team/secrets.d.ts +10 -0
- package/dist/src/team/secrets.js +68 -0
- package/dist/src/team/types.d.ts +157 -0
- package/dist/src/team/types.js +5 -0
- package/dist/src/tui/app.d.ts +29 -0
- package/dist/src/tui/app.js +96 -0
- package/dist/src/tui/control-model.d.ts +101 -0
- package/dist/src/tui/control-model.js +109 -0
- package/dist/src/tui/control-screens.d.ts +27 -0
- package/dist/src/tui/control-screens.js +85 -0
- package/dist/src/tui/graph-model.d.ts +34 -0
- package/dist/src/tui/graph-model.js +29 -0
- package/dist/src/tui/graph-screens.d.ts +13 -0
- package/dist/src/tui/graph-screens.js +4 -0
- package/dist/src/tui/inspector-model.d.ts +150 -0
- package/dist/src/tui/inspector-model.js +15 -0
- package/dist/src/tui/inspector-screens.d.ts +14 -0
- package/dist/src/tui/inspector-screens.js +61 -0
- package/dist/src/tui/live.d.ts +16 -0
- package/dist/src/tui/live.js +39 -0
- package/dist/src/tui/mission-action-screens.d.ts +15 -0
- package/dist/src/tui/mission-action-screens.js +105 -0
- package/dist/src/tui/mission-actions.d.ts +46 -0
- package/dist/src/tui/mission-actions.js +53 -0
- package/dist/src/tui/mission-model.d.ts +120 -0
- package/dist/src/tui/mission-model.js +164 -0
- package/dist/src/tui/mission-nav.d.ts +82 -0
- package/dist/src/tui/mission-nav.js +131 -0
- package/dist/src/tui/mission-plan-screens.d.ts +11 -0
- package/dist/src/tui/mission-plan-screens.js +40 -0
- package/dist/src/tui/mission-plan.d.ts +45 -0
- package/dist/src/tui/mission-plan.js +166 -0
- package/dist/src/tui/mission-screens.d.ts +7 -0
- package/dist/src/tui/mission-screens.js +263 -0
- package/dist/src/tui/provenance-label.d.ts +11 -0
- package/dist/src/tui/provenance-label.js +16 -0
- package/dist/src/tui/screens.d.ts +10 -0
- package/dist/src/tui/screens.js +34 -0
- package/dist/src/tui/session-outcome.d.ts +14 -0
- package/dist/src/tui/session-outcome.js +57 -0
- package/dist/src/tui/setup-model.d.ts +159 -0
- package/dist/src/tui/setup-model.js +234 -0
- package/dist/src/tui/setup-screens.d.ts +66 -0
- package/dist/src/tui/setup-screens.js +72 -0
- package/dist/src/tui/team/app.d.ts +24 -0
- package/dist/src/tui/team/app.js +228 -0
- package/dist/src/tui/team/demo-handle.d.ts +22 -0
- package/dist/src/tui/team/demo-handle.js +42 -0
- package/dist/src/tui/team/model.d.ts +81 -0
- package/dist/src/tui/team/model.js +133 -0
- package/gui/app.css +177 -0
- package/gui/app.js +677 -0
- package/gui/index.html +51 -0
- package/gui/network.js +413 -0
- package/package.json +44 -4
- package/src/storage/schema.sql +42 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { Envelope } from '../core/events.js';
|
|
3
|
+
import { type ProvenanceLabel } from './provenance-label.js';
|
|
4
|
+
export type MissionKind = 'message' | 'tool' | 'system';
|
|
5
|
+
export type DeliveryFacet = 'dispatched' | 'adapter-acknowledged' | 'replied' | 'failed' | 'unknown_delivery';
|
|
6
|
+
export type Availability<T> = {
|
|
7
|
+
status: 'available';
|
|
8
|
+
value: T;
|
|
9
|
+
source: string;
|
|
10
|
+
} | {
|
|
11
|
+
status: 'unavailable';
|
|
12
|
+
reason: string;
|
|
13
|
+
ref?: string;
|
|
14
|
+
};
|
|
15
|
+
export interface MissionAgent {
|
|
16
|
+
id: string;
|
|
17
|
+
kind: 'owner' | 'advisor' | 'worker' | 'system' | 'observed';
|
|
18
|
+
sessionId: string;
|
|
19
|
+
identity: Availability<string>;
|
|
20
|
+
parentId: string | null;
|
|
21
|
+
conversation: Availability<readonly string[]>;
|
|
22
|
+
}
|
|
23
|
+
export interface MissionFacet {
|
|
24
|
+
facet: DeliveryFacet;
|
|
25
|
+
sourceEventId: string;
|
|
26
|
+
reason?: string;
|
|
27
|
+
source?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface MissionEntry {
|
|
30
|
+
id: string;
|
|
31
|
+
kind: MissionKind;
|
|
32
|
+
sessionId: string;
|
|
33
|
+
taskId: string;
|
|
34
|
+
threadId: string;
|
|
35
|
+
sender: string | null;
|
|
36
|
+
recipients: readonly string[];
|
|
37
|
+
content: Availability<string>;
|
|
38
|
+
facets: readonly MissionFacet[];
|
|
39
|
+
parent: {
|
|
40
|
+
state: 'none' | 'pending' | 'resolved';
|
|
41
|
+
parentEventId: string | null;
|
|
42
|
+
};
|
|
43
|
+
provenance: ProvenanceLabel;
|
|
44
|
+
seq: number;
|
|
45
|
+
}
|
|
46
|
+
export type MissionObservation = {
|
|
47
|
+
kind: 'agent';
|
|
48
|
+
agentId: string;
|
|
49
|
+
sessionId: string;
|
|
50
|
+
role: MissionAgent['kind'];
|
|
51
|
+
parentAgentId: string | null;
|
|
52
|
+
transcript: 'unavailable';
|
|
53
|
+
reason: string;
|
|
54
|
+
source: string;
|
|
55
|
+
} | {
|
|
56
|
+
kind: 'delivery';
|
|
57
|
+
eventId: string;
|
|
58
|
+
facet: 'failed';
|
|
59
|
+
reason: string;
|
|
60
|
+
source: string;
|
|
61
|
+
};
|
|
62
|
+
export interface MissionCommittee {
|
|
63
|
+
reviewersSelected: readonly {
|
|
64
|
+
reviewerId: string;
|
|
65
|
+
evidenceRevision: number;
|
|
66
|
+
sourceEventId: string;
|
|
67
|
+
}[];
|
|
68
|
+
primary: Availability<string>;
|
|
69
|
+
slotAccounting: Availability<string>;
|
|
70
|
+
exhaustion: Availability<'conclude' | 'bounded-investigation' | 'needs_owner'>;
|
|
71
|
+
}
|
|
72
|
+
export interface MissionSessionInfo {
|
|
73
|
+
runId: string | null; /** reasonCode of the session's terminal TaskCompleted, or null while it has none */
|
|
74
|
+
reasonCode: string | null;
|
|
75
|
+
outcome: 'success' | 'failed' | 'unknown' | null;
|
|
76
|
+
}
|
|
77
|
+
export interface MissionView {
|
|
78
|
+
sessions?: ReadonlyMap<string, MissionSessionInfo>;
|
|
79
|
+
agents: readonly MissionAgent[];
|
|
80
|
+
entries: readonly MissionEntry[];
|
|
81
|
+
relations: {
|
|
82
|
+
delegation: readonly [string, string][];
|
|
83
|
+
message: readonly [string, string][];
|
|
84
|
+
task: readonly [string, string][];
|
|
85
|
+
};
|
|
86
|
+
cursors: ReadonlyMap<string, number>;
|
|
87
|
+
committee: MissionCommittee;
|
|
88
|
+
pendingFacets: Record<'queued' | 'sending' | 'generating', Availability<never>>;
|
|
89
|
+
diagnostics: readonly string[];
|
|
90
|
+
}
|
|
91
|
+
export type MissionSelection = {
|
|
92
|
+
kind: 'agent' | 'entry' | 'task';
|
|
93
|
+
id: string;
|
|
94
|
+
} | null;
|
|
95
|
+
export type MissionMode = 'LIVE' | 'REPLAY' | 'DEMO';
|
|
96
|
+
/** Resolved by MissionScreen so the screen and the Actions panel cannot disagree on mode or key ownership. */
|
|
97
|
+
/** Row budget for the inspector tab body; panels read it instead of being type-sniffed and cloned. */
|
|
98
|
+
export declare const InspectorBudgetContext: import("react").Context<number | undefined>;
|
|
99
|
+
export interface MissionActionsContext {
|
|
100
|
+
active: boolean;
|
|
101
|
+
mode: MissionMode;
|
|
102
|
+
view: MissionView;
|
|
103
|
+
}
|
|
104
|
+
export interface MissionViewOptions {
|
|
105
|
+
configSummary?: string;
|
|
106
|
+
resolveContent?: (ref: string) => string | undefined;
|
|
107
|
+
mode?: MissionMode;
|
|
108
|
+
charset?: 'unicode' | 'ascii';
|
|
109
|
+
color?: boolean;
|
|
110
|
+
onInputCapture?: (on: boolean) => void;
|
|
111
|
+
panels?: {
|
|
112
|
+
plan?: (selection: MissionSelection, ctx: MissionActionsContext) => ReactNode;
|
|
113
|
+
actions?: (selection: MissionSelection, ctx: MissionActionsContext) => ReactNode;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export declare function bindingLabel(bindingId: string): string;
|
|
117
|
+
/** Observed delegation: a session whose first event names an event of ANOTHER session as parent was spawned by that event's actor.
|
|
118
|
+
* Only worker/advisor agents the child session's own events name become children; nothing is invented, and an unresolved parent yields no edge. */
|
|
119
|
+
export declare function observationsFromJournal(events: readonly Envelope[]): MissionObservation[];
|
|
120
|
+
export declare function projectMission(events: readonly Envelope[], observations?: readonly MissionObservation[], resolveContent?: (ref: string) => string | undefined): MissionView;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import { provenanceLabel } from './provenance-label.js';
|
|
3
|
+
/** Resolved by MissionScreen so the screen and the Actions panel cannot disagree on mode or key ownership. */
|
|
4
|
+
/** Row budget for the inspector tab body; panels read it instead of being type-sniffed and cloned. */
|
|
5
|
+
export const InspectorBudgetContext = createContext(undefined);
|
|
6
|
+
const V1 = 'v1 envelope';
|
|
7
|
+
const NO_PRIMARY = 'v1 envelope has no Primary/role-epoch event';
|
|
8
|
+
const unavailable = (reason, ref) => ref === undefined ? { status: 'unavailable', reason } : { status: 'unavailable', reason, ref };
|
|
9
|
+
export function bindingLabel(bindingId) { return bindingId.replace(/^binding:[^:]*:/, ''); }
|
|
10
|
+
const binding = (sid, role, adapter) => `binding:${sid}:${role}${adapter ? `:${adapter}` : ''}`;
|
|
11
|
+
/** Observed delegation: a session whose first event names an event of ANOTHER session as parent was spawned by that event's actor.
|
|
12
|
+
* Only worker/advisor agents the child session's own events name become children; nothing is invented, and an unresolved parent yields no edge. */
|
|
13
|
+
export function observationsFromJournal(events) {
|
|
14
|
+
const byId = new Map();
|
|
15
|
+
for (const e of events)
|
|
16
|
+
if (!byId.has(e.eventId))
|
|
17
|
+
byId.set(e.eventId, e);
|
|
18
|
+
const out = [];
|
|
19
|
+
const seenSession = new Set();
|
|
20
|
+
for (const e of [...byId.values()].sort(cmpSeq)) {
|
|
21
|
+
if (seenSession.has(e.sessionId))
|
|
22
|
+
continue;
|
|
23
|
+
seenSession.add(e.sessionId);
|
|
24
|
+
const pid = e.causationId ?? e.parentEventId;
|
|
25
|
+
const parent = pid === null ? undefined : byId.get(pid);
|
|
26
|
+
if (!parent || parent.sessionId === e.sessionId)
|
|
27
|
+
continue;
|
|
28
|
+
const parentAgent = binding(parent.sessionId, parent.actor.role, parent.actor.adapter);
|
|
29
|
+
const kids = new Map();
|
|
30
|
+
for (const c of byId.values()) {
|
|
31
|
+
if (c.sessionId !== e.sessionId)
|
|
32
|
+
continue;
|
|
33
|
+
if (c.actor.role === 'worker' || c.actor.role === 'advisor')
|
|
34
|
+
kids.set(binding(c.sessionId, c.actor.role, c.actor.adapter), c.actor.role);
|
|
35
|
+
if (c.payload.type === 'AdvisorDispatched')
|
|
36
|
+
kids.set(binding(c.sessionId, 'advisor', c.payload.adapter), 'advisor');
|
|
37
|
+
}
|
|
38
|
+
for (const [agentId, role] of kids)
|
|
39
|
+
out.push({ kind: 'agent', agentId, sessionId: e.sessionId, role, parentAgentId: parentAgent, transcript: 'unavailable', reason: `${V1} carries no transcript`, source: `journal: session ${e.sessionId.slice(-8)} spawned by ${parent.eventId}` });
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
const cmp = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
44
|
+
const cmpSeq = (a, b) => cmp(a.sessionId, b.sessionId) || a.sessionSequence - b.sessionSequence || cmp(a.eventId, b.eventId);
|
|
45
|
+
const canon = (v) => Array.isArray(v) ? `[${v.map(canon).join(',')}]` : v !== null && typeof v === 'object' ? `{${Object.keys(v).sort().map(k => `${JSON.stringify(k)}:${canon(v[k])}`).join(',')}}` : JSON.stringify(v) ?? 'null';
|
|
46
|
+
const FACET_OF = { AdvisorDispatched: 'dispatched', AdvisorAcked: 'adapter-acknowledged', AdvisorCompleted: 'replied', AdvisorUnknownOutcome: 'unknown_delivery' };
|
|
47
|
+
export function projectMission(events, observations = [], resolveContent) {
|
|
48
|
+
const diagnostics = new Set();
|
|
49
|
+
const byId = new Map();
|
|
50
|
+
for (const e of events) {
|
|
51
|
+
const prior = byId.get(e.eventId);
|
|
52
|
+
if (!prior)
|
|
53
|
+
byId.set(e.eventId, e);
|
|
54
|
+
else if (canon(prior) !== canon(e))
|
|
55
|
+
diagnostics.add(`conflicting-duplicate:${e.eventId}`);
|
|
56
|
+
}
|
|
57
|
+
const ordered = [...byId.values()].sort(cmpSeq);
|
|
58
|
+
const cursors = new Map();
|
|
59
|
+
for (const e of ordered)
|
|
60
|
+
cursors.set(e.sessionId, Math.max(cursors.get(e.sessionId) ?? 0, e.sessionSequence));
|
|
61
|
+
const parentOf = (e) => e.causationId ?? e.parentEventId;
|
|
62
|
+
// Nearest-dispatch ancestor: v1's linear causation chain cannot tell interleaved same-adapter dispatches apart.
|
|
63
|
+
const dispatchOf = (e) => { const seen = new Set(); let cur = e; while (cur && !seen.has(cur.eventId)) {
|
|
64
|
+
seen.add(cur.eventId);
|
|
65
|
+
if (cur.payload.type === 'AdvisorDispatched')
|
|
66
|
+
return cur;
|
|
67
|
+
const p = parentOf(cur);
|
|
68
|
+
cur = p === null ? undefined : byId.get(p);
|
|
69
|
+
} return null; };
|
|
70
|
+
const agents = new Map();
|
|
71
|
+
const addAgent = (id, kind, sessionId) => { if (!agents.has(id))
|
|
72
|
+
agents.set(id, { id, kind, sessionId, identity: unavailable(`${V1} carries no agent identity`), parentId: null, conversation: unavailable(`${V1} carries no transcript`) }); };
|
|
73
|
+
const entries = new Map();
|
|
74
|
+
const parentState = (e) => { const p = parentOf(e); return p === null ? { state: 'none', parentEventId: null } : { state: byId.has(p) ? 'resolved' : 'pending', parentEventId: p }; };
|
|
75
|
+
const base = (e, kind, content, sender, recipients, facets) => ({ id: e.eventId, kind, sessionId: e.sessionId, taskId: e.taskId, threadId: e.traceId, sender, recipients, content, facets, parent: parentState(e), provenance: provenanceLabel(e.provenance), seq: e.sessionSequence });
|
|
76
|
+
const system = (e, text) => entries.set(e.eventId, base(e, 'system', { status: 'available', value: text, source: V1 }, null, [], []));
|
|
77
|
+
const committee = [];
|
|
78
|
+
for (const e of ordered) {
|
|
79
|
+
const actor = binding(e.sessionId, e.actor.role, e.actor.adapter);
|
|
80
|
+
addAgent(actor, e.actor.role, e.sessionId);
|
|
81
|
+
const p = e.payload;
|
|
82
|
+
if (p.type === 'AdvisorDispatched') {
|
|
83
|
+
const to = binding(e.sessionId, 'advisor', p.adapter);
|
|
84
|
+
addAgent(to, 'advisor', e.sessionId);
|
|
85
|
+
const text = resolveContent?.(p.promptRef);
|
|
86
|
+
entries.set(e.eventId, base(e, 'message', text !== undefined ? { status: 'available', value: text, source: 'artifact' } : unavailable(`${V1} carries no message text`, p.promptRef), actor, [to], [{ facet: 'dispatched', sourceEventId: e.eventId }]));
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const facet = FACET_OF[p.type];
|
|
90
|
+
if (facet) {
|
|
91
|
+
const d = dispatchOf(e);
|
|
92
|
+
const m = d && entries.get(d.eventId);
|
|
93
|
+
const adapter = 'adapter' in p ? p.adapter : e.actor.adapter;
|
|
94
|
+
if (m && d && d.payload.type === 'AdvisorDispatched' && adapter !== undefined && adapter !== d.payload.adapter) {
|
|
95
|
+
diagnostics.add(`adapter-mismatch:${e.eventId}`);
|
|
96
|
+
system(e, `Advisor ${facet} from adapter ${adapter} does not match dispatch`);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (m && m.facets.some(f => f.facet === facet)) {
|
|
100
|
+
diagnostics.add(`duplicate-facet:${e.eventId}`);
|
|
101
|
+
system(e, `Repeated ${facet} for the same dispatch`);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (m && p.type === 'AdvisorCompleted') {
|
|
105
|
+
const reply = resolveContent?.(p.resultRef);
|
|
106
|
+
if (reply !== undefined)
|
|
107
|
+
m.content = { status: 'available', value: m.content.status === 'available' ? `${m.content.value} => reply: ${reply}` : `reply: ${reply}`, source: 'artifact' };
|
|
108
|
+
}
|
|
109
|
+
if (m) {
|
|
110
|
+
m.facets.push('reason' in p ? { facet, sourceEventId: e.eventId, reason: p.reason } : { facet, sourceEventId: e.eventId });
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
system(e, p.type === 'AdvisorAcked' ? 'Advisor acknowledged (dispatch not in view)' : p.type === 'AdvisorCompleted' ? 'Advisor completed (dispatch not in view)' : `Advisor outcome unknown: ${'reason' in p ? p.reason : 'unknown'} (dispatch not in view)`);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (p.type === 'TaskCreated')
|
|
117
|
+
system(e, `Task created: ${p.title}`);
|
|
118
|
+
else if (p.type === 'TaskCompleted')
|
|
119
|
+
system(e, `Task completed: ${p.outcome}`);
|
|
120
|
+
else if (p.type === 'ReviewerSelected') {
|
|
121
|
+
system(e, `Reviewer selected ${p.reviewerId} · evidence rev ${p.evidenceRevision}`);
|
|
122
|
+
committee.push({ reviewerId: p.reviewerId, evidenceRevision: p.evidenceRevision, sourceEventId: e.eventId });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const delegation = [];
|
|
126
|
+
for (const o of observations) {
|
|
127
|
+
if (o.kind === 'agent') {
|
|
128
|
+
agents.set(o.agentId, { id: o.agentId, kind: o.role, sessionId: o.sessionId, identity: { status: 'available', value: o.agentId, source: o.source }, parentId: o.parentAgentId, conversation: unavailable(o.reason) });
|
|
129
|
+
if (o.parentAgentId !== null)
|
|
130
|
+
delegation.push([o.parentAgentId, o.agentId]);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
let hit = false;
|
|
134
|
+
for (const m of entries.values()) {
|
|
135
|
+
if (m.kind === 'message' && m.facets.some(f => f.sourceEventId === o.eventId)) {
|
|
136
|
+
hit = true;
|
|
137
|
+
if (!m.facets.some(f => f.facet === 'failed' && f.sourceEventId === o.eventId))
|
|
138
|
+
m.facets.push({ facet: 'failed', sourceEventId: o.eventId, reason: o.reason, source: o.source });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (!hit)
|
|
142
|
+
diagnostics.add(`unmatched-delivery-evidence:${o.eventId}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const list = [...entries.values()];
|
|
146
|
+
const message = [];
|
|
147
|
+
const task = [];
|
|
148
|
+
for (const m of list)
|
|
149
|
+
if (m.kind === 'message' && m.sender !== null) {
|
|
150
|
+
for (const r of m.recipients)
|
|
151
|
+
message.push([m.sender, r]);
|
|
152
|
+
task.push([m.taskId, m.id]);
|
|
153
|
+
}
|
|
154
|
+
const sessions = new Map();
|
|
155
|
+
for (const e of ordered) {
|
|
156
|
+
const cur = sessions.get(e.sessionId) ?? { runId: null, reasonCode: null, outcome: null };
|
|
157
|
+
sessions.set(e.sessionId, { runId: cur.runId ?? e.runId, reasonCode: e.payload.type === 'TaskCompleted' ? e.reasonCode : cur.reasonCode, outcome: e.payload.type === 'TaskCompleted' ? e.payload.outcome : cur.outcome });
|
|
158
|
+
}
|
|
159
|
+
const runKey = (sid) => sessions.get(sid)?.runId ?? '';
|
|
160
|
+
return { sessions, agents: [...agents.values()].sort((a, b) => cmp(runKey(a.sessionId), runKey(b.sessionId)) || cmp(a.sessionId, b.sessionId) || cmp(a.id, b.id)), entries: list, relations: { delegation, message, task }, cursors,
|
|
161
|
+
committee: { reviewersSelected: committee, primary: unavailable(NO_PRIMARY), slotAccounting: unavailable(NO_PRIMARY), exhaustion: unavailable(NO_PRIMARY) },
|
|
162
|
+
pendingFacets: { queued: unavailable('no v1 event'), sending: unavailable('no v1 event'), generating: unavailable('no v1 event') }, diagnostics: [...diagnostics].sort() };
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=mission-model.js.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type MissionAgent, type MissionEntry, type MissionKind, type MissionSelection, type MissionView } from './mission-model.js';
|
|
2
|
+
export type InspectorTab = 'detail' | 'plan' | 'actions';
|
|
3
|
+
export type MissionFocus = 'agents' | 'conversation' | 'inspector' | 'activity';
|
|
4
|
+
export interface MissionNavState {
|
|
5
|
+
layout: 'tree' | 'flat';
|
|
6
|
+
focus: MissionFocus;
|
|
7
|
+
tab: InspectorTab;
|
|
8
|
+
selection: MissionSelection;
|
|
9
|
+
anchorId: string | null;
|
|
10
|
+
following: boolean;
|
|
11
|
+
unseen: number;
|
|
12
|
+
seenTotal: number;
|
|
13
|
+
filter: {
|
|
14
|
+
kind: MissionKind | 'all';
|
|
15
|
+
agentId: string | null;
|
|
16
|
+
threadId: string | null;
|
|
17
|
+
taskId: string | null;
|
|
18
|
+
};
|
|
19
|
+
query: string | null;
|
|
20
|
+
}
|
|
21
|
+
export type MissionNavAction = {
|
|
22
|
+
type: 'focus';
|
|
23
|
+
to?: MissionFocus;
|
|
24
|
+
} | {
|
|
25
|
+
type: 'layout';
|
|
26
|
+
} | {
|
|
27
|
+
type: 'tab';
|
|
28
|
+
tab: InspectorTab;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'move';
|
|
31
|
+
dir: -1 | 1;
|
|
32
|
+
count?: number;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'follow';
|
|
35
|
+
} | {
|
|
36
|
+
type: 'kind';
|
|
37
|
+
} | {
|
|
38
|
+
type: 'agent-filter';
|
|
39
|
+
} | {
|
|
40
|
+
type: 'thread';
|
|
41
|
+
} | {
|
|
42
|
+
type: 'search-open';
|
|
43
|
+
} | {
|
|
44
|
+
type: 'search-input';
|
|
45
|
+
text: string;
|
|
46
|
+
} | {
|
|
47
|
+
type: 'search-back';
|
|
48
|
+
} | {
|
|
49
|
+
type: 'search-clear';
|
|
50
|
+
} | {
|
|
51
|
+
type: 'open';
|
|
52
|
+
narrow?: boolean;
|
|
53
|
+
};
|
|
54
|
+
export declare const initialMissionNav: () => MissionNavState;
|
|
55
|
+
/** Conversation = message/tool entries after filters; system entries live in Activity. */
|
|
56
|
+
export declare const filteredConversation: (view: MissionView, f: MissionNavState['filter']) => MissionEntry[];
|
|
57
|
+
export declare const activityEntries: (view: MissionView) => MissionEntry[];
|
|
58
|
+
export declare function missionWindow(view: MissionView, state: MissionNavState, limits?: {
|
|
59
|
+
page: number;
|
|
60
|
+
retain: number;
|
|
61
|
+
}, filtered?: readonly MissionEntry[]): {
|
|
62
|
+
entries: readonly MissionEntry[];
|
|
63
|
+
total: number;
|
|
64
|
+
unseen: number;
|
|
65
|
+
above: number;
|
|
66
|
+
};
|
|
67
|
+
export declare function agentRows(view: MissionView, layout: 'tree' | 'flat'): {
|
|
68
|
+
agent: MissionAgent;
|
|
69
|
+
depth: number;
|
|
70
|
+
}[];
|
|
71
|
+
export declare function reduceMissionNav(s: MissionNavState, a: MissionNavAction, view: MissionView): MissionNavState;
|
|
72
|
+
/** Redacted, human-readable text of an entry; the only text search may see. */
|
|
73
|
+
export declare function entryText(e: MissionEntry): string;
|
|
74
|
+
export declare function searchMission(window: readonly MissionEntry[], query: string, limit?: number): {
|
|
75
|
+
ids: readonly string[];
|
|
76
|
+
scanned: number;
|
|
77
|
+
};
|
|
78
|
+
export declare const missionRowBudget: (rows: number | undefined, chrome: number) => number | null;
|
|
79
|
+
export declare function resolveTerminalProfile(env: Readonly<Record<string, string | undefined>>): {
|
|
80
|
+
color: boolean;
|
|
81
|
+
charset: 'unicode' | 'ascii';
|
|
82
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { redactSecretText } from '../security/redact.js';
|
|
2
|
+
import { bindingLabel } from './mission-model.js';
|
|
3
|
+
const ORDER = ['agents', 'conversation', 'inspector', 'activity'];
|
|
4
|
+
const KINDS = ['all', 'message', 'tool'];
|
|
5
|
+
const PAGE = 100, RETAIN = 500;
|
|
6
|
+
export const initialMissionNav = () => ({ layout: 'tree', focus: 'agents', tab: 'detail', selection: null, anchorId: null, following: true, unseen: 0, seenTotal: 0, filter: { kind: 'all', agentId: null, threadId: null, taskId: null }, query: null });
|
|
7
|
+
/** Conversation = message/tool entries after filters; system entries live in Activity. */
|
|
8
|
+
export const filteredConversation = (view, f) => view.entries.filter(e => (f.kind === 'all' ? e.kind !== 'system' : e.kind === f.kind) && (f.agentId === null || e.sender === f.agentId || e.recipients.includes(f.agentId)) && (f.threadId === null || e.threadId === f.threadId) && (f.taskId === null || e.taskId === f.taskId));
|
|
9
|
+
export const activityEntries = (view) => view.entries.filter(e => e.kind === 'system');
|
|
10
|
+
export function missionWindow(view, state, limits = { page: PAGE, retain: RETAIN }, filtered) {
|
|
11
|
+
const all = filtered ?? filteredConversation(view, state.filter);
|
|
12
|
+
const total = all.length;
|
|
13
|
+
const kept = all.slice(-limits.retain);
|
|
14
|
+
const dropped = total - kept.length;
|
|
15
|
+
const idx = state.following || state.anchorId === null ? -1 : kept.findLastIndex(e => e.id === state.anchorId);
|
|
16
|
+
if (idx < 0)
|
|
17
|
+
return { entries: kept.slice(-limits.page), total, unseen: 0, above: dropped + Math.max(0, kept.length - limits.page) };
|
|
18
|
+
const start = Math.max(0, idx + 1 - limits.page);
|
|
19
|
+
return { entries: kept.slice(start, idx + 1), total, unseen: Math.max(0, total - state.seenTotal), above: dropped + start };
|
|
20
|
+
}
|
|
21
|
+
export function agentRows(view, layout) {
|
|
22
|
+
if (layout === 'flat')
|
|
23
|
+
return view.agents.map(agent => ({ agent, depth: 0 }));
|
|
24
|
+
const ids = new Set(view.agents.map(a => a.id));
|
|
25
|
+
const out = [];
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
const walk = (a, depth) => { if (seen.has(a.id))
|
|
28
|
+
return; seen.add(a.id); out.push({ agent: a, depth }); for (const c of view.agents)
|
|
29
|
+
if (c.parentId === a.id)
|
|
30
|
+
walk(c, depth + 1); };
|
|
31
|
+
for (const a of view.agents)
|
|
32
|
+
if (a.parentId === null || !ids.has(a.parentId))
|
|
33
|
+
walk(a, 0);
|
|
34
|
+
for (const a of view.agents)
|
|
35
|
+
walk(a, 0);
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
const clamp = (n, lo, hi) => Math.max(lo, Math.min(hi, n));
|
|
39
|
+
function moveConversation(s, dir, count, view) {
|
|
40
|
+
const all = filteredConversation(view, s.filter);
|
|
41
|
+
const total = all.length;
|
|
42
|
+
const kept = all.slice(-RETAIN);
|
|
43
|
+
if (kept.length === 0)
|
|
44
|
+
return s;
|
|
45
|
+
const cur = s.following || s.anchorId === null ? kept.length - 1 : Math.max(0, kept.findLastIndex(e => e.id === s.anchorId));
|
|
46
|
+
const next = clamp(cur + dir * count, 0, kept.length - 1);
|
|
47
|
+
const entry = kept[next];
|
|
48
|
+
if (next === kept.length - 1 && (dir === 1 || s.following))
|
|
49
|
+
return { ...s, following: true, anchorId: null, unseen: 0, seenTotal: total, selection: { kind: 'entry', id: entry.id } };
|
|
50
|
+
return { ...s, following: false, anchorId: entry.id, seenTotal: s.following ? total : s.seenTotal, unseen: s.following ? 0 : Math.max(0, total - s.seenTotal), selection: { kind: 'entry', id: entry.id } };
|
|
51
|
+
}
|
|
52
|
+
export function reduceMissionNav(s, a, view) {
|
|
53
|
+
switch (a.type) {
|
|
54
|
+
case 'focus': return { ...s, focus: a.to ?? ORDER[(ORDER.indexOf(s.focus) + 1) % ORDER.length] };
|
|
55
|
+
case 'layout': return { ...s, layout: s.layout === 'tree' ? 'flat' : 'tree' };
|
|
56
|
+
case 'tab': return { ...s, tab: a.tab };
|
|
57
|
+
case 'follow': {
|
|
58
|
+
const all = filteredConversation(view, s.filter);
|
|
59
|
+
const last = all.at(-1);
|
|
60
|
+
return { ...s, following: true, anchorId: null, unseen: 0, seenTotal: all.length, selection: last ? { kind: 'entry', id: last.id } : s.selection };
|
|
61
|
+
}
|
|
62
|
+
case 'kind': return { ...s, filter: { ...s.filter, kind: KINDS[(KINDS.indexOf(s.filter.kind) + 1) % KINDS.length] }, following: true, anchorId: null, unseen: 0 };
|
|
63
|
+
case 'agent-filter': {
|
|
64
|
+
if (s.selection?.kind !== 'agent')
|
|
65
|
+
return s;
|
|
66
|
+
const id = s.selection.id;
|
|
67
|
+
return { ...s, filter: { ...s.filter, agentId: s.filter.agentId === id ? null : id }, following: true, anchorId: null, unseen: 0 };
|
|
68
|
+
}
|
|
69
|
+
case 'thread': {
|
|
70
|
+
const sel = s.selection?.kind === 'entry' ? view.entries.find(e => e.id === s.selection.id) : missionWindow(view, s).entries.at(-1);
|
|
71
|
+
if (s.filter.threadId !== null)
|
|
72
|
+
return { ...s, filter: { ...s.filter, threadId: null } };
|
|
73
|
+
if (!sel)
|
|
74
|
+
return s;
|
|
75
|
+
return { ...s, filter: { ...s.filter, threadId: sel.threadId }, following: true, anchorId: null, unseen: 0 };
|
|
76
|
+
}
|
|
77
|
+
case 'search-open': return { ...s, query: '' };
|
|
78
|
+
case 'search-input': return s.query === null ? s : { ...s, query: s.query + a.text };
|
|
79
|
+
case 'search-back': return s.query === null ? s : { ...s, query: s.query.slice(0, -1) };
|
|
80
|
+
case 'search-clear': return { ...s, query: null };
|
|
81
|
+
case 'move': {
|
|
82
|
+
const n = a.count ?? 1;
|
|
83
|
+
if (s.focus === 'conversation')
|
|
84
|
+
return moveConversation(s, a.dir, n, view);
|
|
85
|
+
if (s.focus === 'agents') {
|
|
86
|
+
const rows = agentRows(view, s.layout);
|
|
87
|
+
if (rows.length === 0)
|
|
88
|
+
return s;
|
|
89
|
+
const cur = s.selection?.kind === 'agent' ? Math.max(0, rows.findIndex(r => r.agent.id === s.selection.id)) : 0;
|
|
90
|
+
return { ...s, selection: { kind: 'agent', id: rows[clamp(cur + a.dir * n, 0, rows.length - 1)].agent.id } };
|
|
91
|
+
}
|
|
92
|
+
if (s.focus === 'activity') {
|
|
93
|
+
const list = activityEntries(view);
|
|
94
|
+
if (list.length === 0)
|
|
95
|
+
return s;
|
|
96
|
+
const at = s.selection?.kind === 'entry' ? list.findIndex(e => e.id === s.selection.id) : -1;
|
|
97
|
+
const cur = at < 0 ? list.length - 1 : at;
|
|
98
|
+
return { ...s, selection: { kind: 'entry', id: list[clamp(cur + a.dir * n, 0, list.length - 1)].id } };
|
|
99
|
+
}
|
|
100
|
+
return s;
|
|
101
|
+
}
|
|
102
|
+
case 'open': {
|
|
103
|
+
const focus = a.narrow ? 'inspector' : s.focus;
|
|
104
|
+
if (s.focus === 'agents') {
|
|
105
|
+
const rows = agentRows(view, s.layout);
|
|
106
|
+
const sel = s.selection?.kind === 'agent' ? s.selection : rows[0] ? { kind: 'agent', id: rows[0].agent.id } : s.selection;
|
|
107
|
+
return { ...s, selection: sel, tab: 'detail', focus };
|
|
108
|
+
}
|
|
109
|
+
const list = s.focus === 'activity' ? activityEntries(view) : missionWindow(view, s).entries;
|
|
110
|
+
const keep = s.selection?.kind === 'entry' && list.some(e => e.id === s.selection.id) ? s.selection : list.at(-1) ? { kind: 'entry', id: list.at(-1).id } : s.selection;
|
|
111
|
+
return { ...s, selection: keep, tab: 'detail', focus };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/** Redacted, human-readable text of an entry; the only text search may see. */
|
|
116
|
+
export function entryText(e) {
|
|
117
|
+
const body = e.content.status === 'available' ? e.content.value : `${e.content.reason}${e.content.ref ? ` ${e.content.ref}` : ''}`;
|
|
118
|
+
return redactSecretText(`${e.kind} ${e.sender === null ? '' : bindingLabel(e.sender)} ${e.recipients.map(bindingLabel).join(' ')} ${body}`);
|
|
119
|
+
}
|
|
120
|
+
export function searchMission(window, query, limit = RETAIN) {
|
|
121
|
+
const kept = window.slice(-limit);
|
|
122
|
+
const q = query.toLowerCase();
|
|
123
|
+
return { ids: q === '' ? [] : kept.filter(e => entryText(e).toLowerCase().includes(q)).map(e => e.id), scanned: kept.length };
|
|
124
|
+
}
|
|
125
|
+
export const missionRowBudget = (rows, chrome) => rows === undefined ? null : Math.max(1, rows - chrome);
|
|
126
|
+
export function resolveTerminalProfile(env) {
|
|
127
|
+
const dumb = env.TERM === 'dumb';
|
|
128
|
+
const locale = [env.LC_ALL, env.LC_CTYPE, env.LANG].find(v => v !== undefined && v !== '');
|
|
129
|
+
return { color: !dumb && (env.NO_COLOR === undefined || env.NO_COLOR === ''), charset: dumb || (locale !== undefined && !/utf-?8/i.test(locale)) ? 'ascii' : 'unicode' };
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=mission-nav.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type MissionSelection, type MissionView } from './mission-model.js';
|
|
3
|
+
import { type MissionPlanSnapshot } from './mission-plan.js';
|
|
4
|
+
/** Read-only Plan panel. Facets are always shown separately; there is never one aggregate PASS. */
|
|
5
|
+
export declare function MissionPlanPanel({ snapshot, selection, width, view, maxRows: maxRowsProp }: {
|
|
6
|
+
snapshot: MissionPlanSnapshot;
|
|
7
|
+
selection: MissionSelection;
|
|
8
|
+
width: number;
|
|
9
|
+
view?: MissionView;
|
|
10
|
+
maxRows?: number;
|
|
11
|
+
}): React.ReactElement;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import { Box, Text } from 'ink';
|
|
4
|
+
import { InspectorBudgetContext } from './mission-model.js';
|
|
5
|
+
import { planTaskFacets, sanitizePlanText, workspaceFacts } from './mission-plan.js';
|
|
6
|
+
const MAX_TASKS = 12;
|
|
7
|
+
const avail = (name, a) => a.status === 'available' ? `${name} ${sanitizePlanText(a.value)}` : `${name} unavailable (${sanitizePlanText(a.reason)})`;
|
|
8
|
+
const wrap = (s, w) => { const out = []; const t = sanitizePlanText(s); for (let i = 0; i < t.length || i === 0; i += w)
|
|
9
|
+
out.push(t.slice(i, i + w)); return out; };
|
|
10
|
+
const EMPTY_VIEW = { agents: [], entries: [], relations: { delegation: [], message: [], task: [] }, cursors: new Map(), committee: { reviewersSelected: [], primary: { status: 'unavailable', reason: 'no view' }, slotAccounting: { status: 'unavailable', reason: 'no view' }, exhaustion: { status: 'unavailable', reason: 'no view' } }, pendingFacets: { queued: { status: 'unavailable', reason: 'no view' }, sending: { status: 'unavailable', reason: 'no view' }, generating: { status: 'unavailable', reason: 'no view' } }, diagnostics: [] };
|
|
11
|
+
/** Read-only Plan panel. Facets are always shown separately; there is never one aggregate PASS. */
|
|
12
|
+
export function MissionPlanPanel({ snapshot, selection, width, view, maxRows: maxRowsProp }) {
|
|
13
|
+
const ctxRows = useContext(InspectorBudgetContext);
|
|
14
|
+
const maxRows = maxRowsProp ?? ctxRows;
|
|
15
|
+
const w = Math.max(20, width);
|
|
16
|
+
const lines = [];
|
|
17
|
+
if (snapshot.status === 'ok') {
|
|
18
|
+
lines.push(`Plan · ${snapshot.tasks.length} tasks · captured ${(snapshot.digest ?? '').slice(0, 8)}`);
|
|
19
|
+
const shown = snapshot.tasks.slice(0, MAX_TASKS);
|
|
20
|
+
for (const t of shown) {
|
|
21
|
+
const f = planTaskFacets(snapshot, t.id);
|
|
22
|
+
lines.push(`${t.id} [${t.status}] ${t.title} AC ${t.acceptance.checked}/${t.acceptance.total}${t.dependencies.length ? ` deps ${t.dependencies.join(',')}` : ''}`);
|
|
23
|
+
lines.push(` report ${f.agentReport} · check ${f.check} · AC ${f.acceptance} · review ${f.review} · owner gate ${f.ownerGate}${f.blockedBy.length ? ` · blocked by ${f.blockedBy.join(',')}` : ''}`);
|
|
24
|
+
}
|
|
25
|
+
if (snapshot.tasks.length > shown.length)
|
|
26
|
+
lines.push(`+${snapshot.tasks.length - shown.length} more tasks not shown`);
|
|
27
|
+
const focus = (selection?.kind === 'task' ? snapshot.tasks.find(t => t.id === selection.id) : undefined) ?? snapshot.tasks[0];
|
|
28
|
+
const ws = workspaceFacts(snapshot.root, view ?? EMPTY_VIEW, selection?.kind === 'agent' ? selection.id : '', focus);
|
|
29
|
+
lines.push(`Workspace${focus ? ` · ${focus.id}` : ''}`, ` project root ${ws.projectRoot}`, ` ${avail('cwd', ws.cwd)}`, ` ${avail('branch', ws.branch)}`, ` assigned (not observed): ${ws.assignedFiles.length ? ws.assignedFiles.join(', ') : 'none listed'}`, ` observed edits ${ws.observedEdits.status === 'available' ? ws.observedEdits.value.join(', ') : `unavailable (${ws.observedEdits.reason})`}`);
|
|
30
|
+
}
|
|
31
|
+
else
|
|
32
|
+
lines.push(snapshot.status === 'missing' ? 'Plan unavailable' : 'Plan malformed');
|
|
33
|
+
for (const d of snapshot.diagnostics)
|
|
34
|
+
lines.push(d);
|
|
35
|
+
lines.push(selection?.kind === 'task' ? `v1 task ${selection.id.slice(-8)} ↔ Plan task: unknown (no explicit mapping)` : 'v1 task ↔ Plan task link: unknown (no explicit mapping)');
|
|
36
|
+
const all = lines.flatMap(l => wrap(l, w));
|
|
37
|
+
const rows = maxRows !== undefined && all.length > maxRows ? [...all.slice(0, Math.max(0, maxRows - 1)), `… ${all.length - Math.max(0, maxRows - 1)} more`] : all;
|
|
38
|
+
return _jsx(Box, { flexDirection: "column", children: rows.map((l, i) => _jsx(Text, { children: l }, i)) });
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=mission-plan-screens.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Availability, MissionView } from './mission-model.js';
|
|
2
|
+
export interface MissionPlanTask {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
status: string;
|
|
6
|
+
file: string;
|
|
7
|
+
dependencies: readonly string[];
|
|
8
|
+
acceptance: {
|
|
9
|
+
checked: number;
|
|
10
|
+
total: number;
|
|
11
|
+
};
|
|
12
|
+
targetFiles: readonly string[];
|
|
13
|
+
}
|
|
14
|
+
export interface MissionPlanSnapshot {
|
|
15
|
+
status: 'ok' | 'missing' | 'malformed';
|
|
16
|
+
root: string;
|
|
17
|
+
sources: readonly string[];
|
|
18
|
+
digest: string | null;
|
|
19
|
+
capturedAt: string;
|
|
20
|
+
tasks: readonly MissionPlanTask[];
|
|
21
|
+
diagnostics: readonly string[];
|
|
22
|
+
}
|
|
23
|
+
export interface PlanTaskFacets {
|
|
24
|
+
agentReport: 'complete' | 'partial' | 'absent';
|
|
25
|
+
check: 'pass' | 'fail' | 'absent';
|
|
26
|
+
acceptance: 'verified' | 'not-verified';
|
|
27
|
+
review: 'approved' | 'changes-requested' | 'pending';
|
|
28
|
+
ownerGate: 'pending' | 'none';
|
|
29
|
+
blockedBy: readonly string[];
|
|
30
|
+
}
|
|
31
|
+
export declare const PLAN_INDEX_PATH = "docs/AI_HANDOFF/INDEX.md";
|
|
32
|
+
/** Strip OSC/CSI sequences and remaining control bytes, then redact secret-shaped text. */
|
|
33
|
+
export declare function sanitizePlanText(value: string): string;
|
|
34
|
+
/** Read-only snapshot of `<root>/docs/AI_HANDOFF/INDEX.md` + referenced task files. Never writes. */
|
|
35
|
+
export declare function readMissionPlan(projectRoot: string, now?: () => string): Promise<MissionPlanSnapshot>;
|
|
36
|
+
/** Five independent facets. `check` comes only from the Reviewer Verdict VERIFICATION_RERUN line; executor claims never feed it. */
|
|
37
|
+
export declare function planTaskFacets(snapshot: MissionPlanSnapshot, taskId: string): PlanTaskFacets;
|
|
38
|
+
/** Workspace facts. Assigned scope (Target Files) is never presented as observed activity. */
|
|
39
|
+
export declare function workspaceFacts(projectRoot: string, view: MissionView, agentId: string, task?: MissionPlanTask): {
|
|
40
|
+
projectRoot: string;
|
|
41
|
+
cwd: Availability<string>;
|
|
42
|
+
branch: Availability<string>;
|
|
43
|
+
assignedFiles: readonly string[];
|
|
44
|
+
observedEdits: Availability<readonly string[]>;
|
|
45
|
+
};
|