@seawork/server 1.0.19 → 1.0.20-rc.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.
- package/dist/scripts/supervisor-entrypoint.js +169 -0
- package/dist/scripts/supervisor-entrypoint.js.map +1 -1
- package/dist/scripts/supervisor.js +60 -10
- package/dist/scripts/supervisor.js.map +1 -1
- package/dist/server/client/daemon-client.d.ts +27 -1
- package/dist/server/client/daemon-client.d.ts.map +1 -1
- package/dist/server/client/daemon-client.js +45 -2
- package/dist/server/client/daemon-client.js.map +1 -1
- package/dist/server/server/agent/agent-manager.d.ts.map +1 -1
- package/dist/server/server/agent/agent-manager.js +58 -3
- package/dist/server/server/agent/agent-manager.js.map +1 -1
- package/dist/server/server/agent/agent-sdk-types.d.ts +1 -0
- package/dist/server/server/agent/agent-sdk-types.d.ts.map +1 -1
- package/dist/server/server/agent/providers/claude-agent.d.ts.map +1 -1
- package/dist/server/server/agent/providers/claude-agent.js +27 -9
- package/dist/server/server/agent/providers/claude-agent.js.map +1 -1
- package/dist/server/server/agent/providers/codex-app-server-agent.d.ts.map +1 -1
- package/dist/server/server/agent/providers/codex-app-server-agent.js +20 -5
- package/dist/server/server/agent/providers/codex-app-server-agent.js.map +1 -1
- package/dist/server/server/bootstrap.d.ts.map +1 -1
- package/dist/server/server/bootstrap.js +10 -0
- package/dist/server/server/bootstrap.js.map +1 -1
- package/dist/server/server/crash-report.d.ts +12 -0
- package/dist/server/server/crash-report.d.ts.map +1 -0
- package/dist/server/server/crash-report.js +217 -0
- package/dist/server/server/crash-report.js.map +1 -0
- package/dist/server/server/editor-targets.d.ts +3 -1
- package/dist/server/server/editor-targets.d.ts.map +1 -1
- package/dist/server/server/editor-targets.js +51 -2
- package/dist/server/server/editor-targets.js.map +1 -1
- package/dist/server/server/exports.d.ts +1 -0
- package/dist/server/server/exports.d.ts.map +1 -1
- package/dist/server/server/exports.js +5 -0
- package/dist/server/server/exports.js.map +1 -1
- package/dist/server/server/index.js +20 -2
- package/dist/server/server/index.js.map +1 -1
- package/dist/server/server/latency-proxy.d.ts +39 -0
- package/dist/server/server/latency-proxy.d.ts.map +1 -0
- package/dist/server/server/latency-proxy.js +148 -0
- package/dist/server/server/latency-proxy.js.map +1 -0
- package/dist/server/server/latency-tracker.d.ts +120 -0
- package/dist/server/server/latency-tracker.d.ts.map +1 -0
- package/dist/server/server/latency-tracker.js +253 -0
- package/dist/server/server/latency-tracker.js.map +1 -0
- package/dist/server/server/session.d.ts +1 -0
- package/dist/server/server/session.d.ts.map +1 -1
- package/dist/server/server/session.js +13 -1
- package/dist/server/server/session.js.map +1 -1
- package/dist/server/shared/messages.d.ts +540 -0
- package/dist/server/shared/messages.d.ts.map +1 -1
- package/dist/server/shared/messages.js +26 -0
- package/dist/server/shared/messages.js.map +1 -1
- package/dist/src/server/bug-report-redact.js +145 -0
- package/dist/src/server/bug-report-redact.js.map +1 -0
- package/dist/src/server/crash-report.js +217 -0
- package/dist/src/server/crash-report.js.map +1 -0
- package/dist/src/server/daemon-version.js +22 -0
- package/dist/src/server/daemon-version.js.map +1 -0
- package/dist/src/server/package-version.js +46 -0
- package/dist/src/server/package-version.js.map +1 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EA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,EAAE,GAAG,CAAC,CAAC;AACzC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type pino from "pino";
|
|
2
|
+
/**
|
|
3
|
+
* Local transparent CONNECT proxy used in latency debug mode.
|
|
4
|
+
*
|
|
5
|
+
* It does NOT decrypt TLS, so HTTP boundaries are invisible. Each upstream
|
|
6
|
+
* connection is timestamped at two TCP-level boundaries:
|
|
7
|
+
* - first client→upstream byte (`providerRequestSentAt`): when the
|
|
8
|
+
* provider SDK puts its TLS ClientHello on the wire, after queueing /
|
|
9
|
+
* DNS / connection pool overhead inside the SDK.
|
|
10
|
+
* - first upstream→client byte (`gatewayFirstByteAt`): the upstream's
|
|
11
|
+
* TLS ServerHello — NOT the gateway HTTP TTFB. The span between these
|
|
12
|
+
* two timestamps is TLS handshake RTT; gateway processing and model
|
|
13
|
+
* generation are then bundled into the remaining "ServerHello →
|
|
14
|
+
* turn_completed" interval. The UI labels these as `tls` and `model`.
|
|
15
|
+
*
|
|
16
|
+
* Attribution: the proxy hands the two timestamps to LatencyTracker, which
|
|
17
|
+
* only records them when there is exactly one active turn (so we never
|
|
18
|
+
* misattribute under concurrent turns). See latency-tracker.ts.
|
|
19
|
+
*
|
|
20
|
+
* Only started when the daemon was launched with SEAWORK_LATENCY_PROXY=1;
|
|
21
|
+
* kept running for the lifetime of the daemon process.
|
|
22
|
+
*/
|
|
23
|
+
export declare class LatencyProxy {
|
|
24
|
+
private readonly logger;
|
|
25
|
+
private server;
|
|
26
|
+
private port;
|
|
27
|
+
constructor(logger: pino.Logger);
|
|
28
|
+
start(): Promise<number>;
|
|
29
|
+
getProxyUrl(): string | null;
|
|
30
|
+
stop(): Promise<void>;
|
|
31
|
+
private handleConnect;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Lazy-start a single shared proxy and return its URL. Subsequent calls
|
|
35
|
+
* resolve to the same instance. Safe to call from any provider hook.
|
|
36
|
+
*/
|
|
37
|
+
export declare function ensureLatencyProxyUrl(logger: pino.Logger): Promise<string>;
|
|
38
|
+
export declare function getLatencyProxyUrlSync(): string | null;
|
|
39
|
+
//# sourceMappingURL=latency-proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"latency-proxy.d.ts","sourceRoot":"","sources":["../../../src/server/latency-proxy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAI7B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,YAAY;IAIX,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,IAAI,CAAuB;gBAEN,MAAM,EAAE,IAAI,CAAC,MAAM;IAE1C,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAqC9B,WAAW,IAAI,MAAM,GAAG,IAAI;IAItB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B,OAAO,CAAC,aAAa;CAsDtB;AAKD;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAWhF;AAED,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAEtD"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { createServer } from "node:http";
|
|
2
|
+
import { connect } from "node:net";
|
|
3
|
+
import { latencyTracker } from "./latency-tracker.js";
|
|
4
|
+
/**
|
|
5
|
+
* Local transparent CONNECT proxy used in latency debug mode.
|
|
6
|
+
*
|
|
7
|
+
* It does NOT decrypt TLS, so HTTP boundaries are invisible. Each upstream
|
|
8
|
+
* connection is timestamped at two TCP-level boundaries:
|
|
9
|
+
* - first client→upstream byte (`providerRequestSentAt`): when the
|
|
10
|
+
* provider SDK puts its TLS ClientHello on the wire, after queueing /
|
|
11
|
+
* DNS / connection pool overhead inside the SDK.
|
|
12
|
+
* - first upstream→client byte (`gatewayFirstByteAt`): the upstream's
|
|
13
|
+
* TLS ServerHello — NOT the gateway HTTP TTFB. The span between these
|
|
14
|
+
* two timestamps is TLS handshake RTT; gateway processing and model
|
|
15
|
+
* generation are then bundled into the remaining "ServerHello →
|
|
16
|
+
* turn_completed" interval. The UI labels these as `tls` and `model`.
|
|
17
|
+
*
|
|
18
|
+
* Attribution: the proxy hands the two timestamps to LatencyTracker, which
|
|
19
|
+
* only records them when there is exactly one active turn (so we never
|
|
20
|
+
* misattribute under concurrent turns). See latency-tracker.ts.
|
|
21
|
+
*
|
|
22
|
+
* Only started when the daemon was launched with SEAWORK_LATENCY_PROXY=1;
|
|
23
|
+
* kept running for the lifetime of the daemon process.
|
|
24
|
+
*/
|
|
25
|
+
export class LatencyProxy {
|
|
26
|
+
constructor(logger) {
|
|
27
|
+
this.logger = logger;
|
|
28
|
+
this.server = null;
|
|
29
|
+
this.port = null;
|
|
30
|
+
}
|
|
31
|
+
async start() {
|
|
32
|
+
if (this.port !== null)
|
|
33
|
+
return this.port;
|
|
34
|
+
const server = createServer();
|
|
35
|
+
server.on("connect", (req, clientSocket, head) => {
|
|
36
|
+
this.handleConnect(req, clientSocket, head);
|
|
37
|
+
});
|
|
38
|
+
// Plain HTTP is uncommon for gateways but handle it defensively so a
|
|
39
|
+
// misrouted SDK request doesn't hang.
|
|
40
|
+
server.on("request", (_req, res) => {
|
|
41
|
+
res.writeHead(501, { "content-type": "text/plain" });
|
|
42
|
+
res.end("latency-proxy: only HTTPS CONNECT supported");
|
|
43
|
+
});
|
|
44
|
+
server.on("error", (err) => {
|
|
45
|
+
this.logger.warn({ err }, "latency-proxy server error");
|
|
46
|
+
});
|
|
47
|
+
await new Promise((resolve, reject) => {
|
|
48
|
+
server.once("error", reject);
|
|
49
|
+
server.listen({ host: "127.0.0.1", port: 0 }, () => {
|
|
50
|
+
server.off("error", reject);
|
|
51
|
+
resolve();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
const address = server.address();
|
|
55
|
+
if (!address || typeof address === "string") {
|
|
56
|
+
throw new Error("latency-proxy: failed to acquire listening port");
|
|
57
|
+
}
|
|
58
|
+
this.server = server;
|
|
59
|
+
this.port = address.port;
|
|
60
|
+
this.logger.info({ port: this.port }, "latency-proxy listening");
|
|
61
|
+
return this.port;
|
|
62
|
+
}
|
|
63
|
+
getProxyUrl() {
|
|
64
|
+
return this.port === null ? null : `http://127.0.0.1:${this.port}`;
|
|
65
|
+
}
|
|
66
|
+
async stop() {
|
|
67
|
+
const server = this.server;
|
|
68
|
+
if (!server)
|
|
69
|
+
return;
|
|
70
|
+
await new Promise((resolve) => server.close(() => resolve()));
|
|
71
|
+
this.server = null;
|
|
72
|
+
this.port = null;
|
|
73
|
+
}
|
|
74
|
+
handleConnect(req, clientSocket, head) {
|
|
75
|
+
const target = req.url ?? "";
|
|
76
|
+
const [hostname, portStr] = target.split(":");
|
|
77
|
+
const port = Number(portStr) || 443;
|
|
78
|
+
if (!hostname) {
|
|
79
|
+
clientSocket.destroy();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
let requestSentAt;
|
|
83
|
+
let firstByteAt;
|
|
84
|
+
const flushIfReady = () => {
|
|
85
|
+
if (requestSentAt !== undefined && firstByteAt !== undefined) {
|
|
86
|
+
latencyTracker.recordProxyTiming({
|
|
87
|
+
requestSent: requestSentAt,
|
|
88
|
+
firstByte: firstByteAt,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const upstream = connect({ host: hostname, port }, () => {
|
|
93
|
+
clientSocket.write("HTTP/1.1 200 Connection Established\r\n\r\n");
|
|
94
|
+
if (head && head.length > 0) {
|
|
95
|
+
if (requestSentAt === undefined)
|
|
96
|
+
requestSentAt = Date.now();
|
|
97
|
+
upstream.write(head);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
clientSocket.on("data", (chunk) => {
|
|
101
|
+
if (requestSentAt === undefined && chunk.length > 0) {
|
|
102
|
+
requestSentAt = Date.now();
|
|
103
|
+
}
|
|
104
|
+
upstream.write(chunk);
|
|
105
|
+
});
|
|
106
|
+
upstream.on("data", (chunk) => {
|
|
107
|
+
if (firstByteAt === undefined && chunk.length > 0) {
|
|
108
|
+
firstByteAt = Date.now();
|
|
109
|
+
flushIfReady();
|
|
110
|
+
}
|
|
111
|
+
clientSocket.write(chunk);
|
|
112
|
+
});
|
|
113
|
+
const cleanup = (err) => {
|
|
114
|
+
if (err) {
|
|
115
|
+
this.logger.debug({ err, hostname, port }, "latency-proxy tunnel error");
|
|
116
|
+
}
|
|
117
|
+
clientSocket.destroy();
|
|
118
|
+
upstream.destroy();
|
|
119
|
+
};
|
|
120
|
+
clientSocket.on("end", () => upstream.end());
|
|
121
|
+
upstream.on("end", () => clientSocket.end());
|
|
122
|
+
clientSocket.on("error", cleanup);
|
|
123
|
+
upstream.on("error", cleanup);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
let sharedProxy = null;
|
|
127
|
+
let startingPromise = null;
|
|
128
|
+
/**
|
|
129
|
+
* Lazy-start a single shared proxy and return its URL. Subsequent calls
|
|
130
|
+
* resolve to the same instance. Safe to call from any provider hook.
|
|
131
|
+
*/
|
|
132
|
+
export async function ensureLatencyProxyUrl(logger) {
|
|
133
|
+
if (sharedProxy?.getProxyUrl())
|
|
134
|
+
return sharedProxy.getProxyUrl();
|
|
135
|
+
if (!startingPromise) {
|
|
136
|
+
const proxy = new LatencyProxy(logger.child({ component: "latency-proxy" }));
|
|
137
|
+
startingPromise = proxy.start().then(() => {
|
|
138
|
+
sharedProxy = proxy;
|
|
139
|
+
return proxy;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
const proxy = await startingPromise;
|
|
143
|
+
return proxy.getProxyUrl();
|
|
144
|
+
}
|
|
145
|
+
export function getLatencyProxyUrlSync() {
|
|
146
|
+
return sharedProxy?.getProxyUrl() ?? null;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=latency-proxy.js.map
|
|
@@ -0,0 +1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AE,OAAO,WAAW,CAAC,WAAW,EAAY,CAAC;IAC3E,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC;QAC7E,eAAe,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YACxC,WAAW,GAAG,KAAK,CAAC;YACpB,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC;IACpC,OAAO,KAAK,CAAC,WAAW,EAAY,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,OAAO,WAAW,EAAE,WAAW,EAAE,IAAI,IAAI,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { LatencyBreakdown } from "../shared/messages.js";
|
|
2
|
+
/**
|
|
3
|
+
* Per-turn latency tracker. Active only when the user has enabled latency
|
|
4
|
+
* debug mode on the client (which causes `clientSentAt` to be set on the
|
|
5
|
+
* outgoing `send_agent_message_request`).
|
|
6
|
+
*
|
|
7
|
+
* Trackers are keyed by `turnId` because:
|
|
8
|
+
* - one agent can be replaced/cancelled and a new turnId issued before the
|
|
9
|
+
* old one finishes, so agentId is not unique-per-turn;
|
|
10
|
+
* - the wire `turn_completed` event carries turnId, letting the client
|
|
11
|
+
* attach the breakdown to exactly the right assistant message.
|
|
12
|
+
*
|
|
13
|
+
* Proxy attribution (providerRequestSentAt / gatewayFirstByteAt) is only
|
|
14
|
+
* recorded when there is exactly one active turn at the moment a CONNECT
|
|
15
|
+
* arrives. With multiple concurrent turns the proxy cannot distinguish which
|
|
16
|
+
* turn a given socket belongs to (loopback gives us no useful 5-tuple
|
|
17
|
+
* information), so we leave those two timestamps undefined rather than
|
|
18
|
+
* misattribute them. The client renders a partial breakdown in that case.
|
|
19
|
+
*/
|
|
20
|
+
declare class LatencyTracker {
|
|
21
|
+
private readonly turns;
|
|
22
|
+
/** agentId → turnId for currently-tracked turns. */
|
|
23
|
+
private readonly agentToTurn;
|
|
24
|
+
/**
|
|
25
|
+
* Per-agent staging area: timestamps captured before the provider has
|
|
26
|
+
* issued a turnId (session-level receive + dispatch). When agent-manager
|
|
27
|
+
* receives the turnId back from `startTurn`, it calls `promotePending` to
|
|
28
|
+
* move the staged entry under that turnId. Dropped if startTurn fails.
|
|
29
|
+
*/
|
|
30
|
+
private readonly pendingByAgent;
|
|
31
|
+
/**
|
|
32
|
+
* Map of agentId → set of in-flight turnIds (foreground + autonomous),
|
|
33
|
+
* including debug-off turns that do not get a per-turn entry. Needed
|
|
34
|
+
* because the global CONNECT proxy carries traffic from every spawned
|
|
35
|
+
* provider CLI: if a debug-off turn is in flight alongside a single
|
|
36
|
+
* debug-on turn, the proxy must not attribute the debug-off turn's
|
|
37
|
+
* CONNECT to the debug-on turn.
|
|
38
|
+
*
|
|
39
|
+
* Indexed by agentId so close/refresh teardown can sweep all turns
|
|
40
|
+
* (foreground + autonomous) belonging to one agent in a single call.
|
|
41
|
+
*
|
|
42
|
+
* Bookkeeping is idempotent: synthetic terminal events fired before any
|
|
43
|
+
* real turn_started (e.g. startTurn() throwing) are no-ops, and turns
|
|
44
|
+
* that vanish without a terminal event can be force-cleared via
|
|
45
|
+
* `forceEndAgentTurns` without skewing the count for other live turns.
|
|
46
|
+
*/
|
|
47
|
+
private readonly agentActiveTurns;
|
|
48
|
+
private globalActiveTurnCount;
|
|
49
|
+
beginPending(agentId: string, clientSentAt: number, daemonReceivedAt: number): void;
|
|
50
|
+
markPendingDispatched(agentId: string, at?: number): void;
|
|
51
|
+
/**
|
|
52
|
+
* Move the staged entry for `agentId` to a turnId-keyed slot once the
|
|
53
|
+
* provider has issued a turnId. No-op if no pending entry exists (debug
|
|
54
|
+
* mode was off for this turn).
|
|
55
|
+
*/
|
|
56
|
+
promotePending(agentId: string, turnId: string): void;
|
|
57
|
+
dropPending(agentId: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* Record proxy-observed gateway timing. The proxy supplies its own
|
|
60
|
+
* timestamps and the tracker decides whether attribution is safe (i.e.
|
|
61
|
+
* unambiguous single in-flight turn). Concurrent turns → silently ignored.
|
|
62
|
+
*/
|
|
63
|
+
recordProxyTiming(at: {
|
|
64
|
+
requestSent: number;
|
|
65
|
+
firstByte: number;
|
|
66
|
+
}): void;
|
|
67
|
+
/**
|
|
68
|
+
* Account for a turn entering the in-flight pool, regardless of whether it
|
|
69
|
+
* carries per-turn latency tracking. Used by the proxy concurrency gate so
|
|
70
|
+
* debug-off turns cannot get their CONNECTs misattributed to a single
|
|
71
|
+
* debug-on turn. No-op if turnId is empty.
|
|
72
|
+
*
|
|
73
|
+
* Should be called as early as the agent-manager learns about the turnId
|
|
74
|
+
* (right after `await agent.session.startTurn(...)` returns), not waiting
|
|
75
|
+
* for the provider's `turn_started` event — the provider's first CONNECT
|
|
76
|
+
* can fire inside that window and the proxy timing must already see the
|
|
77
|
+
* turn counted to avoid being silently dropped. The `turn_started` event
|
|
78
|
+
* still calls this method later; the Set keeps it idempotent.
|
|
79
|
+
*/
|
|
80
|
+
noteTurnStarted(agentId: string, turnId: string | null | undefined): void;
|
|
81
|
+
/**
|
|
82
|
+
* Mirror of `noteTurnStarted` for terminal events. Idempotent — terminal
|
|
83
|
+
* events fired without a matching `noteTurnStarted` (e.g. synthetic
|
|
84
|
+
* turn_failed from a `startTurn` rejection that never produced a real
|
|
85
|
+
* turn_started) are no-ops and cannot decrement the count for another
|
|
86
|
+
* live turn.
|
|
87
|
+
*/
|
|
88
|
+
noteTurnEnded(agentId: string, turnId: string | null | undefined): void;
|
|
89
|
+
/**
|
|
90
|
+
* Force-clear all in-flight entries for an agent whose terminal events
|
|
91
|
+
* will not flow through handleStreamEvent (closeAgent / session refresh
|
|
92
|
+
* paths that unsubscribe before dispatching). Covers:
|
|
93
|
+
* - turns counted in agentActiveTurns (turn_started already fired);
|
|
94
|
+
* - promoted-but-not-yet-started entries in `turns` (pending → promoted
|
|
95
|
+
* by startTurn returning a turnId, but turn_started not yet seen — a
|
|
96
|
+
* real window between agent-manager.ts promote and the provider's
|
|
97
|
+
* first event);
|
|
98
|
+
* - pendingByAgent entries (never reached promotion).
|
|
99
|
+
*/
|
|
100
|
+
forceEndAgentTurns(agentId: string): void;
|
|
101
|
+
/**
|
|
102
|
+
* Pull and clear the breakdown for a completed turn. Stamps
|
|
103
|
+
* `turnCompletedAt`. Returns undefined if no tracker is active for the turn.
|
|
104
|
+
*/
|
|
105
|
+
complete(turnId: string, at?: number): LatencyBreakdown | undefined;
|
|
106
|
+
/** Drop without producing a breakdown (turn_failed / turn_canceled). */
|
|
107
|
+
drop(turnId: string): void;
|
|
108
|
+
/** Resolve agent → currently tracked turnId, if any. */
|
|
109
|
+
turnIdForAgent(agentId: string): string | undefined;
|
|
110
|
+
isActive(turnId: string): boolean;
|
|
111
|
+
activeCount(): number;
|
|
112
|
+
/** Total in-flight turn count across all agents (foreground + autonomous),
|
|
113
|
+
* including debug-off turns. Exposed for tests; the proxy concurrency
|
|
114
|
+
* gate reads it via recordProxyTiming internally. */
|
|
115
|
+
globalCount(): number;
|
|
116
|
+
}
|
|
117
|
+
export declare const latencyTracker: LatencyTracker;
|
|
118
|
+
export declare function summarizeBreakdown(b: LatencyBreakdown): Record<string, number | undefined>;
|
|
119
|
+
export {};
|
|
120
|
+
//# sourceMappingURL=latency-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"latency-tracker.d.ts","sourceRoot":"","sources":["../../../src/server/latency-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAM,cAAc;IAClB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuC;IAC7D,oDAAoD;IACpD,OAAO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AG,OAAO;IAIjC,WAAW,IAAI,MAAM;IAIrB;;0DAEsD;IACtD,WAAW,IAAI,MAAM;CAGtB;AAED,eAAO,MAAM,cAAc,gBAAuB,CAAC;AAEnD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CA+B1F"}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-turn latency tracker. Active only when the user has enabled latency
|
|
3
|
+
* debug mode on the client (which causes `clientSentAt` to be set on the
|
|
4
|
+
* outgoing `send_agent_message_request`).
|
|
5
|
+
*
|
|
6
|
+
* Trackers are keyed by `turnId` because:
|
|
7
|
+
* - one agent can be replaced/cancelled and a new turnId issued before the
|
|
8
|
+
* old one finishes, so agentId is not unique-per-turn;
|
|
9
|
+
* - the wire `turn_completed` event carries turnId, letting the client
|
|
10
|
+
* attach the breakdown to exactly the right assistant message.
|
|
11
|
+
*
|
|
12
|
+
* Proxy attribution (providerRequestSentAt / gatewayFirstByteAt) is only
|
|
13
|
+
* recorded when there is exactly one active turn at the moment a CONNECT
|
|
14
|
+
* arrives. With multiple concurrent turns the proxy cannot distinguish which
|
|
15
|
+
* turn a given socket belongs to (loopback gives us no useful 5-tuple
|
|
16
|
+
* information), so we leave those two timestamps undefined rather than
|
|
17
|
+
* misattribute them. The client renders a partial breakdown in that case.
|
|
18
|
+
*/
|
|
19
|
+
class LatencyTracker {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.turns = new Map();
|
|
22
|
+
/** agentId → turnId for currently-tracked turns. */
|
|
23
|
+
this.agentToTurn = new Map();
|
|
24
|
+
/**
|
|
25
|
+
* Per-agent staging area: timestamps captured before the provider has
|
|
26
|
+
* issued a turnId (session-level receive + dispatch). When agent-manager
|
|
27
|
+
* receives the turnId back from `startTurn`, it calls `promotePending` to
|
|
28
|
+
* move the staged entry under that turnId. Dropped if startTurn fails.
|
|
29
|
+
*/
|
|
30
|
+
this.pendingByAgent = new Map();
|
|
31
|
+
/**
|
|
32
|
+
* Map of agentId → set of in-flight turnIds (foreground + autonomous),
|
|
33
|
+
* including debug-off turns that do not get a per-turn entry. Needed
|
|
34
|
+
* because the global CONNECT proxy carries traffic from every spawned
|
|
35
|
+
* provider CLI: if a debug-off turn is in flight alongside a single
|
|
36
|
+
* debug-on turn, the proxy must not attribute the debug-off turn's
|
|
37
|
+
* CONNECT to the debug-on turn.
|
|
38
|
+
*
|
|
39
|
+
* Indexed by agentId so close/refresh teardown can sweep all turns
|
|
40
|
+
* (foreground + autonomous) belonging to one agent in a single call.
|
|
41
|
+
*
|
|
42
|
+
* Bookkeeping is idempotent: synthetic terminal events fired before any
|
|
43
|
+
* real turn_started (e.g. startTurn() throwing) are no-ops, and turns
|
|
44
|
+
* that vanish without a terminal event can be force-cleared via
|
|
45
|
+
* `forceEndAgentTurns` without skewing the count for other live turns.
|
|
46
|
+
*/
|
|
47
|
+
this.agentActiveTurns = new Map();
|
|
48
|
+
this.globalActiveTurnCount = 0;
|
|
49
|
+
}
|
|
50
|
+
beginPending(agentId, clientSentAt, daemonReceivedAt) {
|
|
51
|
+
this.pendingByAgent.set(agentId, { clientSentAt, daemonReceivedAt });
|
|
52
|
+
}
|
|
53
|
+
markPendingDispatched(agentId, at = Date.now()) {
|
|
54
|
+
const entry = this.pendingByAgent.get(agentId);
|
|
55
|
+
if (!entry)
|
|
56
|
+
return;
|
|
57
|
+
entry.daemonDispatchedAt = at;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Move the staged entry for `agentId` to a turnId-keyed slot once the
|
|
61
|
+
* provider has issued a turnId. No-op if no pending entry exists (debug
|
|
62
|
+
* mode was off for this turn).
|
|
63
|
+
*/
|
|
64
|
+
promotePending(agentId, turnId) {
|
|
65
|
+
const entry = this.pendingByAgent.get(agentId);
|
|
66
|
+
if (!entry)
|
|
67
|
+
return;
|
|
68
|
+
this.pendingByAgent.delete(agentId);
|
|
69
|
+
this.turns.set(turnId, entry);
|
|
70
|
+
this.agentToTurn.set(agentId, turnId);
|
|
71
|
+
}
|
|
72
|
+
dropPending(agentId) {
|
|
73
|
+
this.pendingByAgent.delete(agentId);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Record proxy-observed gateway timing. The proxy supplies its own
|
|
77
|
+
* timestamps and the tracker decides whether attribution is safe (i.e.
|
|
78
|
+
* unambiguous single in-flight turn). Concurrent turns → silently ignored.
|
|
79
|
+
*/
|
|
80
|
+
recordProxyTiming(at) {
|
|
81
|
+
// Attribution must satisfy BOTH:
|
|
82
|
+
// 1. exactly one debug-tracked turn is in flight (so we know which
|
|
83
|
+
// entry to write to), AND
|
|
84
|
+
// 2. globalActiveCount === 1 (no debug-off turn is concurrently
|
|
85
|
+
// sending CONNECTs through the same proxy).
|
|
86
|
+
// Either condition failing means we cannot safely tell which turn
|
|
87
|
+
// produced this socket; drop the sample.
|
|
88
|
+
const debugTracked = this.turns.size + this.pendingByAgent.size;
|
|
89
|
+
if (debugTracked !== 1 || this.globalActiveTurnCount !== 1)
|
|
90
|
+
return;
|
|
91
|
+
const onlyEntry = this.turns.size === 1
|
|
92
|
+
? this.turns.values().next().value
|
|
93
|
+
: this.pendingByAgent.values().next().value;
|
|
94
|
+
if (!onlyEntry)
|
|
95
|
+
return;
|
|
96
|
+
if (onlyEntry.providerRequestSentAt === undefined) {
|
|
97
|
+
onlyEntry.providerRequestSentAt = at.requestSent;
|
|
98
|
+
}
|
|
99
|
+
if (onlyEntry.gatewayFirstByteAt === undefined) {
|
|
100
|
+
onlyEntry.gatewayFirstByteAt = at.firstByte;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Account for a turn entering the in-flight pool, regardless of whether it
|
|
105
|
+
* carries per-turn latency tracking. Used by the proxy concurrency gate so
|
|
106
|
+
* debug-off turns cannot get their CONNECTs misattributed to a single
|
|
107
|
+
* debug-on turn. No-op if turnId is empty.
|
|
108
|
+
*
|
|
109
|
+
* Should be called as early as the agent-manager learns about the turnId
|
|
110
|
+
* (right after `await agent.session.startTurn(...)` returns), not waiting
|
|
111
|
+
* for the provider's `turn_started` event — the provider's first CONNECT
|
|
112
|
+
* can fire inside that window and the proxy timing must already see the
|
|
113
|
+
* turn counted to avoid being silently dropped. The `turn_started` event
|
|
114
|
+
* still calls this method later; the Set keeps it idempotent.
|
|
115
|
+
*/
|
|
116
|
+
noteTurnStarted(agentId, turnId) {
|
|
117
|
+
if (!turnId)
|
|
118
|
+
return;
|
|
119
|
+
let set = this.agentActiveTurns.get(agentId);
|
|
120
|
+
if (!set) {
|
|
121
|
+
set = new Set();
|
|
122
|
+
this.agentActiveTurns.set(agentId, set);
|
|
123
|
+
}
|
|
124
|
+
if (!set.has(turnId)) {
|
|
125
|
+
set.add(turnId);
|
|
126
|
+
this.globalActiveTurnCount += 1;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Mirror of `noteTurnStarted` for terminal events. Idempotent — terminal
|
|
131
|
+
* events fired without a matching `noteTurnStarted` (e.g. synthetic
|
|
132
|
+
* turn_failed from a `startTurn` rejection that never produced a real
|
|
133
|
+
* turn_started) are no-ops and cannot decrement the count for another
|
|
134
|
+
* live turn.
|
|
135
|
+
*/
|
|
136
|
+
noteTurnEnded(agentId, turnId) {
|
|
137
|
+
if (!turnId)
|
|
138
|
+
return;
|
|
139
|
+
const set = this.agentActiveTurns.get(agentId);
|
|
140
|
+
if (!set)
|
|
141
|
+
return;
|
|
142
|
+
if (set.delete(turnId)) {
|
|
143
|
+
this.globalActiveTurnCount -= 1;
|
|
144
|
+
}
|
|
145
|
+
if (set.size === 0)
|
|
146
|
+
this.agentActiveTurns.delete(agentId);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Force-clear all in-flight entries for an agent whose terminal events
|
|
150
|
+
* will not flow through handleStreamEvent (closeAgent / session refresh
|
|
151
|
+
* paths that unsubscribe before dispatching). Covers:
|
|
152
|
+
* - turns counted in agentActiveTurns (turn_started already fired);
|
|
153
|
+
* - promoted-but-not-yet-started entries in `turns` (pending → promoted
|
|
154
|
+
* by startTurn returning a turnId, but turn_started not yet seen — a
|
|
155
|
+
* real window between agent-manager.ts promote and the provider's
|
|
156
|
+
* first event);
|
|
157
|
+
* - pendingByAgent entries (never reached promotion).
|
|
158
|
+
*/
|
|
159
|
+
forceEndAgentTurns(agentId) {
|
|
160
|
+
const set = this.agentActiveTurns.get(agentId);
|
|
161
|
+
if (set) {
|
|
162
|
+
for (const turnId of set) {
|
|
163
|
+
if (this.turns.has(turnId))
|
|
164
|
+
this.drop(turnId);
|
|
165
|
+
}
|
|
166
|
+
this.globalActiveTurnCount -= set.size;
|
|
167
|
+
this.agentActiveTurns.delete(agentId);
|
|
168
|
+
}
|
|
169
|
+
// Also sweep a promoted-but-not-started entry: agent-manager.promotePending
|
|
170
|
+
// populates `agentToTurn` synchronously after startTurn returns, but the
|
|
171
|
+
// provider's `turn_started` (which would add it to agentActiveTurns) can
|
|
172
|
+
// arrive on a later tick. Without this, a refresh/close in that window
|
|
173
|
+
// would leave a stale entry in `turns`/`agentToTurn` that a later turn
|
|
174
|
+
// could collide with.
|
|
175
|
+
const promotedTurnId = this.agentToTurn.get(agentId);
|
|
176
|
+
if (promotedTurnId && this.turns.has(promotedTurnId)) {
|
|
177
|
+
this.drop(promotedTurnId);
|
|
178
|
+
}
|
|
179
|
+
this.dropPending(agentId);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Pull and clear the breakdown for a completed turn. Stamps
|
|
183
|
+
* `turnCompletedAt`. Returns undefined if no tracker is active for the turn.
|
|
184
|
+
*/
|
|
185
|
+
complete(turnId, at = Date.now()) {
|
|
186
|
+
const entry = this.turns.get(turnId);
|
|
187
|
+
if (!entry)
|
|
188
|
+
return undefined;
|
|
189
|
+
entry.turnCompletedAt = at;
|
|
190
|
+
this.turns.delete(turnId);
|
|
191
|
+
for (const [agentId, t] of this.agentToTurn) {
|
|
192
|
+
if (t === turnId) {
|
|
193
|
+
this.agentToTurn.delete(agentId);
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return entry;
|
|
198
|
+
}
|
|
199
|
+
/** Drop without producing a breakdown (turn_failed / turn_canceled). */
|
|
200
|
+
drop(turnId) {
|
|
201
|
+
this.turns.delete(turnId);
|
|
202
|
+
for (const [agentId, t] of this.agentToTurn) {
|
|
203
|
+
if (t === turnId) {
|
|
204
|
+
this.agentToTurn.delete(agentId);
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/** Resolve agent → currently tracked turnId, if any. */
|
|
210
|
+
turnIdForAgent(agentId) {
|
|
211
|
+
return this.agentToTurn.get(agentId);
|
|
212
|
+
}
|
|
213
|
+
isActive(turnId) {
|
|
214
|
+
return this.turns.has(turnId);
|
|
215
|
+
}
|
|
216
|
+
activeCount() {
|
|
217
|
+
return this.turns.size;
|
|
218
|
+
}
|
|
219
|
+
/** Total in-flight turn count across all agents (foreground + autonomous),
|
|
220
|
+
* including debug-off turns. Exposed for tests; the proxy concurrency
|
|
221
|
+
* gate reads it via recordProxyTiming internally. */
|
|
222
|
+
globalCount() {
|
|
223
|
+
return this.globalActiveTurnCount;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
export const latencyTracker = new LatencyTracker();
|
|
227
|
+
export function summarizeBreakdown(b) {
|
|
228
|
+
return {
|
|
229
|
+
networkUpMs: b.clientSentAt !== undefined && b.daemonReceivedAt !== undefined
|
|
230
|
+
? b.daemonReceivedAt - b.clientSentAt
|
|
231
|
+
: undefined,
|
|
232
|
+
daemonDispatchMs: b.daemonReceivedAt !== undefined && b.daemonDispatchedAt !== undefined
|
|
233
|
+
? b.daemonDispatchedAt - b.daemonReceivedAt
|
|
234
|
+
: undefined,
|
|
235
|
+
providerOverheadMs: b.daemonDispatchedAt !== undefined && b.providerRequestSentAt !== undefined
|
|
236
|
+
? b.providerRequestSentAt - b.daemonDispatchedAt
|
|
237
|
+
: undefined,
|
|
238
|
+
// TLS handshake RTT — the proxy cannot see HTTP boundaries inside the
|
|
239
|
+
// CONNECT tunnel, so this is ClientHello→ServerHello, not gateway TTFB.
|
|
240
|
+
tlsHandshakeMs: b.providerRequestSentAt !== undefined && b.gatewayFirstByteAt !== undefined
|
|
241
|
+
? b.gatewayFirstByteAt - b.providerRequestSentAt
|
|
242
|
+
: undefined,
|
|
243
|
+
modelToDoneMs: b.gatewayFirstByteAt !== undefined && b.turnCompletedAt !== undefined
|
|
244
|
+
? b.turnCompletedAt - b.gatewayFirstByteAt
|
|
245
|
+
: undefined,
|
|
246
|
+
totalMs: b.clientSentAt !== undefined && b.turnCompletedAt !== undefined
|
|
247
|
+
? b.turnCompletedAt - b.clientSentAt
|
|
248
|
+
: b.daemonReceivedAt !== undefined && b.turnCompletedAt !== undefined
|
|
249
|
+
? b.turnCompletedAt - b.daemonReceivedAt
|
|
250
|
+
: undefined,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=latency-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"latency-tracker.js","sourceRoot":"","sources":["../../../src/server/latency-tracker.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,cAAc;IAApB;QACmB,UAAK,GAAG,IAAI,GAAG,EAA4B,CAAC;QAC7D,oDAAoD;QACnC,gBAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;QACzD;;;;;WAKG;QACc,mBAAc,GAAG,IAAI,GAAG,EAA4B,CAAC;QACtE;;;;;;;;;;;;;;;WAeG;QACc,qBAAgB,GAAG,IAAI,GAAG,EAAuB,CAAC;QAC3D,0BAAqB,GAAG,CAAC,CAAC;IAqLpC,CAAC;IAnLC,YAAY,CAAC,OAAe,EAAE,YAAoB,EAAE,gBAAwB;QAC1E,IAAI,CAAC,cAAc,CAAC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