@arbidocs/sdk 0.4.71 → 0.4.73

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.cjs CHANGED
@@ -6479,6 +6479,76 @@ async function requestDeletion(arbi) {
6479
6479
  return requireData(await arbi.fetch.POST("/v1/user/request-deletion"), "Failed to delete account");
6480
6480
  }
6481
6481
 
6482
+ // src/operations/identity.ts
6483
+ var identity_exports = {};
6484
+ __export(identity_exports, {
6485
+ acceptName: () => acceptName,
6486
+ getStatus: () => getStatus,
6487
+ identityErrorCode: () => identityErrorCode,
6488
+ purchase: () => purchase,
6489
+ refresh: () => refresh,
6490
+ remove: () => remove,
6491
+ startSession: () => startSession
6492
+ });
6493
+ function refusal(apiError) {
6494
+ const detail = apiError?.detail;
6495
+ if (typeof detail === "string") return { message: detail };
6496
+ if (detail && typeof detail === "object" && !Array.isArray(detail)) {
6497
+ const { code, message } = detail;
6498
+ return {
6499
+ code: typeof code === "string" ? code : void 0,
6500
+ message: typeof message === "string" ? message : void 0
6501
+ };
6502
+ }
6503
+ return {};
6504
+ }
6505
+ function identityErrorCode(error) {
6506
+ return error instanceof ArbiApiError ? refusal(error.apiError).code : void 0;
6507
+ }
6508
+ function unwrap(result, fallback) {
6509
+ if (result.error || result.data === void 0) {
6510
+ throw new ArbiApiError(
6511
+ refusal(result.error).message ?? fallback,
6512
+ result.error,
6513
+ result.response?.status
6514
+ );
6515
+ }
6516
+ return result.data;
6517
+ }
6518
+ async function getStatus(arbi) {
6519
+ return unwrap(await arbi.fetch.GET("/v1/user/identity"), "Failed to load identity verification");
6520
+ }
6521
+ async function purchase(arbi, projectExtId) {
6522
+ return unwrap(
6523
+ await arbi.fetch.POST("/v1/user/identity/purchase", {
6524
+ body: projectExtId ? { project_ext_id: projectExtId } : {}
6525
+ }),
6526
+ "Payment could not be completed"
6527
+ );
6528
+ }
6529
+ async function startSession(arbi) {
6530
+ const data = unwrap(
6531
+ await arbi.fetch.POST("/v1/user/identity/session"),
6532
+ "Could not start identity verification"
6533
+ );
6534
+ return data.url;
6535
+ }
6536
+ async function refresh(arbi) {
6537
+ return unwrap(
6538
+ await arbi.fetch.POST("/v1/user/identity/refresh"),
6539
+ "Could not read the verification result"
6540
+ );
6541
+ }
6542
+ async function acceptName(arbi) {
6543
+ return unwrap(
6544
+ await arbi.fetch.POST("/v1/user/identity/accept-name"),
6545
+ "Could not change your name"
6546
+ );
6547
+ }
6548
+ async function remove(arbi) {
6549
+ return unwrap(await arbi.fetch.DELETE("/v1/user/identity"), "Could not remove the verification");
6550
+ }
6551
+
6482
6552
  // src/operations/projects.ts
6483
6553
  var projects_exports = {};
6484
6554
  __export(projects_exports, {
@@ -6495,10 +6565,10 @@ __export(projects_exports, {
6495
6565
  async function listProjects(arbi) {
6496
6566
  return requireData(await arbi.fetch.GET("/v1/user/projects/"), "Failed to fetch projects");
6497
6567
  }
6498
- async function createProject(arbi, name) {
6568
+ async function createProject(arbi, name, plan = "free") {
6499
6569
  return requireData(
6500
6570
  await arbi.fetch.POST("/v1/user/projects/", {
6501
- body: { name }
6571
+ body: { name, plan }
6502
6572
  }),
6503
6573
  "Failed to create project"
6504
6574
  );
@@ -6557,9 +6627,11 @@ async function getUserUsageToday(arbi) {
6557
6627
  // src/operations/work.ts
6558
6628
  var work_exports = {};
6559
6629
  __export(work_exports, {
6630
+ actOnStep: () => actOnStep,
6560
6631
  createWork: () => createWork,
6561
6632
  getActivity: () => getActivity,
6562
6633
  getPendingAuth: () => getPendingAuth,
6634
+ notifyConversation: () => notifyConversation,
6563
6635
  planWork: () => planWork,
6564
6636
  runConversation: () => runConversation,
6565
6637
  updateConversation: () => updateConversation
@@ -6597,6 +6669,24 @@ async function getPendingAuth(arbi, conversationId) {
6597
6669
  "Failed to read the pending access request"
6598
6670
  );
6599
6671
  }
6672
+ async function actOnStep(arbi, conversationId, body) {
6673
+ return requireData(
6674
+ await arbi.fetch.POST("/v1/conversation/{conversation_ext_id}/step", {
6675
+ ...byId(conversationId),
6676
+ body
6677
+ }),
6678
+ "Failed to update the workflow step"
6679
+ );
6680
+ }
6681
+ async function notifyConversation(arbi, conversationId, userIds) {
6682
+ return requireData(
6683
+ await arbi.fetch.POST("/v1/conversation/{conversation_ext_id}/notify", {
6684
+ ...byId(conversationId),
6685
+ body: { user_ext_ids: userIds }
6686
+ }),
6687
+ "Failed to notify people about the conversation"
6688
+ );
6689
+ }
6600
6690
  async function getActivity(arbi, conversationId) {
6601
6691
  return requireData(
6602
6692
  await arbi.fetch.GET("/v1/conversation/{conversation_ext_id}/activity", byId(conversationId)),
@@ -7024,7 +7114,8 @@ var Arbi = class {
7024
7114
  ...this.userProfile,
7025
7115
  givenName: updated.given_name ?? this.userProfile.givenName,
7026
7116
  familyName: updated.family_name ?? null,
7027
- picture: updated.picture ?? null
7117
+ picture: updated.picture ?? null,
7118
+ isIdentityVerified: updated.is_identity_verified ?? false
7028
7119
  });
7029
7120
  }
7030
7121
  return updated;
@@ -7069,6 +7160,49 @@ var Arbi = class {
7069
7160
  return result;
7070
7161
  }
7071
7162
  };
7163
+ // ── Identity verification ─────────────────────────────────────────────
7164
+ identity = {
7165
+ /** Whether the ID check is offered (Pro plans), its price, and where the user's check stands. */
7166
+ status: () => getStatus(this.requireClient()),
7167
+ /** Charge the one-time fee to an own Pro project; `requires_action` carries a payment URL. */
7168
+ purchase: (projectExtId) => purchase(this.requireClient(), projectExtId),
7169
+ /** The Didit session URL to run the web SDK on. */
7170
+ startSession: () => startSession(this.requireClient()),
7171
+ /** Read the decision of the open check; the profile follows a granted tick. */
7172
+ refresh: async () => {
7173
+ const status = await refresh(this.requireClient());
7174
+ this.syncIdentity(status);
7175
+ return status;
7176
+ },
7177
+ /** Take the name on the document as the account name; the profile follows. */
7178
+ acceptName: async () => {
7179
+ const client = this.requireClient();
7180
+ const offered = await getStatus(client);
7181
+ const status = await acceptName(client);
7182
+ if (this.userProfile && offered.document_given_name) {
7183
+ this.setUserProfile({
7184
+ ...this.userProfile,
7185
+ givenName: offered.document_given_name,
7186
+ familyName: offered.document_family_name ?? null,
7187
+ isIdentityVerified: status.verified
7188
+ });
7189
+ } else {
7190
+ this.syncIdentity(status);
7191
+ }
7192
+ return status;
7193
+ },
7194
+ /** Remove the tick and erase any open check. */
7195
+ remove: async () => {
7196
+ const status = await remove(this.requireClient());
7197
+ this.syncIdentity(status);
7198
+ return status;
7199
+ }
7200
+ };
7201
+ syncIdentity(status) {
7202
+ if (this.userProfile && this.userProfile.isIdentityVerified !== status.verified) {
7203
+ this.setUserProfile({ ...this.userProfile, isIdentityVerified: status.verified });
7204
+ }
7205
+ }
7072
7206
  // ── Workspaces ────────────────────────────────────────────────────────
7073
7207
  workspaces = {
7074
7208
  list: () => listWorkspaces(this.requireClient()),
@@ -7205,6 +7339,10 @@ var Arbi = class {
7205
7339
  pendingAuth: (conversationId) => getPendingAuth(this.requireClient(), conversationId),
7206
7340
  /** The task's history, oldest first. */
7207
7341
  activity: (conversationId) => getActivity(this.requireClient(), conversationId),
7342
+ /** Complete or skip a step of a workflow run; the run goes on to its next agent step. */
7343
+ actOnStep: (conversationId, body) => actOnStep(this.requireClient(), conversationId, body),
7344
+ /** Notify people about a conversation (each gets a notification); resolves with who was. */
7345
+ notify: (conversationId, userIds) => notifyConversation(this.requireClient(), conversationId, userIds),
7208
7346
  /** Draft an editable plan from an objective. */
7209
7347
  plan: (body) => planWork(this.requireClient(), body),
7210
7348
  /**
@@ -8811,6 +8949,8 @@ exports.getErrorCode = getErrorCode;
8811
8949
  exports.getErrorMessage = getErrorMessage;
8812
8950
  exports.getRawWorkspaceKey = getRawWorkspaceKey;
8813
8951
  exports.health = health_exports;
8952
+ exports.identityErrorCode = identityErrorCode;
8953
+ exports.identityVerification = identity_exports;
8814
8954
  exports.listen = listen_exports;
8815
8955
  exports.mail = mail_exports;
8816
8956
  exports.mailNode = mail_node_exports;