@arbidocs/sdk 0.4.3 → 0.4.5

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/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { q as ConfigStore, n as CliConfig, o as CliCredentials, C as ChatSession, ac as SkippedFile, al as UploadResult, k as AuthHeaders, ah as UploadBatchResult, ak as UploadOptions, ai as UploadDirectOptions, aj as UploadDirectResult, aa as SUPPORTED_EXTENSIONS, w as DmCryptoContext } from './browser-4VHbRx1J.cjs';
2
- export { b as AgentStepEvent, c as Arbi, d as ArbiApiError, e as ArbiError, g as ArbiOptions, h as ArbiSessionExpiredError, i as ArtifactEvent, j as AuthContext, l as AuthenticatedClient, m as CitationSummary, p as CommandDescriptor, r as ConnectOptions, D as DOC_TERMINAL_STATUSES, x as DocNameMap, y as DocumentListFields, z as DocumentListOrder, B as DocumentWaiter, E as DocumentWaiterOptions, I as FormattedWsMessage, L as ListAllOptions, K as ListPaginatedOptions, M as MessageLevel, N as MessageMetadataPayload, O as MessageQueuedEvent, P as OutputTokensDetails, Q as ParsedSlashCommand, S as ProjectInvoicesResponse, T as ProjectUsageResponse, U as QueryOptions, V as ReconnectOptions, W as ReconnectableWsConnection, X as ResolvedCitation, Y as ResolvedRecipient, Z as ResponseCompletedEvent, _ as ResponseContentPartAddedEvent, $ as ResponseCreatedEvent, a0 as ResponseFailedEvent, a1 as ResponseOutputItemAddedEvent, a2 as ResponseOutputItemDoneEvent, a3 as ResponseOutputTextDeltaEvent, a4 as ResponseOutputTextDoneEvent, a5 as ResponseUsage, a6 as SSEEvent, a7 as SSEStreamCallbacks, a8 as SSEStreamResult, a9 as SSEStreamStartData, ab as SkillSummary, ae as TokenBudgetContext, am as UserDailyUsageResponse, an as UserInfo, ao as UserInputRequestEvent, ap as UserMessageEvent, aq as WebSocketAuthError, ar as WorkspaceContext, as as WsConnection, at as agentconfig, au as assistant, av as authenticatedFetch, aw as buildDocNameMap, ax as buildRetrievalChunkTool, ay as buildRetrievalFullContextTool, az as buildRetrievalTocTool, aA as connectWebSocket, aB as connectWithReconnect, aC as consumeSSEStream, aD as contacts, aE as conversations, aF as countCitations, aG as createAuthenticatedClient, aH as createDocumentWaiter, aI as dm, aJ as doctags, aK as documents, aL as facts, aM as files, aN as filterSkills, aO as formatAgentStepLabel, aP as formatFileSize, aQ as formatItemLabel, aR as formatStreamSummary, aS as formatUserName, aT as formatWorkspaceChoices, aU as formatWsMessage, aV as generateEncryptedWorkspaceKey, aW as generateNewWorkspaceKey, aX as getErrorCode, aY as getErrorMessage, aZ as getRawWorkspaceKey, a_ as health, a$ as parseSSEEvents, b0 as parseSlashCommand, b1 as parseSlashTokenInProgress, b2 as performPasswordLogin, b3 as performSigningKeyLogin, b4 as performSsoDeviceFlowLogin, b5 as projects, b6 as requireData, b7 as requireOk, b8 as resolveAuth, b9 as resolveCitations, ba as resolveWorkspace, bb as responses, bc as selectWorkspace, bd as selectWorkspaceById, be as settings, bf as streamSSE, bg as stripCitationMarkdown, bh as summarizeCitations, bi as tags, bj as tasks, bk as workspaces } from './browser-4VHbRx1J.cjs';
1
+ import { q as ConfigStore, n as CliConfig, o as CliCredentials, C as ChatSession, ac as SkippedFile, al as UploadResult, k as AuthHeaders, ah as UploadBatchResult, ak as UploadOptions, ai as UploadDirectOptions, aj as UploadDirectResult, aa as SUPPORTED_EXTENSIONS, w as DmCryptoContext } from './browser-5spRium9.cjs';
2
+ export { b as AgentStepEvent, c as Arbi, d as ArbiApiError, e as ArbiError, g as ArbiOptions, h as ArbiSessionExpiredError, i as ArtifactEvent, j as AuthContext, l as AuthenticatedClient, m as CitationSummary, p as CommandDescriptor, r as ConnectOptions, D as DOC_TERMINAL_STATUSES, x as DocNameMap, y as DocumentListFields, z as DocumentListOrder, B as DocumentWaiter, E as DocumentWaiterOptions, I as FormattedWsMessage, L as ListAllOptions, K as ListPaginatedOptions, M as MessageLevel, N as MessageMetadataPayload, O as MessageQueuedEvent, P as OutputTokensDetails, Q as ParsedSlashCommand, S as ProjectInvoicesResponse, T as ProjectUsageResponse, U as QueryOptions, V as ReconnectOptions, W as ReconnectableWsConnection, X as ResolvedCitation, Y as ResolvedRecipient, Z as ResponseCompletedEvent, _ as ResponseContentPartAddedEvent, $ as ResponseCreatedEvent, a0 as ResponseFailedEvent, a1 as ResponseOutputItemAddedEvent, a2 as ResponseOutputItemDoneEvent, a3 as ResponseOutputTextDeltaEvent, a4 as ResponseOutputTextDoneEvent, a5 as ResponseUsage, a6 as SSEEvent, a7 as SSEStreamCallbacks, a8 as SSEStreamResult, a9 as SSEStreamStartData, ab as SkillSummary, ae as TokenBudgetContext, am as UserDailyUsageResponse, an as UserInfo, ao as UserInputRequestEvent, ap as UserMessageEvent, aq as WebSocketAuthError, ar as WorkspaceContext, as as WsConnection, at as agentconfig, au as assistant, av as authenticatedFetch, aw as buildDocNameMap, ax as buildRetrievalChunkTool, ay as buildRetrievalFullContextTool, az as buildRetrievalTocTool, aA as connectWebSocket, aB as connectWithReconnect, aC as consumeSSEStream, aD as contacts, aE as conversations, aF as countCitations, aG as createAuthenticatedClient, aH as createDocumentWaiter, aI as dm, aJ as doctags, aK as documents, aL as facts, aM as files, aN as filterSkills, aO as formatAgentStepLabel, aP as formatFileSize, aQ as formatItemLabel, aR as formatStreamSummary, aS as formatUserName, aT as formatWorkspaceChoices, aU as formatWsMessage, aV as generateEncryptedWorkspaceKey, aW as generateNewWorkspaceKey, aX as getErrorCode, aY as getErrorMessage, aZ as getRawWorkspaceKey, a_ as health, a$ as parseSSEEvents, b0 as parseSlashCommand, b1 as parseSlashTokenInProgress, b2 as performPasswordLogin, b3 as performSigningKeyLogin, b4 as performSsoDeviceFlowLogin, b5 as projects, b6 as requireData, b7 as requireOk, b8 as resolveAuth, b9 as resolveCitations, ba as resolveWorkspace, bb as responses, bc as selectWorkspace, bd as selectWorkspaceById, be as settings, bf as streamSSE, bg as stripCitationMarkdown, bh as summarizeCitations, bi as tags, bj as tasks, bk as workspaces } from './browser-5spRium9.cjs';
3
3
  import { SessionStorageProvider, ArbiClient, components } from '@arbidocs/client';
4
4
 
5
5
  /**
@@ -380,6 +380,8 @@ declare namespace documentsNode {
380
380
  type UserResponse = components['schemas']['UserResponse'];
381
381
  type CreateAgentResponse = components['schemas']['CreateAgentResponse'];
382
382
  type AgentWorkspaceResponse = components['schemas']['AgentWorkspaceResponse'];
383
+ type AuthorizeAgentResponse = components['schemas']['AuthorizeAgentResponse'];
384
+ type AuthorizeLimitsResponse = components['schemas']['AuthorizeLimitsResponse'];
383
385
  declare function listAgents(arbi: ArbiClient): Promise<UserResponse[]>;
384
386
  /**
385
387
  * Create a persistent agent. Only `name` is accepted (alphanumeric, `_`/`-`).
@@ -677,14 +679,27 @@ declare function listAgentWorkspaces(arbi: ArbiClient, agentExtId: string): Prom
677
679
  declare function deleteAgents(arbi: ArbiClient, agentExtIds: string[]): Promise<{
678
680
  [x: string]: unknown;
679
681
  }>;
682
+ /**
683
+ * Mint a fresh, TTL'd run session for the caller's own agent
684
+ * (`POST /v1/agents/{id}/authorize`). The response carries the session's public key; deposit a
685
+ * temporary workspace key on it with `Arbi.workspaces.grantTemporaryAccess()` (or do both in one
686
+ * call with `Arbi.agents.grantTemporaryAccess()`). `ttlSeconds` omitted = the deployment default.
687
+ */
688
+ declare function authorizeAgent(arbi: ArbiClient, agentExtId: string, workspaceExtId: string, ttlSeconds?: number): Promise<AuthorizeAgentResponse>;
689
+ /** The default and maximum lifetime of a temporary agent authorization. */
690
+ declare function getAuthorizeLimits(arbi: ArbiClient): Promise<AuthorizeLimitsResponse>;
680
691
 
692
+ type agents_AuthorizeAgentResponse = AuthorizeAgentResponse;
693
+ type agents_AuthorizeLimitsResponse = AuthorizeLimitsResponse;
694
+ declare const agents_authorizeAgent: typeof authorizeAgent;
681
695
  declare const agents_createAgent: typeof createAgent;
682
696
  declare const agents_deleteAgents: typeof deleteAgents;
683
697
  declare const agents_getAgentConfig: typeof getAgentConfig;
698
+ declare const agents_getAuthorizeLimits: typeof getAuthorizeLimits;
684
699
  declare const agents_listAgentWorkspaces: typeof listAgentWorkspaces;
685
700
  declare const agents_listAgents: typeof listAgents;
686
701
  declare namespace agents {
687
- export { agents_createAgent as createAgent, agents_deleteAgents as deleteAgents, agents_getAgentConfig as getAgentConfig, agents_listAgentWorkspaces as listAgentWorkspaces, agents_listAgents as listAgents };
702
+ export { type agents_AuthorizeAgentResponse as AuthorizeAgentResponse, type agents_AuthorizeLimitsResponse as AuthorizeLimitsResponse, agents_authorizeAgent as authorizeAgent, agents_createAgent as createAgent, agents_deleteAgents as deleteAgents, agents_getAgentConfig as getAgentConfig, agents_getAuthorizeLimits as getAuthorizeLimits, agents_listAgentWorkspaces as listAgentWorkspaces, agents_listAgents as listAgents };
688
703
  }
689
704
 
690
705
  /**
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { q as ConfigStore, n as CliConfig, o as CliCredentials, C as ChatSession, ac as SkippedFile, al as UploadResult, k as AuthHeaders, ah as UploadBatchResult, ak as UploadOptions, ai as UploadDirectOptions, aj as UploadDirectResult, aa as SUPPORTED_EXTENSIONS, w as DmCryptoContext } from './browser-4VHbRx1J.js';
2
- export { b as AgentStepEvent, c as Arbi, d as ArbiApiError, e as ArbiError, g as ArbiOptions, h as ArbiSessionExpiredError, i as ArtifactEvent, j as AuthContext, l as AuthenticatedClient, m as CitationSummary, p as CommandDescriptor, r as ConnectOptions, D as DOC_TERMINAL_STATUSES, x as DocNameMap, y as DocumentListFields, z as DocumentListOrder, B as DocumentWaiter, E as DocumentWaiterOptions, I as FormattedWsMessage, L as ListAllOptions, K as ListPaginatedOptions, M as MessageLevel, N as MessageMetadataPayload, O as MessageQueuedEvent, P as OutputTokensDetails, Q as ParsedSlashCommand, S as ProjectInvoicesResponse, T as ProjectUsageResponse, U as QueryOptions, V as ReconnectOptions, W as ReconnectableWsConnection, X as ResolvedCitation, Y as ResolvedRecipient, Z as ResponseCompletedEvent, _ as ResponseContentPartAddedEvent, $ as ResponseCreatedEvent, a0 as ResponseFailedEvent, a1 as ResponseOutputItemAddedEvent, a2 as ResponseOutputItemDoneEvent, a3 as ResponseOutputTextDeltaEvent, a4 as ResponseOutputTextDoneEvent, a5 as ResponseUsage, a6 as SSEEvent, a7 as SSEStreamCallbacks, a8 as SSEStreamResult, a9 as SSEStreamStartData, ab as SkillSummary, ae as TokenBudgetContext, am as UserDailyUsageResponse, an as UserInfo, ao as UserInputRequestEvent, ap as UserMessageEvent, aq as WebSocketAuthError, ar as WorkspaceContext, as as WsConnection, at as agentconfig, au as assistant, av as authenticatedFetch, aw as buildDocNameMap, ax as buildRetrievalChunkTool, ay as buildRetrievalFullContextTool, az as buildRetrievalTocTool, aA as connectWebSocket, aB as connectWithReconnect, aC as consumeSSEStream, aD as contacts, aE as conversations, aF as countCitations, aG as createAuthenticatedClient, aH as createDocumentWaiter, aI as dm, aJ as doctags, aK as documents, aL as facts, aM as files, aN as filterSkills, aO as formatAgentStepLabel, aP as formatFileSize, aQ as formatItemLabel, aR as formatStreamSummary, aS as formatUserName, aT as formatWorkspaceChoices, aU as formatWsMessage, aV as generateEncryptedWorkspaceKey, aW as generateNewWorkspaceKey, aX as getErrorCode, aY as getErrorMessage, aZ as getRawWorkspaceKey, a_ as health, a$ as parseSSEEvents, b0 as parseSlashCommand, b1 as parseSlashTokenInProgress, b2 as performPasswordLogin, b3 as performSigningKeyLogin, b4 as performSsoDeviceFlowLogin, b5 as projects, b6 as requireData, b7 as requireOk, b8 as resolveAuth, b9 as resolveCitations, ba as resolveWorkspace, bb as responses, bc as selectWorkspace, bd as selectWorkspaceById, be as settings, bf as streamSSE, bg as stripCitationMarkdown, bh as summarizeCitations, bi as tags, bj as tasks, bk as workspaces } from './browser-4VHbRx1J.js';
1
+ import { q as ConfigStore, n as CliConfig, o as CliCredentials, C as ChatSession, ac as SkippedFile, al as UploadResult, k as AuthHeaders, ah as UploadBatchResult, ak as UploadOptions, ai as UploadDirectOptions, aj as UploadDirectResult, aa as SUPPORTED_EXTENSIONS, w as DmCryptoContext } from './browser-5spRium9.js';
2
+ export { b as AgentStepEvent, c as Arbi, d as ArbiApiError, e as ArbiError, g as ArbiOptions, h as ArbiSessionExpiredError, i as ArtifactEvent, j as AuthContext, l as AuthenticatedClient, m as CitationSummary, p as CommandDescriptor, r as ConnectOptions, D as DOC_TERMINAL_STATUSES, x as DocNameMap, y as DocumentListFields, z as DocumentListOrder, B as DocumentWaiter, E as DocumentWaiterOptions, I as FormattedWsMessage, L as ListAllOptions, K as ListPaginatedOptions, M as MessageLevel, N as MessageMetadataPayload, O as MessageQueuedEvent, P as OutputTokensDetails, Q as ParsedSlashCommand, S as ProjectInvoicesResponse, T as ProjectUsageResponse, U as QueryOptions, V as ReconnectOptions, W as ReconnectableWsConnection, X as ResolvedCitation, Y as ResolvedRecipient, Z as ResponseCompletedEvent, _ as ResponseContentPartAddedEvent, $ as ResponseCreatedEvent, a0 as ResponseFailedEvent, a1 as ResponseOutputItemAddedEvent, a2 as ResponseOutputItemDoneEvent, a3 as ResponseOutputTextDeltaEvent, a4 as ResponseOutputTextDoneEvent, a5 as ResponseUsage, a6 as SSEEvent, a7 as SSEStreamCallbacks, a8 as SSEStreamResult, a9 as SSEStreamStartData, ab as SkillSummary, ae as TokenBudgetContext, am as UserDailyUsageResponse, an as UserInfo, ao as UserInputRequestEvent, ap as UserMessageEvent, aq as WebSocketAuthError, ar as WorkspaceContext, as as WsConnection, at as agentconfig, au as assistant, av as authenticatedFetch, aw as buildDocNameMap, ax as buildRetrievalChunkTool, ay as buildRetrievalFullContextTool, az as buildRetrievalTocTool, aA as connectWebSocket, aB as connectWithReconnect, aC as consumeSSEStream, aD as contacts, aE as conversations, aF as countCitations, aG as createAuthenticatedClient, aH as createDocumentWaiter, aI as dm, aJ as doctags, aK as documents, aL as facts, aM as files, aN as filterSkills, aO as formatAgentStepLabel, aP as formatFileSize, aQ as formatItemLabel, aR as formatStreamSummary, aS as formatUserName, aT as formatWorkspaceChoices, aU as formatWsMessage, aV as generateEncryptedWorkspaceKey, aW as generateNewWorkspaceKey, aX as getErrorCode, aY as getErrorMessage, aZ as getRawWorkspaceKey, a_ as health, a$ as parseSSEEvents, b0 as parseSlashCommand, b1 as parseSlashTokenInProgress, b2 as performPasswordLogin, b3 as performSigningKeyLogin, b4 as performSsoDeviceFlowLogin, b5 as projects, b6 as requireData, b7 as requireOk, b8 as resolveAuth, b9 as resolveCitations, ba as resolveWorkspace, bb as responses, bc as selectWorkspace, bd as selectWorkspaceById, be as settings, bf as streamSSE, bg as stripCitationMarkdown, bh as summarizeCitations, bi as tags, bj as tasks, bk as workspaces } from './browser-5spRium9.js';
3
3
  import { SessionStorageProvider, ArbiClient, components } from '@arbidocs/client';
4
4
 
5
5
  /**
@@ -380,6 +380,8 @@ declare namespace documentsNode {
380
380
  type UserResponse = components['schemas']['UserResponse'];
381
381
  type CreateAgentResponse = components['schemas']['CreateAgentResponse'];
382
382
  type AgentWorkspaceResponse = components['schemas']['AgentWorkspaceResponse'];
383
+ type AuthorizeAgentResponse = components['schemas']['AuthorizeAgentResponse'];
384
+ type AuthorizeLimitsResponse = components['schemas']['AuthorizeLimitsResponse'];
383
385
  declare function listAgents(arbi: ArbiClient): Promise<UserResponse[]>;
384
386
  /**
385
387
  * Create a persistent agent. Only `name` is accepted (alphanumeric, `_`/`-`).
@@ -677,14 +679,27 @@ declare function listAgentWorkspaces(arbi: ArbiClient, agentExtId: string): Prom
677
679
  declare function deleteAgents(arbi: ArbiClient, agentExtIds: string[]): Promise<{
678
680
  [x: string]: unknown;
679
681
  }>;
682
+ /**
683
+ * Mint a fresh, TTL'd run session for the caller's own agent
684
+ * (`POST /v1/agents/{id}/authorize`). The response carries the session's public key; deposit a
685
+ * temporary workspace key on it with `Arbi.workspaces.grantTemporaryAccess()` (or do both in one
686
+ * call with `Arbi.agents.grantTemporaryAccess()`). `ttlSeconds` omitted = the deployment default.
687
+ */
688
+ declare function authorizeAgent(arbi: ArbiClient, agentExtId: string, workspaceExtId: string, ttlSeconds?: number): Promise<AuthorizeAgentResponse>;
689
+ /** The default and maximum lifetime of a temporary agent authorization. */
690
+ declare function getAuthorizeLimits(arbi: ArbiClient): Promise<AuthorizeLimitsResponse>;
680
691
 
692
+ type agents_AuthorizeAgentResponse = AuthorizeAgentResponse;
693
+ type agents_AuthorizeLimitsResponse = AuthorizeLimitsResponse;
694
+ declare const agents_authorizeAgent: typeof authorizeAgent;
681
695
  declare const agents_createAgent: typeof createAgent;
682
696
  declare const agents_deleteAgents: typeof deleteAgents;
683
697
  declare const agents_getAgentConfig: typeof getAgentConfig;
698
+ declare const agents_getAuthorizeLimits: typeof getAuthorizeLimits;
684
699
  declare const agents_listAgentWorkspaces: typeof listAgentWorkspaces;
685
700
  declare const agents_listAgents: typeof listAgents;
686
701
  declare namespace agents {
687
- export { agents_createAgent as createAgent, agents_deleteAgents as deleteAgents, agents_getAgentConfig as getAgentConfig, agents_listAgentWorkspaces as listAgentWorkspaces, agents_listAgents as listAgents };
702
+ export { type agents_AuthorizeAgentResponse as AuthorizeAgentResponse, type agents_AuthorizeLimitsResponse as AuthorizeLimitsResponse, agents_authorizeAgent as authorizeAgent, agents_createAgent as createAgent, agents_deleteAgents as deleteAgents, agents_getAgentConfig as getAgentConfig, agents_getAuthorizeLimits as getAuthorizeLimits, agents_listAgentWorkspaces as listAgentWorkspaces, agents_listAgents as listAgents };
688
703
  }
689
704
 
690
705
  /**
package/dist/index.js CHANGED
@@ -5019,6 +5019,7 @@ async function uploadFile(auth, fileData, fileName, options) {
5019
5019
  if (options?.folder) params.set("folder", sanitizeFolderPath(options.folder));
5020
5020
  if (options?.configExtId) params.set("config_ext_id", options.configExtId);
5021
5021
  if (options?.wpType) params.set("wp_type", options.wpType);
5022
+ if (options?.parentExtId) params.set("parent_ext_id", options.parentExtId);
5022
5023
  const qs = params.toString();
5023
5024
  const res = await authenticatedFetch({
5024
5025
  ...auth,
@@ -5035,6 +5036,7 @@ async function uploadFiles(auth, files, options) {
5035
5036
  if (options?.folder) params.set("folder", sanitizeFolderPath(options.folder));
5036
5037
  if (options?.configExtId) params.set("config_ext_id", options.configExtId);
5037
5038
  if (options?.wpType) params.set("wp_type", options.wpType);
5039
+ if (options?.parentExtId) params.set("parent_ext_id", options.parentExtId);
5038
5040
  const qs = params.toString();
5039
5041
  const res = await authenticatedFetch({
5040
5042
  ...auth,
@@ -5216,6 +5218,7 @@ __export(workspaces_exports, {
5216
5218
  copyDocuments: () => copyDocuments,
5217
5219
  createWorkspace: () => createWorkspace,
5218
5220
  deleteWorkspaces: () => deleteWorkspaces,
5221
+ grantTemporaryWorkspaceAccess: () => grantTemporaryWorkspaceAccess,
5219
5222
  listWorkspaceUsers: () => listWorkspaceUsers,
5220
5223
  listWorkspaces: () => listWorkspaces,
5221
5224
  removeWorkspaceUsers: () => removeWorkspaceUsers,
@@ -5256,14 +5259,33 @@ async function updateWorkspace(arbi, body) {
5256
5259
  async function listWorkspaceUsers(arbi) {
5257
5260
  return requireData(await arbi.fetch.GET("/v1/workspace/users"), "Failed to fetch workspace users");
5258
5261
  }
5259
- async function addWorkspaceUsers(arbi, emails, role = "collaborator") {
5262
+ async function addWorkspaceUsers(arbi, emails, role = "collaborator", target) {
5260
5263
  return requireData(
5261
5264
  await arbi.fetch.POST("/v1/workspace/users", {
5262
- body: { emails, role }
5265
+ body: target ? {
5266
+ emails,
5267
+ role,
5268
+ workspace_ext_id: target.workspaceExtId,
5269
+ workspace_key: target.workspaceKey
5270
+ } : { emails, role }
5263
5271
  }),
5264
5272
  "Failed to add users"
5265
5273
  );
5266
5274
  }
5275
+ async function grantTemporaryWorkspaceAccess(arbi, params) {
5276
+ return requireData(
5277
+ await arbi.fetch.POST("/v1/workspace/users", {
5278
+ body: {
5279
+ emails: params.emails,
5280
+ role: params.role ?? "collaborator",
5281
+ workspace_ext_id: params.workspaceExtId,
5282
+ workspace_key: params.workspaceKey,
5283
+ session_pubkey_b64: params.sessionPubkeyB64
5284
+ }
5285
+ }),
5286
+ "Failed to grant temporary access"
5287
+ );
5288
+ }
5267
5289
  async function removeWorkspaceUsers(arbi, userIds) {
5268
5290
  requireOk(
5269
5291
  await arbi.fetch.DELETE("/v1/workspace/users", {
@@ -5659,9 +5681,11 @@ __export(dm_exports, {
5659
5681
  // src/operations/agents.ts
5660
5682
  var agents_exports = {};
5661
5683
  __export(agents_exports, {
5684
+ authorizeAgent: () => authorizeAgent,
5662
5685
  createAgent: () => createAgent,
5663
5686
  deleteAgents: () => deleteAgents,
5664
5687
  getAgentConfig: () => getAgentConfig,
5688
+ getAuthorizeLimits: () => getAuthorizeLimits,
5665
5689
  listAgentWorkspaces: () => listAgentWorkspaces,
5666
5690
  listAgents: () => listAgents
5667
5691
  });
@@ -5696,6 +5720,21 @@ async function deleteAgents(arbi, agentExtIds) {
5696
5720
  "Failed to delete agents"
5697
5721
  );
5698
5722
  }
5723
+ async function authorizeAgent(arbi, agentExtId, workspaceExtId, ttlSeconds) {
5724
+ return requireData(
5725
+ await arbi.fetch.POST("/v1/agents/{agent_ext_id}/authorize", {
5726
+ params: { path: { agent_ext_id: agentExtId } },
5727
+ body: { workspace_ext_id: workspaceExtId, ttl_seconds: ttlSeconds ?? null }
5728
+ }),
5729
+ "Failed to authorize agent"
5730
+ );
5731
+ }
5732
+ async function getAuthorizeLimits(arbi) {
5733
+ return requireData(
5734
+ await arbi.fetch.GET("/v1/agents/authorize-limits"),
5735
+ "Failed to fetch authorize limits"
5736
+ );
5737
+ }
5699
5738
 
5700
5739
  // src/operations/dm.ts
5701
5740
  function createDmCryptoContext(arbi, signingPrivateKeyBytes, userExtId) {
@@ -6082,6 +6121,7 @@ __export(tasks_exports, {
6082
6121
  createTask: () => createTask,
6083
6122
  deleteTask: () => deleteTask,
6084
6123
  getTask: () => getTask,
6124
+ listTaskRuns: () => listTaskRuns,
6085
6125
  listTasks: () => listTasks,
6086
6126
  runTask: () => runTask,
6087
6127
  updateTask: () => updateTask
@@ -6119,6 +6159,12 @@ async function runTask(arbi, taskId) {
6119
6159
  "Failed to run task"
6120
6160
  );
6121
6161
  }
6162
+ async function listTaskRuns(arbi, taskId) {
6163
+ return requireData(
6164
+ await arbi.fetch.GET("/v1/tasks/{task_id}/runs", { params: { path: { task_id: taskId } } }),
6165
+ "Failed to list task runs"
6166
+ );
6167
+ }
6122
6168
 
6123
6169
  // src/operations/facts.ts
6124
6170
  var facts_exports = {};
@@ -6260,6 +6306,22 @@ var Arbi = class {
6260
6306
  const signingPrivateKey = client.crypto.base64ToBytes(signingPrivateKeyBase64);
6261
6307
  this.loginResult = await client.auth.loginWithKey({ email, signingPrivateKey });
6262
6308
  }
6309
+ /** A workspace's key, sealed to the caller's own session (what `/open` and `POST /workspace/users` take). */
6310
+ async sealWorkspaceKey(workspaceId) {
6311
+ const client = this.requireClient();
6312
+ const lr2 = this.requireLogin();
6313
+ const all = await listWorkspaces(client);
6314
+ const ws = all.find((w2) => w2.external_id === workspaceId);
6315
+ if (!ws || !ws.wrapped_key) {
6316
+ throw new ArbiError(`Workspace ${workspaceId} not found or has no encryption key`);
6317
+ }
6318
+ return generateEncryptedWorkspaceKey(
6319
+ client,
6320
+ ws.wrapped_key,
6321
+ lr2.serverSessionKey,
6322
+ client.crypto.bytesToBase64(lr2.signingPrivateKey)
6323
+ );
6324
+ }
6263
6325
  /**
6264
6326
  * Select a workspace by ID. Fetches the workspace list, finds the matching
6265
6327
  * workspace, decrypts the wrapped key, and sets up auth headers.
@@ -6442,6 +6504,30 @@ var Arbi = class {
6442
6504
  update: (body) => updateWorkspace(this.requireClient(), body),
6443
6505
  listUsers: () => listWorkspaceUsers(this.requireClient()),
6444
6506
  addUsers: (emails, role) => addWorkspaceUsers(this.requireClient(), emails, role),
6507
+ /**
6508
+ * Grant users a temporary key scoped to ONE session (identified by its public key), for
6509
+ * example an agent's run session minted by `agents.authorize()`. Nothing standing is created:
6510
+ * the grant expires with that session. Works for any workspace the caller holds a key for;
6511
+ * it does not need to be the open one.
6512
+ */
6513
+ grantTemporaryAccess: async (params) => {
6514
+ const client = this.requireClient();
6515
+ return grantTemporaryWorkspaceAccess(client, {
6516
+ emails: params.emails,
6517
+ workspaceExtId: params.workspaceId,
6518
+ workspaceKey: await this.sealWorkspaceKey(params.workspaceId),
6519
+ sessionPubkeyB64: params.sessionPubkeyB64,
6520
+ role: params.role
6521
+ });
6522
+ },
6523
+ /**
6524
+ * Add users (standing, permanent membership) to ANY workspace the caller holds a key for,
6525
+ * without opening it. `addUsers` does the same for the currently open workspace.
6526
+ */
6527
+ grantAccess: async (params) => addWorkspaceUsers(this.requireClient(), params.emails, params.role, {
6528
+ workspaceExtId: params.workspaceId,
6529
+ workspaceKey: await this.sealWorkspaceKey(params.workspaceId)
6530
+ }),
6445
6531
  removeUsers: (userIds) => removeWorkspaceUsers(this.requireClient(), userIds),
6446
6532
  setUserRole: (userIds, role) => setUserRole(this.requireClient(), userIds, role),
6447
6533
  /**
@@ -6499,12 +6585,7 @@ var Arbi = class {
6499
6585
  uploadFile: (fileData, fileName, options) => {
6500
6586
  this.requireWorkspace();
6501
6587
  return this.recovering(
6502
- () => uploadFile(
6503
- this.getAuthHeaders(),
6504
- fileData,
6505
- fileName,
6506
- options?.folder ? { folder: options.folder } : void 0
6507
- )
6588
+ () => uploadFile(this.getAuthHeaders(), fileData, fileName, options)
6508
6589
  );
6509
6590
  },
6510
6591
  download: (docId) => this.recovering(() => downloadDocument(this.getAuthHeaders(), docId)),
@@ -6557,6 +6638,8 @@ var Arbi = class {
6557
6638
  * Respond to an agent's question during a human-in-the-loop workflow.
6558
6639
  */
6559
6640
  respond: (assistantMessageExtId, answer) => respondToAgent(this.requireClient(), assistantMessageExtId, answer),
6641
+ /** The skills the caller can run (own + shared marketplace), metadata only. */
6642
+ listSkills: (options) => listSkills(this.requireClient(), options),
6560
6643
  /**
6561
6644
  * Search documents without LLM generation (retrieval only).
6562
6645
  */
@@ -6713,7 +6796,28 @@ var Arbi = class {
6713
6796
  create: (name) => createAgent(this.requireClient(), name),
6714
6797
  getConfig: (agentExtId) => getAgentConfig(this.requireClient(), agentExtId),
6715
6798
  listWorkspaces: (agentExtId) => listAgentWorkspaces(this.requireClient(), agentExtId),
6716
- delete: (agentExtIds) => deleteAgents(this.requireClient(), agentExtIds)
6799
+ delete: (agentExtIds) => deleteAgents(this.requireClient(), agentExtIds),
6800
+ /** Mint a TTL'd run session for an agent; see `grantTemporaryAccess` to also deposit a key. */
6801
+ authorize: (agentExtId, workspaceId, ttlSeconds) => authorizeAgent(this.requireClient(), agentExtId, workspaceId, ttlSeconds),
6802
+ authorizeLimits: () => getAuthorizeLimits(this.requireClient()),
6803
+ /**
6804
+ * Give an agent temporary, session-scoped access to a workspace: mint its run session, then
6805
+ * deposit the workspace key on it. Returns the session details (`ttl` in seconds).
6806
+ */
6807
+ grantTemporaryAccess: async (agentExtId, workspaceId, ttlSeconds) => {
6808
+ const session = await authorizeAgent(
6809
+ this.requireClient(),
6810
+ agentExtId,
6811
+ workspaceId,
6812
+ ttlSeconds
6813
+ );
6814
+ await this.workspaces.grantTemporaryAccess({
6815
+ workspaceId,
6816
+ emails: [session.agent_email],
6817
+ sessionPubkeyB64: session.session_pubkey_b64
6818
+ });
6819
+ return session;
6820
+ }
6717
6821
  };
6718
6822
  // ── Scheduled tasks ───────────────────────────────────────────────────
6719
6823
  tasks = {
@@ -6722,7 +6826,26 @@ var Arbi = class {
6722
6826
  get: (taskId) => getTask(this.requireClient(), taskId),
6723
6827
  update: (taskId, body) => updateTask(this.requireClient(), taskId, body),
6724
6828
  delete: (taskId) => deleteTask(this.requireClient(), taskId),
6725
- run: (taskId) => runTask(this.requireClient(), taskId)
6829
+ run: (taskId) => runTask(this.requireClient(), taskId),
6830
+ listRuns: (taskId) => listTaskRuns(this.requireClient(), taskId),
6831
+ /**
6832
+ * Run a task and, when the run is parked waiting for workspace access (a temporary
6833
+ * authorization tier), grant the agent's run session a temporary key and run it again.
6834
+ * A task that needs no approval returns from the first call already running.
6835
+ */
6836
+ runWithAuth: async (taskId) => {
6837
+ const client = this.requireClient();
6838
+ const first = await runTask(client, taskId);
6839
+ if (!first.pending_auth_request_id || !first.pending_auth_session_pubkey || !first.pending_auth_agent_email || !first.workspace_ext_id) {
6840
+ return first;
6841
+ }
6842
+ await this.workspaces.grantTemporaryAccess({
6843
+ workspaceId: first.workspace_ext_id,
6844
+ emails: [first.pending_auth_agent_email],
6845
+ sessionPubkeyB64: first.pending_auth_session_pubkey
6846
+ });
6847
+ return runTask(client, taskId);
6848
+ }
6726
6849
  };
6727
6850
  // ── Workspace facts ─────────────────────────────────────────────────
6728
6851
  facts = {