@junctionpanel/server 0.1.89 → 0.1.91
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/server/server/agent/providers/claude-agent.d.ts.map +1 -1
- package/dist/server/server/agent/providers/claude-agent.js +51 -4
- package/dist/server/server/agent/providers/claude-agent.js.map +1 -1
- package/dist/server/server/session.d.ts +4 -0
- package/dist/server/server/session.d.ts.map +1 -1
- package/dist/server/server/session.js +164 -22
- package/dist/server/server/session.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-agent.d.ts","sourceRoot":"","sources":["../../../../../src/server/agent/providers/claude-agent.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,eAAe,EAQpB,KAAK,UAAU,EAKhB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAYnC,OAAO,EAOL,KAAK,iBAAiB,EACvB,MAAM,2BAA2B,CAAC;AAWnC,OAAO,KAAK,EACV,oBAAoB,EACpB,WAAW,EAGX,oBAAoB,EAKpB,sBAAsB,EAItB,YAAY,EACZ,kBAAkB,EAGlB,iBAAiB,EAGjB,iBAAiB,EACjB,0BAA0B,EAE1B,wBAAwB,EACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"claude-agent.d.ts","sourceRoot":"","sources":["../../../../../src/server/agent/providers/claude-agent.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,eAAe,EAQpB,KAAK,UAAU,EAKhB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAYnC,OAAO,EAOL,KAAK,iBAAiB,EACvB,MAAM,2BAA2B,CAAC;AAWnC,OAAO,KAAK,EACV,oBAAoB,EACpB,WAAW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
if (typeof modelId !== "string") {
|
|
24
25
|
return null;
|
|
@@ -1171,6 +1172,7 @@ class ClaudeAgentSession {
|
|
|
1171
1172
|
this.toolUseInputBuffers = new Map();
|
|
1172
1173
|
this.pendingPermissions = new Map();
|
|
1173
1174
|
this.activeForegroundTurn = null;
|
|
1175
|
+
this.recentForegroundTerminalRun = null;
|
|
1174
1176
|
this.liveEventQueue = new Pushable();
|
|
1175
1177
|
this.runTracker = new RunTracker();
|
|
1176
1178
|
this.timelineAssembler = new TimelineAssembler();
|
|
@@ -2116,6 +2118,9 @@ class ClaudeAgentSession {
|
|
|
2116
2118
|
this.pendingInterruptPromise = null;
|
|
2117
2119
|
}
|
|
2118
2120
|
createRun(owner, queue) {
|
|
2121
|
+
if (owner === "foreground") {
|
|
2122
|
+
this.recentForegroundTerminalRun = null;
|
|
2123
|
+
}
|
|
2119
2124
|
const runId = `${owner}-run-${this.nextRunOrdinal++}`;
|
|
2120
2125
|
const run = this.runTracker.createRun({
|
|
2121
2126
|
id: runId,
|
|
@@ -2170,6 +2175,17 @@ class ClaudeAgentSession {
|
|
|
2170
2175
|
this.handleRunTerminalEvent(run, event);
|
|
2171
2176
|
}
|
|
2172
2177
|
handleRunTerminalEvent(run, event) {
|
|
2178
|
+
const recentForegroundTerminalRun = event.type === "turn_completed" ||
|
|
2179
|
+
event.type === "turn_failed" ||
|
|
2180
|
+
event.type === "turn_canceled"
|
|
2181
|
+
? run.owner === "foreground"
|
|
2182
|
+
? {
|
|
2183
|
+
run,
|
|
2184
|
+
taskIds: new Set(run.taskIds),
|
|
2185
|
+
completedAtMs: Date.now(),
|
|
2186
|
+
}
|
|
2187
|
+
: null
|
|
2188
|
+
: null;
|
|
2173
2189
|
if (event.type === "turn_completed") {
|
|
2174
2190
|
this.runTracker.complete(run, "completed");
|
|
2175
2191
|
}
|
|
@@ -2186,8 +2202,35 @@ class ClaudeAgentSession {
|
|
|
2186
2202
|
this.activeForegroundTurn = null;
|
|
2187
2203
|
this.preReplayMetadataSeen = false;
|
|
2188
2204
|
}
|
|
2205
|
+
if (recentForegroundTerminalRun) {
|
|
2206
|
+
this.recentForegroundTerminalRun = recentForegroundTerminalRun;
|
|
2207
|
+
}
|
|
2189
2208
|
this.transitionTurnStateFromActiveRuns(`run ${run.id} terminal`);
|
|
2190
2209
|
}
|
|
2210
|
+
getRecentForegroundTerminalRun() {
|
|
2211
|
+
const recent = this.recentForegroundTerminalRun;
|
|
2212
|
+
if (!recent) {
|
|
2213
|
+
return null;
|
|
2214
|
+
}
|
|
2215
|
+
if (Date.now() - recent.completedAtMs > RECENT_FOREGROUND_FALLBACK_GUARD_MS) {
|
|
2216
|
+
this.recentForegroundTerminalRun = null;
|
|
2217
|
+
return null;
|
|
2218
|
+
}
|
|
2219
|
+
return recent;
|
|
2220
|
+
}
|
|
2221
|
+
shouldTreatAsRecentForegroundTail(identifiers) {
|
|
2222
|
+
if (this.pendingAutonomousWakeReservations > 0) {
|
|
2223
|
+
return false;
|
|
2224
|
+
}
|
|
2225
|
+
const recentRun = this.getRecentForegroundTerminalRun();
|
|
2226
|
+
if (!recentRun) {
|
|
2227
|
+
return false;
|
|
2228
|
+
}
|
|
2229
|
+
if (identifiers.taskId) {
|
|
2230
|
+
return recentRun.taskIds.has(identifiers.taskId);
|
|
2231
|
+
}
|
|
2232
|
+
return true;
|
|
2233
|
+
}
|
|
2191
2234
|
async transitionAutonomousToForeground() {
|
|
2192
2235
|
const autonomousRuns = this.runTracker.listActiveRuns("autonomous");
|
|
2193
2236
|
if (autonomousRuns.length === 0) {
|
|
@@ -2262,6 +2305,9 @@ class ClaudeAgentSession {
|
|
|
2262
2305
|
})) {
|
|
2263
2306
|
return { run: foregroundRun, reason: "foreground" };
|
|
2264
2307
|
}
|
|
2308
|
+
if (this.shouldTreatAsRecentForegroundTail(normalized.identifiers)) {
|
|
2309
|
+
return { run: null, reason: "foreground_tail" };
|
|
2310
|
+
}
|
|
2265
2311
|
if (!hasIdentifiers) {
|
|
2266
2312
|
if (this.pendingAutonomousWakeReservations > 0) {
|
|
2267
2313
|
const reservedAutonomousRun = this.claimOrCreateAutonomousRun("reservation_unbound");
|
|
@@ -2445,10 +2491,11 @@ class ClaudeAgentSession {
|
|
|
2445
2491
|
identifiers,
|
|
2446
2492
|
metadataOnly,
|
|
2447
2493
|
});
|
|
2448
|
-
const suppressTerminalEvents =
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2494
|
+
const suppressTerminalEvents = route.reason === "foreground_tail" ||
|
|
2495
|
+
this.shouldSuppressReplayResultTerminal({
|
|
2496
|
+
run: route.run,
|
|
2497
|
+
message,
|
|
2498
|
+
});
|
|
2452
2499
|
if (route.run) {
|
|
2453
2500
|
this.transitionTurnStateFromActiveRuns(`routed via ${route.reason}`);
|
|
2454
2501
|
this.runTracker.bindIdentifiers(route.run, identifiers);
|