@commonlyai/cli 0.1.256 → 0.1.258

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonlyai/cli",
3
- "version": "0.1.256",
3
+ "version": "0.1.258",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -1494,6 +1494,33 @@ export const runMemoryImport = async ({
1494
1494
  const FINAL_TEXT_IS_POSTED = 'Your final text is posted to the pod unless it is exactly NO_REPLY. '
1495
1495
  + 'If you did nothing, or already posted through a tool, end with NO_REPLY alone, with no summary.';
1496
1496
 
1497
+ // Prod walk, 2026-11-05: a person @mentioned a Claude Code seat with a
1498
+ // top-level message, and the seat answered through commonly_post_message with
1499
+ // threadRootId set to that message, so the answer sat in a collapsed thread
1500
+ // under it. The kernel's mention cue teaches threadRootId as a verb but never
1501
+ // says which messages it is for, so each top-level mention says where its
1502
+ // answer goes, beside the message it answers.
1503
+ //
1504
+ // `chat.mention` alone is not "top-level": the kernel sends a chat-thread
1505
+ // mention as chat.mention with `payload.threadRootId`, a 1:1 DM as chat.mention
1506
+ // with `source: 'dm'`, and some wakes (open-work reminders) as chat.mention
1507
+ // with no message at all. Only a message with no thread, outside a DM, gets it.
1508
+ // The line still allows the overflow rule (post the point, continue under your
1509
+ // own root): only threading under the person's message is ruled out.
1510
+ const ANSWER_IN_CHANNEL = '[This message is top-level in the channel, not in a thread: post your answer top-level. '
1511
+ + 'Never set threadRootId to this message\'s id; a long answer may continue under your own top-level post.]';
1512
+
1513
+ export const answersInChannel = (entry) => {
1514
+ const payload = entry?.event?.payload || {};
1515
+ // A duplicate delivery was already answered here; it stays in the prompt as
1516
+ // context, and must not be told to post (CodeRabbit on #3499).
1517
+ return entry?.event?.type === 'chat.mention' && !entry.readOnly
1518
+ && entry.result?.reason !== 'duplicate-delivery'
1519
+ && Boolean(payload.messageId)
1520
+ && (payload.threadRootId === undefined || payload.threadRootId === null || payload.threadRootId === '')
1521
+ && payload.source !== 'dm' && !payload.dmKind;
1522
+ };
1523
+
1497
1524
  const extractPrompt = (event) => {
1498
1525
  const p = event.payload || {};
1499
1526
  if (PROMPT_EVENT_TYPES.has(event.type)) {
@@ -2855,13 +2882,14 @@ export const performRun = ({
2855
2882
  + '[This item is read-only context: a peer won its binding claim. Do not act on it.]\n'
2856
2883
  : (entry.peerFrame ? `${entry.peerFrame}\n` : '');
2857
2884
  const body = entry.prompt || '[No usable prompt was delivered for this item.]';
2885
+ const channelLine = answersInChannel(entry) ? `\n${ANSWER_IN_CHANNEL}` : '';
2858
2886
  const deliveryId = entry.event.payload?.deliveryId;
2859
2887
  const checkpoint = typeof deliveryId === 'string' && deliveryId
2860
2888
  ? `\n[After completed tool-side work or intentional NO_REPLY for only this item, call commonly_checkpoint_event(${JSON.stringify({
2861
2889
  eventId: String(entry.event._id), deliveryId,
2862
2890
  })}). Checkpoint metadata is private runtime data; never post it in chat.]`
2863
2891
  : '';
2864
- return `${prefix}\n${claimContext}${body}${checkpoint}`;
2892
+ return `${prefix}\n${claimContext}${body}${channelLine}${checkpoint}`;
2865
2893
  });
2866
2894
  const rollup = wakeEntries.find((entry) => entry.event.payload?.digestRollup)?.event.payload?.digestRollup;
2867
2895
  const digestFrame = formatDigestFrame(digestEntries.map((entry) => entry.event), rollup);
@@ -643,16 +643,51 @@ const buildPublicClaudePolicyArgs = (mcpToolPatterns, {
643
643
  // be admitted through Seatbelt. Linux caps one argv string at 128 KiB, so the
644
644
  // total is capped well under it.
645
645
  const PUBLIC_SKILL_PROMPT_MAX_BYTES = 96 * 1024;
646
- const publicSkillPromptArgs = async (skillSources) => {
646
+ const publicSkillPromptArgs = async (skillSources, preamble = '') => {
647
647
  const included = [];
648
- const text = await skillsAsText(skillSources, {
648
+ const skills = await skillsAsText(skillSources, {
649
649
  maxBytes: PUBLIC_SKILL_PROMPT_MAX_BYTES,
650
650
  label: 'claude',
651
651
  onIncluded: (source) => included.push(source),
652
652
  });
653
+ const text = [preamble, skills].filter(Boolean).join('\n\n');
653
654
  return { args: text ? ['--append-system-prompt', text] : [], included };
654
655
  };
655
656
 
657
+ // What a confined seat may do on this machine, as prompt text. The CLI logs
658
+ // the same facts to the owner's terminal (workspaceGrantLine in agent.js), but
659
+ // the model never saw them: on 2026-11-05 a read-only workspace seat told its
660
+ // user it could "read and edit files, run shell commands", which is Claude
661
+ // Code's usual kit, not this seat's. Each sentence follows the policy above:
662
+ // a write grant adds Edit, Write and Bash (no Bash on a host with no jail), a
663
+ // web grant adds WebFetch only, and WebSearch is always denied.
664
+ export const seatPermissionsText = ({
665
+ trust, allow = [], noShell = false, gitTool = false,
666
+ }) => {
667
+ const write = trust === 'workspace' && allow.includes('write');
668
+ const web = trust === 'workspace' && allow.includes('web');
669
+ const lines = ['## What you can do on this machine', ''];
670
+ if (write) {
671
+ lines.push(noShell
672
+ ? 'You can read and edit the files in your working folder. You cannot run shell commands.'
673
+ : 'You can read and edit the files in your working folder and run shell commands there. '
674
+ + 'Its .git is read-only, so you cannot commit.');
675
+ } else {
676
+ lines.push(`You can read the files in your working folder${
677
+ gitTool ? ', and read its history through the read-only git tool' : ''}.`);
678
+ lines.push(web
679
+ ? 'You cannot edit or create files or run shell commands.'
680
+ : 'You cannot edit or create files, run shell commands, or use web search or fetch.');
681
+ }
682
+ if (web) lines.push('You can fetch web pages. You cannot use web search.');
683
+ else if (write) lines.push('You cannot use the web search or fetch tools.');
684
+ // A shell's commands can reach the network (workspaceGrantLine says so too),
685
+ // so a seat with one is never told it is offline.
686
+ if (write && !noShell) lines.push('Your shell commands can reach the network.');
687
+ lines.push('When someone asks what you can do, describe these limits, not Claude Code\'s usual tools.');
688
+ return lines.join('\n');
689
+ };
690
+
656
691
  // `ownGroup` is set only under the run supervisor, which kills the child's
657
692
  // whole group; unsupervised, the spawn options are exactly what they were.
658
693
  // Stream-json so each model event is a sign of life for the watchdog. The
@@ -1677,7 +1712,12 @@ export default {
1677
1712
  }
1678
1713
  }
1679
1714
  if (publicTrust) {
1680
- const prompt = await publicSkillPromptArgs(mountedSkills);
1715
+ const prompt = await publicSkillPromptArgs(mountedSkills, seatPermissionsText({
1716
+ trust: ctx.environment?.sandbox?.trust === 'workspace' ? 'workspace' : 'public',
1717
+ allow: workspaceGrants(ctx.environment?.sandbox),
1718
+ noShell: policyOnlyHost(ctx),
1719
+ gitTool: Boolean(ctx.workspaceGit),
1720
+ }));
1681
1721
  publicSkillArgs = prompt.args;
1682
1722
  skillMount = {
1683
1723
  mounted: prompt.included,