@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/browser.cjs CHANGED
@@ -5915,6 +5915,76 @@ async function requestDeletion(arbi) {
5915
5915
  return requireData(await arbi.fetch.POST("/v1/user/request-deletion"), "Failed to delete account");
5916
5916
  }
5917
5917
 
5918
+ // src/operations/identity.ts
5919
+ var identity_exports = {};
5920
+ __export(identity_exports, {
5921
+ acceptName: () => acceptName,
5922
+ getStatus: () => getStatus,
5923
+ identityErrorCode: () => identityErrorCode,
5924
+ purchase: () => purchase,
5925
+ refresh: () => refresh,
5926
+ remove: () => remove,
5927
+ startSession: () => startSession
5928
+ });
5929
+ function refusal(apiError) {
5930
+ const detail = apiError?.detail;
5931
+ if (typeof detail === "string") return { message: detail };
5932
+ if (detail && typeof detail === "object" && !Array.isArray(detail)) {
5933
+ const { code, message } = detail;
5934
+ return {
5935
+ code: typeof code === "string" ? code : void 0,
5936
+ message: typeof message === "string" ? message : void 0
5937
+ };
5938
+ }
5939
+ return {};
5940
+ }
5941
+ function identityErrorCode(error) {
5942
+ return error instanceof ArbiApiError ? refusal(error.apiError).code : void 0;
5943
+ }
5944
+ function unwrap(result, fallback) {
5945
+ if (result.error || result.data === void 0) {
5946
+ throw new ArbiApiError(
5947
+ refusal(result.error).message ?? fallback,
5948
+ result.error,
5949
+ result.response?.status
5950
+ );
5951
+ }
5952
+ return result.data;
5953
+ }
5954
+ async function getStatus(arbi) {
5955
+ return unwrap(await arbi.fetch.GET("/v1/user/identity"), "Failed to load identity verification");
5956
+ }
5957
+ async function purchase(arbi, projectExtId) {
5958
+ return unwrap(
5959
+ await arbi.fetch.POST("/v1/user/identity/purchase", {
5960
+ body: projectExtId ? { project_ext_id: projectExtId } : {}
5961
+ }),
5962
+ "Payment could not be completed"
5963
+ );
5964
+ }
5965
+ async function startSession(arbi) {
5966
+ const data = unwrap(
5967
+ await arbi.fetch.POST("/v1/user/identity/session"),
5968
+ "Could not start identity verification"
5969
+ );
5970
+ return data.url;
5971
+ }
5972
+ async function refresh(arbi) {
5973
+ return unwrap(
5974
+ await arbi.fetch.POST("/v1/user/identity/refresh"),
5975
+ "Could not read the verification result"
5976
+ );
5977
+ }
5978
+ async function acceptName(arbi) {
5979
+ return unwrap(
5980
+ await arbi.fetch.POST("/v1/user/identity/accept-name"),
5981
+ "Could not change your name"
5982
+ );
5983
+ }
5984
+ async function remove(arbi) {
5985
+ return unwrap(await arbi.fetch.DELETE("/v1/user/identity"), "Could not remove the verification");
5986
+ }
5987
+
5918
5988
  // src/operations/projects.ts
5919
5989
  var projects_exports = {};
5920
5990
  __export(projects_exports, {
@@ -5931,10 +6001,10 @@ __export(projects_exports, {
5931
6001
  async function listProjects(arbi) {
5932
6002
  return requireData(await arbi.fetch.GET("/v1/user/projects/"), "Failed to fetch projects");
5933
6003
  }
5934
- async function createProject(arbi, name) {
6004
+ async function createProject(arbi, name, plan = "free") {
5935
6005
  return requireData(
5936
6006
  await arbi.fetch.POST("/v1/user/projects/", {
5937
- body: { name }
6007
+ body: { name, plan }
5938
6008
  }),
5939
6009
  "Failed to create project"
5940
6010
  );
@@ -5993,9 +6063,11 @@ async function getUserUsageToday(arbi) {
5993
6063
  // src/operations/work.ts
5994
6064
  var work_exports = {};
5995
6065
  __export(work_exports, {
6066
+ actOnStep: () => actOnStep,
5996
6067
  createWork: () => createWork,
5997
6068
  getActivity: () => getActivity,
5998
6069
  getPendingAuth: () => getPendingAuth,
6070
+ notifyConversation: () => notifyConversation,
5999
6071
  planWork: () => planWork,
6000
6072
  runConversation: () => runConversation,
6001
6073
  updateConversation: () => updateConversation
@@ -6033,6 +6105,24 @@ async function getPendingAuth(arbi, conversationId) {
6033
6105
  "Failed to read the pending access request"
6034
6106
  );
6035
6107
  }
6108
+ async function actOnStep(arbi, conversationId, body) {
6109
+ return requireData(
6110
+ await arbi.fetch.POST("/v1/conversation/{conversation_ext_id}/step", {
6111
+ ...byId(conversationId),
6112
+ body
6113
+ }),
6114
+ "Failed to update the workflow step"
6115
+ );
6116
+ }
6117
+ async function notifyConversation(arbi, conversationId, userIds) {
6118
+ return requireData(
6119
+ await arbi.fetch.POST("/v1/conversation/{conversation_ext_id}/notify", {
6120
+ ...byId(conversationId),
6121
+ body: { user_ext_ids: userIds }
6122
+ }),
6123
+ "Failed to notify people about the conversation"
6124
+ );
6125
+ }
6036
6126
  async function getActivity(arbi, conversationId) {
6037
6127
  return requireData(
6038
6128
  await arbi.fetch.GET("/v1/conversation/{conversation_ext_id}/activity", byId(conversationId)),
@@ -6460,7 +6550,8 @@ var Arbi = class {
6460
6550
  ...this.userProfile,
6461
6551
  givenName: updated.given_name ?? this.userProfile.givenName,
6462
6552
  familyName: updated.family_name ?? null,
6463
- picture: updated.picture ?? null
6553
+ picture: updated.picture ?? null,
6554
+ isIdentityVerified: updated.is_identity_verified ?? false
6464
6555
  });
6465
6556
  }
6466
6557
  return updated;
@@ -6505,6 +6596,49 @@ var Arbi = class {
6505
6596
  return result;
6506
6597
  }
6507
6598
  };
6599
+ // ── Identity verification ─────────────────────────────────────────────
6600
+ identity = {
6601
+ /** Whether the ID check is offered (Pro plans), its price, and where the user's check stands. */
6602
+ status: () => getStatus(this.requireClient()),
6603
+ /** Charge the one-time fee to an own Pro project; `requires_action` carries a payment URL. */
6604
+ purchase: (projectExtId) => purchase(this.requireClient(), projectExtId),
6605
+ /** The Didit session URL to run the web SDK on. */
6606
+ startSession: () => startSession(this.requireClient()),
6607
+ /** Read the decision of the open check; the profile follows a granted tick. */
6608
+ refresh: async () => {
6609
+ const status = await refresh(this.requireClient());
6610
+ this.syncIdentity(status);
6611
+ return status;
6612
+ },
6613
+ /** Take the name on the document as the account name; the profile follows. */
6614
+ acceptName: async () => {
6615
+ const client = this.requireClient();
6616
+ const offered = await getStatus(client);
6617
+ const status = await acceptName(client);
6618
+ if (this.userProfile && offered.document_given_name) {
6619
+ this.setUserProfile({
6620
+ ...this.userProfile,
6621
+ givenName: offered.document_given_name,
6622
+ familyName: offered.document_family_name ?? null,
6623
+ isIdentityVerified: status.verified
6624
+ });
6625
+ } else {
6626
+ this.syncIdentity(status);
6627
+ }
6628
+ return status;
6629
+ },
6630
+ /** Remove the tick and erase any open check. */
6631
+ remove: async () => {
6632
+ const status = await remove(this.requireClient());
6633
+ this.syncIdentity(status);
6634
+ return status;
6635
+ }
6636
+ };
6637
+ syncIdentity(status) {
6638
+ if (this.userProfile && this.userProfile.isIdentityVerified !== status.verified) {
6639
+ this.setUserProfile({ ...this.userProfile, isIdentityVerified: status.verified });
6640
+ }
6641
+ }
6508
6642
  // ── Workspaces ────────────────────────────────────────────────────────
6509
6643
  workspaces = {
6510
6644
  list: () => listWorkspaces(this.requireClient()),
@@ -6641,6 +6775,10 @@ var Arbi = class {
6641
6775
  pendingAuth: (conversationId) => getPendingAuth(this.requireClient(), conversationId),
6642
6776
  /** The task's history, oldest first. */
6643
6777
  activity: (conversationId) => getActivity(this.requireClient(), conversationId),
6778
+ /** Complete or skip a step of a workflow run; the run goes on to its next agent step. */
6779
+ actOnStep: (conversationId, body) => actOnStep(this.requireClient(), conversationId, body),
6780
+ /** Notify people about a conversation (each gets a notification); resolves with who was. */
6781
+ notify: (conversationId, userIds) => notifyConversation(this.requireClient(), conversationId, userIds),
6644
6782
  /** Draft an editable plan from an objective. */
6645
6783
  plan: (body) => planWork(this.requireClient(), body),
6646
6784
  /**
@@ -7170,6 +7308,8 @@ exports.formatWorkspaceChoices = formatWorkspaceChoices;
7170
7308
  exports.getErrorMessage = getErrorMessage;
7171
7309
  exports.getRawWorkspaceKey = getRawWorkspaceKey;
7172
7310
  exports.health = health_exports;
7311
+ exports.identityErrorCode = identityErrorCode;
7312
+ exports.identityVerification = identity_exports;
7173
7313
  exports.mail = mail_exports;
7174
7314
  exports.parseSSEEvents = parseSSEEvents;
7175
7315
  exports.parseSlashCommand = parseSlashCommand;