@harness-nexus/cli 0.1.0-alpha.2 → 0.1.0-alpha.4
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/daemon/acp/adapters.d.ts.map +1 -1
- package/dist/daemon/acp/adapters.js +9 -3
- package/dist/daemon/acp/adapters.js.map +1 -1
- package/dist/daemon/acp/agent-connection.d.ts +67 -4
- package/dist/daemon/acp/agent-connection.d.ts.map +1 -1
- package/dist/daemon/acp/agent-connection.js +113 -9
- package/dist/daemon/acp/agent-connection.js.map +1 -1
- package/dist/daemon/adapter-ledger.d.ts +62 -0
- package/dist/daemon/adapter-ledger.d.ts.map +1 -0
- package/dist/daemon/adapter-ledger.js +207 -0
- package/dist/daemon/adapter-ledger.js.map +1 -0
- package/dist/daemon/chat.d.ts +33 -2
- package/dist/daemon/chat.d.ts.map +1 -1
- package/dist/daemon/chat.js +956 -42
- package/dist/daemon/chat.js.map +1 -1
- package/dist/daemon/client.d.ts +11 -2
- package/dist/daemon/client.d.ts.map +1 -1
- package/dist/daemon/client.js +122 -24
- package/dist/daemon/client.js.map +1 -1
- package/dist/daemon/config-view.d.ts +42 -0
- package/dist/daemon/config-view.d.ts.map +1 -0
- package/dist/daemon/config-view.js +159 -0
- package/dist/daemon/config-view.js.map +1 -0
- package/dist/daemon/dsh-sessions.d.ts +161 -0
- package/dist/daemon/dsh-sessions.d.ts.map +1 -0
- package/dist/daemon/dsh-sessions.js +674 -0
- package/dist/daemon/dsh-sessions.js.map +1 -0
- package/dist/daemon/dsh-tap/index.mjs +99 -0
- package/dist/daemon/dsh-tap-listener.d.ts +62 -0
- package/dist/daemon/dsh-tap-listener.d.ts.map +1 -0
- package/dist/daemon/dsh-tap-listener.js +196 -0
- package/dist/daemon/dsh-tap-listener.js.map +1 -0
- package/dist/daemon/jobs.d.ts +8 -5
- package/dist/daemon/jobs.d.ts.map +1 -1
- package/dist/daemon/jobs.js +28 -8
- package/dist/daemon/jobs.js.map +1 -1
- package/dist/daemon/runtime-config.d.ts +34 -0
- package/dist/daemon/runtime-config.d.ts.map +1 -0
- package/dist/daemon/runtime-config.js +347 -0
- package/dist/daemon/runtime-config.js.map +1 -0
- package/dist/daemon/runtime.d.ts +49 -0
- package/dist/daemon/runtime.d.ts.map +1 -0
- package/dist/daemon/runtime.js +218 -0
- package/dist/daemon/runtime.js.map +1 -0
- package/dist/daemon/sessions.d.ts +26 -0
- package/dist/daemon/sessions.d.ts.map +1 -0
- package/dist/daemon/sessions.js +169 -0
- package/dist/daemon/sessions.js.map +1 -0
- package/dist/daemon/workspace.d.ts +5 -0
- package/dist/daemon/workspace.d.ts.map +1 -0
- package/dist/daemon/workspace.js +44 -0
- package/dist/daemon/workspace.js.map +1 -0
- package/dist/install/adapters/deepseek.d.ts +4 -0
- package/dist/install/adapters/deepseek.d.ts.map +1 -1
- package/dist/install/adapters/deepseek.js +4 -2
- package/dist/install/adapters/deepseek.js.map +1 -1
- package/dist/inventory/common.d.ts +2 -0
- package/dist/inventory/common.d.ts.map +1 -1
- package/dist/inventory/common.js.map +1 -1
- package/dist/inventory/runtime.d.ts +40 -0
- package/dist/inventory/runtime.d.ts.map +1 -0
- package/dist/inventory/runtime.js +114 -0
- package/dist/inventory/runtime.js.map +1 -0
- package/dist/inventory/scanners/claude-code.d.ts +2 -0
- package/dist/inventory/scanners/claude-code.d.ts.map +1 -1
- package/dist/inventory/scanners/claude-code.js +103 -39
- package/dist/inventory/scanners/claude-code.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type { ChatStreamEvent, HistoryItem } from '@harness-nexus/shared';
|
|
2
|
+
export type FrameDecoder = (frame: Buffer) => Buffer;
|
|
3
|
+
/** The native `zlib.zstdDecompressSync`, or null on Node < 22.15. */
|
|
4
|
+
export declare function nativeZstd(): FrameDecoder | null;
|
|
5
|
+
/** Slice a concatenated-zstd buffer into its frames (magic scan). */
|
|
6
|
+
export declare function splitZstdFrames(buf: Buffer): Buffer[];
|
|
7
|
+
/**
|
|
8
|
+
* Decode every frame and parse the JSONL entries. Undecodable frames (a magic
|
|
9
|
+
* hit inside compressed data — ~2^-32 per position) and non-JSON lines are
|
|
10
|
+
* skipped, never fatal. Entries are capped so a runaway transcript can't
|
|
11
|
+
* exhaust memory.
|
|
12
|
+
*/
|
|
13
|
+
export declare function decodeTranscript(buf: Buffer, decompress: FrameDecoder, maxEntries?: number): Record<string, unknown>[];
|
|
14
|
+
export interface DshSessionSummary {
|
|
15
|
+
sessionId: string;
|
|
16
|
+
cwd: string;
|
|
17
|
+
title: string | null;
|
|
18
|
+
createdAt: string | null;
|
|
19
|
+
updatedAt: string | null;
|
|
20
|
+
/** The model route the session pinned (`request/header.config.model`). */
|
|
21
|
+
model: string | null;
|
|
22
|
+
}
|
|
23
|
+
interface DshHeader {
|
|
24
|
+
createdAt?: unknown;
|
|
25
|
+
cwd?: unknown;
|
|
26
|
+
delegationDepth?: unknown;
|
|
27
|
+
parentSession?: unknown;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Header + derived title + pinned model from the FRONT of a transcript
|
|
31
|
+
* (dsh's own `session/list` exposes none of these). Stops as soon as all are
|
|
32
|
+
* found; bounded read so a huge transcript costs at most `maxBytes`. NB: the
|
|
33
|
+
* `session` HEADER entry carries its fields at the TOP level (no `data`
|
|
34
|
+
* wrapper), unlike every other entry type.
|
|
35
|
+
*/
|
|
36
|
+
export declare function scanSummary(buf: Buffer, decompress: FrameDecoder, maxBytes?: number): {
|
|
37
|
+
header: DshHeader | null;
|
|
38
|
+
title: string | null;
|
|
39
|
+
model: string | null;
|
|
40
|
+
hasTurn: boolean;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* The model ids of OUR managed provider region in `~/.dsh/settings.yaml`
|
|
44
|
+
* (the W3 writer's own format — a `models:` list of `- id:` entries). Null
|
|
45
|
+
* when the region is absent/unparseable: the caller then annotates nothing.
|
|
46
|
+
*/
|
|
47
|
+
export declare function currentCatalogModels(settingsYaml: string): Set<string> | null;
|
|
48
|
+
export interface DshListFs {
|
|
49
|
+
readdir: (path: string) => string[];
|
|
50
|
+
readFile: (path: string) => Buffer;
|
|
51
|
+
stat: (path: string) => {
|
|
52
|
+
mtimeMs: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* List dsh's ROOT sessions (subagent sessions carry `parentSession`/depth and
|
|
57
|
+
* are dsh's own resume-exclusions). Pure given the fs shims; newest first.
|
|
58
|
+
*/
|
|
59
|
+
export declare function dshListSessions(sessionsDir: string, fs: DshListFs, decompress: FrameDecoder, opts?: {
|
|
60
|
+
maxSessions?: number;
|
|
61
|
+
}): DshSessionSummary[];
|
|
62
|
+
type UnknownRecord = Record<string, unknown>;
|
|
63
|
+
/** The usage marker of a verbatim `assistant/chunk` row (history path). */
|
|
64
|
+
export declare function usageFromChunk(entry: UnknownRecord): ChatStreamEvent | null;
|
|
65
|
+
/**
|
|
66
|
+
* The stateful LIVE mapper: one dsh transcript entry → 0..n stream events.
|
|
67
|
+
* Mirrors the semantics of dsh's own in-process bridge mapper (reference:
|
|
68
|
+
* `updates.js` `createEventMapper`, engine/storage shapes verified against
|
|
69
|
+
* dsh 0.1.2-rc.1 — the exact rig version):
|
|
70
|
+
*
|
|
71
|
+
* - Deltas arrive in TWO on-disk shapes: packed `text-chunks`/
|
|
72
|
+
* `reasoning-chunks` rows (runs of ≥3 seq-contiguous same-block deltas) and
|
|
73
|
+
* verbatim `assistant/chunk` events (shorter runs — the codec's MIN_RUN=3
|
|
74
|
+
* falls through). Both map; skipping either would silently drop content.
|
|
75
|
+
* - Committed `assistant/message` carries the step's dedup key: if deltas for
|
|
76
|
+
* that `turn:step` were already emitted, ONLY the usage rides through
|
|
77
|
+
* (re-sending the full block would double-render); if none were (late tail
|
|
78
|
+
* attach, block-only adapters), the complete blocks are emitted — the wire's
|
|
79
|
+
* committed chunk is suppressed while the tail is live, so this fallback is
|
|
80
|
+
* the only copy. Tool-call blocks are skipped: the `tool/call` row owns them.
|
|
81
|
+
* - Turn markers and user inputs never map live — the prompt response owns
|
|
82
|
+
* turn_result, and the browser echoes the user's own prompt.
|
|
83
|
+
*/
|
|
84
|
+
export type DshLiveMapper = (entry: UnknownRecord) => ChatStreamEvent[];
|
|
85
|
+
export declare function createDshLiveMapper(): DshLiveMapper;
|
|
86
|
+
/**
|
|
87
|
+
* Map dsh transcript entries onto history items (user blocks + ordinary
|
|
88
|
+
* stream events — ONE fold path in the browser). Genuine user turns are the
|
|
89
|
+
* `agent/inbox/spliced` inserts; `user/message` echoes and the synthesized
|
|
90
|
+
* runtime-context messages are skipped.
|
|
91
|
+
*/
|
|
92
|
+
export declare function dshHistoryItems(entries: UnknownRecord[]): HistoryItem[];
|
|
93
|
+
/** Locate a session's transcript by id across the slug dirs (null = absent). */
|
|
94
|
+
export declare function findTranscript(sessionsDir: string, sessionId: string, readdir: (path: string) => string[]): string | null;
|
|
95
|
+
/** The fs surface `TranscriptTail` needs (injectable for tests). */
|
|
96
|
+
export interface TailFs {
|
|
97
|
+
/** Current byte size, or null while the file is absent. */
|
|
98
|
+
size(path: string): number | null;
|
|
99
|
+
/** The bytes from `start` to the current end (may grow mid-call — fine). */
|
|
100
|
+
readEnd(path: string, start: number): Buffer;
|
|
101
|
+
}
|
|
102
|
+
/** Runtime knobs for `TranscriptTail`. */
|
|
103
|
+
export interface TailOptions {
|
|
104
|
+
/** Poll interval (default 250ms — dsh flushes write batches ~100–300ms apart). */
|
|
105
|
+
intervalMs?: number;
|
|
106
|
+
/**
|
|
107
|
+
* Fired when the file corrupts mid-stream (a bounded frame that fails to
|
|
108
|
+
* decode): the tail stops itself and the caller should fall back to the
|
|
109
|
+
* adapter's committed chunks (wire suppression must lift).
|
|
110
|
+
*/
|
|
111
|
+
onFatal?: (reason: string) => void;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Tails a dsh transcript for LIVE token streaming. Ground truth (dsh
|
|
115
|
+
* 0.1.2-rc.1 write path): every engine `assistant/chunk` event rides the
|
|
116
|
+
* session bus into a bounded write-behind batch (~100–300ms window) and lands
|
|
117
|
+
* as one zstd frame per batch — so polling the file yields token batches
|
|
118
|
+
* roughly one write window behind the model, while dsh's ACP adapter stays
|
|
119
|
+
* silent until commit. New bytes are split into frames, decoded, and mapped
|
|
120
|
+
* through a stateful `createDshLiveMapper` (packed rows AND verbatim chunk
|
|
121
|
+
* events, with the `turn:step` committed-dedup — see its doc).
|
|
122
|
+
*
|
|
123
|
+
* A trailing frame cut mid-write decodes only once its remaining bytes
|
|
124
|
+
* arrive: the last undecodable slice is buffered for the next poll (the
|
|
125
|
+
* writer completes it on the next batch or truncates it back on rollback).
|
|
126
|
+
* `start()` skips existing bytes (history was already rendered);
|
|
127
|
+
* `flush()` drains once more so a turn's final tokens stay ordered before
|
|
128
|
+
* its turn_result. A BOUNDED frame that fails to decode is corruption —
|
|
129
|
+
* `onFatal` fires and the tail stops (the committed path takes over).
|
|
130
|
+
*/
|
|
131
|
+
export declare class TranscriptTail {
|
|
132
|
+
private readonly file;
|
|
133
|
+
private readonly fs;
|
|
134
|
+
private readonly decompress;
|
|
135
|
+
private readonly onEvent;
|
|
136
|
+
private readonly opts;
|
|
137
|
+
private pending;
|
|
138
|
+
private timer;
|
|
139
|
+
private stopped;
|
|
140
|
+
private offset;
|
|
141
|
+
private readonly mapper;
|
|
142
|
+
/** Wall-clock of the last `turn/end` row seen (0 = none). */
|
|
143
|
+
private lastTurnEndAt;
|
|
144
|
+
constructor(file: string, fs: TailFs, decompress: FrameDecoder, onEvent: (event: ChatStreamEvent) => void, opts?: TailOptions);
|
|
145
|
+
/** Begin polling. `replayFromBeginning` re-maps the whole file instead of
|
|
146
|
+
* skipping existing bytes — valid ONLY when nothing in it was ever
|
|
147
|
+
* rendered (a lazily-materialized new-session transcript attached mid-turn:
|
|
148
|
+
* replaying recovers the deltas that landed before the attach; the
|
|
149
|
+
* caller guarantees no earlier turn ran through the committed path). */
|
|
150
|
+
start(replayFromBeginning?: boolean): void;
|
|
151
|
+
/** Whether a `turn/end` row landed since `since` (the settle signal). */
|
|
152
|
+
turnEndSeenSince(since: number): boolean;
|
|
153
|
+
/** One synchronous drain (call before settling a turn). */
|
|
154
|
+
flush(): void;
|
|
155
|
+
stop(): void;
|
|
156
|
+
private poll;
|
|
157
|
+
private drain;
|
|
158
|
+
private emitLines;
|
|
159
|
+
}
|
|
160
|
+
export {};
|
|
161
|
+
//# sourceMappingURL=dsh-sessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dsh-sessions.d.ts","sourceRoot":"","sources":["../../src/daemon/dsh-sessions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AA6B1E,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AAErD,qEAAqE;AACrE,wBAAgB,UAAU,IAAI,YAAY,GAAG,IAAI,CAGhD;AAED,qEAAqE;AACrE,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAYrD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,YAAY,EACxB,UAAU,SAAQ,GACjB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAuB3B;AAID,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,0EAA0E;IAC1E,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,UAAU,SAAS;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,GA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