@parall/agent-core 1.28.1 → 1.29.0
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/event-format.d.ts +1 -0
- package/dist/event-format.d.ts.map +1 -1
- package/dist/event-format.js +11 -6
- package/dist/gateway-base.d.ts.map +1 -1
- package/dist/gateway-base.js +5 -29
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +7 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/event-format.ts +12 -5
- package/src/gateway-base.ts +5 -29
- package/src/index.ts +1 -0
- package/src/logger.ts +9 -0
- package/src/types.ts +2 -0
package/dist/event-format.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ForkResult, ParallEvent } from "./types.js";
|
|
2
2
|
export declare function buildEventBody(event: ParallEvent): string;
|
|
3
|
+
export declare function buildEventBodyForForkResult(event: ParallEvent): string;
|
|
3
4
|
export declare function buildForkScopePrefix(event: ParallEvent): string;
|
|
4
5
|
export declare function buildForkResultPrefix(results: ForkResult[]): string;
|
|
5
6
|
//# sourceMappingURL=event-format.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-format.d.ts","sourceRoot":"","sources":["../src/event-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAM1D,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAsDzD;AAoBD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAK/D;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"event-format.d.ts","sourceRoot":"","sources":["../src/event-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAM1D,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAsDzD;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAEtE;AAoBD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAK/D;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CAcnE"}
|
package/dist/event-format.js
CHANGED
|
@@ -65,6 +65,9 @@ export function buildEventBody(event) {
|
|
|
65
65
|
}
|
|
66
66
|
return lines.join("\n") + buildSendMessageHint(event);
|
|
67
67
|
}
|
|
68
|
+
export function buildEventBodyForForkResult(event) {
|
|
69
|
+
return buildEventBody(event).replace(/\n<system-reminder>[\s\S]*<\/system-reminder>$/, "");
|
|
70
|
+
}
|
|
68
71
|
function buildSendMessageHint(event) {
|
|
69
72
|
if (event.noReply)
|
|
70
73
|
return "";
|
|
@@ -89,14 +92,16 @@ export function buildForkResultPrefix(results) {
|
|
|
89
92
|
if (!results.length)
|
|
90
93
|
return "";
|
|
91
94
|
const blocks = results.map((result) => {
|
|
92
|
-
const lines = [
|
|
93
|
-
|
|
95
|
+
const lines = [];
|
|
96
|
+
for (const body of result.eventBodies) {
|
|
97
|
+
lines.push(body);
|
|
98
|
+
}
|
|
99
|
+
lines.push(`[This event was handled by a parallel fork session. Do NOT re-handle, re-reply, or duplicate work for it.]`);
|
|
100
|
+
lines.push(`[Fork summary: ${result.agentSummary ? sanitizeMeta(result.agentSummary) : "No fork summary available — the fork completed without producing a text summary. Check the target chat/task for any actions the fork already took before acting."}]`);
|
|
94
101
|
if (result.actions.length)
|
|
95
|
-
lines.push(`[
|
|
96
|
-
if (result.agentSummary)
|
|
97
|
-
lines.push(`[Summary: ${sanitizeMeta(result.agentSummary)}]`);
|
|
102
|
+
lines.push(`[Fork actions: ${result.actions.join("; ")}]`);
|
|
98
103
|
if (result.historyPath)
|
|
99
|
-
lines.push(`[
|
|
104
|
+
lines.push(`[Fork history: ${result.historyPath}]`);
|
|
100
105
|
return lines.join("\n");
|
|
101
106
|
});
|
|
102
107
|
return blocks.join("\n\n") + "\n\n---\n\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway-base.d.ts","sourceRoot":"","sources":["../src/gateway-base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gateway-base.d.ts","sourceRoot":"","sources":["../src/gateway-base.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuB,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,KAAK,EACV,qBAAqB,EActB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAEV,eAAe,EAGf,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAoD/B,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,YAAY,CAAC;IACrB,EAAE,EAAE,QAAQ,CAAC;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE;QACN,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,eAAe,EAAE,eAAe,CAAC;IACjC,GAAG,CAAC,EAAE,aAAa,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAI3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yBAAyB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK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3
|
import * as path from "node:path";
|
|
4
|
-
import { randomUUID } from "node:crypto";
|
|
5
4
|
import { MENTION_ALL_USER_ID } from "@parall/sdk";
|
|
6
|
-
import { buildEventBody, buildForkResultPrefix, buildForkScopePrefix } from "./event-format.js";
|
|
5
|
+
import { buildEventBody, buildEventBodyForForkResult, buildForkResultPrefix, buildForkScopePrefix } from "./event-format.js";
|
|
7
6
|
import { routeTrigger } from "./routing.js";
|
|
8
7
|
import { clearDispatchMessageId, clearDispatchNoReply, clearSessionMessageId, setDispatchMessageId, setDispatchNoReply, setSessionChatId, setSessionMessageId, } from "./session-state.js";
|
|
9
8
|
// Parse PRLL_SHUTDOWN_DEADLINE_MS (or any string env value) into a positive
|
|
@@ -554,7 +553,8 @@ export class ParallAgentGateway {
|
|
|
554
553
|
continue;
|
|
555
554
|
}
|
|
556
555
|
if (!binding) {
|
|
557
|
-
|
|
556
|
+
const detail = runtimeEvent.type === "error" ? `: ${runtimeEvent.message}` : "";
|
|
557
|
+
throw new Error(`runtime emitted ${runtimeEvent.type} before runtime_session${detail}`);
|
|
558
558
|
}
|
|
559
559
|
if (!triggerMessageSet) {
|
|
560
560
|
triggerMessageSet = true;
|
|
@@ -685,6 +685,7 @@ export class ParallAgentGateway {
|
|
|
685
685
|
? `${first.type} from ${first.senderName} in ${first.targetName ?? fork.targetId}`
|
|
686
686
|
: `${fork.processedEvents.length} events in ${first.targetName ?? fork.targetId}`,
|
|
687
687
|
},
|
|
688
|
+
eventBodies: fork.processedEvents.map((e) => buildEventBodyForForkResult(e)),
|
|
688
689
|
actions: [],
|
|
689
690
|
agentSummary,
|
|
690
691
|
historyPath,
|
|
@@ -723,7 +724,7 @@ export class ParallAgentGateway {
|
|
|
723
724
|
return;
|
|
724
725
|
this.draining = true;
|
|
725
726
|
try {
|
|
726
|
-
while (this.dispatchState.mainBuffer.length > 0
|
|
727
|
+
while (this.dispatchState.mainBuffer.length > 0) {
|
|
727
728
|
// Early shutdown guard — same reasoning as runForkDrainLoop: stop
|
|
728
729
|
// before any input AgentSteps are persisted, leaving the buffer +
|
|
729
730
|
// pendingForkResults intact so dispatch catch-up on the replacement
|
|
@@ -732,31 +733,6 @@ export class ParallAgentGateway {
|
|
|
732
733
|
this.opts.log?.info(`parall[${this.opts.accountId}]: drainMainBuffer halted (shutting down) — ${this.dispatchState.mainBuffer.length} buffered, ${this.dispatchState.pendingForkResults.length} pending fork results left for catch-up`);
|
|
733
734
|
break;
|
|
734
735
|
}
|
|
735
|
-
if (this.dispatchState.mainBuffer.length === 0 && this.dispatchState.pendingForkResults.length > 0) {
|
|
736
|
-
const pending = this.dispatchState.pendingForkResults.splice(0);
|
|
737
|
-
const forkPrefix = buildForkResultPrefix(pending);
|
|
738
|
-
const syntheticEvent = {
|
|
739
|
-
type: "message",
|
|
740
|
-
targetId: "_orchestrator",
|
|
741
|
-
targetType: "system",
|
|
742
|
-
senderId: "system",
|
|
743
|
-
senderName: "system",
|
|
744
|
-
messageId: `synthetic-${this.opts.accountId}-${randomUUID()}`,
|
|
745
|
-
body: "[Orchestrator: fork session(s) completed — review results above]",
|
|
746
|
-
};
|
|
747
|
-
this.dispatchState.mainCurrentTargetId = undefined;
|
|
748
|
-
this.dispatchState.mainPreDispatchBranchPoint =
|
|
749
|
-
this.opts.dispatchAdapter.getBranchPoint?.(this.opts.runtimeKey);
|
|
750
|
-
const dispatched = await this.runDispatch(syntheticEvent, this.opts.runtimeKey, forkPrefix + buildEventBody(syntheticEvent));
|
|
751
|
-
if (!dispatched) {
|
|
752
|
-
// Shutdown: put the fork results back at the head so the synthetic
|
|
753
|
-
// event is regenerated on the replacement pod. Synthetic events are
|
|
754
|
-
// not ack'd, so this is the only state we need to preserve.
|
|
755
|
-
this.dispatchState.pendingForkResults.unshift(...pending);
|
|
756
|
-
break;
|
|
757
|
-
}
|
|
758
|
-
continue;
|
|
759
|
-
}
|
|
760
736
|
const targetId = this.dispatchState.mainBuffer[0].targetId;
|
|
761
737
|
const events = [];
|
|
762
738
|
while (this.dispatchState.mainBuffer[0]?.targetId === targetId) {
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./event-format.js";
|
|
|
5
5
|
export * from "./prompt-fragments.js";
|
|
6
6
|
export * from "./bridge-workspace.js";
|
|
7
7
|
export * from "./dispatch-adapter.js";
|
|
8
|
+
export { createLogger } from "./logger.js";
|
|
8
9
|
export * from "./gateway-base.js";
|
|
9
10
|
export * from "./platform-config.js";
|
|
10
11
|
export { writeSkillFiles, buildSkillReferences, SKILLS } from "./skills/index.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAClF,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAClF,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./event-format.js";
|
|
|
5
5
|
export * from "./prompt-fragments.js";
|
|
6
6
|
export * from "./bridge-workspace.js";
|
|
7
7
|
export * from "./dispatch-adapter.js";
|
|
8
|
+
export { createLogger } from "./logger.js";
|
|
8
9
|
export * from "./gateway-base.js";
|
|
9
10
|
export * from "./platform-config.js";
|
|
10
11
|
export { writeSkillFiles, buildSkillReferences, SKILLS } from "./skills/index.js";
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAM1D"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function createLogger(prefix) {
|
|
2
|
+
return {
|
|
3
|
+
info: (msg) => console.log(`${new Date().toISOString()} [${prefix}] ${msg}`),
|
|
4
|
+
warn: (msg) => console.warn(`${new Date().toISOString()} [${prefix}] ${msg}`),
|
|
5
|
+
error: (msg) => console.error(`${new Date().toISOString()} [${prefix}] ${msg}`),
|
|
6
|
+
};
|
|
7
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export type ForkResult = {
|
|
|
6
6
|
targetId: string;
|
|
7
7
|
summary: string;
|
|
8
8
|
};
|
|
9
|
+
/** Original event bodies that the fork processed, built via `buildEventBody()`. */
|
|
10
|
+
eventBodies: string[];
|
|
9
11
|
actions: string[];
|
|
10
12
|
/** Agent's own summary of what it did (captured from the fork's last text output). */
|
|
11
13
|
agentSummary?: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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AAc,GAAG,UAAU,GAAG,UAAU,CAAC;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,KAAK,CAAC;QAClB,EAAE,EAAE,MAAM,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;IACH,8DAA8D;IAC9D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,SAAS,GAAG,eAAe,GAAG,SAAS,GAAG,cAAc,CAAC;IACzE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parall/agent-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.29.0",
|
|
4
4
|
"description": "Shared agent runtime orchestration helpers for Parall",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"src"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@parall/sdk": "1.
|
|
29
|
+
"@parall/sdk": "1.29.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^22.0.0",
|
package/src/event-format.ts
CHANGED
|
@@ -60,6 +60,10 @@ export function buildEventBody(event: ParallEvent): string {
|
|
|
60
60
|
return lines.join("\n") + buildSendMessageHint(event);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
export function buildEventBodyForForkResult(event: ParallEvent): string {
|
|
64
|
+
return buildEventBody(event).replace(/\n<system-reminder>[\s\S]*<\/system-reminder>$/, "");
|
|
65
|
+
}
|
|
66
|
+
|
|
63
67
|
function buildSendMessageHint(event: ParallEvent): string {
|
|
64
68
|
if (event.noReply) return "";
|
|
65
69
|
|
|
@@ -88,11 +92,14 @@ export function buildForkScopePrefix(event: ParallEvent): string {
|
|
|
88
92
|
export function buildForkResultPrefix(results: ForkResult[]): string {
|
|
89
93
|
if (!results.length) return "";
|
|
90
94
|
const blocks = results.map((result) => {
|
|
91
|
-
const lines = [
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
const lines: string[] = [];
|
|
96
|
+
for (const body of result.eventBodies) {
|
|
97
|
+
lines.push(body);
|
|
98
|
+
}
|
|
99
|
+
lines.push(`[This event was handled by a parallel fork session. Do NOT re-handle, re-reply, or duplicate work for it.]`);
|
|
100
|
+
lines.push(`[Fork summary: ${result.agentSummary ? sanitizeMeta(result.agentSummary) : "No fork summary available — the fork completed without producing a text summary. Check the target chat/task for any actions the fork already took before acting."}]`);
|
|
101
|
+
if (result.actions.length) lines.push(`[Fork actions: ${result.actions.join("; ")}]`);
|
|
102
|
+
if (result.historyPath) lines.push(`[Fork history: ${result.historyPath}]`);
|
|
96
103
|
return lines.join("\n");
|
|
97
104
|
});
|
|
98
105
|
return blocks.join("\n\n") + "\n\n---\n\n";
|
package/src/gateway-base.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as os from "node:os";
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as path from "node:path";
|
|
4
|
-
import { randomUUID } from "node:crypto";
|
|
5
4
|
import { MENTION_ALL_USER_ID, ParallClient, ParallWs } from "@parall/sdk";
|
|
6
5
|
import type {
|
|
7
6
|
AgentConfigUpdateData,
|
|
@@ -19,7 +18,7 @@ import type {
|
|
|
19
18
|
TaskAssignedData,
|
|
20
19
|
TextContent,
|
|
21
20
|
} from "@parall/sdk";
|
|
22
|
-
import { buildEventBody, buildForkResultPrefix, buildForkScopePrefix } from "./event-format.js";
|
|
21
|
+
import { buildEventBody, buildEventBodyForForkResult, buildForkResultPrefix, buildForkScopePrefix } from "./event-format.js";
|
|
23
22
|
import type {
|
|
24
23
|
CleanupForkOpts,
|
|
25
24
|
DispatchAdapter,
|
|
@@ -693,7 +692,8 @@ export class ParallAgentGateway {
|
|
|
693
692
|
}
|
|
694
693
|
|
|
695
694
|
if (!binding) {
|
|
696
|
-
|
|
695
|
+
const detail = runtimeEvent.type === "error" ? `: ${runtimeEvent.message}` : "";
|
|
696
|
+
throw new Error(`runtime emitted ${runtimeEvent.type} before runtime_session${detail}`);
|
|
697
697
|
}
|
|
698
698
|
if (!triggerMessageSet) {
|
|
699
699
|
triggerMessageSet = true;
|
|
@@ -823,6 +823,7 @@ export class ParallAgentGateway {
|
|
|
823
823
|
? `${first.type} from ${first.senderName} in ${first.targetName ?? fork.targetId}`
|
|
824
824
|
: `${fork.processedEvents.length} events in ${first.targetName ?? fork.targetId}`,
|
|
825
825
|
},
|
|
826
|
+
eventBodies: fork.processedEvents.map((e) => buildEventBodyForForkResult(e)),
|
|
826
827
|
actions: [],
|
|
827
828
|
agentSummary,
|
|
828
829
|
historyPath,
|
|
@@ -864,7 +865,7 @@ export class ParallAgentGateway {
|
|
|
864
865
|
if (this.draining) return;
|
|
865
866
|
this.draining = true;
|
|
866
867
|
try {
|
|
867
|
-
while (this.dispatchState.mainBuffer.length > 0
|
|
868
|
+
while (this.dispatchState.mainBuffer.length > 0) {
|
|
868
869
|
// Early shutdown guard — same reasoning as runForkDrainLoop: stop
|
|
869
870
|
// before any input AgentSteps are persisted, leaving the buffer +
|
|
870
871
|
// pendingForkResults intact so dispatch catch-up on the replacement
|
|
@@ -875,31 +876,6 @@ export class ParallAgentGateway {
|
|
|
875
876
|
);
|
|
876
877
|
break;
|
|
877
878
|
}
|
|
878
|
-
if (this.dispatchState.mainBuffer.length === 0 && this.dispatchState.pendingForkResults.length > 0) {
|
|
879
|
-
const pending = this.dispatchState.pendingForkResults.splice(0);
|
|
880
|
-
const forkPrefix = buildForkResultPrefix(pending);
|
|
881
|
-
const syntheticEvent: ParallEvent = {
|
|
882
|
-
type: "message",
|
|
883
|
-
targetId: "_orchestrator",
|
|
884
|
-
targetType: "system",
|
|
885
|
-
senderId: "system",
|
|
886
|
-
senderName: "system",
|
|
887
|
-
messageId: `synthetic-${this.opts.accountId}-${randomUUID()}`,
|
|
888
|
-
body: "[Orchestrator: fork session(s) completed — review results above]",
|
|
889
|
-
};
|
|
890
|
-
this.dispatchState.mainCurrentTargetId = undefined;
|
|
891
|
-
this.dispatchState.mainPreDispatchBranchPoint =
|
|
892
|
-
this.opts.dispatchAdapter.getBranchPoint?.(this.opts.runtimeKey);
|
|
893
|
-
const dispatched = await this.runDispatch(syntheticEvent, this.opts.runtimeKey, forkPrefix + buildEventBody(syntheticEvent));
|
|
894
|
-
if (!dispatched) {
|
|
895
|
-
// Shutdown: put the fork results back at the head so the synthetic
|
|
896
|
-
// event is regenerated on the replacement pod. Synthetic events are
|
|
897
|
-
// not ack'd, so this is the only state we need to preserve.
|
|
898
|
-
this.dispatchState.pendingForkResults.unshift(...pending);
|
|
899
|
-
break;
|
|
900
|
-
}
|
|
901
|
-
continue;
|
|
902
|
-
}
|
|
903
879
|
|
|
904
880
|
const targetId = this.dispatchState.mainBuffer[0].targetId;
|
|
905
881
|
const events: ParallEvent[] = [];
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./event-format.js";
|
|
|
5
5
|
export * from "./prompt-fragments.js";
|
|
6
6
|
export * from "./bridge-workspace.js";
|
|
7
7
|
export * from "./dispatch-adapter.js";
|
|
8
|
+
export { createLogger } from "./logger.js";
|
|
8
9
|
export * from "./gateway-base.js";
|
|
9
10
|
export * from "./platform-config.js";
|
|
10
11
|
export { writeSkillFiles, buildSkillReferences, SKILLS } from "./skills/index.js";
|
package/src/logger.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GatewayLogger } from "./dispatch-adapter.js";
|
|
2
|
+
|
|
3
|
+
export function createLogger(prefix: string): GatewayLogger {
|
|
4
|
+
return {
|
|
5
|
+
info: (msg: string) => console.log(`${new Date().toISOString()} [${prefix}] ${msg}`),
|
|
6
|
+
warn: (msg: string) => console.warn(`${new Date().toISOString()} [${prefix}] ${msg}`),
|
|
7
|
+
error: (msg: string) => console.error(`${new Date().toISOString()} [${prefix}] ${msg}`),
|
|
8
|
+
};
|
|
9
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
export type ForkResult = {
|
|
3
3
|
forkSessionKey: string;
|
|
4
4
|
sourceEvent: { type: string; targetId: string; summary: string };
|
|
5
|
+
/** Original event bodies that the fork processed, built via `buildEventBody()`. */
|
|
6
|
+
eventBodies: string[];
|
|
5
7
|
actions: string[];
|
|
6
8
|
/** Agent's own summary of what it did (captured from the fork's last text output). */
|
|
7
9
|
agentSummary?: string;
|