@arbidocs/sdk 0.4.104 → 0.4.106

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
@@ -3837,6 +3837,38 @@ async function resolveWorkspace(store, workspaceOpt) {
3837
3837
  };
3838
3838
  }
3839
3839
 
3840
+ // src/format.ts
3841
+ function formatFileSize(bytes, fallback = "N/A") {
3842
+ if (bytes === null || bytes === void 0) return fallback;
3843
+ if (bytes < 1024) return `${bytes} B`;
3844
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
3845
+ if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
3846
+ return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
3847
+ }
3848
+ function formatUserName(user) {
3849
+ if (!user) return "";
3850
+ return [user.given_name, user.family_name].filter(Boolean).join(" ");
3851
+ }
3852
+ function formatGbp(gbp) {
3853
+ const safe = typeof gbp === "number" && Number.isFinite(gbp) ? gbp : 0;
3854
+ if (safe > 0 && safe < 5e-3) return "<\xA30.01";
3855
+ const rounded = Math.round(safe * 100) / 100;
3856
+ const whole = Number.isInteger(rounded);
3857
+ const digits = Math.abs(rounded).toLocaleString("en-GB", {
3858
+ minimumFractionDigits: whole ? 0 : 2,
3859
+ maximumFractionDigits: whole ? 0 : 2
3860
+ });
3861
+ return `${rounded < 0 ? "-" : ""}\xA3${digits}`;
3862
+ }
3863
+ var DEFAULT_AI_USD_PER_GBP = 1;
3864
+ function usdToGbp(usd, usdPerGbp = DEFAULT_AI_USD_PER_GBP) {
3865
+ return usd / usdPerGbp;
3866
+ }
3867
+ function formatGbpPerMillionTokens(costPerToken) {
3868
+ if (!costPerToken) return null;
3869
+ return formatGbp(usdToGbp(costPerToken * 1e6));
3870
+ }
3871
+
3840
3872
  // src/sse.ts
3841
3873
  function humanizeStep(identifier) {
3842
3874
  const spaced = identifier.replace(/[_-]+/g, " ").trim();
@@ -4250,19 +4282,6 @@ async function connectWithReconnect(options) {
4250
4282
  };
4251
4283
  }
4252
4284
 
4253
- // src/format.ts
4254
- function formatFileSize(bytes, fallback = "N/A") {
4255
- if (bytes === null || bytes === void 0) return fallback;
4256
- if (bytes < 1024) return `${bytes} B`;
4257
- if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
4258
- if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
4259
- return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
4260
- }
4261
- function formatUserName(user) {
4262
- if (!user) return "";
4263
- return [user.given_name, user.family_name].filter(Boolean).join(" ");
4264
- }
4265
-
4266
4285
  // src/citations.ts
4267
4286
  function resolveCitations(metadata) {
4268
4287
  if (!metadata?.tools) return [];
@@ -7655,7 +7674,7 @@ var Arbi = class {
7655
7674
  update: (projectExtId, body) => updateProject(this.requireClient(), projectExtId, body),
7656
7675
  /** The project's stage and budget changes, newest first. */
7657
7676
  events: (projectExtId, options) => listProjectEvents(this.requireClient(), projectExtId, options),
7658
- /** The project's spend by conversation in a billing period (credits). */
7677
+ /** The project's spend by conversation in a billing period (£). */
7659
7678
  usageByConversation: (projectExtId, monthsBack) => getProjectConversationUsage(this.requireClient(), projectExtId, monthsBack),
7660
7679
  refresh: (projectExtId) => refreshProject(this.requireClient(), projectExtId),
7661
7680
  /** AI usage + spend breakdown for a project's billing period. */
@@ -7693,7 +7712,7 @@ var Arbi = class {
7693
7712
  this.profileListeners.add(listener);
7694
7713
  return () => this.profileListeners.delete(listener);
7695
7714
  },
7696
- /** Today's deployment-wide credit spend for the current user. */
7715
+ /** Today's deployment-wide AI usage (£) for the current user. */
7697
7716
  usageToday: () => getUserUsageToday(this.requireClient()),
7698
7717
  /**
7699
7718
  * The signed-in user from the server, with `can_create_projects`: false on deployments where
@@ -7951,7 +7970,7 @@ var Arbi = class {
7951
7970
  sendBackStep: (conversationId, step, options) => sendBackStep(this.requireClient(), conversationId, step, options),
7952
7971
  /** A stepped run's steps, signals, linked runs and send-backs, and what it waits for. */
7953
7972
  runProgress: (conversationId) => getRunProgress(this.requireClient(), conversationId),
7954
- /** What the conversation's AI work cost: by step, run, model, agent and feature (credits). */
7973
+ /** What the conversation's AI work cost: by step, run, model, agent and feature (£). */
7955
7974
  usage: (conversationId) => getConversationUsage(this.requireClient(), conversationId),
7956
7975
  /** Notify people about a conversation (each gets a notification); resolves with who was. */
7957
7976
  notify: (conversationId, userIds) => notifyConversation(this.requireClient(), conversationId, userIds),
@@ -8388,6 +8407,7 @@ var Arbi = class {
8388
8407
  exports.Arbi = Arbi;
8389
8408
  exports.ArbiApiError = ArbiApiError;
8390
8409
  exports.ArbiError = ArbiError;
8410
+ exports.DEFAULT_AI_USD_PER_GBP = DEFAULT_AI_USD_PER_GBP;
8391
8411
  exports.PlanStepsError = PlanStepsError;
8392
8412
  exports.WebSocketAuthError = WebSocketAuthError;
8393
8413
  exports.account = account_exports;
@@ -8413,6 +8433,8 @@ exports.files = files_exports;
8413
8433
  exports.filterSkills = filterSkills;
8414
8434
  exports.formatAgentStepLabel = formatAgentStepLabel;
8415
8435
  exports.formatFileSize = formatFileSize;
8436
+ exports.formatGbp = formatGbp;
8437
+ exports.formatGbpPerMillionTokens = formatGbpPerMillionTokens;
8416
8438
  exports.formatItemLabel = formatItemLabel;
8417
8439
  exports.formatUserName = formatUserName;
8418
8440
  exports.formatWorkspaceChoices = formatWorkspaceChoices;
@@ -8442,6 +8464,7 @@ exports.streamSSE = streamSSE;
8442
8464
  exports.stripCitationMarkdown = stripCitationMarkdown;
8443
8465
  exports.summarizeCitations = summarizeCitations;
8444
8466
  exports.tags = tags_exports;
8467
+ exports.usdToGbp = usdToGbp;
8445
8468
  exports.work = work_exports;
8446
8469
  exports.workflowSteps = workflow_steps_exports;
8447
8470
  exports.workflows = workflows_exports;