@parall/agent-core 1.31.0 → 1.32.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/bridge-workspace.js +12 -12
- package/dist/dispatch-adapter.d.ts +15 -8
- package/dist/dispatch-adapter.d.ts.map +1 -1
- package/dist/event-format.d.ts +1 -1
- package/dist/event-format.d.ts.map +1 -1
- package/dist/event-format.js +68 -25
- package/dist/gateway-base.d.ts +14 -13
- package/dist/gateway-base.d.ts.map +1 -1
- package/dist/gateway-base.js +650 -313
- package/dist/index.d.ts +15 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -12
- package/dist/internal/attachment-input.d.ts +3 -3
- package/dist/internal/attachment-input.d.ts.map +1 -1
- package/dist/internal/attachment-input.js +61 -58
- package/dist/logger.d.ts +1 -1
- package/dist/platform-config.d.ts +28 -2
- package/dist/platform-config.d.ts.map +1 -1
- package/dist/platform-config.js +42 -11
- package/dist/prompt-fragments.d.ts +1 -1
- package/dist/prompt-fragments.d.ts.map +1 -1
- package/dist/prompt-fragments.js +28 -10
- package/dist/provider-config.d.ts +9 -0
- package/dist/provider-config.d.ts.map +1 -1
- package/dist/provider-config.js +13 -2
- package/dist/routing.d.ts +5 -5
- package/dist/routing.js +6 -6
- package/dist/session-state.d.ts +16 -0
- package/dist/session-state.d.ts.map +1 -1
- package/dist/session-state.js +45 -0
- package/dist/skills/index.d.ts +5 -4
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +28 -21
- package/dist/skills/parall-clips.d.ts +2 -0
- package/dist/skills/parall-clips.d.ts.map +1 -0
- package/dist/skills/parall-clips.js +44 -0
- package/dist/telemetry.d.ts +27 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +205 -0
- package/dist/types.d.ts +18 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +11 -2
- package/src/bridge-workspace.ts +12 -12
- package/src/dispatch-adapter.ts +31 -8
- package/src/event-format.ts +80 -30
- package/src/gateway-base.ts +988 -445
- package/src/index.ts +23 -13
- package/src/internal/attachment-input.ts +127 -100
- package/src/logger.ts +1 -1
- package/src/platform-config.ts +61 -16
- package/src/prompt-fragments.ts +28 -10
- package/src/provider-config.ts +14 -2
- package/src/routing.ts +11 -11
- package/src/session-state.ts +62 -0
- package/src/skills/index.ts +34 -23
- package/src/skills/parall-clips.ts +44 -0
- package/src/telemetry.ts +252 -0
- package/src/types.ts +18 -2
package/dist/bridge-workspace.js
CHANGED
|
@@ -82,10 +82,10 @@ Messages may arrive with a \`[Thread: prll://msg_xxx]\` line in the event block,
|
|
|
82
82
|
`;
|
|
83
83
|
/** Extracts the `command` string from a shell/bash tool call's input payload. */
|
|
84
84
|
export function extractShellCommand(input) {
|
|
85
|
-
if (!input || typeof input !==
|
|
85
|
+
if (!input || typeof input !== 'object')
|
|
86
86
|
return undefined;
|
|
87
87
|
const command = input.command;
|
|
88
|
-
return typeof command ===
|
|
88
|
+
return typeof command === 'string' && command.trim() ? command.trim() : undefined;
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
91
|
* Returns the non-flag tokens that follow a Parall CLI invocation in
|
|
@@ -99,31 +99,31 @@ export function extractShellCommand(input) {
|
|
|
99
99
|
* `no-reply` subcommand).
|
|
100
100
|
*/
|
|
101
101
|
export function parseParallCliInvocation(command) {
|
|
102
|
-
const tokens = command.replace(/\s+/g,
|
|
102
|
+
const tokens = command.replace(/\s+/g, ' ').trim().split(' ');
|
|
103
103
|
let i = 0;
|
|
104
|
-
if (tokens[i] ===
|
|
104
|
+
if (tokens[i] === 'parall') {
|
|
105
105
|
i++;
|
|
106
106
|
}
|
|
107
|
-
else if (tokens[i] ===
|
|
107
|
+
else if (tokens[i] === 'npx') {
|
|
108
108
|
i++;
|
|
109
|
-
while (i < tokens.length && tokens[i].startsWith(
|
|
109
|
+
while (i < tokens.length && tokens[i].startsWith('-'))
|
|
110
110
|
i++;
|
|
111
111
|
if (i >= tokens.length || !/^@parall\/cli(?:@.+)?$/.test(tokens[i]))
|
|
112
112
|
return null;
|
|
113
113
|
i++;
|
|
114
114
|
}
|
|
115
|
-
else if (tokens[i] ===
|
|
115
|
+
else if (tokens[i] === 'pnpm') {
|
|
116
116
|
i++;
|
|
117
|
-
if (i < tokens.length && (tokens[i] ===
|
|
117
|
+
if (i < tokens.length && (tokens[i] === 'exec' || tokens[i] === 'dlx'))
|
|
118
118
|
i++;
|
|
119
|
-
if (i >= tokens.length || tokens[i] !==
|
|
119
|
+
if (i >= tokens.length || tokens[i] !== 'parall')
|
|
120
120
|
return null;
|
|
121
121
|
i++;
|
|
122
122
|
}
|
|
123
123
|
else {
|
|
124
124
|
return null;
|
|
125
125
|
}
|
|
126
|
-
return tokens.slice(i).filter((t) => !t.startsWith(
|
|
126
|
+
return tokens.slice(i).filter((t) => !t.startsWith('-'));
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* Detects whether a shell command invokes the Parall CLI to send a
|
|
@@ -138,7 +138,7 @@ export function isParallSendCommand(command) {
|
|
|
138
138
|
const sub = parseParallCliInvocation(command);
|
|
139
139
|
if (!sub || sub.length === 0)
|
|
140
140
|
return false;
|
|
141
|
-
return sub[0] ===
|
|
141
|
+
return sub[0] === 'dm' || (sub[0] === 'messages' && sub[1] === 'send');
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
144
|
* Detects whether a shell command invokes `parall no-reply`, which signals
|
|
@@ -150,5 +150,5 @@ export function isParallNoReplyCommand(command) {
|
|
|
150
150
|
if (!command)
|
|
151
151
|
return false;
|
|
152
152
|
const sub = parseParallCliInvocation(command);
|
|
153
|
-
return sub?.[0] ===
|
|
153
|
+
return sub?.[0] === 'no-reply';
|
|
154
154
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ParallClient } from
|
|
2
|
-
import type { ParallEvent } from
|
|
1
|
+
import type { ParallClient } from '@parall/sdk';
|
|
2
|
+
import type { ParallEvent } from './types.js';
|
|
3
3
|
export type GatewayLogger = {
|
|
4
4
|
info: (msg: string) => void;
|
|
5
5
|
warn: (msg: string) => void;
|
|
@@ -25,23 +25,23 @@ export type DispatchContext = {
|
|
|
25
25
|
log?: GatewayLogger;
|
|
26
26
|
};
|
|
27
27
|
export type RuntimeEvent = {
|
|
28
|
-
type:
|
|
28
|
+
type: 'runtime_session';
|
|
29
29
|
runtimeSessionId: string;
|
|
30
30
|
runtimeLaneKey?: string;
|
|
31
31
|
runtimeRef?: Record<string, unknown>;
|
|
32
32
|
} | {
|
|
33
|
-
type:
|
|
33
|
+
type: 'thinking';
|
|
34
34
|
text: string;
|
|
35
35
|
groupKey?: string;
|
|
36
36
|
} | {
|
|
37
|
-
type:
|
|
37
|
+
type: 'tool_call';
|
|
38
38
|
callId: string;
|
|
39
39
|
toolName: string;
|
|
40
40
|
input: unknown;
|
|
41
41
|
startedAt?: string;
|
|
42
42
|
groupKey?: string;
|
|
43
43
|
} | {
|
|
44
|
-
type:
|
|
44
|
+
type: 'tool_result';
|
|
45
45
|
callId: string;
|
|
46
46
|
toolName: string;
|
|
47
47
|
output: string;
|
|
@@ -49,12 +49,12 @@ export type RuntimeEvent = {
|
|
|
49
49
|
durationMs?: number;
|
|
50
50
|
groupKey?: string;
|
|
51
51
|
} | {
|
|
52
|
-
type:
|
|
52
|
+
type: 'text';
|
|
53
53
|
text: string;
|
|
54
54
|
project?: boolean;
|
|
55
55
|
groupKey?: string;
|
|
56
56
|
} | {
|
|
57
|
-
type:
|
|
57
|
+
type: 'error';
|
|
58
58
|
message: string;
|
|
59
59
|
};
|
|
60
60
|
export type DispatchOpts = {
|
|
@@ -105,5 +105,12 @@ export interface DispatchAdapter {
|
|
|
105
105
|
getBranchPoint?(sessionKey: string): string | undefined;
|
|
106
106
|
/** Return the path to the session's history file on disk, if the runtime persists it. */
|
|
107
107
|
getSessionHistoryPath?(sessionKey: string): string | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Abort the in-flight dispatch for the given session. Called by the gateway
|
|
110
|
+
* when the dispatch deadline is exceeded. Implementations should unblock the
|
|
111
|
+
* `dispatch()` generator (e.g. close a turn sink, end stdin, fail a stream)
|
|
112
|
+
* so the `for await` loop in `runDispatch` exits naturally. Must be idempotent.
|
|
113
|
+
*/
|
|
114
|
+
abortDispatch?(sessionKey: string): void;
|
|
108
115
|
}
|
|
109
116
|
//# sourceMappingURL=dispatch-adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-adapter.d.ts","sourceRoot":"","sources":["../src/dispatch-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,aAAa,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gFAAgF;IAChF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,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AAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAE/D;;;;;OAKG;IACH,aAAa,CAAC,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C"}
|
package/dist/event-format.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ForkResult, ParallEvent } from
|
|
1
|
+
import type { ForkResult, ParallEvent } from './types.js';
|
|
2
2
|
export declare function buildEventBody(event: ParallEvent): string;
|
|
3
3
|
export declare function buildEventBodyForForkResult(event: ParallEvent): string;
|
|
4
4
|
export declare function buildForkScopePrefix(event: ParallEvent): string;
|
|
@@ -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;
|
|
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;AAS1D,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CA4FzD;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAEtE;AAyBD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAK/D;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CAkBnE"}
|
package/dist/event-format.js
CHANGED
|
@@ -1,18 +1,42 @@
|
|
|
1
1
|
function sanitizeMeta(value) {
|
|
2
|
-
return value
|
|
2
|
+
return value
|
|
3
|
+
.replace(/[\r\n]+/g, ' ')
|
|
4
|
+
.replace(/[[\]|]/g, ' ')
|
|
5
|
+
.trim();
|
|
3
6
|
}
|
|
4
7
|
export function buildEventBody(event) {
|
|
5
8
|
const lines = [];
|
|
6
|
-
if (event.type ===
|
|
9
|
+
if (event.type === 'message') {
|
|
7
10
|
lines.push(`[Event: message.new]`);
|
|
8
11
|
const chatLabel = event.targetName
|
|
9
12
|
? `"${event.targetName}" (prll://${event.targetId})`
|
|
10
13
|
: `prll://${event.targetId}`;
|
|
11
|
-
lines.push(`[Chat: ${chatLabel} | type: ${event.targetType ??
|
|
14
|
+
lines.push(`[Chat: ${chatLabel} | type: ${event.targetType ?? 'unknown'}]`);
|
|
12
15
|
lines.push(`[From: ${event.senderName} (prll://${event.senderId})]`);
|
|
13
16
|
lines.push(`[Message ID: prll://${event.messageId}]`);
|
|
14
|
-
if (event.threadRootId)
|
|
15
|
-
|
|
17
|
+
if (event.threadRootId) {
|
|
18
|
+
const threadMeta = [
|
|
19
|
+
`prll://${event.threadRootId}`,
|
|
20
|
+
event.threadReplyCount != null ? `${event.threadReplyCount} replies` : null,
|
|
21
|
+
event.threadUnreadCount != null && event.threadUnreadCount > 0
|
|
22
|
+
? `${event.threadUnreadCount} unread`
|
|
23
|
+
: null,
|
|
24
|
+
event.threadUnreadCount != null && event.threadUnreadCount > 0 && event.threadUnreadSince
|
|
25
|
+
? `since: prll://${event.threadUnreadSince}`
|
|
26
|
+
: null,
|
|
27
|
+
]
|
|
28
|
+
.filter(Boolean)
|
|
29
|
+
.join(' | ');
|
|
30
|
+
lines.push(`[Thread: ${threadMeta}]`);
|
|
31
|
+
}
|
|
32
|
+
if (event.unreadCount != null && event.unreadCount > 1) {
|
|
33
|
+
const countStr = event.unreadCount >= 1000 ? '999+' : String(event.unreadCount);
|
|
34
|
+
const sinceStr = event.unreadSince ? ` | since: prll://${event.unreadSince}` : '';
|
|
35
|
+
let line = `[Unread: ${countStr} messages${sinceStr}]`;
|
|
36
|
+
if (event.unreadCount > 50)
|
|
37
|
+
line += ` — fetch recent context with --limit, not all`;
|
|
38
|
+
lines.push(line);
|
|
39
|
+
}
|
|
16
40
|
if (event.noReply)
|
|
17
41
|
lines.push(`[Hint: no_reply]`);
|
|
18
42
|
if (event.attachments?.length) {
|
|
@@ -23,9 +47,9 @@ export function buildEventBody(event) {
|
|
|
23
47
|
lines.push(`[Attachment: prll://${att.id} | ${sanitizeMeta(att.mimeType)} | ${sizeStr} | ${sanitizeMeta(att.fileName)}]`);
|
|
24
48
|
}
|
|
25
49
|
}
|
|
26
|
-
lines.push(
|
|
50
|
+
lines.push('', event.body);
|
|
27
51
|
}
|
|
28
|
-
else if (event.type ===
|
|
52
|
+
else if (event.type === 'task_comment') {
|
|
29
53
|
lines.push(`[Event: task.comment.created]`);
|
|
30
54
|
const taskLabel = event.targetName
|
|
31
55
|
? `${event.targetName} (prll://${event.targetId})`
|
|
@@ -35,16 +59,31 @@ export function buildEventBody(event) {
|
|
|
35
59
|
lines.push(`[Delivery: ${sanitizeMeta(event.deliveryReason)}]`);
|
|
36
60
|
lines.push(`[From: ${event.senderName} (prll://${event.senderId})]`);
|
|
37
61
|
lines.push(`[Comment ID: prll://${event.messageId}]`);
|
|
38
|
-
lines.push(
|
|
62
|
+
lines.push('', event.body);
|
|
63
|
+
}
|
|
64
|
+
else if (event.type === 'wiki_comment') {
|
|
65
|
+
lines.push(`[Event: wiki.comment.created]`);
|
|
66
|
+
const target = event.replyTargetUri ?? `prll://${event.targetId}`;
|
|
67
|
+
if (event.targetType === 'changeset') {
|
|
68
|
+
lines.push(`[Wiki Changeset: ${target}]`);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
lines.push(`[Wiki: ${event.targetName ? `${sanitizeMeta(event.targetName)} (${target})` : target}]`);
|
|
72
|
+
}
|
|
73
|
+
if (event.deliveryReason)
|
|
74
|
+
lines.push(`[Delivery: ${sanitizeMeta(event.deliveryReason)}]`);
|
|
75
|
+
lines.push(`[From: ${event.senderName} (prll://${event.senderId})]`);
|
|
76
|
+
lines.push(`[Comment ID: prll://${event.messageId}]`);
|
|
77
|
+
lines.push('', event.body);
|
|
39
78
|
}
|
|
40
|
-
else if (event.type ===
|
|
79
|
+
else if (event.type === 'approval') {
|
|
41
80
|
lines.push(`[Event: approval.decided]`);
|
|
42
81
|
lines.push(`[Approval: prll://${event.messageId}]`);
|
|
43
82
|
lines.push(`[Chat: prll://${event.targetId}]`);
|
|
44
83
|
lines.push(`[Decided by: ${event.senderName} (prll://${event.senderId})]`);
|
|
45
|
-
lines.push(
|
|
84
|
+
lines.push('', event.body);
|
|
46
85
|
}
|
|
47
|
-
else if (event.type ===
|
|
86
|
+
else if (event.type === 'schedule') {
|
|
48
87
|
lines.push(`[Event: schedule.fired]`);
|
|
49
88
|
lines.push(`[Schedule: prll://${event.targetId}]`);
|
|
50
89
|
lines.push(`[Run: prll://${event.messageId}]`);
|
|
@@ -52,7 +91,7 @@ export function buildEventBody(event) {
|
|
|
52
91
|
lines.push(`[Scheduled at: ${sanitizeMeta(event.scheduledFireAt)}]`);
|
|
53
92
|
if (event.attachedUri)
|
|
54
93
|
lines.push(`[Attached: ${sanitizeMeta(event.attachedUri)}]`);
|
|
55
|
-
lines.push(
|
|
94
|
+
lines.push('', event.body);
|
|
56
95
|
}
|
|
57
96
|
else {
|
|
58
97
|
lines.push(`[Event: task.assigned]`);
|
|
@@ -61,26 +100,30 @@ export function buildEventBody(event) {
|
|
|
61
100
|
: `prll://${event.targetId}`;
|
|
62
101
|
lines.push(`[Task: ${taskLabel}]`);
|
|
63
102
|
lines.push(`[Assigned by: ${event.senderName} (prll://${event.senderId})]`);
|
|
64
|
-
lines.push(
|
|
103
|
+
lines.push('', event.body);
|
|
65
104
|
}
|
|
66
|
-
return lines.join(
|
|
105
|
+
return lines.join('\n') + buildSendMessageHint(event);
|
|
67
106
|
}
|
|
68
107
|
export function buildEventBodyForForkResult(event) {
|
|
69
|
-
return buildEventBody(event).replace(/\n<system-reminder>[\s\S]*<\/system-reminder>$/,
|
|
108
|
+
return buildEventBody(event).replace(/\n<system-reminder>[\s\S]*<\/system-reminder>$/, '');
|
|
70
109
|
}
|
|
71
110
|
function buildSendMessageHint(event) {
|
|
72
111
|
if (event.noReply)
|
|
73
|
-
return
|
|
74
|
-
if (event.
|
|
112
|
+
return '';
|
|
113
|
+
if (event.type === 'wiki_comment' && event.replyTargetUri) {
|
|
114
|
+
const where = event.targetType === 'changeset' ? 'this changeset comment' : 'this wiki page';
|
|
115
|
+
return `\n<system-reminder>To reply on ${where}, run: \`parall comments add --target "${event.replyTargetUri}" --body "..."\` (read the thread first with \`parall comments list --target "${event.replyTargetUri}"\`). To message someone instead, use \`parall messages send\` / \`parall dm\`. Your plain text output is not delivered.</system-reminder>`;
|
|
116
|
+
}
|
|
117
|
+
if (event.targetId.startsWith('cht_')) {
|
|
75
118
|
return `\n<system-reminder>To reply, run: \`parall messages send prll://${event.targetId} --text "..."\` — your plain text output is not delivered to the chat.</system-reminder>`;
|
|
76
119
|
}
|
|
77
|
-
if (event.targetId.startsWith(
|
|
120
|
+
if (event.targetId.startsWith('tsk_')) {
|
|
78
121
|
return `\n<system-reminder>To respond, use the CLI: \`parall tasks update\` / \`parall tasks comments add\`. To message someone, use \`parall messages send\` / \`parall dm\`. Your plain text output is not delivered.</system-reminder>`;
|
|
79
122
|
}
|
|
80
|
-
if (event.targetId.startsWith(
|
|
123
|
+
if (event.targetId.startsWith('sch_')) {
|
|
81
124
|
return `\n<system-reminder>To communicate, use the CLI: \`parall messages send\` / \`parall dm\`. Your plain text output is not delivered.</system-reminder>`;
|
|
82
125
|
}
|
|
83
|
-
return
|
|
126
|
+
return '';
|
|
84
127
|
}
|
|
85
128
|
export function buildForkScopePrefix(event) {
|
|
86
129
|
const targetLabel = event.targetName
|
|
@@ -90,19 +133,19 @@ export function buildForkScopePrefix(event) {
|
|
|
90
133
|
}
|
|
91
134
|
export function buildForkResultPrefix(results) {
|
|
92
135
|
if (!results.length)
|
|
93
|
-
return
|
|
136
|
+
return '';
|
|
94
137
|
const blocks = results.map((result) => {
|
|
95
138
|
const lines = [];
|
|
96
139
|
for (const body of result.eventBodies) {
|
|
97
140
|
lines.push(body);
|
|
98
141
|
}
|
|
99
142
|
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) :
|
|
143
|
+
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
144
|
if (result.actions.length)
|
|
102
|
-
lines.push(`[Fork actions: ${result.actions.join(
|
|
145
|
+
lines.push(`[Fork actions: ${result.actions.join('; ')}]`);
|
|
103
146
|
if (result.historyPath)
|
|
104
147
|
lines.push(`[Fork history: ${result.historyPath}]`);
|
|
105
|
-
return lines.join(
|
|
148
|
+
return lines.join('\n');
|
|
106
149
|
});
|
|
107
|
-
return blocks.join(
|
|
150
|
+
return blocks.join('\n\n') + '\n\n---\n\n';
|
|
108
151
|
}
|
package/dist/gateway-base.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ParallClient, ParallWs } from
|
|
2
|
-
import type { AgentConfigUpdateData } from
|
|
3
|
-
import type { DispatchAdapter, GatewayLogger } from
|
|
1
|
+
import { ParallClient, ParallWs } from '@parall/sdk';
|
|
2
|
+
import type { AgentConfigUpdateData } from '@parall/sdk';
|
|
3
|
+
import type { DispatchAdapter, GatewayLogger } from './dispatch-adapter.js';
|
|
4
4
|
export type ParallGatewayOptions = {
|
|
5
5
|
accountId: string;
|
|
6
6
|
client: ParallClient;
|
|
@@ -17,8 +17,11 @@ export type ParallGatewayOptions = {
|
|
|
17
17
|
runtimeRef?: Record<string, unknown>;
|
|
18
18
|
dispatchAdapter: DispatchAdapter;
|
|
19
19
|
log?: GatewayLogger;
|
|
20
|
+
/** @deprecated No-op. Cold-start time filter has been removed to prevent silent dispatch loss. */
|
|
20
21
|
coldStartWindowMs?: number;
|
|
21
22
|
shutdownDeadlineMs?: number;
|
|
23
|
+
forkDeadlineMs?: number;
|
|
24
|
+
dispatchDeadlineMs?: number;
|
|
22
25
|
contextFilePathForSession?: (sessionKey: string) => string | undefined;
|
|
23
26
|
/** @deprecated Use contextFilePathForSession. Kept for runtimes that haven't migrated. */
|
|
24
27
|
stepIdFilePathForSession?: (sessionKey: string) => string | undefined;
|
|
@@ -39,11 +42,11 @@ export type ParallGatewayOptions = {
|
|
|
39
42
|
onSessionStale?: (sessionKey: string) => Promise<void> | void;
|
|
40
43
|
};
|
|
41
44
|
export declare function parseShutdownDeadlineMs(raw: string | undefined): number | undefined;
|
|
45
|
+
export declare function parseForkDeadlineMs(raw: string | undefined): number | undefined;
|
|
46
|
+
export declare function parseDispatchDeadlineMs(raw: string | undefined): number | undefined;
|
|
42
47
|
export declare class ParallAgentGateway {
|
|
43
48
|
private readonly opts;
|
|
44
49
|
private readonly chatInfoMap;
|
|
45
|
-
private readonly activeDispatches;
|
|
46
|
-
private readonly injectedTypingCounts;
|
|
47
50
|
private readonly dispatchedTasks;
|
|
48
51
|
private readonly dispatchedMessages;
|
|
49
52
|
private readonly forkStates;
|
|
@@ -52,7 +55,6 @@ export declare class ParallAgentGateway {
|
|
|
52
55
|
private activeSessionId;
|
|
53
56
|
private readonly sessionBindings;
|
|
54
57
|
private heartbeatTimer;
|
|
55
|
-
private hadSuccessfulHello;
|
|
56
58
|
private lastHeartbeatAt;
|
|
57
59
|
private draining;
|
|
58
60
|
private shuttingDown;
|
|
@@ -60,18 +62,15 @@ export declare class ParallAgentGateway {
|
|
|
60
62
|
private drainResolvers;
|
|
61
63
|
private pendingRestartNotification;
|
|
62
64
|
private readonly DISPATCHED_MESSAGES_CAP;
|
|
63
|
-
private readonly COLD_START_WINDOW_MS;
|
|
64
65
|
private readonly SHUTDOWN_DEADLINE_MS;
|
|
66
|
+
private readonly FORK_DEADLINE_MS;
|
|
67
|
+
private readonly DISPATCH_DEADLINE_MS;
|
|
65
68
|
constructor(opts: ParallGatewayOptions);
|
|
66
69
|
run(abortSignal: AbortSignal): Promise<void>;
|
|
67
70
|
private tryClaimMessage;
|
|
68
|
-
private
|
|
69
|
-
private stopTyping;
|
|
70
|
-
private shouldShowTyping;
|
|
71
|
-
private startInjectedTyping;
|
|
72
|
-
private takeInjectedTypingCount;
|
|
73
|
-
private runDispatchWithTyping;
|
|
71
|
+
private emitDispatchReceived;
|
|
74
72
|
private buildDispatchContext;
|
|
73
|
+
private isSessionNotLiveError;
|
|
75
74
|
private createInputStep;
|
|
76
75
|
private createRuntimeStep;
|
|
77
76
|
private writeContextFile;
|
|
@@ -84,6 +83,7 @@ export declare class ParallAgentGateway {
|
|
|
84
83
|
private createInputStepsForEarlierEvents;
|
|
85
84
|
private bindRuntimeSession;
|
|
86
85
|
private runDispatch;
|
|
86
|
+
private abortFork;
|
|
87
87
|
private runForkDrainLoop;
|
|
88
88
|
private drainMainBuffer;
|
|
89
89
|
private handleInboundEvent;
|
|
@@ -93,6 +93,7 @@ export declare class ParallAgentGateway {
|
|
|
93
93
|
private handleTaskAssignment;
|
|
94
94
|
private handleTaskDispatch;
|
|
95
95
|
private handleTaskComment;
|
|
96
|
+
private handleWikiComment;
|
|
96
97
|
/**
|
|
97
98
|
* Fetch the schedule_run snapshot, then feed it as an inbound event. 404 is
|
|
98
99
|
* tolerated and treated as "dispatched" so the caller can ack the stale
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway-base.d.ts","sourceRoot":"","sources":["../src/gateway-base.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"gateway-base.d.ts","sourceRoot":"","sources":["../src/gateway-base.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiC,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,KAAK,EACV,qBAAqB,EAetB,MAAM,aAAa,CAAC;AAOrB,OAAO,KAAK,EAEV,eAAe,EAGf,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAuE/B,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,MAAM,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