@arbidocs/sdk 0.4.16 → 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-B53im_GV.d.cts → browser-DY8mQOdF.d.cts} +4404 -3756
- package/dist/{browser-B53im_GV.d.ts → browser-DY8mQOdF.d.ts} +4404 -3756
- package/dist/browser.cjs +189 -85
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +188 -85
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +189 -85
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +188 -85
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -3502,12 +3502,26 @@ var ArbiSessionExpiredError = class extends ArbiError {
|
|
|
3502
3502
|
this.name = "ArbiSessionExpiredError";
|
|
3503
3503
|
}
|
|
3504
3504
|
};
|
|
3505
|
+
function detailText(detail) {
|
|
3506
|
+
if (!Array.isArray(detail)) return detail || void 0;
|
|
3507
|
+
const messages = detail.map((d2) => d2?.msg).filter((m2) => Boolean(m2));
|
|
3508
|
+
return messages.length ? messages.join("; ") : void 0;
|
|
3509
|
+
}
|
|
3510
|
+
function apiErrorDetail(apiError) {
|
|
3511
|
+
if (typeof apiError === "string") return apiError || void 0;
|
|
3512
|
+
if (!apiError || typeof apiError !== "object") return void 0;
|
|
3513
|
+
const body = apiError;
|
|
3514
|
+
return detailText(body.detail) || (typeof body.message === "string" ? body.message : void 0);
|
|
3515
|
+
}
|
|
3505
3516
|
var ArbiApiError = class extends ArbiError {
|
|
3506
3517
|
apiError;
|
|
3518
|
+
/** Why the server refused, in its words (e.g. "run_at must be in the future"), when it said. */
|
|
3519
|
+
detail;
|
|
3507
3520
|
constructor(message, apiError) {
|
|
3508
3521
|
super(message);
|
|
3509
3522
|
this.name = "ArbiApiError";
|
|
3510
3523
|
this.apiError = apiError;
|
|
3524
|
+
this.detail = apiErrorDetail(apiError);
|
|
3511
3525
|
}
|
|
3512
3526
|
};
|
|
3513
3527
|
function requireData(result, message) {
|
|
@@ -3568,7 +3582,7 @@ async function extractErrorMessage(res) {
|
|
|
3568
3582
|
if (text) {
|
|
3569
3583
|
try {
|
|
3570
3584
|
const json = JSON.parse(text);
|
|
3571
|
-
bodyDetail = json.detail || json.message || json.error || void 0;
|
|
3585
|
+
bodyDetail = detailText(json.detail) || json.message || json.error || void 0;
|
|
3572
3586
|
} catch {
|
|
3573
3587
|
if (text.length < 200) bodyDetail = text;
|
|
3574
3588
|
}
|
|
@@ -5337,8 +5351,8 @@ __export(conversations_exports, {
|
|
|
5337
5351
|
getMessage: () => getMessage,
|
|
5338
5352
|
importConversations: () => importConversations,
|
|
5339
5353
|
listConversations: () => listConversations,
|
|
5340
|
-
|
|
5341
|
-
|
|
5354
|
+
postConversationMessage: () => postConversationMessage,
|
|
5355
|
+
updateConversationAssistantMode: () => updateConversationAssistantMode
|
|
5342
5356
|
});
|
|
5343
5357
|
async function listConversations(arbi) {
|
|
5344
5358
|
return requireData(await arbi.fetch.GET("/v1/conversation/list"), "Failed to fetch conversations");
|
|
@@ -5370,23 +5384,6 @@ async function deleteConversation(arbi, conversationId) {
|
|
|
5370
5384
|
"Failed to delete conversation"
|
|
5371
5385
|
);
|
|
5372
5386
|
}
|
|
5373
|
-
async function shareConversation(arbi, conversationId) {
|
|
5374
|
-
return requireData(
|
|
5375
|
-
await arbi.fetch.POST("/v1/conversation/{conversation_ext_id}/share", {
|
|
5376
|
-
params: { path: { conversation_ext_id: conversationId } }
|
|
5377
|
-
}),
|
|
5378
|
-
"Failed to share conversation"
|
|
5379
|
-
);
|
|
5380
|
-
}
|
|
5381
|
-
async function updateConversationTitle(arbi, conversationId, title) {
|
|
5382
|
-
return requireData(
|
|
5383
|
-
await arbi.fetch.PATCH("/v1/conversation/{conversation_ext_id}/title", {
|
|
5384
|
-
params: { path: { conversation_ext_id: conversationId } },
|
|
5385
|
-
body: { title }
|
|
5386
|
-
}),
|
|
5387
|
-
"Failed to update title"
|
|
5388
|
-
);
|
|
5389
|
-
}
|
|
5390
5387
|
async function getMessage(arbi, messageId) {
|
|
5391
5388
|
return requireData(
|
|
5392
5389
|
await arbi.fetch.GET("/v1/conversation/message/{message_ext_id}", {
|
|
@@ -5403,6 +5400,21 @@ async function deleteMessage(arbi, messageId) {
|
|
|
5403
5400
|
"Failed to delete message"
|
|
5404
5401
|
);
|
|
5405
5402
|
}
|
|
5403
|
+
async function postConversationMessage(arbi, body) {
|
|
5404
|
+
return requireData(
|
|
5405
|
+
await arbi.fetch.POST("/v1/conversation/message", { body }),
|
|
5406
|
+
"Failed to post message"
|
|
5407
|
+
);
|
|
5408
|
+
}
|
|
5409
|
+
async function updateConversationAssistantMode(arbi, conversationId, assistantMode) {
|
|
5410
|
+
return requireData(
|
|
5411
|
+
await arbi.fetch.PATCH("/v1/conversation/{conversation_ext_id}/assistant-mode", {
|
|
5412
|
+
params: { path: { conversation_ext_id: conversationId } },
|
|
5413
|
+
body: { assistant_mode: assistantMode }
|
|
5414
|
+
}),
|
|
5415
|
+
"Failed to update assistant mode"
|
|
5416
|
+
);
|
|
5417
|
+
}
|
|
5406
5418
|
|
|
5407
5419
|
// src/operations/assistant.ts
|
|
5408
5420
|
var assistant_exports = {};
|
|
@@ -5480,7 +5492,7 @@ async function retrieve(options) {
|
|
|
5480
5492
|
return data;
|
|
5481
5493
|
}
|
|
5482
5494
|
async function queryAssistant(options) {
|
|
5483
|
-
const { workspaceId, question, docIds, previousResponseId, model, signal, ...auth } = options;
|
|
5495
|
+
const { workspaceId, question, docIds, previousResponseId, model, mentions, signal, ...auth } = options;
|
|
5484
5496
|
const body = {
|
|
5485
5497
|
input: question,
|
|
5486
5498
|
workspace_ext_id: workspaceId,
|
|
@@ -5492,7 +5504,8 @@ async function queryAssistant(options) {
|
|
|
5492
5504
|
retrieval_full_context: buildRetrievalFullContextTool([])
|
|
5493
5505
|
},
|
|
5494
5506
|
...previousResponseId ? { previous_response_id: previousResponseId } : {},
|
|
5495
|
-
...model ? { model } : {}
|
|
5507
|
+
...model ? { model } : {},
|
|
5508
|
+
...mentions && mentions.length > 0 ? { mentions } : {}
|
|
5496
5509
|
};
|
|
5497
5510
|
return authenticatedFetch({
|
|
5498
5511
|
...auth,
|
|
@@ -6194,54 +6207,121 @@ async function getUserUsageToday(arbi) {
|
|
|
6194
6207
|
return requireData(await arbi.fetch.GET("/v1/user/me/usage/today"), "Failed to fetch today usage");
|
|
6195
6208
|
}
|
|
6196
6209
|
|
|
6197
|
-
// src/operations/
|
|
6198
|
-
var
|
|
6199
|
-
__export(
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6210
|
+
// src/operations/work.ts
|
|
6211
|
+
var work_exports = {};
|
|
6212
|
+
__export(work_exports, {
|
|
6213
|
+
createWork: () => createWork,
|
|
6214
|
+
getActivity: () => getActivity,
|
|
6215
|
+
getPendingAuth: () => getPendingAuth,
|
|
6216
|
+
planWork: () => planWork,
|
|
6217
|
+
requestApproval: () => requestApproval,
|
|
6218
|
+
reviewConversation: () => reviewConversation,
|
|
6219
|
+
runConversation: () => runConversation,
|
|
6220
|
+
updateConversation: () => updateConversation
|
|
6207
6221
|
});
|
|
6208
|
-
|
|
6209
|
-
|
|
6222
|
+
var byId = (conversationId) => ({
|
|
6223
|
+
params: { path: { conversation_ext_id: conversationId } }
|
|
6224
|
+
});
|
|
6225
|
+
async function updateConversation(arbi, conversationId, body) {
|
|
6226
|
+
return requireData(
|
|
6227
|
+
await arbi.fetch.PATCH("/v1/conversation/{conversation_ext_id}", {
|
|
6228
|
+
...byId(conversationId),
|
|
6229
|
+
body
|
|
6230
|
+
}),
|
|
6231
|
+
"Failed to update conversation"
|
|
6232
|
+
);
|
|
6210
6233
|
}
|
|
6211
|
-
async function
|
|
6212
|
-
return requireData(
|
|
6234
|
+
async function createWork(arbi, body) {
|
|
6235
|
+
return requireData(
|
|
6236
|
+
await arbi.fetch.POST("/v1/conversation/work", { body }),
|
|
6237
|
+
"Failed to create task"
|
|
6238
|
+
);
|
|
6213
6239
|
}
|
|
6214
|
-
async function
|
|
6240
|
+
async function runConversation(arbi, conversationId) {
|
|
6215
6241
|
return requireData(
|
|
6216
|
-
await arbi.fetch.
|
|
6217
|
-
"Failed to
|
|
6242
|
+
await arbi.fetch.POST("/v1/conversation/{conversation_ext_id}/run", byId(conversationId)),
|
|
6243
|
+
"Failed to run task"
|
|
6218
6244
|
);
|
|
6219
6245
|
}
|
|
6220
|
-
async function
|
|
6246
|
+
async function reviewConversation(arbi, conversationId, body) {
|
|
6221
6247
|
return requireData(
|
|
6222
|
-
await arbi.fetch.
|
|
6223
|
-
|
|
6248
|
+
await arbi.fetch.POST("/v1/conversation/{conversation_ext_id}/review", {
|
|
6249
|
+
...byId(conversationId),
|
|
6224
6250
|
body
|
|
6225
6251
|
}),
|
|
6226
|
-
"Failed to
|
|
6252
|
+
"Failed to review task"
|
|
6227
6253
|
);
|
|
6228
6254
|
}
|
|
6229
|
-
async function
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6255
|
+
async function requestApproval(arbi, conversationId, body) {
|
|
6256
|
+
return requireData(
|
|
6257
|
+
await arbi.fetch.POST("/v1/conversation/{conversation_ext_id}/request-approval", {
|
|
6258
|
+
...byId(conversationId),
|
|
6259
|
+
body
|
|
6260
|
+
}),
|
|
6261
|
+
"Failed to request approval"
|
|
6262
|
+
);
|
|
6234
6263
|
}
|
|
6235
|
-
async function
|
|
6264
|
+
async function getPendingAuth(arbi, conversationId) {
|
|
6236
6265
|
return requireData(
|
|
6237
|
-
await arbi.fetch.
|
|
6238
|
-
|
|
6266
|
+
await arbi.fetch.GET(
|
|
6267
|
+
"/v1/conversation/{conversation_ext_id}/pending-auth",
|
|
6268
|
+
byId(conversationId)
|
|
6269
|
+
),
|
|
6270
|
+
"Failed to read the pending access request"
|
|
6239
6271
|
);
|
|
6240
6272
|
}
|
|
6241
|
-
async function
|
|
6273
|
+
async function getActivity(arbi, conversationId) {
|
|
6242
6274
|
return requireData(
|
|
6243
|
-
await arbi.fetch.GET("/v1/
|
|
6244
|
-
"Failed to
|
|
6275
|
+
await arbi.fetch.GET("/v1/conversation/{conversation_ext_id}/activity", byId(conversationId)),
|
|
6276
|
+
"Failed to read the task activity"
|
|
6277
|
+
);
|
|
6278
|
+
}
|
|
6279
|
+
async function planWork(arbi, body) {
|
|
6280
|
+
return requireData(
|
|
6281
|
+
await arbi.fetch.POST("/v1/conversation/work/plan", { body }),
|
|
6282
|
+
"Failed to draft a plan"
|
|
6283
|
+
);
|
|
6284
|
+
}
|
|
6285
|
+
|
|
6286
|
+
// src/operations/workflows.ts
|
|
6287
|
+
var workflows_exports = {};
|
|
6288
|
+
__export(workflows_exports, {
|
|
6289
|
+
createWorkflow: () => createWorkflow,
|
|
6290
|
+
deleteWorkflow: () => deleteWorkflow,
|
|
6291
|
+
getWorkflow: () => getWorkflow,
|
|
6292
|
+
listWorkflows: () => listWorkflows,
|
|
6293
|
+
runWorkflow: () => runWorkflow,
|
|
6294
|
+
updateWorkflow: () => updateWorkflow
|
|
6295
|
+
});
|
|
6296
|
+
var byId2 = (workflowId) => ({ params: { path: { workflow_id: workflowId } } });
|
|
6297
|
+
async function listWorkflows(arbi) {
|
|
6298
|
+
return requireData(await arbi.fetch.GET("/v1/workflow"), "Failed to list workflows");
|
|
6299
|
+
}
|
|
6300
|
+
async function createWorkflow(arbi, body) {
|
|
6301
|
+
return requireData(await arbi.fetch.POST("/v1/workflow", { body }), "Failed to create workflow");
|
|
6302
|
+
}
|
|
6303
|
+
async function getWorkflow(arbi, workflowId) {
|
|
6304
|
+
return requireData(
|
|
6305
|
+
await arbi.fetch.GET("/v1/workflow/{workflow_id}", byId2(workflowId)),
|
|
6306
|
+
"Failed to get workflow"
|
|
6307
|
+
);
|
|
6308
|
+
}
|
|
6309
|
+
async function updateWorkflow(arbi, workflowId, body) {
|
|
6310
|
+
return requireData(
|
|
6311
|
+
await arbi.fetch.PATCH("/v1/workflow/{workflow_id}", { ...byId2(workflowId), body }),
|
|
6312
|
+
"Failed to update workflow"
|
|
6313
|
+
);
|
|
6314
|
+
}
|
|
6315
|
+
async function deleteWorkflow(arbi, workflowId) {
|
|
6316
|
+
requireOk(
|
|
6317
|
+
await arbi.fetch.DELETE("/v1/workflow/{workflow_id}", byId2(workflowId)),
|
|
6318
|
+
"Failed to delete workflow"
|
|
6319
|
+
);
|
|
6320
|
+
}
|
|
6321
|
+
async function runWorkflow(arbi, workflowId) {
|
|
6322
|
+
return requireData(
|
|
6323
|
+
await arbi.fetch.POST("/v1/workflow/{workflow_id}/run", byId2(workflowId)),
|
|
6324
|
+
"Failed to run workflow"
|
|
6245
6325
|
);
|
|
6246
6326
|
}
|
|
6247
6327
|
|
|
@@ -6753,10 +6833,52 @@ var Arbi = class {
|
|
|
6753
6833
|
list: () => listConversations(this.requireClient()),
|
|
6754
6834
|
getThreads: (conversationId) => getConversationThreads(this.requireClient(), conversationId),
|
|
6755
6835
|
delete: (conversationId) => deleteConversation(this.requireClient(), conversationId),
|
|
6756
|
-
|
|
6757
|
-
|
|
6836
|
+
/**
|
|
6837
|
+
* Patch a conversation: `title`, `shared` (owner only), and the work fields (`description`,
|
|
6838
|
+
* `due_at`, `signoff_user_ext_id`, `parent_conversation_ext_id`, `status`, `plan`). The one call
|
|
6839
|
+
* behind rename, share and unshare.
|
|
6840
|
+
*/
|
|
6841
|
+
update: (conversationId, body) => updateConversation(this.requireClient(), conversationId, body),
|
|
6842
|
+
/** Create a work item: a plain to-do, or (with a prompt / skill) agent work that starts now. */
|
|
6843
|
+
createWork: (body) => createWork(this.requireClient(), body),
|
|
6844
|
+
/** Run a work item now, or retry it. */
|
|
6845
|
+
run: (conversationId) => runConversation(this.requireClient(), conversationId),
|
|
6846
|
+
/** The sign-off person approves, or sends feedback back to the agent in the same thread. */
|
|
6847
|
+
review: (conversationId, body) => reviewConversation(this.requireClient(), conversationId, body),
|
|
6848
|
+
/** Hand sign-off to another workspace member. */
|
|
6849
|
+
requestApproval: (conversationId, body) => requestApproval(this.requireClient(), conversationId, body),
|
|
6850
|
+
/** The session key an unattended run waits for the owner to allow; 404 when nothing waits. */
|
|
6851
|
+
pendingAuth: (conversationId) => getPendingAuth(this.requireClient(), conversationId),
|
|
6852
|
+
/** The task's history, oldest first. */
|
|
6853
|
+
activity: (conversationId) => getActivity(this.requireClient(), conversationId),
|
|
6854
|
+
/** Draft a reviewable plan from an objective. */
|
|
6855
|
+
plan: (body) => planWork(this.requireClient(), body),
|
|
6856
|
+
/**
|
|
6857
|
+
* Run a work item and, when the run is parked waiting for workspace access, grant the agent's
|
|
6858
|
+
* run session a temporary key and run it again. Work that needs no approval returns from the
|
|
6859
|
+
* first call already running.
|
|
6860
|
+
*/
|
|
6861
|
+
runWithAuth: async (conversationId) => {
|
|
6862
|
+
const client = this.requireClient();
|
|
6863
|
+
const first = await runConversation(client, conversationId);
|
|
6864
|
+
if (!first.pending_auth_request_id) return first;
|
|
6865
|
+
const pending = await getPendingAuth(client, conversationId);
|
|
6866
|
+
await this.workspaces.grantTemporaryAccess({
|
|
6867
|
+
workspaceId: pending.workspace_ext_id ?? this.getWorkspaceId(),
|
|
6868
|
+
emails: [pending.agent_email],
|
|
6869
|
+
sessionPubkeyB64: pending.session_pubkey
|
|
6870
|
+
});
|
|
6871
|
+
return runConversation(client, conversationId);
|
|
6872
|
+
},
|
|
6758
6873
|
getMessage: (messageId) => getMessage(this.requireClient(), messageId),
|
|
6759
|
-
deleteMessage: (messageId) => deleteMessage(this.requireClient(), messageId)
|
|
6874
|
+
deleteMessage: (messageId) => deleteMessage(this.requireClient(), messageId),
|
|
6875
|
+
/** Post a human comment (no assistant run) — see `postConversationMessage`. */
|
|
6876
|
+
postMessage: (body) => postConversationMessage(this.requireClient(), body),
|
|
6877
|
+
setAssistantMode: (conversationId, assistantMode) => updateConversationAssistantMode(
|
|
6878
|
+
this.requireClient(),
|
|
6879
|
+
conversationId,
|
|
6880
|
+
assistantMode
|
|
6881
|
+
)
|
|
6760
6882
|
};
|
|
6761
6883
|
// ── Assistant ─────────────────────────────────────────────────────────
|
|
6762
6884
|
assistant = {
|
|
@@ -6976,33 +7098,14 @@ var Arbi = class {
|
|
|
6976
7098
|
return session;
|
|
6977
7099
|
}
|
|
6978
7100
|
};
|
|
6979
|
-
// ──
|
|
6980
|
-
|
|
6981
|
-
list: () =>
|
|
6982
|
-
create: (body) =>
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
run: (
|
|
6987
|
-
listRuns: (taskId) => listTaskRuns(this.requireClient(), taskId),
|
|
6988
|
-
/**
|
|
6989
|
-
* Run a task and, when the run is parked waiting for workspace access (a temporary
|
|
6990
|
-
* authorization tier), grant the agent's run session a temporary key and run it again.
|
|
6991
|
-
* A task that needs no approval returns from the first call already running.
|
|
6992
|
-
*/
|
|
6993
|
-
runWithAuth: async (taskId) => {
|
|
6994
|
-
const client = this.requireClient();
|
|
6995
|
-
const first = await runTask(client, taskId);
|
|
6996
|
-
if (!first.pending_auth_request_id || !first.pending_auth_session_pubkey || !first.pending_auth_agent_email || !first.workspace_ext_id) {
|
|
6997
|
-
return first;
|
|
6998
|
-
}
|
|
6999
|
-
await this.workspaces.grantTemporaryAccess({
|
|
7000
|
-
workspaceId: first.workspace_ext_id,
|
|
7001
|
-
emails: [first.pending_auth_agent_email],
|
|
7002
|
-
sessionPubkeyB64: first.pending_auth_session_pubkey
|
|
7003
|
-
});
|
|
7004
|
-
return runTask(client, taskId);
|
|
7005
|
-
}
|
|
7101
|
+
// ── Workflows ─────────────────────────────────────────────────────────
|
|
7102
|
+
workflows = {
|
|
7103
|
+
list: () => listWorkflows(this.requireClient()),
|
|
7104
|
+
create: (body) => createWorkflow(this.requireClient(), body),
|
|
7105
|
+
update: (workflowId, body) => updateWorkflow(this.requireClient(), workflowId, body),
|
|
7106
|
+
delete: (workflowId) => deleteWorkflow(this.requireClient(), workflowId),
|
|
7107
|
+
/** Fire a workflow now, as a test run. Resolves with the conversation it created and whether it started. */
|
|
7108
|
+
run: (workflowId) => runWorkflow(this.requireClient(), workflowId)
|
|
7006
7109
|
};
|
|
7007
7110
|
// ── Workspace facts ─────────────────────────────────────────────────
|
|
7008
7111
|
facts = {
|
|
@@ -8235,7 +8338,8 @@ exports.streamSSE = streamSSE;
|
|
|
8235
8338
|
exports.stripCitationMarkdown = stripCitationMarkdown;
|
|
8236
8339
|
exports.summarizeCitations = summarizeCitations;
|
|
8237
8340
|
exports.tags = tags_exports;
|
|
8238
|
-
exports.
|
|
8341
|
+
exports.work = work_exports;
|
|
8342
|
+
exports.workflows = workflows_exports;
|
|
8239
8343
|
exports.workspaces = workspaces_exports;
|
|
8240
8344
|
//# sourceMappingURL=index.cjs.map
|
|
8241
8345
|
//# sourceMappingURL=index.cjs.map
|