@bobannomi/client 0.2.0 → 0.3.0

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/service.js CHANGED
@@ -3915,13 +3915,13 @@ function withoutCursor(url) {
3915
3915
  }
3916
3916
 
3917
3917
  // src/resources/session/session-request-id.ts
3918
- var promptRequestCounter = 0;
3919
- function createPromptRequestId() {
3918
+ var sessionRequestCounter = 0;
3919
+ function createSessionRequestId() {
3920
3920
  if (typeof globalThis.crypto?.randomUUID === "function") {
3921
3921
  return globalThis.crypto.randomUUID();
3922
3922
  }
3923
- promptRequestCounter += 1;
3924
- return `prompt-${Date.now().toString(36)}-${promptRequestCounter.toString(36)}`;
3923
+ sessionRequestCounter += 1;
3924
+ return `prompt-${Date.now().toString(36)}-${sessionRequestCounter.toString(36)}`;
3925
3925
  }
3926
3926
 
3927
3927
  // src/resources/session/session-configuration-requests.ts
@@ -3946,8 +3946,8 @@ async function getDraftComposerOptions(transport, input, options = {}) {
3946
3946
  async function create(transport, input, options = {}) {
3947
3947
  const body = parseCreateSessionRequest({
3948
3948
  ...input,
3949
- id: input.id ?? createPromptRequestId(),
3950
- requestId: input.requestId ?? createPromptRequestId()
3949
+ id: input.id ?? createSessionRequestId(),
3950
+ requestId: input.requestId ?? createSessionRequestId()
3951
3951
  });
3952
3952
  if (body.cwd === void 0) await requireDaemonFeature(transport, "projectSessionCreation", options.signal);
3953
3953
  const response = await transport.request(
@@ -4099,7 +4099,7 @@ function selectSessionMessagesWithParts(bucket) {
4099
4099
  parts: [...bucket.partsByMessageId[message.id] ?? []].sort((a, b) => a.seq - b.seq)
4100
4100
  }));
4101
4101
  }
4102
- function selectVisibleSessionMessagesWithParts(bucket) {
4102
+ function getVisibleSessionMessages(bucket) {
4103
4103
  return selectSessionMessagesWithParts(bucket).map(({ message, parts }) => ({
4104
4104
  message,
4105
4105
  parts: parts.filter((part) => !isSupersededModelPart(part))
@@ -4124,7 +4124,7 @@ var UnsupportedSessionEventSchemaVersionError = class extends Error {
4124
4124
  };
4125
4125
  }
4126
4126
  };
4127
- function createInitialClientState() {
4127
+ function createClientState() {
4128
4128
  return {
4129
4129
  sessions: {},
4130
4130
  sessionOrder: [],
@@ -4135,7 +4135,7 @@ function createInitialClientState() {
4135
4135
  lastSeq: 0
4136
4136
  };
4137
4137
  }
4138
- function applySessionSnapshot(state, snapshot) {
4138
+ function replaceSessionState(state, snapshot) {
4139
4139
  const knownCursor = state.snapshotCursorBySession[snapshot.session.id] ?? 0;
4140
4140
  if (snapshot.cursor < knownCursor) return state;
4141
4141
  if (Object.values(state.eventsBySeq).some((event) => event.sessionId === snapshot.session.id && event.seq > snapshot.cursor)) return state;
@@ -4493,7 +4493,7 @@ function applySessionStreamEvent(state, event) {
4493
4493
  }
4494
4494
  function applySessionStreamSnapshot(state, snapshot) {
4495
4495
  if (snapshot.cursor < state.lastSeq) return state;
4496
- return { ...applySessionSnapshot(state, snapshot), eventsBySeq: {} };
4496
+ return { ...replaceSessionState(state, snapshot), eventsBySeq: {} };
4497
4497
  }
4498
4498
 
4499
4499
  // src/state/sync.ts
@@ -4508,7 +4508,7 @@ async function* syncEvents(client, options = {}) {
4508
4508
  idleTimeoutMs: options.idleTimeoutMs ?? DEFAULT_SESSION_IDLE_TIMEOUT_MS
4509
4509
  });
4510
4510
  }
4511
- async function* runEventSync(client, options, initialState = createInitialClientState(), onLiveEvent) {
4511
+ async function* runEventSync(client, options, initialState = createClientState(), onLiveEvent) {
4512
4512
  let state = initialState;
4513
4513
  let cursor = Math.max(0, options.cursor ?? 0, state.lastSeq);
4514
4514
  let attempt = 0;
@@ -4523,7 +4523,7 @@ async function* runEventSync(client, options, initialState = createInitialClient
4523
4523
  partView: options.partView
4524
4524
  });
4525
4525
  if (signal?.aborted) return;
4526
- const next = initial ? applySessionSnapshot(state, snapshot) : applySessionStreamSnapshot(state, snapshot);
4526
+ const next = initial ? replaceSessionState(state, snapshot) : applySessionStreamSnapshot(state, snapshot);
4527
4527
  state = Object.keys(next.eventsBySeq).length ? { ...next, eventsBySeq: {} } : next;
4528
4528
  cursor = Math.max(cursor, snapshot.cursor, state.lastSeq);
4529
4529
  };
@@ -4633,7 +4633,7 @@ async function waitForRun(client, options) {
4633
4633
  if (!run || run.status === "pending" || run.status === "running") continue;
4634
4634
  return {
4635
4635
  run,
4636
- messages: selectVisibleSessionMessagesWithParts(bucket).filter((item) => item.message.runId === options.runId)
4636
+ messages: getVisibleSessionMessages(bucket).filter((item) => item.message.runId === options.runId)
4637
4637
  };
4638
4638
  }
4639
4639
  options.signal?.throwIfAborted();
@@ -4827,7 +4827,7 @@ async function admitPrompt(transport, sessionId, input, options = {}) {
4827
4827
  `/sessions/${encodeURIComponent(sessionId)}/prompts`,
4828
4828
  {
4829
4829
  method: "POST",
4830
- body: { ...input, expectedModelConnection, id: input.id ?? createPromptRequestId() },
4830
+ body: { ...input, expectedModelConnection, id: input.id ?? createSessionRequestId() },
4831
4831
  signal: options.signal
4832
4832
  }
4833
4833
  );
@@ -4879,7 +4879,7 @@ async function resumeInterruptedRun(transport, sessionId, runId, input = {}, opt
4879
4879
  `/sessions/${encodeURIComponent(sessionId)}/runs/${encodeURIComponent(runId)}/resume`,
4880
4880
  {
4881
4881
  method: "POST",
4882
- body: { ...input, id: input.id ?? createPromptRequestId() },
4882
+ body: { ...input, id: input.id ?? createSessionRequestId() },
4883
4883
  signal: options.signal
4884
4884
  }
4885
4885
  );
@@ -5011,8 +5011,8 @@ function createSessionHandle(transport, syncClient, management, sessionId) {
5011
5011
  method: "POST",
5012
5012
  body: parseForkSessionRequest({
5013
5013
  ...input,
5014
- id: input.id ?? createPromptRequestId(),
5015
- requestId: input.requestId ?? createPromptRequestId()
5014
+ id: input.id ?? createSessionRequestId(),
5015
+ requestId: input.requestId ?? createSessionRequestId()
5016
5016
  }),
5017
5017
  signal: options.signal
5018
5018
  }