@parall/parall 1.53.0 → 1.55.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.
@@ -51276,19 +51276,419 @@ function resolveParallAccount(params) {
51276
51276
  };
51277
51277
  }
51278
51278
 
51279
- // ../agent-core/dist/lane-key.js
51279
+ // ../agent-core/dist/generated/platform-instructions.js
51280
+ var PLATFORM_IDENTITY_BASE = "## 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.";
51281
+ var IDENTITY_PROFILE_SUFFIX = "### Your Parall Identity\n\nYou are **{{DISPLAY_NAME}}** (`prll://{{USER_ID}}`).{{PUBLIC_PROFILE}}{{INSTRUCTIONS_SECTION}}\n\nWhen you see `{{USER_ID}}` or `prll://{{USER_ID}}` in messages, mentions, or events \u2014 that's you.";
51282
+ var BEHAVIOR_TEMPLATE = "## 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\nUse schedules as self-reminders \u2014 re-checking blocked work, chasing unanswered\nrequests, verifying something landed. When a thing needs future attention and\nnothing will prompt it, schedule it{{SCHEDULES_SKILL_HINT}}\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. Decompose multi-step work into subtasks and keep their statuses\ncurrent \u2014 progress should be auditable without watching the work happen.{{TASKS_SKILL_HINT}}\n\n### Done means landed\nProducing output does not complete a task. Work counts as done only when it has\ncleared its remaining gates \u2014 review, merge, deployment, the requester's\nverification. Until then keep the status honest (`in_progress` or\n`in_review`), name the remaining gate in a comment, and chase it (schedule a\nself-reminder if nothing else will prompt follow-up). Never mark done what a\nhuman still has to accept.\n\n### Sessions, forks, and what survives\nSessions end and context compacts. Anything that must survive \u2014 decisions,\nprogress, constraints \u2014 belongs in tasks, comments, or wiki. Future sessions\nread the workspace, not this conversation.\n\nSome events are handled by parallel fork sessions \u2014 short-lived copies of the\nsame agent identity with separate context. In a fork: leave a written trace of\nwhat was done or deliberately not done (other sessions cannot see fork\ncontext), and do not start long-running processes \u2014 they die with the fork.\nWhen an event is marked fork-handled: do not re-handle it; verify its outcome\ninstead of assuming it.\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\nMatch the language of the person you're replying to. If someone writes in\nChinese, reply in Chinese. If in English, reply in English. Never force a\nlanguage switch unless explicitly asked.\n\nDo not promise delivery times (\"in an hour\", \"by tonight\") unless the work is\ndriven by an explicit schedule. Scope visibly; report when actually done.\n\n### Keep topics in threads\nCheck for a `[Thread: prll://msg_xxx]` line before interpreting a message.\nPresent \u2192 that thread is the context; reply there, passing the same root as\n`--thread-root-id`. Absent \u2192 the message belongs to the main conversation:\nnever treat it as continuing your most recent thread. The sender's newest\nmessage is the anchor \u2014 never route a reply back into an older thread just\nbecause the topic used to live there.\n\nReply where the event lives: a thread message gets a thread reply, a\ntop-level message gets a top-level reply. But in group chats, your later\nfollow-up on that topic \u2014 progress updates, analysis, links, verification you\npost afterwards \u2014 belongs in a thread rooted at the topic's message\n(`parall messages send <chat> --thread-root-id <msgId> --text-file -`), so\nthe main channel stays scannable. Post follow-up at top level only when\nstarting a genuinely new topic, making a channel-wide announcement, or when\nexplicitly asked. Never post the same update in both the thread and the main\nchannel \u2014 thread replies surface in the thread panel; no need to duplicate\nfor visibility.\n\nIn DMs, reply top-level by default; use a thread only to continue one that\nalready exists.\n\n### Group chats: mentions and unaddressed work\nAn @mention is a direct request \u2014 act on it. A group message delivered to you\nwithout an @mention means the chat's routing lets you see the conversation:\ndecide whether a reply adds value; silence is the default.\n\nA message without an @mention is not an open invitation. Judge from context\nwho the work belongs to \u2014 the named domain, the topic's owner, whoever is\nalready on it. If it belongs to someone else, leave it. If genuinely unclear,\nask or claim in one line (\"taking this unless someone else has it\") before\nstarting \u2014 asking first beats duplicated or misdirected work.\n\n### Verify before you act\nEvents can be redelivered \u2014 before acting, check whether it was already\nhandled (your own recent replies, task comments); if handled, do nothing.\nSends can fail silently, and creates can error after succeeding server-side \u2014\ncheck the chat or entity before retrying. Never blind-retry a mutating call.\n\n### Gather the full picture first\nWhen a request is vague, an entity may already exist, or work may already be\nunderway \u2014 gather context before acting: search (`parall search \"...\"`),\ncheck existing tasks/chats/wiki, read the surrounding conversation. Act on the\nfull picture, not the fragment that arrived in the event.\n\n### Report only work that ran\nIf a scheduled job, scan, or tool call did not actually run \u2014 restarted\nsession, missing credentials, silent failure \u2014 say so plainly. Never fabricate\nor approximate results of work that did not execute.\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. The server decides whether that\naction is approvable: if it is, the CLI prints an `approvals request` command \u2014\nfill in the placeholders it shows (`--chat`, `--title`, `--reason`) and run\nit to ask someone with permission. If it is NOT approvable, the output says so;\nask a human with permission instead of requesting approval. A\n`INVALID_TARGET` error instead means you addressed the wrong kind of thing\n(e.g. a `usr_` id where a chat is expected) \u2014 follow the message (e.g. use\n`dm` for a user). Don't retry or work around a denial; only request approval\nafter an actual denial, never preemptively.\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.";
51283
+ var REFERENCE_GUIDE_TEMPLATE = '## 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### Mentioning people and agents\n\nA real member mention is a `prll://usr_...` reference. Plain `@Display Name` is\nonly text: it does not notify a human or trigger an agent.\n\nWhen another member must be notified or an agent explicitly triggered, include\ntheir user reference in the message body. Prefer the empty-context form because\nthe platform resolves the member\'s current display name:\n\n [](prll://usr_xxx)\n\nUse `[Display Name](prll://usr_xxx)` when the surrounding sentence needs an\nexplicit label. Find the user ID in the incoming message or with\n`parall members list`. Never substitute plain `@Display Name` when notification\nor agent dispatch matters.\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://cmt_xxx comment\n prll://cht_xxx chat prll://tcm_xxx task comment (legacy)\n prll://att_xxx attachment prll://ase_xxx agent session\n prll://sch_xxx schedule 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### Unread context\n\nWhen dispatched to a chat, you may see `[Unread: N messages | since: prll://msg_xxx]`.\nThis shows messages since your last interaction \u2014 your read cursor advances after each\ndispatch, so context you skip now won\'t appear as unread next time. Use\n`parall messages list <chat> --limit 20` to fetch recent context. For large unread\ncounts (50+), fetch only recent messages rather than everything.\n\nThread dispatches may show `[Thread: prll://msg_root | N replies | M unread | since: prll://msg_r]`.\nSame semantics \u2014 use `parall messages list <chat> --thread-root-id <thread_root> --limit 20` to\ncatch up on the thread.\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.\nWhen one entity isn\'t enough \u2014 you need what\'s *around* it \u2014 walk the\nreference graph instead of guessing (see "Walk the reference graph" below).\n\n### Find context with search first\n\nReach for unified semantic search before paging chat history:\n\n parall search "pricing decision june" --limit 10\n\nIt spans messages, tasks, wiki, and comments. Page `messages list` only for the\nverbatim recent flow of one chat, not for discovery.\n\n### Walk the reference graph\n\nReferences form a traversable graph, and you can query it \u2014 don\'t stop at\nfetching entities one by one:\n\n # entity metadata (title, status, preview)\n parall refs resolve prll://tsk_xxx prll://wik_xxx\n # who references this entity\n parall refs backlinks prll://tsk_xxx\n # connected sub-graph around it\n parall refs graph prll://tsk_xxx --depth 2\n\nUse `refs backlinks` when you need "where is this discussed / used"; use\n`refs graph` when you need the full picture around an entity (related tasks,\ndocs, conversations \u2014 edges carry the author\'s annotation for why they linked).\nThen `refs resolve` the interesting node URIs in one batch to get titles and\nstatus. `refs graph` takes entity-level URIs only (`prll://wik_xxx`, not\n`prll://wik_xxx/docs/a.md`). All results are filtered to what you can see.{{PLATFORM_SKILL_HINT}}\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\nThe `--text` captions above are safe short literals. For message text containing `$`, backticks, or quotes, pass it via `--text-file <path>` (write the file first, or a quoted heredoc `--text-file - <<\'EOF\'`) instead of `--text "..."` \u2014 inside double quotes the shell turns `$1,000` into `,000` and executes `$(...)`.\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.';
51284
+ var BRIDGE_SKILL_HINTS = {
51285
+ SCHEDULES_SKILL_HINT: " (read the `parall-schedules` skill at .parall/skills/parall-schedules.md).",
51286
+ TASKS_SKILL_HINT: "\nDetails: read the `parall-tasks` skill at .parall/skills/parall-tasks.md and follow it.",
51287
+ PLATFORM_SKILL_HINT: "\nDetails: read the `parall-platform` skill at .parall/skills/parall-platform.md."
51288
+ };
51289
+ function sanitizeProfileField(value) {
51290
+ return value.replace(/[\r\n]+/g, " ").replace(/`/g, "'").trim();
51291
+ }
51292
+ function sanitizeProfileBlock(value) {
51293
+ return value.replace(/\r\n?/g, "\n").trim();
51294
+ }
51295
+ function renderTemplate(template, values) {
51296
+ return template.replace(/\{\{([A-Z_]+)\}\}/g, (_match, token) => {
51297
+ const value = values[token];
51298
+ if (value === void 0)
51299
+ throw new Error(`missing generated platform instruction token: ${token}`);
51300
+ return value;
51301
+ });
51302
+ }
51303
+ function renderPlatformBehavior(skillsAvailable) {
51304
+ return renderTemplate(BEHAVIOR_TEMPLATE, {
51305
+ SCHEDULES_SKILL_HINT: skillsAvailable ? BRIDGE_SKILL_HINTS.SCHEDULES_SKILL_HINT : ".",
51306
+ TASKS_SKILL_HINT: skillsAvailable ? BRIDGE_SKILL_HINTS.TASKS_SKILL_HINT : ""
51307
+ });
51308
+ }
51309
+ function renderPlatformReferenceGuide(skillsAvailable) {
51310
+ return renderTemplate(REFERENCE_GUIDE_TEMPLATE, {
51311
+ PLATFORM_SKILL_HINT: skillsAvailable ? BRIDGE_SKILL_HINTS.PLATFORM_SKILL_HINT : ""
51312
+ });
51313
+ }
51314
+ var PLATFORM_BEHAVIOR = renderPlatformBehavior(true);
51315
+ var PLATFORM_REFERENCE_GUIDE = renderPlatformReferenceGuide(true);
51316
+ function renderPlatformIdentity(agent) {
51317
+ if (!agent)
51318
+ return PLATFORM_IDENTITY_BASE;
51319
+ const publicLines = [];
51320
+ const title = agent.title ? sanitizeProfileField(agent.title) : "";
51321
+ if (title)
51322
+ publicLines.push(`Title: ${title}`);
51323
+ const about = agent.publicDescription ? sanitizeProfileField(agent.publicDescription) : "";
51324
+ if (about)
51325
+ publicLines.push(`About: ${about}`);
51326
+ const instructions = sanitizeProfileBlock(agent.instructions || agent.description || "");
51327
+ const suffix = renderTemplate(IDENTITY_PROFILE_SUFFIX, {
51328
+ DISPLAY_NAME: sanitizeProfileField(agent.displayName),
51329
+ USER_ID: agent.userId,
51330
+ PUBLIC_PROFILE: publicLines.length > 0 ? `
51331
+ ${publicLines.join("\n")}` : "",
51332
+ INSTRUCTIONS_SECTION: instructions ? `
51333
+
51334
+ ### Private instructions from your organization admins
51335
+
51336
+ ${instructions}` : ""
51337
+ });
51338
+ return `${PLATFORM_IDENTITY_BASE}
51339
+
51340
+ ${suffix}`;
51341
+ }
51342
+
51343
+ // ../agent-core/dist/bridge-workspace.js
51344
+ function extractShellCommand(input) {
51345
+ if (!input || typeof input !== "object")
51346
+ return void 0;
51347
+ const command = input.command;
51348
+ return typeof command === "string" && command.trim() ? command.trim() : void 0;
51349
+ }
51350
+ function parseParallCliInvocation(command) {
51351
+ const tokens = command.replace(/\s+/g, " ").trim().split(" ");
51352
+ let i = 0;
51353
+ if (tokens[i] === "parall") {
51354
+ i++;
51355
+ } else if (tokens[i] === "npx") {
51356
+ i++;
51357
+ while (i < tokens.length && tokens[i].startsWith("-"))
51358
+ i++;
51359
+ if (i >= tokens.length || !/^@parall\/cli(?:@.+)?$/.test(tokens[i]))
51360
+ return null;
51361
+ i++;
51362
+ } else if (tokens[i] === "pnpm") {
51363
+ i++;
51364
+ if (i < tokens.length && (tokens[i] === "exec" || tokens[i] === "dlx"))
51365
+ i++;
51366
+ if (i >= tokens.length || tokens[i] !== "parall")
51367
+ return null;
51368
+ i++;
51369
+ } else {
51370
+ return null;
51371
+ }
51372
+ return tokens.slice(i).filter((t) => !t.startsWith("-"));
51373
+ }
51374
+ function isParallSendCommand(command) {
51375
+ if (!command)
51376
+ return false;
51377
+ const sub = parseParallCliInvocation(command);
51378
+ if (!sub || sub.length === 0)
51379
+ return false;
51380
+ return sub[0] === "dm" || sub[0] === "messages" && sub[1] === "send";
51381
+ }
51382
+ function isParallNoReplyCommand(command) {
51383
+ if (!command)
51384
+ return false;
51385
+ const sub = parseParallCliInvocation(command);
51386
+ return sub?.[0] === "no-reply";
51387
+ }
51388
+
51389
+ // ../agent-core/dist/channel-capability.js
51390
+ import * as fs from "node:fs";
51280
51391
  import * as path from "node:path";
51281
- function laneKeyForTarget(targetUri, threadRootId) {
51282
- return Buffer.from(`${targetUri}
51283
- ${threadRootId ?? ""}`, "utf8").toString("base64url");
51392
+ import { fileURLToPath } from "node:url";
51393
+ var CAPABILITY_FEISHU_CLI = "feishu-cli";
51394
+ var CAPABILITY_SLACK_SEND = "slack-send";
51395
+ var CAPABILITY_WECHAT_SEND = "wechat-send";
51396
+ function channelCapabilityKeyFor(provider) {
51397
+ if (provider === "slack")
51398
+ return CAPABILITY_SLACK_SEND;
51399
+ if (provider === "wechat")
51400
+ return CAPABILITY_WECHAT_SEND;
51401
+ return `${provider}-cli`;
51402
+ }
51403
+ var CHANNEL_POINTER_MAGIC = "parall channel capability pointer";
51404
+ function capabilityBinDir(stateDir) {
51405
+ return path.join(stateDir, "bin");
51406
+ }
51407
+ function channelExecEntryPath() {
51408
+ const selfDir = path.dirname(fileURLToPath(import.meta.url));
51409
+ const sibling = path.join(selfDir, "parall-channel-exec.js");
51410
+ if (fs.existsSync(sibling))
51411
+ return sibling;
51412
+ return fileURLToPath(new URL("./bin/channel-exec.js", import.meta.url));
51413
+ }
51414
+ function materializeChannelCapabilities(stateDir, capabilities, log) {
51415
+ try {
51416
+ reconcileFeishuCli(stateDir, capabilities, log);
51417
+ } catch (err) {
51418
+ log?.warn(`channel capability materialization failed: ${String(err)}`);
51419
+ }
51420
+ }
51421
+ function reconcileFeishuCli(stateDir, capabilities, log) {
51422
+ const binDir = capabilityBinDir(stateDir);
51423
+ const posixPath = path.join(binDir, "lark-cli");
51424
+ const granted = capabilities.some((c) => c.key === CAPABILITY_FEISHU_CLI);
51425
+ const hadPointer = fs.existsSync(posixPath);
51426
+ if (!granted && !hadPointer)
51427
+ return;
51428
+ fs.mkdirSync(binDir, { recursive: true });
51429
+ const entry = channelExecEntryPath();
51430
+ const nodeExec = process.execPath;
51431
+ writePointerIfChanged(posixPath, renderPosixPointer(nodeExec, entry, binDir, "feishu"), log);
51432
+ writePointerIfChanged(path.join(binDir, "lark-cli.cmd"), renderCmdPointer(nodeExec, entry, binDir, "feishu"), log);
51433
+ }
51434
+ function writePointerIfChanged(filePath, content, log) {
51435
+ let existing = null;
51436
+ try {
51437
+ existing = fs.readFileSync(filePath, "utf8");
51438
+ } catch {
51439
+ existing = null;
51440
+ }
51441
+ if (existing !== content) {
51442
+ fs.writeFileSync(filePath, content, { mode: 493 });
51443
+ log?.info(`channel capability: pointer materialized (${path.basename(filePath)})`);
51444
+ }
51445
+ fs.chmodSync(filePath, 493);
51446
+ }
51447
+ function renderPosixPointer(nodeExecPath, entryJsPath, binDir, channel) {
51448
+ return [
51449
+ "#!/bin/sh",
51450
+ `# Generated by @parall/agent-core \u2014 ${CHANNEL_POINTER_MAGIC} (do not edit).`,
51451
+ "# Credential + exec logic lives in the agent-core package; revocation is",
51452
+ "# enforced by the platform mint endpoint, so this pointer stays constant.",
51453
+ // Strip Node preload-hijack vars BEFORE launching node: NODE_OPTIONS
51454
+ // (e.g. --require=/evil.js) and NODE_PATH would execute caller-supplied code
51455
+ // at interpreter startup — BEFORE channel-exec's own env scrub, i.e. before
51456
+ // the mint. The pointer is a platform-authored trust-boundary artifact whose
51457
+ // whole job is a CONTROLLED launch of the broker (absolute node, magic
51458
+ // guard, skip-dir); this closes the same env-hijack class for node startup
51459
+ // that the absolute node path closes for PATH, keeping the launch deterministic.
51460
+ "unset NODE_OPTIONS NODE_PATH",
51461
+ // "$@" preserves argv exactly (this is the agent's main path via git-bash).
51462
+ `exec "${nodeExecPath}" "${entryJsPath}" --channel ${channel} --skip-dir "${binDir}" -- "$@"`,
51463
+ ""
51464
+ ].join("\n");
51465
+ }
51466
+ function renderCmdPointer(nodeExecPath, entryJsPath, binDir, channel) {
51467
+ return [
51468
+ "@echo off",
51469
+ `rem Generated by @parall/agent-core - ${CHANNEL_POINTER_MAGIC} (do not edit).`,
51470
+ // Clear Node preload-hijack vars before launching node (see the sh pointer).
51471
+ 'set "NODE_OPTIONS="',
51472
+ 'set "NODE_PATH="',
51473
+ `"${nodeExecPath}" "${entryJsPath}" --channel ${channel} --skip-dir "${binDir}" -- %*`,
51474
+ ""
51475
+ ].join("\r\n");
51476
+ }
51477
+
51478
+ // ../agent-core/dist/dispatch-adapter.js
51479
+ function buildErrorStepContent(message) {
51480
+ return { text: message, suppressed: false, status: "error" };
51481
+ }
51482
+
51483
+ // ../agent-core/dist/event-format.js
51484
+ function sanitizeMeta(value) {
51485
+ return value.replace(/[\r\n]+/g, " ").replace(/[[\]|]/g, " ").trim();
51486
+ }
51487
+ function buildEventBody(event) {
51488
+ const lines = [];
51489
+ if (event.type === "message") {
51490
+ lines.push(`[Event: message.new]`);
51491
+ const chatLabel = event.targetName ? `"${event.targetName}" (prll://${event.targetId})` : `prll://${event.targetId}`;
51492
+ lines.push(`[Chat: ${chatLabel} | type: ${event.targetType ?? "unknown"}]`);
51493
+ lines.push(`[From: ${event.senderName} (prll://${event.senderId})]`);
51494
+ lines.push(`[Message ID: prll://${event.messageId}]`);
51495
+ if (event.threadRootId) {
51496
+ const threadMeta = [
51497
+ `prll://${event.threadRootId}`,
51498
+ event.threadReplyCount != null ? `${event.threadReplyCount} replies` : null,
51499
+ event.threadUnreadCount != null && event.threadUnreadCount > 0 ? `${event.threadUnreadCount} unread` : null,
51500
+ event.threadUnreadCount != null && event.threadUnreadCount > 0 && event.threadUnreadSince ? `since: prll://${event.threadUnreadSince}` : null
51501
+ ].filter(Boolean).join(" | ");
51502
+ lines.push(`[Thread: ${threadMeta}]`);
51503
+ }
51504
+ if (event.unreadCount != null && event.unreadCount > 1) {
51505
+ const countStr = event.unreadCount >= 1e3 ? "999+" : String(event.unreadCount);
51506
+ const sinceStr = event.unreadSince ? ` | since: prll://${event.unreadSince}` : "";
51507
+ let line = `[Unread: ${countStr} messages${sinceStr}]`;
51508
+ if (event.unreadCount > 50)
51509
+ line += ` \u2014 fetch recent context with --limit, not all`;
51510
+ lines.push(line);
51511
+ }
51512
+ if (event.noReply)
51513
+ lines.push(`[Hint: no_reply]`);
51514
+ if (event.attachments?.length) {
51515
+ for (const att of event.attachments) {
51516
+ const sizeStr = att.fileSize >= 1048576 ? `${(att.fileSize / 1048576).toFixed(1)}MB` : `${Math.round(att.fileSize / 1024)}KB`;
51517
+ lines.push(`[Attachment: prll://${att.id} | ${sanitizeMeta(att.mimeType)} | ${sizeStr} | ${sanitizeMeta(att.fileName)}]`);
51518
+ }
51519
+ }
51520
+ lines.push("", event.body);
51521
+ } else if (event.type === "task_comment") {
51522
+ lines.push(`[Event: task.comment.created]`);
51523
+ const taskLabel = event.targetName ? `${event.targetName} (prll://${event.targetId})` : `prll://${event.targetId}`;
51524
+ lines.push(`[Task: ${taskLabel}]`);
51525
+ if (event.deliveryReason)
51526
+ lines.push(`[Delivery: ${sanitizeMeta(event.deliveryReason)}]`);
51527
+ lines.push(`[From: ${event.senderName} (prll://${event.senderId})]`);
51528
+ lines.push(`[Comment ID: prll://${event.messageId}]`);
51529
+ lines.push("", event.body);
51530
+ } else if (event.type === "wiki_comment") {
51531
+ lines.push(`[Event: wiki.comment.created]`);
51532
+ const target = event.replyTargetUri ?? `prll://${event.targetId}`;
51533
+ if (event.targetType === "changeset") {
51534
+ lines.push(`[Wiki Changeset: ${target}]`);
51535
+ } else {
51536
+ lines.push(`[Wiki: ${event.targetName ? `${sanitizeMeta(event.targetName)} (${target})` : target}]`);
51537
+ }
51538
+ if (event.deliveryReason)
51539
+ lines.push(`[Delivery: ${sanitizeMeta(event.deliveryReason)}]`);
51540
+ lines.push(`[From: ${event.senderName} (prll://${event.senderId})]`);
51541
+ lines.push(`[Comment ID: prll://${event.messageId}]`);
51542
+ lines.push("", event.body);
51543
+ } else if (event.type === "approval") {
51544
+ lines.push(`[Event: approval.decided]`);
51545
+ lines.push(`[Approval: prll://${event.messageId}]`);
51546
+ lines.push(`[Chat: prll://${event.targetId}]`);
51547
+ lines.push(`[Decided by: ${event.senderName} (prll://${event.senderId})]`);
51548
+ lines.push("", event.body);
51549
+ } else if (event.type === "schedule") {
51550
+ lines.push(`[Event: schedule.fired]`);
51551
+ lines.push(`[Schedule: prll://${event.targetId}]`);
51552
+ lines.push(`[Run: prll://${event.messageId}]`);
51553
+ if (event.scheduledFireAt)
51554
+ lines.push(`[Scheduled at: ${sanitizeMeta(event.scheduledFireAt)}]`);
51555
+ if (event.attachedUri)
51556
+ lines.push(`[Attached: ${sanitizeMeta(event.attachedUri)}]`);
51557
+ lines.push("", event.body);
51558
+ } else if (event.type === "channel_message") {
51559
+ lines.push(`[Event: channel.message]`);
51560
+ const providerLabel = sanitizeMeta(event.channelProvider ?? "external IM");
51561
+ const convLabel = event.channelExternalConversationId ? `${sanitizeMeta(event.channelExternalConversationId)} (${sanitizeMeta(event.channelConversationType ?? "conversation")})` : sanitizeMeta(event.channelConversationType ?? "conversation");
51562
+ lines.push(`[Channel: ${providerLabel} | conversation: ${convLabel}]`);
51563
+ lines.push(`[From: ${sanitizeMeta(event.senderName)} (external user, not a Parall member)]`);
51564
+ if (event.channelExternalMessageId) {
51565
+ lines.push(`[External message ID: ${sanitizeMeta(event.channelExternalMessageId)}]`);
51566
+ }
51567
+ lines.push(`[Audience: this conversation lives on ${providerLabel}, OUTSIDE Parall. Readers cannot open prll:// links, Parall cards, or internal attachments \u2014 never include them in replies. Write plain conversational text.]`);
51568
+ lines.push("", event.body);
51569
+ } else if (event.type === "external_trigger") {
51570
+ lines.push(`[Event: external.trigger]`);
51571
+ lines.push(`[Trigger: prll://${event.targetId}]`);
51572
+ lines.push(`[Run: prll://${event.messageId}]`);
51573
+ if (event.externalConnectionId) {
51574
+ const label = event.externalConnectionDisplayName ? `${sanitizeMeta(event.externalConnectionDisplayName)} (prll://${event.externalConnectionId})` : `prll://${event.externalConnectionId}`;
51575
+ lines.push(`[Connection: ${label}]`);
51576
+ }
51577
+ if (event.externalIngressEventId)
51578
+ lines.push(`[Ingress: prll://${event.externalIngressEventId}]`);
51579
+ if (event.attachedUri)
51580
+ lines.push(`[Attached: ${sanitizeMeta(event.attachedUri)}]`);
51581
+ if (event.externalConnectionSourceType) {
51582
+ lines.push(`[Source: ${sanitizeMeta(event.externalConnectionSourceType)}]`);
51583
+ }
51584
+ if (event.externalIngressEventType) {
51585
+ lines.push(`[External event: ${sanitizeMeta(event.externalIngressEventType)}]`);
51586
+ }
51587
+ lines.push("", event.body);
51588
+ } else {
51589
+ lines.push(`[Event: task.assigned]`);
51590
+ const taskLabel = event.targetName ? `${event.targetName} (prll://${event.targetId})` : `prll://${event.targetId}`;
51591
+ lines.push(`[Task: ${taskLabel}]`);
51592
+ lines.push(`[Assigned by: ${event.senderName} (prll://${event.senderId})]`);
51593
+ lines.push("", event.body);
51594
+ }
51595
+ return lines.join("\n") + buildSendMessageHint(event);
51596
+ }
51597
+ function buildEventBodyForForkResult(event) {
51598
+ return buildEventBody(event).replace(/\n<system-reminder>[\s\S]*<\/system-reminder>$/, "");
51599
+ }
51600
+ function buildSendMessageHint(event) {
51601
+ if (event.noReply)
51602
+ return "";
51603
+ if (event.type === "wiki_comment" && event.replyTargetUri) {
51604
+ const where = event.targetType === "changeset" ? "this changeset comment" : "this wiki page";
51605
+ return `
51606
+ <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>`;
51607
+ }
51608
+ if (event.targetId.startsWith("cht_")) {
51609
+ if (event.threadRootId) {
51610
+ return `
51611
+ <system-reminder>To reply in this thread, run \`parall messages send prll://${event.targetId} --thread-root-id ${sanitizeMeta(event.threadRootId)} --text-file - <<'EOF'\` \u2026 \`EOF\` \u2014 the quoted heredoc keeps \`$\`, backticks and apostrophes literal (plain \`--text "$1,000"\` sends \`,000\`). Your plain text output is not delivered to the chat.</system-reminder>`;
51612
+ }
51613
+ return `
51614
+ <system-reminder>To reply, run \`parall messages send prll://${event.targetId} --text-file - <<'EOF'\` \u2026 \`EOF\` \u2014 the quoted heredoc keeps \`$\`, backticks and apostrophes literal (plain \`--text "$1,000"\` sends \`,000\`). Your plain text output is not delivered to the chat.</system-reminder>`;
51615
+ }
51616
+ if (event.targetId.startsWith("tsk_")) {
51617
+ return `
51618
+ <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>`;
51619
+ }
51620
+ if (event.targetId.startsWith("sch_")) {
51621
+ return `
51622
+ <system-reminder>To communicate, use the CLI: \`parall messages send\` / \`parall dm\`. Your plain text output is not delivered.</system-reminder>`;
51623
+ }
51624
+ if (event.type === "channel_message") {
51625
+ if (event.channelCliCapable) {
51626
+ if (event.channelProvider === "slack") {
51627
+ const channelArg = event.channelExternalConversationId ? ` --channel "${event.channelExternalConversationId}"` : " --channel <conversation id from this event>";
51628
+ const replyTo = event.channelExternalMessageId ? ` --reply-to "${event.channelExternalMessageId}"` : "";
51629
+ return `
51630
+ <system-reminder>To reply, use the platform verb: \`parall slack send${channelArg}${replyTo} --text <your reply>\`. In channels --reply-to is REQUIRED (the reply lands in that message's thread); in DMs it is optional (DMs are linear). \`parall slack send\` is the ONLY outbound path \u2014 your plain text output is NOT delivered to the external conversation.</system-reminder>`;
51631
+ }
51632
+ if (event.channelProvider === "wechat") {
51633
+ const toArg = event.channelExternalConversationId ? ` --to "${event.channelExternalConversationId}"` : " --to <wxid from this event>";
51634
+ const atArg = event.channelConversationType === "group" ? event.senderId && event.senderId !== "external" ? ` --at "${event.senderId}"` : " --at <wxid of the person you are answering>" : "";
51635
+ return `
51636
+ <system-reminder>To reply, use the platform verb: \`parall wechat send${toArg}${atArg} --text-file - <<'EOF'\` \u2026 \`EOF\` (or --text "<short text>" for simple literals \u2014 the quoted heredoc keeps $, backticks and apostrophes literal). In group chats, --at @-mentions the person you are answering. \`parall wechat send\` is the ONLY outbound path \u2014 your plain text output is NOT delivered to the external conversation.</system-reminder>`;
51637
+ }
51638
+ if (!event.channelProvider) {
51639
+ return `
51640
+ <system-reminder>To reply, use the channel capability granted in your system prompt \u2014 for Feishu conversations that is \`lark-cli im\`, for Slack it is \`parall slack send\` (pass the message id from this event as --reply-to), for WeChat it is \`parall wechat send\`. That capability is the ONLY outbound path \u2014 your plain text output is NOT delivered to the external conversation.</system-reminder>`;
51641
+ }
51642
+ const convRef = event.channelExternalConversationId ? `chat_id "${event.channelExternalConversationId}"` : "the conversation id named in this event";
51643
+ const threadAlt = event.channelExternalMessageId ? ` To reply threaded to this specific message, reference message_id "${event.channelExternalMessageId}".` : "";
51644
+ return `
51645
+ <system-reminder>To reply, use the official Feishu CLI on your PATH: send a message to ${convRef} with \`lark-cli im\` (see \`lark-cli im --help\` for send syntax; auth is provisioned automatically).${threadAlt} lark-cli is the ONLY outbound path \u2014 your plain text output is NOT delivered to the external conversation.</system-reminder>`;
51646
+ }
51647
+ const platform = event.channelProvider ?? "the external platform";
51648
+ return `
51649
+ <system-reminder>This message arrived from ${platform}, but outbound replies are currently disabled for this org (no channel capability granted). Do NOT attempt to reply on the external platform. If action is needed, surface it inside Parall (\`parall messages send\` / \`parall dm\`). Your plain text output is not delivered anywhere.</system-reminder>`;
51650
+ }
51651
+ if (event.type === "external_trigger" || event.targetId.startsWith("xtr_")) {
51652
+ return `
51653
+ <system-reminder>This external trigger is incoming-only. Your plain text output is not sent back to the external provider. To communicate in Parall, use \`parall messages send\` / \`parall dm\`; provider-specific outbound actions require a separate capability.</system-reminder>`;
51654
+ }
51655
+ return "";
51284
51656
  }
51285
- function dispatchLaneContextDir(stateDir) {
51286
- return path.join(stateDir, "dispatch-lane-context");
51657
+ function buildForkScopePrefix(event) {
51658
+ const targetLabel = event.targetName ? `"${event.targetName}" (prll://${event.targetId})` : `prll://${event.targetId}`;
51659
+ return `[Fork scope: You are a parallel worker forked from the main session to handle ${targetLabel}. The conversation history above belongs to the main session's in-progress dispatch \u2014 do NOT continue it or complete it, or produce external output (comments, messages) for work visible there. The main session owns its own output.
51660
+
51661
+ Only act on the event below within your target scope. If your event reveals findings about the main session's work, report them in your summary \u2014 do not post them externally.
51662
+
51663
+ End with a brief "Fork summary" of actions taken and decisions made.]
51664
+
51665
+ `;
51287
51666
  }
51288
- function laneContextFilePath(contextDir, targetUri, threadRootId) {
51289
- return path.join(contextDir, `${laneKeyForTarget(targetUri, threadRootId)}.json`);
51667
+ function buildForkResultPrefix(results) {
51668
+ if (!results.length)
51669
+ return "";
51670
+ const blocks = results.map((result) => {
51671
+ const lines = [];
51672
+ for (const body of result.eventBodies) {
51673
+ lines.push(body);
51674
+ }
51675
+ lines.push(`[This event was handled by a parallel fork session. Do NOT re-handle, re-reply, or duplicate work for it.]`);
51676
+ lines.push(`[Fork summary: ${result.agentSummary ? sanitizeMeta(result.agentSummary) : "No fork summary available \u2014 the fork completed without producing a text summary. Check the target chat/task for any actions the fork already took before acting."}]`);
51677
+ if (result.actions.length)
51678
+ lines.push(`[Fork actions: ${result.actions.join("; ")}]`);
51679
+ if (result.historyPath)
51680
+ lines.push(`[Fork history: ${result.historyPath}]`);
51681
+ return lines.join("\n");
51682
+ });
51683
+ return blocks.join("\n\n") + "\n\n---\n\n";
51290
51684
  }
51291
51685
 
51686
+ // ../agent-core/dist/gateway-base.js
51687
+ import * as os from "node:os";
51688
+ import * as fs3 from "node:fs";
51689
+ import * as path3 from "node:path";
51690
+ import { randomUUID } from "node:crypto";
51691
+
51292
51692
  // ../sdk/dist/browser-viewer.js
51293
51693
  var BROWSER_VIEWER_READINESS_TIMEOUT_MS = 6e4;
51294
51694
  function browserViewerRequestOptions(command, opts) {
@@ -51330,6 +51730,9 @@ var ENDPOINTS = {
51330
51730
  ORG_MEMBERS: (orgId) => `${API_BASE}/orgs/${orgId}/members`,
51331
51731
  ORG_MEMBERS_FORMER: (orgId) => `${API_BASE}/orgs/${orgId}/members/former`,
51332
51732
  TEAMS: (orgId) => `${API_BASE}/orgs/${orgId}/teams`,
51733
+ TEAM: (orgId, teamId) => `${API_BASE}/orgs/${orgId}/teams/${teamId}`,
51734
+ TEAM_MEMBERS: (orgId, teamId) => `${API_BASE}/orgs/${orgId}/teams/${teamId}/members`,
51735
+ TEAM_MEMBER: (orgId, teamId, userId) => `${API_BASE}/orgs/${orgId}/teams/${teamId}/members/${userId}`,
51333
51736
  ORG_MEMBERS_ONLINE: (orgId) => `${API_BASE}/orgs/${orgId}/members/online`,
51334
51737
  ORG_MEMBER: (orgId, userId) => `${API_BASE}/orgs/${orgId}/members/${userId}`,
51335
51738
  ORG_MEMBER_CHATS: (orgId, memberId) => `${API_BASE}/orgs/${orgId}/members/${memberId}/chats`,
@@ -51452,6 +51855,7 @@ var ENDPOINTS = {
51452
51855
  MACHINES_ME_BROWSER_PROFILE_VIEWER_RESPONSE: (requestId) => `${API_BASE}/machines/me/browser-profiles/viewer-response/${requestId}`,
51453
51856
  // Tasks (org-scoped)
51454
51857
  TASKS: (orgId) => `${API_BASE}/orgs/${orgId}/tasks`,
51858
+ TASK_SUBTASK_SUMMARY: (orgId) => `${API_BASE}/orgs/${orgId}/tasks/subtask-summary`,
51455
51859
  TASK: (orgId, taskId) => `${API_BASE}/orgs/${orgId}/tasks/${taskId}`,
51456
51860
  TASK_ARCHIVE: (orgId, taskId) => `${API_BASE}/orgs/${orgId}/tasks/${taskId}/archive`,
51457
51861
  TASK_RESTORE: (orgId, taskId) => `${API_BASE}/orgs/${orgId}/tasks/${taskId}/restore`,
@@ -51465,8 +51869,14 @@ var ENDPOINTS = {
51465
51869
  TASK_COMMENTS: (orgId, taskId) => `${API_BASE}/orgs/${orgId}/tasks/${taskId}/comments`,
51466
51870
  TASK_COMMENT: (orgId, taskId, commentId) => `${API_BASE}/orgs/${orgId}/tasks/${taskId}/comments/${commentId}`,
51467
51871
  TASK_ACTIVITIES: (orgId, taskId) => `${API_BASE}/orgs/${orgId}/tasks/${taskId}/activities`,
51872
+ TASK_LABELS: (orgId, taskId) => `${API_BASE}/orgs/${orgId}/tasks/${taskId}/labels`,
51873
+ TASK_LABEL: (orgId, taskId, labelId) => `${API_BASE}/orgs/${orgId}/tasks/${taskId}/labels/${labelId}`,
51874
+ // Labels (org-scoped vocabulary; writes are admin-gated)
51875
+ LABELS: (orgId) => `${API_BASE}/orgs/${orgId}/labels`,
51876
+ LABEL: (orgId, labelId) => `${API_BASE}/orgs/${orgId}/labels/${labelId}`,
51468
51877
  // Projects (org-scoped)
51469
51878
  PROJECTS: (orgId) => `${API_BASE}/orgs/${orgId}/projects`,
51879
+ PROJECT_TASK_SUMMARY: (orgId) => `${API_BASE}/orgs/${orgId}/projects/task-summary`,
51470
51880
  PROJECT: (orgId, projectId) => `${API_BASE}/orgs/${orgId}/projects/${projectId}`,
51471
51881
  // Schedules (org-scoped, platform time trigger primitive)
51472
51882
  SCHEDULES: (orgId) => `${API_BASE}/orgs/${orgId}/schedules`,
@@ -51509,8 +51919,10 @@ var ENDPOINTS = {
51509
51919
  SLACK_HISTORY: (orgId) => `${API_BASE}/orgs/${orgId}/agents/me/slack/history`,
51510
51920
  SLACK_MEMBERS: (orgId) => `${API_BASE}/orgs/${orgId}/agents/me/slack/members`,
51511
51921
  SLACK_STATUS: (orgId) => `${API_BASE}/orgs/${orgId}/agents/me/slack/status`,
51512
- // WeChat tier-B read verb (agent-only; internal research preview).
51922
+ // WeChat tier-B read verbs (agent-only; internal research preview).
51513
51923
  WECHAT_CONTACTS: (orgId) => `${API_BASE}/orgs/${orgId}/agents/me/wechat/contacts`,
51924
+ WECHAT_PROFILE: (orgId) => `${API_BASE}/orgs/${orgId}/agents/me/wechat/profile`,
51925
+ WECHAT_STATUS: (orgId) => `${API_BASE}/orgs/${orgId}/agents/me/wechat/status`,
51514
51926
  // Invitations (org-scoped, admin)
51515
51927
  ORG_INVITATIONS: (orgId) => `${API_BASE}/orgs/${orgId}/invitations`,
51516
51928
  ORG_INVITATION: (orgId, invId) => `${API_BASE}/orgs/${orgId}/invitations/${invId}`,
@@ -51624,8 +52036,10 @@ var ENDPOINTS = {
51624
52036
  NOTIFICATION_PREFERENCES: `${API_BASE}/notification-preferences`,
51625
52037
  // Unified search (messages + tasks + wiki, org-scoped)
51626
52038
  SEARCH: (orgId) => `${API_BASE}/orgs/${orgId}/search`,
51627
- // Feature flags (org-scoped, server-evaluated)
51628
- FEATURE_FLAGS: (orgId) => `${API_BASE}/orgs/${orgId}/feature-flags`,
52039
+ // Feature flags (server-evaluated). Org-scoped by default; omit the org for
52040
+ // the pre-org form, which resolves "cap:" capabilities only (PostHog flags
52041
+ // are org-scoped and absent there) for callers that have no org yet.
52042
+ FEATURE_FLAGS: (orgId) => orgId ? `${API_BASE}/orgs/${orgId}/feature-flags` : `${API_BASE}/feature-flags`,
51629
52043
  // Team templates (org-scoped, owner/admin only)
51630
52044
  TEMPLATES: (orgId) => `${API_BASE}/orgs/${orgId}/templates`,
51631
52045
  TEMPLATE: (orgId, templateId) => `${API_BASE}/orgs/${orgId}/templates/${templateId}`,
@@ -51695,103 +52109,255 @@ var ENDPOINTS = {
51695
52109
  ORG_CLIP_INSTALL: (orgId) => `/api/v1/orgs/${orgId}/clips/install`,
51696
52110
  ORG_CLIPS_INSTALLED: (orgId) => `/api/v1/orgs/${orgId}/clips/installed`,
51697
52111
  ORG_CLIP_UNINSTALL: (orgId, clipId) => `/api/v1/orgs/${orgId}/clips/${clipId}/uninstall`,
52112
+ ORG_CLIP_MCP_REMOVE: (orgId, clipId) => `/api/v1/orgs/${orgId}/clips/${clipId}/mcp-remove`,
51698
52113
  // Per-org agent exec access for one clip (default all agents; PUT human-only)
51699
52114
  ORG_CLIP_EXEC_ACCESS: (orgId, clipId) => `/api/v1/orgs/${orgId}/clips/${clipId}/exec-access`,
51700
- // MCP clip server config (cap:clip-mcp; publisher-org only cross-org gets
51701
- // 403 MCP_CROSS_ORG_DISABLED on the whole family, reads included)
52115
+ // MCP clip server config (cap:clip-mcp; cross-org is limited to installed,
52116
+ // reviewed Official OAuth Clips). The
52117
+ // singular family addresses the org's DEFAULT connection (pre-165
52118
+ // back-compat shim); the plural family is the multi-connection surface —
52119
+ // one config row (credential slot) per connection, addressed by config id.
51702
52120
  ORG_CLIP_MCP_CONFIG: (orgId, clipId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/mcp-config`,
51703
52121
  ORG_CLIP_MCP_TOOLS_REFRESH: (orgId, clipId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/mcp-config/tools/refresh`,
51704
- ORG_CLIP_MCP_OAUTH_DISCONNECT: (orgId, clipId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/mcp-config/oauth/disconnect`
52122
+ ORG_CLIP_MCP_OAUTH_DISCONNECT: (orgId, clipId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/mcp-config/oauth/disconnect`,
52123
+ ORG_CLIP_MCP_CONFIGS: (orgId, clipId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/mcp-configs`,
52124
+ ORG_CLIP_MCP_CONFIG_BY_ID: (orgId, clipId, configId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/mcp-configs/${configId}`,
52125
+ ORG_CLIP_MCP_TOOLS_REFRESH_BY_ID: (orgId, clipId, configId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/mcp-configs/${configId}/tools/refresh`,
52126
+ ORG_CLIP_MCP_OAUTH_DISCONNECT_BY_ID: (orgId, clipId, configId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/mcp-configs/${configId}/oauth/disconnect`
52127
+ };
52128
+ var WS_EVENTS = {
52129
+ // Client -> Server
52130
+ PING: "ping",
52131
+ TYPING: "typing",
52132
+ WATCH: "watch",
52133
+ AGENT_HEARTBEAT: "agent.heartbeat",
52134
+ // Server -> Client
52135
+ HELLO: "hello",
52136
+ PONG: "pong",
52137
+ WATCHING: "watching",
52138
+ MESSAGE_NEW: "message.new",
52139
+ MESSAGE_PATCH: "message.patch",
52140
+ MESSAGE_EDIT: "message.edit",
52141
+ MESSAGE_DELETE: "message.delete",
52142
+ MESSAGE_REACTION_UPDATED: "message.reaction.updated",
52143
+ TYPING_UPDATE: "typing.update",
52144
+ CHAT_UPDATE: "chat.update",
52145
+ CHAT_DELETED: "chat.deleted",
52146
+ APPROVAL_UPDATE: "approval.update",
52147
+ // deprecated
52148
+ CARD_UPDATE: "card.update",
52149
+ RECOVERY_OVERFLOW: "recovery.overflow",
52150
+ MEMBERSHIP_CHANGED: "membership.changed",
52151
+ TASK_CREATED: "task.created",
52152
+ TASK_UPDATED: "task.updated",
52153
+ TASK_DELETED: "task.deleted",
52154
+ TASK_COMMENT_CREATED: "task.comment.created",
52155
+ TASK_COMMENT_UPDATED: "task.comment.updated",
52156
+ TASK_COMMENT_DELETED: "task.comment.deleted",
52157
+ PROJECT_CREATED: "project.created",
52158
+ PROJECT_UPDATED: "project.updated",
52159
+ PROJECT_DELETED: "project.deleted",
52160
+ LABEL_CREATED: "label.created",
52161
+ LABEL_UPDATED: "label.updated",
52162
+ LABEL_DELETED: "label.deleted",
52163
+ AGENT_SESSION_NEW: "agent_session.new",
52164
+ AGENT_SESSION_UPDATE: "agent_session.update",
52165
+ AGENT_STEP_NEW: "agent_step.new",
52166
+ INVITATION_NEW: "invitation.new",
52167
+ INVITATION_ACCEPTED: "invitation.accepted",
52168
+ INVITATION_DECLINED: "invitation.declined",
52169
+ INVITATION_REVOKED: "invitation.revoked",
52170
+ ORG_JOIN_REQUEST_NEW: "org.join_request.new",
52171
+ ORG_INVITE_LINK_JOINED: "org.invite_link.joined",
52172
+ ORG_MEMBER_REMOVED: "org.member.removed",
52173
+ ORG_MEMBER_PROFILE_UPDATED: "org.member.profile.updated",
52174
+ AGENT_CONFIG_UPDATE: "agent_config.update",
52175
+ PRESENCE_UPDATE: "presence.update",
52176
+ WIKI_CHANGESET_CREATED: "wiki.changeset.created",
52177
+ WIKI_CHANGESET_UPDATED: "wiki.changeset.updated",
52178
+ WIKI_DELETED: "wiki.deleted",
52179
+ WIKI_RESTORED: "wiki.restored",
52180
+ COMMENT_CREATED: "comment.created",
52181
+ COMMENT_UPDATED: "comment.updated",
52182
+ COMMENT_DELETED: "comment.deleted",
52183
+ NOTIFICATION_ALERT: "notification.alert",
52184
+ INBOX_NEW: "inbox.new",
52185
+ INBOX_UPDATE: "inbox.update",
52186
+ INBOX_BULK_UPDATE: "inbox.bulk_update",
52187
+ READ_POSITION_UPDATED: "read_position.updated",
52188
+ THREAD_READ_POSITION_UPDATED: "thread_read_position.updated",
52189
+ DISPATCH_NEW: "dispatch.new",
52190
+ DISPATCH_RECEIVED: "dispatch.received",
52191
+ DISPATCH_RESOLVED: "dispatch.resolved",
52192
+ SCHEDULE_CREATED: "schedule.created",
52193
+ SCHEDULE_UPDATED: "schedule.updated",
52194
+ SCHEDULE_DELETED: "schedule.deleted",
52195
+ SCHEDULE_FIRED: "schedule.fired",
52196
+ BILLING_BALANCE_UPDATED: "billing.balance_updated",
52197
+ BILLING_LOW_BALANCE: "billing.low_balance",
52198
+ BILLING_MACHINE_STOPPED: "billing.machine_stopped",
52199
+ BILLING_INSUFFICIENT: "billing.insufficient",
52200
+ USER_UPDATED: "user.updated",
52201
+ MACHINE_HELLO: "machine.hello",
52202
+ MACHINE_AGENT_ATTACHED: "machine.agent.attached",
52203
+ MACHINE_AGENT_DETACHED: "machine.agent.detached",
52204
+ MACHINE_STOP: "machine.stop",
52205
+ MACHINE_WORKSPACE_SETUP_REQUESTED: "machine.workspace.setup.requested",
52206
+ MACHINE_FILESYSTEM_BROWSE: "machine.filesystem.browse",
52207
+ MACHINE_UPDATE: "machine.update",
52208
+ MACHINE_CONFIG_UPDATED: "machine.config.updated",
52209
+ MACHINE_AGENT_CONFIG_UPDATED: "machine.agent_config.updated",
52210
+ MACHINE_CLIP_SYNC: "machine.clip.sync",
52211
+ MACHINE_BROWSER_PROFILE_LIFECYCLE: "machine.browser_profile.lifecycle",
52212
+ MACHINE_BROWSER_PROFILE_VIEWER: "machine.browser_profile.viewer",
52213
+ AGENT_NEW_SESSION: "agent.new_session",
52214
+ CLIP_CREATED: "clip.created",
52215
+ CLIP_REMOVED: "clip.removed",
52216
+ CLIP_UPDATED: "clip.updated"
52217
+ };
52218
+
52219
+ // ../sdk/dist/project-task-client.js
52220
+ var ProjectTaskClient = class {
52221
+ async createTask(orgId, data) {
52222
+ return this.request("POST", ENDPOINTS.TASKS(orgId), data);
52223
+ }
52224
+ async getTasks(orgId, params) {
52225
+ return this.request("GET", ENDPOINTS.TASKS(orgId), void 0, params);
52226
+ }
52227
+ async getTaskSubtaskSummary(orgId, params) {
52228
+ return this.request("GET", ENDPOINTS.TASK_SUBTASK_SUMMARY(orgId), void 0, params);
52229
+ }
52230
+ async getTask(orgId, taskId) {
52231
+ return this.request("GET", ENDPOINTS.TASK(orgId, taskId));
52232
+ }
52233
+ async updateTask(orgId, taskId, data) {
52234
+ return this.request("PATCH", ENDPOINTS.TASK(orgId, taskId), data);
52235
+ }
52236
+ async deleteTask(orgId, taskId, opts) {
52237
+ return this.request("DELETE", ENDPOINTS.TASK(orgId, taskId), void 0, opts?.force ? { force: "true" } : void 0);
52238
+ }
52239
+ async archiveTask(orgId, taskId) {
52240
+ return this.request("POST", ENDPOINTS.TASK_ARCHIVE(orgId, taskId));
52241
+ }
52242
+ async restoreTask(orgId, taskId) {
52243
+ return this.request("POST", ENDPOINTS.TASK_RESTORE(orgId, taskId));
52244
+ }
52245
+ async watchTask(orgId, taskId) {
52246
+ return this.request("POST", ENDPOINTS.TASK_WATCH(orgId, taskId));
52247
+ }
52248
+ async unwatchTask(orgId, taskId) {
52249
+ return this.request("DELETE", ENDPOINTS.TASK_WATCH(orgId, taskId));
52250
+ }
52251
+ async getTaskWatchers(orgId, taskId) {
52252
+ const res = await this.request("GET", ENDPOINTS.TASK_WATCHERS(orgId, taskId));
52253
+ return res.data;
52254
+ }
52255
+ async subscribeTaskMember(orgId, taskId, userId) {
52256
+ return this.request("PUT", ENDPOINTS.TASK_SUBSCRIBER(orgId, taskId, userId));
52257
+ }
52258
+ async unsubscribeTaskMember(orgId, taskId, userId) {
52259
+ return this.request("DELETE", ENDPOINTS.TASK_SUBSCRIBER(orgId, taskId, userId));
52260
+ }
52261
+ async watchThread(threadRootId) {
52262
+ return this.request("POST", ENDPOINTS.MESSAGE_WATCH(threadRootId));
52263
+ }
52264
+ async unwatchThread(threadRootId) {
52265
+ return this.request("DELETE", ENDPOINTS.MESSAGE_WATCH(threadRootId));
52266
+ }
52267
+ async getThreadWatchers(threadRootId) {
52268
+ const res = await this.request("GET", ENDPOINTS.MESSAGE_WATCHERS(threadRootId));
52269
+ return res.data;
52270
+ }
52271
+ async isWatchingThread(threadRootId) {
52272
+ const res = await this.request("GET", ENDPOINTS.MESSAGE_WATCHING(threadRootId));
52273
+ return res.watching;
52274
+ }
52275
+ async getSubtasks(orgId, taskId) {
52276
+ const res = await this.request("GET", ENDPOINTS.TASK_SUBTASKS(orgId, taskId));
52277
+ return res.data;
52278
+ }
52279
+ async createTaskRelation(orgId, taskId, data) {
52280
+ return this.request("POST", ENDPOINTS.TASK_RELATIONS(orgId, taskId), data);
52281
+ }
52282
+ async getTaskRelations(orgId, taskId) {
52283
+ const res = await this.request("GET", ENDPOINTS.TASK_RELATIONS(orgId, taskId));
52284
+ return res.data;
52285
+ }
52286
+ async listTaskRelationsByTarget(orgId, params) {
52287
+ const query = new URLSearchParams({
52288
+ target_type: params.target_type,
52289
+ target_id: params.target_id
52290
+ });
52291
+ const res = await this.request("GET", `${ENDPOINTS.TASK_RELATIONS_BY_TARGET(orgId)}?${query.toString()}`);
52292
+ return res.data;
52293
+ }
52294
+ async deleteTaskRelation(orgId, taskId, relationId) {
52295
+ return this.request("DELETE", ENDPOINTS.TASK_RELATION(orgId, taskId, relationId));
52296
+ }
52297
+ async getTaskComments(orgId, taskId, params) {
52298
+ return this.request("GET", ENDPOINTS.TASK_COMMENTS(orgId, taskId), void 0, params);
52299
+ }
52300
+ async getTaskComment(orgId, taskId, commentId) {
52301
+ return this.request("GET", ENDPOINTS.TASK_COMMENT(orgId, taskId, commentId));
52302
+ }
52303
+ async createTaskComment(orgId, taskId, data) {
52304
+ return this.request("POST", ENDPOINTS.TASK_COMMENTS(orgId, taskId), data);
52305
+ }
52306
+ async updateTaskComment(orgId, taskId, commentId, data) {
52307
+ return this.request("PATCH", ENDPOINTS.TASK_COMMENT(orgId, taskId, commentId), data);
52308
+ }
52309
+ async deleteTaskComment(orgId, taskId, commentId) {
52310
+ return this.request("DELETE", ENDPOINTS.TASK_COMMENT(orgId, taskId, commentId));
52311
+ }
52312
+ async getTaskActivities(orgId, taskId, params) {
52313
+ return this.request("GET", ENDPOINTS.TASK_ACTIVITIES(orgId, taskId), void 0, params);
52314
+ }
52315
+ async createProject(orgId, data) {
52316
+ return this.request("POST", ENDPOINTS.PROJECTS(orgId), data);
52317
+ }
52318
+ async getProjects(orgId) {
52319
+ const res = await this.request("GET", ENDPOINTS.PROJECTS(orgId));
52320
+ return res.data;
52321
+ }
52322
+ async getProjectTaskSummary(orgId) {
52323
+ return this.request("GET", ENDPOINTS.PROJECT_TASK_SUMMARY(orgId));
52324
+ }
52325
+ async getProject(orgId, projectId) {
52326
+ return this.request("GET", ENDPOINTS.PROJECT(orgId, projectId));
52327
+ }
52328
+ async updateProject(orgId, projectId, data) {
52329
+ return this.request("PATCH", ENDPOINTS.PROJECT(orgId, projectId), data);
52330
+ }
52331
+ async deleteProject(orgId, projectId) {
52332
+ return this.request("DELETE", ENDPOINTS.PROJECT(orgId, projectId));
52333
+ }
51705
52334
  };
51706
- var WS_EVENTS = {
51707
- // Client -> Server
51708
- PING: "ping",
51709
- TYPING: "typing",
51710
- WATCH: "watch",
51711
- AGENT_HEARTBEAT: "agent.heartbeat",
51712
- // Server -> Client
51713
- HELLO: "hello",
51714
- PONG: "pong",
51715
- WATCHING: "watching",
51716
- MESSAGE_NEW: "message.new",
51717
- MESSAGE_PATCH: "message.patch",
51718
- MESSAGE_EDIT: "message.edit",
51719
- MESSAGE_DELETE: "message.delete",
51720
- MESSAGE_REACTION_UPDATED: "message.reaction.updated",
51721
- TYPING_UPDATE: "typing.update",
51722
- CHAT_UPDATE: "chat.update",
51723
- CHAT_DELETED: "chat.deleted",
51724
- APPROVAL_UPDATE: "approval.update",
51725
- // deprecated
51726
- CARD_UPDATE: "card.update",
51727
- RECOVERY_OVERFLOW: "recovery.overflow",
51728
- MEMBERSHIP_CHANGED: "membership.changed",
51729
- TASK_CREATED: "task.created",
51730
- TASK_UPDATED: "task.updated",
51731
- TASK_DELETED: "task.deleted",
51732
- TASK_COMMENT_CREATED: "task.comment.created",
51733
- TASK_COMMENT_UPDATED: "task.comment.updated",
51734
- TASK_COMMENT_DELETED: "task.comment.deleted",
51735
- PROJECT_CREATED: "project.created",
51736
- PROJECT_UPDATED: "project.updated",
51737
- PROJECT_DELETED: "project.deleted",
51738
- AGENT_SESSION_NEW: "agent_session.new",
51739
- AGENT_SESSION_UPDATE: "agent_session.update",
51740
- AGENT_STEP_NEW: "agent_step.new",
51741
- INVITATION_NEW: "invitation.new",
51742
- INVITATION_ACCEPTED: "invitation.accepted",
51743
- INVITATION_DECLINED: "invitation.declined",
51744
- INVITATION_REVOKED: "invitation.revoked",
51745
- ORG_JOIN_REQUEST_NEW: "org.join_request.new",
51746
- ORG_INVITE_LINK_JOINED: "org.invite_link.joined",
51747
- ORG_MEMBER_REMOVED: "org.member.removed",
51748
- AGENT_CONFIG_UPDATE: "agent_config.update",
51749
- PRESENCE_UPDATE: "presence.update",
51750
- WIKI_CHANGESET_CREATED: "wiki.changeset.created",
51751
- WIKI_CHANGESET_UPDATED: "wiki.changeset.updated",
51752
- WIKI_DELETED: "wiki.deleted",
51753
- WIKI_RESTORED: "wiki.restored",
51754
- COMMENT_CREATED: "comment.created",
51755
- COMMENT_UPDATED: "comment.updated",
51756
- COMMENT_DELETED: "comment.deleted",
51757
- NOTIFICATION_ALERT: "notification.alert",
51758
- INBOX_NEW: "inbox.new",
51759
- INBOX_UPDATE: "inbox.update",
51760
- INBOX_BULK_UPDATE: "inbox.bulk_update",
51761
- READ_POSITION_UPDATED: "read_position.updated",
51762
- THREAD_READ_POSITION_UPDATED: "thread_read_position.updated",
51763
- DISPATCH_NEW: "dispatch.new",
51764
- DISPATCH_RECEIVED: "dispatch.received",
51765
- DISPATCH_RESOLVED: "dispatch.resolved",
51766
- SCHEDULE_CREATED: "schedule.created",
51767
- SCHEDULE_UPDATED: "schedule.updated",
51768
- SCHEDULE_DELETED: "schedule.deleted",
51769
- SCHEDULE_FIRED: "schedule.fired",
51770
- BILLING_BALANCE_UPDATED: "billing.balance_updated",
51771
- BILLING_LOW_BALANCE: "billing.low_balance",
51772
- BILLING_MACHINE_STOPPED: "billing.machine_stopped",
51773
- BILLING_INSUFFICIENT: "billing.insufficient",
51774
- USER_UPDATED: "user.updated",
51775
- MACHINE_HELLO: "machine.hello",
51776
- MACHINE_AGENT_ATTACHED: "machine.agent.attached",
51777
- MACHINE_AGENT_DETACHED: "machine.agent.detached",
51778
- MACHINE_STOP: "machine.stop",
51779
- MACHINE_WORKSPACE_SETUP_REQUESTED: "machine.workspace.setup.requested",
51780
- MACHINE_FILESYSTEM_BROWSE: "machine.filesystem.browse",
51781
- MACHINE_UPDATE: "machine.update",
51782
- MACHINE_CONFIG_UPDATED: "machine.config.updated",
51783
- MACHINE_AGENT_CONFIG_UPDATED: "machine.agent_config.updated",
51784
- MACHINE_CLIP_SYNC: "machine.clip.sync",
51785
- MACHINE_BROWSER_PROFILE_LIFECYCLE: "machine.browser_profile.lifecycle",
51786
- MACHINE_BROWSER_PROFILE_VIEWER: "machine.browser_profile.viewer",
51787
- AGENT_NEW_SESSION: "agent.new_session",
51788
- CLIP_CREATED: "clip.created",
51789
- CLIP_REMOVED: "clip.removed",
51790
- CLIP_UPDATED: "clip.updated"
52335
+
52336
+ // ../sdk/dist/task-label-client.js
52337
+ var TaskLabelClient = class extends ProjectTaskClient {
52338
+ async getLabels(orgId) {
52339
+ const response = await this.request("GET", ENDPOINTS.LABELS(orgId));
52340
+ return response.data;
52341
+ }
52342
+ async createLabel(orgId, data) {
52343
+ return this.request("POST", ENDPOINTS.LABELS(orgId), data);
52344
+ }
52345
+ async updateLabel(orgId, labelId, data) {
52346
+ return this.request("PATCH", ENDPOINTS.LABEL(orgId, labelId), data);
52347
+ }
52348
+ async deleteLabel(orgId, labelId) {
52349
+ return this.request("DELETE", ENDPOINTS.LABEL(orgId, labelId));
52350
+ }
52351
+ async addTaskLabels(orgId, taskId, data) {
52352
+ return this.request("POST", ENDPOINTS.TASK_LABELS(orgId, taskId), data);
52353
+ }
52354
+ async removeTaskLabel(orgId, taskId, labelId) {
52355
+ return this.request("DELETE", ENDPOINTS.TASK_LABEL(orgId, taskId, labelId));
52356
+ }
51791
52357
  };
51792
52358
 
51793
52359
  // ../sdk/dist/client.js
51794
- var ParallClient = class _ParallClient {
52360
+ var ParallClient = class _ParallClient extends TaskLabelClient {
51795
52361
  baseUrl;
51796
52362
  wikiBaseUrl;
51797
52363
  token;
@@ -51851,6 +52417,7 @@ var ParallClient = class _ParallClient {
51851
52417
  return headers;
51852
52418
  }
51853
52419
  constructor(options = {}) {
52420
+ super();
51854
52421
  this.baseUrl = options.baseUrl ?? "";
51855
52422
  this.wikiBaseUrl = options.wikiBaseUrl ?? this.baseUrl;
51856
52423
  this.token = options.token ?? null;
@@ -52148,6 +52715,44 @@ var ParallClient = class _ParallClient {
52148
52715
  const res = await this.request("GET", ENDPOINTS.TEAMS(orgId));
52149
52716
  return res.data;
52150
52717
  }
52718
+ async getTeam(orgId, teamId) {
52719
+ return this.request("GET", ENDPOINTS.TEAM(orgId, teamId));
52720
+ }
52721
+ /** Creating, renaming and deleting a team are org-admin actions. */
52722
+ async createTeam(orgId, req) {
52723
+ return this.request("POST", ENDPOINTS.TEAMS(orgId), req);
52724
+ }
52725
+ /**
52726
+ * Renames a team. The slug cannot be changed — wiki ACL rows reference it as
52727
+ * `@slug`, so the server answers 400 SLUG_IMMUTABLE if one is sent.
52728
+ */
52729
+ async updateTeam(orgId, teamId, req) {
52730
+ return this.request("PATCH", ENDPOINTS.TEAM(orgId, teamId), req);
52731
+ }
52732
+ async deleteTeam(orgId, teamId) {
52733
+ return this.request("DELETE", ENDPOINTS.TEAM(orgId, teamId));
52734
+ }
52735
+ /** Roster with display info; members who left the org are already excluded. */
52736
+ async getTeamMembers(orgId, teamId) {
52737
+ const res = await this.request("GET", ENDPOINTS.TEAM_MEMBERS(orgId, teamId));
52738
+ return res.data;
52739
+ }
52740
+ /**
52741
+ * Adds an org member (human or agent) to a team. Org admins and that team's
52742
+ * managers may add ordinary members; adding straight to `manager` is an
52743
+ * org-admin action.
52744
+ */
52745
+ async addTeamMember(orgId, teamId, req) {
52746
+ return this.request("POST", ENDPOINTS.TEAM_MEMBERS(orgId, teamId), req);
52747
+ }
52748
+ /** Appointing or demoting a manager is org-admin only. */
52749
+ async updateTeamMember(orgId, teamId, userId, req) {
52750
+ return this.request("PATCH", ENDPOINTS.TEAM_MEMBER(orgId, teamId, userId), req);
52751
+ }
52752
+ /** A team manager may remove ordinary members; removing a peer manager is org-admin only. */
52753
+ async removeTeamMember(orgId, teamId, userId) {
52754
+ return this.request("DELETE", ENDPOINTS.TEAM_MEMBER(orgId, teamId, userId));
52755
+ }
52151
52756
  async getOnlineMembers(orgId) {
52152
52757
  const res = await this.request("GET", ENDPOINTS.ORG_MEMBERS_ONLINE(orgId));
52153
52758
  return res.user_ids ?? [];
@@ -52924,143 +53529,32 @@ var ParallClient = class _ParallClient {
52924
53529
  /**
52925
53530
  * Fetch platform config for the authenticated agent.
52926
53531
  * Pass currentVersion to enable conditional fetch (If-None-Match / 304).
52927
- * Returns null when the server responds with 304 (config unchanged).
52928
- */
52929
- async getPlatformConfig(currentVersion) {
52930
- const url = `${this.baseUrlFor(ENDPOINTS.PLATFORM_CONFIG)}${ENDPOINTS.PLATFORM_CONFIG}`;
52931
- const extra = {};
52932
- if (currentVersion !== void 0) {
52933
- extra["If-None-Match"] = currentVersion;
52934
- }
52935
- const headers = this.buildHeaders(ENDPOINTS.PLATFORM_CONFIG, extra);
52936
- let res;
52937
- try {
52938
- res = await fetch(url, {
52939
- method: "GET",
52940
- headers,
52941
- signal: AbortSignal.timeout(15e3)
52942
- });
52943
- } catch (err) {
52944
- throw _ParallClient.normalizeFetchError(err);
52945
- }
52946
- if (res.status === 304)
52947
- return null;
52948
- if (!res.ok) {
52949
- const rawErrorBody = await res.json().catch(() => ({}));
52950
- throw buildApiError(res, rawErrorBody);
52951
- }
52952
- return res.json();
52953
- }
52954
- // ---- Tasks (org-scoped) ----
52955
- async createTask(orgId, data) {
52956
- return this.request("POST", ENDPOINTS.TASKS(orgId), data);
52957
- }
52958
- async getTasks(orgId, params) {
52959
- return this.request("GET", ENDPOINTS.TASKS(orgId), void 0, params);
52960
- }
52961
- async getTask(orgId, taskId) {
52962
- return this.request("GET", ENDPOINTS.TASK(orgId, taskId));
52963
- }
52964
- async updateTask(orgId, taskId, data) {
52965
- return this.request("PATCH", ENDPOINTS.TASK(orgId, taskId), data);
52966
- }
52967
- async deleteTask(orgId, taskId, opts) {
52968
- return this.request("DELETE", ENDPOINTS.TASK(orgId, taskId), void 0, opts?.force ? { force: "true" } : void 0);
52969
- }
52970
- async archiveTask(orgId, taskId) {
52971
- return this.request("POST", ENDPOINTS.TASK_ARCHIVE(orgId, taskId));
52972
- }
52973
- async restoreTask(orgId, taskId) {
52974
- return this.request("POST", ENDPOINTS.TASK_RESTORE(orgId, taskId));
52975
- }
52976
- async watchTask(orgId, taskId) {
52977
- return this.request("POST", ENDPOINTS.TASK_WATCH(orgId, taskId));
52978
- }
52979
- async unwatchTask(orgId, taskId) {
52980
- return this.request("DELETE", ENDPOINTS.TASK_WATCH(orgId, taskId));
52981
- }
52982
- async getTaskWatchers(orgId, taskId) {
52983
- const res = await this.request("GET", ENDPOINTS.TASK_WATCHERS(orgId, taskId));
52984
- return res.data;
52985
- }
52986
- async subscribeTaskMember(orgId, taskId, userId) {
52987
- return this.request("PUT", ENDPOINTS.TASK_SUBSCRIBER(orgId, taskId, userId));
52988
- }
52989
- async unsubscribeTaskMember(orgId, taskId, userId) {
52990
- return this.request("DELETE", ENDPOINTS.TASK_SUBSCRIBER(orgId, taskId, userId));
52991
- }
52992
- async watchThread(threadRootId) {
52993
- return this.request("POST", ENDPOINTS.MESSAGE_WATCH(threadRootId));
52994
- }
52995
- async unwatchThread(threadRootId) {
52996
- return this.request("DELETE", ENDPOINTS.MESSAGE_WATCH(threadRootId));
52997
- }
52998
- async getThreadWatchers(threadRootId) {
52999
- const res = await this.request("GET", ENDPOINTS.MESSAGE_WATCHERS(threadRootId));
53000
- return res.data;
53001
- }
53002
- async isWatchingThread(threadRootId) {
53003
- const res = await this.request("GET", ENDPOINTS.MESSAGE_WATCHING(threadRootId));
53004
- return res.watching;
53005
- }
53006
- async getSubtasks(orgId, taskId) {
53007
- const res = await this.request("GET", ENDPOINTS.TASK_SUBTASKS(orgId, taskId));
53008
- return res.data;
53009
- }
53010
- async createTaskRelation(orgId, taskId, data) {
53011
- return this.request("POST", ENDPOINTS.TASK_RELATIONS(orgId, taskId), data);
53012
- }
53013
- async getTaskRelations(orgId, taskId) {
53014
- const res = await this.request("GET", ENDPOINTS.TASK_RELATIONS(orgId, taskId));
53015
- return res.data;
53016
- }
53017
- async listTaskRelationsByTarget(orgId, params) {
53018
- const query = new URLSearchParams({
53019
- target_type: params.target_type,
53020
- target_id: params.target_id
53021
- });
53022
- const res = await this.request("GET", `${ENDPOINTS.TASK_RELATIONS_BY_TARGET(orgId)}?${query.toString()}`);
53023
- return res.data;
53024
- }
53025
- async deleteTaskRelation(orgId, taskId, relationId) {
53026
- return this.request("DELETE", ENDPOINTS.TASK_RELATION(orgId, taskId, relationId));
53027
- }
53028
- // ---- Task Comments ----
53029
- async getTaskComments(orgId, taskId, params) {
53030
- return this.request("GET", ENDPOINTS.TASK_COMMENTS(orgId, taskId), void 0, params);
53031
- }
53032
- async getTaskComment(orgId, taskId, commentId) {
53033
- return this.request("GET", ENDPOINTS.TASK_COMMENT(orgId, taskId, commentId));
53034
- }
53035
- async createTaskComment(orgId, taskId, data) {
53036
- return this.request("POST", ENDPOINTS.TASK_COMMENTS(orgId, taskId), data);
53037
- }
53038
- async updateTaskComment(orgId, taskId, commentId, data) {
53039
- return this.request("PATCH", ENDPOINTS.TASK_COMMENT(orgId, taskId, commentId), data);
53040
- }
53041
- async deleteTaskComment(orgId, taskId, commentId) {
53042
- return this.request("DELETE", ENDPOINTS.TASK_COMMENT(orgId, taskId, commentId));
53043
- }
53044
- // ---- Task Activities ----
53045
- async getTaskActivities(orgId, taskId, params) {
53046
- return this.request("GET", ENDPOINTS.TASK_ACTIVITIES(orgId, taskId), void 0, params);
53047
- }
53048
- // ---- Projects (org-scoped) ----
53049
- async createProject(orgId, data) {
53050
- return this.request("POST", ENDPOINTS.PROJECTS(orgId), data);
53051
- }
53052
- async getProjects(orgId) {
53053
- const res = await this.request("GET", ENDPOINTS.PROJECTS(orgId));
53054
- return res.data;
53055
- }
53056
- async getProject(orgId, projectId) {
53057
- return this.request("GET", ENDPOINTS.PROJECT(orgId, projectId));
53058
- }
53059
- async updateProject(orgId, projectId, data) {
53060
- return this.request("PATCH", ENDPOINTS.PROJECT(orgId, projectId), data);
53061
- }
53062
- async deleteProject(orgId, projectId) {
53063
- return this.request("DELETE", ENDPOINTS.PROJECT(orgId, projectId));
53532
+ * Returns null when the server responds with 304 (config unchanged).
53533
+ */
53534
+ async getPlatformConfig(currentVersion) {
53535
+ const url = `${this.baseUrlFor(ENDPOINTS.PLATFORM_CONFIG)}${ENDPOINTS.PLATFORM_CONFIG}`;
53536
+ const extra = {};
53537
+ if (currentVersion !== void 0) {
53538
+ extra["If-None-Match"] = currentVersion;
53539
+ }
53540
+ const headers = this.buildHeaders(ENDPOINTS.PLATFORM_CONFIG, extra);
53541
+ let res;
53542
+ try {
53543
+ res = await fetch(url, {
53544
+ method: "GET",
53545
+ headers,
53546
+ signal: AbortSignal.timeout(15e3)
53547
+ });
53548
+ } catch (err) {
53549
+ throw _ParallClient.normalizeFetchError(err);
53550
+ }
53551
+ if (res.status === 304)
53552
+ return null;
53553
+ if (!res.ok) {
53554
+ const rawErrorBody = await res.json().catch(() => ({}));
53555
+ throw buildApiError(res, rawErrorBody);
53556
+ }
53557
+ return res.json();
53064
53558
  }
53065
53559
  // ---- Schedules (org-scoped) ----
53066
53560
  async createSchedule(orgId, input) {
@@ -53199,12 +53693,26 @@ var ParallClient = class _ParallClient {
53199
53693
  }
53200
53694
  /**
53201
53695
  * WeChat tier-B read verb (agent-only; internal research preview): the
53202
- * account's address book — friend wxids, saved group room ids, followed
53203
- * official accounts. Same live gate as the send verb.
53696
+ * account's address book — friends/chatrooms enriched with display names,
53697
+ * followed official accounts. Same live gate as the send verb.
53204
53698
  */
53205
53699
  async listWechatContacts(orgId) {
53206
53700
  return this.request("GET", ENDPOINTS.WECHAT_CONTACTS(orgId));
53207
53701
  }
53702
+ /**
53703
+ * WeChat tier-B read verb (agent-only): the connected account's identity
53704
+ * (wxid / alias / nickName / app id).
53705
+ */
53706
+ async wechatProfile(orgId) {
53707
+ return this.request("GET", ENDPOINTS.WECHAT_PROFILE(orgId));
53708
+ }
53709
+ /**
53710
+ * WeChat tier-B read verb (agent-only): live online probe + identity +
53711
+ * the platform's offline record.
53712
+ */
53713
+ async wechatStatus(orgId) {
53714
+ return this.request("GET", ENDPOINTS.WECHAT_STATUS(orgId));
53715
+ }
53208
53716
  async listChannelConversations(orgId, connectionId) {
53209
53717
  return this.request("GET", ENDPOINTS.CHANNEL_CONNECTION_CONVERSATIONS(orgId, connectionId));
53210
53718
  }
@@ -53540,6 +54048,7 @@ var ParallClient = class _ParallClient {
53540
54048
  return this.request("PATCH", ENDPOINTS.NOTIFICATION_PREFERENCES, { prefs });
53541
54049
  }
53542
54050
  // ---- Feature Flags (org-scoped, server-evaluated) ----
54051
+ /** Omit orgId to resolve deployment capabilities before joining an org. */
53543
54052
  async getFeatureFlags(orgId) {
53544
54053
  return this.request("GET", ENDPOINTS.FEATURE_FLAGS(orgId));
53545
54054
  }
@@ -53556,6 +54065,44 @@ var ParallClient = class _ParallClient {
53556
54065
  timeoutMs: 185e3
53557
54066
  });
53558
54067
  }
54068
+ /** Queue a template deployment and poll its durable deployment row. Each
54069
+ * request is short-lived; closing the client does not cancel server work. */
54070
+ async deployTemplateAsync(orgId, request3, idempotencyKey) {
54071
+ const queue = () => this.request("POST", ENDPOINTS.TEMPLATE_DEPLOYMENTS(orgId), {
54072
+ ...request3,
54073
+ async: true,
54074
+ idempotency_key: idempotencyKey
54075
+ });
54076
+ let result;
54077
+ for (let attempt = 0; attempt < 2 && result === void 0; attempt += 1) {
54078
+ try {
54079
+ result = await queue();
54080
+ } catch (error) {
54081
+ if (!(error instanceof ApiError) || error.status !== 0 && error.status < 500)
54082
+ throw error;
54083
+ }
54084
+ }
54085
+ if (result === void 0) {
54086
+ throw new ApiError(0, "Template deployment request outcome is unknown", "NETWORK_ERROR");
54087
+ }
54088
+ const deadline = Date.now() + 30 * 60 * 1e3;
54089
+ while (result.status === "queued" || result.status === "deploying") {
54090
+ if (Date.now() >= deadline) {
54091
+ throw new ApiError(0, "Template deployment is still running", "REQUEST_TIMEOUT");
54092
+ }
54093
+ await new Promise((resolve3) => setTimeout(resolve3, 2e3));
54094
+ try {
54095
+ result = await this.request("GET", ENDPOINTS.TEMPLATE_DEPLOYMENT(orgId, result.deployment_id));
54096
+ } catch (error) {
54097
+ if (!(error instanceof ApiError) || error.status !== 0 && error.status < 500)
54098
+ throw error;
54099
+ }
54100
+ }
54101
+ if (result.status !== "deployed") {
54102
+ throw new ApiError(500, result.error?.message ?? "Template deployment failed", result.error?.code);
54103
+ }
54104
+ return result;
54105
+ }
53559
54106
  async getTemplateDeployment(orgId, deploymentId) {
53560
54107
  return this.request("GET", ENDPOINTS.TEMPLATE_DEPLOYMENT(orgId, deploymentId));
53561
54108
  }
@@ -53770,6 +54317,11 @@ var ParallClient = class _ParallClient {
53770
54317
  async uninstallRegistryClip(orgId, clipId) {
53771
54318
  await this.request("DELETE", ENDPOINTS.ORG_CLIP_UNINSTALL(orgId, clipId));
53772
54319
  }
54320
+ /** Best-effort provider revoke followed by atomic local removal of an
54321
+ * installed Official MCP Clip and all org-owned connection state. */
54322
+ async removeOfficialMCPClip(orgId, clipId) {
54323
+ return this.request("DELETE", ENDPOINTS.ORG_CLIP_MCP_REMOVE(orgId, clipId));
54324
+ }
53773
54325
  /** List the org's installed registry clips (full entries). */
53774
54326
  async listInstalledRegistryClips(orgId) {
53775
54327
  const resp = await this.request("GET", ENDPOINTS.ORG_CLIPS_INSTALLED(orgId));
@@ -53956,12 +54508,14 @@ var ParallClient = class _ParallClient {
53956
54508
  async deleteClipConnection(orgId, connId) {
53957
54509
  return this.request("DELETE", ENDPOINTS.CLIP_CONNECTION(orgId, connId));
53958
54510
  }
53959
- // ---- MCP clip server config (cap:clip-mcp; publisher-org only) ----
54511
+ // ---- MCP clip server config (same-org or reviewed Official OAuth) ----
53960
54512
  /**
53961
- * Read the redacted MCP config. 404 NOT_FOUND when the clip has none yet;
53962
- * 403 MCP_CROSS_ORG_DISABLED for a cross-org installed clip (the whole
53963
- * mcp-config family is publisher-org property, reads included). `version`
53964
- * is the CAS token the mutations echo via If-Match.
54513
+ * Read the redacted MCP config. 404 NOT_FOUND when the clip has none yet
54514
+ * and also when a cross-org clip is not public + approved + installed, which
54515
+ * reads as nonexistent rather than refused (same existence-hiding as exec).
54516
+ * A cross-org clip that IS installed and approved reads fine regardless of
54517
+ * auth shape; what may then be configured is decided per credential owner.
54518
+ * `version` is the CAS token the mutations echo via If-Match.
53965
54519
  */
53966
54520
  async getClipMCPConfig(orgId, clipId) {
53967
54521
  return this.request("GET", ENDPOINTS.ORG_CLIP_MCP_CONFIG(orgId, clipId));
@@ -53994,6 +54548,30 @@ var ParallClient = class _ParallClient {
53994
54548
  async deleteClipMCPConfig(orgId, clipId, expectedVersion) {
53995
54549
  return this.request("DELETE", ENDPOINTS.ORG_CLIP_MCP_CONFIG(orgId, clipId), void 0, void 0, false, { headers: { "If-Match": `"${expectedVersion}"` } });
53996
54550
  }
54551
+ /**
54552
+ * List the org's MCP connections for a clip, default first — one row per
54553
+ * connection (credential slot), WITHOUT the tools snapshot (`tool_count`
54554
+ * summarizes it; the per-config GET carries the full snapshot). Same
54555
+ * family-wide fence as the singular GET: same-org clips, or a cross-org clip
54556
+ * that is public + approved + installed; anything else reads as
54557
+ * `404 NOT_FOUND`. An installed cross-org clip with no connection yet lists
54558
+ * as an empty array — including one whose approved auth mode cannot be
54559
+ * configured at all (auth=none), which the write path is what refuses. With
54560
+ * `cap:clip-mcp` off the route is not registered at all.
54561
+ */
54562
+ async listClipMCPConnections(orgId, clipId) {
54563
+ return this.request("GET", ENDPOINTS.ORG_CLIP_MCP_CONFIGS(orgId, clipId));
54564
+ }
54565
+ /** Start a new Official OAuth MCP connection with the platform-owned app.
54566
+ * Omitting oauth_client is load-bearing: the server resolves the exact
54567
+ * reviewed-version binding and never falls back to DCR/CIMD cross-org. */
54568
+ async createClipMCPOAuthConnection(orgId, clipId, serverUrl, alias) {
54569
+ return this.request("POST", ENDPOINTS.ORG_CLIP_MCP_CONFIGS(orgId, clipId), {
54570
+ server_url: serverUrl,
54571
+ auth_type: "oauth",
54572
+ ...alias ? { alias } : {}
54573
+ });
54574
+ }
53997
54575
  /**
53998
54576
  * Re-run tools/list and replace the cached snapshot (org-admin only).
53999
54577
  * Deliberately does NOT advance the CAS version, so an in-flight edit in
@@ -54415,211 +54993,23 @@ var ParallWs = class {
54415
54993
  }
54416
54994
  };
54417
54995
 
54418
- // ../agent-core/dist/event-format.js
54419
- function sanitizeMeta(value) {
54420
- return value.replace(/[\r\n]+/g, " ").replace(/[[\]|]/g, " ").trim();
54421
- }
54422
- function buildEventBody(event) {
54423
- const lines = [];
54424
- if (event.type === "message") {
54425
- lines.push(`[Event: message.new]`);
54426
- const chatLabel = event.targetName ? `"${event.targetName}" (prll://${event.targetId})` : `prll://${event.targetId}`;
54427
- lines.push(`[Chat: ${chatLabel} | type: ${event.targetType ?? "unknown"}]`);
54428
- lines.push(`[From: ${event.senderName} (prll://${event.senderId})]`);
54429
- lines.push(`[Message ID: prll://${event.messageId}]`);
54430
- if (event.threadRootId) {
54431
- const threadMeta = [
54432
- `prll://${event.threadRootId}`,
54433
- event.threadReplyCount != null ? `${event.threadReplyCount} replies` : null,
54434
- event.threadUnreadCount != null && event.threadUnreadCount > 0 ? `${event.threadUnreadCount} unread` : null,
54435
- event.threadUnreadCount != null && event.threadUnreadCount > 0 && event.threadUnreadSince ? `since: prll://${event.threadUnreadSince}` : null
54436
- ].filter(Boolean).join(" | ");
54437
- lines.push(`[Thread: ${threadMeta}]`);
54438
- }
54439
- if (event.unreadCount != null && event.unreadCount > 1) {
54440
- const countStr = event.unreadCount >= 1e3 ? "999+" : String(event.unreadCount);
54441
- const sinceStr = event.unreadSince ? ` | since: prll://${event.unreadSince}` : "";
54442
- let line = `[Unread: ${countStr} messages${sinceStr}]`;
54443
- if (event.unreadCount > 50)
54444
- line += ` \u2014 fetch recent context with --limit, not all`;
54445
- lines.push(line);
54446
- }
54447
- if (event.noReply)
54448
- lines.push(`[Hint: no_reply]`);
54449
- if (event.attachments?.length) {
54450
- for (const att of event.attachments) {
54451
- const sizeStr = att.fileSize >= 1048576 ? `${(att.fileSize / 1048576).toFixed(1)}MB` : `${Math.round(att.fileSize / 1024)}KB`;
54452
- lines.push(`[Attachment: prll://${att.id} | ${sanitizeMeta(att.mimeType)} | ${sizeStr} | ${sanitizeMeta(att.fileName)}]`);
54453
- }
54454
- }
54455
- lines.push("", event.body);
54456
- } else if (event.type === "task_comment") {
54457
- lines.push(`[Event: task.comment.created]`);
54458
- const taskLabel = event.targetName ? `${event.targetName} (prll://${event.targetId})` : `prll://${event.targetId}`;
54459
- lines.push(`[Task: ${taskLabel}]`);
54460
- if (event.deliveryReason)
54461
- lines.push(`[Delivery: ${sanitizeMeta(event.deliveryReason)}]`);
54462
- lines.push(`[From: ${event.senderName} (prll://${event.senderId})]`);
54463
- lines.push(`[Comment ID: prll://${event.messageId}]`);
54464
- lines.push("", event.body);
54465
- } else if (event.type === "wiki_comment") {
54466
- lines.push(`[Event: wiki.comment.created]`);
54467
- const target = event.replyTargetUri ?? `prll://${event.targetId}`;
54468
- if (event.targetType === "changeset") {
54469
- lines.push(`[Wiki Changeset: ${target}]`);
54470
- } else {
54471
- lines.push(`[Wiki: ${event.targetName ? `${sanitizeMeta(event.targetName)} (${target})` : target}]`);
54472
- }
54473
- if (event.deliveryReason)
54474
- lines.push(`[Delivery: ${sanitizeMeta(event.deliveryReason)}]`);
54475
- lines.push(`[From: ${event.senderName} (prll://${event.senderId})]`);
54476
- lines.push(`[Comment ID: prll://${event.messageId}]`);
54477
- lines.push("", event.body);
54478
- } else if (event.type === "approval") {
54479
- lines.push(`[Event: approval.decided]`);
54480
- lines.push(`[Approval: prll://${event.messageId}]`);
54481
- lines.push(`[Chat: prll://${event.targetId}]`);
54482
- lines.push(`[Decided by: ${event.senderName} (prll://${event.senderId})]`);
54483
- lines.push("", event.body);
54484
- } else if (event.type === "schedule") {
54485
- lines.push(`[Event: schedule.fired]`);
54486
- lines.push(`[Schedule: prll://${event.targetId}]`);
54487
- lines.push(`[Run: prll://${event.messageId}]`);
54488
- if (event.scheduledFireAt)
54489
- lines.push(`[Scheduled at: ${sanitizeMeta(event.scheduledFireAt)}]`);
54490
- if (event.attachedUri)
54491
- lines.push(`[Attached: ${sanitizeMeta(event.attachedUri)}]`);
54492
- lines.push("", event.body);
54493
- } else if (event.type === "channel_message") {
54494
- lines.push(`[Event: channel.message]`);
54495
- const providerLabel = sanitizeMeta(event.channelProvider ?? "external IM");
54496
- const convLabel = event.channelExternalConversationId ? `${sanitizeMeta(event.channelExternalConversationId)} (${sanitizeMeta(event.channelConversationType ?? "conversation")})` : sanitizeMeta(event.channelConversationType ?? "conversation");
54497
- lines.push(`[Channel: ${providerLabel} | conversation: ${convLabel}]`);
54498
- lines.push(`[From: ${sanitizeMeta(event.senderName)} (external user, not a Parall member)]`);
54499
- if (event.channelExternalMessageId) {
54500
- lines.push(`[External message ID: ${sanitizeMeta(event.channelExternalMessageId)}]`);
54501
- }
54502
- lines.push(`[Audience: this conversation lives on ${providerLabel}, OUTSIDE Parall. Readers cannot open prll:// links, Parall cards, or internal attachments \u2014 never include them in replies. Write plain conversational text.]`);
54503
- lines.push("", event.body);
54504
- } else if (event.type === "external_trigger") {
54505
- lines.push(`[Event: external.trigger]`);
54506
- lines.push(`[Trigger: prll://${event.targetId}]`);
54507
- lines.push(`[Run: prll://${event.messageId}]`);
54508
- if (event.externalConnectionId) {
54509
- const label = event.externalConnectionDisplayName ? `${sanitizeMeta(event.externalConnectionDisplayName)} (prll://${event.externalConnectionId})` : `prll://${event.externalConnectionId}`;
54510
- lines.push(`[Connection: ${label}]`);
54511
- }
54512
- if (event.externalIngressEventId)
54513
- lines.push(`[Ingress: prll://${event.externalIngressEventId}]`);
54514
- if (event.attachedUri)
54515
- lines.push(`[Attached: ${sanitizeMeta(event.attachedUri)}]`);
54516
- if (event.externalConnectionSourceType) {
54517
- lines.push(`[Source: ${sanitizeMeta(event.externalConnectionSourceType)}]`);
54518
- }
54519
- if (event.externalIngressEventType) {
54520
- lines.push(`[External event: ${sanitizeMeta(event.externalIngressEventType)}]`);
54521
- }
54522
- lines.push("", event.body);
54523
- } else {
54524
- lines.push(`[Event: task.assigned]`);
54525
- const taskLabel = event.targetName ? `${event.targetName} (prll://${event.targetId})` : `prll://${event.targetId}`;
54526
- lines.push(`[Task: ${taskLabel}]`);
54527
- lines.push(`[Assigned by: ${event.senderName} (prll://${event.senderId})]`);
54528
- lines.push("", event.body);
54529
- }
54530
- return lines.join("\n") + buildSendMessageHint(event);
54531
- }
54532
- function buildEventBodyForForkResult(event) {
54533
- return buildEventBody(event).replace(/\n<system-reminder>[\s\S]*<\/system-reminder>$/, "");
54534
- }
54535
- function buildSendMessageHint(event) {
54536
- if (event.noReply)
54537
- return "";
54538
- if (event.type === "wiki_comment" && event.replyTargetUri) {
54539
- const where = event.targetType === "changeset" ? "this changeset comment" : "this wiki page";
54540
- return `
54541
- <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>`;
54542
- }
54543
- if (event.targetId.startsWith("cht_")) {
54544
- if (event.threadRootId) {
54545
- return `
54546
- <system-reminder>To reply in this thread, run \`parall messages send prll://${event.targetId} --thread-root-id ${sanitizeMeta(event.threadRootId)} --text-file - <<'EOF'\` \u2026 \`EOF\` \u2014 the quoted heredoc keeps \`$\`, backticks and apostrophes literal (plain \`--text "$1,000"\` sends \`,000\`). Your plain text output is not delivered to the chat.</system-reminder>`;
54547
- }
54548
- return `
54549
- <system-reminder>To reply, run \`parall messages send prll://${event.targetId} --text-file - <<'EOF'\` \u2026 \`EOF\` \u2014 the quoted heredoc keeps \`$\`, backticks and apostrophes literal (plain \`--text "$1,000"\` sends \`,000\`). Your plain text output is not delivered to the chat.</system-reminder>`;
54550
- }
54551
- if (event.targetId.startsWith("tsk_")) {
54552
- return `
54553
- <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>`;
54554
- }
54555
- if (event.targetId.startsWith("sch_")) {
54556
- return `
54557
- <system-reminder>To communicate, use the CLI: \`parall messages send\` / \`parall dm\`. Your plain text output is not delivered.</system-reminder>`;
54558
- }
54559
- if (event.type === "channel_message") {
54560
- if (event.channelCliCapable) {
54561
- if (event.channelProvider === "slack") {
54562
- const channelArg = event.channelExternalConversationId ? ` --channel "${event.channelExternalConversationId}"` : " --channel <conversation id from this event>";
54563
- const replyTo = event.channelExternalMessageId ? ` --reply-to "${event.channelExternalMessageId}"` : "";
54564
- return `
54565
- <system-reminder>To reply, use the platform verb: \`parall slack send${channelArg}${replyTo} --text <your reply>\`. In channels --reply-to is REQUIRED (the reply lands in that message's thread); in DMs it is optional (DMs are linear). \`parall slack send\` is the ONLY outbound path \u2014 your plain text output is NOT delivered to the external conversation.</system-reminder>`;
54566
- }
54567
- if (event.channelProvider === "wechat") {
54568
- const toArg = event.channelExternalConversationId ? ` --to "${event.channelExternalConversationId}"` : " --to <wxid from this event>";
54569
- const atArg = event.channelConversationType === "group" ? event.senderId && event.senderId !== "external" ? ` --at "${event.senderId}"` : " --at <wxid of the person you are answering>" : "";
54570
- return `
54571
- <system-reminder>To reply, use the platform verb: \`parall wechat send${toArg}${atArg} --text <your reply>\`. In group chats, --at @-mentions the person you are answering. \`parall wechat send\` is the ONLY outbound path \u2014 your plain text output is NOT delivered to the external conversation.</system-reminder>`;
54572
- }
54573
- if (!event.channelProvider) {
54574
- return `
54575
- <system-reminder>To reply, use the channel capability granted in your system prompt \u2014 for Feishu conversations that is \`lark-cli im\`, for Slack it is \`parall slack send\` (pass the message id from this event as --reply-to), for WeChat it is \`parall wechat send\`. That capability is the ONLY outbound path \u2014 your plain text output is NOT delivered to the external conversation.</system-reminder>`;
54576
- }
54577
- const convRef = event.channelExternalConversationId ? `chat_id "${event.channelExternalConversationId}"` : "the conversation id named in this event";
54578
- const threadAlt = event.channelExternalMessageId ? ` To reply threaded to this specific message, reference message_id "${event.channelExternalMessageId}".` : "";
54579
- return `
54580
- <system-reminder>To reply, use the official Feishu CLI on your PATH: send a message to ${convRef} with \`lark-cli im\` (see \`lark-cli im --help\` for send syntax; auth is provisioned automatically).${threadAlt} lark-cli is the ONLY outbound path \u2014 your plain text output is NOT delivered to the external conversation.</system-reminder>`;
54581
- }
54582
- const platform = event.channelProvider ?? "the external platform";
54583
- return `
54584
- <system-reminder>This message arrived from ${platform}, but outbound replies are currently disabled for this org (no channel capability granted). Do NOT attempt to reply on the external platform. If action is needed, surface it inside Parall (\`parall messages send\` / \`parall dm\`). Your plain text output is not delivered anywhere.</system-reminder>`;
54585
- }
54586
- if (event.type === "external_trigger" || event.targetId.startsWith("xtr_")) {
54587
- return `
54588
- <system-reminder>This external trigger is incoming-only. Your plain text output is not sent back to the external provider. To communicate in Parall, use \`parall messages send\` / \`parall dm\`; provider-specific outbound actions require a separate capability.</system-reminder>`;
54589
- }
54590
- return "";
54591
- }
54592
- function buildForkScopePrefix(event) {
54593
- const targetLabel = event.targetName ? `"${event.targetName}" (prll://${event.targetId})` : `prll://${event.targetId}`;
54594
- return `[Fork scope: You are a parallel worker forked from the main session to handle ${targetLabel}. The conversation history above belongs to the main session's in-progress dispatch \u2014 do NOT continue it or complete it, or produce external output (comments, messages) for work visible there. The main session owns its own output.
54595
-
54596
- Only act on the event below within your target scope. If your event reveals findings about the main session's work, report them in your summary \u2014 do not post them externally.
54597
-
54598
- End with a brief "Fork summary" of actions taken and decisions made.]
54996
+ // ../agent-core/dist/lane-ledger.js
54997
+ import * as fs2 from "node:fs";
54599
54998
 
54600
- `;
54999
+ // ../agent-core/dist/lane-key.js
55000
+ import * as path2 from "node:path";
55001
+ function laneKeyForTarget(targetUri, threadRootId) {
55002
+ return Buffer.from(`${targetUri}
55003
+ ${threadRootId ?? ""}`, "utf8").toString("base64url");
54601
55004
  }
54602
- function buildForkResultPrefix(results) {
54603
- if (!results.length)
54604
- return "";
54605
- const blocks = results.map((result) => {
54606
- const lines = [];
54607
- for (const body of result.eventBodies) {
54608
- lines.push(body);
54609
- }
54610
- lines.push(`[This event was handled by a parallel fork session. Do NOT re-handle, re-reply, or duplicate work for it.]`);
54611
- lines.push(`[Fork summary: ${result.agentSummary ? sanitizeMeta(result.agentSummary) : "No fork summary available \u2014 the fork completed without producing a text summary. Check the target chat/task for any actions the fork already took before acting."}]`);
54612
- if (result.actions.length)
54613
- lines.push(`[Fork actions: ${result.actions.join("; ")}]`);
54614
- if (result.historyPath)
54615
- lines.push(`[Fork history: ${result.historyPath}]`);
54616
- return lines.join("\n");
54617
- });
54618
- return blocks.join("\n\n") + "\n\n---\n\n";
55005
+ function dispatchLaneContextDir(stateDir) {
55006
+ return path2.join(stateDir, "dispatch-lane-context");
55007
+ }
55008
+ function laneContextFilePath(contextDir, targetUri, threadRootId) {
55009
+ return path2.join(contextDir, `${laneKeyForTarget(targetUri, threadRootId)}.json`);
54619
55010
  }
54620
55011
 
54621
55012
  // ../agent-core/dist/lane-ledger.js
54622
- import * as fs from "node:fs";
54623
55013
  var LedgerUnsupportedError = class extends Error {
54624
55014
  };
54625
55015
  function bindLaneSession(lane, agentSessionId) {
@@ -55043,7 +55433,7 @@ var LaneLedger = class {
55043
55433
  const contextPath = this.laneContextPath(lane);
55044
55434
  for (const p of [contextPath, contextPath.replace(/\.json$/, ".reply-state.json")]) {
55045
55435
  try {
55046
- fs.rmSync(p, { force: true });
55436
+ fs2.rmSync(p, { force: true });
55047
55437
  } catch {
55048
55438
  }
55049
55439
  }
@@ -55393,531 +55783,38 @@ async function consumeMessageWorkItem(host, item) {
55393
55783
  try {
55394
55784
  const dispatched = await host.handleInboundEvent(decision.event);
55395
55785
  if (dispatched) {
55396
- if (!laneResolved)
55397
- ackItem();
55398
- } else {
55399
- host.dispatchedMessages.delete(item.source_id);
55400
- }
55401
- } catch (err) {
55402
- host.dispatchedMessages.delete(item.source_id);
55403
- throw err;
55404
- }
55405
- }
55406
-
55407
- // ../agent-core/dist/session-state.js
55408
- function normalizeSessionKey(sessionKey) {
55409
- return sessionKey.toLowerCase();
55410
- }
55411
- var sessionChatIdMap = /* @__PURE__ */ new Map();
55412
- var sessionMessageIdMap = /* @__PURE__ */ new Map();
55413
- var dispatchMessageIdMap = /* @__PURE__ */ new Map();
55414
- var dispatchGroupKeyMap = /* @__PURE__ */ new Map();
55415
- var dispatchNoReplyMap = /* @__PURE__ */ new Map();
55416
- function setSessionChatId(sessionKey, chatId) {
55417
- sessionChatIdMap.set(normalizeSessionKey(sessionKey), chatId);
55418
- }
55419
- function getSessionChatId(sessionKey) {
55420
- return sessionChatIdMap.get(normalizeSessionKey(sessionKey));
55421
- }
55422
- function setSessionMessageId(sessionKey, messageId) {
55423
- sessionMessageIdMap.set(normalizeSessionKey(sessionKey), messageId);
55424
- }
55425
- function clearSessionMessageId(sessionKey) {
55426
- sessionMessageIdMap.delete(normalizeSessionKey(sessionKey));
55427
- }
55428
- function setDispatchMessageId(sessionKey, messageId) {
55429
- dispatchMessageIdMap.set(normalizeSessionKey(sessionKey), messageId);
55430
- }
55431
- function getDispatchMessageId(sessionKey) {
55432
- return dispatchMessageIdMap.get(normalizeSessionKey(sessionKey));
55433
- }
55434
- function clearDispatchMessageId(sessionKey) {
55435
- dispatchMessageIdMap.delete(normalizeSessionKey(sessionKey));
55436
- }
55437
- function setDispatchGroupKey(sessionKey, groupKey) {
55438
- dispatchGroupKeyMap.set(normalizeSessionKey(sessionKey), groupKey);
55439
- }
55440
- function getDispatchGroupKey(sessionKey) {
55441
- return dispatchGroupKeyMap.get(normalizeSessionKey(sessionKey));
55442
- }
55443
- function clearDispatchGroupKey(sessionKey) {
55444
- dispatchGroupKeyMap.delete(normalizeSessionKey(sessionKey));
55445
- }
55446
- function setDispatchNoReply(sessionKey, noReply) {
55447
- dispatchNoReplyMap.set(normalizeSessionKey(sessionKey), noReply);
55448
- }
55449
- function clearDispatchNoReply(sessionKey) {
55450
- dispatchNoReplyMap.delete(normalizeSessionKey(sessionKey));
55451
- }
55452
- var dispatchMetricsMap = /* @__PURE__ */ new Map();
55453
- function resetDispatchMetrics(sessionKey) {
55454
- dispatchMetricsMap.set(normalizeSessionKey(sessionKey), {
55455
- deliver_text_chunks: 0,
55456
- deliver_text_chars: 0,
55457
- message_send_attempts: 0,
55458
- message_send_successes: 0,
55459
- no_reply_called: false,
55460
- tool_call_count: 0,
55461
- started_at: Date.now()
55462
- });
55463
- }
55464
- function getDispatchMetrics(sessionKey) {
55465
- return dispatchMetricsMap.get(normalizeSessionKey(sessionKey));
55466
- }
55467
- function clearDispatchMetrics(sessionKey) {
55468
- dispatchMetricsMap.delete(normalizeSessionKey(sessionKey));
55469
- }
55470
- function recordDeliverText(sessionKey, charCount) {
55471
- const m = dispatchMetricsMap.get(normalizeSessionKey(sessionKey));
55472
- if (!m)
55473
- return;
55474
- m.deliver_text_chunks++;
55475
- m.deliver_text_chars += charCount;
55476
- }
55477
- function recordMessageSend(sessionKey, success) {
55478
- const m = dispatchMetricsMap.get(normalizeSessionKey(sessionKey));
55479
- if (!m)
55480
- return;
55481
- m.message_send_attempts++;
55482
- if (success)
55483
- m.message_send_successes++;
55484
- }
55485
- function recordNoReply(sessionKey) {
55486
- const m = dispatchMetricsMap.get(normalizeSessionKey(sessionKey));
55487
- if (!m)
55488
- return;
55489
- m.no_reply_called = true;
55490
- }
55491
- function recordToolCall(sessionKey) {
55492
- const m = dispatchMetricsMap.get(normalizeSessionKey(sessionKey));
55493
- if (!m)
55494
- return;
55495
- m.tool_call_count++;
55496
- }
55497
-
55498
- // ../agent-core/dist/routing.js
55499
- var MAX_CONCURRENT_FORKS = 20;
55500
- var defaultRoutingStrategy = (event, state) => {
55501
- if (state.mainCurrentTargetId === event.targetId) {
55502
- return { action: "buffer-main" };
55503
- }
55504
- const existingForkKey = state.activeForks.get(event.targetId);
55505
- if (existingForkKey)
55506
- return { action: "buffer-fork", forkKey: existingForkKey };
55507
- if (state.activeForks.size >= MAX_CONCURRENT_FORKS) {
55508
- return { action: "buffer-main" };
55509
- }
55510
- return { action: "new-fork" };
55511
- };
55512
- function routeTrigger(event, state, strategy = defaultRoutingStrategy) {
55513
- const existingForkKey = state.activeForks.get(event.targetId);
55514
- if (existingForkKey)
55515
- return { action: "buffer-fork", forkKey: existingForkKey };
55516
- if (!state.mainDispatching)
55517
- return { action: "main" };
55518
- return strategy(event, state);
55519
- }
55520
-
55521
- // ../agent-core/dist/prompt-fragments.js
55522
- function identityFromMe(me) {
55523
- return {
55524
- userId: me.id,
55525
- displayName: me.display_name,
55526
- title: me.public_profile?.title || void 0,
55527
- publicDescription: me.public_profile?.description || void 0,
55528
- // `||` on purpose: an empty-string instructions must also fall back to
55529
- // the deprecated description alias (empty means "unset" on this wire).
55530
- instructions: me.agent_profile?.instructions || me.agent_profile?.description || void 0
55531
- };
55532
- }
55533
- var PRLL_IDENTITY_BASE = `## You on Parall
55534
-
55535
- Parall is a shared workspace where humans and agents work side by side as equals.
55536
- You are a participant here, not a service. You hold tasks, own decisions, and are
55537
- accountable for the work you take on \u2014 the same way a human teammate is.
55538
-
55539
- The people and agents around you are collaborators, not users to serve. Be honest,
55540
- be direct, and care about the outcome of the work \u2014 not just the request in front
55541
- of you.`;
55542
- function sanitizeProfileField(value) {
55543
- return value.replace(/[\r\n]+/g, " ").replace(/`/g, "'").trim();
55544
- }
55545
- function sanitizeProfileBlock(value) {
55546
- return value.replace(/\r\n?/g, "\n").trim();
55547
- }
55548
- function buildIdentity(agent) {
55549
- if (!agent)
55550
- return PRLL_IDENTITY_BASE;
55551
- const name = sanitizeProfileField(agent.displayName);
55552
- const lines = [PRLL_IDENTITY_BASE, "", "### Your Parall Identity", ""];
55553
- lines.push(`You are **${name}** (\`prll://${agent.userId}\`).`);
55554
- const title = agent.title ? sanitizeProfileField(agent.title) : "";
55555
- if (title)
55556
- lines.push(`Title: ${title}`);
55557
- const about = agent.publicDescription ? sanitizeProfileField(agent.publicDescription) : "";
55558
- if (about)
55559
- lines.push(`About: ${about}`);
55560
- const instructions = sanitizeProfileBlock(agent.instructions ?? agent.description ?? "");
55561
- if (instructions) {
55562
- lines.push("", "### Private instructions from your organization admins", "", instructions);
55563
- }
55564
- lines.push("", `When you see \`${agent.userId}\` or \`prll://${agent.userId}\` in messages, mentions, or events \u2014 that's you.`);
55565
- return lines.join("\n");
55566
- }
55567
- var PRLL_BEHAVIOR = `## How to work here
55568
-
55569
- ### Move work forward
55570
- Don't wait for instructions. If you see the next step, take it. If something is
55571
- ambiguous, clarify once and proceed. If you're blocked, say what's blocking you
55572
- \u2014 don't go silent. Initiative is expected.
55573
-
55574
- Use schedules as self-reminders \u2014 re-checking blocked work, chasing unanswered
55575
- requests, verifying something landed. When a thing needs future attention and
55576
- nothing will prompt it, schedule it (load the \`parall-schedules\` skill).
55577
-
55578
- ### Work in the open
55579
- Nothing you do exists until the system can see it. Your progress, decisions,
55580
- blockers, and results need to live in tasks, comments, messages, or wiki pages
55581
- \u2014 otherwise the organization is blind to your work, and so is the next agent
55582
- who picks up where you left off. Leave traces as you go, not at the end.
55583
-
55584
- For non-trivial work: create or claim a task, mark it \`in_progress\`, comment
55585
- when status materially changes, close it when done, and link the origin that
55586
- triggered it. Decompose multi-step work into subtasks and keep their statuses
55587
- current \u2014 progress should be auditable without watching the work happen.
55588
- Details: load the \`parall-tasks\` skill.
55589
-
55590
- ### Done means landed
55591
- Producing output does not complete a task. Work counts as done only when it has
55592
- cleared its remaining gates \u2014 review, merge, deployment, the requester's
55593
- verification. Until then keep the status honest (\`in_progress\` or
55594
- \`in_review\`), name the remaining gate in a comment, and chase it (schedule a
55595
- self-reminder if nothing else will prompt follow-up). Never mark done what a
55596
- human still has to accept.
55597
-
55598
- ### Sessions, forks, and what survives
55599
- Sessions end and context compacts. Anything that must survive \u2014 decisions,
55600
- progress, constraints \u2014 belongs in tasks, comments, or wiki. Future sessions
55601
- read the workspace, not this conversation.
55602
-
55603
- Some events are handled by parallel fork sessions \u2014 short-lived copies of the
55604
- same agent identity with separate context. In a fork: leave a written trace of
55605
- what was done or deliberately not done (other sessions cannot see fork
55606
- context), and do not start long-running processes \u2014 they die with the fork.
55607
- When an event is marked fork-handled: do not re-handle it; verify its outcome
55608
- instead of assuming it.
55609
-
55610
- ### Communicate like a teammate
55611
- Match the conversation \u2014 concise in chat, thorough in docs, plain language over
55612
- jargon. Say what matters; stop when you're done. Don't narrate every tool call
55613
- or pad replies to seem thorough.
55614
-
55615
- Match the language of the person you're replying to. If someone writes in
55616
- Chinese, reply in Chinese. If in English, reply in English. Never force a
55617
- language switch unless explicitly asked.
55618
-
55619
- Do not promise delivery times ("in an hour", "by tonight") unless the work is
55620
- driven by an explicit schedule. Scope visibly; report when actually done.
55621
-
55622
- ### Keep topics in threads
55623
- Check for a \`[Thread: prll://msg_xxx]\` line before interpreting a message.
55624
- Present \u2192 that thread is the context; reply there, passing the same root as
55625
- \`--thread-root-id\`. Absent \u2192 the message belongs to the main conversation:
55626
- never treat it as continuing your most recent thread. The sender's newest
55627
- message is the anchor \u2014 never route a reply back into an older thread just
55628
- because the topic used to live there.
55629
-
55630
- Reply where the event lives: a thread message gets a thread reply, a
55631
- top-level message gets a top-level reply. But in group chats, your later
55632
- follow-up on that topic \u2014 progress updates, analysis, links, verification you
55633
- post afterwards \u2014 belongs in a thread rooted at the topic's message
55634
- (\`parall messages send <chat> --thread-root-id <msgId> --text-file -\`), so
55635
- the main channel stays scannable. Post follow-up at top level only when
55636
- starting a genuinely new topic, making a channel-wide announcement, or when
55637
- explicitly asked. Never post the same update in both the thread and the main
55638
- channel \u2014 thread replies surface in the thread panel; no need to duplicate
55639
- for visibility.
55640
-
55641
- In DMs, reply top-level by default; use a thread only to continue one that
55642
- already exists.
55643
-
55644
- ### Group chats: mentions and unaddressed work
55645
- An @mention is a direct request \u2014 act on it. A group message delivered to you
55646
- without an @mention means the chat's routing lets you see the conversation:
55647
- decide whether a reply adds value; silence is the default.
55648
-
55649
- A message without an @mention is not an open invitation. Judge from context
55650
- who the work belongs to \u2014 the named domain, the topic's owner, whoever is
55651
- already on it. If it belongs to someone else, leave it. If genuinely unclear,
55652
- ask or claim in one line ("taking this unless someone else has it") before
55653
- starting \u2014 asking first beats duplicated or misdirected work.
55654
-
55655
- ### Verify before you act
55656
- Events can be redelivered \u2014 before acting, check whether it was already
55657
- handled (your own recent replies, task comments); if handled, do nothing.
55658
- Sends can fail silently, and creates can error after succeeding server-side \u2014
55659
- check the chat or entity before retrying. Never blind-retry a mutating call.
55660
-
55661
- ### Gather the full picture first
55662
- When a request is vague, an entity may already exist, or work may already be
55663
- underway \u2014 gather context before acting: search (\`parall search "..."\`),
55664
- check existing tasks/chats/wiki, read the surrounding conversation. Act on the
55665
- full picture, not the fragment that arrived in the event.
55666
-
55667
- ### Report only work that ran
55668
- If a scheduled job, scan, or tool call did not actually run \u2014 restarted
55669
- session, missing credentials, silent failure \u2014 say so plainly. Never fabricate
55670
- or approximate results of work that did not execute.
55671
-
55672
- ### Respect what's shared
55673
- You have broad latitude inside your own work. But actions that are visible to
55674
- others, hard to reverse, or touch shared state \u2014 sending DMs, editing shared
55675
- wiki, reassigning others' tasks, deleting content \u2014 pause and confirm before
55676
- acting, unless you've been explicitly authorized.
55677
-
55678
- ### Shared workspace
55679
- Other agents share this workspace. Before starting work, check whether someone
55680
- \u2014 human or agent \u2014 has already picked it up. Coordination beats racing.
55681
-
55682
- ### Permissions and approvals
55683
- You have real permissions based on your roles (chat member/admin, org member).
55684
- If you lack permission for an action, the API returns PERMISSION_DENIED with the
55685
- \`action\` and \`resource_uri\` that were denied. The server decides whether that
55686
- action is approvable: if it is, the CLI prints an \`approvals request\` command \u2014
55687
- fill in the placeholders it shows (\`--chat\`, \`--title\`, \`--reason\`) and run
55688
- it to ask someone with permission. If it is NOT approvable, the output says so;
55689
- ask a human with permission instead of requesting approval. A
55690
- \`INVALID_TARGET\` error instead means you addressed the wrong kind of thing
55691
- (e.g. a \`usr_\` id where a chat is expected) \u2014 follow the message (e.g. use
55692
- \`dm\` for a user). Don't retry or work around a denial; only request approval
55693
- after an actual denial, never preemptively.
55694
-
55695
- ### When in doubt
55696
- Prefer asking over guessing. Prefer "I don't know" over fabricating. Your
55697
- credibility is what you bring to the workspace \u2014 protect it.`;
55698
- var PRLL_REFERENCE_GUIDE = `## Parall References
55699
-
55700
- Every entity on Parall has a \`prll://\` URI. Use these URIs to link related
55701
- entities when you create or update tasks, comments, messages, and wiki files.
55702
-
55703
- All three forms work \u2014 pick whichever fits:
55704
-
55705
- prll://tsk_abc bare URI (auto-linked)
55706
- [](prll://tsk_abc) empty context (renders resolved title)
55707
- [relevant context](prll://tsk_abc) with author annotation
55708
-
55709
- Bare URIs and empty-context refs are preferred in most cases \u2014 the platform
55710
- resolves and renders the entity title automatically.
55711
-
55712
- ### Mentioning people and agents
55713
-
55714
- A real member mention is a \`prll://usr_...\` reference. Plain \`@Display Name\` is
55715
- only text: it does not notify a human or trigger an agent.
55716
-
55717
- When another member must be notified or an agent explicitly triggered, include
55718
- their user reference in the message body. Prefer the empty-context form because
55719
- the platform resolves the member's current display name:
55720
-
55721
- [](prll://usr_xxx)
55722
-
55723
- Use \`[Display Name](prll://usr_xxx)\` when the surrounding sentence needs an
55724
- explicit label. Find the user ID in the incoming message or with
55725
- \`parall members list\`. Never substitute plain \`@Display Name\` when notification
55726
- or agent dispatch matters.
55727
-
55728
- ### URI format
55729
-
55730
- \`prll://\` follows standard URI structure: \`scheme://authority/path?query#fragment\`.
55731
-
55732
- **Entities** \u2014 the entity ID is the authority:
55733
-
55734
- prll://usr_xxx user prll://prj_xxx project
55735
- prll://tsk_xxx task prll://wik_xxx wiki
55736
- prll://msg_xxx message prll://cmt_xxx comment
55737
- prll://cht_xxx chat prll://tcm_xxx task comment (legacy)
55738
- prll://att_xxx attachment prll://ase_xxx agent session
55739
- prll://sch_xxx schedule prll://srn_xxx schedule run
55740
-
55741
- **Wiki** \u2014 path is file path, fragment is a typed anchor:
55742
-
55743
- prll://wik_xxx/docs/guide.md file
55744
- prll://wik_xxx/docs/guide.md#h=Auth::OAuth heading (:: = hierarchy)
55745
- prll://wik_xxx/src/auth.go?rev=<sha>#l=42-58 line range (revision-pinned)
55746
-
55747
- Anchor types: \`h=\` heading, \`l=\` line/range, \`s=\` symbol.
55748
- Line anchors in persistent content require \`?rev=<full-40-char-sha>\`.
55749
-
55750
- **Chat message range**:
55751
-
55752
- prll://cht_xxx#range=msg_01HA,msg_01HZ
55753
-
55754
- **Field access** \u2014 path selects a field (omit to reference the entity itself):
55755
-
55756
- prll://tsk_xxx/description#Implementation heading within task description
55757
-
55758
- ### Unread context
55759
-
55760
- When dispatched to a chat, you may see \`[Unread: N messages | since: prll://msg_xxx]\`.
55761
- This shows messages since your last interaction \u2014 your read cursor advances after each
55762
- dispatch, so context you skip now won't appear as unread next time. Use
55763
- \`parall messages list <chat> --limit 20\` to fetch recent context. For large unread
55764
- counts (50+), fetch only recent messages rather than everything.
55765
-
55766
- Thread dispatches may show \`[Thread: prll://msg_root | N replies | M unread | since: prll://msg_r]\`.
55767
- Same semantics \u2014 use \`parall messages list <chat> --thread-root-id <thread_root> --limit 20\` to
55768
- catch up on the thread.
55769
-
55770
- ### Reading context on demand
55771
-
55772
- An event only carries the single triggering message. If you're mentioned in a
55773
- group chat and lack context, pull what you need from the chat \u2014 don't guess:
55774
-
55775
- parall messages list cht_xxx --limit 20 --before msg_xxx
55776
- parall messages get msg_xxx
55777
- parall chats get cht_xxx
55778
-
55779
- Rule of thumb: in a group chat mention, the conversation that led up to you
55780
- being called almost always matters \u2014 read it before replying. In a DM, your
55781
- session already has continuity, so skip the fetch unless something is unclear.
55782
-
55783
- Same pattern for any other entity referenced in the event: \`tasks get\`,
55784
- \`projects get\`, \`users get\`, \`chats get\`. Follow the reflink, don't ask.
55785
- When one entity isn't enough \u2014 you need what's *around* it \u2014 walk the
55786
- reference graph instead of guessing (see "Walk the reference graph" below).
55787
-
55788
- ### Find context with search first
55789
-
55790
- Reach for unified semantic search before paging chat history:
55791
-
55792
- parall search "pricing decision june" --limit 10
55793
-
55794
- It spans messages, tasks, wiki, and comments. Page \`messages list\` only for the
55795
- verbatim recent flow of one chat, not for discovery.
55796
-
55797
- ### Walk the reference graph
55798
-
55799
- References form a traversable graph, and you can query it \u2014 don't stop at
55800
- fetching entities one by one:
55801
-
55802
- # entity metadata (title, status, preview)
55803
- parall refs resolve prll://tsk_xxx prll://wik_xxx
55804
- # who references this entity
55805
- parall refs backlinks prll://tsk_xxx
55806
- # connected sub-graph around it
55807
- parall refs graph prll://tsk_xxx --depth 2
55808
-
55809
- Use \`refs backlinks\` when you need "where is this discussed / used"; use
55810
- \`refs graph\` when you need the full picture around an entity (related tasks,
55811
- docs, conversations \u2014 edges carry the author's annotation for why they linked).
55812
- Then \`refs resolve\` the interesting node URIs in one batch to get titles and
55813
- status. \`refs graph\` takes entity-level URIs only (\`prll://wik_xxx\`, not
55814
- \`prll://wik_xxx/docs/a.md\`). All results are filtered to what you can see.
55815
- Details: parall-platform skill.
55816
-
55817
- ### File attachments
55818
-
55819
- Messages may include attachments. They appear in events as:
55820
-
55821
- [Attachment: prll://att_xxx | image/png | 1.2MB | screenshot.png]
55822
-
55823
- To download an attachment, use the CLI:
55824
-
55825
- parall files download att_xxx --output /tmp/screenshot.png
55826
-
55827
- To send a file:
55828
-
55829
- parall messages send prll://cht_xxx --file /tmp/output.png --text "Done"
55830
-
55831
- Or upload first and reuse across chats:
55832
-
55833
- parall files upload /tmp/report.pdf
55834
- parall messages send prll://cht_aaa --attachment att_yyy --text "Report"
55835
- parall messages send prll://cht_bbb --attachment att_yyy --text "FYI"
55836
-
55837
- The \`--text\` captions above are safe short literals. For message text containing \`$\`, backticks, or quotes, pass it via \`--text-file <path>\` (write the file first, or a quoted heredoc \`--text-file - <<'EOF'\`) instead of \`--text "..."\` \u2014 inside double quotes the shell turns \`$1,000\` into \`,000\` and executes \`$(...)\`.
55838
-
55839
- ### When to reference
55840
-
55841
- - **Origin** \u2014 always link the message or task that triggered your work
55842
- - **Design docs / wiki** \u2014 link specs and guides relevant to the work
55843
- - **Related tasks** \u2014 link parent, sibling, or blocking tasks
55844
- - **People** \u2014 link assignees or stakeholders when mentioning them
55845
- - **Conversations** \u2014 link a chat or message range as context
55846
-
55847
- ### Why this matters
55848
-
55849
- Other agents and humans read your output. References build a navigable context graph \u2014
55850
- in multi-agent workflows, your references are the map that the next agent follows.`;
55851
- function renderLocalAttachmentSection(section) {
55852
- if (section.images.length === 0 && section.notes.length === 0)
55853
- return "";
55854
- const lines = ["[Local attachment files]"];
55855
- for (const image of section.images) {
55856
- lines.push(`- prll://${image.attachmentId} (${sanitizePromptMeta(image.mimeType)}, ${formatBytes(image.fileSize)}, ${sanitizePromptMeta(image.fileName)})`, ` ${image.localPath}`);
55857
- }
55858
- lines.push(...section.notes);
55859
- return lines.join("\n");
55860
- }
55861
- function sanitizePromptMeta(value) {
55862
- return value.replace(/[\r\n]+/g, " ").replace(/[()]/g, " ").trim();
55863
- }
55864
- function formatBytes(bytes) {
55865
- if (bytes >= 1048576)
55866
- return `${(bytes / 1048576).toFixed(1)}MB`;
55867
- if (bytes >= 1024)
55868
- return `${Math.round(bytes / 1024)}KB`;
55869
- return `${bytes}B`;
55870
- }
55871
-
55872
- // ../agent-core/dist/bridge-workspace.js
55873
- function extractShellCommand(input) {
55874
- if (!input || typeof input !== "object")
55875
- return void 0;
55876
- const command = input.command;
55877
- return typeof command === "string" && command.trim() ? command.trim() : void 0;
55878
- }
55879
- function parseParallCliInvocation(command) {
55880
- const tokens = command.replace(/\s+/g, " ").trim().split(" ");
55881
- let i = 0;
55882
- if (tokens[i] === "parall") {
55883
- i++;
55884
- } else if (tokens[i] === "npx") {
55885
- i++;
55886
- while (i < tokens.length && tokens[i].startsWith("-"))
55887
- i++;
55888
- if (i >= tokens.length || !/^@parall\/cli(?:@.+)?$/.test(tokens[i]))
55889
- return null;
55890
- i++;
55891
- } else if (tokens[i] === "pnpm") {
55892
- i++;
55893
- if (i < tokens.length && (tokens[i] === "exec" || tokens[i] === "dlx"))
55894
- i++;
55895
- if (i >= tokens.length || tokens[i] !== "parall")
55896
- return null;
55897
- i++;
55898
- } else {
55899
- return null;
55786
+ if (!laneResolved)
55787
+ ackItem();
55788
+ } else {
55789
+ host.dispatchedMessages.delete(item.source_id);
55790
+ }
55791
+ } catch (err) {
55792
+ host.dispatchedMessages.delete(item.source_id);
55793
+ throw err;
55900
55794
  }
55901
- return tokens.slice(i).filter((t) => !t.startsWith("-"));
55902
- }
55903
- function isParallSendCommand(command) {
55904
- if (!command)
55905
- return false;
55906
- const sub = parseParallCliInvocation(command);
55907
- if (!sub || sub.length === 0)
55908
- return false;
55909
- return sub[0] === "dm" || sub[0] === "messages" && sub[1] === "send";
55910
- }
55911
- function isParallNoReplyCommand(command) {
55912
- if (!command)
55913
- return false;
55914
- const sub = parseParallCliInvocation(command);
55915
- return sub?.[0] === "no-reply";
55916
55795
  }
55917
55796
 
55918
- // ../agent-core/dist/dispatch-adapter.js
55919
- function buildErrorStepContent(message) {
55920
- return { text: message, suppressed: false, status: "error" };
55797
+ // ../agent-core/dist/routing.js
55798
+ var MAX_CONCURRENT_FORKS = 20;
55799
+ var defaultRoutingStrategy = (event, state) => {
55800
+ if (state.mainCurrentTargetId === event.targetId) {
55801
+ return { action: "buffer-main" };
55802
+ }
55803
+ const existingForkKey = state.activeForks.get(event.targetId);
55804
+ if (existingForkKey)
55805
+ return { action: "buffer-fork", forkKey: existingForkKey };
55806
+ if (state.activeForks.size >= MAX_CONCURRENT_FORKS) {
55807
+ return { action: "buffer-main" };
55808
+ }
55809
+ return { action: "new-fork" };
55810
+ };
55811
+ function routeTrigger(event, state, strategy = defaultRoutingStrategy) {
55812
+ const existingForkKey = state.activeForks.get(event.targetId);
55813
+ if (existingForkKey)
55814
+ return { action: "buffer-fork", forkKey: existingForkKey };
55815
+ if (!state.mainDispatching)
55816
+ return { action: "main" };
55817
+ return strategy(event, state);
55921
55818
  }
55922
55819
 
55923
55820
  // ../agent-core/dist/redact.js
@@ -55942,101 +55839,6 @@ function redactTurnOutcome(event, knownValues) {
55942
55839
  return redacted;
55943
55840
  }
55944
55841
 
55945
- // ../agent-core/dist/gateway-base.js
55946
- import * as os from "node:os";
55947
- import * as fs3 from "node:fs";
55948
- import * as path3 from "node:path";
55949
- import { randomUUID } from "node:crypto";
55950
-
55951
- // ../agent-core/dist/channel-capability.js
55952
- import * as fs2 from "node:fs";
55953
- import * as path2 from "node:path";
55954
- import { fileURLToPath } from "node:url";
55955
- var CAPABILITY_FEISHU_CLI = "feishu-cli";
55956
- var CAPABILITY_SLACK_SEND = "slack-send";
55957
- var CAPABILITY_WECHAT_SEND = "wechat-send";
55958
- function channelCapabilityKeyFor(provider) {
55959
- if (provider === "slack")
55960
- return CAPABILITY_SLACK_SEND;
55961
- if (provider === "wechat")
55962
- return CAPABILITY_WECHAT_SEND;
55963
- return `${provider}-cli`;
55964
- }
55965
- var CHANNEL_POINTER_MAGIC = "parall channel capability pointer";
55966
- function capabilityBinDir(stateDir) {
55967
- return path2.join(stateDir, "bin");
55968
- }
55969
- function channelExecEntryPath() {
55970
- const selfDir = path2.dirname(fileURLToPath(import.meta.url));
55971
- const sibling = path2.join(selfDir, "parall-channel-exec.js");
55972
- if (fs2.existsSync(sibling))
55973
- return sibling;
55974
- return fileURLToPath(new URL("./bin/channel-exec.js", import.meta.url));
55975
- }
55976
- function materializeChannelCapabilities(stateDir, capabilities, log) {
55977
- try {
55978
- reconcileFeishuCli(stateDir, capabilities, log);
55979
- } catch (err) {
55980
- log?.warn(`channel capability materialization failed: ${String(err)}`);
55981
- }
55982
- }
55983
- function reconcileFeishuCli(stateDir, capabilities, log) {
55984
- const binDir = capabilityBinDir(stateDir);
55985
- const posixPath = path2.join(binDir, "lark-cli");
55986
- const granted = capabilities.some((c) => c.key === CAPABILITY_FEISHU_CLI);
55987
- const hadPointer = fs2.existsSync(posixPath);
55988
- if (!granted && !hadPointer)
55989
- return;
55990
- fs2.mkdirSync(binDir, { recursive: true });
55991
- const entry = channelExecEntryPath();
55992
- const nodeExec = process.execPath;
55993
- writePointerIfChanged(posixPath, renderPosixPointer(nodeExec, entry, binDir, "feishu"), log);
55994
- writePointerIfChanged(path2.join(binDir, "lark-cli.cmd"), renderCmdPointer(nodeExec, entry, binDir, "feishu"), log);
55995
- }
55996
- function writePointerIfChanged(filePath, content, log) {
55997
- let existing = null;
55998
- try {
55999
- existing = fs2.readFileSync(filePath, "utf8");
56000
- } catch {
56001
- existing = null;
56002
- }
56003
- if (existing !== content) {
56004
- fs2.writeFileSync(filePath, content, { mode: 493 });
56005
- log?.info(`channel capability: pointer materialized (${path2.basename(filePath)})`);
56006
- }
56007
- fs2.chmodSync(filePath, 493);
56008
- }
56009
- function renderPosixPointer(nodeExecPath, entryJsPath, binDir, channel) {
56010
- return [
56011
- "#!/bin/sh",
56012
- `# Generated by @parall/agent-core \u2014 ${CHANNEL_POINTER_MAGIC} (do not edit).`,
56013
- "# Credential + exec logic lives in the agent-core package; revocation is",
56014
- "# enforced by the platform mint endpoint, so this pointer stays constant.",
56015
- // Strip Node preload-hijack vars BEFORE launching node: NODE_OPTIONS
56016
- // (e.g. --require=/evil.js) and NODE_PATH would execute caller-supplied code
56017
- // at interpreter startup — BEFORE channel-exec's own env scrub, i.e. before
56018
- // the mint. The pointer is a platform-authored trust-boundary artifact whose
56019
- // whole job is a CONTROLLED launch of the broker (absolute node, magic
56020
- // guard, skip-dir); this closes the same env-hijack class for node startup
56021
- // that the absolute node path closes for PATH, keeping the launch deterministic.
56022
- "unset NODE_OPTIONS NODE_PATH",
56023
- // "$@" preserves argv exactly (this is the agent's main path via git-bash).
56024
- `exec "${nodeExecPath}" "${entryJsPath}" --channel ${channel} --skip-dir "${binDir}" -- "$@"`,
56025
- ""
56026
- ].join("\n");
56027
- }
56028
- function renderCmdPointer(nodeExecPath, entryJsPath, binDir, channel) {
56029
- return [
56030
- "@echo off",
56031
- `rem Generated by @parall/agent-core - ${CHANNEL_POINTER_MAGIC} (do not edit).`,
56032
- // Clear Node preload-hijack vars before launching node (see the sh pointer).
56033
- 'set "NODE_OPTIONS="',
56034
- 'set "NODE_PATH="',
56035
- `"${nodeExecPath}" "${entryJsPath}" --channel ${channel} --skip-dir "${binDir}" -- %*`,
56036
- ""
56037
- ].join("\r\n");
56038
- }
56039
-
56040
55842
  // ../agent-core/dist/step-retry-queue.js
56041
55843
  var DEFAULT_RETRY_DELAYS_MS = [5e3, 1e4, 2e4, 4e4, 6e4];
56042
55844
  async function raceWithDeadline(work, ms) {
@@ -56796,6 +56598,97 @@ var ForkSessionFinalizer = class {
56796
56598
  }
56797
56599
  };
56798
56600
 
56601
+ // ../agent-core/dist/session-state.js
56602
+ function normalizeSessionKey(sessionKey) {
56603
+ return sessionKey.toLowerCase();
56604
+ }
56605
+ var sessionChatIdMap = /* @__PURE__ */ new Map();
56606
+ var sessionMessageIdMap = /* @__PURE__ */ new Map();
56607
+ var dispatchMessageIdMap = /* @__PURE__ */ new Map();
56608
+ var dispatchGroupKeyMap = /* @__PURE__ */ new Map();
56609
+ var dispatchNoReplyMap = /* @__PURE__ */ new Map();
56610
+ function setSessionChatId(sessionKey, chatId) {
56611
+ sessionChatIdMap.set(normalizeSessionKey(sessionKey), chatId);
56612
+ }
56613
+ function getSessionChatId(sessionKey) {
56614
+ return sessionChatIdMap.get(normalizeSessionKey(sessionKey));
56615
+ }
56616
+ function setSessionMessageId(sessionKey, messageId) {
56617
+ sessionMessageIdMap.set(normalizeSessionKey(sessionKey), messageId);
56618
+ }
56619
+ function clearSessionMessageId(sessionKey) {
56620
+ sessionMessageIdMap.delete(normalizeSessionKey(sessionKey));
56621
+ }
56622
+ function setDispatchMessageId(sessionKey, messageId) {
56623
+ dispatchMessageIdMap.set(normalizeSessionKey(sessionKey), messageId);
56624
+ }
56625
+ function getDispatchMessageId(sessionKey) {
56626
+ return dispatchMessageIdMap.get(normalizeSessionKey(sessionKey));
56627
+ }
56628
+ function clearDispatchMessageId(sessionKey) {
56629
+ dispatchMessageIdMap.delete(normalizeSessionKey(sessionKey));
56630
+ }
56631
+ function setDispatchGroupKey(sessionKey, groupKey) {
56632
+ dispatchGroupKeyMap.set(normalizeSessionKey(sessionKey), groupKey);
56633
+ }
56634
+ function getDispatchGroupKey(sessionKey) {
56635
+ return dispatchGroupKeyMap.get(normalizeSessionKey(sessionKey));
56636
+ }
56637
+ function clearDispatchGroupKey(sessionKey) {
56638
+ dispatchGroupKeyMap.delete(normalizeSessionKey(sessionKey));
56639
+ }
56640
+ function setDispatchNoReply(sessionKey, noReply) {
56641
+ dispatchNoReplyMap.set(normalizeSessionKey(sessionKey), noReply);
56642
+ }
56643
+ function clearDispatchNoReply(sessionKey) {
56644
+ dispatchNoReplyMap.delete(normalizeSessionKey(sessionKey));
56645
+ }
56646
+ var dispatchMetricsMap = /* @__PURE__ */ new Map();
56647
+ function resetDispatchMetrics(sessionKey) {
56648
+ dispatchMetricsMap.set(normalizeSessionKey(sessionKey), {
56649
+ deliver_text_chunks: 0,
56650
+ deliver_text_chars: 0,
56651
+ message_send_attempts: 0,
56652
+ message_send_successes: 0,
56653
+ no_reply_called: false,
56654
+ tool_call_count: 0,
56655
+ started_at: Date.now()
56656
+ });
56657
+ }
56658
+ function getDispatchMetrics(sessionKey) {
56659
+ return dispatchMetricsMap.get(normalizeSessionKey(sessionKey));
56660
+ }
56661
+ function clearDispatchMetrics(sessionKey) {
56662
+ dispatchMetricsMap.delete(normalizeSessionKey(sessionKey));
56663
+ }
56664
+ function recordDeliverText(sessionKey, charCount) {
56665
+ const m = dispatchMetricsMap.get(normalizeSessionKey(sessionKey));
56666
+ if (!m)
56667
+ return;
56668
+ m.deliver_text_chunks++;
56669
+ m.deliver_text_chars += charCount;
56670
+ }
56671
+ function recordMessageSend(sessionKey, success) {
56672
+ const m = dispatchMetricsMap.get(normalizeSessionKey(sessionKey));
56673
+ if (!m)
56674
+ return;
56675
+ m.message_send_attempts++;
56676
+ if (success)
56677
+ m.message_send_successes++;
56678
+ }
56679
+ function recordNoReply(sessionKey) {
56680
+ const m = dispatchMetricsMap.get(normalizeSessionKey(sessionKey));
56681
+ if (!m)
56682
+ return;
56683
+ m.no_reply_called = true;
56684
+ }
56685
+ function recordToolCall(sessionKey) {
56686
+ const m = dispatchMetricsMap.get(normalizeSessionKey(sessionKey));
56687
+ if (!m)
56688
+ return;
56689
+ m.tool_call_count++;
56690
+ }
56691
+
56799
56692
  // ../agent-core/dist/telemetry.js
56800
56693
  init_esm();
56801
56694
  var import_api_logs = __toESM(require_src(), 1);
@@ -59483,6 +59376,44 @@ function extractCapabilities(config) {
59483
59376
  return out;
59484
59377
  }
59485
59378
 
59379
+ // ../agent-core/dist/prompt-fragments.js
59380
+ function identityFromMe(me) {
59381
+ return {
59382
+ userId: me.id,
59383
+ displayName: me.display_name,
59384
+ title: me.public_profile?.title || void 0,
59385
+ publicDescription: me.public_profile?.description || void 0,
59386
+ // `||` on purpose: an empty-string instructions must also fall back to
59387
+ // the deprecated description alias (empty means "unset" on this wire).
59388
+ instructions: me.agent_profile?.instructions || me.agent_profile?.description || void 0
59389
+ };
59390
+ }
59391
+ function buildIdentity(agent) {
59392
+ return renderPlatformIdentity(agent);
59393
+ }
59394
+ var PRLL_BEHAVIOR = PLATFORM_BEHAVIOR;
59395
+ var PRLL_REFERENCE_GUIDE = PLATFORM_REFERENCE_GUIDE;
59396
+ function renderLocalAttachmentSection(section) {
59397
+ if (section.images.length === 0 && section.notes.length === 0)
59398
+ return "";
59399
+ const lines = ["[Local attachment files]"];
59400
+ for (const image of section.images) {
59401
+ lines.push(`- prll://${image.attachmentId} (${sanitizePromptMeta(image.mimeType)}, ${formatBytes(image.fileSize)}, ${sanitizePromptMeta(image.fileName)})`, ` ${image.localPath}`);
59402
+ }
59403
+ lines.push(...section.notes);
59404
+ return lines.join("\n");
59405
+ }
59406
+ function sanitizePromptMeta(value) {
59407
+ return value.replace(/[\r\n]+/g, " ").replace(/[()]/g, " ").trim();
59408
+ }
59409
+ function formatBytes(bytes) {
59410
+ if (bytes >= 1048576)
59411
+ return `${(bytes / 1048576).toFixed(1)}MB`;
59412
+ if (bytes >= 1024)
59413
+ return `${Math.round(bytes / 1024)}KB`;
59414
+ return `${bytes}B`;
59415
+ }
59416
+
59486
59417
  // ../agent-core/dist/internal/attachment-input.js
59487
59418
  import { execSync } from "node:child_process";
59488
59419
  import { constants } from "node:fs";