@parall/agent-core 1.31.0 → 1.32.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.
Files changed (72) hide show
  1. package/dist/bridge-workspace.d.ts +1 -1
  2. package/dist/bridge-workspace.d.ts.map +1 -1
  3. package/dist/bridge-workspace.js +13 -13
  4. package/dist/dispatch-adapter.d.ts +15 -8
  5. package/dist/dispatch-adapter.d.ts.map +1 -1
  6. package/dist/event-format.d.ts +1 -1
  7. package/dist/event-format.d.ts.map +1 -1
  8. package/dist/event-format.js +68 -25
  9. package/dist/gateway-base.d.ts +14 -13
  10. package/dist/gateway-base.d.ts.map +1 -1
  11. package/dist/gateway-base.js +650 -313
  12. package/dist/index.d.ts +15 -13
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +13 -12
  15. package/dist/internal/attachment-input.d.ts +3 -3
  16. package/dist/internal/attachment-input.d.ts.map +1 -1
  17. package/dist/internal/attachment-input.js +61 -58
  18. package/dist/logger.d.ts +1 -1
  19. package/dist/platform-config.d.ts +28 -2
  20. package/dist/platform-config.d.ts.map +1 -1
  21. package/dist/platform-config.js +42 -11
  22. package/dist/prompt-fragments.d.ts +2 -2
  23. package/dist/prompt-fragments.d.ts.map +1 -1
  24. package/dist/prompt-fragments.js +37 -14
  25. package/dist/provider-config.d.ts +9 -0
  26. package/dist/provider-config.d.ts.map +1 -1
  27. package/dist/provider-config.js +13 -2
  28. package/dist/routing.d.ts +5 -5
  29. package/dist/routing.js +6 -6
  30. package/dist/session-state.d.ts +16 -0
  31. package/dist/session-state.d.ts.map +1 -1
  32. package/dist/session-state.js +45 -0
  33. package/dist/skills/index.d.ts +5 -4
  34. package/dist/skills/index.d.ts.map +1 -1
  35. package/dist/skills/index.js +28 -21
  36. package/dist/skills/parall-clips.d.ts +2 -0
  37. package/dist/skills/parall-clips.d.ts.map +1 -0
  38. package/dist/skills/parall-clips.js +44 -0
  39. package/dist/skills/parall-platform.d.ts +1 -1
  40. package/dist/skills/parall-platform.d.ts.map +1 -1
  41. package/dist/skills/parall-platform.js +6 -2
  42. package/dist/skills/parall-tasks.d.ts +1 -1
  43. package/dist/skills/parall-tasks.d.ts.map +1 -1
  44. package/dist/skills/parall-tasks.js +1 -1
  45. package/dist/skills/parall-wiki.d.ts +1 -1
  46. package/dist/skills/parall-wiki.d.ts.map +1 -1
  47. package/dist/skills/parall-wiki.js +1 -1
  48. package/dist/telemetry.d.ts +27 -0
  49. package/dist/telemetry.d.ts.map +1 -0
  50. package/dist/telemetry.js +205 -0
  51. package/dist/types.d.ts +18 -2
  52. package/dist/types.d.ts.map +1 -1
  53. package/package.json +11 -2
  54. package/src/bridge-workspace.ts +13 -13
  55. package/src/dispatch-adapter.ts +31 -8
  56. package/src/event-format.ts +80 -30
  57. package/src/gateway-base.ts +988 -445
  58. package/src/index.ts +23 -13
  59. package/src/internal/attachment-input.ts +127 -100
  60. package/src/logger.ts +1 -1
  61. package/src/platform-config.ts +61 -16
  62. package/src/prompt-fragments.ts +37 -14
  63. package/src/provider-config.ts +14 -2
  64. package/src/routing.ts +11 -11
  65. package/src/session-state.ts +62 -0
  66. package/src/skills/index.ts +34 -23
  67. package/src/skills/parall-clips.ts +44 -0
  68. package/src/skills/parall-platform.ts +6 -2
  69. package/src/skills/parall-tasks.ts +1 -1
  70. package/src/skills/parall-wiki.ts +1 -1
  71. package/src/telemetry.ts +252 -0
  72. package/src/types.ts +18 -2
@@ -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\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";
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 plus the denied `action` and `resource_uri`. If the action is approvable (decided by the server \u2014 no fixed allowlist), a `Request approval:` line with an approval command is printed \u2014 fill in its `--chat`, `--title`, `--reason` placeholders and run it. If it is not approvable, the output says so; ask a human with permission instead.\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,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"}
1
+ {"version":3,"file":"bridge-workspace.d.ts","sourceRoot":"","sources":["../src/bridge-workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,6BAA6B,8kKAwEzC,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"}
@@ -49,7 +49,7 @@ See \`docs/engineering-design/agent-dm-loop-prevention.md\` § Layer 0 for why p
49
49
 
50
50
  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:
51
51
 
52
- 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\`)
52
+ 1. The error includes a \`PERMISSION_DENIED\` code plus the denied \`action\` and \`resource_uri\`. If the action is approvable (decided by the server — no fixed allowlist), a \`Request approval:\` line with an approval command is printed — fill in its \`--chat\`, \`--title\`, \`--reason\` placeholders and run it. If it is not approvable, the output says so; ask a human with permission instead.
53
53
  2. Request approval: \`parall approvals request --action chat.archive --resource prll://cht_123 --chat prll://cht_456 --title "Archive #old-project" --reason "Channel inactive"\`
54
54
  3. A card will appear in the specified chat for someone with permission to approve
55
55
  4. Check the result: \`parall approvals get prll://<id>\` or wait: \`parall approvals wait prll://<id> --timeout 300\`
@@ -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 !== "object")
85
+ if (!input || typeof input !== 'object')
86
86
  return undefined;
87
87
  const command = input.command;
88
- return typeof command === "string" && command.trim() ? command.trim() : undefined;
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, " ").trim().split(" ");
102
+ const tokens = command.replace(/\s+/g, ' ').trim().split(' ');
103
103
  let i = 0;
104
- if (tokens[i] === "parall") {
104
+ if (tokens[i] === 'parall') {
105
105
  i++;
106
106
  }
107
- else if (tokens[i] === "npx") {
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] === "pnpm") {
115
+ else if (tokens[i] === 'pnpm') {
116
116
  i++;
117
- if (i < tokens.length && (tokens[i] === "exec" || tokens[i] === "dlx"))
117
+ if (i < tokens.length && (tokens[i] === 'exec' || tokens[i] === 'dlx'))
118
118
  i++;
119
- if (i >= tokens.length || tokens[i] !== "parall")
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] === "dm" || (sub[0] === "messages" && sub[1] === "send");
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] === "no-reply";
153
+ return sub?.[0] === 'no-reply';
154
154
  }
@@ -1,5 +1,5 @@
1
- import type { ParallClient } from "@parall/sdk";
2
- import type { ParallEvent } from "./types.js";
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: "runtime_session";
28
+ type: 'runtime_session';
29
29
  runtimeSessionId: string;
30
30
  runtimeLaneKey?: string;
31
31
  runtimeRef?: Record<string, unknown>;
32
32
  } | {
33
- type: "thinking";
33
+ type: 'thinking';
34
34
  text: string;
35
35
  groupKey?: string;
36
36
  } | {
37
- type: "tool_call";
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: "tool_result";
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: "text";
52
+ type: 'text';
53
53
  text: string;
54
54
  project?: boolean;
55
55
  groupKey?: string;
56
56
  } | {
57
- type: "error";
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;AAE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AC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAE/D;;;;;OAKG;IACH,aAAa,CAAC,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C"}
@@ -1,4 +1,4 @@
1
- import type { ForkResult, ParallEvent } from "./types.js";
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;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"}
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"}
@@ -1,18 +1,42 @@
1
1
  function sanitizeMeta(value) {
2
- return value.replace(/[\r\n]+/g, " ").replace(/[[\]|]/g, " ").trim();
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 === "message") {
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 ?? "unknown"}]`);
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
- lines.push(`[Thread: prll://${event.threadRootId}]`);
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("", event.body);
50
+ lines.push('', event.body);
27
51
  }
28
- else if (event.type === "task_comment") {
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("", event.body);
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 === "approval") {
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("", event.body);
84
+ lines.push('', event.body);
46
85
  }
47
- else if (event.type === "schedule") {
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("", event.body);
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("", event.body);
103
+ lines.push('', event.body);
65
104
  }
66
- return lines.join("\n") + buildSendMessageHint(event);
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.targetId.startsWith("cht_")) {
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("tsk_")) {
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("sch_")) {
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) : "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."}]`);
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("\n");
148
+ return lines.join('\n');
106
149
  });
107
- return blocks.join("\n\n") + "\n\n---\n\n";
150
+ return blocks.join('\n\n') + '\n\n---\n\n';
108
151
  }
@@ -1,6 +1,6 @@
1
- import { ParallClient, ParallWs } from "@parall/sdk";
2
- import type { AgentConfigUpdateData } from "@parall/sdk";
3
- import type { DispatchAdapter, GatewayLogger } from "./dispatch-adapter.js";
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 startTyping;
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,EAAuB,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,KAAK,EACV,qBAAqB,EAetB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAEV,eAAe,EAGf,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAuD/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;IACz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