@wrongstack/core 0.309.1 → 0.310.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chronicle/index.js +113 -41
- package/dist/chronicle/metrics-ingest.d.ts +7 -0
- package/dist/chronicle/metrics-schema.d.ts +4 -1
- package/dist/chronicle/project-server.js +94 -38
- package/dist/chronicle/query.d.ts +1 -0
- package/dist/chronicle/sqlite-journal-schema.d.ts +2 -1
- package/dist/chronicle/types.d.ts +2 -0
- package/dist/{agent-status-helpers.d.ts → coordination/agent-status-helpers.d.ts} +1 -1
- package/dist/{agent-status-tracker.d.ts → coordination/agent-status-tracker.d.ts} +2 -2
- package/dist/{middleware → coordination}/collab-pause.d.ts +1 -1
- package/dist/coordination/director-kanban-queue-helpers.d.ts +1 -1
- package/dist/coordination/fleet-status-tool.d.ts +1 -1
- package/dist/coordination/index.d.ts +5 -1
- package/dist/coordination/index.js +2061 -346
- package/dist/coordination/kanban-dispatch-port.d.ts +30 -0
- package/dist/coordination/kanban-ops-port.d.ts +21 -0
- package/dist/coordination/mailbox-hooks.d.ts +1 -1
- package/dist/coordination/mailbox-project-server.js +14 -9
- package/dist/core/context.d.ts +35 -44
- package/dist/core/conversation-state.d.ts +16 -52
- package/dist/core/index.js +53 -16
- package/dist/core/provider-runner.d.ts +2 -2
- package/dist/core/run-env.d.ts +7 -28
- package/dist/core/streaming-response-builder.d.ts +2 -2
- package/dist/execution/index.js +111 -153
- package/dist/goal/index.js +100 -22
- package/dist/hq/auth-store.d.ts +9 -0
- package/dist/hq/cost-bridge.d.ts +1 -1
- package/dist/hq/index.js +24 -2
- package/dist/index.d.ts +12 -5
- package/dist/index.js +27806 -33937
- package/dist/infrastructure/index.js +210 -132
- package/dist/infrastructure/provider-cache-ledger.d.ts +1 -1
- package/dist/infrastructure/token-counter.d.ts +5 -1
- package/dist/kernel/events/file-events.d.ts +6 -0
- package/dist/kernel/events/provider-events.d.ts +10 -7
- package/dist/kernel/events/session-events.d.ts +4 -4
- package/dist/kernel/events/tool-events.d.ts +12 -2
- package/dist/plugin/index.js +105 -35
- package/dist/security/index.d.ts +1 -0
- package/dist/security/index.js +47 -18
- package/dist/security/kanban-boundary.d.ts +1 -1
- package/dist/security/kanban-governance-port.d.ts +28 -0
- package/dist/session-catalog/index.js +2 -3
- package/dist/session-catalog/project-server.js +2 -3
- package/dist/session-catalog/protocol.d.ts +1 -1
- package/dist/session-catalog/registry.d.ts +1 -1
- package/dist/session-catalog/store-schema.d.ts +1 -1
- package/dist/session-catalog/store.d.ts +1 -1
- package/dist/storage/annotations-store.d.ts +1 -1
- package/dist/storage/board-store-port.d.ts +45 -0
- package/dist/storage/completed-work-checkpoint.d.ts +1 -1
- package/dist/storage/config-loader/types.d.ts +1 -1
- package/dist/storage/event-bus-port.d.ts +27 -0
- package/dist/storage/file-session-writer.d.ts +47 -5
- package/dist/storage/goal-coordination.d.ts +1 -1
- package/dist/storage/goal-store.d.ts +1 -1
- package/dist/storage/index.d.ts +3 -4
- package/dist/storage/index.js +1063 -1459
- package/dist/storage/plan-store.d.ts +1 -1
- package/dist/storage/queue-store.d.ts +1 -1
- package/dist/storage/replay-log-store.d.ts +1 -1
- package/dist/storage/session-recovery.d.ts +10 -0
- package/dist/storage/session-resume-validation.d.ts +13 -1
- package/dist/storage/session-store/events.d.ts +1 -1
- package/dist/storage/session-store/load-session-data.d.ts +1 -1
- package/dist/storage/session-store/rename-session.d.ts +1 -1
- package/dist/storage/session-store/resume-session.d.ts +3 -1
- package/dist/storage/session-store/session-store-index.d.ts +2 -1
- package/dist/storage/session-store/types.d.ts +1 -1
- package/dist/storage/session-store.d.ts +70 -0
- package/dist/storage/session-summary-tracker.d.ts +8 -0
- package/dist/storage/session-write-buffer.d.ts +31 -2
- package/dist/storage/task-store.d.ts +1 -1
- package/dist/storage/todos-checkpoint.d.ts +1 -1
- package/dist/storage/tool-audit-log.d.ts +1 -1
- package/dist/tasking/index.js +100 -22
- package/dist/tasking/task-tracker.d.ts +24 -1
- package/dist/types/compactor.d.ts +2 -2
- package/dist/types/context.d.ts +212 -0
- package/dist/types/conversation-state.d.ts +109 -0
- package/dist/types/error-handler.d.ts +2 -2
- package/dist/types/file-event-record.d.ts +6 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +17 -1
- package/dist/types/permission.d.ts +3 -3
- package/dist/types/plugin.d.ts +3 -3
- package/dist/types/provider-runner.d.ts +2 -2
- package/dist/types/provider.d.ts +10 -0
- package/dist/types/run-env.d.ts +32 -0
- package/dist/types/session.d.ts +3 -0
- package/dist/types/slash-command.d.ts +2 -2
- package/dist/types/token-counter.d.ts +30 -1
- package/dist/types/tool-executor.d.ts +2 -2
- package/dist/types/tool.d.ts +5 -5
- package/dist/utils/context-breakdown.d.ts +2 -2
- package/dist/utils/context-evidence.d.ts +12 -12
- package/dist/utils/crash-shield.d.ts +9 -0
- package/dist/utils/heap-watchdog.js +11 -3
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +72 -156
- package/dist/utils/regex-guard.d.ts +7 -30
- package/dist/utils/todos-format.d.ts +1 -1
- package/dist/utils/tree-kill.d.ts +2 -0
- package/dist/utils/tree-kill.js +1 -0
- package/instructions/coordination/subagent-baseline.md +10 -0
- package/instructions/system-lite.md +2 -0
- package/instructions/system-pro.md +40 -0
- package/instructions/system.md +15 -0
- package/package.json +6 -9
- package/dist/defaults/index.d.ts +0 -69
- package/dist/defaults/index.js +0 -38133
- /package/dist/{fleet-notifier.d.ts → coordination/fleet-notifier.d.ts} +0 -0
- /package/dist/{session-registry-atomic-file.d.ts → session-catalog/session-registry-atomic-file.d.ts} +0 -0
- /package/dist/{session-registry-types.d.ts → session-catalog/session-registry-types.d.ts} +0 -0
- /package/dist/{session-registry.d.ts → session-catalog/session-registry.d.ts} +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kanban board-store port for the storage area (goal coordination).
|
|
3
|
+
*
|
|
4
|
+
* `goal-kanban.ts` and `goal-coordination.ts` previously imported the
|
|
5
|
+
* concrete functions from `@wrongstack/kanban` directly, keeping a
|
|
6
|
+
* core → kanban runtime edge (the layering inversion catalogued as
|
|
7
|
+
* roadmap #11 / report §2.1). This port is the leaf contract the storage
|
|
8
|
+
* area codes against; the CLI composition root registers the real
|
|
9
|
+
* implementation at boot (TOKENS-style dependency injection).
|
|
10
|
+
*
|
|
11
|
+
* Type-only imports of kanban's data shapes remain permitted — they erase
|
|
12
|
+
* at compile time and do not create a runtime edge. Only *callable*
|
|
13
|
+
* surface is ported.
|
|
14
|
+
*
|
|
15
|
+
* Un-registered default: goal features fail soft (board sync disabled)
|
|
16
|
+
* exactly as before the extraction, so embedding contexts without kanban
|
|
17
|
+
* keep working.
|
|
18
|
+
*/
|
|
19
|
+
import type { CreateKanbanBoardInput, CreateKanbanTaskInput, KanbanBoard, KanbanBoardSummary, KanbanEventContext, KanbanTask, UpdateKanbanTaskInput } from '@wrongstack/kanban';
|
|
20
|
+
export interface BoardStorePort {
|
|
21
|
+
createBoard(projectRoot: string, input: CreateKanbanBoardInput): Promise<KanbanBoard>;
|
|
22
|
+
listBoards(projectRoot: string): Promise<KanbanBoardSummary[]>;
|
|
23
|
+
getBoard(projectRoot: string, boardId: string): Promise<KanbanBoard | null>;
|
|
24
|
+
removeBoard(projectRoot: string, boardId: string): Promise<boolean>;
|
|
25
|
+
addTask(projectRoot: string, boardId: string, input: CreateKanbanTaskInput, eventContext?: KanbanEventContext): Promise<{
|
|
26
|
+
board: KanbanBoard;
|
|
27
|
+
task: KanbanTask;
|
|
28
|
+
} | null>;
|
|
29
|
+
updateTask(projectRoot: string, boardId: string, taskId: string, input: UpdateKanbanTaskInput, eventContext?: KanbanEventContext): Promise<KanbanBoard | null>;
|
|
30
|
+
}
|
|
31
|
+
/** Composition-root hook: register the real kanban-backed implementation. */
|
|
32
|
+
export declare function setBoardStorePort(impl: BoardStorePort): void;
|
|
33
|
+
/**
|
|
34
|
+
* Resolve the board-store port. Callers that must fail soft should catch
|
|
35
|
+
* the not-wired error, same semantics as kanban being absent.
|
|
36
|
+
*/
|
|
37
|
+
export declare function boardStore(): BoardStorePort;
|
|
38
|
+
/**
|
|
39
|
+
* Fail-soft resolver: the port when wired, otherwise `null`. For code paths
|
|
40
|
+
* whose documented behavior when kanban is absent is a no-op or empty
|
|
41
|
+
* result (goal sync, previews) — avoids the synchronous throw breaking
|
|
42
|
+
* `.catch()` fail-soft chains in non-CLI embeddings.
|
|
43
|
+
*/
|
|
44
|
+
export declare function tryBoardStore(): BoardStorePort | null;
|
|
45
|
+
//# sourceMappingURL=board-store-port.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EventBus } from '
|
|
1
|
+
import type { EventBus } from '../event-bus-port.js';
|
|
2
2
|
import type { Config } from '../../types/config.js';
|
|
3
3
|
import type { Logger } from '../../types/logger.js';
|
|
4
4
|
import type { SecretVault } from '../../types/secret-vault.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event-bus port for the storage area.
|
|
3
|
+
*
|
|
4
|
+
* Storage modules receive a bus instance from the composition root and use
|
|
5
|
+
* it only to *emit* `storage.*` events (verified: zero subscribe/logger/
|
|
6
|
+
* constructor calls across packages/core/src/storage). Importing the concrete
|
|
7
|
+
* `EventBus` class from `../kernel/events.js` kept a storage → kernel edge in
|
|
8
|
+
* the dependency graph; this port severs it.
|
|
9
|
+
*
|
|
10
|
+
* Structurally satisfied by the kernel `EventBus` class (its typed-generic
|
|
11
|
+
* `emit` is compatible with this loose signature via method-bivariance), so
|
|
12
|
+
* composition-root wiring needs no adapter.
|
|
13
|
+
*
|
|
14
|
+
* Surface policy: emit-only. If a storage consumer ever needs to subscribe,
|
|
15
|
+
* widen this port deliberately instead of re-importing the kernel type.
|
|
16
|
+
*/
|
|
17
|
+
export interface EventBus {
|
|
18
|
+
/**
|
|
19
|
+
* Emit a storage-domain event onto the bus.
|
|
20
|
+
*
|
|
21
|
+
* Loose parameter typing is deliberate: the concrete kernel bus carries the
|
|
22
|
+
* full `EventMap` typing; storage call sites pass literal `'storage.*'`
|
|
23
|
+
* names whose payloads the kernel map validates at the wiring boundary.
|
|
24
|
+
*/
|
|
25
|
+
emit(event: string, payload?: unknown): void;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=event-bus-port.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as fsp from 'node:fs/promises';
|
|
2
|
-
import type { EventBus } from '
|
|
2
|
+
import type { EventBus } from './event-bus-port.js';
|
|
3
3
|
import type { SecretScrubber } from '../types/secret-scrubber.js';
|
|
4
4
|
import type { FileSnapshot, SessionEvent, SessionMetadata, SessionSummary, SessionWriter } from '../types/session.js';
|
|
5
5
|
import type { SessionCheckpointCas } from './session-checkpoint-cas.js';
|
|
@@ -46,6 +46,15 @@ export declare class FileSessionWriter implements SessionWriter {
|
|
|
46
46
|
get onAppendBatch(): ((events: SessionEvent[]) => void) | undefined;
|
|
47
47
|
set onAppendBatch(cb: ((events: SessionEvent[]) => void) | undefined);
|
|
48
48
|
private readonly onCloseCb?;
|
|
49
|
+
/** Mid-session metadata checkpoint throttle. 0 disables checkpointing. */
|
|
50
|
+
private readonly metadataCheckpointMs;
|
|
51
|
+
/** One-shot guard for the "interval set but no sink" warning below. */
|
|
52
|
+
private _checkpointNoSinkWarned;
|
|
53
|
+
private readonly onMetadataCheckpointCb?;
|
|
54
|
+
/** Set whenever summary counters changed since the last metadata checkpoint. */
|
|
55
|
+
private metadataDirty;
|
|
56
|
+
private metadataTimer;
|
|
57
|
+
private metadataCheckpointInFlight;
|
|
49
58
|
/** Implements SessionWriter.traceId — propagated from ContextInit.traceId. */
|
|
50
59
|
traceId: string | undefined;
|
|
51
60
|
/**
|
|
@@ -104,15 +113,47 @@ export declare class FileSessionWriter implements SessionWriter {
|
|
|
104
113
|
onClose?: ((summary: SessionSummary) => void | Promise<void>) | undefined;
|
|
105
114
|
/** Reconcile an explicit name changed while this writer remained open. */
|
|
106
115
|
resolveName?: (() => Promise<Pick<SessionSummary, 'name'> | null>) | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Mid-session metadata checkpoint throttle (ms). While the session is
|
|
118
|
+
* live and dirty, the summary sidecar + index row are refreshed at most
|
|
119
|
+
* this often, so a SIGKILLed process still leaves accurate listing
|
|
120
|
+
* metadata instead of its create-time stub. 0 disables checkpointing —
|
|
121
|
+
* killed sessions then stay visible through the store's list()-union
|
|
122
|
+
* scan, but only with analyzer-derived metadata rather than tracked
|
|
123
|
+
* counters. Default 10_000.
|
|
124
|
+
*/
|
|
125
|
+
metadataCheckpointMs?: number | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* Persists a mid-session summary snapshot (store-level index row /
|
|
128
|
+
* catalog upsert). The sidecar file itself is written by the writer
|
|
129
|
+
* under its manifest lock; this callback covers the index side.
|
|
130
|
+
*/
|
|
131
|
+
onMetadataCheckpoint?: ((summary: SessionSummary) => void | Promise<void>) | undefined;
|
|
107
132
|
}, traceId?: string | undefined);
|
|
108
133
|
get pendingToolUses(): string[];
|
|
109
134
|
private writeSessionStartLazy;
|
|
135
|
+
/**
|
|
136
|
+
* Arm the mid-session metadata checkpoint timer if it is not already armed.
|
|
137
|
+
* Called after every observed event; the timer itself is unref'd so an idle
|
|
138
|
+
* session never keeps the process alive for a cosmetic sidecar refresh.
|
|
139
|
+
*/
|
|
140
|
+
private scheduleMetadataCheckpoint;
|
|
141
|
+
/**
|
|
142
|
+
* Persist a mid-session summary snapshot: the `.summary.json` sidecar under
|
|
143
|
+
* the manifest lock, then the store-level index row / catalog upsert via
|
|
144
|
+
* `onMetadataCheckpoint`. Runs at most once per throttle interval and only
|
|
145
|
+
* when summary counters changed since the last checkpoint; a failed
|
|
146
|
+
* checkpoint stays dirty and retries on the next armed tick.
|
|
147
|
+
*/
|
|
148
|
+
private runMetadataCheckpoint;
|
|
110
149
|
append(event: SessionEvent): Promise<void>;
|
|
111
150
|
appendBatch(events: SessionEvent[]): Promise<void>;
|
|
112
151
|
/**
|
|
113
152
|
* Flush buffered events to disk immediately. Critical events
|
|
114
|
-
* (user_input, llm_response
|
|
115
|
-
*
|
|
153
|
+
* (user_input, llm_response, checkpoint, in_flight_*) already flush
|
|
154
|
+
* themselves inside append()/appendBatch(), so calling this matters for
|
|
155
|
+
* non-critical tails that would otherwise sit in the in-memory buffer
|
|
156
|
+
* for up to 500ms.
|
|
116
157
|
*
|
|
117
158
|
* Idempotent — cancels any pending timer, writes whatever has accumulated,
|
|
118
159
|
* then asks the OS to synchronize the file data before resolving. Even an
|
|
@@ -123,8 +164,9 @@ export declare class FileSessionWriter implements SessionWriter {
|
|
|
123
164
|
* Last-gasp synchronous drain for hard-exit paths (process.exit after
|
|
124
165
|
* rapid Ctrl+C). The async write chain cannot be awaited when the process
|
|
125
166
|
* is about to die, but whatever still sits in the in-memory buffer CAN be
|
|
126
|
-
* saved with a blocking append.
|
|
127
|
-
*
|
|
167
|
+
* saved with a blocking append. A failed sync append leaves the buffer
|
|
168
|
+
* intact so a subsequent close()/flush() can retry. An in-flight async
|
|
169
|
+
* write may still be cut off by a hard exit.
|
|
128
170
|
*/
|
|
129
171
|
flushSync(): void;
|
|
130
172
|
close(): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BrainArbiter } from '../coordination/brain.js';
|
|
2
|
-
import type { EventBus } from '
|
|
2
|
+
import type { EventBus } from './event-bus-port.js';
|
|
3
3
|
import { type GoalFile } from './goal-store.js';
|
|
4
4
|
export interface CompletedGoalDeliverable {
|
|
5
5
|
index: number;
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { FleetNotifier, type FleetNotifierOptions, } from '../fleet-notifier.js';
|
|
1
|
+
export { type BoardStorePort, boardStore, setBoardStorePort, } from './board-store-port.js';
|
|
3
2
|
export { type CatalogSessionRecord, type MaintenanceLease, type ResumeReservation, type SessionCatalogHealth, SessionCatalogProjectClient, type SessionCatalogProjectClientOptions, type SessionLeaseCredential, type SessionResumeClaim, } from '../session-catalog/index.js';
|
|
4
3
|
export { getProjectSessionRegistry as getSessionRegistry, hasProjectSessionRegistry as hasSessionRegistry, ProjectSessionRegistry as SessionRegistry, } from '../session-catalog/registry.js';
|
|
5
|
-
export type { AgentEntry, AgentLiveStatus, SessionLiveStatus, SessionRegistryEntry, SessionWebUIEndpointHint, } from '../session-registry.js';
|
|
4
|
+
export type { AgentEntry, AgentLiveStatus, SessionLiveStatus, SessionRegistryEntry, SessionWebUIEndpointHint, } from '../session-catalog/session-registry.js';
|
|
6
5
|
/** @deprecated Test/migration adapter; production ownership uses SessionRegistry above. */
|
|
7
|
-
export { SessionRegistry as LegacySessionRegistry } from '../session-registry.js';
|
|
6
|
+
export { SessionRegistry as LegacySessionRegistry } from '../session-catalog/session-registry.js';
|
|
8
7
|
export type { SyncCategory, SyncConfig } from '../types/config.js';
|
|
9
8
|
export type { DefaultSessionReaderOptions, SessionReader } from '../types/session-reader.js';
|
|
10
9
|
export { type Annotation, AnnotationsStore, type AnnotationsStoreOptions, } from './annotations-store.js';
|