@arbidocs/sdk 0.4.15 → 0.4.18

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/browser.cjs CHANGED
@@ -3490,12 +3490,26 @@ var ArbiSessionExpiredError = class extends ArbiError {
3490
3490
  this.name = "ArbiSessionExpiredError";
3491
3491
  }
3492
3492
  };
3493
+ function detailText(detail) {
3494
+ if (!Array.isArray(detail)) return detail || void 0;
3495
+ const messages = detail.map((d2) => d2?.msg).filter((m2) => Boolean(m2));
3496
+ return messages.length ? messages.join("; ") : void 0;
3497
+ }
3498
+ function apiErrorDetail(apiError) {
3499
+ if (typeof apiError === "string") return apiError || void 0;
3500
+ if (!apiError || typeof apiError !== "object") return void 0;
3501
+ const body = apiError;
3502
+ return detailText(body.detail) || (typeof body.message === "string" ? body.message : void 0);
3503
+ }
3493
3504
  var ArbiApiError = class extends ArbiError {
3494
3505
  apiError;
3506
+ /** Why the server refused, in its words (e.g. "run_at must be in the future"), when it said. */
3507
+ detail;
3495
3508
  constructor(message, apiError) {
3496
3509
  super(message);
3497
3510
  this.name = "ArbiApiError";
3498
3511
  this.apiError = apiError;
3512
+ this.detail = apiErrorDetail(apiError);
3499
3513
  }
3500
3514
  };
3501
3515
  function requireData(result, message) {
@@ -3544,7 +3558,7 @@ async function extractErrorMessage(res) {
3544
3558
  if (text) {
3545
3559
  try {
3546
3560
  const json = JSON.parse(text);
3547
- bodyDetail = json.detail || json.message || json.error || void 0;
3561
+ bodyDetail = detailText(json.detail) || json.message || json.error || void 0;
3548
3562
  } catch {
3549
3563
  if (text.length < 200) bodyDetail = text;
3550
3564
  }
@@ -4788,8 +4802,8 @@ __export(conversations_exports, {
4788
4802
  getMessage: () => getMessage,
4789
4803
  importConversations: () => importConversations,
4790
4804
  listConversations: () => listConversations,
4791
- shareConversation: () => shareConversation,
4792
- updateConversationTitle: () => updateConversationTitle
4805
+ postConversationMessage: () => postConversationMessage,
4806
+ updateConversationAssistantMode: () => updateConversationAssistantMode
4793
4807
  });
4794
4808
  async function listConversations(arbi) {
4795
4809
  return requireData(await arbi.fetch.GET("/v1/conversation/list"), "Failed to fetch conversations");
@@ -4821,23 +4835,6 @@ async function deleteConversation(arbi, conversationId) {
4821
4835
  "Failed to delete conversation"
4822
4836
  );
4823
4837
  }
4824
- async function shareConversation(arbi, conversationId) {
4825
- return requireData(
4826
- await arbi.fetch.POST("/v1/conversation/{conversation_ext_id}/share", {
4827
- params: { path: { conversation_ext_id: conversationId } }
4828
- }),
4829
- "Failed to share conversation"
4830
- );
4831
- }
4832
- async function updateConversationTitle(arbi, conversationId, title) {
4833
- return requireData(
4834
- await arbi.fetch.PATCH("/v1/conversation/{conversation_ext_id}/title", {
4835
- params: { path: { conversation_ext_id: conversationId } },
4836
- body: { title }
4837
- }),
4838
- "Failed to update title"
4839
- );
4840
- }
4841
4838
  async function getMessage(arbi, messageId) {
4842
4839
  return requireData(
4843
4840
  await arbi.fetch.GET("/v1/conversation/message/{message_ext_id}", {
@@ -4854,6 +4851,21 @@ async function deleteMessage(arbi, messageId) {
4854
4851
  "Failed to delete message"
4855
4852
  );
4856
4853
  }
4854
+ async function postConversationMessage(arbi, body) {
4855
+ return requireData(
4856
+ await arbi.fetch.POST("/v1/conversation/message", { body }),
4857
+ "Failed to post message"
4858
+ );
4859
+ }
4860
+ async function updateConversationAssistantMode(arbi, conversationId, assistantMode) {
4861
+ return requireData(
4862
+ await arbi.fetch.PATCH("/v1/conversation/{conversation_ext_id}/assistant-mode", {
4863
+ params: { path: { conversation_ext_id: conversationId } },
4864
+ body: { assistant_mode: assistantMode }
4865
+ }),
4866
+ "Failed to update assistant mode"
4867
+ );
4868
+ }
4857
4869
 
4858
4870
  // src/operations/assistant.ts
4859
4871
  var assistant_exports = {};
@@ -4931,7 +4943,7 @@ async function retrieve(options) {
4931
4943
  return data;
4932
4944
  }
4933
4945
  async function queryAssistant(options) {
4934
- const { workspaceId, question, docIds, previousResponseId, model, signal, ...auth } = options;
4946
+ const { workspaceId, question, docIds, previousResponseId, model, mentions, signal, ...auth } = options;
4935
4947
  const body = {
4936
4948
  input: question,
4937
4949
  workspace_ext_id: workspaceId,
@@ -4943,7 +4955,8 @@ async function queryAssistant(options) {
4943
4955
  retrieval_full_context: buildRetrievalFullContextTool([])
4944
4956
  },
4945
4957
  ...previousResponseId ? { previous_response_id: previousResponseId } : {},
4946
- ...model ? { model } : {}
4958
+ ...model ? { model } : {},
4959
+ ...mentions && mentions.length > 0 ? { mentions } : {}
4947
4960
  };
4948
4961
  return authenticatedFetch({
4949
4962
  ...auth,
@@ -5635,54 +5648,121 @@ async function getUserUsageToday(arbi) {
5635
5648
  return requireData(await arbi.fetch.GET("/v1/user/me/usage/today"), "Failed to fetch today usage");
5636
5649
  }
5637
5650
 
5638
- // src/operations/tasks.ts
5639
- var tasks_exports = {};
5640
- __export(tasks_exports, {
5641
- createTask: () => createTask,
5642
- deleteTask: () => deleteTask,
5643
- getTask: () => getTask,
5644
- listTaskRuns: () => listTaskRuns,
5645
- listTasks: () => listTasks,
5646
- runTask: () => runTask,
5647
- updateTask: () => updateTask
5651
+ // src/operations/work.ts
5652
+ var work_exports = {};
5653
+ __export(work_exports, {
5654
+ createWork: () => createWork,
5655
+ getActivity: () => getActivity,
5656
+ getPendingAuth: () => getPendingAuth,
5657
+ planWork: () => planWork,
5658
+ requestApproval: () => requestApproval,
5659
+ reviewConversation: () => reviewConversation,
5660
+ runConversation: () => runConversation,
5661
+ updateConversation: () => updateConversation
5648
5662
  });
5649
- async function listTasks(arbi) {
5650
- return requireData(await arbi.fetch.GET("/v1/tasks"), "Failed to list tasks");
5663
+ var byId = (conversationId) => ({
5664
+ params: { path: { conversation_ext_id: conversationId } }
5665
+ });
5666
+ async function updateConversation(arbi, conversationId, body) {
5667
+ return requireData(
5668
+ await arbi.fetch.PATCH("/v1/conversation/{conversation_ext_id}", {
5669
+ ...byId(conversationId),
5670
+ body
5671
+ }),
5672
+ "Failed to update conversation"
5673
+ );
5651
5674
  }
5652
- async function createTask(arbi, body) {
5653
- return requireData(await arbi.fetch.POST("/v1/tasks", { body }), "Failed to create task");
5675
+ async function createWork(arbi, body) {
5676
+ return requireData(
5677
+ await arbi.fetch.POST("/v1/conversation/work", { body }),
5678
+ "Failed to create task"
5679
+ );
5654
5680
  }
5655
- async function getTask(arbi, taskId) {
5681
+ async function runConversation(arbi, conversationId) {
5656
5682
  return requireData(
5657
- await arbi.fetch.GET("/v1/tasks/{task_id}", { params: { path: { task_id: taskId } } }),
5658
- "Failed to get task"
5683
+ await arbi.fetch.POST("/v1/conversation/{conversation_ext_id}/run", byId(conversationId)),
5684
+ "Failed to run task"
5659
5685
  );
5660
5686
  }
5661
- async function updateTask(arbi, taskId, body) {
5687
+ async function reviewConversation(arbi, conversationId, body) {
5662
5688
  return requireData(
5663
- await arbi.fetch.PATCH("/v1/tasks/{task_id}", {
5664
- params: { path: { task_id: taskId } },
5689
+ await arbi.fetch.POST("/v1/conversation/{conversation_ext_id}/review", {
5690
+ ...byId(conversationId),
5665
5691
  body
5666
5692
  }),
5667
- "Failed to update task"
5693
+ "Failed to review task"
5668
5694
  );
5669
5695
  }
5670
- async function deleteTask(arbi, taskId) {
5671
- const { error } = await arbi.fetch.DELETE("/v1/tasks/{task_id}", {
5672
- params: { path: { task_id: taskId } }
5673
- });
5674
- if (error) throw new Error("Failed to delete task");
5696
+ async function requestApproval(arbi, conversationId, body) {
5697
+ return requireData(
5698
+ await arbi.fetch.POST("/v1/conversation/{conversation_ext_id}/request-approval", {
5699
+ ...byId(conversationId),
5700
+ body
5701
+ }),
5702
+ "Failed to request approval"
5703
+ );
5675
5704
  }
5676
- async function runTask(arbi, taskId) {
5705
+ async function getPendingAuth(arbi, conversationId) {
5677
5706
  return requireData(
5678
- await arbi.fetch.POST("/v1/tasks/{task_id}/run", { params: { path: { task_id: taskId } } }),
5679
- "Failed to run task"
5707
+ await arbi.fetch.GET(
5708
+ "/v1/conversation/{conversation_ext_id}/pending-auth",
5709
+ byId(conversationId)
5710
+ ),
5711
+ "Failed to read the pending access request"
5680
5712
  );
5681
5713
  }
5682
- async function listTaskRuns(arbi, taskId) {
5714
+ async function getActivity(arbi, conversationId) {
5683
5715
  return requireData(
5684
- await arbi.fetch.GET("/v1/tasks/{task_id}/runs", { params: { path: { task_id: taskId } } }),
5685
- "Failed to list task runs"
5716
+ await arbi.fetch.GET("/v1/conversation/{conversation_ext_id}/activity", byId(conversationId)),
5717
+ "Failed to read the task activity"
5718
+ );
5719
+ }
5720
+ async function planWork(arbi, body) {
5721
+ return requireData(
5722
+ await arbi.fetch.POST("/v1/conversation/work/plan", { body }),
5723
+ "Failed to draft a plan"
5724
+ );
5725
+ }
5726
+
5727
+ // src/operations/workflows.ts
5728
+ var workflows_exports = {};
5729
+ __export(workflows_exports, {
5730
+ createWorkflow: () => createWorkflow,
5731
+ deleteWorkflow: () => deleteWorkflow,
5732
+ getWorkflow: () => getWorkflow,
5733
+ listWorkflows: () => listWorkflows,
5734
+ runWorkflow: () => runWorkflow,
5735
+ updateWorkflow: () => updateWorkflow
5736
+ });
5737
+ var byId2 = (workflowId) => ({ params: { path: { workflow_id: workflowId } } });
5738
+ async function listWorkflows(arbi) {
5739
+ return requireData(await arbi.fetch.GET("/v1/workflow"), "Failed to list workflows");
5740
+ }
5741
+ async function createWorkflow(arbi, body) {
5742
+ return requireData(await arbi.fetch.POST("/v1/workflow", { body }), "Failed to create workflow");
5743
+ }
5744
+ async function getWorkflow(arbi, workflowId) {
5745
+ return requireData(
5746
+ await arbi.fetch.GET("/v1/workflow/{workflow_id}", byId2(workflowId)),
5747
+ "Failed to get workflow"
5748
+ );
5749
+ }
5750
+ async function updateWorkflow(arbi, workflowId, body) {
5751
+ return requireData(
5752
+ await arbi.fetch.PATCH("/v1/workflow/{workflow_id}", { ...byId2(workflowId), body }),
5753
+ "Failed to update workflow"
5754
+ );
5755
+ }
5756
+ async function deleteWorkflow(arbi, workflowId) {
5757
+ requireOk(
5758
+ await arbi.fetch.DELETE("/v1/workflow/{workflow_id}", byId2(workflowId)),
5759
+ "Failed to delete workflow"
5760
+ );
5761
+ }
5762
+ async function runWorkflow(arbi, workflowId) {
5763
+ return requireData(
5764
+ await arbi.fetch.POST("/v1/workflow/{workflow_id}/run", byId2(workflowId)),
5765
+ "Failed to run workflow"
5686
5766
  );
5687
5767
  }
5688
5768
 
@@ -6194,10 +6274,52 @@ var Arbi = class {
6194
6274
  list: () => listConversations(this.requireClient()),
6195
6275
  getThreads: (conversationId) => getConversationThreads(this.requireClient(), conversationId),
6196
6276
  delete: (conversationId) => deleteConversation(this.requireClient(), conversationId),
6197
- share: (conversationId) => shareConversation(this.requireClient(), conversationId),
6198
- updateTitle: (conversationId, title) => updateConversationTitle(this.requireClient(), conversationId, title),
6277
+ /**
6278
+ * Patch a conversation: `title`, `shared` (owner only), and the work fields (`description`,
6279
+ * `due_at`, `signoff_user_ext_id`, `parent_conversation_ext_id`, `status`, `plan`). The one call
6280
+ * behind rename, share and unshare.
6281
+ */
6282
+ update: (conversationId, body) => updateConversation(this.requireClient(), conversationId, body),
6283
+ /** Create a work item: a plain to-do, or (with a prompt / skill) agent work that starts now. */
6284
+ createWork: (body) => createWork(this.requireClient(), body),
6285
+ /** Run a work item now, or retry it. */
6286
+ run: (conversationId) => runConversation(this.requireClient(), conversationId),
6287
+ /** The sign-off person approves, or sends feedback back to the agent in the same thread. */
6288
+ review: (conversationId, body) => reviewConversation(this.requireClient(), conversationId, body),
6289
+ /** Hand sign-off to another workspace member. */
6290
+ requestApproval: (conversationId, body) => requestApproval(this.requireClient(), conversationId, body),
6291
+ /** The session key an unattended run waits for the owner to allow; 404 when nothing waits. */
6292
+ pendingAuth: (conversationId) => getPendingAuth(this.requireClient(), conversationId),
6293
+ /** The task's history, oldest first. */
6294
+ activity: (conversationId) => getActivity(this.requireClient(), conversationId),
6295
+ /** Draft a reviewable plan from an objective. */
6296
+ plan: (body) => planWork(this.requireClient(), body),
6297
+ /**
6298
+ * Run a work item and, when the run is parked waiting for workspace access, grant the agent's
6299
+ * run session a temporary key and run it again. Work that needs no approval returns from the
6300
+ * first call already running.
6301
+ */
6302
+ runWithAuth: async (conversationId) => {
6303
+ const client = this.requireClient();
6304
+ const first = await runConversation(client, conversationId);
6305
+ if (!first.pending_auth_request_id) return first;
6306
+ const pending = await getPendingAuth(client, conversationId);
6307
+ await this.workspaces.grantTemporaryAccess({
6308
+ workspaceId: pending.workspace_ext_id ?? this.getWorkspaceId(),
6309
+ emails: [pending.agent_email],
6310
+ sessionPubkeyB64: pending.session_pubkey
6311
+ });
6312
+ return runConversation(client, conversationId);
6313
+ },
6199
6314
  getMessage: (messageId) => getMessage(this.requireClient(), messageId),
6200
- deleteMessage: (messageId) => deleteMessage(this.requireClient(), messageId)
6315
+ deleteMessage: (messageId) => deleteMessage(this.requireClient(), messageId),
6316
+ /** Post a human comment (no assistant run) — see `postConversationMessage`. */
6317
+ postMessage: (body) => postConversationMessage(this.requireClient(), body),
6318
+ setAssistantMode: (conversationId, assistantMode) => updateConversationAssistantMode(
6319
+ this.requireClient(),
6320
+ conversationId,
6321
+ assistantMode
6322
+ )
6201
6323
  };
6202
6324
  // ── Assistant ─────────────────────────────────────────────────────────
6203
6325
  assistant = {
@@ -6417,33 +6539,14 @@ var Arbi = class {
6417
6539
  return session;
6418
6540
  }
6419
6541
  };
6420
- // ── Scheduled tasks ───────────────────────────────────────────────────
6421
- tasks = {
6422
- list: () => listTasks(this.requireClient()),
6423
- create: (body) => createTask(this.requireClient(), body),
6424
- get: (taskId) => getTask(this.requireClient(), taskId),
6425
- update: (taskId, body) => updateTask(this.requireClient(), taskId, body),
6426
- delete: (taskId) => deleteTask(this.requireClient(), taskId),
6427
- run: (taskId) => runTask(this.requireClient(), taskId),
6428
- listRuns: (taskId) => listTaskRuns(this.requireClient(), taskId),
6429
- /**
6430
- * Run a task and, when the run is parked waiting for workspace access (a temporary
6431
- * authorization tier), grant the agent's run session a temporary key and run it again.
6432
- * A task that needs no approval returns from the first call already running.
6433
- */
6434
- runWithAuth: async (taskId) => {
6435
- const client = this.requireClient();
6436
- const first = await runTask(client, taskId);
6437
- if (!first.pending_auth_request_id || !first.pending_auth_session_pubkey || !first.pending_auth_agent_email || !first.workspace_ext_id) {
6438
- return first;
6439
- }
6440
- await this.workspaces.grantTemporaryAccess({
6441
- workspaceId: first.workspace_ext_id,
6442
- emails: [first.pending_auth_agent_email],
6443
- sessionPubkeyB64: first.pending_auth_session_pubkey
6444
- });
6445
- return runTask(client, taskId);
6446
- }
6542
+ // ── Workflows ─────────────────────────────────────────────────────────
6543
+ workflows = {
6544
+ list: () => listWorkflows(this.requireClient()),
6545
+ create: (body) => createWorkflow(this.requireClient(), body),
6546
+ update: (workflowId, body) => updateWorkflow(this.requireClient(), workflowId, body),
6547
+ delete: (workflowId) => deleteWorkflow(this.requireClient(), workflowId),
6548
+ /** Fire a workflow now, as a test run. Resolves with the conversation it created and whether it started. */
6549
+ run: (workflowId) => runWorkflow(this.requireClient(), workflowId)
6447
6550
  };
6448
6551
  // ── Workspace facts ─────────────────────────────────────────────────
6449
6552
  facts = {
@@ -6610,7 +6713,8 @@ exports.streamSSE = streamSSE;
6610
6713
  exports.stripCitationMarkdown = stripCitationMarkdown;
6611
6714
  exports.summarizeCitations = summarizeCitations;
6612
6715
  exports.tags = tags_exports;
6613
- exports.tasks = tasks_exports;
6716
+ exports.work = work_exports;
6717
+ exports.workflows = workflows_exports;
6614
6718
  exports.workspaces = workspaces_exports;
6615
6719
  //# sourceMappingURL=browser.cjs.map
6616
6720
  //# sourceMappingURL=browser.cjs.map