primcli 1.56.0 → 1.58.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.
@@ -435,7 +435,7 @@ async function haltAutoWorking(configDir, match, reason, options = {}) {
435
435
  }
436
436
  const stopped = [];
437
437
  for (const lease of candidates.values()) {
438
- const byPeer = peers.has(lease.sender) && match.profileName !== void 0 && match.profileName === lease.profile;
438
+ const byPeer = peers.has(lease.sender) && match.profileName !== void 0 && match.profileName === lease.profile && (match.threadId === void 0 || match.threadId !== null && lease.thread_id === match.threadId);
439
439
  if (!ids.has(lease.email_id) && !byPeer) continue;
440
440
  try {
441
441
  const stop = stopWorkingLease(configDir, lease.email_id, reason);
@@ -7,7 +7,7 @@ import { $ as describeSessionHookItem, A as evaluateContactPolicy, B as agentInv
7
7
  import { a as scopedChatSenderTrust, i as readBeforeDeadline, n as isPlainChatReply, o as presenceDisposition, r as isScopedChatReply, s as readPresenceProjection, t as isConnectedChatCredential } from "../scoped-chat-C7cpIxVS.js";
8
8
  import { c as startBackgroundListen, i as backgroundListenToken, l as stopBackgroundListen, o as runBackgroundListen, r as backgroundListenStatus, u as verifyBackgroundListenTarget } from "../listen-background--0peztKE.js";
9
9
  import { a as ensureSharedMailSubscription, c as reserveSharedMailSubscription, d as otherParticipants, f as EventConnection, i as sharedMailScope, l as followEmailConversation, n as reconcileChatSend, o as createSharedMailWaiter, p as EventReceiverError, r as openSharedMailReceiver, s as openSharedMailStore, t as sendSignal, u as readConversationFollow } from "../signal-command-KEfppb9h.js";
10
- import { autoSignalEligible, dispatchAutoRead, dispatchAutoWorking, haltAutoWorking, isSentSignal, restoreAutoWorking } from "./auto-signals.js";
10
+ import { autoSignalEligible, dispatchAutoRead, dispatchAutoWorking, haltAutoWorking, isSentSignal, readWorkingLease, restoreAutoWorking } from "./auto-signals.js";
11
11
  import { t as guardJsonOutputCommands } from "../json-output-CEskSQJi.js";
12
12
  import { Args, Command, Errors, Flags, ux } from "@oclif/core";
13
13
  import { chmodSync, closeSync, constants, cpSync, existsSync, fstatSync, fsyncSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
@@ -42215,9 +42215,29 @@ async function clearPendingAfterRead(configDir, emailId) {
42215
42215
  await clearReadPendingMail(configDir, profileName, runtime ? runtime.slice(runtime.indexOf(":") + 1) : null, emailId);
42216
42216
  } catch {}
42217
42217
  }
42218
- const NO_SIGNAL_DESCRIPTION = "With --brief, do not report working to the sender. By default, reading mail from the verified owner or a same-organization member (not another agent) that a receiver surfaced to this session reports working in the background until you answer (also disabled by PRIMITIVE_NO_AUTO_SIGNALS=1).";
42218
+ const NO_SIGNAL_DESCRIPTION = "With --brief, do not report working to the sender, and stop a working report an earlier read of this email started; nothing is sent. By default, reading mail from the verified owner or a same-organization member (not another agent) that a receiver surfaced to this session reports working in the background until you answer (also disabled by PRIMITIVE_NO_AUTO_SIGNALS=1).";
42219
+ /**
42220
+ * The line a brief ends with once it has started reporting working: the
42221
+ * agent only knows whether it will act after reading, so the way out has to
42222
+ * come after the content.
42223
+ */
42224
+ function workingStopCommand(emailId, prefix) {
42225
+ return `${prefix} emails get --id ${emailId} --brief --no-signal`;
42226
+ }
42227
+ /**
42228
+ * Whether a working report from an earlier read is still being renewed: not
42229
+ * stopped, and inside the renewal cap (past it nothing renews, whatever the
42230
+ * saved lease says).
42231
+ */
42232
+ function workingStillRunning(lease, now = Date.now()) {
42233
+ return lease !== null && lease.stopped_at === null && now - lease.started_at < 9e5;
42234
+ }
42235
+ function workingStopLine(command) {
42236
+ return `The sender now sees you working on this until you answer. If you will not act on it, stop that with ${command} (it sends nothing).`;
42237
+ }
42219
42238
  async function runBrief(command, flags) {
42220
42239
  await runWithTiming(flags.time === true, async () => {
42240
+ if (flags["no-signal"]) await haltAutoWorking(command.config.configDir, { emailIds: [flags.id] }, "not_acting");
42221
42241
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
42222
42242
  configDir: command.config.configDir,
42223
42243
  apiKey: flags["api-key"],
@@ -42253,12 +42273,15 @@ async function runBrief(command, flags) {
42253
42273
  isOwnSignal: (sentId) => isSentSignal(command.config.configDir, sentId),
42254
42274
  signal: AbortSignal.timeout(3e4)
42255
42275
  });
42256
- command.log(flags.json ? JSON.stringify(brief, null, 2) : renderEmailBrief(brief));
42257
- await clearPendingAfterRead(command.config.configDir, detail.id);
42258
- if (!flags["no-signal"] && detail.sender_connected_agent_verified !== true) dispatchAutoWorking({
42276
+ const stop = !flags["no-signal"] && detail.sender_connected_agent_verified !== true && dispatchAutoWorking({
42259
42277
  configDir: command.config.configDir,
42260
42278
  emailId: detail.id
42261
- });
42279
+ }) || !flags["no-signal"] && workingStillRunning(readWorkingLease(command.config.configDir, detail.id)) ? workingStopCommand(detail.id, followUpCommandPrefix()) : null;
42280
+ command.log(flags.json ? JSON.stringify(stop ? {
42281
+ ...brief,
42282
+ working_signal: { stop_command: stop }
42283
+ } : brief, null, 2) : `${renderEmailBrief(brief)}${stop ? `\n${workingStopLine(stop)}` : ""}`);
42284
+ await clearPendingAfterRead(command.config.configDir, detail.id);
42262
42285
  });
42263
42286
  }
42264
42287
  /**
@@ -43954,7 +43977,7 @@ const PRIMITIVE_TEAM_AUTHOR = {
43954
43977
  url: "https://primitive.dev"
43955
43978
  };
43956
43979
  const SDK_VERSION_RANGE = "^1.35.0";
43957
- const CLI_VERSION_RANGE = "^1.56.0";
43980
+ const CLI_VERSION_RANGE = "^1.58.0";
43958
43981
  const ESBUILD_VERSION_RANGE = "^0.27.0";
43959
43982
  function renderHandler() {
43960
43983
  return `// env.PRIMITIVE_API_KEY, env.PRIMITIVE_WEBHOOK_SECRET, and
@@ -55207,7 +55230,8 @@ var ReplyCommand = class ReplyCommand extends Command {
55207
55230
  const halted = await haltAutoWorking(this.config.configDir, {
55208
55231
  emailIds: [emailId],
55209
55232
  peers: priorRepliesCheck.status === "checked" && priorRepliesCheck.detail?.from_email ? [priorRepliesCheck.detail.from_email] : [],
55210
- profileName: auth.connectedAgent?.profileName
55233
+ profileName: auth.connectedAgent?.profileName,
55234
+ threadId: priorRepliesCheck.status === "checked" ? priorRepliesCheck.detail?.thread_id ?? null : null
55211
55235
  }, flags.fyi ? "fyi" : "reply");
55212
55236
  const attemptStartedAtIso = (/* @__PURE__ */ new Date()).toISOString();
55213
55237
  this.attemptStartedAtIso = attemptStartedAtIso;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primcli",
3
- "version": "1.56.0",
3
+ "version": "1.58.0",
4
4
  "description": "Official Primitive CLI: deploy Primitive Functions, send and inspect mail, manage endpoints, all from the terminal. Wraps the @primitivedotdev/sdk runtime client with one-shot commands.",
5
5
  "type": "module",
6
6
  "sideEffects": false,