@agentic-surfaces/server 0.1.28 → 0.1.29

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.
@@ -4,8 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>agentic-surfaces — workflow editor</title>
7
- <script type="module" crossorigin src="/assets/index-C7_sNeWL.js"></script>
8
- <link rel="stylesheet" crossorigin href="/assets/index-CQrXDTe4.css">
7
+ <script type="module" crossorigin src="/assets/index-kTJFLfkQ.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-HQKltIcN.css">
9
9
  </head>
10
10
  <body>
11
11
  <div id="root"></div>
package/dist/http.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import http from "node:http";
2
- import type { Workflow, AgentDefinition } from "@agentic-surfaces/core";
2
+ import type { Workflow, AgentDefinition, PlanUsage } from "@agentic-surfaces/core";
3
3
  import type { StreamingObserver } from "./streaming-observer.js";
4
4
  /** Minimal run record kept in-memory for the /api/runs endpoint. */
5
5
  export interface RunRecord {
@@ -54,6 +54,8 @@ export interface ServerOptions {
54
54
  pause(): void;
55
55
  resume(): void;
56
56
  };
57
+ /** Best-effort claude.ai plan usage provider, surfaced (cached) at GET /api/usage. */
58
+ planUsage?: () => Promise<PlanUsage | null>;
57
59
  }
58
60
  /** Build an http.Server that serves the workflow-engine API and optional static files. */
59
61
  export declare function createServer(opts: ServerOptions): http.Server;
package/dist/http.js CHANGED
@@ -26,8 +26,26 @@ function writeEvent(res, event) {
26
26
  }
27
27
  /** Build an http.Server that serves the workflow-engine API and optional static files. */
28
28
  export function createServer(opts) {
29
- const { observer, workflows = [], staticDir, onRun, config, agents = [], cache, pause } = opts;
29
+ const { observer, workflows = [], staticDir, onRun, config, agents = [], cache, pause, planUsage } = opts;
30
30
  const workflowByName = new Map(workflows.map((w) => [w.name, w]));
31
+ // Cache plan usage briefly — the experimental SDK call spins up a session, so don't hit it per request.
32
+ let usageCache = null;
33
+ const PLAN_USAGE_TTL_MS = 5 * 60_000;
34
+ async function getCachedPlanUsage() {
35
+ if (!planUsage)
36
+ return null;
37
+ if (usageCache && Date.now() - usageCache.at < PLAN_USAGE_TTL_MS)
38
+ return usageCache.data;
39
+ let data = null;
40
+ try {
41
+ data = await planUsage();
42
+ }
43
+ catch {
44
+ data = null;
45
+ }
46
+ usageCache = { data, at: Date.now() };
47
+ return data;
48
+ }
31
49
  // In-memory run registry — populated by listening to the observer.
32
50
  const runs = new Map();
33
51
  let runCounter = 0;
@@ -145,6 +163,12 @@ export function createServer(opts) {
145
163
  json(res, { paused: pause ? pause.isPaused() : false, controllable: Boolean(pause) });
146
164
  return;
147
165
  }
166
+ // Best-effort claude.ai plan usage (session + weekly windows) for the spend/balance box.
167
+ if (pathname === "/api/usage" && (req.method === "GET" || req.method === undefined)) {
168
+ const data = await getCachedPlanUsage();
169
+ json(res, data ?? { available: false });
170
+ return;
171
+ }
148
172
  if (pathname === "/api/pause" && req.method === "POST") {
149
173
  if (!pause) {
150
174
  json(res, { error: "pause not available" }, 405);
package/dist/serve.d.ts CHANGED
@@ -44,6 +44,8 @@ export interface ServeOptions {
44
44
  pause(): void;
45
45
  resume(): void;
46
46
  };
47
+ /** Best-effort claude.ai plan usage provider, surfaced (cached) at GET /api/usage. */
48
+ planUsage?: () => Promise<import("@agentic-surfaces/core").PlanUsage | null>;
47
49
  }
48
50
  /**
49
51
  * Locate the built editor assets to serve. Checks, in order:
package/dist/serve.js CHANGED
@@ -38,6 +38,7 @@ export function serve(opts = {}) {
38
38
  agents: opts.agents,
39
39
  cache: opts.cache,
40
40
  pause: opts.pause,
41
+ planUsage: opts.planUsage,
41
42
  });
42
43
  server.listen(port, host, () => {
43
44
  console.log(`[flow-server] listening on http://${host}:${port}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentic-surfaces/server",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -22,7 +22,7 @@
22
22
  "README.md"
23
23
  ],
24
24
  "dependencies": {
25
- "@agentic-surfaces/core": "0.1.28"
25
+ "@agentic-surfaces/core": "0.1.29"
26
26
  },
27
27
  "repository": {
28
28
  "type": "git",