@adhdev/daemon-core 0.9.82-rc.166 → 0.9.82-rc.168
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/cli-adapters/raw-terminal-io.d.ts +37 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +234 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +230 -16
- package/dist/index.mjs.map +1 -1
- package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +1 -0
- package/package.json +1 -1
- package/src/cli-adapters/raw-terminal-io.ts +252 -0
- package/src/index.ts +7 -0
- package/src/mesh/mesh-events.ts +19 -1
- package/src/providers/cli-provider-instance.ts +1 -1
- package/src/providers/provider-loader.ts +4 -4
- package/src/providers/sdk/v1/builders/cli/parse-approval.ts +7 -2
- package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +6 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type SessionHostEndpoint, type SessionHostRequest, type SessionHostResponse, type SessionTerminalSnapshot, type SessionTerminalState } from '@adhdev/session-host-core';
|
|
2
|
+
type LowercaseLetter = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
|
|
3
|
+
type FunctionKey = 'f1' | 'f2' | 'f3' | 'f4' | 'f5' | 'f6' | 'f7' | 'f8' | 'f9' | 'f10' | 'f11' | 'f12';
|
|
4
|
+
type BaseNamedKey = 'enter' | 'escape' | 'tab' | 'backspace' | 'up' | 'down' | 'left' | 'right' | 'home' | 'end' | 'pageup' | 'pagedown' | 'space' | FunctionKey;
|
|
5
|
+
type ShiftNamedKey = BaseNamedKey | LowercaseLetter | `ctrl+${LowercaseLetter}` | `alt+${LowercaseLetter}`;
|
|
6
|
+
export type NamedKey = BaseNamedKey | `ctrl+${LowercaseLetter}` | `alt+${LowercaseLetter}` | `shift+${ShiftNamedKey}`;
|
|
7
|
+
export declare function namedKeyToAnsi(key: NamedKey | string): string;
|
|
8
|
+
export declare function namedKeysToAnsi(keys: readonly (NamedKey | string)[]): string;
|
|
9
|
+
export interface RawTerminalSessionHostClient {
|
|
10
|
+
connect(): Promise<void>;
|
|
11
|
+
request<T = unknown>(request: SessionHostRequest): Promise<SessionHostResponse<T>>;
|
|
12
|
+
close(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export interface RawTerminalAttachmentOptions {
|
|
15
|
+
endpoint?: SessionHostEndpoint;
|
|
16
|
+
sessionId: string;
|
|
17
|
+
mode?: 'read' | 'write';
|
|
18
|
+
clientId?: string;
|
|
19
|
+
client?: RawTerminalSessionHostClient;
|
|
20
|
+
}
|
|
21
|
+
export declare class RawTerminalAttachment {
|
|
22
|
+
readonly sessionId: string;
|
|
23
|
+
private readonly clientId;
|
|
24
|
+
private readonly mode;
|
|
25
|
+
private readonly client;
|
|
26
|
+
private closed;
|
|
27
|
+
private constructor();
|
|
28
|
+
static attach(options: RawTerminalAttachmentOptions): Promise<RawTerminalAttachment>;
|
|
29
|
+
readSnapshot(): Promise<SessionTerminalSnapshot>;
|
|
30
|
+
readScreenText(): Promise<string>;
|
|
31
|
+
readState(): Promise<SessionTerminalState>;
|
|
32
|
+
writeInput(text: string): Promise<void>;
|
|
33
|
+
writeKeys(keys: readonly (NamedKey | string)[]): Promise<void>;
|
|
34
|
+
close(): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export declare function withRawTerminalAttachment<T>(options: RawTerminalAttachmentOptions, operation: (attachment: RawTerminalAttachment) => Promise<T>): Promise<T>;
|
|
37
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -123,6 +123,8 @@ export type { CliAdapter } from './cli-adapter-types.js';
|
|
|
123
123
|
export { NodePtyTransportFactory } from './cli-adapters/pty-transport.js';
|
|
124
124
|
export type { PtyRuntimeTransport, PtyTransportFactory, PtySpawnOptions } from './cli-adapters/pty-transport.js';
|
|
125
125
|
export { SessionHostPtyTransportFactory } from './cli-adapters/session-host-transport.js';
|
|
126
|
+
export { RawTerminalAttachment, namedKeyToAnsi, namedKeysToAnsi, withRawTerminalAttachment, } from './cli-adapters/raw-terminal-io.js';
|
|
127
|
+
export type { NamedKey, RawTerminalAttachmentOptions, RawTerminalSessionHostClient } from './cli-adapters/raw-terminal-io.js';
|
|
126
128
|
export type { HostedCliRuntimeDescriptor, CliTransportFactoryParams } from './commands/cli-manager.js';
|
|
127
129
|
export { DEFAULT_SESSION_HOST_APP_NAME, DEFAULT_STANDALONE_SESSION_HOST_APP_NAME, resolveSessionHostAppName, resolveSessionHostAppNameResolution, } from './session-host/app-name.js';
|
|
128
130
|
export type { SessionHostAppNameResolution } from './session-host/app-name.js';
|
package/dist/index.js
CHANGED
|
@@ -3699,6 +3699,20 @@ function hasDispatchAfterTerminal(meshId, sessionId, terminalId) {
|
|
|
3699
3699
|
}
|
|
3700
3700
|
return false;
|
|
3701
3701
|
}
|
|
3702
|
+
function hasUnterminalDirectDispatchLedgerEntry(meshId, sessionId) {
|
|
3703
|
+
const entries = readLedgerEntries(meshId, { tail: 200 });
|
|
3704
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
3705
|
+
const entry = entries[i];
|
|
3706
|
+
if (entry.sessionId !== sessionId) continue;
|
|
3707
|
+
if (entry.kind === "task_completed" || entry.kind === "task_failed" || entry.kind === "task_stalled") {
|
|
3708
|
+
return false;
|
|
3709
|
+
}
|
|
3710
|
+
if (entry.kind === "task_dispatched" && entry.payload?.source === "direct") {
|
|
3711
|
+
return true;
|
|
3712
|
+
}
|
|
3713
|
+
}
|
|
3714
|
+
return false;
|
|
3715
|
+
}
|
|
3702
3716
|
function buildLongGeneratingCompletionReconciliation(args) {
|
|
3703
3717
|
const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
3704
3718
|
const nodeId = readNonEmptyString2(args.nodeId) || readNonEmptyString2(args.metadataEvent.meshNodeId);
|
|
@@ -4566,7 +4580,7 @@ function setupMeshEventForwarding(components) {
|
|
|
4566
4580
|
if (coordinatorMeshId) {
|
|
4567
4581
|
try {
|
|
4568
4582
|
const activeDispatches = getActiveDirectDispatches(coordinatorMeshId);
|
|
4569
|
-
if (activeDispatches.some((d) => d.sessionId === instanceId)) {
|
|
4583
|
+
if (activeDispatches.some((d) => d.sessionId === instanceId) || hasUnterminalDirectDispatchLedgerEntry(coordinatorMeshId, instanceId)) {
|
|
4570
4584
|
meshIdFromDirectDispatch = coordinatorMeshId;
|
|
4571
4585
|
}
|
|
4572
4586
|
} catch {
|
|
@@ -6402,12 +6416,14 @@ function scopeLines(spec, lines, questionIndex) {
|
|
|
6402
6416
|
function extractButtons(spec, lines, windowStart, windowEnd) {
|
|
6403
6417
|
const buttonRe = compile3(spec.buttonPattern, spec.buttonFlags ?? "m");
|
|
6404
6418
|
const out = [];
|
|
6419
|
+
const labelGroup = Number.isInteger(spec.buttonLabelGroup) && (spec.buttonLabelGroup ?? 0) > 0 ? spec.buttonLabelGroup : 1;
|
|
6405
6420
|
let i = windowStart;
|
|
6406
6421
|
while (i < windowEnd) {
|
|
6407
6422
|
const line = lines[i];
|
|
6408
6423
|
const m = buttonRe.exec(line);
|
|
6409
|
-
|
|
6410
|
-
|
|
6424
|
+
const captured = m?.[labelGroup] ?? (labelGroup === 1 && m && m.length > 2 ? m[m.length - 1] : void 0);
|
|
6425
|
+
if (m && captured) {
|
|
6426
|
+
let label = captured.trim();
|
|
6411
6427
|
if (spec.continuationLines) {
|
|
6412
6428
|
let j = i + 1;
|
|
6413
6429
|
while (j < windowEnd) {
|
|
@@ -12063,6 +12079,7 @@ __export(index_exports, {
|
|
|
12063
12079
|
ProviderCliAdapter: () => ProviderCliAdapter,
|
|
12064
12080
|
ProviderInstanceManager: () => ProviderInstanceManager,
|
|
12065
12081
|
ProviderLoader: () => ProviderLoader,
|
|
12082
|
+
RawTerminalAttachment: () => RawTerminalAttachment,
|
|
12066
12083
|
STANDALONE_CDP_SCAN_INTERVAL_MS: () => STANDALONE_CDP_SCAN_INTERVAL_MS,
|
|
12067
12084
|
SessionHostPtyTransportFactory: () => SessionHostPtyTransportFactory,
|
|
12068
12085
|
SpecDriver: () => SpecDriver,
|
|
@@ -12213,6 +12230,8 @@ __export(index_exports, {
|
|
|
12213
12230
|
markSetupComplete: () => markSetupComplete,
|
|
12214
12231
|
markStaleDirectDispatches: () => markStaleDirectDispatches,
|
|
12215
12232
|
maybeRunDaemonUpgradeHelperFromEnv: () => maybeRunDaemonUpgradeHelperFromEnv,
|
|
12233
|
+
namedKeyToAnsi: () => namedKeyToAnsi,
|
|
12234
|
+
namedKeysToAnsi: () => namedKeysToAnsi,
|
|
12216
12235
|
normalizeActiveChatData: () => normalizeActiveChatData,
|
|
12217
12236
|
normalizeChatMessage: () => normalizeChatMessage,
|
|
12218
12237
|
normalizeChatMessageKind: () => normalizeChatMessageKind,
|
|
@@ -12293,7 +12312,8 @@ __export(index_exports, {
|
|
|
12293
12312
|
validateCliProviderManifest: () => validateCliProviderManifest,
|
|
12294
12313
|
validateMeshRefineConfig: () => validateMeshRefineConfig,
|
|
12295
12314
|
validateMeshTaskModeRequest: () => validateMeshTaskModeRequest,
|
|
12296
|
-
validateMeshWorktreeBootstrapConfig: () => validateMeshWorktreeBootstrapConfig
|
|
12315
|
+
validateMeshWorktreeBootstrapConfig: () => validateMeshWorktreeBootstrapConfig,
|
|
12316
|
+
withRawTerminalAttachment: () => withRawTerminalAttachment
|
|
12297
12317
|
});
|
|
12298
12318
|
module.exports = __toCommonJS(index_exports);
|
|
12299
12319
|
init_repo_mesh_types();
|
|
@@ -28397,7 +28417,7 @@ var CliProviderInstance = class {
|
|
|
28397
28417
|
};
|
|
28398
28418
|
}
|
|
28399
28419
|
getSessionModalState(sessionId) {
|
|
28400
|
-
const adapterStatus = this.adapter.getStatus({ allowParse:
|
|
28420
|
+
const adapterStatus = this.adapter.getStatus({ allowParse: true });
|
|
28401
28421
|
const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
|
|
28402
28422
|
const visibleStatus = autoApproveActive ? "generating" : adapterStatus.status;
|
|
28403
28423
|
const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
|
|
@@ -31930,6 +31950,7 @@ function validateControl(control, errors) {
|
|
|
31930
31950
|
}
|
|
31931
31951
|
|
|
31932
31952
|
// src/providers/provider-loader.ts
|
|
31953
|
+
init_external_sources();
|
|
31933
31954
|
function registerProviderScriptRootSafely(root) {
|
|
31934
31955
|
if (!root || typeof root !== "string") return;
|
|
31935
31956
|
try {
|
|
@@ -32187,11 +32208,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
32187
32208
|
this.log(`Loaded ${externalCount} external providers (legacy unnamed source)`);
|
|
32188
32209
|
}
|
|
32189
32210
|
} else {
|
|
32190
|
-
const
|
|
32191
|
-
loadProvidersActive: loadProvidersActive2,
|
|
32192
|
-
resolveActiveSource: resolveActiveSource2
|
|
32193
|
-
} = (init_external_sources(), __toCommonJS(external_sources_exports));
|
|
32194
|
-
const activeFile = loadProvidersActive2();
|
|
32211
|
+
const activeFile = loadProvidersActive();
|
|
32195
32212
|
let totalLoaded = 0;
|
|
32196
32213
|
const ambiguousTypes = [];
|
|
32197
32214
|
for (const sourceEntry of rootEntries) {
|
|
@@ -32206,7 +32223,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
32206
32223
|
for (const [type] of this.providers) {
|
|
32207
32224
|
const prov = this.providers.get(type);
|
|
32208
32225
|
if (!prov) continue;
|
|
32209
|
-
const resolved =
|
|
32226
|
+
const resolved = resolveActiveSource(prov.category, type, activeFile);
|
|
32210
32227
|
if (resolved.candidates.length <= 1) continue;
|
|
32211
32228
|
if (resolved.ambiguous) {
|
|
32212
32229
|
ambiguousTypes.push({ type, chosen: resolved.source ?? "?", candidates: resolved.candidates });
|
|
@@ -39364,9 +39381,9 @@ var DaemonCommandRouter = class {
|
|
|
39364
39381
|
});
|
|
39365
39382
|
let node;
|
|
39366
39383
|
if (meshRecord.inline) {
|
|
39367
|
-
const { randomUUID:
|
|
39384
|
+
const { randomUUID: randomUUID11 } = await import("crypto");
|
|
39368
39385
|
node = {
|
|
39369
|
-
id: `node_${
|
|
39386
|
+
id: `node_${randomUUID11().replace(/-/g, "")}`,
|
|
39370
39387
|
workspace: result.worktreePath,
|
|
39371
39388
|
repoRoot: result.worktreePath,
|
|
39372
39389
|
daemonId: sourceNode.daemonId,
|
|
@@ -47720,6 +47737,201 @@ var SessionHostPtyTransportFactory = class {
|
|
|
47720
47737
|
}
|
|
47721
47738
|
};
|
|
47722
47739
|
|
|
47740
|
+
// src/cli-adapters/raw-terminal-io.ts
|
|
47741
|
+
var import_crypto6 = require("crypto");
|
|
47742
|
+
var import_session_host_core4 = require("@adhdev/session-host-core");
|
|
47743
|
+
var BASE_KEY_SEQUENCES = {
|
|
47744
|
+
enter: "\r",
|
|
47745
|
+
escape: "\x1B",
|
|
47746
|
+
tab: " ",
|
|
47747
|
+
backspace: "\x7F",
|
|
47748
|
+
up: "\x1B[A",
|
|
47749
|
+
down: "\x1B[B",
|
|
47750
|
+
right: "\x1B[C",
|
|
47751
|
+
left: "\x1B[D",
|
|
47752
|
+
home: "\x1B[H",
|
|
47753
|
+
end: "\x1B[F",
|
|
47754
|
+
pageup: "\x1B[5~",
|
|
47755
|
+
pagedown: "\x1B[6~",
|
|
47756
|
+
space: " ",
|
|
47757
|
+
f1: "\x1BOP",
|
|
47758
|
+
f2: "\x1BOQ",
|
|
47759
|
+
f3: "\x1BOR",
|
|
47760
|
+
f4: "\x1BOS",
|
|
47761
|
+
f5: "\x1B[15~",
|
|
47762
|
+
f6: "\x1B[17~",
|
|
47763
|
+
f7: "\x1B[18~",
|
|
47764
|
+
f8: "\x1B[19~",
|
|
47765
|
+
f9: "\x1B[20~",
|
|
47766
|
+
f10: "\x1B[21~",
|
|
47767
|
+
f11: "\x1B[23~",
|
|
47768
|
+
f12: "\x1B[24~"
|
|
47769
|
+
};
|
|
47770
|
+
var SHIFTED_CSI_KEYS = {
|
|
47771
|
+
up: "\x1B[1;2A",
|
|
47772
|
+
down: "\x1B[1;2B",
|
|
47773
|
+
right: "\x1B[1;2C",
|
|
47774
|
+
left: "\x1B[1;2D",
|
|
47775
|
+
home: "\x1B[1;2H",
|
|
47776
|
+
end: "\x1B[1;2F",
|
|
47777
|
+
pageup: "\x1B[5;2~",
|
|
47778
|
+
pagedown: "\x1B[6;2~",
|
|
47779
|
+
f1: "\x1B[1;2P",
|
|
47780
|
+
f2: "\x1B[1;2Q",
|
|
47781
|
+
f3: "\x1B[1;2R",
|
|
47782
|
+
f4: "\x1B[1;2S",
|
|
47783
|
+
f5: "\x1B[15;2~",
|
|
47784
|
+
f6: "\x1B[17;2~",
|
|
47785
|
+
f7: "\x1B[18;2~",
|
|
47786
|
+
f8: "\x1B[19;2~",
|
|
47787
|
+
f9: "\x1B[20;2~",
|
|
47788
|
+
f10: "\x1B[21;2~",
|
|
47789
|
+
f11: "\x1B[23;2~",
|
|
47790
|
+
f12: "\x1B[24;2~"
|
|
47791
|
+
};
|
|
47792
|
+
function isLowercaseLetter(value) {
|
|
47793
|
+
return /^[a-z]$/.test(value);
|
|
47794
|
+
}
|
|
47795
|
+
function encodeControlLetter(letter) {
|
|
47796
|
+
return String.fromCharCode(letter.charCodeAt(0) - 96);
|
|
47797
|
+
}
|
|
47798
|
+
function encodeShiftedKey(key) {
|
|
47799
|
+
if (isLowercaseLetter(key)) return key.toUpperCase();
|
|
47800
|
+
if (key.startsWith("ctrl+") && isLowercaseLetter(key.slice(5))) {
|
|
47801
|
+
return encodeControlLetter(key.slice(5));
|
|
47802
|
+
}
|
|
47803
|
+
if (key.startsWith("alt+") && isLowercaseLetter(key.slice(4))) {
|
|
47804
|
+
return `\x1B${key.slice(4).toUpperCase()}`;
|
|
47805
|
+
}
|
|
47806
|
+
if (key === "tab") return "\x1B[Z";
|
|
47807
|
+
if (key in SHIFTED_CSI_KEYS) return SHIFTED_CSI_KEYS[key];
|
|
47808
|
+
if (key in BASE_KEY_SEQUENCES) return BASE_KEY_SEQUENCES[key];
|
|
47809
|
+
throw new Error(`Unsupported named key: shift+${key}`);
|
|
47810
|
+
}
|
|
47811
|
+
function namedKeyToAnsi(key) {
|
|
47812
|
+
const normalized = String(key || "").trim().toLowerCase();
|
|
47813
|
+
if (normalized in BASE_KEY_SEQUENCES) return BASE_KEY_SEQUENCES[normalized];
|
|
47814
|
+
if (normalized.startsWith("ctrl+") && isLowercaseLetter(normalized.slice(5))) {
|
|
47815
|
+
return encodeControlLetter(normalized.slice(5));
|
|
47816
|
+
}
|
|
47817
|
+
if (normalized.startsWith("alt+") && isLowercaseLetter(normalized.slice(4))) {
|
|
47818
|
+
return `\x1B${normalized.slice(4)}`;
|
|
47819
|
+
}
|
|
47820
|
+
if (normalized.startsWith("shift+")) return encodeShiftedKey(normalized.slice(6));
|
|
47821
|
+
throw new Error(`Unsupported named key: ${key}`);
|
|
47822
|
+
}
|
|
47823
|
+
function namedKeysToAnsi(keys) {
|
|
47824
|
+
if (!Array.isArray(keys)) throw new Error("keys must be an array");
|
|
47825
|
+
return keys.map(namedKeyToAnsi).join("");
|
|
47826
|
+
}
|
|
47827
|
+
var RawTerminalAttachment = class _RawTerminalAttachment {
|
|
47828
|
+
constructor(sessionId, clientId, mode, client) {
|
|
47829
|
+
this.sessionId = sessionId;
|
|
47830
|
+
this.clientId = clientId;
|
|
47831
|
+
this.mode = mode;
|
|
47832
|
+
this.client = client;
|
|
47833
|
+
}
|
|
47834
|
+
closed = false;
|
|
47835
|
+
static async attach(options) {
|
|
47836
|
+
const sessionId = String(options.sessionId || "").trim();
|
|
47837
|
+
if (!sessionId) throw new Error("sessionId is required");
|
|
47838
|
+
const mode = options.mode || "read";
|
|
47839
|
+
const clientId = options.clientId || `raw-terminal-${process.pid}-${(0, import_crypto6.randomUUID)().slice(0, 8)}`;
|
|
47840
|
+
const client = options.client || new import_session_host_core4.SessionHostClient({ endpoint: options.endpoint });
|
|
47841
|
+
await client.connect();
|
|
47842
|
+
const attachResponse = await client.request({
|
|
47843
|
+
type: "attach_session",
|
|
47844
|
+
payload: {
|
|
47845
|
+
sessionId,
|
|
47846
|
+
clientId,
|
|
47847
|
+
clientType: "web",
|
|
47848
|
+
readOnly: mode === "read"
|
|
47849
|
+
}
|
|
47850
|
+
});
|
|
47851
|
+
if (!attachResponse.success) {
|
|
47852
|
+
await client.close().catch(() => {
|
|
47853
|
+
});
|
|
47854
|
+
throw new Error(attachResponse.error || `Failed to attach terminal session ${sessionId}`);
|
|
47855
|
+
}
|
|
47856
|
+
if (mode === "write") {
|
|
47857
|
+
const ownerResponse = await client.request({
|
|
47858
|
+
type: "acquire_write",
|
|
47859
|
+
payload: {
|
|
47860
|
+
sessionId,
|
|
47861
|
+
clientId,
|
|
47862
|
+
ownerType: "user",
|
|
47863
|
+
force: true
|
|
47864
|
+
}
|
|
47865
|
+
});
|
|
47866
|
+
if (!ownerResponse.success) {
|
|
47867
|
+
await client.request({
|
|
47868
|
+
type: "detach_session",
|
|
47869
|
+
payload: { sessionId, clientId }
|
|
47870
|
+
}).catch(() => ({ success: false }));
|
|
47871
|
+
await client.close().catch(() => {
|
|
47872
|
+
});
|
|
47873
|
+
throw new Error(ownerResponse.error || `Failed to acquire terminal session ${sessionId}`);
|
|
47874
|
+
}
|
|
47875
|
+
}
|
|
47876
|
+
return new _RawTerminalAttachment(sessionId, clientId, mode, client);
|
|
47877
|
+
}
|
|
47878
|
+
async readSnapshot() {
|
|
47879
|
+
const response = await this.client.request({
|
|
47880
|
+
type: "get_terminal_snapshot",
|
|
47881
|
+
payload: { sessionId: this.sessionId }
|
|
47882
|
+
});
|
|
47883
|
+
if (!response.success || !response.result) {
|
|
47884
|
+
throw new Error(response.error || `Terminal screen unavailable for ${this.sessionId}`);
|
|
47885
|
+
}
|
|
47886
|
+
return response.result;
|
|
47887
|
+
}
|
|
47888
|
+
async readScreenText() {
|
|
47889
|
+
return (await this.readSnapshot()).text;
|
|
47890
|
+
}
|
|
47891
|
+
async readState() {
|
|
47892
|
+
return (await this.readSnapshot()).state;
|
|
47893
|
+
}
|
|
47894
|
+
async writeInput(text) {
|
|
47895
|
+
if (this.mode !== "write") throw new Error("Raw terminal attachment is read-only");
|
|
47896
|
+
const response = await this.client.request({
|
|
47897
|
+
type: "send_input",
|
|
47898
|
+
payload: {
|
|
47899
|
+
sessionId: this.sessionId,
|
|
47900
|
+
clientId: this.clientId,
|
|
47901
|
+
data: text
|
|
47902
|
+
}
|
|
47903
|
+
});
|
|
47904
|
+
if (!response.success) throw new Error(response.error || `Failed to write terminal input to ${this.sessionId}`);
|
|
47905
|
+
}
|
|
47906
|
+
async writeKeys(keys) {
|
|
47907
|
+
await this.writeInput(namedKeysToAnsi(keys));
|
|
47908
|
+
}
|
|
47909
|
+
async close() {
|
|
47910
|
+
if (this.closed) return;
|
|
47911
|
+
this.closed = true;
|
|
47912
|
+
if (this.mode === "write") {
|
|
47913
|
+
await this.client.request({
|
|
47914
|
+
type: "release_write",
|
|
47915
|
+
payload: { sessionId: this.sessionId, clientId: this.clientId }
|
|
47916
|
+
}).catch(() => ({ success: false }));
|
|
47917
|
+
}
|
|
47918
|
+
await this.client.request({
|
|
47919
|
+
type: "detach_session",
|
|
47920
|
+
payload: { sessionId: this.sessionId, clientId: this.clientId }
|
|
47921
|
+
}).catch(() => ({ success: false }));
|
|
47922
|
+
await this.client.close().catch(() => {
|
|
47923
|
+
});
|
|
47924
|
+
}
|
|
47925
|
+
};
|
|
47926
|
+
async function withRawTerminalAttachment(options, operation) {
|
|
47927
|
+
const attachment = await RawTerminalAttachment.attach(options);
|
|
47928
|
+
try {
|
|
47929
|
+
return await operation(attachment);
|
|
47930
|
+
} finally {
|
|
47931
|
+
await attachment.close();
|
|
47932
|
+
}
|
|
47933
|
+
}
|
|
47934
|
+
|
|
47723
47935
|
// src/session-host/app-name.ts
|
|
47724
47936
|
var DEFAULT_SESSION_HOST_APP_NAME = "adhdev";
|
|
47725
47937
|
var DEFAULT_STANDALONE_SESSION_HOST_APP_NAME = "adhdev-standalone";
|
|
@@ -47752,7 +47964,7 @@ function resolveSessionHostAppName(options = {}) {
|
|
|
47752
47964
|
}
|
|
47753
47965
|
|
|
47754
47966
|
// src/session-host/runtime-support.ts
|
|
47755
|
-
var
|
|
47967
|
+
var import_session_host_core5 = require("@adhdev/session-host-core");
|
|
47756
47968
|
var STARTUP_TIMEOUT_MS = DEFAULT_SESSION_HOST_READY_TIMEOUT_MS;
|
|
47757
47969
|
var STARTUP_POLL_MS = 200;
|
|
47758
47970
|
var SessionHostCompatibilityError = class extends Error {
|
|
@@ -47780,7 +47992,7 @@ async function assertRequiredRequestTypes(client, requiredRequestTypes) {
|
|
|
47780
47992
|
}
|
|
47781
47993
|
}
|
|
47782
47994
|
async function canConnect(endpoint, requiredRequestTypes = []) {
|
|
47783
|
-
const client = new
|
|
47995
|
+
const client = new import_session_host_core5.SessionHostClient({ endpoint });
|
|
47784
47996
|
try {
|
|
47785
47997
|
await client.connect();
|
|
47786
47998
|
await assertRequiredRequestTypes(client, requiredRequestTypes);
|
|
@@ -47802,7 +48014,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS, requiredRe
|
|
|
47802
48014
|
throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
|
|
47803
48015
|
}
|
|
47804
48016
|
async function ensureSessionHostReady(options) {
|
|
47805
|
-
const endpoint = (0,
|
|
48017
|
+
const endpoint = (0, import_session_host_core5.getDefaultSessionHostEndpoint)(options.appName || "adhdev");
|
|
47806
48018
|
const requiredRequestTypes = options.requiredRequestTypes || [];
|
|
47807
48019
|
if (await canConnect(endpoint, requiredRequestTypes)) return endpoint;
|
|
47808
48020
|
options.spawnHost();
|
|
@@ -47810,7 +48022,7 @@ async function ensureSessionHostReady(options) {
|
|
|
47810
48022
|
return endpoint;
|
|
47811
48023
|
}
|
|
47812
48024
|
async function listHostedCliRuntimes(endpoint) {
|
|
47813
|
-
const client = new
|
|
48025
|
+
const client = new import_session_host_core5.SessionHostClient({ endpoint });
|
|
47814
48026
|
try {
|
|
47815
48027
|
const response = await client.request({
|
|
47816
48028
|
type: "list_sessions",
|
|
@@ -48685,6 +48897,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
48685
48897
|
ProviderCliAdapter,
|
|
48686
48898
|
ProviderInstanceManager,
|
|
48687
48899
|
ProviderLoader,
|
|
48900
|
+
RawTerminalAttachment,
|
|
48688
48901
|
STANDALONE_CDP_SCAN_INTERVAL_MS,
|
|
48689
48902
|
SessionHostPtyTransportFactory,
|
|
48690
48903
|
SpecDriver,
|
|
@@ -48835,6 +49048,8 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
48835
49048
|
markSetupComplete,
|
|
48836
49049
|
markStaleDirectDispatches,
|
|
48837
49050
|
maybeRunDaemonUpgradeHelperFromEnv,
|
|
49051
|
+
namedKeyToAnsi,
|
|
49052
|
+
namedKeysToAnsi,
|
|
48838
49053
|
normalizeActiveChatData,
|
|
48839
49054
|
normalizeChatMessage,
|
|
48840
49055
|
normalizeChatMessageKind,
|
|
@@ -48915,6 +49130,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
48915
49130
|
validateCliProviderManifest,
|
|
48916
49131
|
validateMeshRefineConfig,
|
|
48917
49132
|
validateMeshTaskModeRequest,
|
|
48918
|
-
validateMeshWorktreeBootstrapConfig
|
|
49133
|
+
validateMeshWorktreeBootstrapConfig,
|
|
49134
|
+
withRawTerminalAttachment
|
|
48919
49135
|
});
|
|
48920
49136
|
//# sourceMappingURL=index.js.map
|