@adhdev/session-host-core 1.0.60-rc.6 → 1.0.60-rc.60
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/index.d.mts +28 -4
- package/dist/index.d.ts +28 -4
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/control-plane.ts +23 -2
- package/src/index.ts +1 -1
- package/src/ipc.ts +12 -2
- package/src/registry.ts +14 -1
package/dist/index.d.mts
CHANGED
|
@@ -549,8 +549,16 @@ declare function getDefaultSessionHostEndpoint(appName?: string, options?: Sessi
|
|
|
549
549
|
* finish it arrive, which is the only correct way to turn a byte stream into
|
|
550
550
|
* text. String chunks bypass it: they are already decoded, and feeding them
|
|
551
551
|
* through `Buffer.from` would re-encode text the caller never asked us to touch.
|
|
552
|
+
*
|
|
553
|
+
* The envelope type is a parameter (defaulting to this package's own wire type)
|
|
554
|
+
* purely so sibling newline-framed sockets can REUSE this decoder rather than
|
|
555
|
+
* re-deriving it. `@adhdev/terminal-mux-control`'s control socket carried a
|
|
556
|
+
* verbatim `chunk.toString()` copy of the pre-fix parser and inherited the same
|
|
557
|
+
* silent corruption; it now shares this implementation. Nothing about the
|
|
558
|
+
* framing is session-host-specific — only the payload type was, and that is now
|
|
559
|
+
* the caller's to name.
|
|
552
560
|
*/
|
|
553
|
-
declare function createLineParser(onEnvelope: (envelope:
|
|
561
|
+
declare function createLineParser<TEnvelope = SessionHostWireEnvelope>(onEnvelope: (envelope: TEnvelope) => void): {
|
|
554
562
|
(chunk: Buffer | string): void;
|
|
555
563
|
end(): string;
|
|
556
564
|
};
|
|
@@ -700,8 +708,16 @@ declare function applyTerminalColorEnv(env: Record<string, string>): void;
|
|
|
700
708
|
*/
|
|
701
709
|
declare function ensureNodePtySpawnHelperPermissions(logFn?: (msg: string) => void): void;
|
|
702
710
|
|
|
711
|
+
/** Response shape of the `get_snapshot` wire request — a PTY snapshot for a session. */
|
|
712
|
+
interface SessionHostSnapshot {
|
|
713
|
+
seq: number;
|
|
714
|
+
text: string;
|
|
715
|
+
truncated: boolean;
|
|
716
|
+
cols?: number;
|
|
717
|
+
rows?: number;
|
|
718
|
+
}
|
|
703
719
|
/**
|
|
704
|
-
* The
|
|
720
|
+
* The session-host control-plane surface shared by the cloud and
|
|
705
721
|
* standalone daemons. Both daemons used to carry a byte-for-byte copy of this
|
|
706
722
|
* dispatch table plus the identical throw strings; this is the single source of
|
|
707
723
|
* truth for that mapping. The wire `type` strings and error text here are the
|
|
@@ -721,6 +737,14 @@ interface SessionHostControlPlane {
|
|
|
721
737
|
pruneDuplicateSessions(payload?: PruneDuplicateSessionsPayload): Promise<SessionHostPruneDuplicatesResult>;
|
|
722
738
|
acquireWrite(payload: AcquireWritePayload): Promise<SessionHostRecord | null>;
|
|
723
739
|
releaseWrite(payload: ReleaseWritePayload): Promise<SessionHostRecord | null>;
|
|
740
|
+
/**
|
|
741
|
+
* A PTY snapshot for `sessionId` (optionally only the tail since `sinceSeq`),
|
|
742
|
+
* over wire type `get_snapshot`. Mirrors the shape daemon-core's local
|
|
743
|
+
* `SessionHostControlPlane` interface (`commands/router.ts`) and cloud's
|
|
744
|
+
* former `cloud-command-transports.ts` P2P-only `get_runtime_snapshot` case
|
|
745
|
+
* both already used against a raw `SessionHostClient`.
|
|
746
|
+
*/
|
|
747
|
+
getSnapshot(sessionId: string, sinceSeq?: number): Promise<SessionHostSnapshot | null>;
|
|
724
748
|
}
|
|
725
749
|
/**
|
|
726
750
|
* Minimal request transport the control-plane factory needs. Each daemon injects
|
|
@@ -737,11 +761,11 @@ interface SessionHostControlTransport {
|
|
|
737
761
|
request<T>(type: SessionHostRequestType, payload: Record<string, unknown>): Promise<T>;
|
|
738
762
|
}
|
|
739
763
|
/**
|
|
740
|
-
* Build the shared
|
|
764
|
+
* Build the shared 12-method control-plane over an injected request transport.
|
|
741
765
|
* The (type string, payload shape) pairs are verbatim what both daemons emitted
|
|
742
766
|
* previously — do not reword them without matching the session-host daemon's
|
|
743
767
|
* request handlers.
|
|
744
768
|
*/
|
|
745
769
|
declare function createSessionHostControlPlane(transport: SessionHostControlTransport): SessionHostControlPlane;
|
|
746
770
|
|
|
747
|
-
export { type AcquireWritePayload, type AttachSessionPayload, type ClearSessionBufferPayload, type CreateSessionPayload, DEFAULT_CONFIG_DIR_NAME, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, type DetachSessionPayload, type ForceDetachClientPayload, type GetHostDiagnosticsPayload, type GetSnapshotPayload, type GetTerminalSnapshotPayload, type PruneDuplicateSessionsPayload, type ReleaseWritePayload, type ResizeSessionPayload, type RestartSessionPayload, type ResumeSessionPayload, SESSION_HOST_SUPPORTED_REQUEST_TYPES, type SendInputPayload, type SendSignalPayload, type SessionAttachedClient, type SessionBufferSnapshot, type SessionClientType, type SessionHostCategory, SessionHostClient, type SessionHostClientOptions, type SessionHostControlPlane, type SessionHostControlTransport, type SessionHostDiagnostics, type SessionHostDisconnectInfo, type SessionHostDisconnectReason, type SessionHostDuplicateSessionGroup, type SessionHostEndpoint, type SessionHostEndpointOptions, type SessionHostEvent, type SessionHostEventEnvelope, type SessionHostLogEntry, type SessionHostPruneDuplicatesResult, type SessionHostRecord, SessionHostRegistry, type SessionHostRequest, type SessionHostRequestEnvelope, type SessionHostRequestTrace, type SessionHostRequestType, type SessionHostResponse, type SessionHostResponseEnvelope, type SessionHostRuntimeTransition, type SessionHostSurfaceKind, type SessionHostSurfaceRecordLike, type SessionHostWireEnvelope, type SessionLaunchCommand, type SessionLifecycle, type SessionOwnerType, SessionRingBuffer, type SessionRingBufferOptions, type SessionTerminalSnapshot, type SessionTerminalState, type SessionTermination, type SessionTransport, type SessionWriteOwner, type StopSessionPayload, type UpdateSessionMetaPayload, applyTerminalColorEnv, buildRuntimeDisplayName, buildRuntimeKey, canonicalizeInstancePath, classifyTermination, createLineParser, createResponseEnvelope, createSessionHostControlPlane, ensureNodePtySpawnHelperPermissions, formatRuntimeOwner, getDefaultSessionHostEndpoint, getSessionHostRecoveryLabel, getSessionHostSurfaceKind, getWorkspaceLabel, isDefaultInstanceConfigDir, isSessionHostLiveRuntime, isSessionHostRecoverySnapshot, isTerminalRecord, partitionSessionHostDiagnosticsSessions, partitionSessionHostRecords, resolveAttachableRuntimeRecord, resolveInstanceConfigDir, resolveRuntimeRecord, resolveSessionHostIpcKey, sanitizeSpawnEnv, writeEnvelope };
|
|
771
|
+
export { type AcquireWritePayload, type AttachSessionPayload, type ClearSessionBufferPayload, type CreateSessionPayload, DEFAULT_CONFIG_DIR_NAME, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, type DetachSessionPayload, type ForceDetachClientPayload, type GetHostDiagnosticsPayload, type GetSnapshotPayload, type GetTerminalSnapshotPayload, type PruneDuplicateSessionsPayload, type ReleaseWritePayload, type ResizeSessionPayload, type RestartSessionPayload, type ResumeSessionPayload, SESSION_HOST_SUPPORTED_REQUEST_TYPES, type SendInputPayload, type SendSignalPayload, type SessionAttachedClient, type SessionBufferSnapshot, type SessionClientType, type SessionHostCategory, SessionHostClient, type SessionHostClientOptions, type SessionHostControlPlane, type SessionHostControlTransport, type SessionHostDiagnostics, type SessionHostDisconnectInfo, type SessionHostDisconnectReason, type SessionHostDuplicateSessionGroup, type SessionHostEndpoint, type SessionHostEndpointOptions, type SessionHostEvent, type SessionHostEventEnvelope, type SessionHostLogEntry, type SessionHostPruneDuplicatesResult, type SessionHostRecord, SessionHostRegistry, type SessionHostRequest, type SessionHostRequestEnvelope, type SessionHostRequestTrace, type SessionHostRequestType, type SessionHostResponse, type SessionHostResponseEnvelope, type SessionHostRuntimeTransition, type SessionHostSnapshot, type SessionHostSurfaceKind, type SessionHostSurfaceRecordLike, type SessionHostWireEnvelope, type SessionLaunchCommand, type SessionLifecycle, type SessionOwnerType, SessionRingBuffer, type SessionRingBufferOptions, type SessionTerminalSnapshot, type SessionTerminalState, type SessionTermination, type SessionTransport, type SessionWriteOwner, type StopSessionPayload, type UpdateSessionMetaPayload, applyTerminalColorEnv, buildRuntimeDisplayName, buildRuntimeKey, canonicalizeInstancePath, classifyTermination, createLineParser, createResponseEnvelope, createSessionHostControlPlane, ensureNodePtySpawnHelperPermissions, formatRuntimeOwner, getDefaultSessionHostEndpoint, getSessionHostRecoveryLabel, getSessionHostSurfaceKind, getWorkspaceLabel, isDefaultInstanceConfigDir, isSessionHostLiveRuntime, isSessionHostRecoverySnapshot, isTerminalRecord, partitionSessionHostDiagnosticsSessions, partitionSessionHostRecords, resolveAttachableRuntimeRecord, resolveInstanceConfigDir, resolveRuntimeRecord, resolveSessionHostIpcKey, sanitizeSpawnEnv, writeEnvelope };
|
package/dist/index.d.ts
CHANGED
|
@@ -549,8 +549,16 @@ declare function getDefaultSessionHostEndpoint(appName?: string, options?: Sessi
|
|
|
549
549
|
* finish it arrive, which is the only correct way to turn a byte stream into
|
|
550
550
|
* text. String chunks bypass it: they are already decoded, and feeding them
|
|
551
551
|
* through `Buffer.from` would re-encode text the caller never asked us to touch.
|
|
552
|
+
*
|
|
553
|
+
* The envelope type is a parameter (defaulting to this package's own wire type)
|
|
554
|
+
* purely so sibling newline-framed sockets can REUSE this decoder rather than
|
|
555
|
+
* re-deriving it. `@adhdev/terminal-mux-control`'s control socket carried a
|
|
556
|
+
* verbatim `chunk.toString()` copy of the pre-fix parser and inherited the same
|
|
557
|
+
* silent corruption; it now shares this implementation. Nothing about the
|
|
558
|
+
* framing is session-host-specific — only the payload type was, and that is now
|
|
559
|
+
* the caller's to name.
|
|
552
560
|
*/
|
|
553
|
-
declare function createLineParser(onEnvelope: (envelope:
|
|
561
|
+
declare function createLineParser<TEnvelope = SessionHostWireEnvelope>(onEnvelope: (envelope: TEnvelope) => void): {
|
|
554
562
|
(chunk: Buffer | string): void;
|
|
555
563
|
end(): string;
|
|
556
564
|
};
|
|
@@ -700,8 +708,16 @@ declare function applyTerminalColorEnv(env: Record<string, string>): void;
|
|
|
700
708
|
*/
|
|
701
709
|
declare function ensureNodePtySpawnHelperPermissions(logFn?: (msg: string) => void): void;
|
|
702
710
|
|
|
711
|
+
/** Response shape of the `get_snapshot` wire request — a PTY snapshot for a session. */
|
|
712
|
+
interface SessionHostSnapshot {
|
|
713
|
+
seq: number;
|
|
714
|
+
text: string;
|
|
715
|
+
truncated: boolean;
|
|
716
|
+
cols?: number;
|
|
717
|
+
rows?: number;
|
|
718
|
+
}
|
|
703
719
|
/**
|
|
704
|
-
* The
|
|
720
|
+
* The session-host control-plane surface shared by the cloud and
|
|
705
721
|
* standalone daemons. Both daemons used to carry a byte-for-byte copy of this
|
|
706
722
|
* dispatch table plus the identical throw strings; this is the single source of
|
|
707
723
|
* truth for that mapping. The wire `type` strings and error text here are the
|
|
@@ -721,6 +737,14 @@ interface SessionHostControlPlane {
|
|
|
721
737
|
pruneDuplicateSessions(payload?: PruneDuplicateSessionsPayload): Promise<SessionHostPruneDuplicatesResult>;
|
|
722
738
|
acquireWrite(payload: AcquireWritePayload): Promise<SessionHostRecord | null>;
|
|
723
739
|
releaseWrite(payload: ReleaseWritePayload): Promise<SessionHostRecord | null>;
|
|
740
|
+
/**
|
|
741
|
+
* A PTY snapshot for `sessionId` (optionally only the tail since `sinceSeq`),
|
|
742
|
+
* over wire type `get_snapshot`. Mirrors the shape daemon-core's local
|
|
743
|
+
* `SessionHostControlPlane` interface (`commands/router.ts`) and cloud's
|
|
744
|
+
* former `cloud-command-transports.ts` P2P-only `get_runtime_snapshot` case
|
|
745
|
+
* both already used against a raw `SessionHostClient`.
|
|
746
|
+
*/
|
|
747
|
+
getSnapshot(sessionId: string, sinceSeq?: number): Promise<SessionHostSnapshot | null>;
|
|
724
748
|
}
|
|
725
749
|
/**
|
|
726
750
|
* Minimal request transport the control-plane factory needs. Each daemon injects
|
|
@@ -737,11 +761,11 @@ interface SessionHostControlTransport {
|
|
|
737
761
|
request<T>(type: SessionHostRequestType, payload: Record<string, unknown>): Promise<T>;
|
|
738
762
|
}
|
|
739
763
|
/**
|
|
740
|
-
* Build the shared
|
|
764
|
+
* Build the shared 12-method control-plane over an injected request transport.
|
|
741
765
|
* The (type string, payload shape) pairs are verbatim what both daemons emitted
|
|
742
766
|
* previously — do not reword them without matching the session-host daemon's
|
|
743
767
|
* request handlers.
|
|
744
768
|
*/
|
|
745
769
|
declare function createSessionHostControlPlane(transport: SessionHostControlTransport): SessionHostControlPlane;
|
|
746
770
|
|
|
747
|
-
export { type AcquireWritePayload, type AttachSessionPayload, type ClearSessionBufferPayload, type CreateSessionPayload, DEFAULT_CONFIG_DIR_NAME, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, type DetachSessionPayload, type ForceDetachClientPayload, type GetHostDiagnosticsPayload, type GetSnapshotPayload, type GetTerminalSnapshotPayload, type PruneDuplicateSessionsPayload, type ReleaseWritePayload, type ResizeSessionPayload, type RestartSessionPayload, type ResumeSessionPayload, SESSION_HOST_SUPPORTED_REQUEST_TYPES, type SendInputPayload, type SendSignalPayload, type SessionAttachedClient, type SessionBufferSnapshot, type SessionClientType, type SessionHostCategory, SessionHostClient, type SessionHostClientOptions, type SessionHostControlPlane, type SessionHostControlTransport, type SessionHostDiagnostics, type SessionHostDisconnectInfo, type SessionHostDisconnectReason, type SessionHostDuplicateSessionGroup, type SessionHostEndpoint, type SessionHostEndpointOptions, type SessionHostEvent, type SessionHostEventEnvelope, type SessionHostLogEntry, type SessionHostPruneDuplicatesResult, type SessionHostRecord, SessionHostRegistry, type SessionHostRequest, type SessionHostRequestEnvelope, type SessionHostRequestTrace, type SessionHostRequestType, type SessionHostResponse, type SessionHostResponseEnvelope, type SessionHostRuntimeTransition, type SessionHostSurfaceKind, type SessionHostSurfaceRecordLike, type SessionHostWireEnvelope, type SessionLaunchCommand, type SessionLifecycle, type SessionOwnerType, SessionRingBuffer, type SessionRingBufferOptions, type SessionTerminalSnapshot, type SessionTerminalState, type SessionTermination, type SessionTransport, type SessionWriteOwner, type StopSessionPayload, type UpdateSessionMetaPayload, applyTerminalColorEnv, buildRuntimeDisplayName, buildRuntimeKey, canonicalizeInstancePath, classifyTermination, createLineParser, createResponseEnvelope, createSessionHostControlPlane, ensureNodePtySpawnHelperPermissions, formatRuntimeOwner, getDefaultSessionHostEndpoint, getSessionHostRecoveryLabel, getSessionHostSurfaceKind, getWorkspaceLabel, isDefaultInstanceConfigDir, isSessionHostLiveRuntime, isSessionHostRecoverySnapshot, isTerminalRecord, partitionSessionHostDiagnosticsSessions, partitionSessionHostRecords, resolveAttachableRuntimeRecord, resolveInstanceConfigDir, resolveRuntimeRecord, resolveSessionHostIpcKey, sanitizeSpawnEnv, writeEnvelope };
|
|
771
|
+
export { type AcquireWritePayload, type AttachSessionPayload, type ClearSessionBufferPayload, type CreateSessionPayload, DEFAULT_CONFIG_DIR_NAME, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, type DetachSessionPayload, type ForceDetachClientPayload, type GetHostDiagnosticsPayload, type GetSnapshotPayload, type GetTerminalSnapshotPayload, type PruneDuplicateSessionsPayload, type ReleaseWritePayload, type ResizeSessionPayload, type RestartSessionPayload, type ResumeSessionPayload, SESSION_HOST_SUPPORTED_REQUEST_TYPES, type SendInputPayload, type SendSignalPayload, type SessionAttachedClient, type SessionBufferSnapshot, type SessionClientType, type SessionHostCategory, SessionHostClient, type SessionHostClientOptions, type SessionHostControlPlane, type SessionHostControlTransport, type SessionHostDiagnostics, type SessionHostDisconnectInfo, type SessionHostDisconnectReason, type SessionHostDuplicateSessionGroup, type SessionHostEndpoint, type SessionHostEndpointOptions, type SessionHostEvent, type SessionHostEventEnvelope, type SessionHostLogEntry, type SessionHostPruneDuplicatesResult, type SessionHostRecord, SessionHostRegistry, type SessionHostRequest, type SessionHostRequestEnvelope, type SessionHostRequestTrace, type SessionHostRequestType, type SessionHostResponse, type SessionHostResponseEnvelope, type SessionHostRuntimeTransition, type SessionHostSnapshot, type SessionHostSurfaceKind, type SessionHostSurfaceRecordLike, type SessionHostWireEnvelope, type SessionLaunchCommand, type SessionLifecycle, type SessionOwnerType, SessionRingBuffer, type SessionRingBufferOptions, type SessionTerminalSnapshot, type SessionTerminalState, type SessionTermination, type SessionTransport, type SessionWriteOwner, type StopSessionPayload, type UpdateSessionMetaPayload, applyTerminalColorEnv, buildRuntimeDisplayName, buildRuntimeKey, canonicalizeInstancePath, classifyTermination, createLineParser, createResponseEnvelope, createSessionHostControlPlane, ensureNodePtySpawnHelperPermissions, formatRuntimeOwner, getDefaultSessionHostEndpoint, getSessionHostRecoveryLabel, getSessionHostSurfaceKind, getWorkspaceLabel, isDefaultInstanceConfigDir, isSessionHostLiveRuntime, isSessionHostRecoverySnapshot, isTerminalRecord, partitionSessionHostDiagnosticsSessions, partitionSessionHostRecords, resolveAttachableRuntimeRecord, resolveInstanceConfigDir, resolveRuntimeRecord, resolveSessionHostIpcKey, sanitizeSpawnEnv, writeEnvelope };
|
package/dist/index.js
CHANGED
|
@@ -571,10 +571,21 @@ var SessionHostRegistry = class {
|
|
|
571
571
|
writeOwner: record.writeOwner ? { ...record.writeOwner } : null,
|
|
572
572
|
attachedClients: record.attachedClients.map((client) => ({ ...client })),
|
|
573
573
|
buffer: { ...record.buffer },
|
|
574
|
-
|
|
574
|
+
// Deep: meta carries nested records (e.g. the daemon's `launchRecord`,
|
|
575
|
+
// wiring-unification Phase E), and a caller mutating a returned record
|
|
576
|
+
// must never reach into the registry's own copy.
|
|
577
|
+
meta: cloneMeta(record.meta)
|
|
575
578
|
};
|
|
576
579
|
}
|
|
577
580
|
};
|
|
581
|
+
function cloneMeta(meta) {
|
|
582
|
+
if (!meta) return {};
|
|
583
|
+
try {
|
|
584
|
+
return structuredClone(meta);
|
|
585
|
+
} catch {
|
|
586
|
+
return { ...meta };
|
|
587
|
+
}
|
|
588
|
+
}
|
|
578
589
|
|
|
579
590
|
// src/ipc.ts
|
|
580
591
|
var os = __toESM(require("os"));
|
|
@@ -960,6 +971,9 @@ function createSessionHostControlPlane(transport) {
|
|
|
960
971
|
},
|
|
961
972
|
releaseWrite(payload) {
|
|
962
973
|
return transport.request("release_write", payload);
|
|
974
|
+
},
|
|
975
|
+
getSnapshot(sessionId, sinceSeq) {
|
|
976
|
+
return transport.request("get_snapshot", { sessionId, sinceSeq });
|
|
963
977
|
}
|
|
964
978
|
};
|
|
965
979
|
}
|