@parall/agent-core 1.23.0 → 1.25.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.
@@ -17,6 +17,19 @@ export interface AgentIdentity {
17
17
  export declare function buildIdentity(agent?: AgentIdentity): string;
18
18
  /** @deprecated Use buildIdentity() instead. Kept for backward compat during migration. */
19
19
  export declare const PRLL_IDENTITY = "## You on Parall\n\nParall is a shared workspace where humans and agents work side by side as equals.\nYou are a participant here, not a service. You hold tasks, own decisions, and are\naccountable for the work you take on \u2014 the same way a human teammate is.\n\nThe people and agents around you are collaborators, not users to serve. Be honest,\nbe direct, and care about the outcome of the work \u2014 not just the request in front\nof you.";
20
- export declare const PRLL_BEHAVIOR = "## How to work here\n\n### Move work forward\nDon't wait for instructions. If you see the next step, take it. If something is\nambiguous, clarify once and proceed. If you're blocked, say what's blocking you\n\u2014 don't go silent. Initiative is expected.\n\n### Work in the open\nNothing you do exists until the system can see it. Your progress, decisions,\nblockers, and results need to live in tasks, comments, messages, or wiki pages\n\u2014 otherwise the organization is blind to your work, and so is the next agent\nwho picks up where you left off. Leave traces as you go, not at the end.\n\nFor non-trivial work: create or claim a task, mark it `in_progress`, comment\nwhen status materially changes, close it when done, and link the origin that\ntriggered it. Details: load the `parall-tasks` skill.\n\n### Communicate like a teammate\nMatch the conversation \u2014 concise in chat, thorough in docs, plain language over\njargon. Say what matters; stop when you're done. Don't narrate every tool call\nor pad replies to seem thorough.\n\n### Respect what's shared\nYou have broad latitude inside your own work. But actions that are visible to\nothers, hard to reverse, or touch shared state \u2014 sending DMs, editing shared\nwiki, reassigning others' tasks, deleting content \u2014 pause and confirm before\nacting, unless you've been explicitly authorized.\n\n### Shared workspace\nOther agents share this workspace. Before starting work, check whether someone\n\u2014 human or agent \u2014 has already picked it up. Coordination beats racing.\n\n### When in doubt\nPrefer asking over guessing. Prefer \"I don't know\" over fabricating. Your\ncredibility is what you bring to the workspace \u2014 protect it.";
21
- export declare const PRLL_REFERENCE_GUIDE = "## Parall References\n\nEvery entity on Parall has a `prll://` URI. Use these URIs to link related\nentities when you create or update tasks, comments, messages, and wiki files.\n\nAll three forms work \u2014 pick whichever fits:\n\n prll://tsk_abc bare URI (auto-linked)\n [](prll://tsk_abc) empty context (renders resolved title)\n [relevant context](prll://tsk_abc) with author annotation\n\nBare URIs and empty-context refs are preferred in most cases \u2014 the platform\nresolves and renders the entity title automatically.\n\n### URI format\n\n`prll://` follows standard URI structure: `scheme://authority/path?query#fragment`.\n\n**Entities** \u2014 the entity ID is the authority:\n\n prll://usr_xxx user prll://prj_xxx project\n prll://tsk_xxx task prll://wik_xxx wiki\n prll://msg_xxx message prll://tcm_xxx task comment\n prll://cht_xxx chat prll://ase_xxx agent session\n prll://att_xxx attachment prll://sch_xxx schedule\n prll://srn_xxx schedule run\n\n**Wiki** \u2014 path is file path, fragment is a typed anchor:\n\n prll://wik_xxx/docs/guide.md file\n prll://wik_xxx/docs/guide.md#h=Auth::OAuth heading (:: = hierarchy)\n prll://wik_xxx/src/auth.go?rev=<sha>#l=42-58 line range (revision-pinned)\n\n Anchor types: `h=` heading, `l=` line/range, `s=` symbol.\n Line anchors in persistent content require `?rev=<full-40-char-sha>`.\n\n**Chat message range**:\n\n prll://cht_xxx#range=msg_01HA,msg_01HZ\n\n**Field access** \u2014 path selects a field (omit to reference the entity itself):\n\n prll://tsk_xxx/description#Implementation heading within task description\n\n### Reading context on demand\n\nAn event only carries the single triggering message. If you're mentioned in a\ngroup chat and lack context, pull what you need from the chat \u2014 don't guess:\n\n npx --yes @parall/cli@latest messages list cht_xxx --limit 20 --before msg_xxx\n npx --yes @parall/cli@latest messages get msg_xxx\n npx --yes @parall/cli@latest chats get cht_xxx\n\nRule of thumb: in a group chat mention, the conversation that led up to you\nbeing called almost always matters \u2014 read it before replying. In a DM, your\nsession already has continuity, so skip the fetch unless something is unclear.\n\nSame pattern for any other entity referenced in the event: `tasks get`,\n`projects get`, `users get`, `chats get`. Follow the reflink, don't ask.\n\n### File attachments\n\nMessages may include attachments. They appear in events as:\n\n [Attachment: prll://att_xxx | image/png | 1.2MB | screenshot.png]\n\nTo download an attachment, use the CLI:\n\n npx @parall/cli@latest files download att_xxx --output /tmp/screenshot.png\n\nTo send a file:\n\n npx @parall/cli@latest messages send prll://cht_xxx --file /tmp/output.png --text \"Done\"\n\nOr upload first and reuse across chats:\n\n npx @parall/cli@latest files upload /tmp/report.pdf\n npx @parall/cli@latest messages send prll://cht_aaa --attachment att_yyy --text \"Report\"\n npx @parall/cli@latest messages send prll://cht_bbb --attachment att_yyy --text \"FYI\"\n\n### When to reference\n\n- **Origin** \u2014 always link the message or task that triggered your work\n- **Design docs / wiki** \u2014 link specs and guides relevant to the work\n- **Related tasks** \u2014 link parent, sibling, or blocking tasks\n- **People** \u2014 link assignees or stakeholders when mentioning them\n- **Conversations** \u2014 link a chat or message range as context\n\n### Why this matters\n\nOther agents and humans read your output. References build a navigable context graph \u2014\nin multi-agent workflows, your references are the map that the next agent follows.";
20
+ export declare const PRLL_BEHAVIOR = "## How to work here\n\n### Move work forward\nDon't wait for instructions. If you see the next step, take it. If something is\nambiguous, clarify once and proceed. If you're blocked, say what's blocking you\n\u2014 don't go silent. Initiative is expected.\n\n### Work in the open\nNothing you do exists until the system can see it. Your progress, decisions,\nblockers, and results need to live in tasks, comments, messages, or wiki pages\n\u2014 otherwise the organization is blind to your work, and so is the next agent\nwho picks up where you left off. Leave traces as you go, not at the end.\n\nFor non-trivial work: create or claim a task, mark it `in_progress`, comment\nwhen status materially changes, close it when done, and link the origin that\ntriggered it. Details: load the `parall-tasks` skill.\n\n### Communicate like a teammate\nMatch the conversation \u2014 concise in chat, thorough in docs, plain language over\njargon. Say what matters; stop when you're done. Don't narrate every tool call\nor pad replies to seem thorough.\n\n### Respect what's shared\nYou have broad latitude inside your own work. But actions that are visible to\nothers, hard to reverse, or touch shared state \u2014 sending DMs, editing shared\nwiki, reassigning others' tasks, deleting content \u2014 pause and confirm before\nacting, unless you've been explicitly authorized.\n\n### Shared workspace\nOther agents share this workspace. Before starting work, check whether someone\n\u2014 human or agent \u2014 has already picked it up. Coordination beats racing.\n\n### Permissions and approvals\nYou have real permissions based on your roles (chat member/admin, org member).\nIf you lack permission for an action, the API returns PERMISSION_DENIED with the\n`action` and `resource_uri` that were denied. When that happens, use\n`approvals request` to ask someone with permission to approve it \u2014 don't retry\nor work around the denial. Only request approval after an actual denial, never\npreemptively.\n\n### When in doubt\nPrefer asking over guessing. Prefer \"I don't know\" over fabricating. Your\ncredibility is what you bring to the workspace \u2014 protect it.";
21
+ export declare const PRLL_REFERENCE_GUIDE = "## Parall References\n\nEvery entity on Parall has a `prll://` URI. Use these URIs to link related\nentities when you create or update tasks, comments, messages, and wiki files.\n\nAll three forms work \u2014 pick whichever fits:\n\n prll://tsk_abc bare URI (auto-linked)\n [](prll://tsk_abc) empty context (renders resolved title)\n [relevant context](prll://tsk_abc) with author annotation\n\nBare URIs and empty-context refs are preferred in most cases \u2014 the platform\nresolves and renders the entity title automatically.\n\n### URI format\n\n`prll://` follows standard URI structure: `scheme://authority/path?query#fragment`.\n\n**Entities** \u2014 the entity ID is the authority:\n\n prll://usr_xxx user prll://prj_xxx project\n prll://tsk_xxx task prll://wik_xxx wiki\n prll://msg_xxx message prll://tcm_xxx task comment\n prll://cht_xxx chat prll://ase_xxx agent session\n prll://att_xxx attachment prll://sch_xxx schedule\n prll://srn_xxx schedule run\n\n**Wiki** \u2014 path is file path, fragment is a typed anchor:\n\n prll://wik_xxx/docs/guide.md file\n prll://wik_xxx/docs/guide.md#h=Auth::OAuth heading (:: = hierarchy)\n prll://wik_xxx/src/auth.go?rev=<sha>#l=42-58 line range (revision-pinned)\n\n Anchor types: `h=` heading, `l=` line/range, `s=` symbol.\n Line anchors in persistent content require `?rev=<full-40-char-sha>`.\n\n**Chat message range**:\n\n prll://cht_xxx#range=msg_01HA,msg_01HZ\n\n**Field access** \u2014 path selects a field (omit to reference the entity itself):\n\n prll://tsk_xxx/description#Implementation heading within task description\n\n### Reading context on demand\n\nAn event only carries the single triggering message. If you're mentioned in a\ngroup chat and lack context, pull what you need from the chat \u2014 don't guess:\n\n parall messages list cht_xxx --limit 20 --before msg_xxx\n parall messages get msg_xxx\n parall chats get cht_xxx\n\nRule of thumb: in a group chat mention, the conversation that led up to you\nbeing called almost always matters \u2014 read it before replying. In a DM, your\nsession already has continuity, so skip the fetch unless something is unclear.\n\nSame pattern for any other entity referenced in the event: `tasks get`,\n`projects get`, `users get`, `chats get`. Follow the reflink, don't ask.\n\n### File attachments\n\nMessages may include attachments. They appear in events as:\n\n [Attachment: prll://att_xxx | image/png | 1.2MB | screenshot.png]\n\nTo download an attachment, use the CLI:\n\n parall files download att_xxx --output /tmp/screenshot.png\n\nTo send a file:\n\n parall messages send prll://cht_xxx --file /tmp/output.png --text \"Done\"\n\nOr upload first and reuse across chats:\n\n parall files upload /tmp/report.pdf\n parall messages send prll://cht_aaa --attachment att_yyy --text \"Report\"\n parall messages send prll://cht_bbb --attachment att_yyy --text \"FYI\"\n\n### When to reference\n\n- **Origin** \u2014 always link the message or task that triggered your work\n- **Design docs / wiki** \u2014 link specs and guides relevant to the work\n- **Related tasks** \u2014 link parent, sibling, or blocking tasks\n- **People** \u2014 link assignees or stakeholders when mentioning them\n- **Conversations** \u2014 link a chat or message range as context\n\n### Why this matters\n\nOther agents and humans read your output. References build a navigable context graph \u2014\nin multi-agent workflows, your references are the map that the next agent follows.";
22
+ export type PreparedLocalImage = {
23
+ attachmentId: string;
24
+ fileName: string;
25
+ mimeType: string;
26
+ fileSize: number;
27
+ localPath: string;
28
+ };
29
+ export type LocalAttachmentResult = {
30
+ images: PreparedLocalImage[];
31
+ notes: string[];
32
+ };
33
+ export declare function renderLocalAttachmentSection(section: LocalAttachmentResult): string;
34
+ export declare function formatBytes(bytes: number): string;
22
35
  //# sourceMappingURL=prompt-fragments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-fragments.d.ts","sourceRoot":"","sources":["../src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gB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIjD"}
@@ -21,6 +21,9 @@ of you.`;
21
21
  function sanitizeProfileField(value) {
22
22
  return value.replace(/[\r\n]+/g, " ").replace(/`/g, "'").trim();
23
23
  }
24
+ function sanitizeProfileBlock(value) {
25
+ return value.replace(/\r\n?/g, "\n").trim();
26
+ }
24
27
  export function buildIdentity(agent) {
25
28
  if (!agent)
26
29
  return PRLL_IDENTITY_BASE;
@@ -28,7 +31,10 @@ export function buildIdentity(agent) {
28
31
  const lines = [PRLL_IDENTITY_BASE, "", "### Your Parall Identity", ""];
29
32
  lines.push(`You are **${name}** (\`prll://${agent.userId}\`).`);
30
33
  if (agent.description) {
31
- lines.push(`Description: ${sanitizeProfileField(agent.description)}`);
34
+ const description = sanitizeProfileBlock(agent.description);
35
+ if (description) {
36
+ lines.push("", "### Your Agent Profile", "", description);
37
+ }
32
38
  }
33
39
  lines.push("", `When you see \`${agent.userId}\` or \`prll://${agent.userId}\` in messages, mentions, or events — that's you.`);
34
40
  return lines.join("\n");
@@ -67,6 +73,14 @@ acting, unless you've been explicitly authorized.
67
73
  Other agents share this workspace. Before starting work, check whether someone
68
74
  — human or agent — has already picked it up. Coordination beats racing.
69
75
 
76
+ ### Permissions and approvals
77
+ You have real permissions based on your roles (chat member/admin, org member).
78
+ If you lack permission for an action, the API returns PERMISSION_DENIED with the
79
+ \`action\` and \`resource_uri\` that were denied. When that happens, use
80
+ \`approvals request\` to ask someone with permission to approve it — don't retry
81
+ or work around the denial. Only request approval after an actual denial, never
82
+ preemptively.
83
+
70
84
  ### When in doubt
71
85
  Prefer asking over guessing. Prefer "I don't know" over fabricating. Your
72
86
  credibility is what you bring to the workspace — protect it.`;
@@ -119,9 +133,9 @@ resolves and renders the entity title automatically.
119
133
  An event only carries the single triggering message. If you're mentioned in a
120
134
  group chat and lack context, pull what you need from the chat — don't guess:
121
135
 
122
- npx --yes @parall/cli@latest messages list cht_xxx --limit 20 --before msg_xxx
123
- npx --yes @parall/cli@latest messages get msg_xxx
124
- npx --yes @parall/cli@latest chats get cht_xxx
136
+ parall messages list cht_xxx --limit 20 --before msg_xxx
137
+ parall messages get msg_xxx
138
+ parall chats get cht_xxx
125
139
 
126
140
  Rule of thumb: in a group chat mention, the conversation that led up to you
127
141
  being called almost always matters — read it before replying. In a DM, your
@@ -138,17 +152,17 @@ Messages may include attachments. They appear in events as:
138
152
 
139
153
  To download an attachment, use the CLI:
140
154
 
141
- npx @parall/cli@latest files download att_xxx --output /tmp/screenshot.png
155
+ parall files download att_xxx --output /tmp/screenshot.png
142
156
 
143
157
  To send a file:
144
158
 
145
- npx @parall/cli@latest messages send prll://cht_xxx --file /tmp/output.png --text "Done"
159
+ parall messages send prll://cht_xxx --file /tmp/output.png --text "Done"
146
160
 
147
161
  Or upload first and reuse across chats:
148
162
 
149
- npx @parall/cli@latest files upload /tmp/report.pdf
150
- npx @parall/cli@latest messages send prll://cht_aaa --attachment att_yyy --text "Report"
151
- npx @parall/cli@latest messages send prll://cht_bbb --attachment att_yyy --text "FYI"
163
+ parall files upload /tmp/report.pdf
164
+ parall messages send prll://cht_aaa --attachment att_yyy --text "Report"
165
+ parall messages send prll://cht_bbb --attachment att_yyy --text "FYI"
152
166
 
153
167
  ### When to reference
154
168
 
@@ -162,3 +176,30 @@ Or upload first and reuse across chats:
162
176
 
163
177
  Other agents and humans read your output. References build a navigable context graph —
164
178
  in multi-agent workflows, your references are the map that the next agent follows.`;
179
+ export function renderLocalAttachmentSection(section) {
180
+ if (section.images.length === 0 && section.notes.length === 0)
181
+ return "";
182
+ // Each image renders as a metadata header line plus the absolute path on
183
+ // its own line. The path stands alone (no quoting / escaping) so file-
184
+ // reading tools can consume it verbatim — paths inside the attachment root
185
+ // are sanitized to ASCII-safe segments, and the workspace dir comes from
186
+ // the bridge operator. A pathological workspace dir with embedded newlines
187
+ // would split across lines; that's exotic enough not to warrant scrubbing
188
+ // every consumer's path through escape rules.
189
+ const lines = ["[Local attachment files]"];
190
+ for (const image of section.images) {
191
+ lines.push(`- prll://${image.attachmentId} (${sanitizePromptMeta(image.mimeType)}, ${formatBytes(image.fileSize)}, ${sanitizePromptMeta(image.fileName)})`, ` ${image.localPath}`);
192
+ }
193
+ lines.push(...section.notes);
194
+ return lines.join("\n");
195
+ }
196
+ function sanitizePromptMeta(value) {
197
+ return value.replace(/[\r\n]+/g, " ").replace(/[()]/g, " ").trim();
198
+ }
199
+ export function formatBytes(bytes) {
200
+ if (bytes >= 1048576)
201
+ return `${(bytes / 1048576).toFixed(1)}MB`;
202
+ if (bytes >= 1024)
203
+ return `${Math.round(bytes / 1024)}KB`;
204
+ return `${bytes}B`;
205
+ }
package/dist/types.d.ts CHANGED
@@ -22,6 +22,7 @@ export type ParallEvent = {
22
22
  targetId: string;
23
23
  targetName?: string;
24
24
  targetType?: string;
25
+ deliveryReason?: string;
25
26
  senderId: string;
26
27
  senderName: string;
27
28
  messageId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,MAAM,MAAM,UAAU,GAAG;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACjE,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,2DAA2D;AAC3D,MAAM,MAAM,aAAa,GAAG;IAC1B,eAAe,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,kBAAkB,EAAE,UAAU,EAAE,CAAC;IACjC,UAAU,EAAE,WAAW,EAAE,CAAC;CAC3B,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EA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AC;IACjC,kBAAkB,EAAE,UAAU,EAAE,CAAC;IACjC,UAAU,EAAE,WAAW,EAAE,CAAC;CAC3B,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,cAAc,GAAG,UAAU,CAAC;IACvD,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.23.0",
3
+ "version": "1.25.0",
4
4
  "description": "Shared agent runtime orchestration helpers for Parall",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -15,6 +15,10 @@
15
15
  ".": {
16
16
  "types": "./dist/index.d.ts",
17
17
  "import": "./dist/index.js"
18
+ },
19
+ "./internal/attachment-input": {
20
+ "types": "./dist/internal/attachment-input.d.ts",
21
+ "import": "./dist/internal/attachment-input.js"
18
22
  }
19
23
  },
20
24
  "files": [
@@ -22,7 +26,7 @@
22
26
  "src"
23
27
  ],
24
28
  "dependencies": {
25
- "@parall/sdk": "1.23.0"
29
+ "@parall/sdk": "1.25.0"
26
30
  },
27
31
  "devDependencies": {
28
32
  "@types/node": "^22.0.0",
@@ -22,15 +22,21 @@ To say something in a chat, you **must** invoke the Parall CLI via your shell/ex
22
22
 
23
23
  ## Parall CLI
24
24
 
25
- All outbound interactions go through \`@parall/cli\`. Credentials are pre-injected as environment variables — no setup needed.
25
+ All outbound interactions go through the \`parall\` CLI. Credentials are pre-injected as environment variables — no setup needed. If \`parall\` is not on PATH, use \`npx --yes @parall/cli@latest\` instead.
26
26
 
27
- - \`npx --yes @parall/cli@latest messages send prll://cht_xxx --text "..."\` — reply into the triggering chat
28
- - \`npx --yes @parall/cli@latest dm prll://usr_xxx --text "..." [--no-reply]\` — direct message another user
29
- - \`npx --yes @parall/cli@latest tasks update prll://tsk_xxx --status in_progress\` — task state
30
- - \`npx --yes @parall/cli@latest no-reply [--reason "..."]\` — explicitly declare this turn silent (audit signal; not required for silence, just clarifies intent)
27
+ - \`parall messages send prll://cht_xxx --text "..."\` — reply into the triggering chat
28
+ - \`parall dm prll://usr_xxx --text "..." [--no-reply]\` — direct message another user
29
+ - \`parall tasks update prll://tsk_xxx --status in_progress\` — task state
30
+ - \`parall no-reply [--reason "..."]\` — explicitly declare this turn silent (audit signal; not required for silence, just clarifies intent)
31
31
 
32
32
  The bridge injects Parall context via environment variables. The static credentials \`PRLL_API_URL\`, \`PRLL_API_KEY\`, and \`PRLL_ORG_ID\` are always set. Per-dispatch context — \`PRLL_SESSION_ID\`, \`PRLL_CHAT_ID\`, \`PRLL_TRIGGER_MESSAGE_ID\`, \`PRLL_STEP_ID_FILE\` — is set in subprocess-per-dispatch runtimes (Claude Code); in long-running runtimes (Codex) those may be absent and the CLI will fall back to whatever defaults you supply on the command line.
33
33
 
34
+ ## Attachments
35
+
36
+ Image 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 — pass that path to your file-reading tool when the user refers to image contents.
37
+
38
+ Supported image types: PNG, JPEG, WebP, GIF. Other attachment types (PDFs, archives, etc.) are not pre-downloaded — fetch them on demand with \`parall files download att_xxx --output ...\`.
39
+
34
40
  ## Guardrails
35
41
 
36
42
  - A dispatch may coalesce multiple events. Decide per event whether to reply via \`messages send\` / \`dm\` — events you do not act on simply receive no reply.
@@ -39,6 +45,18 @@ The bridge injects Parall context via environment variables. The static credenti
39
45
  - Keep CLI replies concise and task-focused.
40
46
 
41
47
  See \`docs/engineering-design/agent-dm-loop-prevention.md\` § Layer 0 for why plain text is never auto-projected.
48
+
49
+ ## Approval Flow
50
+
51
+ When you try an action (e.g., archive a chat) and receive a PERMISSION_DENIED error, you can request someone with permission to do it:
52
+
53
+ 1. The error includes a \`PERMISSION_DENIED\` code. For commonly approvable actions (archive, delete, restore), a \`Tip:\` line with an approval-request template is printed — copy it and fill in the remaining placeholders (\`--chat\`, \`--title\`, \`--reason\`)
54
+ 2. Request approval: \`parall approvals request --action chat.archive --resource prll://cht_123 --chat prll://cht_456 --title "Archive #old-project" --reason "Channel inactive"\`
55
+ 3. A card will appear in the specified chat for someone with permission to approve
56
+ 4. Check the result: \`parall approvals get prll://<id>\` or wait: \`parall approvals wait prll://<id> --timeout 300\`
57
+ 5. List available actions: \`parall approvals actions\`
58
+
59
+ Only request approval when you've actually been denied permission. Don't request approval preemptively.
42
60
  `;
43
61
 
44
62
  /** Extracts the `command` string from a shell/bash tool call's input payload. */
@@ -31,6 +31,7 @@ export function buildEventBody(event: ParallEvent): string {
31
31
  ? `${event.targetName} (prll://${event.targetId})`
32
32
  : `prll://${event.targetId}`;
33
33
  lines.push(`[Task: ${taskLabel}]`);
34
+ if (event.deliveryReason) lines.push(`[Delivery: ${sanitizeMeta(event.deliveryReason)}]`);
34
35
  lines.push(`[From: ${event.senderName} (prll://${event.senderId})]`);
35
36
  lines.push(`[Comment ID: prll://${event.messageId}]`);
36
37
  lines.push("", event.body);
@@ -8,6 +8,7 @@ import type {
8
8
  Chat,
9
9
  ChatUpdateData,
10
10
  Comment,
11
+ DispatchDeliveryReason,
11
12
  DispatchNewData,
12
13
  HelloData,
13
14
  MessageNewData,
@@ -264,13 +265,23 @@ export class ParallAgentGateway {
264
265
  if (data.event_type === "task_comment") {
265
266
  if (!data.source_id || !data.task_id) return;
266
267
  try {
267
- const dispatched = await this.handleTaskComment(data.source_id, data.task_id, data.actor_id);
268
+ const dispatched = await this.handleTaskComment(data.source_id, data.task_id, data.actor_id, data.delivery_reason);
268
269
  if (dispatched) {
269
270
  this.opts.client.ackDispatchByID(this.opts.config.org_id, data.id).catch(() => {});
270
271
  }
271
272
  } catch (err) {
272
273
  this.opts.log?.error(`parall[${this.opts.accountId}]: task comment dispatch failed for ${data.source_id}: ${String(err)}`);
273
274
  }
275
+ } else if (data.event_type === "task_update") {
276
+ if (!data.task_id) return;
277
+ try {
278
+ const dispatched = await this.handleTaskDispatch(data.task_id, data.source_id ?? data.task_id, { allowCreator: true });
279
+ if (dispatched) {
280
+ this.opts.client.ackDispatchByID(this.opts.config.org_id, data.id).catch(() => {});
281
+ }
282
+ } catch (err) {
283
+ this.opts.log?.error(`parall[${this.opts.accountId}]: task update dispatch failed for ${data.task_id}: ${String(err)}`);
284
+ }
274
285
  } else if (data.event_type === "schedule.fire") {
275
286
  if (!data.source_id) return;
276
287
  try {
@@ -958,7 +969,36 @@ export class ParallAgentGateway {
958
969
  return dispatched;
959
970
  }
960
971
 
961
- private async handleTaskComment(commentId: string, taskId: string, actorId: string | null): Promise<boolean> {
972
+ private async handleTaskDispatch(
973
+ taskId: string,
974
+ ackSourceId?: string,
975
+ opts: { allowCreator?: boolean } = {},
976
+ ): Promise<boolean> {
977
+ let task: Awaited<ReturnType<typeof this.opts.client.getTask>> | null = null;
978
+ try {
979
+ task = await this.opts.client.getTask(this.opts.config.org_id, taskId);
980
+ } catch (err: unknown) {
981
+ const status = (err as { status?: number })?.status;
982
+ if (status === 404) return true;
983
+ throw err;
984
+ }
985
+ const isAssignee = task.assignee_id === this.opts.agentUserId;
986
+ const isCreatorUpdate = opts.allowCreator === true && task.creator_id === this.opts.agentUserId;
987
+ if (!isAssignee && !isCreatorUpdate) {
988
+ this.opts.log?.info(
989
+ `parall[${this.opts.accountId}]: skipping stale task dispatch ${ackSourceId ?? taskId} — assigned to ${task.assignee_id}, creator ${task.creator_id}`,
990
+ );
991
+ return true;
992
+ }
993
+ return this.handleTaskAssignment(task, ackSourceId);
994
+ }
995
+
996
+ private async handleTaskComment(
997
+ commentId: string,
998
+ taskId: string,
999
+ actorId: string | null,
1000
+ deliveryReason?: DispatchDeliveryReason | null,
1001
+ ): Promise<boolean> {
962
1002
  if (this.shuttingDown) return false; // drain window — let server requeue via catch-up
963
1003
  const dedupeKey = `comment:${commentId}`;
964
1004
  if (this.dispatchedTasks.has(dedupeKey)) return false;
@@ -1015,6 +1055,7 @@ export class ParallAgentGateway {
1015
1055
  senderName: comment.author?.display_name ?? actorId ?? "unknown",
1016
1056
  messageId: commentId,
1017
1057
  body: parts.join("\n"),
1058
+ deliveryReason: deliveryReason ?? undefined,
1018
1059
  ackSourceType: "comment",
1019
1060
  ackSourceId: commentId,
1020
1061
  };
@@ -1127,32 +1168,21 @@ export class ParallAgentGateway {
1127
1168
  try {
1128
1169
  let dispatched = false;
1129
1170
  if (item.event_type === "task_assign" && item.task_id) {
1130
- let task: Awaited<ReturnType<typeof this.opts.client.getTask>> | null = null;
1131
- let taskFetchFailed = false;
1132
1171
  try {
1133
- task = await this.opts.client.getTask(this.opts.config.org_id, item.task_id);
1172
+ dispatched = await this.handleTaskDispatch(item.task_id, item.source_id ?? item.task_id);
1134
1173
  } catch (err: unknown) {
1135
- const status = (err as { status?: number })?.status;
1136
- if (status === 404) {
1137
- task = null;
1138
- } else {
1139
- taskFetchFailed = true;
1140
- this.opts.log?.warn(`parall[${this.opts.accountId}]: catch-up task fetch failed for ${item.task_id}, leaving pending: ${String(err)}`);
1141
- }
1174
+ this.opts.log?.warn(`parall[${this.opts.accountId}]: catch-up task fetch failed for ${item.task_id}, leaving pending: ${String(err)}`);
1175
+ continue;
1142
1176
  }
1143
- if (taskFetchFailed) continue;
1144
- if (task) {
1145
- if (task.assignee_id !== this.opts.agentUserId) {
1146
- this.opts.log?.info(`parall[${this.opts.accountId}]: skipping stale task dispatch ${item.id} — reassigned to ${task.assignee_id}`);
1147
- this.opts.client.ackDispatchByID(this.opts.config.org_id, item.id).catch(() => {});
1148
- continue;
1149
- }
1150
- dispatched = await this.handleTaskAssignment(task);
1151
- } else {
1152
- dispatched = true;
1177
+ } else if (item.event_type === "task_update" && item.task_id) {
1178
+ try {
1179
+ dispatched = await this.handleTaskDispatch(item.task_id, item.source_id ?? item.task_id, { allowCreator: true });
1180
+ } catch (err: unknown) {
1181
+ this.opts.log?.warn(`parall[${this.opts.accountId}]: catch-up task fetch failed for ${item.task_id}, leaving pending: ${String(err)}`);
1182
+ continue;
1153
1183
  }
1154
1184
  } else if (item.event_type === "task_comment" && item.source_id && item.task_id) {
1155
- dispatched = await this.handleTaskComment(item.source_id, item.task_id, item.actor_id);
1185
+ dispatched = await this.handleTaskComment(item.source_id, item.task_id, item.actor_id, item.delivery_reason);
1156
1186
  } else if (item.event_type === "schedule.fire" && item.source_id) {
1157
1187
  dispatched = await this.fetchAndHandleScheduleFire(item.source_id, item.actor_id);
1158
1188
  } else if (item.event_type === "message" && item.source_id && item.chat_id) {