@wrongstack/core 0.306.4 → 0.307.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/dist/chronicle/index.js +957 -953
- package/dist/chronicle/metrics-ingest.d.ts +55 -0
- package/dist/chronicle/metrics-schema.d.ts +86 -0
- package/dist/chronicle/metrics-store.d.ts +5 -120
- package/dist/chronicle/project-server.js +1083 -1084
- package/dist/chronicle/sqlite-journal-quota.d.ts +39 -0
- package/dist/chronicle/sqlite-journal-schema.d.ts +25 -0
- package/dist/chronicle/sqlite-journal.d.ts +12 -177
- package/dist/coordination/agents/index.js +1803 -1701
- package/dist/coordination/agents/project-agent-capture.d.ts +48 -0
- package/dist/coordination/agents/project-agent-identity.d.ts +3 -129
- package/dist/coordination/agents/project-agent-roster.d.ts +17 -0
- package/dist/coordination/agents/types.d.ts +6 -9
- package/dist/coordination/index.js +6051 -5880
- package/dist/coordination/mail-tools.d.ts +1 -1
- package/dist/coordination/mailbox-http-actor-query.d.ts +16 -0
- package/dist/coordination/mailbox-http-router.d.ts +0 -48
- package/dist/coordination/mailbox-http-sse.d.ts +12 -0
- package/dist/coordination/mailbox-message-types.d.ts +71 -0
- package/dist/coordination/mailbox-predicates.d.ts +13 -0
- package/dist/coordination/mailbox-project-server.js +1 -1
- package/dist/coordination/mailbox-session-sync.d.ts +8 -0
- package/dist/coordination/mailbox-types.d.ts +6 -793
- package/dist/core/agent-loop-context.d.ts +28 -0
- package/dist/core/agent-loop-detector.d.ts +25 -0
- package/dist/core/fallback-doctor.d.ts +72 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1859 -1335
- package/dist/defaults/index.js +3647 -3559
- package/dist/execution/autonomy-brain-llm.d.ts +55 -0
- package/dist/execution/autonomy-brain.d.ts +3 -156
- package/dist/execution/compaction-budget.d.ts +38 -0
- package/dist/execution/compaction-core.d.ts +3 -170
- package/dist/execution/compaction-elision.d.ts +58 -0
- package/dist/execution/council-orchestrator-helpers.d.ts +39 -0
- package/dist/execution/council-orchestrator.d.ts +3 -42
- package/dist/execution/council-response-parser.d.ts +56 -0
- package/dist/execution/index.js +2475 -2449
- package/dist/execution/prompt-enhancer.js +11 -3
- package/dist/execution/tool-executor-guard.d.ts +18 -0
- package/dist/execution/tool-executor-runner.d.ts +12 -0
- package/dist/execution/tool-executor.d.ts +0 -75
- package/dist/goal/index.js +19 -6
- package/dist/hq/index.js +8 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8021 -7405
- package/dist/infrastructure/index.js +3 -1
- package/dist/kernel/events/agent-events.d.ts +2 -0
- package/dist/kernel/events/provider-events.d.ts +13 -0
- package/dist/plugin/index.js +2590 -2561
- package/dist/plugins/auto-review-config.d.ts +53 -0
- package/dist/plugins/auto-review-git.d.ts +19 -0
- package/dist/plugins/auto-review-plugin.d.ts +2 -140
- package/dist/plugins/review-finding-verification.d.ts +7 -0
- package/dist/prompts/index.d.ts +1 -0
- package/dist/prompts/index.js +601 -0
- package/dist/prompts/prompt-journal.d.ts +103 -0
- package/dist/security/index.js +627 -652
- package/dist/security/permission-explain.d.ts +19 -0
- package/dist/security/permission-policy.d.ts +0 -101
- package/dist/security/yolo-risk.d.ts +5 -4
- package/dist/session-catalog/index.js +220 -212
- package/dist/session-catalog/project-server.js +227 -219
- package/dist/session-catalog/store-rebuild.d.ts +9 -0
- package/dist/session-catalog/store-schema.d.ts +48 -0
- package/dist/session-catalog/store.d.ts +0 -17
- package/dist/storage/director-state.d.ts +6 -0
- package/dist/storage/file-session-writer.d.ts +2 -58
- package/dist/storage/index.d.ts +2 -1
- package/dist/storage/index.js +2057 -1925
- package/dist/storage/orphan-lock-cleaner.d.ts +15 -0
- package/dist/storage/queue-store.d.ts +6 -0
- package/dist/storage/session-recovery.d.ts +9 -0
- package/dist/storage/session-store/rename-session.d.ts +16 -0
- package/dist/storage/session-store/resume-session.d.ts +26 -0
- package/dist/storage/session-store/session-store-clear.d.ts +11 -0
- package/dist/storage/session-store/session-store-index.d.ts +13 -0
- package/dist/storage/session-store.d.ts +1 -129
- package/dist/storage/session-summary-tracker.d.ts +39 -0
- package/dist/storage/session-write-buffer.d.ts +43 -0
- package/dist/storage/session-writer/session-writer-flush.d.ts +4 -0
- package/dist/storage/session-writer/session-writer-summary-tracker.d.ts +28 -0
- package/dist/tools/fallback-agent-model-assign-tool.d.ts +18 -0
- package/dist/tools/fallback-leader-model-set-tool.d.ts +18 -0
- package/dist/tools/fallback-manage-tools.d.ts +8 -45
- package/dist/tools/fallback-profile-manage-tool.d.ts +16 -0
- package/dist/tools/fallback-provider-key-set-tool.d.ts +17 -0
- package/dist/tools/fallback-provider-manage-tool.d.ts +26 -0
- package/dist/tools/index.js +5124 -5071
- package/dist/types/config/root.d.ts +7 -2
- package/dist/types/default-config.d.ts +1 -1
- package/dist/types/index.d.ts +54 -55
- package/dist/types/index.js +953 -932
- package/dist/types/runtime-capability-manifest.d.ts +5 -5
- package/dist/types/session-markers.d.ts +12 -0
- package/dist/types/session-markers.js +19 -0
- package/dist/worktree/worktree-manager.d.ts +1 -1
- package/instructions/agents/architect.md +2 -0
- package/instructions/agents/code-reviewer.md +1 -0
- package/instructions/agents/debugger.md +2 -0
- package/instructions/agents/executor.md +2 -0
- package/instructions/agents/explore.md +3 -1
- package/instructions/agents/refactor.md +2 -0
- package/instructions/agents/reviewer.md +1 -0
- package/instructions/coordination/subagent-baseline.md +68 -7
- package/instructions/llm/prompt-enhancer.md +2 -1
- package/instructions/sections/tool/common-patterns.md +30 -0
- package/instructions/sections/tool/delegation-compact.md +3 -1
- package/instructions/sections/tool/delegation-full.md +5 -1
- package/instructions/system-lite.md +32 -4
- package/instructions/system-pro.md +63 -9
- package/instructions/system.md +56 -11
- package/package.json +9 -5
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import { type ChronicleMetricsRefreshResult } from './metrics-schema.js';
|
|
3
|
+
export declare class ChronicleMetricsIngester {
|
|
4
|
+
private readonly db;
|
|
5
|
+
private readonly directory;
|
|
6
|
+
private readonly dbPath;
|
|
7
|
+
constructor(db: DatabaseSync, directory: string, dbPath: string);
|
|
8
|
+
refresh(): Promise<ChronicleMetricsRefreshResult>;
|
|
9
|
+
private loadOffsets;
|
|
10
|
+
/** True once the legacy JSONL journal was imported into the SQLite journal
|
|
11
|
+
* (`importLegacyChronicleJournal` records the marker in `chronicle_meta`).
|
|
12
|
+
* After that point the SQLite `events` table already holds every JSONL
|
|
13
|
+
* event, so folding the leftover partition files again would double-count
|
|
14
|
+
* every migrated event in the aggregates. `source` is the already-opened
|
|
15
|
+
* read-only journal handle (null when no SQLite journal exists yet). */
|
|
16
|
+
private legacyJsonlConsumed;
|
|
17
|
+
/** Per-partition-file JSONL byte offsets recorded by
|
|
18
|
+
* `importLegacyChronicleJournal` at import time (keyed by the same relative
|
|
19
|
+
* path the fold uses). Files absent from the map were quarantined (or
|
|
20
|
+
* created after the migration) — their events live only in JSONL. */
|
|
21
|
+
private loadJsonlBoundary;
|
|
22
|
+
/** Persist the rebuild sentinel idempotently. Its presence makes
|
|
23
|
+
* `needsSqliteRebuild` return false, so post-migration jsonl-store offsets
|
|
24
|
+
* are never mistaken for pre-migration progress. */
|
|
25
|
+
private ensureRebuildMarker;
|
|
26
|
+
/** Upgrade path: `metrics.db` already aggregated the legacy JSONL, then the
|
|
27
|
+
* one-shot import copied those same events into the SQLite journal. There
|
|
28
|
+
* is no `sqlite:` cursor yet, so a plain incremental fold would replay the
|
|
29
|
+
* entire migrated history on top of the existing aggregates. The metrics
|
|
30
|
+
* projection is disposable (fully derived from the journal), so rebuild it
|
|
31
|
+
* from the SQLite source exactly once — the rebuild writes the cursors and
|
|
32
|
+
* subsequent refreshes go back to incremental folding. */
|
|
33
|
+
private needsSqliteRebuild;
|
|
34
|
+
private rebuildFromSqliteJournal;
|
|
35
|
+
private pruneOffsets;
|
|
36
|
+
private ingestSqliteJournal;
|
|
37
|
+
private ingestFile;
|
|
38
|
+
/** Fold one event into the aggregates atomically. `ingestEvent` runs several
|
|
39
|
+
* statements; when one throws mid-way (e.g. a malformed resource path), the
|
|
40
|
+
* statements before it already mutated the aggregates. The savepoint rolls
|
|
41
|
+
* those partial updates back: `ROLLBACK TO` rewinds, `RELEASE` (reached
|
|
42
|
+
* before the re-throw) pops the savepoint so the next event in the batch
|
|
43
|
+
* starts from a clean stack, and the batch commits only fully-succeeded
|
|
44
|
+
* events. Dropping the `RELEASE` would leak the savepoint into the next
|
|
45
|
+
* event's stack — the outer transaction ROLLBACK is never reached because
|
|
46
|
+
* the per-event catch swallows the error and continues the batch. */
|
|
47
|
+
private ingestEventAtomically;
|
|
48
|
+
private ingestEvent;
|
|
49
|
+
private ingestDailyCounters;
|
|
50
|
+
private ingestProvider;
|
|
51
|
+
private ingestTokenCost;
|
|
52
|
+
private ingestTask;
|
|
53
|
+
private ingestFileEvent;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=metrics-ingest.d.ts.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import type { ChronicleSignalFamily } from './query.js';
|
|
3
|
+
import type { ChronicleEvent } from './types.js';
|
|
4
|
+
export declare const SCHEMA_VERSION = 3;
|
|
5
|
+
export declare const READ_CHUNK_BYTES: number;
|
|
6
|
+
export declare const SQLITE_SOURCE_PREFIX = "sqlite:";
|
|
7
|
+
export declare const SQLITE_INGEST_BATCH = 2000;
|
|
8
|
+
export declare const EMPTY_FAMILIES: Record<ChronicleSignalFamily, number>;
|
|
9
|
+
export interface ChronicleMetricsRefreshResult {
|
|
10
|
+
ingestedEvents: number;
|
|
11
|
+
ingestedBytes: number;
|
|
12
|
+
sourceFiles: number;
|
|
13
|
+
invalidLines: number;
|
|
14
|
+
}
|
|
15
|
+
export interface ChronicleProviderDailyRow {
|
|
16
|
+
day: string;
|
|
17
|
+
providerId: string;
|
|
18
|
+
modelId: string;
|
|
19
|
+
attempts: number;
|
|
20
|
+
completed: number;
|
|
21
|
+
failed: number;
|
|
22
|
+
retries: number;
|
|
23
|
+
fallbacks: number;
|
|
24
|
+
inputTokens: number;
|
|
25
|
+
outputTokens: number;
|
|
26
|
+
cacheReadTokens: number;
|
|
27
|
+
cacheWriteTokens: number;
|
|
28
|
+
avgDurationMs: number;
|
|
29
|
+
maxDurationMs: number;
|
|
30
|
+
}
|
|
31
|
+
export interface ChronicleTaskOutcomeRow {
|
|
32
|
+
taskId: string;
|
|
33
|
+
runId: string;
|
|
34
|
+
boardId: string;
|
|
35
|
+
sessionId: string;
|
|
36
|
+
agentId: string;
|
|
37
|
+
status: string;
|
|
38
|
+
startedAt: string | null;
|
|
39
|
+
endedAt: string | null;
|
|
40
|
+
durationMs: number | null;
|
|
41
|
+
retries: number;
|
|
42
|
+
verificationFailures: number;
|
|
43
|
+
filesTouched: number;
|
|
44
|
+
}
|
|
45
|
+
export interface ChronicleFileLineageRow {
|
|
46
|
+
path: string;
|
|
47
|
+
operation: string;
|
|
48
|
+
occurredAt: string;
|
|
49
|
+
sessionId: string;
|
|
50
|
+
agentId: string;
|
|
51
|
+
taskId: string;
|
|
52
|
+
boardId: string;
|
|
53
|
+
runId: string;
|
|
54
|
+
toolName: string;
|
|
55
|
+
providerId: string;
|
|
56
|
+
modelId: string;
|
|
57
|
+
source: string;
|
|
58
|
+
}
|
|
59
|
+
export interface ChronicleMetricsSummary {
|
|
60
|
+
providers: {
|
|
61
|
+
attempts: number;
|
|
62
|
+
completed: number;
|
|
63
|
+
failed: number;
|
|
64
|
+
successRate: number;
|
|
65
|
+
};
|
|
66
|
+
tasks: Record<string, number>;
|
|
67
|
+
files: {
|
|
68
|
+
mutations: number;
|
|
69
|
+
uniquePaths: number;
|
|
70
|
+
};
|
|
71
|
+
estimatedCostUsd: number;
|
|
72
|
+
}
|
|
73
|
+
export declare function loadDatabaseSync(): typeof DatabaseSync;
|
|
74
|
+
export declare function isChronicleMetricsAvailable(): boolean;
|
|
75
|
+
export declare function ensureMetricsSchema(db: DatabaseSync): void;
|
|
76
|
+
export declare function eventDay(event: ChronicleEvent): string;
|
|
77
|
+
export declare function durationMs(event: ChronicleEvent): number;
|
|
78
|
+
export declare function numberOrDuration(event: ChronicleEvent, attributes: Record<string, unknown>): number;
|
|
79
|
+
export declare function numberAt(event: ChronicleEvent, dotPath: string): number;
|
|
80
|
+
export declare function readPath(value: Record<string, unknown>, key: string): unknown;
|
|
81
|
+
export declare function stringAt(record: Record<string, unknown>, key: string): string | undefined;
|
|
82
|
+
export declare function asString(value: unknown): string | undefined;
|
|
83
|
+
export declare function clampLimit(limit: number | undefined, fallback: number): number;
|
|
84
|
+
export declare function normalizeKey(value: string): string;
|
|
85
|
+
export declare function normalizePathKey(value: string): string;
|
|
86
|
+
//# sourceMappingURL=metrics-schema.d.ts.map
|
|
@@ -6,98 +6,16 @@
|
|
|
6
6
|
* projection kept in `<chronicleDir>/metrics.db` (node:sqlite, WAL). Each
|
|
7
7
|
* `refresh()` incrementally consumes only the journal bytes appended since
|
|
8
8
|
* the previous run (per-partition byte offsets in `ingest_state`), so the
|
|
9
|
-
* raw JSONL partitions can be purged by retention without losing metrics
|
|
10
|
-
*
|
|
11
|
-
* - `provider_daily` — provider×model×day attempt/success/failure/retry/
|
|
12
|
-
* fallback counts, token totals, duration stats.
|
|
13
|
-
* - `task_outcomes` — one row per task (kanban/SDD/subagent) with status,
|
|
14
|
-
* timing, retry counts, and board/run/session lineage.
|
|
15
|
-
* - `file_lineage` — one row per observed file mutation with full
|
|
16
|
-
* session/agent/task/board/tool/model attribution.
|
|
17
|
-
* - `token_cost` — latest cumulative token.accounted cost snapshot per
|
|
18
|
-
* scope (same latest-wins semantics as the query
|
|
19
|
-
* engine's summary).
|
|
20
|
-
* - `daily_counters`, `family_daily`, `agent_daily`, `logical_request_daily`,
|
|
21
|
-
* `file_seen_daily` — per-day scalar counters and dedup sets backing
|
|
22
|
-
* `defaultSummary()`, a `ChronicleSummary` for the common unfiltered/
|
|
23
|
-
* time-bounded dashboard view. Any genuinely ad hoc filter (free text,
|
|
24
|
-
* path, session, provider, model) falls back to the raw-scan summary in
|
|
25
|
-
* query.ts — fixed-dimension aggregation fundamentally can't answer those.
|
|
26
|
-
*
|
|
27
|
-
* The schema is a cache: on version mismatch it is dropped and re-ingested
|
|
28
|
-
* from whatever journal partitions still exist.
|
|
9
|
+
* raw JSONL partitions can be purged by retention without losing metrics.
|
|
29
10
|
*/
|
|
30
11
|
import type { ChronicleSummary } from './query.js';
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
ingestedBytes: number;
|
|
34
|
-
sourceFiles: number;
|
|
35
|
-
invalidLines: number;
|
|
36
|
-
}
|
|
37
|
-
export interface ChronicleProviderDailyRow {
|
|
38
|
-
day: string;
|
|
39
|
-
providerId: string;
|
|
40
|
-
modelId: string;
|
|
41
|
-
attempts: number;
|
|
42
|
-
completed: number;
|
|
43
|
-
failed: number;
|
|
44
|
-
retries: number;
|
|
45
|
-
fallbacks: number;
|
|
46
|
-
inputTokens: number;
|
|
47
|
-
outputTokens: number;
|
|
48
|
-
cacheReadTokens: number;
|
|
49
|
-
cacheWriteTokens: number;
|
|
50
|
-
avgDurationMs: number;
|
|
51
|
-
maxDurationMs: number;
|
|
52
|
-
}
|
|
53
|
-
export interface ChronicleTaskOutcomeRow {
|
|
54
|
-
taskId: string;
|
|
55
|
-
runId: string;
|
|
56
|
-
boardId: string;
|
|
57
|
-
sessionId: string;
|
|
58
|
-
agentId: string;
|
|
59
|
-
status: string;
|
|
60
|
-
startedAt: string | null;
|
|
61
|
-
endedAt: string | null;
|
|
62
|
-
durationMs: number | null;
|
|
63
|
-
retries: number;
|
|
64
|
-
verificationFailures: number;
|
|
65
|
-
filesTouched: number;
|
|
66
|
-
}
|
|
67
|
-
export interface ChronicleFileLineageRow {
|
|
68
|
-
path: string;
|
|
69
|
-
operation: string;
|
|
70
|
-
occurredAt: string;
|
|
71
|
-
sessionId: string;
|
|
72
|
-
agentId: string;
|
|
73
|
-
taskId: string;
|
|
74
|
-
boardId: string;
|
|
75
|
-
runId: string;
|
|
76
|
-
toolName: string;
|
|
77
|
-
providerId: string;
|
|
78
|
-
modelId: string;
|
|
79
|
-
source: string;
|
|
80
|
-
}
|
|
81
|
-
export interface ChronicleMetricsSummary {
|
|
82
|
-
providers: {
|
|
83
|
-
attempts: number;
|
|
84
|
-
completed: number;
|
|
85
|
-
failed: number;
|
|
86
|
-
successRate: number;
|
|
87
|
-
};
|
|
88
|
-
tasks: Record<string, number>;
|
|
89
|
-
files: {
|
|
90
|
-
mutations: number;
|
|
91
|
-
uniquePaths: number;
|
|
92
|
-
};
|
|
93
|
-
estimatedCostUsd: number;
|
|
94
|
-
}
|
|
95
|
-
/** Non-throwing availability probe for callers that degrade gracefully. */
|
|
96
|
-
export declare function isChronicleMetricsAvailable(): boolean;
|
|
12
|
+
import { isChronicleMetricsAvailable, type ChronicleFileLineageRow, type ChronicleMetricsRefreshResult, type ChronicleMetricsSummary, type ChronicleProviderDailyRow, type ChronicleTaskOutcomeRow } from './metrics-schema.js';
|
|
13
|
+
export { isChronicleMetricsAvailable, type ChronicleFileLineageRow, type ChronicleMetricsRefreshResult, type ChronicleMetricsSummary, type ChronicleProviderDailyRow, type ChronicleTaskOutcomeRow, };
|
|
97
14
|
export declare class ChronicleMetricsStore {
|
|
98
15
|
private readonly db;
|
|
99
16
|
private readonly directory;
|
|
100
17
|
private readonly dbPath;
|
|
18
|
+
private readonly ingester;
|
|
101
19
|
private constructor();
|
|
102
20
|
static open(chronicleDirectory: string): ChronicleMetricsStore;
|
|
103
21
|
close(): void;
|
|
@@ -127,44 +45,11 @@ export declare class ChronicleMetricsStore {
|
|
|
127
45
|
summary(): ChronicleMetricsSummary;
|
|
128
46
|
/**
|
|
129
47
|
* A `ChronicleSummary` for the default/unfiltered dashboard view — only
|
|
130
|
-
* `from`/`to` (day-precision) narrow it.
|
|
131
|
-
* path, provider, model, session) can't be answered from these
|
|
132
|
-
* fixed-dimension aggregates; callers must fall back to query.ts's
|
|
133
|
-
* raw-scan summary for those.
|
|
48
|
+
* `from`/`to` (day-precision) narrow it.
|
|
134
49
|
*/
|
|
135
50
|
defaultSummary(options?: {
|
|
136
51
|
from?: string;
|
|
137
52
|
to?: string;
|
|
138
53
|
}): ChronicleSummary;
|
|
139
|
-
private ensureSchema;
|
|
140
|
-
private loadOffsets;
|
|
141
|
-
private pruneOffsets;
|
|
142
|
-
/**
|
|
143
|
-
* Fold everything the SQLite journal holds past this store's per-day cursor.
|
|
144
|
-
*
|
|
145
|
-
* Opened read-only on its own connection: the journal runs in WAL, so this
|
|
146
|
-
* never blocks the daemon writing to it, and metrics are best-effort — a
|
|
147
|
-
* journal that cannot be opened (mid-migration, absent, locked) leaves the
|
|
148
|
-
* cursors untouched and the next refresh retries.
|
|
149
|
-
*
|
|
150
|
-
* Rows the journal has already evicted are simply not seen. That is the
|
|
151
|
-
* intended split of responsibilities: the journal is a bounded ring, and this
|
|
152
|
-
* store is where an aggregate outlives the raw event it came from — which
|
|
153
|
-
* only holds if refresh runs more often than the ring turns over.
|
|
154
|
-
*/
|
|
155
|
-
private ingestSqliteJournal;
|
|
156
|
-
/** Read complete lines appended after `consumed` bytes. The trailing
|
|
157
|
-
* partial line of an actively-written partition is left for the next
|
|
158
|
-
* refresh — `ingest_state.bytes` only ever advances past full lines. */
|
|
159
|
-
private ingestFile;
|
|
160
|
-
private ingestEvent;
|
|
161
|
-
/** Runs for every ingested event (not just the type-specific branches
|
|
162
|
-
* below) — mirrors query.ts's updateSummary() closely enough that
|
|
163
|
-
* defaultSummary() matches what a raw scan of the same window would say. */
|
|
164
|
-
private ingestDailyCounters;
|
|
165
|
-
private ingestProvider;
|
|
166
|
-
private ingestTokenCost;
|
|
167
|
-
private ingestTask;
|
|
168
|
-
private ingestFileEvent;
|
|
169
54
|
}
|
|
170
55
|
//# sourceMappingURL=metrics-store.d.ts.map
|