@arbidocs/sdk 0.4.168 → 0.5.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.
@@ -15,6 +15,24 @@ declare class ArbiError extends Error {
15
15
  declare class ArbiSessionExpiredError extends ArbiError {
16
16
  constructor(message?: string);
17
17
  }
18
+ /**
19
+ * A newer `selectWorkspace` for another workspace was asked for before this one's turn: it never
20
+ * opened, and the newer one decides where the session ends.
21
+ */
22
+ declare class ArbiWorkspaceSupersededError extends ArbiError {
23
+ readonly workspaceId: string;
24
+ readonly supersededBy: string;
25
+ constructor(workspaceId: string, supersededBy: string);
26
+ }
27
+ /**
28
+ * A read made for one workspace could have been answered for another: the session's workspace was
29
+ * not, or did not stay, the one it was made for (a switch ran meanwhile). Nothing it returned is
30
+ * kept; read again in the workspace now open.
31
+ */
32
+ declare class ArbiWorkspaceChangedError extends ArbiError {
33
+ readonly workspaceId: string;
34
+ constructor(workspaceId: string);
35
+ }
18
36
  declare class ArbiApiError extends ArbiError {
19
37
  readonly status?: number;
20
38
  readonly apiError?: unknown;
@@ -818,6 +836,11 @@ type DocumentListFields = 'full' | 'lite';
818
836
  * Options for paginated document listing.
819
837
  */
820
838
  interface ListPaginatedOptions {
839
+ /**
840
+ * The workspace to list (its key must be on the session): sent with every page, and every
841
+ * document returned is checked to belong to it. Default: the session's open workspace.
842
+ */
843
+ workspaceExtId?: string;
821
844
  /**
822
845
  * Number of documents per page (applies to every page after the first).
823
846
  * @default 5000
@@ -7754,6 +7777,8 @@ declare class Arbi {
7754
7777
  private userProfile;
7755
7778
  private readonly profileListeners;
7756
7779
  private currentWorkspaceId;
7780
+ /** The latest `selectWorkspace` asked for: only it may open when its turn comes. */
7781
+ private openIntent;
7757
7782
  private chatCryptoContext;
7758
7783
  /** The chat keys I hold, opened once per set of epochs (`chatRingSignature`). */
7759
7784
  private chatRings;
@@ -7877,6 +7902,18 @@ declare class Arbi {
7877
7902
  * documents, which are listed page by page). A public workspace has no key and opens without one.
7878
7903
  */
7879
7904
  selectWorkspace(workspaceId: string): Promise<WorkspaceOpenResponse>;
7905
+ /** `POST /open` with the workspace's key sealed to this session (none for a public workspace). */
7906
+ private openOnServer;
7907
+ /** Resolves once no workspace open is running or waiting (a switch has landed on the server). */
7908
+ workspaceSettled(): Promise<void>;
7909
+ /**
7910
+ * Run `read` — a request answered from the session's open workspace — for `workspaceId`, and
7911
+ * keep its answer only if it can only be that workspace's: once no open is pending, the open
7912
+ * workspace must be `workspaceId` when it is sent and still be when it returns, with no open
7913
+ * started in between. Otherwise it throws `ArbiWorkspaceChangedError` and nothing it returned
7914
+ * is kept, so a list read across a switch can never be cached as another workspace's.
7915
+ */
7916
+ readInWorkspace<T>(workspaceId: string, read: () => Promise<T>): Promise<T>;
7880
7917
  /**
7881
7918
  * Subscribe to "the session cannot be recovered". Fires when a request failed with 401 or
7882
7919
  * "No active workspace" and neither a workspace re-open nor a silent re-login was possible
@@ -10051,7 +10088,9 @@ declare class Arbi {
10051
10088
  * }
10052
10089
  * ```
10053
10090
  */
10054
- listPaginated: (options?: ListPaginatedOptions) => AsyncGenerator<{
10091
+ listPaginated: (options?: ListPaginatedOptions & {
10092
+ workspaceId?: string;
10093
+ }) => AsyncGenerator<{
10055
10094
  external_id: string;
10056
10095
  workspace_ext_id: string;
10057
10096
  file_name?: string | null;
@@ -16689,4 +16728,4 @@ declare function getAttachableRunId(messages: readonly RunMessage[]): string | n
16689
16728
  */
16690
16729
  declare function getRunToAttach(localGeneration: LocalGeneration | undefined, messages: readonly RunMessage[]): string | null;
16691
16730
 
16692
- export { type ConnectorCatalogEntry as $, ACCOUNT_VENDOR as A, type BookingConfirmation as B, type CalDavConnectBody as C, type CalendarRead as D, type CalendarSettings as E, type CalendarSettingsBody as F, type CalendarUpdate as G, type CalendarWindow as H, CallApiError as I, type ChatAttachmentFile as J, type ChatAttachmentInput as K, type ChatCryptoContext as L, type ChatKeyRing as M, type ChatKind as N, type ChatMemberKey as O, type ChatMemberResponse as P, type ChatMessage as Q, type ChatMessageResponse as R, type ChatResponse as S, type ChatSession as T, type CitationSummary as U, type CitationToolSources as V, type CliConfig as W, type CliCredentials as X, type CommandDescriptor as Y, type ConfigStore as Z, type ConnectOptions as _, type AccountSyncResult as a, type MessageLevel as a$, type ConnectorFolder as a0, type ConnectorSyncProgress as a1, type ConnectorSyncStatus as a2, type ConnectorVendorKey as a3, type ConnectorVisibilitySettings as a4, type ContextUsage as a5, type ConversationResponse as a6, type ConversationUsageResponse as a7, type CreateFactRequest as a8, type CreateFactsRequest as a9, FLAT_TAG_KINDS as aA, type FactResponse as aB, type FactSearchRequest as aC, type FactSearchResponse as aD, type FindTimeParams as aE, type FormattedWsMessage as aF, type FreeBusyEntry as aG, type FullContextSelection as aH, GOOGLE_VENDORS as aI, type HolidayCountry as aJ, type HouseTemplateCandidate as aK, IMANAGE_VENDORS as aL, type IdentityErrorCode as aM, type IdentityPurchase as aN, type IdentityState as aO, type IdentityStatus as aP, type ImportResult as aQ, type InvitationRead as aR, type LinkedRun as aS, type ListAllOptions as aT, type ListEventsParams as aU, type ListFactsOptions as aV, type ListPaginatedOptions as aW, MAILBOX_SYNC_VENDORS as aX, MAX_RETRIEVE_DOC_IDS as aY, MICROSOFT_VENDORS as aZ, type MailAttachment as a_, type CreateWorkRequest as aa, type CreateWorkflowRequest as ab, DEFAULT_AI_USD_PER_GBP as ac, DOC_TERMINAL_STATUSES as ad, DRIVE_SYNC_VENDORS as ae, type DateTimeSpec as af, type DecryptedChat as ag, type DecryptedChatMessage as ah, type DeploymentHouseTemplate as ai, type DocInfo as aj, type DocInfoMap as ak, type DocNameMap as al, type DocumentAutomationAction as am, type DocumentListFields as an, type DocumentListOrder as ao, type DocumentSelector as ap, type DocumentWaiter as aq, type DocumentWaiterOptions as ar, type DriveSyncProgress as as, type DriveSyncSummary as at, DuplicateContactError as au, ENTITY_KINDS as av, type EditScope as aw, type EntityKind as ax, type EventCreateBody as ay, type EventPatchBody as az, type ActivityKind as b, type StepAssignee as b$, type OAuthAccountKind as b0, type OutputItemDone as b1, type OverlayItem as b2, type OverlayLayerName as b3, PRESENCE_KINDS as b4, PROMPT_CONTEXT_CHARS as b5, type ParsedSlashCommand as b6, type PendingAuthResponse as b7, type PersonKey as b8, PlanStepsError as b9, type RespondParams as bA, type RespondPartstat as bB, type RoomCreateBody as bC, type RoomQuery as bD, type RoomRead as bE, type RunProgress as bF, type RunStats as bG, type RunStep as bH, type RunWaitingOn as bI, SHAREPOINT_VENDORS as bJ, type SSEEvent as bK, type SSEStreamCallbacks as bL, type SSEStreamResult as bM, STEP_FIELD_OPTION_TONES as bN, STOP_ID_WAIT_MS as bO, STOP_REPEAT_WINDOW_MS as bP, SUPPORTED_EXTENSIONS as bQ, type ScopedTarget as bR, type SearchChunk as bS, type SendBack as bT, type ShareRead as bU, type ShareRole as bV, type SkillSummary as bW, type SkippedFile as bX, type SlackConnectionStatus as bY, type StepActionRequest as bZ, type StepActivityEvent as b_, type PlanWorkRequest as ba, type ProductResponse as bb, type ProjectAddonKind as bc, type ProjectAddonSettingsRequest as bd, type ProjectBudget as be, type ProjectCheckoutRequest as bf, type ProjectConversationUsageResponse as bg, type ProjectCreateOptions as bh, type ProjectDetails as bi, type ProjectEventKind as bj, type ProjectEventResponse as bk, type ProjectInvoicesResponse as bl, type ProjectNextPeriodAddonsRequest as bm, type ProjectPlanChangeRequest as bn, type ProjectQuoteRequest as bo, type ProjectResponse as bp, type ProjectUpdateRequest as bq, type ProjectUsageResponse as br, PublicBookingError as bs, type PublicBookingPage as bt, type QuotaExceeded as bu, type RaisedSignal as bv, type ReconnectOptions as bw, type ReconnectableWsConnection as bx, type ResolvedCitation as by, type ResolvedRecipient as bz, type ActivityResponse as c, appendTranscriptionHints as c$, type StepDisplay as c0, type StepField as c1, type StepFieldOption as c2, type StepFieldOptionTone as c3, type StepKind as c4, type StepPhase as c5, type StepSignal as c6, type StepSignalWhen as c7, type StepState as c8, type StepStatus as c9, type UpdateConversationRequest as cA, type UpdateFactRequest as cB, type UpdateWorkflowRequest as cC, type UploadBatchResult as cD, type UploadDirectOptions as cE, type UploadDirectResult as cF, type UploadDocumentsOptions as cG, type UploadOptions as cH, type UploadProgressListener as cI, type UploadResult as cJ, type UsageBreakdown as cK, type UserConnectorEntry as cL, type UserDailyUsageResponse as cM, type UserInfo as cN, WebSocketAuthError as cO, type WeeklyHoursSpec as cP, type WorkStatus as cQ, type WorkflowAuthMode as cR, type WorkflowResponse as cS, type WorkflowRunHistoryResponse as cT, type WorkflowRunResponse as cU, type WorkspaceContext as cV, type WorkspaceOpenResponse as cW, type WsConnection as cX, account as cY, agentconfig as cZ, agents as c_, type SubagentBranchRecord as ca, type SubagentLaneInfo as cb, type SubmitBackgroundQueryOptions as cc, type SubscribeParams as cd, type SyncTriggerResult as ce, TAG_KINDS as cf, TAG_NESTING_MAX_DEPTH as cg, type TagChange as ch, type TagFieldDefinition as ci, type TagGroup as cj, type TagKind as ck, type TagKindField as cl, type TagKindSchema as cm, type TagLinks as cn, type TagListQuery as co, type TagNode as cp, type TagResponse as cq, type TagScope as cr, type TagTreeRow as cs, type TaskPlan as ct, type TaskPlanStep as cu, type TaxQuoteResponse as cv, type Thread as cw, type ThreadsResponse as cx, type TimeSuggestion as cy, type TurnRequest as cz, Arbi as d, getContextUsedTokens as d$, assistant as d0, authenticatedFetch as d1, bookPublicSlot as d2, buildCitationChunkData as d3, buildDocNameMap as d4, buildDocumentTools as d5, buildFactsContextTool as d6, buildRetrievalChunkTool as d7, buildRetrievalFullContextTool as d8, buildRetrievalTocTool as d9, extractSubagentLanes as dA, facts as dB, files as dC, filterDocumentTags as dD, filterSkills as dE, findLeafForTaskMessage as dF, findMainSiblingLeaf as dG, findReplyTarget as dH, findSubagentRunId as dI, flattenTagTree as dJ, formatAgentStepLabel as dK, formatFileSize as dL, formatGbp as dM, formatGbpPerMillionTokens as dN, formatItemLabel as dO, formatStreamSummary as dP, formatTokens as dQ, formatUserName as dR, formatWorkspaceChoices as dS, formatWsMessage as dT, generateEncryptedWorkspaceKey as dU, generateNewWorkspaceKey as dV, getAgentStepLabel as dW, getAttachableRunId as dX, getChildTags as dY, getContextRemainingPercent as dZ, getContextUsedPercent as d_, buildTurnRequest as da, calendar as db, calls as dc, canTagHaveParent as dd, cancelPublicBooking as de, chats as df, computeRunStats as dg, connectErrorMessage as dh, connectWebSocket as di, connectWithReconnect as dj, connectors as dk, consumeSSEStream as dl, contacts as dm, continuityPrompt as dn, conversations as dp, countCitations as dq, createAuthenticatedClient as dr, createDocumentWaiter as ds, createIndexAssigner as dt, defaultKindForFormat as du, doctags as dv, documents as dw, estimateDraftTokens as dx, extractDocumentIdsFromMessages as dy, extractFactIdsFromMessages as dz, ArbiApiError as e, subagentJobLabel as e$, getCurrentStep as e0, getEligibleParentTags as e1, getErrorCode as e2, getErrorMessage as e3, getPublicBookingPage as e4, getRawWorkspaceKey as e5, getRunToAttach as e6, getRunToCancel as e7, getStepDisplay as e8, getStepTool as e9, performSigningKeyLogin as eA, performSsoDeviceFlowLogin as eB, pickMainThread as eC, profile as eD, progressFetch as eE, projects as eF, quotaExceededFrom as eG, quotaFromStreamError as eH, reduceOutputItem as eI, refusalReason as eJ, requireData as eK, requireOk as eL, resolveAuth as eM, resolveCitations as eN, resolveSummary as eO, resolveWorkspace as eP, responses as eQ, searchChunks as eR, selectFullContextDocument as eS, selectWorkspace as eT, selectWorkspaceById as eU, sessions as eV, settings as eW, signatureRequests as eX, sliceToSubagentThread as eY, streamSSE as eZ, stripCitationMarkdown as e_, getSubagentBranchRecord as ea, getTagDescendantIds as eb, health as ec, houseTemplate as ed, hydrateAgentSteps as ee, identity as ef, identityErrorCode as eg, isAnnotationTag as eh, isConnectorVendorVisible as ei, isDriveSyncVendor as ej, isEntityTag as ek, isFlatKind as el, isLabelTag as em, isMailboxSyncVendor as en, isNearAiUsageBudget as eo, isPresenceTag as ep, isSharePointVendor as eq, isSharedSkill as er, isTraceItem as es, mail as et, mergeAgentSteps as eu, notifications as ev, parseSSEEvents as ew, parseSlashCommand as ex, parseSlashTokenInProgress as ey, performPasswordLogin as ez, ArbiError as f, summarizeCitations as f0, tagUseCount as f1, tags as f2, tagsForScope as f3, tagsOfGroup as f4, topLevelAgentSteps as f5, uploadSkill as f6, usdToGbp as f7, work as f8, workflowSteps as f9, workflows as fa, workspaces as fb, wouldCreateTagCycle as fc, type ArbiHostSession as g, type ArbiOptions as h, ArbiSessionExpiredError as i, type AskHandlers as j, type AskRequest as k, type AttendeeRead as l, type AuthContext as m, type AuthHeaders as n, type AuthMode as o, type AuthenticatedClient as p, type BookingPage as q, type BookingPageWriteBody as r, type BookingRequestBody as s, type BridgeTokensOptions as t, type CalDavProfile as u, type CalendarAccount as v, type CalendarAccountKind as w, type CalendarCreateBody as x, type CalendarEvent as y, type CalendarKeys as z };
16731
+ export { type ConfigStore as $, ACCOUNT_VENDOR as A, type BookingConfirmation as B, type CalDavConnectBody as C, type CalendarEvent as D, type CalendarKeys as E, type CalendarRead as F, type CalendarSettings as G, type CalendarSettingsBody as H, type CalendarUpdate as I, type CalendarWindow as J, CallApiError as K, type ChatAttachmentFile as L, type ChatAttachmentInput as M, type ChatCryptoContext as N, type ChatKeyRing as O, type ChatKind as P, type ChatMemberKey as Q, type ChatMemberResponse as R, type ChatMessage as S, type ChatMessageResponse as T, type ChatResponse as U, type ChatSession as V, type CitationSummary as W, type CitationToolSources as X, type CliConfig as Y, type CliCredentials as Z, type CommandDescriptor as _, type AccountSyncResult as a, MICROSOFT_VENDORS as a$, type ConnectOptions as a0, type ConnectorCatalogEntry as a1, type ConnectorFolder as a2, type ConnectorSyncProgress as a3, type ConnectorSyncStatus as a4, type ConnectorVendorKey as a5, type ConnectorVisibilitySettings as a6, type ContextUsage as a7, type ConversationResponse as a8, type ConversationUsageResponse as a9, type EventCreateBody as aA, type EventPatchBody as aB, FLAT_TAG_KINDS as aC, type FactResponse as aD, type FactSearchRequest as aE, type FactSearchResponse as aF, type FindTimeParams as aG, type FormattedWsMessage as aH, type FreeBusyEntry as aI, type FullContextSelection as aJ, GOOGLE_VENDORS as aK, type HolidayCountry as aL, type HouseTemplateCandidate as aM, IMANAGE_VENDORS as aN, type IdentityErrorCode as aO, type IdentityPurchase as aP, type IdentityState as aQ, type IdentityStatus as aR, type ImportResult as aS, type InvitationRead as aT, type LinkedRun as aU, type ListAllOptions as aV, type ListEventsParams as aW, type ListFactsOptions as aX, type ListPaginatedOptions as aY, MAILBOX_SYNC_VENDORS as aZ, MAX_RETRIEVE_DOC_IDS as a_, type CreateFactRequest as aa, type CreateFactsRequest as ab, type CreateWorkRequest as ac, type CreateWorkflowRequest as ad, DEFAULT_AI_USD_PER_GBP as ae, DOC_TERMINAL_STATUSES as af, DRIVE_SYNC_VENDORS as ag, type DateTimeSpec as ah, type DecryptedChat as ai, type DecryptedChatMessage as aj, type DeploymentHouseTemplate as ak, type DocInfo as al, type DocInfoMap as am, type DocNameMap as an, type DocumentAutomationAction as ao, type DocumentListFields as ap, type DocumentListOrder as aq, type DocumentSelector as ar, type DocumentWaiter as as, type DocumentWaiterOptions as at, type DriveSyncProgress as au, type DriveSyncSummary as av, DuplicateContactError as aw, ENTITY_KINDS as ax, type EditScope as ay, type EntityKind as az, type ActivityKind as b, type StepActionRequest as b$, type MailAttachment as b0, type MessageLevel as b1, type OAuthAccountKind as b2, type OutputItemDone as b3, type OverlayItem as b4, type OverlayLayerName as b5, PRESENCE_KINDS as b6, PROMPT_CONTEXT_CHARS as b7, type ParsedSlashCommand as b8, type PendingAuthResponse as b9, type ResolvedCitation as bA, type ResolvedRecipient as bB, type RespondParams as bC, type RespondPartstat as bD, type RoomCreateBody as bE, type RoomQuery as bF, type RoomRead as bG, type RunProgress as bH, type RunStats as bI, type RunStep as bJ, type RunWaitingOn as bK, SHAREPOINT_VENDORS as bL, type SSEEvent as bM, type SSEStreamCallbacks as bN, type SSEStreamResult as bO, STEP_FIELD_OPTION_TONES as bP, STOP_ID_WAIT_MS as bQ, STOP_REPEAT_WINDOW_MS as bR, SUPPORTED_EXTENSIONS as bS, type ScopedTarget as bT, type SearchChunk as bU, type SendBack as bV, type ShareRead as bW, type ShareRole as bX, type SkillSummary as bY, type SkippedFile as bZ, type SlackConnectionStatus as b_, type PersonKey as ba, PlanStepsError as bb, type PlanWorkRequest as bc, type ProductResponse as bd, type ProjectAddonKind as be, type ProjectAddonSettingsRequest as bf, type ProjectBudget as bg, type ProjectCheckoutRequest as bh, type ProjectConversationUsageResponse as bi, type ProjectCreateOptions as bj, type ProjectDetails as bk, type ProjectEventKind as bl, type ProjectEventResponse as bm, type ProjectInvoicesResponse as bn, type ProjectNextPeriodAddonsRequest as bo, type ProjectPlanChangeRequest as bp, type ProjectQuoteRequest as bq, type ProjectResponse as br, type ProjectUpdateRequest as bs, type ProjectUsageResponse as bt, PublicBookingError as bu, type PublicBookingPage as bv, type QuotaExceeded as bw, type RaisedSignal as bx, type ReconnectOptions as by, type ReconnectableWsConnection as bz, type ActivityResponse as c, agentconfig as c$, type StepActivityEvent as c0, type StepAssignee as c1, type StepDisplay as c2, type StepField as c3, type StepFieldOption as c4, type StepFieldOptionTone as c5, type StepKind as c6, type StepPhase as c7, type StepSignal as c8, type StepSignalWhen as c9, type TimeSuggestion as cA, type TurnRequest as cB, type UpdateConversationRequest as cC, type UpdateFactRequest as cD, type UpdateWorkflowRequest as cE, type UploadBatchResult as cF, type UploadDirectOptions as cG, type UploadDirectResult as cH, type UploadDocumentsOptions as cI, type UploadOptions as cJ, type UploadProgressListener as cK, type UploadResult as cL, type UsageBreakdown as cM, type UserConnectorEntry as cN, type UserDailyUsageResponse as cO, type UserInfo as cP, WebSocketAuthError as cQ, type WeeklyHoursSpec as cR, type WorkStatus as cS, type WorkflowAuthMode as cT, type WorkflowResponse as cU, type WorkflowRunHistoryResponse as cV, type WorkflowRunResponse as cW, type WorkspaceContext as cX, type WorkspaceOpenResponse as cY, type WsConnection as cZ, account as c_, type StepState as ca, type StepStatus as cb, type SubagentBranchRecord as cc, type SubagentLaneInfo as cd, type SubmitBackgroundQueryOptions as ce, type SubscribeParams as cf, type SyncTriggerResult as cg, TAG_KINDS as ch, TAG_NESTING_MAX_DEPTH as ci, type TagChange as cj, type TagFieldDefinition as ck, type TagGroup as cl, type TagKind as cm, type TagKindField as cn, type TagKindSchema as co, type TagLinks as cp, type TagListQuery as cq, type TagNode as cr, type TagResponse as cs, type TagScope as ct, type TagTreeRow as cu, type TaskPlan as cv, type TaskPlanStep as cw, type TaxQuoteResponse as cx, type Thread as cy, type ThreadsResponse as cz, Arbi as d, getContextRemainingPercent as d$, agents as d0, appendTranscriptionHints as d1, assistant as d2, authenticatedFetch as d3, bookPublicSlot as d4, buildCitationChunkData as d5, buildDocNameMap as d6, buildDocumentTools as d7, buildFactsContextTool as d8, buildRetrievalChunkTool as d9, extractDocumentIdsFromMessages as dA, extractFactIdsFromMessages as dB, extractSubagentLanes as dC, facts as dD, files as dE, filterDocumentTags as dF, filterSkills as dG, findLeafForTaskMessage as dH, findMainSiblingLeaf as dI, findReplyTarget as dJ, findSubagentRunId as dK, flattenTagTree as dL, formatAgentStepLabel as dM, formatFileSize as dN, formatGbp as dO, formatGbpPerMillionTokens as dP, formatItemLabel as dQ, formatStreamSummary as dR, formatTokens as dS, formatUserName as dT, formatWorkspaceChoices as dU, formatWsMessage as dV, generateEncryptedWorkspaceKey as dW, generateNewWorkspaceKey as dX, getAgentStepLabel as dY, getAttachableRunId as dZ, getChildTags as d_, buildRetrievalFullContextTool as da, buildRetrievalTocTool as db, buildTurnRequest as dc, calendar as dd, calls as de, canTagHaveParent as df, cancelPublicBooking as dg, chats as dh, computeRunStats as di, connectErrorMessage as dj, connectWebSocket as dk, connectWithReconnect as dl, connectors as dm, consumeSSEStream as dn, contacts as dp, continuityPrompt as dq, conversations as dr, countCitations as ds, createAuthenticatedClient as dt, createDocumentWaiter as du, createIndexAssigner as dv, defaultKindForFormat as dw, doctags as dx, documents as dy, estimateDraftTokens as dz, ArbiApiError as e, streamSSE as e$, getContextUsedPercent as e0, getContextUsedTokens as e1, getCurrentStep as e2, getEligibleParentTags as e3, getErrorCode as e4, getErrorMessage as e5, getPublicBookingPage as e6, getRawWorkspaceKey as e7, getRunToAttach as e8, getRunToCancel as e9, parseSlashTokenInProgress as eA, performPasswordLogin as eB, performSigningKeyLogin as eC, performSsoDeviceFlowLogin as eD, pickMainThread as eE, profile as eF, progressFetch as eG, projects as eH, quotaExceededFrom as eI, quotaFromStreamError as eJ, reduceOutputItem as eK, refusalReason as eL, requireData as eM, requireOk as eN, resolveAuth as eO, resolveCitations as eP, resolveSummary as eQ, resolveWorkspace as eR, responses as eS, searchChunks as eT, selectFullContextDocument as eU, selectWorkspace as eV, selectWorkspaceById as eW, sessions as eX, settings as eY, signatureRequests as eZ, sliceToSubagentThread as e_, getStepDisplay as ea, getStepTool as eb, getSubagentBranchRecord as ec, getTagDescendantIds as ed, health as ee, houseTemplate as ef, hydrateAgentSteps as eg, identity as eh, identityErrorCode as ei, isAnnotationTag as ej, isConnectorVendorVisible as ek, isDriveSyncVendor as el, isEntityTag as em, isFlatKind as en, isLabelTag as eo, isMailboxSyncVendor as ep, isNearAiUsageBudget as eq, isPresenceTag as er, isSharePointVendor as es, isSharedSkill as et, isTraceItem as eu, mail as ev, mergeAgentSteps as ew, notifications as ex, parseSSEEvents as ey, parseSlashCommand as ez, ArbiError as f, stripCitationMarkdown as f0, subagentJobLabel as f1, summarizeCitations as f2, tagUseCount as f3, tags as f4, tagsForScope as f5, tagsOfGroup as f6, topLevelAgentSteps as f7, uploadSkill as f8, usdToGbp as f9, work as fa, workflowSteps as fb, workflows as fc, workspaces as fd, wouldCreateTagCycle as fe, type ArbiHostSession as g, type ArbiOptions as h, ArbiSessionExpiredError as i, ArbiWorkspaceChangedError as j, ArbiWorkspaceSupersededError as k, type AskHandlers as l, type AskRequest as m, type AttendeeRead as n, type AuthContext as o, type AuthHeaders as p, type AuthMode as q, type AuthenticatedClient as r, type BookingPage as s, type BookingPageWriteBody as t, type BookingRequestBody as u, type BridgeTokensOptions as v, type CalDavProfile as w, type CalendarAccount as x, type CalendarAccountKind as y, type CalendarCreateBody as z };
@@ -15,6 +15,24 @@ declare class ArbiError extends Error {
15
15
  declare class ArbiSessionExpiredError extends ArbiError {
16
16
  constructor(message?: string);
17
17
  }
18
+ /**
19
+ * A newer `selectWorkspace` for another workspace was asked for before this one's turn: it never
20
+ * opened, and the newer one decides where the session ends.
21
+ */
22
+ declare class ArbiWorkspaceSupersededError extends ArbiError {
23
+ readonly workspaceId: string;
24
+ readonly supersededBy: string;
25
+ constructor(workspaceId: string, supersededBy: string);
26
+ }
27
+ /**
28
+ * A read made for one workspace could have been answered for another: the session's workspace was
29
+ * not, or did not stay, the one it was made for (a switch ran meanwhile). Nothing it returned is
30
+ * kept; read again in the workspace now open.
31
+ */
32
+ declare class ArbiWorkspaceChangedError extends ArbiError {
33
+ readonly workspaceId: string;
34
+ constructor(workspaceId: string);
35
+ }
18
36
  declare class ArbiApiError extends ArbiError {
19
37
  readonly status?: number;
20
38
  readonly apiError?: unknown;
@@ -818,6 +836,11 @@ type DocumentListFields = 'full' | 'lite';
818
836
  * Options for paginated document listing.
819
837
  */
820
838
  interface ListPaginatedOptions {
839
+ /**
840
+ * The workspace to list (its key must be on the session): sent with every page, and every
841
+ * document returned is checked to belong to it. Default: the session's open workspace.
842
+ */
843
+ workspaceExtId?: string;
821
844
  /**
822
845
  * Number of documents per page (applies to every page after the first).
823
846
  * @default 5000
@@ -7754,6 +7777,8 @@ declare class Arbi {
7754
7777
  private userProfile;
7755
7778
  private readonly profileListeners;
7756
7779
  private currentWorkspaceId;
7780
+ /** The latest `selectWorkspace` asked for: only it may open when its turn comes. */
7781
+ private openIntent;
7757
7782
  private chatCryptoContext;
7758
7783
  /** The chat keys I hold, opened once per set of epochs (`chatRingSignature`). */
7759
7784
  private chatRings;
@@ -7877,6 +7902,18 @@ declare class Arbi {
7877
7902
  * documents, which are listed page by page). A public workspace has no key and opens without one.
7878
7903
  */
7879
7904
  selectWorkspace(workspaceId: string): Promise<WorkspaceOpenResponse>;
7905
+ /** `POST /open` with the workspace's key sealed to this session (none for a public workspace). */
7906
+ private openOnServer;
7907
+ /** Resolves once no workspace open is running or waiting (a switch has landed on the server). */
7908
+ workspaceSettled(): Promise<void>;
7909
+ /**
7910
+ * Run `read` — a request answered from the session's open workspace — for `workspaceId`, and
7911
+ * keep its answer only if it can only be that workspace's: once no open is pending, the open
7912
+ * workspace must be `workspaceId` when it is sent and still be when it returns, with no open
7913
+ * started in between. Otherwise it throws `ArbiWorkspaceChangedError` and nothing it returned
7914
+ * is kept, so a list read across a switch can never be cached as another workspace's.
7915
+ */
7916
+ readInWorkspace<T>(workspaceId: string, read: () => Promise<T>): Promise<T>;
7880
7917
  /**
7881
7918
  * Subscribe to "the session cannot be recovered". Fires when a request failed with 401 or
7882
7919
  * "No active workspace" and neither a workspace re-open nor a silent re-login was possible
@@ -10051,7 +10088,9 @@ declare class Arbi {
10051
10088
  * }
10052
10089
  * ```
10053
10090
  */
10054
- listPaginated: (options?: ListPaginatedOptions) => AsyncGenerator<{
10091
+ listPaginated: (options?: ListPaginatedOptions & {
10092
+ workspaceId?: string;
10093
+ }) => AsyncGenerator<{
10055
10094
  external_id: string;
10056
10095
  workspace_ext_id: string;
10057
10096
  file_name?: string | null;
@@ -16689,4 +16728,4 @@ declare function getAttachableRunId(messages: readonly RunMessage[]): string | n
16689
16728
  */
16690
16729
  declare function getRunToAttach(localGeneration: LocalGeneration | undefined, messages: readonly RunMessage[]): string | null;
16691
16730
 
16692
- export { type ConnectorCatalogEntry as $, ACCOUNT_VENDOR as A, type BookingConfirmation as B, type CalDavConnectBody as C, type CalendarRead as D, type CalendarSettings as E, type CalendarSettingsBody as F, type CalendarUpdate as G, type CalendarWindow as H, CallApiError as I, type ChatAttachmentFile as J, type ChatAttachmentInput as K, type ChatCryptoContext as L, type ChatKeyRing as M, type ChatKind as N, type ChatMemberKey as O, type ChatMemberResponse as P, type ChatMessage as Q, type ChatMessageResponse as R, type ChatResponse as S, type ChatSession as T, type CitationSummary as U, type CitationToolSources as V, type CliConfig as W, type CliCredentials as X, type CommandDescriptor as Y, type ConfigStore as Z, type ConnectOptions as _, type AccountSyncResult as a, type MessageLevel as a$, type ConnectorFolder as a0, type ConnectorSyncProgress as a1, type ConnectorSyncStatus as a2, type ConnectorVendorKey as a3, type ConnectorVisibilitySettings as a4, type ContextUsage as a5, type ConversationResponse as a6, type ConversationUsageResponse as a7, type CreateFactRequest as a8, type CreateFactsRequest as a9, FLAT_TAG_KINDS as aA, type FactResponse as aB, type FactSearchRequest as aC, type FactSearchResponse as aD, type FindTimeParams as aE, type FormattedWsMessage as aF, type FreeBusyEntry as aG, type FullContextSelection as aH, GOOGLE_VENDORS as aI, type HolidayCountry as aJ, type HouseTemplateCandidate as aK, IMANAGE_VENDORS as aL, type IdentityErrorCode as aM, type IdentityPurchase as aN, type IdentityState as aO, type IdentityStatus as aP, type ImportResult as aQ, type InvitationRead as aR, type LinkedRun as aS, type ListAllOptions as aT, type ListEventsParams as aU, type ListFactsOptions as aV, type ListPaginatedOptions as aW, MAILBOX_SYNC_VENDORS as aX, MAX_RETRIEVE_DOC_IDS as aY, MICROSOFT_VENDORS as aZ, type MailAttachment as a_, type CreateWorkRequest as aa, type CreateWorkflowRequest as ab, DEFAULT_AI_USD_PER_GBP as ac, DOC_TERMINAL_STATUSES as ad, DRIVE_SYNC_VENDORS as ae, type DateTimeSpec as af, type DecryptedChat as ag, type DecryptedChatMessage as ah, type DeploymentHouseTemplate as ai, type DocInfo as aj, type DocInfoMap as ak, type DocNameMap as al, type DocumentAutomationAction as am, type DocumentListFields as an, type DocumentListOrder as ao, type DocumentSelector as ap, type DocumentWaiter as aq, type DocumentWaiterOptions as ar, type DriveSyncProgress as as, type DriveSyncSummary as at, DuplicateContactError as au, ENTITY_KINDS as av, type EditScope as aw, type EntityKind as ax, type EventCreateBody as ay, type EventPatchBody as az, type ActivityKind as b, type StepAssignee as b$, type OAuthAccountKind as b0, type OutputItemDone as b1, type OverlayItem as b2, type OverlayLayerName as b3, PRESENCE_KINDS as b4, PROMPT_CONTEXT_CHARS as b5, type ParsedSlashCommand as b6, type PendingAuthResponse as b7, type PersonKey as b8, PlanStepsError as b9, type RespondParams as bA, type RespondPartstat as bB, type RoomCreateBody as bC, type RoomQuery as bD, type RoomRead as bE, type RunProgress as bF, type RunStats as bG, type RunStep as bH, type RunWaitingOn as bI, SHAREPOINT_VENDORS as bJ, type SSEEvent as bK, type SSEStreamCallbacks as bL, type SSEStreamResult as bM, STEP_FIELD_OPTION_TONES as bN, STOP_ID_WAIT_MS as bO, STOP_REPEAT_WINDOW_MS as bP, SUPPORTED_EXTENSIONS as bQ, type ScopedTarget as bR, type SearchChunk as bS, type SendBack as bT, type ShareRead as bU, type ShareRole as bV, type SkillSummary as bW, type SkippedFile as bX, type SlackConnectionStatus as bY, type StepActionRequest as bZ, type StepActivityEvent as b_, type PlanWorkRequest as ba, type ProductResponse as bb, type ProjectAddonKind as bc, type ProjectAddonSettingsRequest as bd, type ProjectBudget as be, type ProjectCheckoutRequest as bf, type ProjectConversationUsageResponse as bg, type ProjectCreateOptions as bh, type ProjectDetails as bi, type ProjectEventKind as bj, type ProjectEventResponse as bk, type ProjectInvoicesResponse as bl, type ProjectNextPeriodAddonsRequest as bm, type ProjectPlanChangeRequest as bn, type ProjectQuoteRequest as bo, type ProjectResponse as bp, type ProjectUpdateRequest as bq, type ProjectUsageResponse as br, PublicBookingError as bs, type PublicBookingPage as bt, type QuotaExceeded as bu, type RaisedSignal as bv, type ReconnectOptions as bw, type ReconnectableWsConnection as bx, type ResolvedCitation as by, type ResolvedRecipient as bz, type ActivityResponse as c, appendTranscriptionHints as c$, type StepDisplay as c0, type StepField as c1, type StepFieldOption as c2, type StepFieldOptionTone as c3, type StepKind as c4, type StepPhase as c5, type StepSignal as c6, type StepSignalWhen as c7, type StepState as c8, type StepStatus as c9, type UpdateConversationRequest as cA, type UpdateFactRequest as cB, type UpdateWorkflowRequest as cC, type UploadBatchResult as cD, type UploadDirectOptions as cE, type UploadDirectResult as cF, type UploadDocumentsOptions as cG, type UploadOptions as cH, type UploadProgressListener as cI, type UploadResult as cJ, type UsageBreakdown as cK, type UserConnectorEntry as cL, type UserDailyUsageResponse as cM, type UserInfo as cN, WebSocketAuthError as cO, type WeeklyHoursSpec as cP, type WorkStatus as cQ, type WorkflowAuthMode as cR, type WorkflowResponse as cS, type WorkflowRunHistoryResponse as cT, type WorkflowRunResponse as cU, type WorkspaceContext as cV, type WorkspaceOpenResponse as cW, type WsConnection as cX, account as cY, agentconfig as cZ, agents as c_, type SubagentBranchRecord as ca, type SubagentLaneInfo as cb, type SubmitBackgroundQueryOptions as cc, type SubscribeParams as cd, type SyncTriggerResult as ce, TAG_KINDS as cf, TAG_NESTING_MAX_DEPTH as cg, type TagChange as ch, type TagFieldDefinition as ci, type TagGroup as cj, type TagKind as ck, type TagKindField as cl, type TagKindSchema as cm, type TagLinks as cn, type TagListQuery as co, type TagNode as cp, type TagResponse as cq, type TagScope as cr, type TagTreeRow as cs, type TaskPlan as ct, type TaskPlanStep as cu, type TaxQuoteResponse as cv, type Thread as cw, type ThreadsResponse as cx, type TimeSuggestion as cy, type TurnRequest as cz, Arbi as d, getContextUsedTokens as d$, assistant as d0, authenticatedFetch as d1, bookPublicSlot as d2, buildCitationChunkData as d3, buildDocNameMap as d4, buildDocumentTools as d5, buildFactsContextTool as d6, buildRetrievalChunkTool as d7, buildRetrievalFullContextTool as d8, buildRetrievalTocTool as d9, extractSubagentLanes as dA, facts as dB, files as dC, filterDocumentTags as dD, filterSkills as dE, findLeafForTaskMessage as dF, findMainSiblingLeaf as dG, findReplyTarget as dH, findSubagentRunId as dI, flattenTagTree as dJ, formatAgentStepLabel as dK, formatFileSize as dL, formatGbp as dM, formatGbpPerMillionTokens as dN, formatItemLabel as dO, formatStreamSummary as dP, formatTokens as dQ, formatUserName as dR, formatWorkspaceChoices as dS, formatWsMessage as dT, generateEncryptedWorkspaceKey as dU, generateNewWorkspaceKey as dV, getAgentStepLabel as dW, getAttachableRunId as dX, getChildTags as dY, getContextRemainingPercent as dZ, getContextUsedPercent as d_, buildTurnRequest as da, calendar as db, calls as dc, canTagHaveParent as dd, cancelPublicBooking as de, chats as df, computeRunStats as dg, connectErrorMessage as dh, connectWebSocket as di, connectWithReconnect as dj, connectors as dk, consumeSSEStream as dl, contacts as dm, continuityPrompt as dn, conversations as dp, countCitations as dq, createAuthenticatedClient as dr, createDocumentWaiter as ds, createIndexAssigner as dt, defaultKindForFormat as du, doctags as dv, documents as dw, estimateDraftTokens as dx, extractDocumentIdsFromMessages as dy, extractFactIdsFromMessages as dz, ArbiApiError as e, subagentJobLabel as e$, getCurrentStep as e0, getEligibleParentTags as e1, getErrorCode as e2, getErrorMessage as e3, getPublicBookingPage as e4, getRawWorkspaceKey as e5, getRunToAttach as e6, getRunToCancel as e7, getStepDisplay as e8, getStepTool as e9, performSigningKeyLogin as eA, performSsoDeviceFlowLogin as eB, pickMainThread as eC, profile as eD, progressFetch as eE, projects as eF, quotaExceededFrom as eG, quotaFromStreamError as eH, reduceOutputItem as eI, refusalReason as eJ, requireData as eK, requireOk as eL, resolveAuth as eM, resolveCitations as eN, resolveSummary as eO, resolveWorkspace as eP, responses as eQ, searchChunks as eR, selectFullContextDocument as eS, selectWorkspace as eT, selectWorkspaceById as eU, sessions as eV, settings as eW, signatureRequests as eX, sliceToSubagentThread as eY, streamSSE as eZ, stripCitationMarkdown as e_, getSubagentBranchRecord as ea, getTagDescendantIds as eb, health as ec, houseTemplate as ed, hydrateAgentSteps as ee, identity as ef, identityErrorCode as eg, isAnnotationTag as eh, isConnectorVendorVisible as ei, isDriveSyncVendor as ej, isEntityTag as ek, isFlatKind as el, isLabelTag as em, isMailboxSyncVendor as en, isNearAiUsageBudget as eo, isPresenceTag as ep, isSharePointVendor as eq, isSharedSkill as er, isTraceItem as es, mail as et, mergeAgentSteps as eu, notifications as ev, parseSSEEvents as ew, parseSlashCommand as ex, parseSlashTokenInProgress as ey, performPasswordLogin as ez, ArbiError as f, summarizeCitations as f0, tagUseCount as f1, tags as f2, tagsForScope as f3, tagsOfGroup as f4, topLevelAgentSteps as f5, uploadSkill as f6, usdToGbp as f7, work as f8, workflowSteps as f9, workflows as fa, workspaces as fb, wouldCreateTagCycle as fc, type ArbiHostSession as g, type ArbiOptions as h, ArbiSessionExpiredError as i, type AskHandlers as j, type AskRequest as k, type AttendeeRead as l, type AuthContext as m, type AuthHeaders as n, type AuthMode as o, type AuthenticatedClient as p, type BookingPage as q, type BookingPageWriteBody as r, type BookingRequestBody as s, type BridgeTokensOptions as t, type CalDavProfile as u, type CalendarAccount as v, type CalendarAccountKind as w, type CalendarCreateBody as x, type CalendarEvent as y, type CalendarKeys as z };
16731
+ export { type ConfigStore as $, ACCOUNT_VENDOR as A, type BookingConfirmation as B, type CalDavConnectBody as C, type CalendarEvent as D, type CalendarKeys as E, type CalendarRead as F, type CalendarSettings as G, type CalendarSettingsBody as H, type CalendarUpdate as I, type CalendarWindow as J, CallApiError as K, type ChatAttachmentFile as L, type ChatAttachmentInput as M, type ChatCryptoContext as N, type ChatKeyRing as O, type ChatKind as P, type ChatMemberKey as Q, type ChatMemberResponse as R, type ChatMessage as S, type ChatMessageResponse as T, type ChatResponse as U, type ChatSession as V, type CitationSummary as W, type CitationToolSources as X, type CliConfig as Y, type CliCredentials as Z, type CommandDescriptor as _, type AccountSyncResult as a, MICROSOFT_VENDORS as a$, type ConnectOptions as a0, type ConnectorCatalogEntry as a1, type ConnectorFolder as a2, type ConnectorSyncProgress as a3, type ConnectorSyncStatus as a4, type ConnectorVendorKey as a5, type ConnectorVisibilitySettings as a6, type ContextUsage as a7, type ConversationResponse as a8, type ConversationUsageResponse as a9, type EventCreateBody as aA, type EventPatchBody as aB, FLAT_TAG_KINDS as aC, type FactResponse as aD, type FactSearchRequest as aE, type FactSearchResponse as aF, type FindTimeParams as aG, type FormattedWsMessage as aH, type FreeBusyEntry as aI, type FullContextSelection as aJ, GOOGLE_VENDORS as aK, type HolidayCountry as aL, type HouseTemplateCandidate as aM, IMANAGE_VENDORS as aN, type IdentityErrorCode as aO, type IdentityPurchase as aP, type IdentityState as aQ, type IdentityStatus as aR, type ImportResult as aS, type InvitationRead as aT, type LinkedRun as aU, type ListAllOptions as aV, type ListEventsParams as aW, type ListFactsOptions as aX, type ListPaginatedOptions as aY, MAILBOX_SYNC_VENDORS as aZ, MAX_RETRIEVE_DOC_IDS as a_, type CreateFactRequest as aa, type CreateFactsRequest as ab, type CreateWorkRequest as ac, type CreateWorkflowRequest as ad, DEFAULT_AI_USD_PER_GBP as ae, DOC_TERMINAL_STATUSES as af, DRIVE_SYNC_VENDORS as ag, type DateTimeSpec as ah, type DecryptedChat as ai, type DecryptedChatMessage as aj, type DeploymentHouseTemplate as ak, type DocInfo as al, type DocInfoMap as am, type DocNameMap as an, type DocumentAutomationAction as ao, type DocumentListFields as ap, type DocumentListOrder as aq, type DocumentSelector as ar, type DocumentWaiter as as, type DocumentWaiterOptions as at, type DriveSyncProgress as au, type DriveSyncSummary as av, DuplicateContactError as aw, ENTITY_KINDS as ax, type EditScope as ay, type EntityKind as az, type ActivityKind as b, type StepActionRequest as b$, type MailAttachment as b0, type MessageLevel as b1, type OAuthAccountKind as b2, type OutputItemDone as b3, type OverlayItem as b4, type OverlayLayerName as b5, PRESENCE_KINDS as b6, PROMPT_CONTEXT_CHARS as b7, type ParsedSlashCommand as b8, type PendingAuthResponse as b9, type ResolvedCitation as bA, type ResolvedRecipient as bB, type RespondParams as bC, type RespondPartstat as bD, type RoomCreateBody as bE, type RoomQuery as bF, type RoomRead as bG, type RunProgress as bH, type RunStats as bI, type RunStep as bJ, type RunWaitingOn as bK, SHAREPOINT_VENDORS as bL, type SSEEvent as bM, type SSEStreamCallbacks as bN, type SSEStreamResult as bO, STEP_FIELD_OPTION_TONES as bP, STOP_ID_WAIT_MS as bQ, STOP_REPEAT_WINDOW_MS as bR, SUPPORTED_EXTENSIONS as bS, type ScopedTarget as bT, type SearchChunk as bU, type SendBack as bV, type ShareRead as bW, type ShareRole as bX, type SkillSummary as bY, type SkippedFile as bZ, type SlackConnectionStatus as b_, type PersonKey as ba, PlanStepsError as bb, type PlanWorkRequest as bc, type ProductResponse as bd, type ProjectAddonKind as be, type ProjectAddonSettingsRequest as bf, type ProjectBudget as bg, type ProjectCheckoutRequest as bh, type ProjectConversationUsageResponse as bi, type ProjectCreateOptions as bj, type ProjectDetails as bk, type ProjectEventKind as bl, type ProjectEventResponse as bm, type ProjectInvoicesResponse as bn, type ProjectNextPeriodAddonsRequest as bo, type ProjectPlanChangeRequest as bp, type ProjectQuoteRequest as bq, type ProjectResponse as br, type ProjectUpdateRequest as bs, type ProjectUsageResponse as bt, PublicBookingError as bu, type PublicBookingPage as bv, type QuotaExceeded as bw, type RaisedSignal as bx, type ReconnectOptions as by, type ReconnectableWsConnection as bz, type ActivityResponse as c, agentconfig as c$, type StepActivityEvent as c0, type StepAssignee as c1, type StepDisplay as c2, type StepField as c3, type StepFieldOption as c4, type StepFieldOptionTone as c5, type StepKind as c6, type StepPhase as c7, type StepSignal as c8, type StepSignalWhen as c9, type TimeSuggestion as cA, type TurnRequest as cB, type UpdateConversationRequest as cC, type UpdateFactRequest as cD, type UpdateWorkflowRequest as cE, type UploadBatchResult as cF, type UploadDirectOptions as cG, type UploadDirectResult as cH, type UploadDocumentsOptions as cI, type UploadOptions as cJ, type UploadProgressListener as cK, type UploadResult as cL, type UsageBreakdown as cM, type UserConnectorEntry as cN, type UserDailyUsageResponse as cO, type UserInfo as cP, WebSocketAuthError as cQ, type WeeklyHoursSpec as cR, type WorkStatus as cS, type WorkflowAuthMode as cT, type WorkflowResponse as cU, type WorkflowRunHistoryResponse as cV, type WorkflowRunResponse as cW, type WorkspaceContext as cX, type WorkspaceOpenResponse as cY, type WsConnection as cZ, account as c_, type StepState as ca, type StepStatus as cb, type SubagentBranchRecord as cc, type SubagentLaneInfo as cd, type SubmitBackgroundQueryOptions as ce, type SubscribeParams as cf, type SyncTriggerResult as cg, TAG_KINDS as ch, TAG_NESTING_MAX_DEPTH as ci, type TagChange as cj, type TagFieldDefinition as ck, type TagGroup as cl, type TagKind as cm, type TagKindField as cn, type TagKindSchema as co, type TagLinks as cp, type TagListQuery as cq, type TagNode as cr, type TagResponse as cs, type TagScope as ct, type TagTreeRow as cu, type TaskPlan as cv, type TaskPlanStep as cw, type TaxQuoteResponse as cx, type Thread as cy, type ThreadsResponse as cz, Arbi as d, getContextRemainingPercent as d$, agents as d0, appendTranscriptionHints as d1, assistant as d2, authenticatedFetch as d3, bookPublicSlot as d4, buildCitationChunkData as d5, buildDocNameMap as d6, buildDocumentTools as d7, buildFactsContextTool as d8, buildRetrievalChunkTool as d9, extractDocumentIdsFromMessages as dA, extractFactIdsFromMessages as dB, extractSubagentLanes as dC, facts as dD, files as dE, filterDocumentTags as dF, filterSkills as dG, findLeafForTaskMessage as dH, findMainSiblingLeaf as dI, findReplyTarget as dJ, findSubagentRunId as dK, flattenTagTree as dL, formatAgentStepLabel as dM, formatFileSize as dN, formatGbp as dO, formatGbpPerMillionTokens as dP, formatItemLabel as dQ, formatStreamSummary as dR, formatTokens as dS, formatUserName as dT, formatWorkspaceChoices as dU, formatWsMessage as dV, generateEncryptedWorkspaceKey as dW, generateNewWorkspaceKey as dX, getAgentStepLabel as dY, getAttachableRunId as dZ, getChildTags as d_, buildRetrievalFullContextTool as da, buildRetrievalTocTool as db, buildTurnRequest as dc, calendar as dd, calls as de, canTagHaveParent as df, cancelPublicBooking as dg, chats as dh, computeRunStats as di, connectErrorMessage as dj, connectWebSocket as dk, connectWithReconnect as dl, connectors as dm, consumeSSEStream as dn, contacts as dp, continuityPrompt as dq, conversations as dr, countCitations as ds, createAuthenticatedClient as dt, createDocumentWaiter as du, createIndexAssigner as dv, defaultKindForFormat as dw, doctags as dx, documents as dy, estimateDraftTokens as dz, ArbiApiError as e, streamSSE as e$, getContextUsedPercent as e0, getContextUsedTokens as e1, getCurrentStep as e2, getEligibleParentTags as e3, getErrorCode as e4, getErrorMessage as e5, getPublicBookingPage as e6, getRawWorkspaceKey as e7, getRunToAttach as e8, getRunToCancel as e9, parseSlashTokenInProgress as eA, performPasswordLogin as eB, performSigningKeyLogin as eC, performSsoDeviceFlowLogin as eD, pickMainThread as eE, profile as eF, progressFetch as eG, projects as eH, quotaExceededFrom as eI, quotaFromStreamError as eJ, reduceOutputItem as eK, refusalReason as eL, requireData as eM, requireOk as eN, resolveAuth as eO, resolveCitations as eP, resolveSummary as eQ, resolveWorkspace as eR, responses as eS, searchChunks as eT, selectFullContextDocument as eU, selectWorkspace as eV, selectWorkspaceById as eW, sessions as eX, settings as eY, signatureRequests as eZ, sliceToSubagentThread as e_, getStepDisplay as ea, getStepTool as eb, getSubagentBranchRecord as ec, getTagDescendantIds as ed, health as ee, houseTemplate as ef, hydrateAgentSteps as eg, identity as eh, identityErrorCode as ei, isAnnotationTag as ej, isConnectorVendorVisible as ek, isDriveSyncVendor as el, isEntityTag as em, isFlatKind as en, isLabelTag as eo, isMailboxSyncVendor as ep, isNearAiUsageBudget as eq, isPresenceTag as er, isSharePointVendor as es, isSharedSkill as et, isTraceItem as eu, mail as ev, mergeAgentSteps as ew, notifications as ex, parseSSEEvents as ey, parseSlashCommand as ez, ArbiError as f, stripCitationMarkdown as f0, subagentJobLabel as f1, summarizeCitations as f2, tagUseCount as f3, tags as f4, tagsForScope as f5, tagsOfGroup as f6, topLevelAgentSteps as f7, uploadSkill as f8, usdToGbp as f9, work as fa, workflowSteps as fb, workflows as fc, workspaces as fd, wouldCreateTagCycle as fe, type ArbiHostSession as g, type ArbiOptions as h, ArbiSessionExpiredError as i, ArbiWorkspaceChangedError as j, ArbiWorkspaceSupersededError as k, type AskHandlers as l, type AskRequest as m, type AttendeeRead as n, type AuthContext as o, type AuthHeaders as p, type AuthMode as q, type AuthenticatedClient as r, type BookingPage as s, type BookingPageWriteBody as t, type BookingRequestBody as u, type BridgeTokensOptions as v, type CalDavProfile as w, type CalendarAccount as x, type CalendarAccountKind as y, type CalendarCreateBody as z };
package/dist/browser.cjs CHANGED
@@ -3490,6 +3490,24 @@ var ArbiSessionExpiredError = class extends ArbiError {
3490
3490
  this.name = "ArbiSessionExpiredError";
3491
3491
  }
3492
3492
  };
3493
+ var ArbiWorkspaceSupersededError = class extends ArbiError {
3494
+ constructor(workspaceId, supersededBy) {
3495
+ super(`Opening ${workspaceId} was superseded by opening ${supersededBy}`);
3496
+ this.workspaceId = workspaceId;
3497
+ this.supersededBy = supersededBy;
3498
+ this.name = "ArbiWorkspaceSupersededError";
3499
+ }
3500
+ workspaceId;
3501
+ supersededBy;
3502
+ };
3503
+ var ArbiWorkspaceChangedError = class extends ArbiError {
3504
+ constructor(workspaceId) {
3505
+ super(`The workspace changed while reading ${workspaceId}`);
3506
+ this.workspaceId = workspaceId;
3507
+ this.name = "ArbiWorkspaceChangedError";
3508
+ }
3509
+ workspaceId;
3510
+ };
3493
3511
  function detailText(detail) {
3494
3512
  if (typeof detail === "string") return detail || void 0;
3495
3513
  if (Array.isArray(detail)) {
@@ -4503,7 +4521,8 @@ async function* listPaginated(arbi, options = {}) {
4503
4521
  order = "id_asc",
4504
4522
  fields,
4505
4523
  signal,
4506
- lookahead = 1
4524
+ lookahead = 1,
4525
+ workspaceExtId
4507
4526
  } = options;
4508
4527
  const fetchPage = async (pageOffset, limit) => {
4509
4528
  const query2 = {
@@ -4512,6 +4531,7 @@ async function* listPaginated(arbi, options = {}) {
4512
4531
  order
4513
4532
  };
4514
4533
  if (fields) query2.fields = fields;
4534
+ if (workspaceExtId) query2.workspace_ext_id = workspaceExtId;
4515
4535
  const { data, error } = await arbi.fetch.GET("/v1/document/list", {
4516
4536
  params: { query: query2 },
4517
4537
  signal
@@ -4519,7 +4539,11 @@ async function* listPaginated(arbi, options = {}) {
4519
4539
  if (error) {
4520
4540
  throw new Error(typeof error === "string" ? error : JSON.stringify(error));
4521
4541
  }
4522
- return data ?? [];
4542
+ const page = data ?? [];
4543
+ if (workspaceExtId && page.some((doc) => doc.workspace_ext_id !== workspaceExtId)) {
4544
+ throw new ArbiError(`The server returned another workspace's documents for ${workspaceExtId}`);
4545
+ }
4546
+ return page;
4523
4547
  };
4524
4548
  if (signal?.aborted) return;
4525
4549
  const depth = Math.max(1, Math.min(lookahead, MAX_PAGES));
@@ -9800,12 +9824,21 @@ function tokenExpiresWithin(token, seconds) {
9800
9824
  const expiresAt = client.readSessionClaims(token)?.expiresAt;
9801
9825
  return expiresAt != null && expiresAt - Date.now() < seconds * 1e3;
9802
9826
  }
9827
+ var WorkspaceOpenIntent = class {
9828
+ constructor(workspaceId) {
9829
+ this.workspaceId = workspaceId;
9830
+ }
9831
+ workspaceId;
9832
+ result = null;
9833
+ };
9803
9834
  var Arbi = class {
9804
9835
  client = null;
9805
9836
  loginResult = null;
9806
9837
  userProfile = null;
9807
9838
  profileListeners = /* @__PURE__ */ new Set();
9808
9839
  currentWorkspaceId = null;
9840
+ /** The latest `selectWorkspace` asked for: only it may open when its turn comes. */
9841
+ openIntent = null;
9809
9842
  chatCryptoContext = null;
9810
9843
  /** The chat keys I hold, opened once per set of epochs (`chatRingSignature`). */
9811
9844
  chatRings = /* @__PURE__ */ new Map();
@@ -10041,6 +10074,38 @@ var Arbi = class {
10041
10074
  * documents, which are listed page by page). A public workspace has no key and opens without one.
10042
10075
  */
10043
10076
  async selectWorkspace(workspaceId) {
10077
+ const client = this.requireClient();
10078
+ this.requireLogin();
10079
+ const intent = new WorkspaceOpenIntent(workspaceId);
10080
+ this.openIntent = intent;
10081
+ client.session.setSelectedWorkspace(workspaceId);
10082
+ const result = client.workspaceOpens.run(
10083
+ () => workspaceId,
10084
+ async () => {
10085
+ const latest = this.openIntent;
10086
+ if (latest && latest !== intent) return latest;
10087
+ const opened = await this.openOnServer(workspaceId);
10088
+ this.currentWorkspaceId = workspaceId;
10089
+ return opened;
10090
+ }
10091
+ ).then(
10092
+ (outcome) => {
10093
+ if (!(outcome instanceof WorkspaceOpenIntent)) return outcome;
10094
+ if (outcome.workspaceId === workspaceId && outcome.result) return outcome.result;
10095
+ throw new ArbiWorkspaceSupersededError(workspaceId, outcome.workspaceId);
10096
+ },
10097
+ (error) => {
10098
+ if (this.openIntent === intent) {
10099
+ client.session.setSelectedWorkspace(this.currentWorkspaceId);
10100
+ }
10101
+ throw error;
10102
+ }
10103
+ );
10104
+ intent.result = result;
10105
+ return result;
10106
+ }
10107
+ /** `POST /open` with the workspace's key sealed to this session (none for a public workspace). */
10108
+ async openOnServer(workspaceId) {
10044
10109
  const client = this.requireClient();
10045
10110
  const lr2 = this.requireLogin();
10046
10111
  const open = async (workspaceKey) => requireData(
@@ -10053,21 +10118,40 @@ var Arbi = class {
10053
10118
  const listed = await client.workspaceKeys.wrappedKey(workspaceId).catch((error) => {
10054
10119
  throw new ArbiError(error instanceof Error ? error.message : String(error));
10055
10120
  });
10056
- const opened = !listed.wrappedKey ? await open("") : await this.withWrappedKey(
10121
+ if (!listed.wrappedKey) return open("");
10122
+ return this.withWrappedKey(
10057
10123
  workspaceId,
10058
10124
  async (wrappedKey) => open(
10059
- await selectWorkspace(
10125
+ await generateEncryptedWorkspaceKey(
10060
10126
  client,
10061
- workspaceId,
10062
10127
  wrappedKey,
10063
10128
  lr2.serverSessionKey,
10064
10129
  client.crypto.bytesToBase64(lr2.signingPrivateKey)
10065
10130
  )
10066
10131
  )
10067
10132
  );
10068
- client.session.setSelectedWorkspace(workspaceId);
10069
- this.currentWorkspaceId = workspaceId;
10070
- return opened;
10133
+ }
10134
+ /** Resolves once no workspace open is running or waiting (a switch has landed on the server). */
10135
+ workspaceSettled() {
10136
+ return this.client ? this.client.workspaceOpens.idle() : Promise.resolve();
10137
+ }
10138
+ /**
10139
+ * Run `read` — a request answered from the session's open workspace — for `workspaceId`, and
10140
+ * keep its answer only if it can only be that workspace's: once no open is pending, the open
10141
+ * workspace must be `workspaceId` when it is sent and still be when it returns, with no open
10142
+ * started in between. Otherwise it throws `ArbiWorkspaceChangedError` and nothing it returned
10143
+ * is kept, so a list read across a switch can never be cached as another workspace's.
10144
+ */
10145
+ async readInWorkspace(workspaceId, read) {
10146
+ const opens = this.requireClient().workspaceOpens;
10147
+ await opens.idle();
10148
+ const generation = opens.generation;
10149
+ if (this.currentWorkspaceId !== workspaceId) throw new ArbiWorkspaceChangedError(workspaceId);
10150
+ const result = await read();
10151
+ if (opens.generation !== generation || this.currentWorkspaceId !== workspaceId) {
10152
+ throw new ArbiWorkspaceChangedError(workspaceId);
10153
+ }
10154
+ return result;
10071
10155
  }
10072
10156
  /**
10073
10157
  * Subscribe to "the session cannot be recovered". Fires when a request failed with 401 or
@@ -10089,6 +10173,7 @@ var Arbi = class {
10089
10173
  this.loginResult = null;
10090
10174
  this.userProfile = null;
10091
10175
  this.currentWorkspaceId = null;
10176
+ this.openIntent = null;
10092
10177
  this.chatCryptoContext = null;
10093
10178
  this.chatRings.clear();
10094
10179
  for (const listener of [...this.sessionExpiredListeners]) listener();
@@ -10136,6 +10221,7 @@ var Arbi = class {
10136
10221
  this.loginResult = null;
10137
10222
  this.userProfile = null;
10138
10223
  this.currentWorkspaceId = null;
10224
+ this.openIntent = null;
10139
10225
  this.chatCryptoContext = null;
10140
10226
  this.chatRings.clear();
10141
10227
  }
@@ -10530,7 +10616,16 @@ var Arbi = class {
10530
10616
  * }
10531
10617
  * ```
10532
10618
  */
10533
- listPaginated: (options) => listPaginated(this.requireClient(), options),
10619
+ listPaginated: (options) => {
10620
+ const { workspaceId, ...rest } = options ?? {};
10621
+ if (!workspaceId) return listPaginated(this.requireClient(), rest);
10622
+ const client = this.requireClient();
10623
+ const open = () => this.openWorkspace(workspaceId);
10624
+ return (async function* () {
10625
+ await open();
10626
+ yield* listPaginated(client, { ...rest, workspaceExtId: workspaceId });
10627
+ })();
10628
+ },
10534
10629
  /**
10535
10630
  * Collect all workspace documents into a single array using sequential pagination.
10536
10631
  *
@@ -12227,6 +12322,8 @@ exports.ACCOUNT_VENDOR = ACCOUNT_VENDOR;
12227
12322
  exports.Arbi = Arbi;
12228
12323
  exports.ArbiApiError = ArbiApiError;
12229
12324
  exports.ArbiError = ArbiError;
12325
+ exports.ArbiWorkspaceChangedError = ArbiWorkspaceChangedError;
12326
+ exports.ArbiWorkspaceSupersededError = ArbiWorkspaceSupersededError;
12230
12327
  exports.CallApiError = CallApiError;
12231
12328
  exports.DEFAULT_AI_USD_PER_GBP = DEFAULT_AI_USD_PER_GBP;
12232
12329
  exports.DRIVE_SYNC_VENDORS = DRIVE_SYNC_VENDORS;