@agentic-surfaces/server 0.1.27 → 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.
- package/dist/editor/assets/{index-CQwBaAEq.css → index-HQKltIcN.css} +1 -1
- package/dist/editor/assets/index-kTJFLfkQ.js +298 -0
- package/dist/editor/index.html +2 -2
- package/dist/http.d.ts +4 -1
- package/dist/http.js +25 -1
- package/dist/serve.d.ts +3 -0
- package/dist/serve.js +1 -0
- package/dist/streaming-observer.d.ts +7 -5
- package/dist/streaming-observer.js +10 -10
- package/package.json +2 -2
- package/dist/editor/assets/index-CS8llYsy.js +0 -298
package/dist/editor/index.html
CHANGED
|
@@ -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-
|
|
8
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
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 {
|
|
@@ -29,6 +29,7 @@ export interface ServerOptions {
|
|
|
29
29
|
effort?: string;
|
|
30
30
|
};
|
|
31
31
|
version?: string;
|
|
32
|
+
atlassianSite?: string;
|
|
32
33
|
};
|
|
33
34
|
/** File-based agent definitions, surfaced at GET /api/agents (for the node detail view). */
|
|
34
35
|
agents?: AgentDefinition[];
|
|
@@ -53,6 +54,8 @@ export interface ServerOptions {
|
|
|
53
54
|
pause(): void;
|
|
54
55
|
resume(): void;
|
|
55
56
|
};
|
|
57
|
+
/** Best-effort claude.ai plan usage provider, surfaced (cached) at GET /api/usage. */
|
|
58
|
+
planUsage?: () => Promise<PlanUsage | null>;
|
|
56
59
|
}
|
|
57
60
|
/** Build an http.Server that serves the workflow-engine API and optional static files. */
|
|
58
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
|
@@ -19,6 +19,7 @@ export interface ServeOptions {
|
|
|
19
19
|
effort?: string;
|
|
20
20
|
};
|
|
21
21
|
version?: string;
|
|
22
|
+
atlassianSite?: string;
|
|
22
23
|
};
|
|
23
24
|
/** Agent definitions surfaced at GET /api/agents. */
|
|
24
25
|
agents?: AgentDefinition[];
|
|
@@ -43,6 +44,8 @@ export interface ServeOptions {
|
|
|
43
44
|
pause(): void;
|
|
44
45
|
resume(): void;
|
|
45
46
|
};
|
|
47
|
+
/** Best-effort claude.ai plan usage provider, surfaced (cached) at GET /api/usage. */
|
|
48
|
+
planUsage?: () => Promise<import("@agentic-surfaces/core").PlanUsage | null>;
|
|
46
49
|
}
|
|
47
50
|
/**
|
|
48
51
|
* Locate the built editor assets to serve. Checks, in order:
|
package/dist/serve.js
CHANGED
|
@@ -3,6 +3,8 @@ import type { RunObserver } from "@agentic-surfaces/core";
|
|
|
3
3
|
export interface RunEvent {
|
|
4
4
|
type: "run:start" | "node:start" | "node:finish" | "node:activity" | "run:finish";
|
|
5
5
|
workflow: string;
|
|
6
|
+
/** Which run this event belongs to (from the executor) — lets the UI separate concurrent runs. */
|
|
7
|
+
runId?: string;
|
|
6
8
|
/** Short human label for the content this run is processing (from the trigger payload). */
|
|
7
9
|
label?: string;
|
|
8
10
|
nodeId?: string;
|
|
@@ -33,9 +35,9 @@ export declare class StreamingObserver implements RunObserver {
|
|
|
33
35
|
getEvents(): readonly RunEvent[];
|
|
34
36
|
/** Clear the event buffer (useful between test runs). */
|
|
35
37
|
clear(): void;
|
|
36
|
-
onRunStart(workflow: string, payload?: unknown): void;
|
|
37
|
-
onNodeStart(nodeId: string): void;
|
|
38
|
-
onNodeActivity(nodeId: string, activity: unknown): void;
|
|
39
|
-
onNodeFinish(nodeId: string, status: "success" | "failed", meta?: unknown): void;
|
|
40
|
-
onRunFinish(workflow: string, status: "success" | "failed"): void;
|
|
38
|
+
onRunStart(workflow: string, payload?: unknown, runId?: string): void;
|
|
39
|
+
onNodeStart(nodeId: string, runId?: string): void;
|
|
40
|
+
onNodeActivity(nodeId: string, activity: unknown, runId?: string): void;
|
|
41
|
+
onNodeFinish(nodeId: string, status: "success" | "failed", meta?: unknown, runId?: string): void;
|
|
42
|
+
onRunFinish(workflow: string, status: "success" | "failed", runId?: string): void;
|
|
41
43
|
}
|
|
@@ -82,18 +82,18 @@ export class StreamingObserver {
|
|
|
82
82
|
this.events = [];
|
|
83
83
|
}
|
|
84
84
|
// ── RunObserver interface ──────────────────────────────────────────────────
|
|
85
|
-
onRunStart(workflow, payload) {
|
|
86
|
-
this.emit({ type: "run:start", workflow, label: runLabel(payload), ts: Date.now() });
|
|
85
|
+
onRunStart(workflow, payload, runId) {
|
|
86
|
+
this.emit({ type: "run:start", workflow, runId, label: runLabel(payload), ts: Date.now() });
|
|
87
87
|
}
|
|
88
|
-
onNodeStart(nodeId) {
|
|
88
|
+
onNodeStart(nodeId, runId) {
|
|
89
89
|
// workflow name is unknown at this call-site in the core interface;
|
|
90
90
|
// emit a placeholder so the shape stays consistent.
|
|
91
|
-
this.emit({ type: "node:start", workflow: "", nodeId, ts: Date.now() });
|
|
91
|
+
this.emit({ type: "node:start", workflow: "", runId, nodeId, ts: Date.now() });
|
|
92
92
|
}
|
|
93
|
-
onNodeActivity(nodeId, activity) {
|
|
94
|
-
this.emit({ type: "node:activity", workflow: "", nodeId, meta: activity, ts: Date.now() });
|
|
93
|
+
onNodeActivity(nodeId, activity, runId) {
|
|
94
|
+
this.emit({ type: "node:activity", workflow: "", runId, nodeId, meta: activity, ts: Date.now() });
|
|
95
95
|
}
|
|
96
|
-
onNodeFinish(nodeId, status, meta) {
|
|
96
|
+
onNodeFinish(nodeId, status, meta, runId) {
|
|
97
97
|
// Normalize meta to { output?, error? }. `output` is the node's result (capped for the
|
|
98
98
|
// wire) so the UI can show what each node fetched/produced; `error` carries failures.
|
|
99
99
|
// `usage` is lifted out as a structured field (agent nodes only) so the UI can sum a run total.
|
|
@@ -103,9 +103,9 @@ export class StreamingObserver {
|
|
|
103
103
|
output: "output" in m ? previewOutput(m.output) : undefined,
|
|
104
104
|
usage: extractUsage(m.output),
|
|
105
105
|
};
|
|
106
|
-
this.emit({ type: "node:finish", workflow: "", nodeId, status, meta: wireMeta, ts: Date.now() });
|
|
106
|
+
this.emit({ type: "node:finish", workflow: "", runId, nodeId, status, meta: wireMeta, ts: Date.now() });
|
|
107
107
|
}
|
|
108
|
-
onRunFinish(workflow, status) {
|
|
109
|
-
this.emit({ type: "run:finish", workflow, status, ts: Date.now() });
|
|
108
|
+
onRunFinish(workflow, status, runId) {
|
|
109
|
+
this.emit({ type: "run:finish", workflow, runId, status, ts: Date.now() });
|
|
110
110
|
}
|
|
111
111
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentic-surfaces/server",
|
|
3
|
-
"version": "0.1.
|
|
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.
|
|
25
|
+
"@agentic-surfaces/core": "0.1.29"
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|