@omercnet/paseo-omp 1.3.1 → 1.3.2-next.231.1

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.
@@ -93,6 +93,23 @@ type RewindCleanupQuarantine = (cleanup: Promise<void>) => void;
93
93
  type RewindSessionRetirement = () => void;
94
94
  type SessionPermissionInput = Extract<ProviderInput, { type: "session.permission" }>;
95
95
  type Emit = (event: ProviderEvent) => void;
96
+
97
+ /** The surface a connection drives for every opened session, live or history-only. */
98
+ export interface OmpOpenedSession {
99
+ readonly persistenceSessionId: string | undefined;
100
+ openPaseoBrowser(url: string): Promise<void>;
101
+ setBrowserAuthorizationIssuer(issue: ((url: string) => string | undefined) | null): void;
102
+ publishOpened(requestId: string): Promise<void>;
103
+ prompt(input: SessionPromptInput): Promise<void>;
104
+ permission(input: SessionPermissionInput): Promise<void>;
105
+ configure(input: SessionConfigureInput): Promise<void>;
106
+ revert(input: SessionRevertInput): Promise<void>;
107
+ interrupt(input: SessionInterruptInput): Promise<void>;
108
+ close(input?: SessionCloseInput): Promise<void>;
109
+ abortOpen(): Promise<void>;
110
+ beginConnectionShutdown(): void;
111
+ }
112
+
96
113
  const LOCAL_ONLY_SETTLE_MS = 5_000;
97
114
  const AGENT_END_STATE_TIMEOUT_MS = 2_000;
98
115
  const AGENT_END_HISTORY_TIMEOUT_MS = 2_000;
@@ -119,7 +136,7 @@ const MAX_PENDING_USER_BYTES = 2 * 1024 * 1024;
119
136
  const MAX_UNCLAIMED_BRANCH_BYTES = 4 * 1024 * 1024;
120
137
  class OmpCatalogEscape extends OmpPublicError {}
121
138
  const MAX_REPLAY_MESSAGES = 100_000;
122
- const REPLAY_TIMEOUT_MS = 20_000;
139
+ export const REPLAY_TIMEOUT_MS = 20_000;
123
140
  const _OMP_ASK_USER_FREEFORM_SENTINEL = "✏️ Type custom response...";
124
141
  const _MAX_FREEFORM_RESPONSE_BYTES = 64 * 1024;
125
142
  const OMP_BUILTIN_COMMANDS: readonly OmpAvailableCommand[] = [
@@ -162,7 +179,7 @@ function applicableThinkingLevel(
162
179
  return model?.reasoning === false ? undefined : level;
163
180
  }
164
181
 
165
- function fixedSessionMode(modeId = "full") {
182
+ export function fixedSessionMode(modeId = "full") {
166
183
  const mode = OMP_MODES.find((candidate) => candidate.id === modeId);
167
184
  if (!mode) throw new OmpPublicError("OMP mode is unavailable");
168
185
  return {
@@ -194,7 +211,7 @@ export function ompPersistenceSessionId(input: SessionOpenInput): string | undef
194
211
  }
195
212
  }
196
213
 
197
- async function authorizeNativeSession(
214
+ export async function authorizeNativeSession(
198
215
  runtime: OmpRuntime,
199
216
  sessionId: string,
200
217
  cwd: string,
@@ -228,7 +245,7 @@ function retainedBytes(values: readonly unknown[], maxBytes: number): number {
228
245
  return total;
229
246
  }
230
247
 
231
- async function waitForReplay<T>(operation: Promise<T>, signal: AbortSignal): Promise<T> {
248
+ export async function waitForReplay<T>(operation: Promise<T>, signal: AbortSignal): Promise<T> {
232
249
  signal.throwIfAborted();
233
250
  const aborted = Promise.withResolvers<never>();
234
251
  const onAbort = () => aborted.reject(signal.reason);
@@ -271,7 +288,7 @@ async function settleSessionCleanup(promises: readonly Promise<void>[]): Promise
271
288
  throw new AggregateError(failures, "OMP session initialization cleanup failed");
272
289
  }
273
290
  }
274
- export class OmpProviderSession {
291
+ export class OmpProviderSession implements OmpOpenedSession {
275
292
  readonly id: string;
276
293
  readonly cwd: string;
277
294
 
@@ -390,7 +390,8 @@ export class OmpSubsessionProjector {
390
390
  }
391
391
  async replay(
392
392
  messages: readonly OmpMessage[],
393
- runtimeSession: OmpRuntimeSession,
393
+ // Undefined replays the persisted journal only; history sessions have no live runtime to ask.
394
+ runtimeSession: OmpRuntimeSession | undefined,
394
395
  runtime: OmpRuntime,
395
396
  signal: AbortSignal,
396
397
  ): Promise<void> {
@@ -411,12 +412,14 @@ export class OmpSubsessionProjector {
411
412
  0,
412
413
  );
413
414
  let snapshots: OmpSubagentSnapshot[] = [];
414
- try {
415
- snapshots = await waitForReplay(runtimeSession.getSubagents(), signal);
416
- } catch (error) {
417
- if (signal.aborted) throw error;
415
+ if (runtimeSession) {
416
+ try {
417
+ snapshots = await waitForReplay(runtimeSession.getSubagents(), signal);
418
+ } catch (error) {
419
+ if (signal.aborted) throw error;
420
+ }
421
+ await this.replaySnapshots(snapshots, runtimeSession, runtime, visited, budget, signal);
418
422
  }
419
- await this.replaySnapshots(snapshots, runtimeSession, runtime, visited, budget, signal);
420
423
  signal.throwIfAborted();
421
424
  this.reconcileSnapshots(snapshots);
422
425
  completed = true;