@hydraharness/harness-client-runtime 0.0.0-stage → 0.1.1-rc.6

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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +96 -2
  3. package/lib/client.js +10964 -0
  4. package/lib/index.js +6 -0
  5. package/lib/invariant.js +36 -0
  6. package/lib/types/client/agents/scope.d.ts +35 -0
  7. package/lib/types/client/contract/conversation.d.ts +242 -0
  8. package/lib/types/client/contract/session.d.ts +97 -0
  9. package/lib/types/client/contract/sessions-port.d.ts +55 -0
  10. package/lib/types/client/contract/sessions.d.ts +164 -0
  11. package/lib/types/client/contract/settings-scope.d.ts +79 -0
  12. package/lib/types/client/contract/store.d.ts +90 -0
  13. package/lib/types/client/contract/workspaces.d.ts +102 -0
  14. package/lib/types/client/conversation/definition-registry.d.ts +30 -0
  15. package/lib/types/client/conversation/event-registry.d.ts +27 -0
  16. package/lib/types/client/conversation/view-registry.d.ts +15 -0
  17. package/lib/types/client/index.d.ts +128 -0
  18. package/lib/types/client/ordered-baseline.d.ts +12 -0
  19. package/lib/types/client/sessions/assistant-timing.d.ts +34 -0
  20. package/lib/types/client/sessions/context-provenance.d.ts +58 -0
  21. package/lib/types/client/sessions/conversation-assembler.d.ts +107 -0
  22. package/lib/types/client/sessions/conversation-context.d.ts +22 -0
  23. package/lib/types/client/sessions/conversation-location-index.d.ts +70 -0
  24. package/lib/types/client/sessions/conversation-versions.d.ts +25 -0
  25. package/lib/types/client/sessions/conversation.d.ts +422 -0
  26. package/lib/types/client/sessions/failure-display.d.ts +7 -0
  27. package/lib/types/client/sessions/lineage.d.ts +47 -0
  28. package/lib/types/client/sessions/manager.d.ts +300 -0
  29. package/lib/types/client/sessions/notifier.d.ts +35 -0
  30. package/lib/types/client/sessions/partial.d.ts +40 -0
  31. package/lib/types/client/sessions/pending.d.ts +55 -0
  32. package/lib/types/client/sessions/projection-store.d.ts +111 -0
  33. package/lib/types/client/sessions/provide.d.ts +79 -0
  34. package/lib/types/client/sessions/queue-mirror.d.ts +33 -0
  35. package/lib/types/client/sessions/remotes.d.ts +10 -0
  36. package/lib/types/client/sessions/request-inspection.d.ts +74 -0
  37. package/lib/types/client/sessions/service.d.ts +415 -0
  38. package/lib/types/client/sessions/session.d.ts +287 -0
  39. package/lib/types/client/sessions/steering-history.d.ts +23 -0
  40. package/lib/types/client/sessions/subagent-lineage.d.ts +24 -0
  41. package/lib/types/client/sessions/tool-call-tree.d.ts +45 -0
  42. package/lib/types/client/slots.d.ts +191 -0
  43. package/lib/types/client/time-zone.d.ts +8 -0
  44. package/lib/types/client/workspaces/manager.d.ts +182 -0
  45. package/lib/types/client/workspaces/path.d.ts +17 -0
  46. package/lib/types/client/workspaces/service.d.ts +179 -0
  47. package/lib/types/client/workspaces/workspace.d.ts +65 -0
  48. package/lib/types/index.d.ts +4 -0
  49. package/lib/types/invariant.d.ts +16 -0
  50. package/package.json +94 -3
@@ -0,0 +1,33 @@
1
+ import type { MuxFrame } from '@hydraharness/harness-api-remotes/client';
2
+ import type { SessionEvent } from '@hydraharness/harness-session/types';
3
+ import type { QueuedMessage } from './conversation.ts';
4
+ type QueueItems = Extract<MuxFrame, {
5
+ type: 'session/queue';
6
+ }>['items'];
7
+ /** Authoritative transient queue projection and durable steering handoff. */
8
+ export declare class SessionQueueMirror {
9
+ private current;
10
+ /**
11
+ * Return the current immutable queue projection.
12
+ * @returns current queue rows.
13
+ */
14
+ snapshot(): readonly QueuedMessage[];
15
+ /**
16
+ * Drop the stale generation before its replacement queue baseline arrives.
17
+ * @returns whether any projected queue row was removed.
18
+ */
19
+ reset(): boolean;
20
+ /**
21
+ * Replace from one authoritative stream queue frame.
22
+ * @param items - complete host queue snapshot.
23
+ */
24
+ replace(items: QueueItems): void;
25
+ /**
26
+ * Retire a transient steering row once its durable message enters the log.
27
+ * @param event - newly contiguous durable Session event.
28
+ * @returns whether the projection changed.
29
+ */
30
+ acceptDurable(event: SessionEvent): boolean;
31
+ }
32
+ export {};
33
+ //# sourceMappingURL=queue-mirror.d.ts.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Remote namespaces the Session cluster calls. One parameter for one concept:
3
+ * the generated surface a Session and its manager reach the Host through.
4
+ *
5
+ * @module @hydraharness/harness-client-runtime/client/sessions/remotes
6
+ */
7
+ import type { Context } from '@hydraharness/cordis';
8
+ /** The generated Remote namespaces a Session and its manager call. */
9
+ export type SessionRemotes = Pick<Context['remote'], 'commands'>;
10
+ //# sourceMappingURL=remotes.d.ts.map
@@ -0,0 +1,74 @@
1
+ import type { ContentBlock, ToolSchema } from '@hydraharness/harness-llm/types';
2
+ import type { AssistantProvenanceView, AssistantRequestConfig } from './conversation.ts';
3
+ export type { AssistantProvenanceView, AssistantRequestConfig, } from './conversation.ts';
4
+ /** Complete model-visible request header in force for an ordinary generation. */
5
+ export interface ConversationPromptSnapshot {
6
+ /** Provider/model and sampling configuration from the effective request header. */
7
+ config: AssistantRequestConfig;
8
+ /** Rendered system prompt text; empty when the request had no system prompt. */
9
+ system: string;
10
+ /** Complete tool catalog sent with the request, including tools that were never called. */
11
+ tools: readonly ToolSchema[];
12
+ }
13
+ /** System/tool change introduced while preparing one ordinary request. */
14
+ export interface RequestPromptChange {
15
+ /** Sequence of the request/header event that introduced this state. */
16
+ seq: number;
17
+ /** Unix epoch ms from the request/header event. */
18
+ time: number;
19
+ /** How the model-visible prompt differs from the previous recorded state. */
20
+ kind: 'initial' | 'system' | 'tools' | 'system-and-tools';
21
+ /** State immediately before this change; absent for the initial header. */
22
+ previous?: ConversationPromptSnapshot;
23
+ }
24
+ /** Lifecycle fields shared by ordinary generation and compaction requests. */
25
+ interface RequestViewBase {
26
+ /** Sequence that opened the operation represented by this request. */
27
+ startSeq: number;
28
+ startedAt: number;
29
+ completedAt: number | null;
30
+ status: 'running' | 'complete' | 'error';
31
+ error?: string;
32
+ provenance?: AssistantProvenanceView;
33
+ requestConfig?: AssistantRequestConfig;
34
+ usage?: unknown;
35
+ /** Assistant message or compaction summary sequence produced by this request. */
36
+ resultSeq?: number;
37
+ }
38
+ /** One ordinary assistant generation assembled from durable request events. */
39
+ interface AssistantRequestView extends RequestViewBase {
40
+ purpose: 'assistant';
41
+ turn: number;
42
+ /** Agent-loop step that issued this request. */
43
+ step: number;
44
+ /** Effective ordinary request input, inherited until a later header changes it. */
45
+ prompt?: ConversationPromptSnapshot;
46
+ /** Prompt change logged while preparing this request. */
47
+ promptChange?: RequestPromptChange;
48
+ /** Retry ordinal scheduled after a failed ordinary request. */
49
+ retry?: number;
50
+ maxRetries?: number;
51
+ retryDelayMs?: number;
52
+ }
53
+ /** One compaction provider request, either turn-owned or standalone between turns. */
54
+ interface CompactionRequestView extends RequestViewBase {
55
+ purpose: 'compaction';
56
+ /** Owning turn, or `null` when manual compaction ran between turns. */
57
+ turn: number | null;
58
+ /** Direct compaction requests do not consume an agent-loop step. */
59
+ step: 0;
60
+ /** Compaction replacement message sequence, when one was committed. */
61
+ replacementSeq?: number;
62
+ /** Safe compaction summary projection. */
63
+ summary?: readonly ContentBlock[];
64
+ /** Complete compaction provider output before the safe projection. */
65
+ rawOutput?: readonly ContentBlock[];
66
+ }
67
+ /** One provider request assembled from durable request lifecycle events. */
68
+ export type RequestView = AssistantRequestView | CompactionRequestView;
69
+ /** Request data consumed by the stage-oriented Trajectory layout. */
70
+ export interface RequestInspectionSnapshot {
71
+ requests: readonly RequestView[];
72
+ callSchemas: ReadonlyMap<string, ToolSchema>;
73
+ }
74
+ //# sourceMappingURL=request-inspection.d.ts.map
@@ -0,0 +1,415 @@
1
+ /**
2
+ * SessionRuntime: root sessions service — list snapshot store (manager
3
+ * projection; carries `current`, the persisted selection every
4
+ * session-scoped surface keys off), Agent scope tree (mintScope pattern: no-op plugin
5
+ * Fiber + ctx.extend scope tag; one scope per session, agent id === session
6
+ * id), stable SessionBinding cache, breadcrumb-route projection.
7
+ *
8
+ * Scope lifecycle is stage-driven: a scope is minted lazily on first
9
+ * resolution (pure — resolution has no side effects and is render-safe);
10
+ * the event window and deferred teardown key off the STAGED session, which
11
+ * follows `list.current` exactly. Staging is the open signal: the window
12
+ * opens ⟺ the session is on stage (today the stage is `current`; the staged
13
+ * state can widen to a multi-pane list later). A session leaving the list
14
+ * tears its scope down immediately unless it is the staged one, whose scope
15
+ * survives frozen (read-only view) until the stage moves on.
16
+ */
17
+ import type { Context } from '@hydraharness/cordis';
18
+ import type { ConversationRevision, SessionVersionState, IApiClient, RpcError, RpcResult, SessionId, SubagentAddress, JobView, WorkspaceId } from '@hydraharness/harness-api-remotes/client';
19
+ import type { PromptRevisionRequest } from '@hydraharness/harness-host-apiproxy/api';
20
+ import type { HostObservable, SessionMaybeProvideInfo, SessionProvideInfo } from '@hydraharness/harness-client-ui-slots';
21
+ import type { SessionProjectionMap } from '@hydraharness/harness-session-projection/types';
22
+ import type { SnapshotStore } from '../contract/store.ts';
23
+ import type { SessionFace } from '../contract/session.ts';
24
+ import type { AgentContext, ISessions } from '../contract/sessions.ts';
25
+ import type { ConversationRuntime } from './conversation-assembler.ts';
26
+ import { SessionManager } from './manager.ts';
27
+ import type { SessionRemotes } from './remotes.ts';
28
+ import type { SessionListPhase, SessionSearchResultItem, SubagentCatalogSnapshot } from './manager.ts';
29
+ import type { PendingInteractionStatus } from './pending.ts';
30
+ /** Session list row projected from the host list RPC plus live stream increments. */
31
+ export interface SessionSummary {
32
+ /** Transcript paths sharing this session's storage identity. */
33
+ versionState?: SessionVersionState;
34
+ id: SessionId;
35
+ /** Latest durable log-backed title, absent until the host projects one. */
36
+ title?: string;
37
+ /** Human-facing label: durable title, project basename, then session id. */
38
+ displayTitle: string;
39
+ cwd?: string;
40
+ /**
41
+ * Agent preset this session's agent was composed from; absent when the
42
+ * deployment composes no presets. The session header labels what the
43
+ * session actually runs rather than the deployment's current default.
44
+ */
45
+ agentPreset?: string;
46
+ parentId?: SessionId;
47
+ /** Prompt revision grouped under its original conversation. */
48
+ revision?: ConversationRevision;
49
+ /** Coarse durable origin for navigation filtering; not a continuation capability. */
50
+ origin?: 'subagent';
51
+ running: boolean;
52
+ /** User interaction currently blocking this session (sidebar amber-dot state). */
53
+ pendingInteraction?: PendingInteractionStatus;
54
+ /** Finished while not selected and not yet opened — the sidebar's green "done" reminder. Absent = false. */
55
+ completed?: boolean;
56
+ /**
57
+ * Empty-log bit (host summary derivation mirror). New Session reuses a blank
58
+ * one targeting the same workspace. Filtering stays with the consumer: the
59
+ * store carries every row, while the Workspace browser shows only the
60
+ * selected blank entry.
61
+ */
62
+ blank: boolean;
63
+ updatedAt: number;
64
+ /** Current host-computed projection values retained by the object layer. */
65
+ projectionValues?: Readonly<Partial<SessionProjectionMap>>;
66
+ }
67
+ /**
68
+ * Session list store shape. `current` rides the same snapshot (arbitrated:
69
+ * the single useSessions standard hook reads list and selection together —
70
+ * sidebar highlighting and SessionProvider share one fact source).
71
+ */
72
+ export interface SessionListState {
73
+ /** Host-list order; addressed breadcrumb-only rows are excluded. */
74
+ ids: SessionId[];
75
+ /** Host rows plus the current addressed subagent route used by navigation. */
76
+ byId: Record<SessionId, SessionSummary>;
77
+ current: SessionId | undefined;
78
+ /** Last viewed version per conversation, retained across navigation and browser reloads. */
79
+ viewedVersions?: Readonly<Partial<Record<SessionId, SessionId>>>;
80
+ /** Arrival lifecycle projected 1:1 from the manager snapshot (see SessionListPhase): empty-with-ready means "truly no sessions". */
81
+ phase: SessionListPhase;
82
+ /** Direct durable catalogs keyed by their selected parent address. */
83
+ subagentsByParent: Readonly<Record<SessionId, SubagentCatalogSnapshot>>;
84
+ /**
85
+ * Background jobs each session can see, mirrored last-wins from
86
+ * `session/jobs`. A missing key is an empty set — the Host sends no baseline
87
+ * for a session without tasks — so consumers read absence, never a sentinel.
88
+ */
89
+ jobsBySession: Readonly<Record<SessionId, readonly JobView[]>>;
90
+ /** Current session's catalog-derived address, absent on ordinary navigation. */
91
+ currentAddress: SubagentAddress | undefined;
92
+ }
93
+ /** Structured session-create failure. */
94
+ export declare class SessionCreateError extends Error {
95
+ readonly rpcError: RpcError;
96
+ readonly requestedSessionId: SessionId | undefined;
97
+ readonly name = "SessionCreateError";
98
+ /**
99
+ * @param rpcError - Host business or folded transport error.
100
+ * @param requestedSessionId - caller-preallocated id used for later stream/list reconciliation.
101
+ */
102
+ constructor(rpcError: RpcError, requestedSessionId: SessionId | undefined);
103
+ }
104
+ /** Structured session-fork failure. */
105
+ export declare class SessionForkError extends Error {
106
+ readonly rpcError: RpcError;
107
+ readonly sourceSessionId: SessionId;
108
+ readonly name = "SessionForkError";
109
+ /**
110
+ * @param rpcError - Host business or folded transport error.
111
+ * @param sourceSessionId - the session the fork was cut from.
112
+ */
113
+ constructor(rpcError: RpcError, sourceSessionId: SessionId);
114
+ }
115
+ /** Session assembly handle for SessionProvider/inject factories (identity-stable per session). */
116
+ export interface SessionBinding {
117
+ readonly sessionId: SessionId;
118
+ /** The outward session face only — feature code never sees the concrete class. */
119
+ readonly session: SessionFace;
120
+ readonly ctx: AgentContext;
121
+ }
122
+ export { scopeOf } from '../agents/scope.ts';
123
+ /**
124
+ * Workspace display title of a session cwd: the path's last non-empty
125
+ * segment (both separators accepted; trailing separators ignored), or ''
126
+ * for separator-only paths — callers own their fallback (session id, raw
127
+ * cwd, default-directory copy). The repo-wide single basename derivation —
128
+ * every surface naming a workspace (picker rows, toggle labels, list titles)
129
+ * calls this instead of re-splitting paths.
130
+ * @param cwd - workspace directory path.
131
+ * @returns basename title, or '' when no non-empty segment exists.
132
+ */
133
+ export declare function workspaceTitleOf(cwd: string): string;
134
+ /** One plugin's per-session standard-props contribution (see {@link SessionRuntime.provide}). */
135
+ export interface SessionProvideContribution {
136
+ /** Bare observable sources, keyed by hook base name ('input' → useInput). */
137
+ hooks?: Record<string, HostObservable<unknown>>;
138
+ /** Stable plain members (action callbacks etc.), spread into standard props verbatim. */
139
+ props?: Record<string, unknown>;
140
+ }
141
+ /**
142
+ * Static declaration plus per-session resolver for one standard-kit
143
+ * contribution. The declared names let the renderer construct the same hook
144
+ * and prop surface while no session is current.
145
+ */
146
+ export interface SessionProvideDescriptor {
147
+ /** Hook base names (`input` becomes `useInput`). */
148
+ hooks?: readonly string[];
149
+ /** Plain standard-prop names. */
150
+ props?: readonly string[];
151
+ /** Resolve every declared member for one definite session. */
152
+ resolve(binding: SessionBinding): SessionProvideContribution;
153
+ }
154
+ /** Root sessions service: list store, current selection, object-layer manager, scope tree, bindings, and breadcrumb routes. */
155
+ export declare class SessionRuntime implements ISessions {
156
+ private readonly rootCtx;
157
+ /**
158
+ * The wire schema's own result bound, re-exposed for presentation plugins as
159
+ * injected data. Not per-connection state: the `session.search` response
160
+ * schema caps `items` at this constant, so every transport (fixture included)
161
+ * reports the same number.
162
+ */
163
+ readonly searchResultLimit = 20;
164
+ /** List snapshot store (list RPC + host stream increments; re-pulled on reconnect) — the useSessions standard feed, current included. */
165
+ readonly list: SnapshotStore<SessionListState>;
166
+ /** The object-layer instance cluster and frame dispatch entry. */
167
+ private readonly manager;
168
+ /**
169
+ * Atomic current-session provide projection: selection changes and
170
+ * provider-roster changes publish through this one source (the renderer
171
+ * host's `sessions.provide` feed), so a roster change under a stable
172
+ * current id republishes the bundle instead of stranding mounted entries.
173
+ */
174
+ readonly currentProvideInfo: HostObservable<SessionMaybeProvideInfo>;
175
+ /**
176
+ * Persisted selection cell (the durable half of `list.current`). Private on
177
+ * purpose: reads go through the list snapshot; writes through {@link
178
+ * SessionRuntime.open} / {@link SessionRuntime.clear}. Projection
179
+ * validates it against the live list instead of destructively pruning, so a
180
+ * selection survives transient list states (reconnect re-pull) and
181
+ * resurfaces when its session returns.
182
+ */
183
+ private readonly selection;
184
+ private readonly scopes;
185
+ /** The provide channel (roster, materialization rules, current projection) — shared with the test runtime's double. */
186
+ private readonly provideChannel;
187
+ /**
188
+ * The staged session id — follows `list.current` exactly, holding its last
189
+ * defined value across masked gaps (a transiently absent selection blanks
190
+ * `current` without moving the stage, so reconnect re-pulls and removals
191
+ * keep the staged scope's frozen view alive until the stage moves on).
192
+ */
193
+ private watched;
194
+ /** Removed-while-staged sessions whose teardown waits for the stage to move away. */
195
+ private readonly deferredRemovals;
196
+ /**
197
+ * @param ctx - client root context (scope fibers mount under it).
198
+ * @param api - wire client shared with every Session.
199
+ * @param remote - generated Remote namespaces shared with every Session.
200
+ * @param conversationRuntime - same-pass registry instances, when runtime apply owns them.
201
+ */
202
+ constructor(rootCtx: Context, api: IApiClient, remote: SessionRemotes, conversationRuntime?: ConversationRuntime);
203
+ /**
204
+ * Register a per-session standard-props provider: every session-scope slot
205
+ * component receives the contributed members as standard props (`hooks`
206
+ * sources become `use<Name>` selector hooks on the render side; `props`
207
+ * spread verbatim). Contributions materialize lazily with the session's
208
+ * scope record and die with it. Registration order is resolution order;
209
+ * duplicate member names fail loud at materialization.
210
+ * @param descriptor - static member roster plus per-session resolver.
211
+ * @returns disposer removing the provider (already-materialized bundles keep their members until their scope drops).
212
+ */
213
+ provide(descriptor: SessionProvideDescriptor): () => void;
214
+ /**
215
+ * Select a listed or retained catalog-addressed session as current.
216
+ * @param id - listed or addressed session id.
217
+ */
218
+ open(id: SessionId): void;
219
+ /**
220
+ * Open a healthy catalog child through its direct-parent address.
221
+ * @param address - catalog-derived parent and child ids.
222
+ */
223
+ openSubagent(address: SubagentAddress): void;
224
+ /**
225
+ * Resolve an already discovered direct-parent address without opening it.
226
+ * Feature plugins use this to avoid Agent-bound RPCs in persisted child views.
227
+ * @param id - possible addressed child id.
228
+ * @returns The retained address, when present.
229
+ */
230
+ subagentAddress(id: SessionId): SubagentAddress | undefined;
231
+ /**
232
+ * Inform the runtime whether a catalog menu is consuming membership updates.
233
+ * @param parentSessionId - selected parent.
234
+ * @param open - menu state.
235
+ */
236
+ setSubagentCatalogOpen(parentSessionId: SessionId, open: boolean): void;
237
+ /**
238
+ * Refresh one direct-child catalog.
239
+ * @param parentSessionId - catalog owner.
240
+ */
241
+ refreshSubagents(parentSessionId: SessionId): Promise<void>;
242
+ noteAgentPreset(sessionId: SessionId, agentPreset: string): void;
243
+ /**
244
+ * Clear the current selection so the layout shows the no-session empty
245
+ * state (new-session affordance and the workspace preselection flow).
246
+ * Clears the persisted current address — a reload stays on empty until the
247
+ * user opens or starts a session. Conversation version choices are retained.
248
+ * The staged scope keeps its frozen view
249
+ * per the masked-gap contract until the next open() moves the stage.
250
+ */
251
+ clear(): void;
252
+ /**
253
+ * Refresh the real Session baseline, reusing an in-flight pull.
254
+ * @returns completion of the current or newly started baseline pull.
255
+ */
256
+ refresh(): Promise<void>;
257
+ /**
258
+ * Search the Host's visible message-content index. Results stay
259
+ * request-local; the list snapshot remains the metadata authority.
260
+ * @param query - non-blank literal phrase.
261
+ * @param signal - cancellation for a superseded search.
262
+ * @returns bounded results or a business/transport error.
263
+ */
264
+ search(query: string, signal: AbortSignal): Promise<RpcResult<{
265
+ items: SessionSearchResultItem[];
266
+ hasMore: boolean;
267
+ }>>;
268
+ /**
269
+ * Route a mux stream envelope into the Session object layer.
270
+ * @param envelope - validated mux stream envelope.
271
+ */
272
+ handleMuxEnvelope(envelope: Parameters<SessionManager['handleMuxEnvelope']>[0]): void;
273
+ /**
274
+ * Route a Host stream envelope into the Session object layer.
275
+ * @param envelope - validated Host stream envelope.
276
+ */
277
+ handleHostEnvelope(envelope: Parameters<SessionManager['handleHostEnvelope']>[0]): void;
278
+ /** Rebuild the Session baseline and every opened window after connection. */
279
+ handleConnected(): void;
280
+ /** Drop generation-scoped live interaction state the moment a connection generation dies. */
281
+ handleDisconnected(): void;
282
+ /**
283
+ * Create a session on the host. Resolution guarantee: by the time the
284
+ * promise resolves, the created session is in the list store and
285
+ * {@link SessionRuntime.binding} resolves it — callers (New Session
286
+ * draft hand-off) may address the scope synchronously, without waiting a
287
+ * notifier flush. The synchronous projection below makes this structural
288
+ * rather than an accident of microtask ordering.
289
+ * @param opts - target workspace or directory and an optional preallocated id.
290
+ * @returns the new session id.
291
+ * @throws {SessionCreateError} with the requested id.
292
+ */
293
+ create(opts?: {
294
+ workspaceId?: WorkspaceId;
295
+ cwd?: string;
296
+ sessionId?: SessionId;
297
+ reuseWorkspaceBlank?: true;
298
+ }): Promise<SessionId>;
299
+ /** Permanently delete a session after its caller has confirmed the action. */
300
+ delete(sessionId: SessionId): Promise<void>;
301
+ /**
302
+ * Fork a session from a completed-turn prefix of the source (same
303
+ * synchronous-addressability guarantee as {@link SessionRuntime.create}:
304
+ * on resolution the child is in the list store and open() can target it).
305
+ * @param opts - source session id, the optional event seq anchoring the
306
+ * cut (the boundary is the first turn/end at or after it; an in-log
307
+ * anchor in an open turn is unavailable rather than clipped backward),
308
+ * and whether to increment an inherited durable title before resolving.
309
+ * A fractional anchor floors to a real event seq: the frozen nodes of an
310
+ * interrupted turn carry flow-ordering seqs between two events, and the
311
+ * wire takes integers only.
312
+ * `beforeSeq` excludes the selected turn-opening user message's entire turn
313
+ * and cannot accompany `atSeq`; the first and active turns are supported.
314
+ * @returns the child session id.
315
+ * @throws {SessionForkError} with the source id.
316
+ * @throws {Error} when a requested child-title rename fails after creation.
317
+ */
318
+ fork(opts: {
319
+ sessionId: SessionId;
320
+ atSeq?: number;
321
+ beforeSeq?: number;
322
+ increaseTitle?: boolean;
323
+ }): Promise<SessionId>;
324
+ /**
325
+ * Admit an edit or retry without changing selection until the Host acknowledges it.
326
+ * @param input - Revision admission and stable idempotency key.
327
+ * @returns synchronously addressable attempt identity.
328
+ */
329
+ revise(input: PromptRevisionRequest): Promise<SessionId>;
330
+ /**
331
+ * Select or reference a session-local transcript path.
332
+ * @param sessionId - Owning session.
333
+ * @param versionId - Stored transcript path.
334
+ * @param mode - View only or add logged reference context.
335
+ * @returns Completion after the Host acknowledgement and refreshed catalog.
336
+ */
337
+ selectVersion(sessionId: SessionId, versionId: import('@hydraharness/harness-session/types').SessionVersionId, mode?: 'view' | 'reference'): Promise<void>;
338
+ /**
339
+ * Resolve an Agent-scoped context view (use-and-discard).
340
+ * @param id - session id (the agent identity — 1:1 same axis).
341
+ * @returns scoped ctx, or undefined for a session neither listed nor already scoped.
342
+ */
343
+ scope(id: SessionId): AgentContext | undefined;
344
+ /**
345
+ * Read the Agent scope tag off a context. Service-method boundary: fetch
346
+ * bundles must reach scope resolution through ctx.sessions — a cross-bundle
347
+ * value import of the standalone helper would inline a second module
348
+ * instance whose private tag Symbol never matches.
349
+ * @param ctx - any client context.
350
+ * @returns the session id, or undefined on root contexts.
351
+ */
352
+ scopeOf(ctx: Context): SessionId | undefined;
353
+ /**
354
+ * Resolve the business Session behind an Agent-scoped context — the one
355
+ * hop every scoped consumer (event listeners, per-session controllers)
356
+ * takes from ctx-space into object-space (the client mirror of host
357
+ * `agent.session`). Same service-method boundary as
358
+ * {@link SessionRuntime.scopeOf}.
359
+ * @param ctx - an Agent-scoped context.
360
+ * @returns the session face, or undefined when the ctx is untagged or its scope was pruned.
361
+ */
362
+ sessionOf(ctx: Context): SessionFace | undefined;
363
+ /**
364
+ * Resolve the stable session binding (scope-addressed assembly feed). Pure
365
+ * resolution — no staging, no window side effects.
366
+ * @param id - session id.
367
+ * @returns binding, or undefined for a session neither listed nor already scoped.
368
+ */
369
+ binding(id: SessionId): SessionBinding | undefined;
370
+ /**
371
+ * Resolve one session's render-layer standard-props bundle (ctx never
372
+ * enters the render layer; the renderer subscribes to
373
+ * {@link SessionRuntime.currentProvideInfo}). Pure resolution — render-safe:
374
+ * no staging, no window side effects (StrictMode double-invokes and
375
+ * concurrent discarded passes must stay free).
376
+ */
377
+ provideInfo(id: string): SessionProvideInfo | undefined;
378
+ /**
379
+ * Resolve the current-session-optional standard kit. Unknown or absent ids
380
+ * return the static no-session projection rather than removing hook props.
381
+ */
382
+ private maybeProvideInfo;
383
+ /**
384
+ * Move the stage to the list's current session: sweep teardowns deferred
385
+ * behind the previous occupant and pull the new occupant's history window.
386
+ * Staging IS the open signal — the window opens ⟺ the session is on stage
387
+ * — and open() is idempotent (an in-flight or completed open no-ops; a
388
+ * failed one retries the next time current is touched).
389
+ */
390
+ private followCurrent;
391
+ /**
392
+ * Lazily mint the scope + binding for an eligible session. Eligibility and
393
+ * prune share one predicate: listed on the host or selected
394
+ * through a retained subagent address. Breadcrumb-only ancestors remain
395
+ * summary data and do not keep scopes alive.
396
+ */
397
+ private resolve;
398
+ /** The one aliveness predicate shared by scope mint and prune: host-listed or currently addressed. */
399
+ private eligible;
400
+ /** Project the manager's list snapshot into the store (title derivation is display-only). */
401
+ private projectList;
402
+ /** Tear down scope + instance for no-longer-eligible sessions off stage; the staged one defers until the stage moves. */
403
+ private pruneScopes;
404
+ /**
405
+ * One teardown for the whole per-session axis: the scope
406
+ * fiber (cascading every actx-registered effect: input shell, slash
407
+ * controller, popup, plugin stores, listeners), the session-keyed slot
408
+ * stores, and the Session instance itself — the host session log is the
409
+ * durable truth, a reopen lazily rebuilds and backfills via open().
410
+ */
411
+ private dropScope;
412
+ /** Run deferred teardowns whose session is no longer staged (called when the stage moves). */
413
+ private sweepDeferred;
414
+ }
415
+ //# sourceMappingURL=service.d.ts.map