@arbidocs/sdk 0.4.104 → 0.4.105

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
@@ -4230,6 +4230,38 @@ async function resolveWorkspace(store, workspaceOpt) {
4230
4230
  };
4231
4231
  }
4232
4232
 
4233
+ // src/format.ts
4234
+ function formatFileSize(bytes, fallback = "N/A") {
4235
+ if (bytes === null || bytes === void 0) return fallback;
4236
+ if (bytes < 1024) return `${bytes} B`;
4237
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
4238
+ if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
4239
+ return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
4240
+ }
4241
+ function formatUserName(user) {
4242
+ if (!user) return "";
4243
+ return [user.given_name, user.family_name].filter(Boolean).join(" ");
4244
+ }
4245
+ function formatGbp(gbp) {
4246
+ const safe = typeof gbp === "number" && Number.isFinite(gbp) ? gbp : 0;
4247
+ if (safe > 0 && safe < 5e-3) return "<\xA30.01";
4248
+ const rounded = Math.round(safe * 100) / 100;
4249
+ const whole = Number.isInteger(rounded);
4250
+ const digits = Math.abs(rounded).toLocaleString("en-GB", {
4251
+ minimumFractionDigits: whole ? 0 : 2,
4252
+ maximumFractionDigits: whole ? 0 : 2
4253
+ });
4254
+ return `${rounded < 0 ? "-" : ""}\xA3${digits}`;
4255
+ }
4256
+ var DEFAULT_AI_USD_PER_GBP = 1;
4257
+ function usdToGbp(usd, usdPerGbp = DEFAULT_AI_USD_PER_GBP) {
4258
+ return usd / usdPerGbp;
4259
+ }
4260
+ function formatGbpPerMillionTokens(costPerToken) {
4261
+ if (!costPerToken) return null;
4262
+ return formatGbp(usdToGbp(costPerToken * 1e6));
4263
+ }
4264
+
4233
4265
  // src/sse.ts
4234
4266
  function humanizeStep(identifier) {
4235
4267
  const spaced = identifier.replace(/[_-]+/g, " ").trim();
@@ -4532,8 +4564,10 @@ function formatStreamSummary(result, elapsedTime) {
4532
4564
  const used = result.context.all_llm_calls?.last_input_tokens ?? result.context.total_input;
4533
4565
  parts.push(`${used.toLocaleString()}/${result.context.context_window.toLocaleString()} context`);
4534
4566
  }
4535
- if (result.context?.credits_spent != null && result.context.credit_budget != null) {
4536
- parts.push(`${result.context.credits_spent.toFixed(2)}/${result.context.credit_budget} credits`);
4567
+ if (result.context?.spent_gbp != null && result.context.budget_gbp != null) {
4568
+ parts.push(
4569
+ `${formatGbp(result.context.spent_gbp)}/${formatGbp(result.context.budget_gbp)} AI usage`
4570
+ );
4537
4571
  }
4538
4572
  if (elapsedTime != null) {
4539
4573
  parts.push(`${elapsedTime.toFixed(1)}s`);
@@ -4799,19 +4833,6 @@ function formatWsMessage(msg) {
4799
4833
  return { text: `${msg.type}`, level: "info" };
4800
4834
  }
4801
4835
 
4802
- // src/format.ts
4803
- function formatFileSize(bytes, fallback = "N/A") {
4804
- if (bytes === null || bytes === void 0) return fallback;
4805
- if (bytes < 1024) return `${bytes} B`;
4806
- if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
4807
- if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
4808
- return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
4809
- }
4810
- function formatUserName(user) {
4811
- if (!user) return "";
4812
- return [user.given_name, user.family_name].filter(Boolean).join(" ");
4813
- }
4814
-
4815
4836
  // src/citations.ts
4816
4837
  function resolveCitations(metadata) {
4817
4838
  if (!metadata?.tools) return [];
@@ -8240,7 +8261,7 @@ var Arbi = class {
8240
8261
  update: (projectExtId, body) => updateProject(this.requireClient(), projectExtId, body),
8241
8262
  /** The project's stage and budget changes, newest first. */
8242
8263
  events: (projectExtId, options) => listProjectEvents(this.requireClient(), projectExtId, options),
8243
- /** The project's spend by conversation in a billing period (credits). */
8264
+ /** The project's spend by conversation in a billing period (£). */
8244
8265
  usageByConversation: (projectExtId, monthsBack) => getProjectConversationUsage(this.requireClient(), projectExtId, monthsBack),
8245
8266
  refresh: (projectExtId) => refreshProject(this.requireClient(), projectExtId),
8246
8267
  /** AI usage + spend breakdown for a project's billing period. */
@@ -8278,7 +8299,7 @@ var Arbi = class {
8278
8299
  this.profileListeners.add(listener);
8279
8300
  return () => this.profileListeners.delete(listener);
8280
8301
  },
8281
- /** Today's deployment-wide credit spend for the current user. */
8302
+ /** Today's deployment-wide AI usage (£) for the current user. */
8282
8303
  usageToday: () => getUserUsageToday(this.requireClient()),
8283
8304
  /**
8284
8305
  * The signed-in user from the server, with `can_create_projects`: false on deployments where
@@ -8536,7 +8557,7 @@ var Arbi = class {
8536
8557
  sendBackStep: (conversationId, step, options) => sendBackStep(this.requireClient(), conversationId, step, options),
8537
8558
  /** A stepped run's steps, signals, linked runs and send-backs, and what it waits for. */
8538
8559
  runProgress: (conversationId) => getRunProgress(this.requireClient(), conversationId),
8539
- /** What the conversation's AI work cost: by step, run, model, agent and feature (credits). */
8560
+ /** What the conversation's AI work cost: by step, run, model, agent and feature (£). */
8540
8561
  usage: (conversationId) => getConversationUsage(this.requireClient(), conversationId),
8541
8562
  /** Notify people about a conversation (each gets a notification); resolves with who was. */
8542
8563
  notify: (conversationId, userIds) => notifyConversation(this.requireClient(), conversationId, userIds),
@@ -10037,6 +10058,7 @@ exports.ArbiApiError = ArbiApiError;
10037
10058
  exports.ArbiError = ArbiError;
10038
10059
  exports.ArbiSessionExpiredError = ArbiSessionExpiredError;
10039
10060
  exports.ClaudeOrchestrator = ClaudeOrchestrator;
10061
+ exports.DEFAULT_AI_USD_PER_GBP = DEFAULT_AI_USD_PER_GBP;
10040
10062
  exports.DOC_TERMINAL_STATUSES = DOC_TERMINAL_STATUSES;
10041
10063
  exports.FileConfigStore = FileConfigStore;
10042
10064
  exports.OpenClawOrchestrator = OpenClawOrchestrator;
@@ -10071,6 +10093,8 @@ exports.files = files_exports;
10071
10093
  exports.filterSkills = filterSkills;
10072
10094
  exports.formatAgentStepLabel = formatAgentStepLabel;
10073
10095
  exports.formatFileSize = formatFileSize;
10096
+ exports.formatGbp = formatGbp;
10097
+ exports.formatGbpPerMillionTokens = formatGbpPerMillionTokens;
10074
10098
  exports.formatItemLabel = formatItemLabel;
10075
10099
  exports.formatStreamSummary = formatStreamSummary;
10076
10100
  exports.formatUserName = formatUserName;
@@ -10111,6 +10135,7 @@ exports.streamSSE = streamSSE;
10111
10135
  exports.stripCitationMarkdown = stripCitationMarkdown;
10112
10136
  exports.summarizeCitations = summarizeCitations;
10113
10137
  exports.tags = tags_exports;
10138
+ exports.usdToGbp = usdToGbp;
10114
10139
  exports.work = work_exports;
10115
10140
  exports.workflowSteps = workflow_steps_exports;
10116
10141
  exports.workflows = workflows_exports;