@parall/agent-core 1.28.0 → 1.28.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/bridge-workspace.d.ts +1 -1
- package/dist/bridge-workspace.d.ts.map +1 -1
- package/dist/bridge-workspace.js +23 -0
- package/dist/dispatch-adapter.d.ts +16 -0
- package/dist/dispatch-adapter.d.ts.map +1 -1
- package/dist/event-format.d.ts.map +1 -1
- package/dist/event-format.js +15 -1
- package/dist/gateway-base.d.ts.map +1 -1
- package/dist/gateway-base.js +15 -1
- package/package.json +2 -2
- package/src/bridge-workspace.ts +23 -0
- package/src/dispatch-adapter.ts +18 -0
- package/src/event-format.ts +19 -1
- package/src/gateway-base.ts +19 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* `@parall/agent-core` stays runtime-neutral and exports only text + pure
|
|
8
8
|
* helpers here.
|
|
9
9
|
*/
|
|
10
|
-
export declare const BRIDGE_WORKSPACE_INSTRUCTIONS = "# Agent workspace\n\nYou are an agent in Parall IM. You participate in chats, handle tasks, and interact exclusively through the Parall CLI.\n\n## Message Model\n\nIncoming events are rendered as structured `[Event: ...]` blocks.\nEach event includes `[Chat: ... (prll://cht_xxx)]` \u2014 use that chat ID (or full URI) when replying.\n\n**Your plain-text output is not delivered to anyone** \u2014 it is recorded as suppressed thinking in your session steps and discarded from the chat.\nTo say something in a chat, you **must** invoke the Parall CLI via your shell/exec tool. To stay silent, simply do not invoke it.\n\n## Parall CLI\n\nAll outbound interactions go through the `parall` CLI. Credentials are pre-injected as environment variables \u2014 no setup needed. If `parall` is not on PATH, use `npx --yes @parall/cli@latest` instead.\n\n- `parall messages send prll://cht_xxx --text \"...\"` \u2014 reply into the triggering chat\n- `parall dm prll://usr_xxx --text \"...\" [--no-reply]` \u2014 direct message another user\n- `parall tasks update prll://tsk_xxx --status in_progress` \u2014 task state\n- `parall no-reply [--reason \"...\"]` \u2014 explicitly declare this turn silent (audit signal; not required for silence, just clarifies intent)\n\nThe bridge injects Parall context via environment variables. The static credentials `PRLL_API_URL`, `PRLL_API_KEY`, and `PRLL_ORG_ID` are always set. `PRLL_CONTEXT_FILE` points to a per-session JSON file that the gateway updates each dispatch with `session_id`, `chat_id`, `trigger_message_id`, `no_reply`, and `step_id` (updated per tool call). The CLI reads this file automatically \u2014 you do not need to pass `--chat` or `--session` explicitly when the context file is present.\n\n## Attachments\n\nImage attachments are pre-downloaded under `.parall/attachments/<messageId>/`. Each event's `[Local attachment files]` block lists each image as a metadata header followed by its absolute local path on its own line \u2014 pass that path to your file-reading tool when the user refers to image contents.\n\nSupported image types: PNG, JPEG, WebP, GIF. Other attachment types (PDFs, archives, etc.) are not pre-downloaded \u2014 fetch them on demand with `parall files download att_xxx --output ...`.\n\n## Guardrails\n\n- A dispatch may coalesce multiple events. Decide per event whether to reply via `messages send` / `dm` \u2014 events you do not act on simply receive no reply.\n- If an event carries `[Hint: no_reply]`, do not send anything for that event. `no-reply` is optional and only useful as an explicit intent marker.\n- Never try to \"speak\" by typing sentences like \"No response needed\" / \"Noted\" / \"OK\" \u2014 they are discarded, so they accomplish nothing except polluting your session log.\n- Keep CLI replies concise and task-focused.\n\nSee `docs/engineering-design/agent-dm-loop-prevention.md` \u00A7 Layer 0 for why plain text is never auto-projected.\n\n## Approval Flow\n\nWhen you try an action (e.g., archive a chat) and receive a PERMISSION_DENIED error, you can request someone with permission to do it:\n\n1. The error includes a `PERMISSION_DENIED` code. For commonly approvable actions (archive, delete, restore), a `Tip:` line with an approval-request template is printed \u2014 copy it and fill in the remaining placeholders (`--chat`, `--title`, `--reason`)\n2. Request approval: `parall approvals request --action chat.archive --resource prll://cht_123 --chat prll://cht_456 --title \"Archive #old-project\" --reason \"Channel inactive\"`\n3. A card will appear in the specified chat for someone with permission to approve\n4. Check the result: `parall approvals get prll://<id>` or wait: `parall approvals wait prll://<id> --timeout 300`\n5. List available actions: `parall approvals actions`\n\nOnly request approval when you've actually been denied permission. Don't request approval preemptively.\n";
|
|
10
|
+
export declare const BRIDGE_WORKSPACE_INSTRUCTIONS = "# Agent workspace\n\nYou are an agent in Parall IM. You participate in chats, handle tasks, and interact exclusively through the Parall CLI.\n\n## Message Model\n\nIncoming events are rendered as structured `[Event: ...]` blocks.\nEach event includes `[Chat: ... (prll://cht_xxx)]` \u2014 use that chat ID (or full URI) when replying.\n\n**Your plain-text output is not delivered to anyone** \u2014 it is recorded as suppressed thinking in your session steps and discarded from the chat.\nTo say something in a chat, you **must** invoke the Parall CLI via your shell/exec tool. To stay silent, simply do not invoke it.\n\n## Parall CLI\n\nAll outbound interactions go through the `parall` CLI. Credentials are pre-injected as environment variables \u2014 no setup needed. If `parall` is not on PATH, use `npx --yes @parall/cli@latest` instead.\n\n- `parall messages send prll://cht_xxx --text \"...\"` \u2014 reply into the triggering chat\n- `parall dm prll://usr_xxx --text \"...\" [--no-reply]` \u2014 direct message another user\n- `parall tasks update prll://tsk_xxx --status in_progress` \u2014 task state\n- `parall no-reply [--reason \"...\"]` \u2014 explicitly declare this turn silent (audit signal; not required for silence, just clarifies intent)\n\nThe bridge injects Parall context via environment variables. The static credentials `PRLL_API_URL`, `PRLL_API_KEY`, and `PRLL_ORG_ID` are always set. `PRLL_CONTEXT_FILE` points to a per-session JSON file that the gateway updates each dispatch with `session_id`, `chat_id`, `trigger_message_id`, `no_reply`, and `step_id` (updated per tool call). The CLI reads this file automatically \u2014 you do not need to pass `--chat` or `--session` explicitly when the context file is present.\n\n## Attachments\n\nImage attachments are pre-downloaded under `.parall/attachments/<messageId>/`. Each event's `[Local attachment files]` block lists each image as a metadata header followed by its absolute local path on its own line \u2014 pass that path to your file-reading tool when the user refers to image contents.\n\nSupported image types: PNG, JPEG, WebP, GIF. Other attachment types (PDFs, archives, etc.) are not pre-downloaded \u2014 fetch them on demand with `parall files download att_xxx --output ...`.\n\n## Guardrails\n\n- A dispatch may coalesce multiple events. Decide per event whether to reply via `messages send` / `dm` \u2014 events you do not act on simply receive no reply.\n- If an event carries `[Hint: no_reply]`, do not send anything for that event. `no-reply` is optional and only useful as an explicit intent marker.\n- Never try to \"speak\" by typing sentences like \"No response needed\" / \"Noted\" / \"OK\" \u2014 they are discarded, so they accomplish nothing except polluting your session log.\n- Keep CLI replies concise and task-focused.\n\nSee `docs/engineering-design/agent-dm-loop-prevention.md` \u00A7 Layer 0 for why plain text is never auto-projected.\n\n## Approval Flow\n\nWhen you try an action (e.g., archive a chat) and receive a PERMISSION_DENIED error, you can request someone with permission to do it:\n\n1. The error includes a `PERMISSION_DENIED` code. For commonly approvable actions (archive, delete, restore), a `Tip:` line with an approval-request template is printed \u2014 copy it and fill in the remaining placeholders (`--chat`, `--title`, `--reason`)\n2. Request approval: `parall approvals request --action chat.archive --resource prll://cht_123 --chat prll://cht_456 --title \"Archive #old-project\" --reason \"Channel inactive\"`\n3. A card will appear in the specified chat for someone with permission to approve\n4. Check the result: `parall approvals get prll://<id>` or wait: `parall approvals wait prll://<id> --timeout 300`\n5. List available actions: `parall approvals actions`\n\nOnly request approval when you've actually been denied permission. Don't request approval preemptively.\n\n## Threads\n\nMessages may arrive with a `[Thread: prll://msg_xxx]` line in the event block, indicating the message is a reply inside a thread rooted at `msg_xxx`.\n\n### When to use threads\n- Replying to a specific message or continuing a focused sub-conversation\n- Keeping detailed discussion (logs, debugging, follow-ups) out of the main channel flow\n- When someone starts a thread with you, reply in the same thread\n\n### When NOT to use threads\n- Broadcasting status updates or announcements \u2014 use top-level messages\n- Starting a new topic \u2014 post at top level, let others thread if needed\n\n### CLI usage\n- The `msg_xxx` from the `[Thread: prll://msg_xxx]` line is the thread root ID \u2014 pass it as `--thread-root-id`\n- Reply in a thread: `parall messages send <chatId> --text \"...\" --thread-root-id <msgId>`\n- Read thread replies: `parall messages list <chatId> --thread-root-id <msgId>`\n\n### Thread etiquette\n- If your trigger message is in a thread, reply in that thread by default\n- Don't duplicate thread content to the channel unless explicitly asked\n- Keep thread replies focused on the original topic\n";
|
|
11
11
|
/** Extracts the `command` string from a shell/bash tool call's input payload. */
|
|
12
12
|
export declare function extractShellCommand(input: unknown): string | undefined;
|
|
13
13
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge-workspace.d.ts","sourceRoot":"","sources":["../src/bridge-workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,6BAA6B,
|
|
1
|
+
{"version":3,"file":"bridge-workspace.d.ts","sourceRoot":"","sources":["../src/bridge-workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,6BAA6B,q8JAwEzC,CAAC;AAEF,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAItE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAmBzE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAKxE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAI3E"}
|
package/dist/bridge-workspace.js
CHANGED
|
@@ -56,6 +56,29 @@ When you try an action (e.g., archive a chat) and receive a PERMISSION_DENIED er
|
|
|
56
56
|
5. List available actions: \`parall approvals actions\`
|
|
57
57
|
|
|
58
58
|
Only request approval when you've actually been denied permission. Don't request approval preemptively.
|
|
59
|
+
|
|
60
|
+
## Threads
|
|
61
|
+
|
|
62
|
+
Messages may arrive with a \`[Thread: prll://msg_xxx]\` line in the event block, indicating the message is a reply inside a thread rooted at \`msg_xxx\`.
|
|
63
|
+
|
|
64
|
+
### When to use threads
|
|
65
|
+
- Replying to a specific message or continuing a focused sub-conversation
|
|
66
|
+
- Keeping detailed discussion (logs, debugging, follow-ups) out of the main channel flow
|
|
67
|
+
- When someone starts a thread with you, reply in the same thread
|
|
68
|
+
|
|
69
|
+
### When NOT to use threads
|
|
70
|
+
- Broadcasting status updates or announcements — use top-level messages
|
|
71
|
+
- Starting a new topic — post at top level, let others thread if needed
|
|
72
|
+
|
|
73
|
+
### CLI usage
|
|
74
|
+
- The \`msg_xxx\` from the \`[Thread: prll://msg_xxx]\` line is the thread root ID — pass it as \`--thread-root-id\`
|
|
75
|
+
- Reply in a thread: \`parall messages send <chatId> --text "..." --thread-root-id <msgId>\`
|
|
76
|
+
- Read thread replies: \`parall messages list <chatId> --thread-root-id <msgId>\`
|
|
77
|
+
|
|
78
|
+
### Thread etiquette
|
|
79
|
+
- If your trigger message is in a thread, reply in that thread by default
|
|
80
|
+
- Don't duplicate thread content to the channel unless explicitly asked
|
|
81
|
+
- Keep thread replies focused on the original topic
|
|
59
82
|
`;
|
|
60
83
|
/** Extracts the `command` string from a shell/bash tool call's input payload. */
|
|
61
84
|
export function extractShellCommand(input) {
|
|
@@ -79,6 +79,22 @@ export type CleanupForkOpts = {
|
|
|
79
79
|
export interface DispatchAdapter {
|
|
80
80
|
/** Dispatch a Parall event to the runtime and emit normalized runtime events. */
|
|
81
81
|
dispatch(opts: DispatchOpts): AsyncIterable<RuntimeEvent>;
|
|
82
|
+
/**
|
|
83
|
+
* Inject a user message into the running subprocess's stdin mid-turn so the
|
|
84
|
+
* runtime reads it between tool calls and steers immediately, rather than
|
|
85
|
+
* waiting for the current turn to complete.
|
|
86
|
+
*
|
|
87
|
+
* Returns true if the message was successfully written to stdin; false if no
|
|
88
|
+
* live process exists for the session (caller should fall back to mainBuffer).
|
|
89
|
+
*
|
|
90
|
+
* The gateway still pushes the event to mainBuffer after a successful
|
|
91
|
+
* injection — drainMainBuffer will call dispatch() for it, and dispatch()
|
|
92
|
+
* must detect the pending injection (skip the stdin write) and only consume
|
|
93
|
+
* the parser output that Claude produced in response.
|
|
94
|
+
*/
|
|
95
|
+
enqueueDuringDispatch?(sessionKey: string, body: string): boolean;
|
|
96
|
+
/** True if enqueueDuringDispatch was called and the injections have not yet been consumed by dispatch(). */
|
|
97
|
+
hasPendingInjections?(sessionKey: string): boolean;
|
|
82
98
|
/** Fork the current runtime session for concurrent handling. Return null to buffer on main. */
|
|
83
99
|
forkSession?(opts: ForkOpts): Promise<ForkSessionHandle | null> | ForkSessionHandle | null;
|
|
84
100
|
/** Clean up a fork session created by forkSession(). */
|
|
@@ -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;CAC9B,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,MAAM,EAAE,YAAY,CAAC;IACrB,GAAG,CAAC,EAAE,aAAa,CAAC;CACrB,CAAC;AAEF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AAG,OAAO,CAAC;IAEnD,+FAA+F;IAC/F,WAAW,CAAC,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,GAAG,iBAAiB,GAAG,IAAI,CAAC;IAE3F,wDAAwD;IACxD,WAAW,CAAC,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAE1D,6FAA6F;IAC7F,cAAc,CAAC,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAExD,yFAAyF;IACzF,qBAAqB,CAAC,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAChE"}
|
|
@@ -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;
|
|
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,CAWnE"}
|
package/dist/event-format.js
CHANGED
|
@@ -63,7 +63,21 @@ export function buildEventBody(event) {
|
|
|
63
63
|
lines.push(`[Assigned by: ${event.senderName} (prll://${event.senderId})]`);
|
|
64
64
|
lines.push("", event.body);
|
|
65
65
|
}
|
|
66
|
-
return lines.join("\n");
|
|
66
|
+
return lines.join("\n") + buildSendMessageHint(event);
|
|
67
|
+
}
|
|
68
|
+
function buildSendMessageHint(event) {
|
|
69
|
+
if (event.noReply)
|
|
70
|
+
return "";
|
|
71
|
+
if (event.targetId.startsWith("cht_")) {
|
|
72
|
+
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>`;
|
|
73
|
+
}
|
|
74
|
+
if (event.targetId.startsWith("tsk_")) {
|
|
75
|
+
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>`;
|
|
76
|
+
}
|
|
77
|
+
if (event.targetId.startsWith("sch_")) {
|
|
78
|
+
return `\n<system-reminder>To communicate, use the CLI: \`parall messages send\` / \`parall dm\`. Your plain text output is not delivered.</system-reminder>`;
|
|
79
|
+
}
|
|
80
|
+
return "";
|
|
67
81
|
}
|
|
68
82
|
export function buildForkScopePrefix(event) {
|
|
69
83
|
const targetLabel = event.targetName
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway-base.d.ts","sourceRoot":"","sources":["../src/gateway-base.ts"],"names":[],"mappings":"AAIA,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,E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CAAS;gBAEjB,IAAI,EAAE,oBAAoB;IAKjD,GAAG,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAmIlD,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,UAAU;IAWlB,OAAO,CAAC,oBAAoB;YAqBd,eAAe;YA8Bf,iBAAiB;IAyF/B,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,uBAAuB;IAW/B,OAAO,CAAC,0BAA0B;IAWlC,kEAAkE;IAClE,OAAO,CAAC,eAAe;IASvB,kEAAkE;IAClE,OAAO,CAAC,eAAe;YAQT,gCAAgC;YAMhC,kBAAkB;YAoDlB,WAAW;YAqIX,gBAAgB;YAsGhB,eAAe;YAiFf,kBAAkB;YA6FlB,kBAAkB;YAkBlB,4BAA4B;YAoD5B,aAAa;YA+Bb,oBAAoB;YAoCpB,kBAAkB;YAwBlB,iBAAiB;IAiF/B;;;;;;;OAOG;YACW,0BAA0B;YAsB1B,kBAAkB;YAsClB,6BAA6B;YA+C7B,mBAAmB;YAoGnB,WAAW;IA+CzB,OAAO,CAAC,YAAY;YAiBN,QAAQ;CAkCvB"}
|
package/dist/gateway-base.js
CHANGED
|
@@ -572,9 +572,18 @@ export class ParallAgentGateway {
|
|
|
572
572
|
}
|
|
573
573
|
await this.createRuntimeStep(binding.agentSessionId, event, runtimeEvent, stepIdFilePath, contextFilePath);
|
|
574
574
|
}
|
|
575
|
+
if (!binding) {
|
|
576
|
+
binding = this.sessionBindings.get(sessionKey);
|
|
577
|
+
}
|
|
575
578
|
if (!binding) {
|
|
576
579
|
throw new Error("runtime completed without runtime_session");
|
|
577
580
|
}
|
|
581
|
+
if (!inputStepsCreated) {
|
|
582
|
+
if (earlierEvents.length > 0) {
|
|
583
|
+
await this.createInputStepsForEarlierEvents(binding.agentSessionId, earlierEvents);
|
|
584
|
+
}
|
|
585
|
+
await this.createInputStep(binding.agentSessionId, event);
|
|
586
|
+
}
|
|
578
587
|
}
|
|
579
588
|
catch (err) {
|
|
580
589
|
if (binding) {
|
|
@@ -755,7 +764,8 @@ export class ParallAgentGateway {
|
|
|
755
764
|
}
|
|
756
765
|
const event = events[events.length - 1];
|
|
757
766
|
const earlier = events.slice(0, -1);
|
|
758
|
-
const
|
|
767
|
+
const skipForkSplice = this.opts.dispatchAdapter.hasPendingInjections?.(this.opts.runtimeKey) ?? false;
|
|
768
|
+
const pendingFork = skipForkSplice ? [] : this.dispatchState.pendingForkResults.splice(0);
|
|
759
769
|
const forkPrefix = buildForkResultPrefix(pendingFork);
|
|
760
770
|
this.dispatchState.mainCurrentTargetId = event.targetId;
|
|
761
771
|
this.dispatchState.mainPreDispatchBranchPoint =
|
|
@@ -817,6 +827,10 @@ export class ParallAgentGateway {
|
|
|
817
827
|
if (this.shuttingDown) {
|
|
818
828
|
return false;
|
|
819
829
|
}
|
|
830
|
+
if (this.dispatchState.mainCurrentTargetId === event.targetId &&
|
|
831
|
+
this.opts.dispatchAdapter.enqueueDuringDispatch?.(this.opts.runtimeKey, buildEventBody(event))) {
|
|
832
|
+
this.opts.log?.info(`parall[${this.opts.accountId}]: steer injected to stdin for ${event.messageId} (will drain for bookkeeping)`);
|
|
833
|
+
}
|
|
820
834
|
this.dispatchState.mainBuffer.push(event);
|
|
821
835
|
return false;
|
|
822
836
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parall/agent-core",
|
|
3
|
-
"version": "1.28.
|
|
3
|
+
"version": "1.28.1",
|
|
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.28.
|
|
29
|
+
"@parall/sdk": "1.28.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^22.0.0",
|
package/src/bridge-workspace.ts
CHANGED
|
@@ -57,6 +57,29 @@ When you try an action (e.g., archive a chat) and receive a PERMISSION_DENIED er
|
|
|
57
57
|
5. List available actions: \`parall approvals actions\`
|
|
58
58
|
|
|
59
59
|
Only request approval when you've actually been denied permission. Don't request approval preemptively.
|
|
60
|
+
|
|
61
|
+
## Threads
|
|
62
|
+
|
|
63
|
+
Messages may arrive with a \`[Thread: prll://msg_xxx]\` line in the event block, indicating the message is a reply inside a thread rooted at \`msg_xxx\`.
|
|
64
|
+
|
|
65
|
+
### When to use threads
|
|
66
|
+
- Replying to a specific message or continuing a focused sub-conversation
|
|
67
|
+
- Keeping detailed discussion (logs, debugging, follow-ups) out of the main channel flow
|
|
68
|
+
- When someone starts a thread with you, reply in the same thread
|
|
69
|
+
|
|
70
|
+
### When NOT to use threads
|
|
71
|
+
- Broadcasting status updates or announcements — use top-level messages
|
|
72
|
+
- Starting a new topic — post at top level, let others thread if needed
|
|
73
|
+
|
|
74
|
+
### CLI usage
|
|
75
|
+
- The \`msg_xxx\` from the \`[Thread: prll://msg_xxx]\` line is the thread root ID — pass it as \`--thread-root-id\`
|
|
76
|
+
- Reply in a thread: \`parall messages send <chatId> --text "..." --thread-root-id <msgId>\`
|
|
77
|
+
- Read thread replies: \`parall messages list <chatId> --thread-root-id <msgId>\`
|
|
78
|
+
|
|
79
|
+
### Thread etiquette
|
|
80
|
+
- If your trigger message is in a thread, reply in that thread by default
|
|
81
|
+
- Don't duplicate thread content to the channel unless explicitly asked
|
|
82
|
+
- Keep thread replies focused on the original topic
|
|
60
83
|
`;
|
|
61
84
|
|
|
62
85
|
/** Extracts the `command` string from a shell/bash tool call's input payload. */
|
package/src/dispatch-adapter.ts
CHANGED
|
@@ -67,6 +67,24 @@ export interface DispatchAdapter {
|
|
|
67
67
|
/** Dispatch a Parall event to the runtime and emit normalized runtime events. */
|
|
68
68
|
dispatch(opts: DispatchOpts): AsyncIterable<RuntimeEvent>;
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Inject a user message into the running subprocess's stdin mid-turn so the
|
|
72
|
+
* runtime reads it between tool calls and steers immediately, rather than
|
|
73
|
+
* waiting for the current turn to complete.
|
|
74
|
+
*
|
|
75
|
+
* Returns true if the message was successfully written to stdin; false if no
|
|
76
|
+
* live process exists for the session (caller should fall back to mainBuffer).
|
|
77
|
+
*
|
|
78
|
+
* The gateway still pushes the event to mainBuffer after a successful
|
|
79
|
+
* injection — drainMainBuffer will call dispatch() for it, and dispatch()
|
|
80
|
+
* must detect the pending injection (skip the stdin write) and only consume
|
|
81
|
+
* the parser output that Claude produced in response.
|
|
82
|
+
*/
|
|
83
|
+
enqueueDuringDispatch?(sessionKey: string, body: string): boolean;
|
|
84
|
+
|
|
85
|
+
/** True if enqueueDuringDispatch was called and the injections have not yet been consumed by dispatch(). */
|
|
86
|
+
hasPendingInjections?(sessionKey: string): boolean;
|
|
87
|
+
|
|
70
88
|
/** Fork the current runtime session for concurrent handling. Return null to buffer on main. */
|
|
71
89
|
forkSession?(opts: ForkOpts): Promise<ForkSessionHandle | null> | ForkSessionHandle | null;
|
|
72
90
|
|
package/src/event-format.ts
CHANGED
|
@@ -57,7 +57,25 @@ export function buildEventBody(event: ParallEvent): string {
|
|
|
57
57
|
lines.push(`[Assigned by: ${event.senderName} (prll://${event.senderId})]`);
|
|
58
58
|
lines.push("", event.body);
|
|
59
59
|
}
|
|
60
|
-
return lines.join("\n");
|
|
60
|
+
return lines.join("\n") + buildSendMessageHint(event);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function buildSendMessageHint(event: ParallEvent): string {
|
|
64
|
+
if (event.noReply) return "";
|
|
65
|
+
|
|
66
|
+
if (event.targetId.startsWith("cht_")) {
|
|
67
|
+
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>`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (event.targetId.startsWith("tsk_")) {
|
|
71
|
+
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>`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (event.targetId.startsWith("sch_")) {
|
|
75
|
+
return `\n<system-reminder>To communicate, use the CLI: \`parall messages send\` / \`parall dm\`. Your plain text output is not delivered.</system-reminder>`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return "";
|
|
61
79
|
}
|
|
62
80
|
|
|
63
81
|
export function buildForkScopePrefix(event: ParallEvent): string {
|
package/src/gateway-base.ts
CHANGED
|
@@ -714,9 +714,18 @@ export class ParallAgentGateway {
|
|
|
714
714
|
}
|
|
715
715
|
await this.createRuntimeStep(binding.agentSessionId, event, runtimeEvent, stepIdFilePath, contextFilePath);
|
|
716
716
|
}
|
|
717
|
+
if (!binding) {
|
|
718
|
+
binding = this.sessionBindings.get(sessionKey);
|
|
719
|
+
}
|
|
717
720
|
if (!binding) {
|
|
718
721
|
throw new Error("runtime completed without runtime_session");
|
|
719
722
|
}
|
|
723
|
+
if (!inputStepsCreated) {
|
|
724
|
+
if (earlierEvents.length > 0) {
|
|
725
|
+
await this.createInputStepsForEarlierEvents(binding.agentSessionId, earlierEvents);
|
|
726
|
+
}
|
|
727
|
+
await this.createInputStep(binding.agentSessionId, event);
|
|
728
|
+
}
|
|
720
729
|
} catch (err) {
|
|
721
730
|
if (binding) {
|
|
722
731
|
await this.createRuntimeStep(binding.agentSessionId, event, {
|
|
@@ -900,7 +909,8 @@ export class ParallAgentGateway {
|
|
|
900
909
|
|
|
901
910
|
const event = events[events.length - 1];
|
|
902
911
|
const earlier = events.slice(0, -1);
|
|
903
|
-
const
|
|
912
|
+
const skipForkSplice = this.opts.dispatchAdapter.hasPendingInjections?.(this.opts.runtimeKey) ?? false;
|
|
913
|
+
const pendingFork = skipForkSplice ? [] : this.dispatchState.pendingForkResults.splice(0);
|
|
904
914
|
const forkPrefix = buildForkResultPrefix(pendingFork);
|
|
905
915
|
this.dispatchState.mainCurrentTargetId = event.targetId;
|
|
906
916
|
this.dispatchState.mainPreDispatchBranchPoint =
|
|
@@ -963,6 +973,14 @@ export class ParallAgentGateway {
|
|
|
963
973
|
if (this.shuttingDown) {
|
|
964
974
|
return false;
|
|
965
975
|
}
|
|
976
|
+
if (
|
|
977
|
+
this.dispatchState.mainCurrentTargetId === event.targetId &&
|
|
978
|
+
this.opts.dispatchAdapter.enqueueDuringDispatch?.(this.opts.runtimeKey, buildEventBody(event))
|
|
979
|
+
) {
|
|
980
|
+
this.opts.log?.info(
|
|
981
|
+
`parall[${this.opts.accountId}]: steer injected to stdin for ${event.messageId} (will drain for bookkeeping)`,
|
|
982
|
+
);
|
|
983
|
+
}
|
|
966
984
|
this.dispatchState.mainBuffer.push(event);
|
|
967
985
|
return false;
|
|
968
986
|
}
|