@open-autonomy/sdk 2.3.0 → 2.3.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/rails.ts +19 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-autonomy/sdk",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "The Open Autonomy SDK: the roadmap model and its codec, the development-stream client (sessions, turns, updates), and the key helpers. Everything it does is a documented HTTP wire any language can speak without it.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/src/rails.ts CHANGED
@@ -71,3 +71,22 @@ export function parseModelsBound(yaml: string): string[] {
71
71
  }
72
72
  return out;
73
73
  }
74
+
75
+ // The most the project's funds may spend on the model rail in a day (UTC), from the same file:
76
+ // spend:
77
+ // daily_usd_cents: 500
78
+ // 0 or absent: no bound of the project's own beyond the platform's global rail.
79
+ export function parseSpendBound(yaml: string): { daily_usd_cents: number } {
80
+ let block = '';
81
+ let daily = 0;
82
+ for (const raw of yaml.split('\n')) {
83
+ const line = raw.replace(/\s+#.*$/, '').trimEnd();
84
+ if (!line.trim() || line.trim().startsWith('#')) continue;
85
+ const top = /^([a-z_]+):\s*(.*)$/.exec(line);
86
+ if (top) { block = top[2] === '' ? top[1] : ''; continue; }
87
+ if (block !== 'spend') continue;
88
+ const kv = /^\s+daily_usd_cents:\s*(\d+)\s*$/.exec(line);
89
+ if (kv) daily = Math.max(0, Math.floor(Number(kv[1])));
90
+ }
91
+ return { daily_usd_cents: daily };
92
+ }