@arbidocs/sdk 0.3.119 → 0.3.121

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
@@ -5770,6 +5770,7 @@ async function resolveRecipient(arbi, ref) {
5770
5770
  return null;
5771
5771
  }
5772
5772
  async function sendEncryptedDM(arbi, messages, crypto) {
5773
+ const plaintextFor = new Map(messages.map((m2) => [m2.recipient_ext_id, m2.content]));
5773
5774
  const encrypted = await Promise.all(
5774
5775
  messages.map(async (msg) => ({
5775
5776
  recipient_ext_id: msg.recipient_ext_id,
@@ -5781,10 +5782,14 @@ async function sendEncryptedDM(arbi, messages, crypto) {
5781
5782
  )
5782
5783
  }))
5783
5784
  );
5784
- return requireData(
5785
+ const created = requireData(
5785
5786
  await arbi.fetch.POST("/v1/notifications/", { body: { messages: encrypted } }),
5786
5787
  "Failed to send message"
5787
5788
  );
5789
+ return created.map((n2) => ({
5790
+ ...n2,
5791
+ content: plaintextFor.get(n2.recipient.external_id) ?? n2.content
5792
+ }));
5788
5793
  }
5789
5794
  async function requestWorkspaceAccess(arbi, params, crypto) {
5790
5795
  const payload = JSON.stringify({
@@ -5978,11 +5983,14 @@ async function listSessions(arbi) {
5978
5983
  var projects_exports = {};
5979
5984
  __export(projects_exports, {
5980
5985
  createProject: () => createProject,
5986
+ deleteProject: () => deleteProject,
5981
5987
  getProjectInvoices: () => getProjectInvoices,
5982
5988
  getProjectUsage: () => getProjectUsage,
5983
5989
  getUserUsageToday: () => getUserUsageToday,
5984
5990
  listProjects: () => listProjects,
5985
- refreshProject: () => refreshProject
5991
+ refreshProject: () => refreshProject,
5992
+ renameProject: () => renameProject,
5993
+ updateProject: () => updateProject
5986
5994
  });
5987
5995
  async function listProjects(arbi) {
5988
5996
  return requireData(await arbi.fetch.GET("/v1/user/projects/"), "Failed to fetch projects");
@@ -5995,6 +6003,26 @@ async function createProject(arbi, name) {
5995
6003
  "Failed to create project"
5996
6004
  );
5997
6005
  }
6006
+ async function updateProject(arbi, projectExtId, body) {
6007
+ return requireData(
6008
+ await arbi.fetch.PATCH("/v1/user/projects/{project_ext_id}", {
6009
+ params: { path: { project_ext_id: projectExtId } },
6010
+ body
6011
+ }),
6012
+ "Failed to update project"
6013
+ );
6014
+ }
6015
+ async function renameProject(arbi, projectExtId, name) {
6016
+ return updateProject(arbi, projectExtId, { name });
6017
+ }
6018
+ async function deleteProject(arbi, projectExtId) {
6019
+ requireOk(
6020
+ await arbi.fetch.DELETE("/v1/user/projects/{project_ext_id}", {
6021
+ params: { path: { project_ext_id: projectExtId } }
6022
+ }),
6023
+ "Failed to delete project"
6024
+ );
6025
+ }
5998
6026
  async function refreshProject(arbi, projectExtId) {
5999
6027
  return requireData(
6000
6028
  await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/refresh", {
@@ -6027,6 +6055,15 @@ async function getUserUsageToday(arbi) {
6027
6055
  }
6028
6056
 
6029
6057
  // src/operations/tasks.ts
6058
+ var tasks_exports = {};
6059
+ __export(tasks_exports, {
6060
+ createTask: () => createTask,
6061
+ deleteTask: () => deleteTask,
6062
+ getTask: () => getTask,
6063
+ listTasks: () => listTasks,
6064
+ runTask: () => runTask,
6065
+ updateTask: () => updateTask
6066
+ });
6030
6067
  async function listTasks(arbi) {
6031
6068
  return requireData(await arbi.fetch.GET("/v1/tasks"), "Failed to list tasks");
6032
6069
  }
@@ -6245,13 +6282,19 @@ var Arbi = class {
6245
6282
  user = {
6246
6283
  /**
6247
6284
  * The authenticated user's identity from the current session
6248
- * (`external_id` + `email`), established at login. Returns `null` when not
6249
- * logged in. This is the canonical "who am I" accessor — DM direction and
6250
- * ownership checks read it instead of re-deriving identity per call.
6285
+ * (`external_id`, plus `email` when the session carries one), established at
6286
+ * login. Returns `null` when not logged in. This is the canonical "who am I"
6287
+ * accessor — DM direction and ownership checks read it instead of re-deriving
6288
+ * identity per call.
6289
+ *
6290
+ * The external_id alone decides identity. A session without an email (e.g. an
6291
+ * agent, or a key-restored session) is still a known user, so `email` is
6292
+ * nullable rather than gating the whole identity: an ownership check must
6293
+ * never silently fail open just because the email is missing.
6251
6294
  */
6252
6295
  identity: () => {
6253
6296
  const state = this.requireClient().session.getState();
6254
- return state.userExtId && state.userEmail ? { externalId: state.userExtId, email: state.userEmail } : null;
6297
+ return state.userExtId ? { externalId: state.userExtId, email: state.userEmail ?? null } : null;
6255
6298
  },
6256
6299
  /** Today's deployment-wide credit spend for the current user. */
6257
6300
  usageToday: () => getUserUsageToday(this.requireClient())
@@ -6439,23 +6482,31 @@ var Arbi = class {
6439
6482
  /**
6440
6483
  * Build (and cache) the DM crypto context for the current session.
6441
6484
  *
6442
- * Derives the user's curve25519 keypair from the stored signing key and pairs
6443
- * it with their external_id — everything `list()`/`send()` need to encrypt and
6485
+ * Derives the user's curve25519 keypair from their signing key and pairs it
6486
+ * with their external_id — everything `list()`/`send()` need to encrypt and
6444
6487
  * decrypt. Cached for the session and cleared on logout. Consumers never touch
6445
6488
  * this: it's an internal of the `dm` surface.
6489
+ *
6490
+ * The key comes from the live login result first, exactly as `selectWorkspace`
6491
+ * sources it, and only then from persisted storage (which is what restores a
6492
+ * session on reload). Reading storage first would make DMs the one feature that
6493
+ * breaks whenever persistence is unavailable — `saveSession` deliberately
6494
+ * no-ops without Web Crypto (a non-secure origin, tracking prevention, an
6495
+ * embedded widget), so a perfectly authenticated user with a working workspace
6496
+ * would be told they are "not authenticated" the moment they opened Messages.
6446
6497
  */
6447
6498
  async requireDmCrypto() {
6448
6499
  if (this.dmCryptoContext) return this.dmCryptoContext;
6449
6500
  const client = this.requireClient();
6450
- const session = await client.storage.getSession();
6451
- if (!session) {
6501
+ const signingPrivateKey = this.loginResult?.signingPrivateKey ?? (await client.storage.getSession())?.signingPrivateKey;
6502
+ if (!signingPrivateKey) {
6452
6503
  throw new ArbiError("Not authenticated \u2014 no session available for DM encryption");
6453
6504
  }
6454
6505
  const userExtId = client.session.getState().userExtId;
6455
6506
  if (!userExtId) {
6456
6507
  throw new ArbiError("No user identity in session \u2014 cannot set up DM encryption");
6457
6508
  }
6458
- this.dmCryptoContext = createDmCryptoContext(client, session.signingPrivateKey, userExtId);
6509
+ this.dmCryptoContext = createDmCryptoContext(client, signingPrivateKey, userExtId);
6459
6510
  return this.dmCryptoContext;
6460
6511
  }
6461
6512
  dm = {
@@ -7398,6 +7449,18 @@ function extractResponseText(response) {
7398
7449
  return parts.join("");
7399
7450
  }
7400
7451
 
7452
+ // src/operations/profile.ts
7453
+ var profile_exports = {};
7454
+ __export(profile_exports, {
7455
+ updateProfile: () => updateProfile
7456
+ });
7457
+ async function updateProfile(arbi, body) {
7458
+ return requireData(
7459
+ await arbi.fetch.PATCH("/v1/user/profile", { body }),
7460
+ "Failed to update profile"
7461
+ );
7462
+ }
7463
+
7401
7464
  // src/listen/index.ts
7402
7465
  var listen_exports = {};
7403
7466
  __export(listen_exports, {
@@ -7749,6 +7812,7 @@ exports.parseSlashTokenInProgress = parseSlashTokenInProgress;
7749
7812
  exports.performPasswordLogin = performPasswordLogin;
7750
7813
  exports.performSigningKeyLogin = performSigningKeyLogin;
7751
7814
  exports.performSsoDeviceFlowLogin = performSsoDeviceFlowLogin;
7815
+ exports.profile = profile_exports;
7752
7816
  exports.projects = projects_exports;
7753
7817
  exports.requireData = requireData;
7754
7818
  exports.requireOk = requireOk;
@@ -7765,6 +7829,7 @@ exports.streamSSE = streamSSE;
7765
7829
  exports.stripCitationMarkdown = stripCitationMarkdown;
7766
7830
  exports.summarizeCitations = summarizeCitations;
7767
7831
  exports.tags = tags_exports;
7832
+ exports.tasks = tasks_exports;
7768
7833
  exports.workspaces = workspaces_exports;
7769
7834
  //# sourceMappingURL=index.cjs.map
7770
7835
  //# sourceMappingURL=index.cjs.map