@phnx-labs/agents-cli 1.22.42 → 1.22.44
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/CHANGELOG.md +149 -0
- package/README.md +15 -13
- package/dist/bootstrap.js +33 -13
- package/dist/cli/command-registry.d.ts +0 -8
- package/dist/cli/command-registry.js +1 -25
- package/dist/commands/alias.d.ts +7 -4
- package/dist/commands/alias.js +33 -8
- package/dist/commands/apply.d.ts +7 -10
- package/dist/commands/apply.js +15 -35
- package/dist/commands/artifacts.js +4 -5
- package/dist/commands/audit.d.ts +6 -6
- package/dist/commands/audit.js +12 -12
- package/dist/commands/auth.js +14 -6
- package/dist/commands/beta.d.ts +7 -1
- package/dist/commands/beta.js +16 -9
- package/dist/commands/commands.js +1 -1
- package/dist/commands/computer.js +20 -6
- package/dist/commands/daemon.js +1 -1
- package/dist/commands/doctor.d.ts +4 -2
- package/dist/commands/doctor.js +21 -9
- package/dist/commands/events.d.ts +2 -2
- package/dist/commands/events.js +6 -5
- package/dist/commands/exec.d.ts +1 -1
- package/dist/commands/exec.js +11 -6
- package/dist/commands/factory.d.ts +1 -1
- package/dist/commands/feed.js +1 -30
- package/dist/commands/fleet-capture.d.ts +1 -1
- package/dist/commands/fleet-capture.js +4 -5
- package/dist/commands/harness.js +4 -52
- package/dist/commands/hooks.js +1 -1
- package/dist/commands/insights.d.ts +1 -1
- package/dist/commands/insights.js +3 -2
- package/dist/commands/menubar.js +58 -1
- package/dist/commands/monitors.js +1 -1
- package/dist/commands/org.d.ts +5 -0
- package/dist/commands/org.js +83 -29
- package/dist/commands/output.js +2 -2
- package/dist/commands/profiles.js +2 -2
- package/dist/commands/prune.js +5 -4
- package/dist/commands/routines.js +43 -25
- package/dist/commands/routines.test-fixture.d.ts +86 -0
- package/dist/commands/routines.test-fixture.js +345 -0
- package/dist/commands/sessions-picker.js +124 -122
- package/dist/commands/sessions.test-fixture.d.ts +24 -0
- package/dist/commands/sessions.test-fixture.js +224 -0
- package/dist/commands/setup.js +9 -1
- package/dist/commands/share.d.ts +9 -10
- package/dist/commands/share.js +68 -50
- package/dist/commands/skills.js +1 -1
- package/dist/commands/snapshot.d.ts +1 -1
- package/dist/commands/snapshot.js +4 -4
- package/dist/commands/ssh.js +15 -62
- package/dist/commands/status.d.ts +4 -2
- package/dist/commands/status.js +10 -7
- package/dist/commands/subagents.js +1 -1
- package/dist/commands/sync.d.ts +1 -0
- package/dist/commands/sync.js +29 -2
- package/dist/commands/view.js +11 -2
- package/dist/commands/webhook.js +1 -1
- package/dist/lib/accounting/rotate.d.ts +5 -3
- package/dist/lib/accounting/rotate.js +36 -7
- package/dist/lib/accounting/usage.d.ts +18 -4
- package/dist/lib/accounting/usage.js +138 -27
- package/dist/lib/agent-spec/agents.d.ts +7 -7
- package/dist/lib/agent-spec/agents.js +15 -15
- package/dist/lib/analytics/mix-commands.d.ts +6 -28
- package/dist/lib/analytics/mix-commands.js +14 -40
- package/dist/lib/audit/log.d.ts +2 -2
- package/dist/lib/audit/log.js +2 -2
- package/dist/lib/beta.js +1 -1
- package/dist/lib/browser/domain-skills.d.ts +26 -6
- package/dist/lib/browser/domain-skills.js +81 -43
- package/dist/lib/cloud/rush.d.ts +0 -15
- package/dist/lib/cloud/rush.js +0 -35
- package/dist/lib/crabbox/runtimes.d.ts +6 -2
- package/dist/lib/crabbox/runtimes.js +21 -5
- package/dist/lib/daemon/daemon.js +97 -58
- package/dist/lib/daemon/daemon.test-fixture.d.ts +24 -0
- package/dist/lib/daemon/daemon.test-fixture.js +71 -0
- package/dist/lib/daemon/runner.d.ts +18 -1
- package/dist/lib/daemon/runner.js +105 -11
- package/dist/lib/daemon-ticks.d.ts +38 -1
- package/dist/lib/daemon-ticks.js +52 -5
- package/dist/lib/device-config.js +1 -2
- package/dist/lib/devices/discovery-policy.d.ts +3 -3
- package/dist/lib/devices/discovery-policy.js +3 -3
- package/dist/lib/devices/doctor-findings.js +1 -1
- package/dist/lib/devices/fleet.d.ts +4 -8
- package/dist/lib/devices/fleet.js +3 -15
- package/dist/lib/devices/health-report.js +4 -4
- package/dist/lib/devices/pool.d.ts +0 -6
- package/dist/lib/devices/pool.js +0 -6
- package/dist/lib/devices/registry.d.ts +0 -15
- package/dist/lib/devices/registry.js +0 -9
- package/dist/lib/devices/stats-cache.d.ts +12 -0
- package/dist/lib/devices/stats-cache.js +24 -5
- package/dist/lib/drift-sync.d.ts +1 -1
- package/dist/lib/drift-sync.js +2 -2
- package/dist/lib/drift.d.ts +1 -1
- package/dist/lib/exec.js +13 -3
- package/dist/lib/fleet/capture.d.ts +1 -1
- package/dist/lib/fleet/manifest.js +1 -1
- package/dist/lib/fleet/remote-login.d.ts +2 -2
- package/dist/lib/fleet/remote-login.js +3 -4
- package/dist/lib/format.d.ts +9 -0
- package/dist/lib/format.js +16 -0
- package/dist/lib/github/pr-mergeable.d.ts +49 -0
- package/dist/lib/github/pr-mergeable.js +157 -0
- package/dist/lib/github/pr-verdict.d.ts +67 -0
- package/dist/lib/github/pr-verdict.js +72 -0
- package/dist/lib/harness/adapter.d.ts +6 -5
- package/dist/lib/hosts/dispatch.d.ts +2 -0
- package/dist/lib/hosts/dispatch.js +8 -1
- package/dist/lib/hosts/passthrough.d.ts +10 -0
- package/dist/lib/hosts/passthrough.js +28 -7
- package/dist/lib/hosts/providers/devices.js +1 -13
- package/dist/lib/hosts/ready.d.ts +12 -3
- package/dist/lib/hosts/ready.js +27 -12
- package/dist/lib/hosts/registry.d.ts +4 -5
- package/dist/lib/hosts/registry.js +3 -7
- package/dist/lib/hosts/session-index.js +1 -1
- package/dist/lib/installations/shims.js +1 -1
- package/dist/lib/installations/versions.d.ts +40 -0
- package/dist/lib/installations/versions.js +78 -4
- package/dist/lib/menubar/MenubarHelper.app/Contents/Info.plist +1 -5
- package/dist/lib/menubar/MenubarHelper.app/Contents/MacOS/MenubarHelper +0 -0
- package/dist/lib/menubar/MenubarHelper.app/Contents/_CodeSignature/CodeResources +2 -15
- package/dist/lib/menubar/install-menubar.d.ts +109 -0
- package/dist/lib/menubar/install-menubar.js +218 -12
- package/dist/lib/monitors/config.d.ts +2 -2
- package/dist/lib/monitors/config.js +3 -2
- package/dist/lib/origin-machine.d.ts +18 -0
- package/dist/lib/origin-machine.js +34 -0
- package/dist/lib/perf/db.js +1 -1
- package/dist/lib/perf/spool.js +1 -1
- package/dist/lib/prix-account.d.ts +2 -1
- package/dist/lib/prix-account.js +2 -1
- package/dist/lib/profiles.d.ts +7 -0
- package/dist/lib/profiles.js +26 -1
- package/dist/lib/remote-agents-json.js +1 -7
- package/dist/lib/routines-placement.d.ts +1 -1
- package/dist/lib/routines-placement.js +1 -1
- package/dist/lib/sandbox.d.ts +24 -0
- package/dist/lib/sandbox.js +101 -0
- package/dist/lib/scheduling/routines.d.ts +18 -9
- package/dist/lib/scheduling/routines.js +16 -8
- package/dist/lib/secrets/Agents CLI.app/Contents/CodeResources +0 -0
- package/dist/lib/secrets/Agents CLI.app/Contents/Info.plist +0 -2
- package/dist/lib/secrets/Agents CLI.app/Contents/MacOS/Agents CLI +0 -0
- package/dist/lib/secrets/Agents CLI.app/Contents/_CodeSignature/CodeResources +1 -13
- package/dist/lib/secrets/agent.js +9 -1
- package/dist/lib/secrets/index.js +1 -1
- package/dist/lib/secrets/list-filter.js +1 -1
- package/dist/lib/service-manifest.d.ts +20 -0
- package/dist/lib/service-manifest.js +34 -0
- package/dist/lib/session/active.d.ts +4 -16
- package/dist/lib/session/active.js +2 -6
- package/dist/lib/session/cloud.js +1 -1
- package/dist/lib/session/db.d.ts +13 -98
- package/dist/lib/session/db.js +5 -12
- package/dist/lib/session/discover.d.ts +5 -81
- package/dist/lib/session/discover.js +5 -5
- package/dist/lib/session/fork.js +1 -1
- package/dist/lib/session/live-metadata.js +1 -1
- package/dist/lib/session/origin-machine.d.ts +1 -18
- package/dist/lib/session/origin-machine.js +4 -34
- package/dist/lib/session/relative-time.d.ts +1 -44
- package/dist/lib/session/relative-time.js +4 -120
- package/dist/lib/session/remote/remote-bundle.d.ts +12 -0
- package/dist/lib/session/remote/remote-bundle.js +61 -0
- package/dist/lib/session/remote/remote-list.d.ts +148 -0
- package/dist/lib/session/remote/remote-list.js +607 -0
- package/dist/lib/session/remote/remote.d.ts +132 -0
- package/dist/lib/session/remote/remote.js +314 -0
- package/dist/lib/session/remote/watch.d.ts +101 -0
- package/dist/lib/session/remote/watch.js +241 -0
- package/dist/lib/session/remote-bundle.d.ts +1 -12
- package/dist/lib/session/remote-bundle.js +3 -61
- package/dist/lib/session/remote-list.d.ts +1 -148
- package/dist/lib/session/remote-list.js +3 -607
- package/dist/lib/session/remote.d.ts +1 -132
- package/dist/lib/session/remote.js +3 -314
- package/dist/lib/session/short-id.d.ts +1 -17
- package/dist/lib/session/short-id.js +4 -20
- package/dist/lib/session/watch.d.ts +1 -101
- package/dist/lib/session/watch.js +3 -242
- package/dist/lib/session/width.d.ts +1 -29
- package/dist/lib/session/width.js +4 -101
- package/dist/lib/share/config.d.ts +12 -2
- package/dist/lib/share/config.js +47 -11
- package/dist/lib/share/delete.js +1 -1
- package/dist/lib/share/publish.js +1 -1
- package/dist/lib/share/worker-template.js +2 -2
- package/dist/lib/smart-launch.d.ts +4 -4
- package/dist/lib/smart-launch.js +8 -18
- package/dist/lib/snapshot.d.ts +2 -2
- package/dist/lib/snapshot.js +1 -1
- package/dist/lib/staleness/index.d.ts +3 -1
- package/dist/lib/staleness/index.js +21 -1
- package/dist/lib/staleness/types.d.ts +11 -0
- package/dist/lib/staleness/writers/commands.js +13 -4
- package/dist/lib/staleness/writers/hooks.js +3 -1
- package/dist/lib/staleness/writers/mcp.d.ts +0 -7
- package/dist/lib/staleness/writers/mcp.js +16 -1
- package/dist/lib/staleness/writers/rules.js +1 -1
- package/dist/lib/staleness/writers/skills.js +3 -1
- package/dist/lib/staleness/writers/subagents.d.ts +0 -9
- package/dist/lib/staleness/writers/subagents.js +18 -1
- package/dist/lib/staleness/writers/types.d.ts +10 -0
- package/dist/lib/startup/command-registry.d.ts +10 -1
- package/dist/lib/startup/command-registry.js +26 -7
- package/dist/lib/startup/root-command.d.ts +18 -1
- package/dist/lib/startup/root-command.js +18 -1
- package/dist/lib/state.js +7 -0
- package/dist/lib/teams/placement-probe.js +28 -13
- package/dist/lib/teams/scheduler.d.ts +3 -1
- package/dist/lib/teams/scheduler.js +1 -1
- package/dist/lib/text/relative-time.d.ts +44 -0
- package/dist/lib/text/relative-time.js +120 -0
- package/dist/lib/text/short-id.d.ts +17 -0
- package/dist/lib/text/short-id.js +20 -0
- package/dist/lib/text/width.d.ts +29 -0
- package/dist/lib/text/width.js +101 -0
- package/dist/lib/triggers/handlers.d.ts +7 -0
- package/dist/lib/triggers/handlers.js +8 -0
- package/dist/lib/triggers/webhook.d.ts +1 -0
- package/dist/lib/triggers/webhook.js +2 -1
- package/dist/lib/types.d.ts +1 -1
- package/dist/lib/view-types.d.ts +7 -0
- package/package.json +2 -3
- package/dist/bin/agents +0 -0
- package/dist/commands/serve.d.ts +0 -10
- package/dist/commands/serve.js +0 -68
- package/dist/commands/tickets.d.ts +0 -2
- package/dist/commands/tickets.js +0 -43
- package/dist/commands/trends.d.ts +0 -10
- package/dist/commands/trends.js +0 -12
- package/dist/lib/menubar/MenubarHelper.app/Contents/CodeResources +0 -0
- package/dist/lib/menubar/MenubarHelper.app/Contents/Resources/AppIcon.icns +0 -0
- package/dist/lib/observe-aliases.d.ts +0 -30
- package/dist/lib/observe-aliases.js +0 -38
- package/dist/lib/secrets/Agents CLI.app/Contents/Resources/AppIcon.icns +0 -0
- package/dist/lib/serve/control.d.ts +0 -95
- package/dist/lib/serve/control.js +0 -260
- package/dist/lib/serve/data.d.ts +0 -81
- package/dist/lib/serve/data.js +0 -91
- package/dist/lib/serve/page.d.ts +0 -7
- package/dist/lib/serve/page.js +0 -140
- package/dist/lib/serve/server.d.ts +0 -80
- package/dist/lib/serve/server.js +0 -145
- package/dist/lib/serve/stream.d.ts +0 -43
- package/dist/lib/serve/stream.js +0 -116
- package/dist/lib/serve/token.d.ts +0 -35
- package/dist/lib/serve/token.js +0 -85
- package/dist/lib/tickets/list.d.ts +0 -53
- package/dist/lib/tickets/list.js +0 -153
package/dist/lib/session/db.d.ts
CHANGED
|
@@ -13,13 +13,6 @@ import { type IndexedToolCall } from './tool-calls.js';
|
|
|
13
13
|
* assert against the constant instead of hardcoding a number that every bump
|
|
14
14
|
* then has to chase (docs/sessions.md calls the constant the source of truth). */
|
|
15
15
|
export declare const SCHEMA_VERSION = 39;
|
|
16
|
-
/**
|
|
17
|
-
* Bump to force `agents sessions backfill resources` to re-derive every
|
|
18
|
-
* session's skill/slash-command tallies on its next run (resource_scan_ledger
|
|
19
|
-
* rows with a lower version are treated as stale — the same mechanism
|
|
20
|
-
* TOOL_INDEX_VERSION gives the tool backfill).
|
|
21
|
-
*/
|
|
22
|
-
export declare const RESOURCE_INDEX_VERSION = 1;
|
|
23
16
|
/**
|
|
24
17
|
* Bumping this invalidates every cached facet row without touching the schema
|
|
25
18
|
* version, so a change to the extraction logic (a new metric, a corrected bucket)
|
|
@@ -28,67 +21,6 @@ export declare const RESOURCE_INDEX_VERSION = 1;
|
|
|
28
21
|
*/
|
|
29
22
|
/** Bump when facet extraction changes so cached rows recompute (stalls-by-model v6). */
|
|
30
23
|
export declare const INSIGHTS_EXTRACTOR_VERSION = 6;
|
|
31
|
-
export declare const PREVIEW_EXTRACTOR_VERSION = 1;
|
|
32
|
-
/** Raw row shape returned from the sessions table. */
|
|
33
|
-
export interface SessionRow {
|
|
34
|
-
id: string;
|
|
35
|
-
short_id: string;
|
|
36
|
-
agent: string;
|
|
37
|
-
origin: string | null;
|
|
38
|
-
routine_name: string | null;
|
|
39
|
-
routine_run_id: string | null;
|
|
40
|
-
version: string | null;
|
|
41
|
-
account: string | null;
|
|
42
|
-
account_key: string | null;
|
|
43
|
-
account_org: string | null;
|
|
44
|
-
mode: string | null;
|
|
45
|
-
timestamp: string;
|
|
46
|
-
last_activity: string | null;
|
|
47
|
-
project: string | null;
|
|
48
|
-
cwd: string | null;
|
|
49
|
-
git_branch: string | null;
|
|
50
|
-
topic: string | null;
|
|
51
|
-
label: string | null;
|
|
52
|
-
message_count: number | null;
|
|
53
|
-
token_count: number | null;
|
|
54
|
-
output_tokens: number | null;
|
|
55
|
-
input_tokens: number | null;
|
|
56
|
-
cache_read_tokens: number | null;
|
|
57
|
-
cache_write_tokens: number | null;
|
|
58
|
-
cost_usd: number | null;
|
|
59
|
-
cost_usd_nocache: number | null;
|
|
60
|
-
duration_ms: number | null;
|
|
61
|
-
model: string | null;
|
|
62
|
-
tool_call_count: number | null;
|
|
63
|
-
file_path: string;
|
|
64
|
-
file_mtime_ms: number | null;
|
|
65
|
-
file_size: number | null;
|
|
66
|
-
scanned_at: number | null;
|
|
67
|
-
is_team_origin: number;
|
|
68
|
-
pr_url: string | null;
|
|
69
|
-
pr_number: number | null;
|
|
70
|
-
worktree_slug: string | null;
|
|
71
|
-
ticket_id: string | null;
|
|
72
|
-
spawned_team: string | null;
|
|
73
|
-
plan: string | null;
|
|
74
|
-
machine: string | null;
|
|
75
|
-
todos: string | null;
|
|
76
|
-
recent_directories_touched: string | null;
|
|
77
|
-
linear_project: string | null;
|
|
78
|
-
linear_project_url: string | null;
|
|
79
|
-
actor: string | null;
|
|
80
|
-
initiated_by: string | null;
|
|
81
|
-
/** NULL means "not yet computed" (a row scanned before this field existed) — see rowToMeta. */
|
|
82
|
-
used_browser: number | null;
|
|
83
|
-
used_computer: number | null;
|
|
84
|
-
/**
|
|
85
|
-
* Epoch ms the transcript file was first confirmed gone while content survived
|
|
86
|
-
* (RUSH-2436); NULL = live/never archived. Optional because the scanner upsert
|
|
87
|
-
* write-payload never sets it — the INSERT column list omits it, so a rescan
|
|
88
|
-
* preserves the sticky stamp; it is written only by querySessions.
|
|
89
|
-
*/
|
|
90
|
-
archived_at?: number | null;
|
|
91
|
-
}
|
|
92
24
|
/** File stat snapshot used to detect changes between scan runs. */
|
|
93
25
|
export interface ScanStamp {
|
|
94
26
|
fileMtimeMs: number;
|
|
@@ -143,7 +75,7 @@ export interface QueryOptions {
|
|
|
143
75
|
export declare function getDB(): Database.Database;
|
|
144
76
|
/** Close the cached database connection. */
|
|
145
77
|
export declare function closeDB(): void;
|
|
146
|
-
|
|
78
|
+
interface FtsOptimizeResult {
|
|
147
79
|
table: string;
|
|
148
80
|
segmentsBefore: number;
|
|
149
81
|
segmentsAfter: number;
|
|
@@ -224,7 +156,7 @@ export declare function getScanStampsForPaths(filePaths: string[]): Map<string,
|
|
|
224
156
|
* written by the Claude scan (B-2) and consumed on the next scan to decide
|
|
225
157
|
* full-vs-incremental and to hydrate the resume.
|
|
226
158
|
*/
|
|
227
|
-
|
|
159
|
+
interface ParserStateRow {
|
|
228
160
|
parserState: string | null;
|
|
229
161
|
contentText: string | null;
|
|
230
162
|
fileMtimeMs: number;
|
|
@@ -348,7 +280,7 @@ export declare function querySessions(options?: QueryOptions): SessionMeta[];
|
|
|
348
280
|
/** Count sessions matching the given filter options. */
|
|
349
281
|
export declare function countSessions(options?: QueryOptions): number;
|
|
350
282
|
/** One grouped row in a cost/duration rollup. */
|
|
351
|
-
|
|
283
|
+
interface UsageRollupRow {
|
|
352
284
|
/**
|
|
353
285
|
* Grouping key value: the agent id, project name, ISO date (YYYY-MM-DD), or
|
|
354
286
|
* account identity (`claude:org=<uuid>` / `unattributed:<reason>`).
|
|
@@ -454,7 +386,7 @@ export type UsageRollupGroup = 'agent' | 'project' | 'day' | 'account';
|
|
|
454
386
|
* Account rotation is NOT done here — that stays on live rate-limit windows
|
|
455
387
|
* via `--strategy balanced` / rotate.ts.
|
|
456
388
|
*/
|
|
457
|
-
|
|
389
|
+
type AffinityGroup = 'machine' | 'agent' | 'machine_agent';
|
|
458
390
|
export interface AffinityRow {
|
|
459
391
|
/** Group key: machine name, agent id, or "machine\\tagent". */
|
|
460
392
|
key: string;
|
|
@@ -540,7 +472,7 @@ export declare function resourceUsageCoverage(): {
|
|
|
540
472
|
total: number;
|
|
541
473
|
};
|
|
542
474
|
/** Outcome of a resource-usage backfill run. */
|
|
543
|
-
|
|
475
|
+
interface ResourceBackfillResult {
|
|
544
476
|
/** Sessions considered (matched the filter, had a real transcript). */
|
|
545
477
|
scanned: number;
|
|
546
478
|
/** Sessions (re)parsed and written this run. */
|
|
@@ -585,7 +517,7 @@ export interface TeamSpawner {
|
|
|
585
517
|
*/
|
|
586
518
|
export declare function teamSpawners(): Map<string, TeamSpawner>;
|
|
587
519
|
/** A session with its cost, for the top-N-by-cost listing. */
|
|
588
|
-
|
|
520
|
+
interface TopCostSession {
|
|
589
521
|
meta: SessionMeta;
|
|
590
522
|
costUsd: number;
|
|
591
523
|
durationMs: number;
|
|
@@ -638,7 +570,7 @@ export declare function findSessionsById(idQuery: string, scope?: Pick<QueryOpti
|
|
|
638
570
|
*/
|
|
639
571
|
export declare function findSessionsByShortIds(shortIds: string[]): Map<string, SessionMeta>;
|
|
640
572
|
/** A single full-text search result with ranking score. */
|
|
641
|
-
|
|
573
|
+
interface FtsHit {
|
|
642
574
|
sessionId: string;
|
|
643
575
|
score: number;
|
|
644
576
|
matchedTerms: string[];
|
|
@@ -667,11 +599,6 @@ export declare function buildFtsQuery(input: string): {
|
|
|
667
599
|
* so "higher = better" is consistent across all tiers.
|
|
668
600
|
*/
|
|
669
601
|
export declare function ftsSearch(input: string, limit?: number): FtsHit[];
|
|
670
|
-
/** Return the total row counts for the sessions and FTS5 tables (diagnostic). */
|
|
671
|
-
export declare function getRowCount(): {
|
|
672
|
-
sessions: number;
|
|
673
|
-
textRows: number;
|
|
674
|
-
};
|
|
675
602
|
/**
|
|
676
603
|
* Rewrite file_path for all sessions whose path starts with oldPrefix, replacing
|
|
677
604
|
* it with newPrefix + the unchanged suffix. Also clears the matching scan_ledger
|
|
@@ -683,14 +610,14 @@ export declare function getRowCount(): {
|
|
|
683
610
|
*/
|
|
684
611
|
export declare function updateSessionFilePaths(oldPrefix: string, newPrefix: string): number;
|
|
685
612
|
/** Per-kind capture tallies for a browser task. Counts only -- never the bytes. */
|
|
686
|
-
|
|
613
|
+
interface BrowserCaptureCounts {
|
|
687
614
|
screenshot: number;
|
|
688
615
|
pdf: number;
|
|
689
616
|
recording: number;
|
|
690
617
|
download: number;
|
|
691
618
|
}
|
|
692
619
|
/** One durable browser-task row. `machine` defaults to this device. */
|
|
693
|
-
|
|
620
|
+
interface BrowserSessionRecord {
|
|
694
621
|
task: string;
|
|
695
622
|
profile: string;
|
|
696
623
|
sessionId?: string;
|
|
@@ -704,7 +631,7 @@ export interface BrowserSessionRecord {
|
|
|
704
631
|
capturesRemote?: string;
|
|
705
632
|
}
|
|
706
633
|
/** One durable computer-use invocation row. `machine` defaults to this device. */
|
|
707
|
-
|
|
634
|
+
interface ComputerSessionRecord {
|
|
708
635
|
invocationId: string;
|
|
709
636
|
sessionId?: string;
|
|
710
637
|
launchId?: string;
|
|
@@ -743,7 +670,7 @@ export declare function recordBrowserSession(record: BrowserSessionRecord): void
|
|
|
743
670
|
*/
|
|
744
671
|
export declare function recordComputerSession(record: ComputerSessionRecord): void;
|
|
745
672
|
/** A stored browser row as read back, with counts rehydrated. */
|
|
746
|
-
|
|
673
|
+
interface StoredBrowserSession extends Required<Pick<BrowserSessionRecord, 'task' | 'profile'>> {
|
|
747
674
|
sessionId?: string;
|
|
748
675
|
launchId?: string;
|
|
749
676
|
actor?: string;
|
|
@@ -771,7 +698,7 @@ export declare function listBrowserSessionRecords(profile?: string, opts?: {
|
|
|
771
698
|
/** One stored browser task by its (profile, task) key, or null. */
|
|
772
699
|
export declare function getBrowserSessionRecord(profile: string, task: string): StoredBrowserSession | null;
|
|
773
700
|
/** A stored computer-use invocation as read back. */
|
|
774
|
-
|
|
701
|
+
interface StoredComputerSession {
|
|
775
702
|
invocationId: string;
|
|
776
703
|
sessionId?: string;
|
|
777
704
|
launchId?: string;
|
|
@@ -782,19 +709,6 @@ export interface StoredComputerSession {
|
|
|
782
709
|
actionCount: number;
|
|
783
710
|
taskPreview?: string;
|
|
784
711
|
}
|
|
785
|
-
/**
|
|
786
|
-
* Retention for the tool-session tables.
|
|
787
|
-
*
|
|
788
|
-
* These are the durable answer to a ledger that prunes at 7 days, so they are
|
|
789
|
-
* deliberately long-lived — but "durable" is not "unbounded". `computer_sessions`
|
|
790
|
-
* takes one row per `agents computer` CLI PROCESS (`COMPUTER_INVOCATION_ID` is
|
|
791
|
-
* minted per process), and an agent driving a desktop invokes that hundreds of
|
|
792
|
-
* times a day, so an unbounded table would grow without limit and be read in
|
|
793
|
-
* full on every listing.
|
|
794
|
-
*/
|
|
795
|
-
export declare const TOOL_SESSION_MAX_AGE_DAYS = 365;
|
|
796
|
-
/** Default ceiling on rows one listing will read. */
|
|
797
|
-
export declare const TOOL_SESSION_LIST_LIMIT = 2000;
|
|
798
712
|
/**
|
|
799
713
|
* Drop tool-session rows past {@link TOOL_SESSION_MAX_AGE_DAYS}.
|
|
800
714
|
*
|
|
@@ -813,3 +727,4 @@ export declare function listComputerSessionRecords(opts?: {
|
|
|
813
727
|
limit?: number;
|
|
814
728
|
startedBeforeMs?: number;
|
|
815
729
|
}): StoredComputerSession[];
|
|
730
|
+
export {};
|
package/dist/lib/session/db.js
CHANGED
|
@@ -13,7 +13,7 @@ import { parseSession, sessionFilePathContainer } from './parse.js';
|
|
|
13
13
|
import { extractRecentDirectoriesTouched, extractTodoProgressFromEvents } from './state.js';
|
|
14
14
|
import { getSessionsDir, getSessionsDbPath } from '../state.js';
|
|
15
15
|
import { query as queryEvents, queryToolUsageForSessions } from '../feed/events.js';
|
|
16
|
-
import { machineForSessionFile } from '
|
|
16
|
+
import { machineForSessionFile } from '../origin-machine.js';
|
|
17
17
|
import { loadSessionActorIndex, readSessionActorRecord } from './actor-sidecar.js';
|
|
18
18
|
import { toolCallsFromEvents } from './tool-calls.js';
|
|
19
19
|
import { persistToolCalls, toolEvidenceSourcePath } from './tool-store.js';
|
|
@@ -34,7 +34,7 @@ export const SCHEMA_VERSION = 39;
|
|
|
34
34
|
* rows with a lower version are treated as stale — the same mechanism
|
|
35
35
|
* TOOL_INDEX_VERSION gives the tool backfill).
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
const RESOURCE_INDEX_VERSION = 1;
|
|
38
38
|
/**
|
|
39
39
|
* Canonicalize a file path for use as a scan_ledger key. The same physical
|
|
40
40
|
* session file is reachable via multiple aliases — `~/.claude/projects/x.jsonl`
|
|
@@ -397,7 +397,7 @@ CREATE INDEX IF NOT EXISTS idx_computer_sessions_started ON computer_sessions(st
|
|
|
397
397
|
*/
|
|
398
398
|
/** Bump when facet extraction changes so cached rows recompute (stalls-by-model v6). */
|
|
399
399
|
export const INSIGHTS_EXTRACTOR_VERSION = 6;
|
|
400
|
-
|
|
400
|
+
const PREVIEW_EXTRACTOR_VERSION = 1;
|
|
401
401
|
let dbInstance = null;
|
|
402
402
|
/**
|
|
403
403
|
* Apply schema migrations from `fromVersion` → SCHEMA_VERSION. The new
|
|
@@ -3365,13 +3365,6 @@ export function ftsSearch(input, limit = 200) {
|
|
|
3365
3365
|
hits.sort((a, b) => b.score - a.score);
|
|
3366
3366
|
return hits.slice(0, limit);
|
|
3367
3367
|
}
|
|
3368
|
-
/** Return the total row counts for the sessions and FTS5 tables (diagnostic). */
|
|
3369
|
-
export function getRowCount() {
|
|
3370
|
-
const db = getDB();
|
|
3371
|
-
const sessions = db.prepare(`SELECT COUNT(*) AS c FROM sessions`).get().c;
|
|
3372
|
-
const textRows = db.prepare(`SELECT COUNT(*) AS c FROM session_text`).get().c;
|
|
3373
|
-
return { sessions, textRows };
|
|
3374
|
-
}
|
|
3375
3368
|
/**
|
|
3376
3369
|
* Rewrite file_path for all sessions whose path starts with oldPrefix, replacing
|
|
3377
3370
|
* it with newPrefix + the unchanged suffix. Also clears the matching scan_ledger
|
|
@@ -3520,9 +3513,9 @@ export function getBrowserSessionRecord(profile, task) {
|
|
|
3520
3513
|
* times a day, so an unbounded table would grow without limit and be read in
|
|
3521
3514
|
* full on every listing.
|
|
3522
3515
|
*/
|
|
3523
|
-
|
|
3516
|
+
const TOOL_SESSION_MAX_AGE_DAYS = 365;
|
|
3524
3517
|
/** Default ceiling on rows one listing will read. */
|
|
3525
|
-
|
|
3518
|
+
const TOOL_SESSION_LIST_LIMIT = 2000;
|
|
3526
3519
|
/**
|
|
3527
3520
|
* Drop tool-session rows past {@link TOOL_SESSION_MAX_AGE_DAYS}.
|
|
3528
3521
|
*
|
|
@@ -10,8 +10,6 @@ import type { SessionAgentId, SessionEvent, SessionMeta, TodoProgress } from './
|
|
|
10
10
|
export { machineForSessionFile } from './origin-machine.js';
|
|
11
11
|
import { type ScanStamp } from './db.js';
|
|
12
12
|
import { ToolCallCollector, type IndexedToolCall, type ToolCallCollectorSnapshot } from './tool-calls.js';
|
|
13
|
-
/** One JSONL record may not force an unbounded string allocation. */
|
|
14
|
-
export declare const SESSION_JSONL_LINE_MAX_BYTES: number;
|
|
15
13
|
/** Options controlling which sessions to discover and how to report progress. */
|
|
16
14
|
export interface DiscoverOptions {
|
|
17
15
|
agent?: SessionAgentId;
|
|
@@ -172,7 +170,7 @@ interface CodexSessionScan {
|
|
|
172
170
|
*/
|
|
173
171
|
export declare function discoverSessions(options?: DiscoverOptions): Promise<SessionMeta[]>;
|
|
174
172
|
/** What one incremental scan actually did. */
|
|
175
|
-
|
|
173
|
+
interface IncrementalScanResult {
|
|
176
174
|
/** True when this process won the single-flight claim and ran the scan. */
|
|
177
175
|
claimed: boolean;
|
|
178
176
|
/**
|
|
@@ -362,7 +360,7 @@ export declare function filterChangedFiles(filePaths: string[]): Array<{
|
|
|
362
360
|
scan: ScanStamp;
|
|
363
361
|
}>;
|
|
364
362
|
/** A path already stat'd by the walk — mtime is the raw (unfloored) fs value. */
|
|
365
|
-
|
|
363
|
+
interface PreStatEntry {
|
|
366
364
|
filePath: string;
|
|
367
365
|
fileMtimeMs: number;
|
|
368
366
|
fileSize: number;
|
|
@@ -378,64 +376,13 @@ export declare function filterChangedEntries(entries: PreStatEntry[]): Array<{
|
|
|
378
376
|
scan: ScanStamp;
|
|
379
377
|
}>;
|
|
380
378
|
export declare function shouldDeferRecentAppend(prev: ScanStamp, current: ScanStamp, nowMs: number, debounceMs?: number): boolean;
|
|
381
|
-
/** One leaf directory of transcripts to change-detect, plus its live-root flag. */
|
|
382
|
-
export interface LeafDir {
|
|
383
|
-
/** Absolute path to the directory that directly holds transcript files. */
|
|
384
|
-
dirPath: string;
|
|
385
|
-
/**
|
|
386
|
-
* True if this dir is under the agent's LIVE `~/.<agent>` root — the only tree
|
|
387
|
-
* an agent process appends to live. Every file in such a dir is treated as
|
|
388
|
-
* hot (always re-stat'd), so an in-place append is never missed there.
|
|
389
|
-
*/
|
|
390
|
-
isLiveRoot: boolean;
|
|
391
|
-
}
|
|
392
|
-
/** The changed files a leaf-dir walk surfaced, ready to parse + upsert. */
|
|
393
|
-
export interface LeafDirScan {
|
|
394
|
-
/** Files whose (mtime, size) changed vs the ledger — the parse set. */
|
|
395
|
-
changed: Array<{
|
|
396
|
-
filePath: string;
|
|
397
|
-
scan: ScanStamp;
|
|
398
|
-
}>;
|
|
399
|
-
/**
|
|
400
|
-
* Every transcript file seen across all leaf dirs (changed or not), in
|
|
401
|
-
* live-root-first order, each tagged with whether its dir is a live root.
|
|
402
|
-
* Lets a caller restore cross-root, session-id precedence (prefer the live
|
|
403
|
-
* copy of a session over a frozen backup copy) independent of which copy
|
|
404
|
-
* happened to be flagged "changed" this run.
|
|
405
|
-
*/
|
|
406
|
-
allFiles: Array<{
|
|
407
|
-
filePath: string;
|
|
408
|
-
isLiveRoot: boolean;
|
|
409
|
-
}>;
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Walk a set of leaf transcript directories and return the files that changed,
|
|
413
|
-
* skipping the per-file `stat` of directories whose (mtime, entry_count) matches
|
|
414
|
-
* the dir_ledger.
|
|
415
|
-
*
|
|
416
|
-
* Per leaf dir:
|
|
417
|
-
* - `stat` the dir once and `readdir` it (one cheap syscall) to get the entry
|
|
418
|
-
* count and the file list.
|
|
419
|
-
* - If the dir matches the dir_ledger (floored mtime AND entry_count), no file
|
|
420
|
-
* was created / deleted / renamed since we last walked it. We then stat ONLY
|
|
421
|
-
* the hot files (live-root files, or files scanned within HOT_FILE_WINDOW_MS)
|
|
422
|
-
* and run just those through the ledger compare — so an in-place append to a
|
|
423
|
-
* still-live session is still caught, while immutable backup/version dirs
|
|
424
|
-
* collapse to a single dir stat and zero per-file stats.
|
|
425
|
-
* - Else (changed dir, or no ledger row) we stat every file (today's full
|
|
426
|
-
* walk) and record the fresh dir stamp so the next run can short-circuit.
|
|
427
|
-
*
|
|
428
|
-
* The kill-switch (`AGENTS_SESSIONS_NO_DIR_LEDGER=1`) forces the full-walk branch
|
|
429
|
-
* for every dir and never consults or records the dir_ledger.
|
|
430
|
-
*/
|
|
431
|
-
export declare function collectChangedFilesInLeafDirs(leafDirs: LeafDir[], ext: string): LeafDirScan;
|
|
432
379
|
/**
|
|
433
380
|
* Collect all directories to scan for an agent's sessions. Deduplicates by
|
|
434
381
|
* realpath to avoid double-counting symlinked version homes.
|
|
435
382
|
*/
|
|
436
383
|
export declare function getAgentSessionDirs(agent: string, subdir: string): string[];
|
|
437
384
|
/** A session-agent's on-disk watch roots (every version home + backup mirror). */
|
|
438
|
-
|
|
385
|
+
interface SessionRoots {
|
|
439
386
|
agent: SessionAgentId;
|
|
440
387
|
/** Absolute directories that hold this agent's transcripts, existing right now. */
|
|
441
388
|
dirs: string[];
|
|
@@ -492,7 +439,7 @@ export declare function readCodexMeta(filePath: string, resolveAccount?: () => s
|
|
|
492
439
|
* both a full parse and a resumable incremental parse (see
|
|
493
440
|
* {@link scanClaudeSessionIncremental}).
|
|
494
441
|
*/
|
|
495
|
-
|
|
442
|
+
interface ClaudeParseState {
|
|
496
443
|
timestamp?: string;
|
|
497
444
|
cwd?: string;
|
|
498
445
|
gitBranch?: string;
|
|
@@ -680,7 +627,7 @@ export declare function __resetClaudeScanBranchCountsForTest(): void;
|
|
|
680
627
|
* fold ({@link applyCodexLine}) runs for both a full parse and an incremental
|
|
681
628
|
* resume. Mirrors {@link ClaudeParseState}.
|
|
682
629
|
*/
|
|
683
|
-
|
|
630
|
+
interface CodexParseState {
|
|
684
631
|
sessionId?: string;
|
|
685
632
|
timestamp?: string;
|
|
686
633
|
cwd?: string;
|
|
@@ -712,18 +659,6 @@ export interface CodexParseState {
|
|
|
712
659
|
}
|
|
713
660
|
/** Zero-value accumulator for a fresh (from-byte-0) Codex parse. */
|
|
714
661
|
export declare function initCodexParseState(): CodexParseState;
|
|
715
|
-
/**
|
|
716
|
-
* Fold one parsed Codex line into the accumulator — the exact loop body
|
|
717
|
-
* {@link scanCodexSession} used to run inline, extracted verbatim and mutating
|
|
718
|
-
* `state.*` in place. `parsed` is the already-`JSON.parse`d line (the
|
|
719
|
-
* malformed-line skip happens in the caller, as before).
|
|
720
|
-
*/
|
|
721
|
-
export declare function applyCodexLine(state: CodexParseState, parsed: any): void;
|
|
722
|
-
/**
|
|
723
|
-
* Build the {@link CodexSessionScan} return object from an accumulator — the
|
|
724
|
-
* exact return-building {@link scanCodexSession} used to run inline.
|
|
725
|
-
*/
|
|
726
|
-
export declare function finalizeCodexScan(state: CodexParseState): CodexSessionScan;
|
|
727
662
|
/**
|
|
728
663
|
* SERIALIZED continuation blob persisted in `scan_ledger.parser_state` for a
|
|
729
664
|
* Codex rollout. Carries everything {@link hydrateCodexParseState} needs to
|
|
@@ -769,17 +704,6 @@ export interface CodexParserState {
|
|
|
769
704
|
* incremental replay equals a full parse.
|
|
770
705
|
*/
|
|
771
706
|
export declare function serializeCodexParserState(state: CodexParseState, offset: number, jsonlDroppingOversizedLine?: boolean): CodexParserState;
|
|
772
|
-
/**
|
|
773
|
-
* Rebuild a live {@link CodexParseState} from a persisted continuation so that
|
|
774
|
-
* applying the appended lines yields the same accumulator a full parse would.
|
|
775
|
-
*
|
|
776
|
-
* `userTexts` is rehydrated as a single joined blob from `contentText`: only
|
|
777
|
-
* `userTexts.join('\n')` (detectTicket + contentText) and `userTexts.length > 0`
|
|
778
|
-
* are ever read downstream, and both are preserved by a one-element array
|
|
779
|
-
* holding the joined content. Topic is first-wins and already persisted, so a
|
|
780
|
-
* collapsed userTexts never changes it.
|
|
781
|
-
*/
|
|
782
|
-
export declare function hydrateCodexParseState(prior: CodexParserState): CodexParseState;
|
|
783
707
|
/**
|
|
784
708
|
* Resume a Codex parse from `fromOffset` bytes into the file, folding only the
|
|
785
709
|
* newly-appended lines into `prior`. Returns the finalized scan, the next
|
|
@@ -55,7 +55,7 @@ const MUSE_SESSIONS_DIR = path.join(HOME, '.local', 'share', 'muse', 'sessions')
|
|
|
55
55
|
const OPENCLAW_TTL_MS = 60_000;
|
|
56
56
|
const ACTIVE_APPEND_RESCAN_DEBOUNCE_MS = 5_000;
|
|
57
57
|
/** One JSONL record may not force an unbounded string allocation. */
|
|
58
|
-
|
|
58
|
+
const SESSION_JSONL_LINE_MAX_BYTES = 1024 * 1024;
|
|
59
59
|
/**
|
|
60
60
|
* Stream one appended JSONL range, applying only newline-terminated records.
|
|
61
61
|
* Memory is bounded to one record. An ordinary unterminated tail remains for the
|
|
@@ -728,7 +728,7 @@ export function shouldDeferRecentAppend(prev, current, nowMs, debounceMs = ACTIV
|
|
|
728
728
|
* The kill-switch (`AGENTS_SESSIONS_NO_DIR_LEDGER=1`) forces the full-walk branch
|
|
729
729
|
* for every dir and never consults or records the dir_ledger.
|
|
730
730
|
*/
|
|
731
|
-
|
|
731
|
+
function collectChangedFilesInLeafDirs(leafDirs, ext) {
|
|
732
732
|
const disabled = dirLedgerDisabled();
|
|
733
733
|
const dirStamps = disabled ? new Map() : getDirLedgerForPaths(leafDirs.map(d => d.dirPath));
|
|
734
734
|
const now = Date.now();
|
|
@@ -3619,7 +3619,7 @@ export function initCodexParseState() {
|
|
|
3619
3619
|
* `state.*` in place. `parsed` is the already-`JSON.parse`d line (the
|
|
3620
3620
|
* malformed-line skip happens in the caller, as before).
|
|
3621
3621
|
*/
|
|
3622
|
-
|
|
3622
|
+
function applyCodexLine(state, parsed) {
|
|
3623
3623
|
collectCodexToolCalls(state.toolCollector, parsed);
|
|
3624
3624
|
// PR signal, structurally: a Codex `function_call` whose command is
|
|
3625
3625
|
// `gh pr create`, then the pull URL from a `function_call_output`.
|
|
@@ -3730,7 +3730,7 @@ export function applyCodexLine(state, parsed) {
|
|
|
3730
3730
|
* Build the {@link CodexSessionScan} return object from an accumulator — the
|
|
3731
3731
|
* exact return-building {@link scanCodexSession} used to run inline.
|
|
3732
3732
|
*/
|
|
3733
|
-
|
|
3733
|
+
function finalizeCodexScan(state) {
|
|
3734
3734
|
// Codex reports one cumulative snapshot: uncached input, cached (cache-read)
|
|
3735
3735
|
// input, and output+reasoning. It has no cache-write bucket. Derive the burn
|
|
3736
3736
|
// split and both costs (actual + no-cache) from that final snapshot (RUSH-2287).
|
|
@@ -3869,7 +3869,7 @@ export function serializeCodexParserState(state, offset, jsonlDroppingOversizedL
|
|
|
3869
3869
|
* holding the joined content. Topic is first-wins and already persisted, so a
|
|
3870
3870
|
* collapsed userTexts never changes it.
|
|
3871
3871
|
*/
|
|
3872
|
-
|
|
3872
|
+
function hydrateCodexParseState(prior) {
|
|
3873
3873
|
return {
|
|
3874
3874
|
sessionId: prior.sessionId,
|
|
3875
3875
|
timestamp: prior.timestamp,
|
package/dist/lib/session/fork.js
CHANGED
|
@@ -19,7 +19,7 @@ import * as fs from 'fs';
|
|
|
19
19
|
import * as path from 'path';
|
|
20
20
|
import { upsertSession } from './db.js';
|
|
21
21
|
import { recordRunName } from './run-names.js';
|
|
22
|
-
import { deriveShortId } from '
|
|
22
|
+
import { deriveShortId } from '../text/short-id.js';
|
|
23
23
|
/** Agents that `fork` can branch today (see the module doc for why). */
|
|
24
24
|
export const FORKABLE_AGENTS = ['claude'];
|
|
25
25
|
/** Whether a session's agent can be forked by {@link forkSession}. */
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// state the live registry already computed. When the transcript IS on disk, the
|
|
17
17
|
// synthesized row carries its path, so the downstream `buildPreview` renders the
|
|
18
18
|
// real digest; otherwise it renders the header + a "not indexed here" note.
|
|
19
|
-
import { deriveShortId } from '
|
|
19
|
+
import { deriveShortId } from '../text/short-id.js';
|
|
20
20
|
import { isSessionTrackedAgent } from './types.js';
|
|
21
21
|
/**
|
|
22
22
|
* Reshape one live `ActiveSession` into a `SessionMeta` candidate for the id
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Resolve which machine a session transcript originated on.
|
|
3
|
-
*
|
|
4
|
-
* Cross-machine sync mirrors a remote transcript to
|
|
5
|
-
* `backups/<agent>/<machine>/<subdir>/…`. Every other transcript is a live-home
|
|
6
|
-
* file on this box, so the origin is the local machine id.
|
|
7
|
-
*
|
|
8
|
-
* Kept in a leaf module (no session/db imports) so both discovery and the
|
|
9
|
-
* sessions DB upsert path can stamp `machine` without circular deps.
|
|
10
|
-
*/
|
|
11
|
-
/** Local machine id, cached for the process lifetime. */
|
|
12
|
-
export declare function localMachineId(): string;
|
|
13
|
-
/**
|
|
14
|
-
* The machine a discovered session originated on.
|
|
15
|
-
* When the path sits under the agent's backups root, the first segment below it
|
|
16
|
-
* is the origin machine id; otherwise it's the local machine.
|
|
17
|
-
*/
|
|
18
|
-
export declare function machineForSessionFile(filePath: string, agent: string): string;
|
|
1
|
+
export * from '../origin-machine.js';
|
|
@@ -1,34 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* `backups/<agent>/<machine>/<subdir>/…`. Every other transcript is a live-home
|
|
6
|
-
* file on this box, so the origin is the local machine id.
|
|
7
|
-
*
|
|
8
|
-
* Kept in a leaf module (no session/db imports) so both discovery and the
|
|
9
|
-
* sessions DB upsert path can stamp `machine` without circular deps.
|
|
10
|
-
*/
|
|
11
|
-
import * as path from 'path';
|
|
12
|
-
import { getHistoryDir } from '../state.js';
|
|
13
|
-
import { machineId } from '../machine-id.js';
|
|
14
|
-
let _localMachineId;
|
|
15
|
-
/** Local machine id, cached for the process lifetime. */
|
|
16
|
-
export function localMachineId() {
|
|
17
|
-
return (_localMachineId ??= machineId());
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* The machine a discovered session originated on.
|
|
21
|
-
* When the path sits under the agent's backups root, the first segment below it
|
|
22
|
-
* is the origin machine id; otherwise it's the local machine.
|
|
23
|
-
*/
|
|
24
|
-
export function machineForSessionFile(filePath, agent) {
|
|
25
|
-
if (!filePath)
|
|
26
|
-
return localMachineId();
|
|
27
|
-
const base = path.join(getHistoryDir(), 'backups', agent) + path.sep;
|
|
28
|
-
if (filePath.startsWith(base)) {
|
|
29
|
-
const seg = filePath.slice(base.length).split(path.sep)[0];
|
|
30
|
-
if (seg)
|
|
31
|
-
return seg;
|
|
32
|
-
}
|
|
33
|
-
return localMachineId();
|
|
34
|
-
}
|
|
1
|
+
// Moved to ../origin-machine.ts (move 1 of the core-module refactor — see
|
|
2
|
+
// .agents/artifacts/2026-08-20/plan-*.md). Kept as a re-export shim so
|
|
3
|
+
// existing importers don't break.
|
|
4
|
+
export * from '../origin-machine.js';
|
|
@@ -1,44 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Human-readable "time since" formatting for session timestamps. Lives here (not
|
|
3
|
-
* inline in `sessions.ts`) so both the session list renderer and the remote
|
|
4
|
-
* offline-cache banner (`remote.ts`) share one formatter — `sessions.ts` imports
|
|
5
|
-
* `remote.ts`, so a back-import would cycle.
|
|
6
|
-
*/
|
|
7
|
-
export declare function formatRelativeTime(isoTimestamp: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Compact age — `now`, `45m`, `3h`, `2d`, then the calendar date. This is the
|
|
10
|
-
* *creation* half of a session's time cell: it renders right next to the long
|
|
11
|
-
* last-activity label, and one row can afford one long form, not two.
|
|
12
|
-
*/
|
|
13
|
-
export declare function formatCompactAge(isoTimestamp: string): string;
|
|
14
|
-
/** The two time fields a session listing shows for one row. */
|
|
15
|
-
export interface SessionAgeParts {
|
|
16
|
-
/**
|
|
17
|
-
* Compact age of the session's creation, set only when the session ran long
|
|
18
|
-
* enough (>= a minute) for it to say something `last` does not.
|
|
19
|
-
*/
|
|
20
|
-
created?: string;
|
|
21
|
-
/** Last-activity label — the long relative form the listing sorts by. */
|
|
22
|
-
last: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Split a session's timestamps into the two fields a listing renders: when it
|
|
26
|
-
* was created and when it was last active. One last-activity label answers
|
|
27
|
-
* neither "is this the old session I'm looking for" nor "how long did it run" —
|
|
28
|
-
* a session touched an hour ago may have started last week.
|
|
29
|
-
*/
|
|
30
|
-
export declare function sessionAgeParts(createdIso: string, lastActivityIso?: string): SessionAgeParts;
|
|
31
|
-
/**
|
|
32
|
-
* Parse a time filter string (relative like '7d' or an ISO timestamp) into epoch
|
|
33
|
-
* milliseconds. Backs `--since` on `sessions`, `cost`, `teams`, and `output`, and
|
|
34
|
-
* `--unused` on `secrets list`.
|
|
35
|
-
*
|
|
36
|
-
* It lives here, in a module with no imports, rather than in `discover.ts` where
|
|
37
|
-
* it started: `discover.ts` loads `../sqlite.js`, so importing this one function
|
|
38
|
-
* from there pulls `node:sqlite` into the caller's module graph and Node prints
|
|
39
|
-
* `ExperimentalWarning: SQLite …` on stderr. That is invisible in a command that
|
|
40
|
-
* already touches the session DB, and a broken contract in one that doesn't —
|
|
41
|
-
* `monitors --json` asserts a clean stderr. `discover.ts` re-exports it, so
|
|
42
|
-
* existing importers are unaffected.
|
|
43
|
-
*/
|
|
44
|
-
export declare function parseTimeFilter(input: string): number;
|
|
1
|
+
export * from '../text/relative-time.js';
|