@arbidocs/sdk 0.4.3 → 0.4.4
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-4VHbRx1J.d.cts → browser-Bdzn5DIN.d.cts} +192 -3
- package/dist/{browser-4VHbRx1J.d.ts → browser-Bdzn5DIN.d.ts} +192 -3
- package/dist/browser.cjs +138 -4
- 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 +138 -4
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +130 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +130 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -5225,6 +5225,7 @@ __export(workspaces_exports, {
|
|
|
5225
5225
|
copyDocuments: () => copyDocuments,
|
|
5226
5226
|
createWorkspace: () => createWorkspace,
|
|
5227
5227
|
deleteWorkspaces: () => deleteWorkspaces,
|
|
5228
|
+
grantTemporaryWorkspaceAccess: () => grantTemporaryWorkspaceAccess,
|
|
5228
5229
|
listWorkspaceUsers: () => listWorkspaceUsers,
|
|
5229
5230
|
listWorkspaces: () => listWorkspaces,
|
|
5230
5231
|
removeWorkspaceUsers: () => removeWorkspaceUsers,
|
|
@@ -5265,14 +5266,33 @@ async function updateWorkspace(arbi, body) {
|
|
|
5265
5266
|
async function listWorkspaceUsers(arbi) {
|
|
5266
5267
|
return requireData(await arbi.fetch.GET("/v1/workspace/users"), "Failed to fetch workspace users");
|
|
5267
5268
|
}
|
|
5268
|
-
async function addWorkspaceUsers(arbi, emails, role = "collaborator") {
|
|
5269
|
+
async function addWorkspaceUsers(arbi, emails, role = "collaborator", target) {
|
|
5269
5270
|
return requireData(
|
|
5270
5271
|
await arbi.fetch.POST("/v1/workspace/users", {
|
|
5271
|
-
body:
|
|
5272
|
+
body: target ? {
|
|
5273
|
+
emails,
|
|
5274
|
+
role,
|
|
5275
|
+
workspace_ext_id: target.workspaceExtId,
|
|
5276
|
+
workspace_key: target.workspaceKey
|
|
5277
|
+
} : { emails, role }
|
|
5272
5278
|
}),
|
|
5273
5279
|
"Failed to add users"
|
|
5274
5280
|
);
|
|
5275
5281
|
}
|
|
5282
|
+
async function grantTemporaryWorkspaceAccess(arbi, params) {
|
|
5283
|
+
return requireData(
|
|
5284
|
+
await arbi.fetch.POST("/v1/workspace/users", {
|
|
5285
|
+
body: {
|
|
5286
|
+
emails: params.emails,
|
|
5287
|
+
role: params.role ?? "collaborator",
|
|
5288
|
+
workspace_ext_id: params.workspaceExtId,
|
|
5289
|
+
workspace_key: params.workspaceKey,
|
|
5290
|
+
session_pubkey_b64: params.sessionPubkeyB64
|
|
5291
|
+
}
|
|
5292
|
+
}),
|
|
5293
|
+
"Failed to grant temporary access"
|
|
5294
|
+
);
|
|
5295
|
+
}
|
|
5276
5296
|
async function removeWorkspaceUsers(arbi, userIds) {
|
|
5277
5297
|
requireOk(
|
|
5278
5298
|
await arbi.fetch.DELETE("/v1/workspace/users", {
|
|
@@ -5668,9 +5688,11 @@ __export(dm_exports, {
|
|
|
5668
5688
|
// src/operations/agents.ts
|
|
5669
5689
|
var agents_exports = {};
|
|
5670
5690
|
__export(agents_exports, {
|
|
5691
|
+
authorizeAgent: () => authorizeAgent,
|
|
5671
5692
|
createAgent: () => createAgent,
|
|
5672
5693
|
deleteAgents: () => deleteAgents,
|
|
5673
5694
|
getAgentConfig: () => getAgentConfig,
|
|
5695
|
+
getAuthorizeLimits: () => getAuthorizeLimits,
|
|
5674
5696
|
listAgentWorkspaces: () => listAgentWorkspaces,
|
|
5675
5697
|
listAgents: () => listAgents
|
|
5676
5698
|
});
|
|
@@ -5705,6 +5727,21 @@ async function deleteAgents(arbi, agentExtIds) {
|
|
|
5705
5727
|
"Failed to delete agents"
|
|
5706
5728
|
);
|
|
5707
5729
|
}
|
|
5730
|
+
async function authorizeAgent(arbi, agentExtId, workspaceExtId, ttlSeconds) {
|
|
5731
|
+
return requireData(
|
|
5732
|
+
await arbi.fetch.POST("/v1/agents/{agent_ext_id}/authorize", {
|
|
5733
|
+
params: { path: { agent_ext_id: agentExtId } },
|
|
5734
|
+
body: { workspace_ext_id: workspaceExtId, ttl_seconds: ttlSeconds ?? null }
|
|
5735
|
+
}),
|
|
5736
|
+
"Failed to authorize agent"
|
|
5737
|
+
);
|
|
5738
|
+
}
|
|
5739
|
+
async function getAuthorizeLimits(arbi) {
|
|
5740
|
+
return requireData(
|
|
5741
|
+
await arbi.fetch.GET("/v1/agents/authorize-limits"),
|
|
5742
|
+
"Failed to fetch authorize limits"
|
|
5743
|
+
);
|
|
5744
|
+
}
|
|
5708
5745
|
|
|
5709
5746
|
// src/operations/dm.ts
|
|
5710
5747
|
function createDmCryptoContext(arbi, signingPrivateKeyBytes, userExtId) {
|
|
@@ -6091,6 +6128,7 @@ __export(tasks_exports, {
|
|
|
6091
6128
|
createTask: () => createTask,
|
|
6092
6129
|
deleteTask: () => deleteTask,
|
|
6093
6130
|
getTask: () => getTask,
|
|
6131
|
+
listTaskRuns: () => listTaskRuns,
|
|
6094
6132
|
listTasks: () => listTasks,
|
|
6095
6133
|
runTask: () => runTask,
|
|
6096
6134
|
updateTask: () => updateTask
|
|
@@ -6128,6 +6166,12 @@ async function runTask(arbi, taskId) {
|
|
|
6128
6166
|
"Failed to run task"
|
|
6129
6167
|
);
|
|
6130
6168
|
}
|
|
6169
|
+
async function listTaskRuns(arbi, taskId) {
|
|
6170
|
+
return requireData(
|
|
6171
|
+
await arbi.fetch.GET("/v1/tasks/{task_id}/runs", { params: { path: { task_id: taskId } } }),
|
|
6172
|
+
"Failed to list task runs"
|
|
6173
|
+
);
|
|
6174
|
+
}
|
|
6131
6175
|
|
|
6132
6176
|
// src/operations/facts.ts
|
|
6133
6177
|
var facts_exports = {};
|
|
@@ -6269,6 +6313,22 @@ var Arbi = class {
|
|
|
6269
6313
|
const signingPrivateKey = client.crypto.base64ToBytes(signingPrivateKeyBase64);
|
|
6270
6314
|
this.loginResult = await client.auth.loginWithKey({ email, signingPrivateKey });
|
|
6271
6315
|
}
|
|
6316
|
+
/** A workspace's key, sealed to the caller's own session (what `/open` and `POST /workspace/users` take). */
|
|
6317
|
+
async sealWorkspaceKey(workspaceId) {
|
|
6318
|
+
const client = this.requireClient();
|
|
6319
|
+
const lr2 = this.requireLogin();
|
|
6320
|
+
const all = await listWorkspaces(client);
|
|
6321
|
+
const ws = all.find((w2) => w2.external_id === workspaceId);
|
|
6322
|
+
if (!ws || !ws.wrapped_key) {
|
|
6323
|
+
throw new ArbiError(`Workspace ${workspaceId} not found or has no encryption key`);
|
|
6324
|
+
}
|
|
6325
|
+
return generateEncryptedWorkspaceKey(
|
|
6326
|
+
client,
|
|
6327
|
+
ws.wrapped_key,
|
|
6328
|
+
lr2.serverSessionKey,
|
|
6329
|
+
client.crypto.bytesToBase64(lr2.signingPrivateKey)
|
|
6330
|
+
);
|
|
6331
|
+
}
|
|
6272
6332
|
/**
|
|
6273
6333
|
* Select a workspace by ID. Fetches the workspace list, finds the matching
|
|
6274
6334
|
* workspace, decrypts the wrapped key, and sets up auth headers.
|
|
@@ -6451,6 +6511,30 @@ var Arbi = class {
|
|
|
6451
6511
|
update: (body) => updateWorkspace(this.requireClient(), body),
|
|
6452
6512
|
listUsers: () => listWorkspaceUsers(this.requireClient()),
|
|
6453
6513
|
addUsers: (emails, role) => addWorkspaceUsers(this.requireClient(), emails, role),
|
|
6514
|
+
/**
|
|
6515
|
+
* Grant users a temporary key scoped to ONE session (identified by its public key), for
|
|
6516
|
+
* example an agent's run session minted by `agents.authorize()`. Nothing standing is created:
|
|
6517
|
+
* the grant expires with that session. Works for any workspace the caller holds a key for;
|
|
6518
|
+
* it does not need to be the open one.
|
|
6519
|
+
*/
|
|
6520
|
+
grantTemporaryAccess: async (params) => {
|
|
6521
|
+
const client = this.requireClient();
|
|
6522
|
+
return grantTemporaryWorkspaceAccess(client, {
|
|
6523
|
+
emails: params.emails,
|
|
6524
|
+
workspaceExtId: params.workspaceId,
|
|
6525
|
+
workspaceKey: await this.sealWorkspaceKey(params.workspaceId),
|
|
6526
|
+
sessionPubkeyB64: params.sessionPubkeyB64,
|
|
6527
|
+
role: params.role
|
|
6528
|
+
});
|
|
6529
|
+
},
|
|
6530
|
+
/**
|
|
6531
|
+
* Add users (standing, permanent membership) to ANY workspace the caller holds a key for,
|
|
6532
|
+
* without opening it. `addUsers` does the same for the currently open workspace.
|
|
6533
|
+
*/
|
|
6534
|
+
grantAccess: async (params) => addWorkspaceUsers(this.requireClient(), params.emails, params.role, {
|
|
6535
|
+
workspaceExtId: params.workspaceId,
|
|
6536
|
+
workspaceKey: await this.sealWorkspaceKey(params.workspaceId)
|
|
6537
|
+
}),
|
|
6454
6538
|
removeUsers: (userIds) => removeWorkspaceUsers(this.requireClient(), userIds),
|
|
6455
6539
|
setUserRole: (userIds, role) => setUserRole(this.requireClient(), userIds, role),
|
|
6456
6540
|
/**
|
|
@@ -6566,6 +6650,8 @@ var Arbi = class {
|
|
|
6566
6650
|
* Respond to an agent's question during a human-in-the-loop workflow.
|
|
6567
6651
|
*/
|
|
6568
6652
|
respond: (assistantMessageExtId, answer) => respondToAgent(this.requireClient(), assistantMessageExtId, answer),
|
|
6653
|
+
/** The skills the caller can run (own + shared marketplace), metadata only. */
|
|
6654
|
+
listSkills: (options) => listSkills(this.requireClient(), options),
|
|
6569
6655
|
/**
|
|
6570
6656
|
* Search documents without LLM generation (retrieval only).
|
|
6571
6657
|
*/
|
|
@@ -6722,7 +6808,28 @@ var Arbi = class {
|
|
|
6722
6808
|
create: (name) => createAgent(this.requireClient(), name),
|
|
6723
6809
|
getConfig: (agentExtId) => getAgentConfig(this.requireClient(), agentExtId),
|
|
6724
6810
|
listWorkspaces: (agentExtId) => listAgentWorkspaces(this.requireClient(), agentExtId),
|
|
6725
|
-
delete: (agentExtIds) => deleteAgents(this.requireClient(), agentExtIds)
|
|
6811
|
+
delete: (agentExtIds) => deleteAgents(this.requireClient(), agentExtIds),
|
|
6812
|
+
/** Mint a TTL'd run session for an agent; see `grantTemporaryAccess` to also deposit a key. */
|
|
6813
|
+
authorize: (agentExtId, workspaceId, ttlSeconds) => authorizeAgent(this.requireClient(), agentExtId, workspaceId, ttlSeconds),
|
|
6814
|
+
authorizeLimits: () => getAuthorizeLimits(this.requireClient()),
|
|
6815
|
+
/**
|
|
6816
|
+
* Give an agent temporary, session-scoped access to a workspace: mint its run session, then
|
|
6817
|
+
* deposit the workspace key on it. Returns the session details (`ttl` in seconds).
|
|
6818
|
+
*/
|
|
6819
|
+
grantTemporaryAccess: async (agentExtId, workspaceId, ttlSeconds) => {
|
|
6820
|
+
const session = await authorizeAgent(
|
|
6821
|
+
this.requireClient(),
|
|
6822
|
+
agentExtId,
|
|
6823
|
+
workspaceId,
|
|
6824
|
+
ttlSeconds
|
|
6825
|
+
);
|
|
6826
|
+
await this.workspaces.grantTemporaryAccess({
|
|
6827
|
+
workspaceId,
|
|
6828
|
+
emails: [session.agent_email],
|
|
6829
|
+
sessionPubkeyB64: session.session_pubkey_b64
|
|
6830
|
+
});
|
|
6831
|
+
return session;
|
|
6832
|
+
}
|
|
6726
6833
|
};
|
|
6727
6834
|
// ── Scheduled tasks ───────────────────────────────────────────────────
|
|
6728
6835
|
tasks = {
|
|
@@ -6731,7 +6838,26 @@ var Arbi = class {
|
|
|
6731
6838
|
get: (taskId) => getTask(this.requireClient(), taskId),
|
|
6732
6839
|
update: (taskId, body) => updateTask(this.requireClient(), taskId, body),
|
|
6733
6840
|
delete: (taskId) => deleteTask(this.requireClient(), taskId),
|
|
6734
|
-
run: (taskId) => runTask(this.requireClient(), taskId)
|
|
6841
|
+
run: (taskId) => runTask(this.requireClient(), taskId),
|
|
6842
|
+
listRuns: (taskId) => listTaskRuns(this.requireClient(), taskId),
|
|
6843
|
+
/**
|
|
6844
|
+
* Run a task and, when the run is parked waiting for workspace access (a temporary
|
|
6845
|
+
* authorization tier), grant the agent's run session a temporary key and run it again.
|
|
6846
|
+
* A task that needs no approval returns from the first call already running.
|
|
6847
|
+
*/
|
|
6848
|
+
runWithAuth: async (taskId) => {
|
|
6849
|
+
const client = this.requireClient();
|
|
6850
|
+
const first = await runTask(client, taskId);
|
|
6851
|
+
if (!first.pending_auth_request_id || !first.pending_auth_session_pubkey || !first.pending_auth_agent_email || !first.workspace_ext_id) {
|
|
6852
|
+
return first;
|
|
6853
|
+
}
|
|
6854
|
+
await this.workspaces.grantTemporaryAccess({
|
|
6855
|
+
workspaceId: first.workspace_ext_id,
|
|
6856
|
+
emails: [first.pending_auth_agent_email],
|
|
6857
|
+
sessionPubkeyB64: first.pending_auth_session_pubkey
|
|
6858
|
+
});
|
|
6859
|
+
return runTask(client, taskId);
|
|
6860
|
+
}
|
|
6735
6861
|
};
|
|
6736
6862
|
// ── Workspace facts ─────────────────────────────────────────────────
|
|
6737
6863
|
facts = {
|