@omercnet/paseo-omp 0.3.0-next.102.1 → 0.3.0-next.103.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omercnet/paseo-omp",
3
- "version": "0.3.0-next.102.1",
3
+ "version": "0.3.0-next.103.1",
4
4
  "type": "module",
5
5
  "description": "Paseo integration for OMP, including its direct provider and workspace tooling.",
6
6
  "license": "MIT",
@@ -1262,6 +1262,7 @@ const ProtocolNegotiationResultSchema = z.object({
1262
1262
  });
1263
1263
 
1264
1264
  export type OmpModel = z.infer<typeof OmpModelSchema>;
1265
+ export type OmpBranchResult = z.infer<typeof OmpBranchResultSchema>;
1265
1266
  export type OmpSessionState = z.infer<typeof OmpSessionStateSchema>;
1266
1267
  export type OmpSessionStats = z.infer<typeof OmpSessionStatsSchema>;
1267
1268
  export type OmpCompactionResult = z.infer<typeof OmpCompactionResultSchema>;
@@ -1369,7 +1370,7 @@ export interface OmpRuntimeSession {
1369
1370
  respondToExtensionUi(response: OmpExtensionUiResponse): Promise<void>;
1370
1371
  respondToToolApproval(response: OmpToolApprovalResponse): Promise<void>;
1371
1372
  getBranchMessages(): Promise<Array<{ entryId: string; text: string }>>;
1372
- branch(entryId: string): Promise<{ text: string; cancelled: boolean }>;
1373
+ branch(entryId: string): Promise<OmpBranchResult>;
1373
1374
  readonly canReplayHistory: boolean;
1374
1375
  getMessages(): Promise<OmpMessage[]>;
1375
1376
  abort(): Promise<void>;
@@ -1416,6 +1417,13 @@ export interface OmpRpcRuntimeOptions {
1416
1417
  ) => OmpSessionDescriptor[] | Promise<OmpSessionDescriptor[]>;
1417
1418
  }
1418
1419
 
1420
+ export class OmpRpcRequestRejectedError extends Error {
1421
+ constructor() {
1422
+ super("OMP RPC request failed");
1423
+ this.name = "OmpRpcRequestRejectedError";
1424
+ }
1425
+ }
1426
+
1419
1427
  type PendingRequest = {
1420
1428
  resolve(value: unknown): void;
1421
1429
  reject(error: Error): void;
@@ -2517,7 +2525,7 @@ class OmpRpcProcess {
2517
2525
  settled.reject(new Error("OMP RPC response is invalid"));
2518
2526
  }
2519
2527
  } else {
2520
- settled.reject(new Error("OMP RPC request failed"));
2528
+ settled.reject(new OmpRpcRequestRejectedError());
2521
2529
  }
2522
2530
  }
2523
2531
 
@@ -21,6 +21,7 @@ import { OmpHostToolsBridge, type OmpMcpConnector, validateOmpHostToolConfig } f
21
21
  import { isOmpImageMimeType, isValidImagePayload, OmpImageMaterializer } from "./image";
22
22
  import type {
23
23
  OmpAvailableCommand,
24
+ OmpBranchResult,
24
25
  OmpCompactionResult,
25
26
  OmpExtensionUiResponse,
26
27
  OmpImage,
@@ -35,7 +36,7 @@ import type {
35
36
  OmpToolApprovalCancel,
36
37
  OmpToolApprovalRequest,
37
38
  } from "./omp-rpc";
38
- import { buildOmpSpawnRequest } from "./omp-rpc";
39
+ import { buildOmpSpawnRequest, OmpRpcRequestRejectedError } from "./omp-rpc";
39
40
  import {
40
41
  BoundedStringSet,
41
42
  boundedJsonBytes,
@@ -1679,19 +1680,22 @@ export class OmpProviderSession {
1679
1680
  throw new OmpPublicError("OMP conversation rewind requires negotiated RPC protocol v2");
1680
1681
  }
1681
1682
  const entryId = this.projector.resolveRevertToken(input.token);
1682
- const [branchMessages, beforeState] = await Promise.all([
1683
- runtime.getBranchMessages(),
1684
- runtime.getState(),
1685
- ]);
1683
+ const beforeState = await runtime.getState();
1686
1684
  this.requireCurrentRuntime(runtime, generation);
1687
1685
  if (this.activeTurn || beforeState.isStreaming || beforeState.isCompacting) {
1688
1686
  throw new OmpPublicError("Cannot rewind the OMP conversation while a turn is active");
1689
1687
  }
1690
- if (!branchMessages.some((message) => message.entryId === entryId)) {
1691
- throw new OmpPublicError("OMP conversation rewind token is stale");
1692
- }
1693
1688
  branchMutationPossible = true;
1694
- const result = await runtime.branch(entryId);
1689
+ let result: OmpBranchResult;
1690
+ try {
1691
+ result = await runtime.branch(entryId);
1692
+ } catch (error) {
1693
+ if (error instanceof OmpRpcRequestRejectedError) {
1694
+ branchMutationPossible = false;
1695
+ throw new OmpPublicError("OMP conversation rewind token is stale");
1696
+ }
1697
+ throw error;
1698
+ }
1695
1699
  this.requireCurrentRuntime(runtime, generation);
1696
1700
  if (result.cancelled) {
1697
1701
  branchMutationPossible = false;