@arbidocs/sdk 0.4.20 → 0.4.29

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.
@@ -1,2 +1,2 @@
1
- export { A as ActivityKind, a as ActivityResponse, b as AgentControlStateEvent, c as AgentStepDeltaEvent, d as AgentStepEvent, e as Arbi, f as ArbiApiError, g as ArbiError, h as ArbiErrorEvent, i as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthHeaders, n as AuthMode, o as AuthenticatedClient, C as ChatSession, p as CitationSummary, q as CliConfig, r as CliCredentials, s as CommandDescriptor, t as ConfigStore, u as ConnectOptions, v as ConversationResponse, w as CreateFactRequest, x as CreateFactsRequest, y as CreateWorkRequest, z as CreateWorkflowRequest, B as DeferredInterjectionEvent, K as FactResponse, L as FactSearchRequest, M as FactSearchResponse, P as ListFactsOptions, S as MessageMetadataPayload, T as MessageQueuedEvent, U as OutputTokensDetails, V as ParsedSlashCommand, W as PendingAuthResponse, X as PlanWorkRequest, Y as ProbeAnswerEvent, Z as ProjectInvoicesResponse, _ as ProjectUsageResponse, $ as QueryOptions, a0 as ReconnectOptions, a1 as ReconnectableWsConnection, a2 as RequestApprovalRequest, a3 as ResolvedCitation, a5 as ResponseCompletedEvent, a6 as ResponseContentPartAddedEvent, a7 as ResponseCreatedEvent, a8 as ResponseFailedEvent, a9 as ResponseOutputItemAddedEvent, aa as ResponseOutputItemDoneEvent, ab as ResponseOutputTextDeltaEvent, ac as ResponseOutputTextDoneEvent, ad as ResponseUsage, ae as ReviewWorkRequest, af as SSEEvent, ag as SSEStreamCallbacks, ah as SSEStreamResult, ai as SSEStreamStartData, ak as SkillSummary, am as TaskPlan, an as TokenBudgetContext, ao as UpdateConversationRequest, ap as UpdateFactRequest, aq as UpdateWorkflowRequest, aw as UserDailyUsageResponse, ax as UserInfo, ay as UserInputRequestEvent, az as UserMessageEvent, aA as WebSocketAuthError, aB as WorkStatus, aC as WorkflowAuthMode, aD as WorkflowResponse, aE as WorkflowRunResponse, aF as WorkspaceContext, aG as WsConnection, aH as account, aI as agentconfig, aJ as assistant, aK as authenticatedFetch, aM as buildRetrievalChunkTool, aN as buildRetrievalFullContextTool, aO as buildRetrievalTocTool, aP as connectWebSocket, aQ as connectWithReconnect, aR as consumeSSEStream, aS as contacts, aT as conversations, aU as countCitations, aV as createAuthenticatedClient, aX as dm, aY as doctags, aZ as documents, a_ as facts, a$ as files, b0 as filterSkills, b1 as formatAgentStepLabel, b2 as formatFileSize, b3 as formatItemLabel, b5 as formatUserName, b6 as formatWorkspaceChoices, bb as getErrorMessage, bc as getRawWorkspaceKey, bd as health, be as parseSSEEvents, bf as parseSlashCommand, bg as parseSlashTokenInProgress, bh as performPasswordLogin, bk as profile, bl as projects, bm as requireData, bn as requireOk, bo as resolveAuth, bp as resolveCitations, bq as resolveWorkspace, br as responses, bs as selectWorkspace, bt as selectWorkspaceById, bu as sessions, bv as settings, bw as streamSSE, bx as stripCitationMarkdown, by as summarizeCitations, bz as tags, bA as work, bB as workflows, bC as workspaces } from './browser-DY8mQOdF.cjs';
1
+ export { A as ActivityKind, a as ActivityResponse, b as AgentControlStateEvent, c as AgentStepDeltaEvent, d as AgentStepEvent, e as Arbi, f as ArbiApiError, g as ArbiError, h as ArbiErrorEvent, i as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthHeaders, n as AuthMode, o as AuthenticatedClient, C as ChatSession, p as CitationSummary, q as CliConfig, r as CliCredentials, s as CommandDescriptor, t as ConfigStore, u as ConnectOptions, v as ConversationResponse, w as CreateFactRequest, x as CreateFactsRequest, y as CreateWorkRequest, z as CreateWorkflowRequest, B as DeferredInterjectionEvent, K as FactResponse, L as FactSearchRequest, M as FactSearchResponse, P as ListFactsOptions, S as MessageMetadataPayload, T as MessageQueuedEvent, U as OutputTokensDetails, V as ParsedSlashCommand, W as PendingAuthResponse, X as PlanWorkRequest, Y as ProbeAnswerEvent, Z as ProjectInvoicesResponse, _ as ProjectUsageResponse, $ as QueryOptions, a0 as ReconnectOptions, a1 as ReconnectableWsConnection, a2 as RequestApprovalRequest, a3 as ResolvedCitation, a5 as ResponseCompletedEvent, a6 as ResponseContentPartAddedEvent, a7 as ResponseCreatedEvent, a8 as ResponseFailedEvent, a9 as ResponseOutputItemAddedEvent, aa as ResponseOutputItemDoneEvent, ab as ResponseOutputTextDeltaEvent, ac as ResponseOutputTextDoneEvent, ad as ResponseUsage, ae as ReviewWorkRequest, af as SSEEvent, ag as SSEStreamCallbacks, ah as SSEStreamResult, ai as SSEStreamStartData, ak as SkillSummary, am as SubmitBackgroundQueryOptions, an as TaskPlan, ao as TokenBudgetContext, ap as UpdateConversationRequest, aq as UpdateFactRequest, ar as UpdateWorkflowRequest, ax as UserDailyUsageResponse, ay as UserInfo, az as UserInputRequestEvent, aA as UserMessageEvent, aB as WebSocketAuthError, aC as WorkStatus, aD as WorkflowAuthMode, aE as WorkflowResponse, aF as WorkflowRunResponse, aG as WorkspaceContext, aH as WsConnection, aI as account, aJ as agentconfig, aL as assistant, aM as authenticatedFetch, aO as buildRetrievalChunkTool, aP as buildRetrievalFullContextTool, aQ as buildRetrievalTocTool, aR as connectWebSocket, aS as connectWithReconnect, aT as consumeSSEStream, aU as contacts, aV as conversations, aW as countCitations, aX as createAuthenticatedClient, aZ as dm, a_ as doctags, a$ as documents, b0 as facts, b1 as files, b2 as filterSkills, b3 as formatAgentStepLabel, b4 as formatFileSize, b5 as formatItemLabel, b7 as formatUserName, b8 as formatWorkspaceChoices, bd as getErrorMessage, be as getRawWorkspaceKey, bf as health, bg as parseSSEEvents, bh as parseSlashCommand, bi as parseSlashTokenInProgress, bj as performPasswordLogin, bm as profile, bn as projects, bo as requireData, bp as requireOk, bq as resolveAuth, br as resolveCitations, bs as resolveWorkspace, bt as responses, bu as selectWorkspace, bv as selectWorkspaceById, bw as sessions, bx as settings, by as streamSSE, bz as stripCitationMarkdown, bA as summarizeCitations, bB as tags, bC as work, bD as workflows, bE as workspaces } from './browser-AwN8DBBO.cjs';
2
2
  export { LoginProfile } from '@arbidocs/client';
package/dist/browser.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { A as ActivityKind, a as ActivityResponse, b as AgentControlStateEvent, c as AgentStepDeltaEvent, d as AgentStepEvent, e as Arbi, f as ArbiApiError, g as ArbiError, h as ArbiErrorEvent, i as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthHeaders, n as AuthMode, o as AuthenticatedClient, C as ChatSession, p as CitationSummary, q as CliConfig, r as CliCredentials, s as CommandDescriptor, t as ConfigStore, u as ConnectOptions, v as ConversationResponse, w as CreateFactRequest, x as CreateFactsRequest, y as CreateWorkRequest, z as CreateWorkflowRequest, B as DeferredInterjectionEvent, K as FactResponse, L as FactSearchRequest, M as FactSearchResponse, P as ListFactsOptions, S as MessageMetadataPayload, T as MessageQueuedEvent, U as OutputTokensDetails, V as ParsedSlashCommand, W as PendingAuthResponse, X as PlanWorkRequest, Y as ProbeAnswerEvent, Z as ProjectInvoicesResponse, _ as ProjectUsageResponse, $ as QueryOptions, a0 as ReconnectOptions, a1 as ReconnectableWsConnection, a2 as RequestApprovalRequest, a3 as ResolvedCitation, a5 as ResponseCompletedEvent, a6 as ResponseContentPartAddedEvent, a7 as ResponseCreatedEvent, a8 as ResponseFailedEvent, a9 as ResponseOutputItemAddedEvent, aa as ResponseOutputItemDoneEvent, ab as ResponseOutputTextDeltaEvent, ac as ResponseOutputTextDoneEvent, ad as ResponseUsage, ae as ReviewWorkRequest, af as SSEEvent, ag as SSEStreamCallbacks, ah as SSEStreamResult, ai as SSEStreamStartData, ak as SkillSummary, am as TaskPlan, an as TokenBudgetContext, ao as UpdateConversationRequest, ap as UpdateFactRequest, aq as UpdateWorkflowRequest, aw as UserDailyUsageResponse, ax as UserInfo, ay as UserInputRequestEvent, az as UserMessageEvent, aA as WebSocketAuthError, aB as WorkStatus, aC as WorkflowAuthMode, aD as WorkflowResponse, aE as WorkflowRunResponse, aF as WorkspaceContext, aG as WsConnection, aH as account, aI as agentconfig, aJ as assistant, aK as authenticatedFetch, aM as buildRetrievalChunkTool, aN as buildRetrievalFullContextTool, aO as buildRetrievalTocTool, aP as connectWebSocket, aQ as connectWithReconnect, aR as consumeSSEStream, aS as contacts, aT as conversations, aU as countCitations, aV as createAuthenticatedClient, aX as dm, aY as doctags, aZ as documents, a_ as facts, a$ as files, b0 as filterSkills, b1 as formatAgentStepLabel, b2 as formatFileSize, b3 as formatItemLabel, b5 as formatUserName, b6 as formatWorkspaceChoices, bb as getErrorMessage, bc as getRawWorkspaceKey, bd as health, be as parseSSEEvents, bf as parseSlashCommand, bg as parseSlashTokenInProgress, bh as performPasswordLogin, bk as profile, bl as projects, bm as requireData, bn as requireOk, bo as resolveAuth, bp as resolveCitations, bq as resolveWorkspace, br as responses, bs as selectWorkspace, bt as selectWorkspaceById, bu as sessions, bv as settings, bw as streamSSE, bx as stripCitationMarkdown, by as summarizeCitations, bz as tags, bA as work, bB as workflows, bC as workspaces } from './browser-DY8mQOdF.js';
1
+ export { A as ActivityKind, a as ActivityResponse, b as AgentControlStateEvent, c as AgentStepDeltaEvent, d as AgentStepEvent, e as Arbi, f as ArbiApiError, g as ArbiError, h as ArbiErrorEvent, i as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthHeaders, n as AuthMode, o as AuthenticatedClient, C as ChatSession, p as CitationSummary, q as CliConfig, r as CliCredentials, s as CommandDescriptor, t as ConfigStore, u as ConnectOptions, v as ConversationResponse, w as CreateFactRequest, x as CreateFactsRequest, y as CreateWorkRequest, z as CreateWorkflowRequest, B as DeferredInterjectionEvent, K as FactResponse, L as FactSearchRequest, M as FactSearchResponse, P as ListFactsOptions, S as MessageMetadataPayload, T as MessageQueuedEvent, U as OutputTokensDetails, V as ParsedSlashCommand, W as PendingAuthResponse, X as PlanWorkRequest, Y as ProbeAnswerEvent, Z as ProjectInvoicesResponse, _ as ProjectUsageResponse, $ as QueryOptions, a0 as ReconnectOptions, a1 as ReconnectableWsConnection, a2 as RequestApprovalRequest, a3 as ResolvedCitation, a5 as ResponseCompletedEvent, a6 as ResponseContentPartAddedEvent, a7 as ResponseCreatedEvent, a8 as ResponseFailedEvent, a9 as ResponseOutputItemAddedEvent, aa as ResponseOutputItemDoneEvent, ab as ResponseOutputTextDeltaEvent, ac as ResponseOutputTextDoneEvent, ad as ResponseUsage, ae as ReviewWorkRequest, af as SSEEvent, ag as SSEStreamCallbacks, ah as SSEStreamResult, ai as SSEStreamStartData, ak as SkillSummary, am as SubmitBackgroundQueryOptions, an as TaskPlan, ao as TokenBudgetContext, ap as UpdateConversationRequest, aq as UpdateFactRequest, ar as UpdateWorkflowRequest, ax as UserDailyUsageResponse, ay as UserInfo, az as UserInputRequestEvent, aA as UserMessageEvent, aB as WebSocketAuthError, aC as WorkStatus, aD as WorkflowAuthMode, aE as WorkflowResponse, aF as WorkflowRunResponse, aG as WorkspaceContext, aH as WsConnection, aI as account, aJ as agentconfig, aL as assistant, aM as authenticatedFetch, aO as buildRetrievalChunkTool, aP as buildRetrievalFullContextTool, aQ as buildRetrievalTocTool, aR as connectWebSocket, aS as connectWithReconnect, aT as consumeSSEStream, aU as contacts, aV as conversations, aW as countCitations, aX as createAuthenticatedClient, aZ as dm, a_ as doctags, a$ as documents, b0 as facts, b1 as files, b2 as filterSkills, b3 as formatAgentStepLabel, b4 as formatFileSize, b5 as formatItemLabel, b7 as formatUserName, b8 as formatWorkspaceChoices, bd as getErrorMessage, be as getRawWorkspaceKey, bf as health, bg as parseSSEEvents, bh as parseSlashCommand, bi as parseSlashTokenInProgress, bj as performPasswordLogin, bm as profile, bn as projects, bo as requireData, bp as requireOk, bq as resolveAuth, br as resolveCitations, bs as resolveWorkspace, bt as responses, bu as selectWorkspace, bv as selectWorkspaceById, bw as sessions, bx as settings, by as streamSSE, bz as stripCitationMarkdown, bA as summarizeCitations, bB as tags, bC as work, bD as workflows, bE as workspaces } from './browser-AwN8DBBO.js';
2
2
  export { LoginProfile } from '@arbidocs/client';
package/dist/browser.js CHANGED
@@ -3499,19 +3499,21 @@ function apiErrorDetail(apiError) {
3499
3499
  return detailText(body.detail) || (typeof body.message === "string" ? body.message : void 0);
3500
3500
  }
3501
3501
  var ArbiApiError = class extends ArbiError {
3502
+ status;
3502
3503
  apiError;
3503
3504
  /** Why the server refused, in its words (e.g. "run_at must be in the future"), when it said. */
3504
3505
  detail;
3505
- constructor(message, apiError) {
3506
+ constructor(message, apiError, status) {
3506
3507
  super(message);
3507
3508
  this.name = "ArbiApiError";
3508
3509
  this.apiError = apiError;
3510
+ this.status = status;
3509
3511
  this.detail = apiErrorDetail(apiError);
3510
3512
  }
3511
3513
  };
3512
3514
  function requireData(result, message) {
3513
3515
  if (result.error || !result.data) {
3514
- throw new ArbiApiError(message, result.error);
3516
+ throw new ArbiApiError(message, result.error, result.response?.status);
3515
3517
  }
3516
3518
  return result.data;
3517
3519
  }
@@ -4870,6 +4872,7 @@ __export(assistant_exports, {
4870
4872
  buildRetrievalChunkTool: () => buildRetrievalChunkTool,
4871
4873
  buildRetrievalFullContextTool: () => buildRetrievalFullContextTool,
4872
4874
  buildRetrievalTocTool: () => buildRetrievalTocTool,
4875
+ cancelAssistantRun: () => cancelAssistantRun,
4873
4876
  filterSkills: () => filterSkills,
4874
4877
  listCommands: () => listCommands,
4875
4878
  listSkills: () => listSkills,
@@ -4940,18 +4943,35 @@ async function retrieve(options) {
4940
4943
  return data;
4941
4944
  }
4942
4945
  async function queryAssistant(options) {
4943
- const { workspaceId, question, docIds, previousResponseId, model, mentions, signal, ...auth } = options;
4946
+ const {
4947
+ workspaceId,
4948
+ question,
4949
+ docIds,
4950
+ previousResponseId,
4951
+ conversationId,
4952
+ assistantMode,
4953
+ agentId,
4954
+ model,
4955
+ mentions,
4956
+ signal,
4957
+ activeArtifactExtId,
4958
+ ...auth
4959
+ } = options;
4944
4960
  const body = {
4945
4961
  input: question,
4962
+ ...activeArtifactExtId ? { active_artifact_ext_id: activeArtifactExtId } : {},
4946
4963
  workspace_ext_id: workspaceId,
4964
+ ...agentId ? { agent_ext_id: agentId } : {},
4947
4965
  stream: true,
4948
4966
  background: false,
4949
4967
  store: true,
4950
- tools: {
4968
+ tools: agentId ? {} : {
4951
4969
  retrieval_chunk: buildRetrievalChunkTool(docIds),
4952
4970
  retrieval_full_context: buildRetrievalFullContextTool([])
4953
4971
  },
4954
4972
  ...previousResponseId ? { previous_response_id: previousResponseId } : {},
4973
+ ...conversationId ? { conversation_ext_id: conversationId } : {},
4974
+ ...assistantMode ? { assistant_mode: assistantMode } : {},
4955
4975
  ...model ? { model } : {},
4956
4976
  ...mentions && mentions.length > 0 ? { mentions } : {}
4957
4977
  };
@@ -5013,6 +5033,91 @@ function filterSkills(items, query, pinned = []) {
5013
5033
  });
5014
5034
  return matched;
5015
5035
  }
5036
+ async function cancelAssistantRun(auth, responseId) {
5037
+ await authenticatedFetch({
5038
+ ...auth,
5039
+ path: `/v1/assistant/run/${encodeURIComponent(responseId)}/cancel`,
5040
+ method: "POST"
5041
+ });
5042
+ }
5043
+
5044
+ // src/operations/responses.ts
5045
+ var responses_exports = {};
5046
+ __export(responses_exports, {
5047
+ extractResponseText: () => extractResponseText,
5048
+ getResponse: () => getResponse,
5049
+ submitBackgroundQuery: () => submitBackgroundQuery
5050
+ });
5051
+ async function submitBackgroundQuery(options) {
5052
+ const {
5053
+ workspaceId,
5054
+ question,
5055
+ docIds,
5056
+ previousResponseId,
5057
+ model,
5058
+ task,
5059
+ conversationId,
5060
+ mentions,
5061
+ activeArtifactExtId,
5062
+ ...auth
5063
+ } = options;
5064
+ const tools = {};
5065
+ if (docIds.length > 0) {
5066
+ tools.retrieval_chunk = {
5067
+ name: "retrieval_chunk",
5068
+ description: "retrieval chunk",
5069
+ tool_args: { doc_ext_ids: docIds },
5070
+ tool_responses: {}
5071
+ };
5072
+ tools.retrieval_full_context = {
5073
+ name: "retrieval_full_context",
5074
+ description: "retrieval full context",
5075
+ tool_args: { doc_ext_ids: docIds },
5076
+ tool_responses: {}
5077
+ };
5078
+ }
5079
+ const body = {
5080
+ input: question,
5081
+ workspace_ext_id: workspaceId,
5082
+ stream: false,
5083
+ background: true,
5084
+ store: true,
5085
+ tools,
5086
+ ...task !== void 0 ? { task } : {},
5087
+ ...conversationId ? { conversation_ext_id: conversationId } : {},
5088
+ ...mentions !== void 0 ? { mentions } : {},
5089
+ ...activeArtifactExtId ? { active_artifact_ext_id: activeArtifactExtId } : {},
5090
+ ...previousResponseId ? { previous_response_id: previousResponseId } : {},
5091
+ ...model ? { model } : {}
5092
+ };
5093
+ const res = await authenticatedFetch({
5094
+ ...auth,
5095
+ path: "/v1/responses",
5096
+ method: "POST",
5097
+ body: JSON.stringify(body),
5098
+ headers: { "Content-Type": "application/json" }
5099
+ });
5100
+ return await res.json();
5101
+ }
5102
+ async function getResponse(auth, responseId) {
5103
+ const res = await authenticatedFetch({
5104
+ ...auth,
5105
+ path: `/v1/responses/${responseId}`,
5106
+ method: "GET"
5107
+ });
5108
+ return await res.json();
5109
+ }
5110
+ function extractResponseText(response) {
5111
+ const parts = [];
5112
+ for (const msg of response.output) {
5113
+ for (const item of msg.content) {
5114
+ if ("type" in item && item.type === "output_text" && "text" in item) {
5115
+ parts.push(item.text);
5116
+ }
5117
+ }
5118
+ }
5119
+ return parts.join("");
5120
+ }
5016
5121
 
5017
5122
  // src/operations/tags.ts
5018
5123
  var tags_exports = {};
@@ -5200,6 +5305,48 @@ async function getAuthorizeLimits(arbi) {
5200
5305
  "Failed to fetch authorize limits"
5201
5306
  );
5202
5307
  }
5308
+ async function getAgentSession(arbi, agentId) {
5309
+ return requireData(
5310
+ await arbi.fetch.GET("/v1/agents/{agent_ext_id}/session", {
5311
+ params: { path: { agent_ext_id: agentId } }
5312
+ }),
5313
+ "Failed to read agent session"
5314
+ );
5315
+ }
5316
+ async function startAgentSession(arbi, agentId, workspaceId) {
5317
+ return requireData(
5318
+ await arbi.fetch.POST("/v1/agents/{agent_ext_id}/session", {
5319
+ params: { path: { agent_ext_id: agentId } },
5320
+ body: { workspace_ext_id: workspaceId ?? null }
5321
+ }),
5322
+ "Failed to start agent session"
5323
+ );
5324
+ }
5325
+ async function closeAgentSession(arbi, agentId) {
5326
+ const { error } = await arbi.fetch.DELETE("/v1/agents/{agent_ext_id}/session", {
5327
+ params: { path: { agent_ext_id: agentId } }
5328
+ });
5329
+ if (error) throw new Error("Failed to close agent session");
5330
+ }
5331
+ async function listAgentChats(arbi, agentId) {
5332
+ return requireData(
5333
+ await arbi.fetch.GET("/v1/agents/{agent_ext_id}/chats", {
5334
+ params: { path: { agent_ext_id: agentId } }
5335
+ }),
5336
+ "Failed to read agent chats"
5337
+ );
5338
+ }
5339
+ async function stageAgentFile(auth, agentId, file, name) {
5340
+ const body = new FormData();
5341
+ body.append("file", file, name);
5342
+ const response = await authenticatedFetch({
5343
+ ...auth,
5344
+ path: `/v1/agents/${encodeURIComponent(agentId)}/files`,
5345
+ method: "POST",
5346
+ body
5347
+ });
5348
+ return response.json();
5349
+ }
5203
5350
 
5204
5351
  // src/operations/dm.ts
5205
5352
  function createDmCryptoContext(arbi, signingPrivateKeyBytes, userExtId) {
@@ -5309,7 +5456,9 @@ async function sendEncryptedDM(arbi, messages, crypto) {
5309
5456
  }))
5310
5457
  );
5311
5458
  const created = requireData(
5312
- await arbi.fetch.POST("/v1/notifications/", { body: { messages: encrypted } }),
5459
+ await arbi.fetch.POST("/v1/notifications/", {
5460
+ body: { messages: encrypted, context_only: false }
5461
+ }),
5313
5462
  "Failed to send message"
5314
5463
  );
5315
5464
  return created.map((n2) => ({
@@ -5342,7 +5491,7 @@ async function requestWorkspaceAccess(arbi, params, crypto) {
5342
5491
  async function sendDM(arbi, messages) {
5343
5492
  return requireData(
5344
5493
  await arbi.fetch.POST("/v1/notifications/", {
5345
- body: { messages }
5494
+ body: { messages, context_only: false }
5346
5495
  }),
5347
5496
  "Failed to send message"
5348
5497
  );
@@ -5907,6 +6056,18 @@ var Arbi = class {
5907
6056
  this.loginResult = await client.auth.loginWithKey({ email, signingPrivateKey });
5908
6057
  this.userProfile = this.loginResult.profile ?? null;
5909
6058
  }
6059
+ /** Recover browser authentication using the encrypted signing key already in IndexedDB. */
6060
+ async restoreSession(email) {
6061
+ const client = await this.init();
6062
+ const saved = await client.storage.getSession();
6063
+ if (!saved?.signingPrivateKey) return false;
6064
+ this.loginResult = await client.auth.loginWithKey({
6065
+ email,
6066
+ signingPrivateKey: saved.signingPrivateKey
6067
+ });
6068
+ this.userProfile = this.loginResult.profile ?? null;
6069
+ return true;
6070
+ }
5910
6071
  /** A workspace's key, sealed to the caller's own session (what `/open` and `POST /workspace/users` take). */
5911
6072
  async sealWorkspaceKey(workspaceId) {
5912
6073
  const client = this.requireClient();
@@ -6318,22 +6479,76 @@ var Arbi = class {
6318
6479
  assistantMode
6319
6480
  )
6320
6481
  };
6482
+ /** Persisted notifications also arrive on the normal workspace WebSocket. */
6483
+ notifications = {
6484
+ list: async (type) => {
6485
+ const { data, error } = await this.requireClient().fetch.GET("/v1/notifications/", {
6486
+ params: { query: { ...type ? { type } : {}, limit: 100 } }
6487
+ });
6488
+ if (error) throw new ArbiError("Could not load notifications");
6489
+ return data || [];
6490
+ },
6491
+ markRead: async (ids) => {
6492
+ if (!ids.length) return;
6493
+ const { error } = await this.requireClient().fetch.PATCH("/v1/notifications/", {
6494
+ body: { updates: ids.map((external_id) => ({ external_id, read: true })) }
6495
+ });
6496
+ if (error) throw new ArbiError("Could not mark notifications read");
6497
+ }
6498
+ };
6499
+ /** Authenticated native Word transport, with normal session recovery. */
6500
+ editor = {
6501
+ request: (path, options = {}) => this.recovering(async () => {
6502
+ const { baseUrl, accessToken } = this.getAuthHeaders();
6503
+ const headers = new Headers(options.headers);
6504
+ headers.set("Authorization", `Bearer ${accessToken}`);
6505
+ const response = await fetch(`${baseUrl}/v1/editor${path}`, { ...options, headers });
6506
+ if (!response.ok) {
6507
+ const body = await response.json().catch(() => null);
6508
+ throw new ArbiApiError(body?.detail || `Document request failed (${response.status})`, {
6509
+ status: response.status,
6510
+ statusText: response.statusText
6511
+ });
6512
+ }
6513
+ return response;
6514
+ })
6515
+ };
6321
6516
  // ── Assistant ─────────────────────────────────────────────────────────
6322
6517
  assistant = {
6518
+ cancelRun: (responseId) => this.recovering(() => cancelAssistantRun(this.getAuthHeaders(), responseId)),
6519
+ /** Start a durable background turn; task options make its thread a reviewable work item. */
6520
+ submit: (question, options) => {
6521
+ const workspaceId = this.requireWorkspace();
6522
+ return this.recovering(
6523
+ () => submitBackgroundQuery({
6524
+ ...this.getAuthHeaders(),
6525
+ ...options,
6526
+ workspaceId,
6527
+ question
6528
+ })
6529
+ );
6530
+ },
6531
+ /** Read the status of a background turn. */
6532
+ getResponse: (id) => this.recovering(() => getResponse(this.getAuthHeaders(), id)),
6323
6533
  /**
6324
6534
  * Send a question to the RAG assistant with streaming support.
6325
6535
  * Returns the accumulated result after the stream completes.
6326
6536
  */
6327
6537
  query: async (question, options) => {
6328
- const workspaceId = this.requireWorkspace();
6538
+ const workspaceId = options.workspaceId ?? this.requireWorkspace();
6329
6539
  const response = await this.recovering(
6330
6540
  () => queryAssistant({
6331
6541
  ...this.getAuthHeaders(),
6332
6542
  workspaceId,
6333
6543
  question,
6544
+ agentId: options.agentId,
6334
6545
  docIds: options.docIds,
6335
6546
  previousResponseId: options.previousResponseId,
6547
+ conversationId: options.conversationId,
6548
+ assistantMode: options.assistantMode,
6549
+ mentions: options.mentions,
6336
6550
  model: options.model,
6551
+ activeArtifactExtId: options.activeArtifactExtId,
6337
6552
  signal: options.signal
6338
6553
  })
6339
6554
  );
@@ -6509,6 +6724,11 @@ var Arbi = class {
6509
6724
  };
6510
6725
  // ── Agents ──────────────────────────────────────────────────────────
6511
6726
  agents = {
6727
+ getSession: (agentId) => getAgentSession(this.requireClient(), agentId),
6728
+ startSession: (agentId, workspaceId) => startAgentSession(this.requireClient(), agentId, workspaceId),
6729
+ closeSession: (agentId) => closeAgentSession(this.requireClient(), agentId),
6730
+ listChats: (agentId) => listAgentChats(this.requireClient(), agentId),
6731
+ stageFile: (agentId, file, name) => this.recovering(() => stageAgentFile(this.getAuthHeaders(), agentId, file, name)),
6512
6732
  list: () => listAgents(this.requireClient()),
6513
6733
  create: (name) => createAgent(this.requireClient(), name),
6514
6734
  getConfig: (agentExtId) => getAgentConfig(this.requireClient(), agentExtId),
@@ -6595,69 +6815,6 @@ var Arbi = class {
6595
6815
  }
6596
6816
  };
6597
6817
 
6598
- // src/operations/responses.ts
6599
- var responses_exports = {};
6600
- __export(responses_exports, {
6601
- extractResponseText: () => extractResponseText,
6602
- getResponse: () => getResponse,
6603
- submitBackgroundQuery: () => submitBackgroundQuery
6604
- });
6605
- async function submitBackgroundQuery(options) {
6606
- const { workspaceId, question, docIds, previousResponseId, model, ...auth } = options;
6607
- const tools = {};
6608
- if (docIds.length > 0) {
6609
- tools.retrieval_chunk = {
6610
- name: "retrieval_chunk",
6611
- description: "retrieval chunk",
6612
- tool_args: { doc_ext_ids: docIds },
6613
- tool_responses: {}
6614
- };
6615
- tools.retrieval_full_context = {
6616
- name: "retrieval_full_context",
6617
- description: "retrieval full context",
6618
- tool_args: { doc_ext_ids: [] },
6619
- tool_responses: {}
6620
- };
6621
- }
6622
- const body = {
6623
- input: question,
6624
- workspace_ext_id: workspaceId,
6625
- stream: false,
6626
- background: true,
6627
- store: true,
6628
- tools,
6629
- ...previousResponseId ? { previous_response_id: previousResponseId } : {},
6630
- ...model ? { model } : {}
6631
- };
6632
- const res = await authenticatedFetch({
6633
- ...auth,
6634
- path: "/v1/responses",
6635
- method: "POST",
6636
- body: JSON.stringify(body),
6637
- headers: { "Content-Type": "application/json" }
6638
- });
6639
- return await res.json();
6640
- }
6641
- async function getResponse(auth, responseId) {
6642
- const res = await authenticatedFetch({
6643
- ...auth,
6644
- path: `/v1/responses/${responseId}`,
6645
- method: "GET"
6646
- });
6647
- return await res.json();
6648
- }
6649
- function extractResponseText(response) {
6650
- const parts = [];
6651
- for (const msg of response.output) {
6652
- for (const item of msg.content) {
6653
- if ("type" in item && item.type === "output_text" && "text" in item) {
6654
- parts.push(item.text);
6655
- }
6656
- }
6657
- }
6658
- return parts.join("");
6659
- }
6660
-
6661
6818
  export { Arbi, ArbiApiError, ArbiError, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, assistant_exports as assistant, authenticatedFetch, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, countCitations, createAuthenticatedClient, dm_exports as dm, doctags_exports as doctags, documents_exports as documents, facts_exports as facts, files_exports as files, filterSkills, formatAgentStepLabel, formatFileSize, formatItemLabel, formatUserName, formatWorkspaceChoices, getErrorMessage, getRawWorkspaceKey, health_exports as health, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, performPasswordLogin, profile_exports as profile, projects_exports as projects, requireData, requireOk, resolveAuth, resolveCitations, resolveWorkspace, responses_exports as responses, selectWorkspace, selectWorkspaceById, sessions_exports as sessions, settings_exports as settings, streamSSE, stripCitationMarkdown, summarizeCitations, tags_exports as tags, work_exports as work, workflows_exports as workflows, workspaces_exports as workspaces };
6662
6819
  //# sourceMappingURL=browser.js.map
6663
6820
  //# sourceMappingURL=browser.js.map