primcli 1.55.0 → 1.55.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { n as __exportAll } from "./rolldown-runtime-CNZpIYwj.js";
2
- import { C as resolveCliAuth, F as agentProfilesDirectory, G as createClient, H as requireDefaultLoginProfile, K as createConfig, N as agentProfileDirectory, R as loadConnectedAgentProfile, S as normalizeApiBaseUrl, T as saveSignupCredentials, W as PrimitiveApiClient, _ as deleteCliCredentials, c as resolveConfigEnvironment, d as validateCliHeaderName, f as validateCliHeaderValue, i as loadCliConfig, j as AGENT_PROFILE_ENV, m as cliAccessTokenExpiresAt, p as acquireCliCredentialsLock, w as saveCliCredentials, x as loadCliCredentials, y as detectPrimitiveKeyEnvMisname } from "./cli-config-DGrZCUfw.js";
3
- import { h as writeMailJson, m as withMailLock, p as syncMailDirectory, u as privateMailPermissions } from "./shared-mail-files-SPPcis9g.js";
1
+ import { b as __exportAll } from "./repeats-x4QM2yoG-De3MV3st.js";
2
+ import { C as resolveCliAuth, F as agentProfilesDirectory, G as createClient, H as requireDefaultLoginProfile, K as createConfig, N as agentProfileDirectory, R as loadConnectedAgentProfile, S as normalizeApiBaseUrl, T as saveSignupCredentials, W as PrimitiveApiClient, _ as deleteCliCredentials, c as resolveConfigEnvironment, d as validateCliHeaderName, f as validateCliHeaderValue, i as loadCliConfig, j as AGENT_PROFILE_ENV, m as cliAccessTokenExpiresAt, p as acquireCliCredentialsLock, w as saveCliCredentials, x as loadCliCredentials, y as detectPrimitiveKeyEnvMisname } from "./cli-config-DMszFbGn.js";
3
+ import { h as writeMailJson, m as withMailLock, p as syncMailDirectory, u as privateMailPermissions } from "./shared-mail-files-MwlVE90c.js";
4
4
  import { Command, Errors, Flags } from "@oclif/core";
5
5
  import { existsSync, lstatSync, readFileSync, readdirSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
6
6
  import { createHash } from "node:crypto";
@@ -3296,7 +3296,7 @@ const provisionMemberAddress = (options) => (options.client ?? client).put({
3296
3296
  //#endregion
3297
3297
  //#region src/oclif/api-client.ts
3298
3298
  const API_HEADERS_ENV = "PRIMITIVE_API_HEADERS";
3299
- const OAUTH_REFRESH_SKEW_MS = 60 * 1e3;
3299
+ const OAUTH_REFRESH_SKEW_MS = 6e4;
3300
3300
  const SAVED_CLI_OAUTH_SESSION_EXPIRED_MESSAGE = "Saved Primitive CLI OAuth session expired or was revoked. Run `primitive signin` to authenticate again.";
3301
3301
  function mergeHeaders(...headers) {
3302
3302
  const merged = {};
@@ -3337,7 +3337,8 @@ function resolveCliApiRequestConfig(params) {
3337
3337
  environmentName: null
3338
3338
  };
3339
3339
  }
3340
- const currentEnvironment = resolveConfigEnvironment(loadCliConfig(params.configDir));
3340
+ const cliConfig = loadCliConfig(params.configDir);
3341
+ const currentEnvironment = resolveConfigEnvironment(cliConfig);
3341
3342
  const configuredApiBaseUrl = currentEnvironment?.config.api_base_url;
3342
3343
  if (currentEnvironment !== null && currentEnvironment.name !== "default" && params.apiBaseUrl === void 0 && configuredApiBaseUrl === void 0) throw new Errors.CLIError(`The active Primitive CLI environment \`${currentEnvironment.name}\` does not specify an api_base_url. Set one with \`primitive config set --environment ${currentEnvironment.name} --api-base-url https://...\`, or switch to a different environment with \`primitive config use <name>\`. Refusing to fall back to the production default for a non-default environment.`, { exit: 1 });
3343
3344
  const apiBaseUrl = params.apiBaseUrl !== void 0 ? normalizeApiBaseUrl(params.apiBaseUrl) : configuredApiBaseUrl;
@@ -3487,7 +3488,7 @@ async function createAuthenticatedCliApiClient(params) {
3487
3488
  //#endregion
3488
3489
  //#region src/oclif/attachment-wait.ts
3489
3490
  /** Generated download commands that wait for attachment content by default. */
3490
- const ATTACHMENT_WAIT_OPERATIONS = new Set([
3491
+ const ATTACHMENT_WAIT_OPERATIONS = /* @__PURE__ */ new Set([
3491
3492
  "downloadAttachments",
3492
3493
  "downloadEmailAttachmentPart",
3493
3494
  "downloadSentAttachmentPart"
@@ -3732,7 +3733,7 @@ async function maybeWriteFunctionEndpointRedirect(inputs) {
3732
3733
  * closest valid flag to that message so the fix is on the first line.
3733
3734
  */
3734
3735
  /** Common names for a free-text query, mapped onto the `q` flag. */
3735
- const FREE_TEXT_ALIASES = new Set([
3736
+ const FREE_TEXT_ALIASES = /* @__PURE__ */ new Set([
3736
3737
  "query",
3737
3738
  "search",
3738
3739
  "text",
@@ -3969,12 +3970,12 @@ function apiResultHttpStatus(result) {
3969
3970
  const response = result.response;
3970
3971
  return typeof response?.status === "number" ? response.status : void 0;
3971
3972
  }
3972
- const SEND_STATUSES_THAT_DID_NOT_GO_OUT = new Set([
3973
+ const SEND_STATUSES_THAT_DID_NOT_GO_OUT = /* @__PURE__ */ new Set([
3973
3974
  "agent_failed",
3974
3975
  "canceled",
3975
3976
  "gate_denied"
3976
3977
  ]);
3977
- const SEND_STATUSES_WITH_UNKNOWN_OUTCOME = new Set(["unknown"]);
3978
+ const SEND_STATUSES_WITH_UNKNOWN_OUTCOME = /* @__PURE__ */ new Set(["unknown"]);
3978
3979
  /**
3979
3980
  * Classify a send record the API returned with a 2xx. A 2xx alone does
3980
3981
  * not mean a message went out: the record's status can show the
@@ -4161,11 +4162,11 @@ function buildFollowUpCommand(kind, description, argv, options = {}, invocation
4161
4162
  requires_message: requiresMessage
4162
4163
  };
4163
4164
  }
4164
- const SENT_HISTORY_CLOCK_SKEW_MS = 300 * 1e3;
4165
+ const SENT_HISTORY_CLOCK_SKEW_MS = 3e5;
4165
4166
  function sentHistoryWindowStart(attemptStartedAtIso) {
4166
4167
  const started = Date.parse(attemptStartedAtIso);
4167
4168
  if (!Number.isFinite(started)) return attemptStartedAtIso;
4168
- return new Date(started - SENT_HISTORY_CLOCK_SKEW_MS).toISOString();
4169
+ return (/* @__PURE__ */ new Date(started - SENT_HISTORY_CLOCK_SKEW_MS)).toISOString();
4169
4170
  }
4170
4171
  /** Header rule for Idempotency-Key: 1 to 255 printable ASCII characters. */
4171
4172
  const IDEMPOTENCY_KEY_PATTERN = /^[\x21-\x7E]{1,255}$/;
@@ -4180,7 +4181,7 @@ const MAX_SEND_WAIT_TIMEOUT_MS = 3e4;
4180
4181
  function sendWaitClampNotice(requestedMs) {
4181
4182
  return `--wait-timeout-ms ${requestedMs} is longer than the ${MAX_SEND_WAIT_TIMEOUT_MS}ms the server allows, so the delivery wait uses ${MAX_SEND_WAIT_TIMEOUT_MS}ms. --wait covers delivery only; to wait for a reply, run \`primitive emails wait --reply-to-sent-email-id <sent id> --from <recipient> --timeout ${Math.ceil(requestedMs / 1e3)}\` after this send.`;
4182
4183
  }
4183
- const NON_CONTENT_SEND_FIELDS = new Set(["wait", "wait_timeout_ms"]);
4184
+ const NON_CONTENT_SEND_FIELDS = /* @__PURE__ */ new Set(["wait", "wait_timeout_ms"]);
4184
4185
  function canonicalJson(value) {
4185
4186
  if (Array.isArray(value)) return `[${value.map((item) => canonicalJson(item ?? null)).join(",")}]`;
4186
4187
  if (value !== null && typeof value === "object") return `{${Object.entries(value).filter(([, item]) => item !== void 0).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, item]) => `${JSON.stringify(key)}:${canonicalJson(item)}`).join(",")}}`;
@@ -4194,7 +4195,7 @@ function canonicalJson(value) {
4194
4195
  * on another day) still goes out, exactly as without a key. An explicit
4195
4196
  * --idempotency-key never expires.
4196
4197
  */
4197
- const DERIVED_IDEMPOTENCY_WINDOW_MS = 300 * 1e3;
4198
+ const DERIVED_IDEMPOTENCY_WINDOW_MS = 3e5;
4198
4199
  /**
4199
4200
  * The idempotency key a send uses when the caller passes none. It is a
4200
4201
  * hash of what is sent (and, for a reply, of the email replied to) and
@@ -4354,7 +4355,7 @@ function thrownErrorExitCode(error) {
4354
4355
  }
4355
4356
  //#endregion
4356
4357
  //#region src/oclif/interaction-actions.ts
4357
- const HINTS = new Set([
4358
+ const HINTS = /* @__PURE__ */ new Set([
4358
4359
  "status",
4359
4360
  "card",
4360
4361
  "none",
@@ -5125,7 +5126,7 @@ function savedConnectedProfiles(configDir, exclude) {
5125
5126
  */
5126
5127
  async function otherProfiles(configDir, session, current) {
5127
5128
  if (session) try {
5128
- const { connectedProfilesForSession } = await import("./machine-session-BYaA1qXC.js").then((n) => n.s);
5129
+ const { connectedProfilesForSession } = await import("./machine-session-CufQfBvp.js").then((n) => n.s);
5129
5130
  return {
5130
5131
  inSession: true,
5131
5132
  profiles: connectedProfilesForSession(configDir, session, current)
@@ -5498,7 +5499,7 @@ function renderRequestSchemaSummary(schema) {
5498
5499
  for (const f of complex) {
5499
5500
  const marker = f.required ? " *" : " ";
5500
5501
  const padName = f.name.padEnd(nameWidth);
5501
- const trimmedDesc = f.description.length > descMax ? `${f.description.slice(0, descMax - 3)}...` : f.description;
5502
+ const trimmedDesc = f.description.length > descMax ? `${f.description.slice(0, 75)}...` : f.description;
5502
5503
  const desc = trimmedDesc ? ` ${trimmedDesc}` : "";
5503
5504
  lines.push(`${marker} ${padName} ${f.displayType}${desc}`);
5504
5505
  }
@@ -5669,7 +5670,7 @@ async function runWithTiming(enabled, fn) {
5669
5670
  }
5670
5671
  const TIME_FLAG_DESCRIPTION = "Print the wall-clock duration of this command to stderr after it completes (e.g. `[time: 1.34s]`). Useful for measuring `--wait` send latency, comparing CLI overhead, or capturing timing in scripts.";
5671
5672
  const API_BASE_URL_FLAG_DESCRIPTION = "Override the API base URL. Internal testing only; not documented to customers.";
5672
- const RESERVED_FLAG_NAMES = new Set([
5673
+ const RESERVED_FLAG_NAMES = /* @__PURE__ */ new Set([
5673
5674
  "api-key",
5674
5675
  "api-base-url",
5675
5676
  "raw-body",
@@ -5844,17 +5845,18 @@ function createOperationCommand(operation) {
5844
5845
  if (operation.hasJsonBody) {
5845
5846
  const explicit = readJsonBody(parsedFlags);
5846
5847
  const overrides = collectBodyFieldFlags(parsedFlags, bodyFieldFlagToProperty);
5847
- if (Object.keys(overrides).length > 0) if (explicit === void 0) body = overrides;
5848
- else if (explicit !== null && typeof explicit === "object" && !Array.isArray(explicit)) body = {
5849
- ...explicit,
5850
- ...overrides
5851
- };
5852
- else {
5853
- const explicitKind = explicit === null ? "null" : Array.isArray(explicit) ? "array" : typeof explicit;
5854
- const overrideFlags = Object.keys(overrides).map((p) => `--${flagName(p)}`).join(", ");
5855
- throw new Errors.CLIError(`--raw-body must be a JSON object when also passing per-field flags (got ${explicitKind}); supplied per-field flags: ${overrideFlags}. Either drop --raw-body and rely on the per-field flags, or move every field into the JSON --raw-body and drop the flags.`);
5856
- }
5857
- else body = explicit;
5848
+ if (Object.keys(overrides).length > 0) {
5849
+ if (explicit === void 0) body = overrides;
5850
+ else if (explicit !== null && typeof explicit === "object" && !Array.isArray(explicit)) body = {
5851
+ ...explicit,
5852
+ ...overrides
5853
+ };
5854
+ else {
5855
+ const explicitKind = explicit === null ? "null" : Array.isArray(explicit) ? "array" : typeof explicit;
5856
+ const overrideFlags = Object.keys(overrides).map((p) => `--${flagName(p)}`).join(", ");
5857
+ throw new Errors.CLIError(`--raw-body must be a JSON object when also passing per-field flags (got ${explicitKind}); supplied per-field flags: ${overrideFlags}. Either drop --raw-body and rely on the per-field flags, or move every field into the JSON --raw-body and drop the flags.`);
5858
+ }
5859
+ } else body = explicit;
5858
5860
  }
5859
5861
  if (operation.bodyRequired && body === void 0) throw new Errors.CLIError(`Operation ${operation.operationId} requires a body. Pass each field as a --flag (see --help) or supply JSON via --raw-body / --body-file.`);
5860
5862
  const operationFn = sdk_gen_exports[operation.sdkName];
@@ -1,4 +1,4 @@
1
- import { c as mailTime, d as readMailJson, h as writeMailJson, i as mailId, l as privateMailDirectory, o as mailObject, r as mailAddress, s as mailString } from "./shared-mail-files-SPPcis9g.js";
1
+ import { c as mailTime, d as readMailJson, h as writeMailJson, i as mailId, l as privateMailDirectory, o as mailObject, r as mailAddress, s as mailString } from "./shared-mail-files-MwlVE90c.js";
2
2
  import { Errors } from "@oclif/core";
3
3
  import { chmodSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
4
4
  import { randomUUID } from "node:crypto";
@@ -91,7 +91,8 @@ function createSseClient({ onRequest, onSseError, onSseEvent, responseTransforme
91
91
  } catch (error) {
92
92
  onSseError?.(error);
93
93
  if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) break;
94
- await sleep(Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4));
94
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
95
+ await sleep(backoff);
95
96
  }
96
97
  }
97
98
  };
@@ -337,9 +338,7 @@ async function setAuthParams(options) {
337
338
  case "cookie":
338
339
  options.headers.append("Cookie", `${name}=${token}`);
339
340
  break;
340
- default:
341
- options.headers.set(name, token);
342
- break;
341
+ default: options.headers.set(name, token);
343
342
  }
344
343
  }
345
344
  }
@@ -496,9 +495,7 @@ const createClient = (config = {}) => {
496
495
  case "stream":
497
496
  emptyData = response.body;
498
497
  break;
499
- default:
500
- emptyData = {};
501
- break;
498
+ default: emptyData = {};
502
499
  }
503
500
  return opts.responseStyle === "data" ? emptyData : {
504
501
  data: emptyData,
@@ -947,7 +944,7 @@ function saveActiveChatState(configDir, input, options = {}) {
947
944
  const CREDENTIALS_FILE = "credentials.json";
948
945
  const CREDENTIALS_LOCK_DIR = "credentials.lock";
949
946
  const CREDENTIALS_LOCK_OWNER_FILE = "owner.json";
950
- const CREDENTIALS_LOCK_STALE_MS = 1800 * 1e3;
947
+ const CREDENTIALS_LOCK_STALE_MS = 18e5;
951
948
  const MALFORMED_CREDENTIALS_HINT = "Run `primitive logout` and then `primitive signin`.";
952
949
  const CREDENTIALS_LOCK_CLEANUP_SIGNALS = [
953
950
  "SIGINT",
@@ -235,7 +235,7 @@ function guardJsonOutput(cls) {
235
235
  };
236
236
  }
237
237
  /** Command ids whose `--json` streams several documents over time. */
238
- const STREAMING_JSON_COMMAND_IDS = new Set(["listen"]);
238
+ const STREAMING_JSON_COMMAND_IDS = /* @__PURE__ */ new Set(["listen"]);
239
239
  /**
240
240
  * Guard every command in `commands` that accepts `--json`, except the
241
241
  * streaming ones. Called once by the command registry.
@@ -1,4 +1,4 @@
1
- import { _ as acquireListenLock, a as mailLockBusy, b as listenProcessIdentity, d as readMailJson, f as removeMailFile, g as ListenStateError, h as writeMailJson, i as mailId, l as privateMailDirectory, o as mailObject, s as mailString, v as compareListenProcessIdentity } from "./shared-mail-files-SPPcis9g.js";
1
+ import { _ as acquireListenLock, a as mailLockBusy, b as listenProcessIdentity, d as readMailJson, f as removeMailFile, g as ListenStateError, h as writeMailJson, i as mailId, l as privateMailDirectory, o as mailObject, s as mailString, v as compareListenProcessIdentity } from "./shared-mail-files-MwlVE90c.js";
2
2
  import { lstatSync, realpathSync } from "node:fs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import { join } from "node:path";
@@ -11,10 +11,10 @@ const SUPERVISOR_ENV = "PRIMITIVE_LISTEN_SUPERVISOR";
11
11
  const SUPERVISOR_ARGV_ENV = "PRIMITIVE_LISTEN_SUPERVISOR_ARGV";
12
12
  const SUPERVISOR_WORKER_ENV = "PRIMITIVE_LISTEN_SUPERVISOR_WORKER";
13
13
  const STALE_AFTER_MS = 15e3;
14
- const RESTART_WINDOW_MS = 10 * 6e4;
15
- const HEALTHY_RESET_MS = 10 * 6e4;
14
+ const RESTART_WINDOW_MS = 6e5;
15
+ const HEALTHY_RESET_MS = 6e5;
16
16
  const MAX_FAILURES = 5;
17
- const RESTART_COOLDOWN_MS = 5 * 6e4;
17
+ const RESTART_COOLDOWN_MS = 3e5;
18
18
  const phases = [
19
19
  "starting",
20
20
  "receiving",
@@ -46,8 +46,8 @@ function savedFailureCode(value) {
46
46
  if (value === null || value === void 0) return null;
47
47
  return knownFailureCode(value) ?? "unrecognized";
48
48
  }
49
- const DISK_FULL_ERRORS = new Set(["ENOSPC", "EDQUOT"]);
50
- const STORAGE_ERRORS = new Set([
49
+ const DISK_FULL_ERRORS = /* @__PURE__ */ new Set(["ENOSPC", "EDQUOT"]);
50
+ const STORAGE_ERRORS = /* @__PURE__ */ new Set([
51
51
  "EIO",
52
52
  "EROFS",
53
53
  "EMFILE",
@@ -112,7 +112,8 @@ function configurationFingerprint(value) {
112
112
  function verifyBackgroundListenTarget(target, env = process.env) {
113
113
  if (backgroundListenToken(env) === null) return;
114
114
  try {
115
- const expected = mailObject(JSON.parse(env["PRIMITIVE_LISTEN_BACKGROUND_TARGET"] ?? ""), [
115
+ const value = JSON.parse(env["PRIMITIVE_LISTEN_BACKGROUND_TARGET"] ?? "");
116
+ const expected = mailObject(value, [
116
117
  "scope",
117
118
  "threadId",
118
119
  "configDir",
@@ -1,11 +1,11 @@
1
- import { n as __exportAll } from "./rolldown-runtime-CNZpIYwj.js";
2
- import { B as parseOwnerMemberAddress, F as agentProfilesDirectory, I as connectedAgentIdentity, L as connectedApiBaseUrl, M as AgentConnectionSetupError, N as agentProfileDirectory, P as agentProfileName, R as loadConnectedAgentProfile, U as saveConnectedAgentProfile, V as profileAlreadyConnectedMessage, W as PrimitiveApiClient, j as AGENT_PROFILE_ENV, x as loadCliCredentials, z as parseConnectedAgentProfile } from "./cli-config-DGrZCUfw.js";
3
- import { An as listContacts, Bn as listSentEmails, Jn as putContact, Kn as putAgentContact, Nn as listDomains, On as listAgentContacts, Tt as defaultConnectionName, _n as getEmail, an as deleteContact, fn as getAgentContactPolicy, in as deleteAgentContact, ir as sendEmail, pn as getContact, qn as putAgentContactPolicy, qt as refreshStoredCliCredentials, tr as searchEmails } from "./api-command-CQRMWPkg.js";
4
- import { _ as acquireListenLock, c as mailTime, d as readMailJson, f as removeMailFile, g as ListenStateError, h as writeMailJson, i as mailId, l as privateMailDirectory, o as mailObject, r as mailAddress, s as mailString } from "./shared-mail-files-SPPcis9g.js";
5
- import { _ as detectAgentRuntime, a as NotificationRetryError, d as defaultSessionSocket, f as NativeSessionDisconnectedError, l as SESSION_UUID, t as notificationScope, u as connectNativeSession, v as installConnectSkill, x as readBundledConnectSkill } from "./notify-session-BnEHEbxa.js";
6
- import { a as scopedChatSenderTrust } from "./scoped-chat-BrLq4dXH.js";
7
- import { l as stopBackgroundListen, r as backgroundListenStatus } from "./listen-background-CMfxkeVP.js";
8
- import { t as readSharedMailOwner } from "./shared-mail-watch-CWhpfJ0N.js";
1
+ import { b as __exportAll } from "./repeats-x4QM2yoG-De3MV3st.js";
2
+ import { B as parseOwnerMemberAddress, F as agentProfilesDirectory, I as connectedAgentIdentity, L as connectedApiBaseUrl, M as AgentConnectionSetupError, N as agentProfileDirectory, P as agentProfileName, R as loadConnectedAgentProfile, U as saveConnectedAgentProfile, V as profileAlreadyConnectedMessage, W as PrimitiveApiClient, j as AGENT_PROFILE_ENV, x as loadCliCredentials, z as parseConnectedAgentProfile } from "./cli-config-DMszFbGn.js";
3
+ import { An as listContacts, Bn as listSentEmails, Jn as putContact, Kn as putAgentContact, Nn as listDomains, On as listAgentContacts, Tt as defaultConnectionName, _n as getEmail, an as deleteContact, fn as getAgentContactPolicy, in as deleteAgentContact, ir as sendEmail, pn as getContact, qn as putAgentContactPolicy, qt as refreshStoredCliCredentials, tr as searchEmails } from "./api-command-0FiEAuQi.js";
4
+ import { _ as acquireListenLock, c as mailTime, d as readMailJson, f as removeMailFile, g as ListenStateError, h as writeMailJson, i as mailId, l as privateMailDirectory, o as mailObject, r as mailAddress, s as mailString } from "./shared-mail-files-MwlVE90c.js";
5
+ import { _ as detectAgentRuntime, a as NotificationRetryError, d as defaultSessionSocket, f as NativeSessionDisconnectedError, l as SESSION_UUID, t as notificationScope, u as connectNativeSession, v as installConnectSkill, x as readBundledConnectSkill } from "./notify-session-BGzeKcQO.js";
6
+ import { a as scopedChatSenderTrust } from "./scoped-chat-C7cpIxVS.js";
7
+ import { l as stopBackgroundListen, r as backgroundListenStatus } from "./listen-background--0peztKE.js";
8
+ import { t as readSharedMailOwner } from "./shared-mail-watch-DtKpsgg8.js";
9
9
  import { accessSync, chmodSync, closeSync, constants, copyFileSync, existsSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, rmdirSync, statSync, unlinkSync, writeFileSync } from "node:fs";
10
10
  import { createHash, randomUUID } from "node:crypto";
11
11
  import { basename, delimiter, dirname, isAbsolute, join, resolve } from "node:path";
@@ -16,7 +16,7 @@ import { promisify } from "node:util";
16
16
  import { createConnection } from "node:net";
17
17
  //#region src/oclif/owner-member-address.ts
18
18
  const REFRESH_TIMEOUT_MS = 5e3;
19
- const MAX_RESPONSE_BYTES$1 = 64 * 1024;
19
+ const MAX_RESPONSE_BYTES$1 = 65536;
20
20
  /** Reads at most MAX_RESPONSE_BYTES, stopping as soon as the body exceeds it. */
21
21
  async function boundedText(response) {
22
22
  const reader = response.body?.getReader();
@@ -1326,8 +1326,6 @@ const LOCK_WAIT = new Int32Array(new SharedArrayBuffer(4));
1326
1326
  function record$1(value) {
1327
1327
  return value !== null && typeof value === "object" && !Array.isArray(value);
1328
1328
  }
1329
- /** Clock skew tolerated for a record written slightly in the future. */
1330
- const RECORD_CLOCK_SKEW_MS = 6e4;
1331
1329
  function hookMailCheckPath(configDir, profileName, sessionId) {
1332
1330
  return join(agentProfileDirectory(configDir, profileName), `pending-mail-${sessionId}.mail-check.json`);
1333
1331
  }
@@ -1362,7 +1360,8 @@ function claudeWakeHookStatus(options) {
1362
1360
  if (!SESSION_UUID.test(options.sessionId)) return unavailable;
1363
1361
  const sessionId = options.sessionId.toLowerCase();
1364
1362
  const env = options.env ?? process.env;
1365
- const read = readManagedFile(join(resolve(env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude")), "settings.json"));
1363
+ const claudeDir = resolve(env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude"));
1364
+ const read = readManagedFile(join(claudeDir, "settings.json"));
1366
1365
  if (read.state !== "present") return unavailable;
1367
1366
  const settings = JSON.parse(read.text);
1368
1367
  if (!record$1(settings) || !record$1(settings.hooks)) return unavailable;
@@ -1385,7 +1384,7 @@ function claudeWakeHookStatus(options) {
1385
1384
  const recent = (at) => {
1386
1385
  if (at === null) return false;
1387
1386
  const age = now - Date.parse(at);
1388
- return age >= -RECORD_CLOCK_SKEW_MS && age <= 6e5;
1387
+ return age >= -6e4 && age <= 6e5;
1389
1388
  };
1390
1389
  return {
1391
1390
  installed,
@@ -1574,7 +1573,8 @@ function uninstallClaudeWakeHook(options) {
1574
1573
  const agentAddress = mailAddress(options.agentAddress);
1575
1574
  if (!SESSION_UUID.test(options.sessionId)) return false;
1576
1575
  const sessionId = options.sessionId.toLowerCase();
1577
- const claudeDir = resolve((options.env ?? process.env).CLAUDE_CONFIG_DIR || join(homedir(), ".claude"));
1576
+ const env = options.env ?? process.env;
1577
+ const claudeDir = resolve(env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude"));
1578
1578
  if (!existsSync(join(claudeDir, "settings.json"))) return true;
1579
1579
  return editClaudeSettings(claudeDir, (settings) => {
1580
1580
  const hooks = settings.hooks ?? {};
@@ -1611,7 +1611,8 @@ function uninstallClaudeWakeHook(options) {
1611
1611
  hooks: siblings
1612
1612
  }] : [];
1613
1613
  });
1614
- nextHooks[PENDING_EVENT] = (hooks[PENDING_EVENT] ?? []).flatMap((entry) => {
1614
+ const pendingEntries = hooks[PENDING_EVENT];
1615
+ nextHooks[PENDING_EVENT] = (pendingEntries ?? []).flatMap((entry) => {
1615
1616
  if (!record$1(entry) || !Array.isArray(entry.hooks)) return [entry];
1616
1617
  const siblings = entry.hooks.filter((candidate) => !isOwnPendingHook(candidate));
1617
1618
  if (siblings.length === entry.hooks.length) return [entry];
@@ -1644,6 +1645,7 @@ const INVITATION_INVALID = "Primitive rejected this invitation as invalid. Ask t
1644
1645
  * is safe to discard every local trace of the attempt.
1645
1646
  */
1646
1647
  var AgentInvitationRejectedError = class extends AgentConnectionSetupError {
1648
+ reason;
1647
1649
  constructor(message, reason) {
1648
1650
  super(message);
1649
1651
  this.reason = reason;
@@ -1800,7 +1802,8 @@ function agentConnectionStatus(configDir, profileName, env = process.env) {
1800
1802
  scope,
1801
1803
  threadId: session
1802
1804
  });
1803
- const mailOwner = readSharedMailOwner({ directory: join(configDir, "shared-mail", createHash("sha256").update(scope).digest("hex")) });
1805
+ const sharedDirectory = join(configDir, "shared-mail", createHash("sha256").update(scope).digest("hex"));
1806
+ const mailOwner = readSharedMailOwner({ directory: sharedDirectory });
1804
1807
  return {
1805
1808
  mode,
1806
1809
  sessionId: session,
@@ -2034,6 +2037,7 @@ async function connectAgent(params) {
2034
2037
  //#endregion
2035
2038
  //#region src/oclif/contacts.ts
2036
2039
  var ContactsApiError = class extends Error {
2040
+ payload;
2037
2041
  directoryAvailable = false;
2038
2042
  constructor(payload) {
2039
2043
  super("Contact request failed.");
@@ -2231,6 +2235,8 @@ async function runContactRequest(client, request) {
2231
2235
  //#endregion
2232
2236
  //#region src/oclif/address-notes.ts
2233
2237
  var AddressNotesApiError = class extends Error {
2238
+ payload;
2239
+ status;
2234
2240
  constructor(payload, status) {
2235
2241
  super("Address note request failed.");
2236
2242
  this.payload = payload;
@@ -2821,7 +2827,7 @@ const RECEIVER_MODES = [
2821
2827
  "external",
2822
2828
  "poll"
2823
2829
  ];
2824
- const RECEIPT_STATUSES = new Set([
2830
+ const RECEIPT_STATUSES = /* @__PURE__ */ new Set([
2825
2831
  "queued",
2826
2832
  "submitted_to_agent",
2827
2833
  "agent_failed",
@@ -3236,7 +3242,7 @@ async function setupAgent(params) {
3236
3242
  session: params.session ?? null,
3237
3243
  receiverMode: params.receiverMode ?? "native",
3238
3244
  invitationHash: hash,
3239
- since: (/* @__PURE__ */ new Date(dependencies.now() - 15 * 6e4)).toISOString(),
3245
+ since: (/* @__PURE__ */ new Date(dependencies.now() - 9e5)).toISOString(),
3240
3246
  contactRequests: Boolean(params.contactRequests),
3241
3247
  phase: "waiting",
3242
3248
  challenge: null,
@@ -3514,8 +3520,9 @@ function defaults(options) {
3514
3520
  codexVersion: installedCodexVersion,
3515
3521
  installClaudeWakeHook,
3516
3522
  installSkill(runtime) {
3523
+ const bundle = readBundledConnectSkill(options.packageRoot);
3517
3524
  return installConnectSkill({
3518
- bundle: readBundledConnectSkill(options.packageRoot),
3525
+ bundle,
3519
3526
  runtime,
3520
3527
  project: options.project,
3521
3528
  cwd: options.cwd,
@@ -3664,29 +3671,33 @@ async function runAgentConnect(options) {
3664
3671
  };
3665
3672
  const warnings = connectWarnings(options.configDir, result.identity.profileName);
3666
3673
  let externalHook = null;
3667
- if (receiver === "external") if (verified) externalHook = dependencies.installClaudeWakeHook({
3668
- cliPath: options.cliPath,
3669
- configDir: options.configDir,
3670
- profileName: result.identity.profileName,
3671
- agentAddress: result.identity.agentAddress,
3672
- sessionId: session ?? "",
3673
- env
3674
- });
3675
- else skipped.push({
3676
- step: "receiver",
3677
- reason: "pending_verification"
3678
- });
3674
+ if (receiver === "external") {
3675
+ if (verified) externalHook = dependencies.installClaudeWakeHook({
3676
+ cliPath: options.cliPath,
3677
+ configDir: options.configDir,
3678
+ profileName: result.identity.profileName,
3679
+ agentAddress: result.identity.agentAddress,
3680
+ sessionId: session ?? "",
3681
+ env
3682
+ });
3683
+ else skipped.push({
3684
+ step: "receiver",
3685
+ reason: "pending_verification"
3686
+ });
3687
+ }
3679
3688
  let mailCheck = null;
3680
- if (receiver === "native") if (result.receiving.state === "healthy") {
3681
- mailCheck = await dependencies.awaitMailCheck(profileName, startedAt);
3682
- if (mailCheck.state === "pending") skipped.push({
3683
- step: "mail_check",
3684
- reason: "not_yet_observed"
3689
+ if (receiver === "native") {
3690
+ if (result.receiving.state === "healthy") {
3691
+ mailCheck = await dependencies.awaitMailCheck(profileName, startedAt);
3692
+ if (mailCheck.state === "pending") skipped.push({
3693
+ step: "mail_check",
3694
+ reason: "not_yet_observed"
3695
+ });
3696
+ } else skipped.push({
3697
+ step: "receiver",
3698
+ reason: verified ? "not_ready" : "pending_verification"
3685
3699
  });
3686
- } else skipped.push({
3687
- step: "receiver",
3688
- reason: verified ? "not_ready" : "pending_verification"
3689
- });
3700
+ }
3690
3701
  const pendingPath = join(agentProfileDirectory(options.configDir, profileName), PENDING_AGENT_INFO_FILE);
3691
3702
  const noteValue = agentInfo ?? readPendingAgentInfo(pendingPath);
3692
3703
  let agentInfoState = "not_requested";
@@ -4109,7 +4120,7 @@ async function enableAgentContactRequests(options) {
4109
4120
  return "unavailable";
4110
4121
  }
4111
4122
  const after = await readPolicy();
4112
- if (!after || after.agent_policy.allow_contact_requests !== true || after.allow_contact_requests !== true || !after.contact_request_since || !after.contact_request_generation || JSON.stringify(policyRuleInputs(after.agent_policy.rules)) !== JSON.stringify(rules)) return "unavailable";
4123
+ if (after?.agent_policy.allow_contact_requests !== true || after.allow_contact_requests !== true || !after.contact_request_since || !after.contact_request_generation || JSON.stringify(policyRuleInputs(after.agent_policy.rules)) !== JSON.stringify(rules)) return "unavailable";
4113
4124
  return "enabled";
4114
4125
  }
4115
4126
  async function readOwnerConnection(enrollment, params, deadline, listed) {
@@ -4175,7 +4186,7 @@ async function confirmOwnerConnection(enrollment, params, listed) {
4175
4186
  last = await readOwnerConnection(enrollment, params, deadline, listed);
4176
4187
  if (last === "connected" || last === "revoked" || last === "owner_inactive") return last;
4177
4188
  const remaining = deadline - Date.now();
4178
- if (remaining <= 0 || attempt === CONFIRMATION_MAX_ATTEMPTS - 1) break;
4189
+ if (remaining <= 0 || attempt === 39) break;
4179
4190
  await (params.confirmationSleep ?? ((milliseconds) => setTimeout$1(milliseconds)))(Math.min(3e3, remaining));
4180
4191
  }
4181
4192
  return last;
@@ -4580,7 +4591,7 @@ function runtimeSessionId(runtime, env, configDir, ompSession = ompProcessSessio
4580
4591
  * not sessions a person works in, so they get no address. Any other or
4581
4592
  * missing value is treated as interactive.
4582
4593
  */
4583
- const HEADLESS_CLAUDE_ENTRYPOINTS = new Set([
4594
+ const HEADLESS_CLAUDE_ENTRYPOINTS = /* @__PURE__ */ new Set([
4584
4595
  "sdk-cli",
4585
4596
  "sdk-ts",
4586
4597
  "sdk-py",
@@ -4715,7 +4726,7 @@ function profilesBoundToSession(configDir, sessionId, ownProfile, mode) {
4715
4726
  function connectedProfilesForSession(configDir, session, exclude) {
4716
4727
  const sessionId = session.trim().toLowerCase();
4717
4728
  if (!SESSION_UUID.test(sessionId)) return [];
4718
- const candidates = new Set([`session-${sessionId}`]);
4729
+ const candidates = /* @__PURE__ */ new Set([`session-${sessionId}`]);
4719
4730
  const record = readSessionRecord(configDir, sessionId);
4720
4731
  if (record) candidates.add(record.profile);
4721
4732
  try {
@@ -4781,7 +4792,7 @@ async function revokeWithMemberLogin(configDir, address, fetchImpl = fetch) {
4781
4792
  }
4782
4793
  }
4783
4794
  /** Enrollment saves its state before any request, so a quiet record this old created nothing. */
4784
- const ENROLLMENT_SETTLED_MS = 10 * 6e4;
4795
+ const ENROLLMENT_SETTLED_MS = 6e5;
4785
4796
  async function disconnectSessionAgent(configDir, record, deps, env, fetchImpl, enrollmentSettled = false) {
4786
4797
  try {
4787
4798
  if (loadConnectedAgentProfile(configDir, record.profile)) {
@@ -5128,7 +5139,7 @@ async function endSession(options) {
5128
5139
  let managed = false;
5129
5140
  let alreadyDone = false;
5130
5141
  const record = await updateSessionRecord(options.configDir, sessionId, (current) => {
5131
- if (!current || current.createdBy !== "session-register") return current;
5142
+ if (current?.createdBy !== "session-register") return current;
5132
5143
  managed = true;
5133
5144
  if (current.endedAt && current.disconnect === "done") {
5134
5145
  alreadyDone = true;
@@ -1,6 +1,6 @@
1
- import { F as wakeReadCommand, P as skillFirstLine, Y as wakeInteractionSentence, un as downloadEmailAttachmentPart } from "./api-command-CQRMWPkg.js";
2
- import { _ as acquireListenLock, g as ListenStateError, y as listenIdentity } from "./shared-mail-files-SPPcis9g.js";
3
- import { _ as isTrustedSender, c as classifySignalContent, g as isEmailReceivedEvent, v as parseWebhookEvent } from "./repeats-D2xtLium-DmtVD6ol.js";
1
+ import { _ as isTrustedSender, c as classifySignalContent, g as isEmailReceivedEvent, v as parseWebhookEvent } from "./repeats-x4QM2yoG-De3MV3st.js";
2
+ import { F as wakeReadCommand, P as skillFirstLine, Y as wakeInteractionSentence, un as downloadEmailAttachmentPart } from "./api-command-0FiEAuQi.js";
3
+ import { _ as acquireListenLock, g as ListenStateError, y as listenIdentity } from "./shared-mail-files-MwlVE90c.js";
4
4
  import { closeSync, copyFileSync, existsSync, fsyncSync, lstatSync, mkdirSync, openSync, opendirSync, readFileSync, readdirSync, readlinkSync, renameSync, rmSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
5
5
  import { createHash, randomUUID, scryptSync } from "node:crypto";
6
6
  import { dirname, isAbsolute, join, normalize, resolve } from "node:path";
@@ -27,7 +27,8 @@ function detectAgentRuntime(session, env = process.env) {
27
27
  function connectSkillTarget(options) {
28
28
  const env = options.env ?? process.env;
29
29
  const cwd = resolve(options.cwd ?? process.cwd());
30
- return join(options.runtime === "claude" ? options.project ? join(cwd, ".claude") : resolve(env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude")) : options.project ? join(cwd, ".agents") : resolve(env.CODEX_HOME || join(homedir(), ".codex")), "skills", CONNECT_SKILL_NAME);
30
+ const root = options.runtime === "claude" ? options.project ? join(cwd, ".claude") : resolve(env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude")) : options.project ? join(cwd, ".agents") : resolve(env.CODEX_HOME || join(homedir(), ".codex"));
31
+ return join(root, "skills", CONNECT_SKILL_NAME);
31
32
  }
32
33
  /** A path printed into agent instructions stays on one line. */
33
34
  function printablePath(value) {
@@ -290,6 +291,7 @@ function installConnectSkill(options) {
290
291
  //#endregion
291
292
  //#region src/oclif/notify-session-errors.ts
292
293
  var NativeSessionError = class extends ListenStateError {
294
+ submitted;
293
295
  constructor(message, submitted = false) {
294
296
  super(message);
295
297
  this.submitted = submitted;
@@ -399,7 +401,7 @@ async function connectNativeSession(options) {
399
401
  }
400
402
  options.signal.throwIfAborted();
401
403
  const socket = new WebSocket(`ws+unix://${identity.targetPath}:/`, {
402
- maxPayload: 8 * 1024 * 1024,
404
+ maxPayload: 8388608,
403
405
  handshakeTimeout: timeoutMs,
404
406
  followRedirects: false
405
407
  });
@@ -555,7 +557,7 @@ async function connectNativeSession(options) {
555
557
  }
556
558
  beforeDispatch();
557
559
  try {
558
- const turn = record(record(await request("turn/start", {
560
+ const result = record(await request("turn/start", {
559
561
  threadId: options.threadId,
560
562
  input: [],
561
563
  toolOutput: {
@@ -563,7 +565,8 @@ async function connectNativeSession(options) {
563
565
  namespace: "primitive",
564
566
  output: text
565
567
  }
566
- })).turn);
568
+ }));
569
+ const turn = record(result.turn);
567
570
  if (typeof turn.id !== "string" || turn.id.length === 0 || !Array.isArray(turn.items) || typeof turn.status !== "string" || ![
568
571
  "completed",
569
572
  "interrupted",
@@ -716,7 +719,8 @@ function index(value) {
716
719
  };
717
720
  }
718
721
  function stateDirectory(configDir, scope, threadId) {
719
- return join(configDir, "session-notifications", createHash("sha256").update(JSON.stringify([scope, uuid(threadId)])).digest("hex"));
722
+ const key = createHash("sha256").update(JSON.stringify([scope, uuid(threadId)])).digest("hex");
723
+ return join(configDir, "session-notifications", key);
720
724
  }
721
725
  function privateDirectory(path) {
722
726
  const info = lstatSync(path);
@@ -1,6 +1,6 @@
1
- import { A as readThreadContext, Gt as createAuthenticatedCliApiClient, Tn as getSentEmail } from "../api-command-CQRMWPkg.js";
2
- import { _ as acquireListenLock } from "../shared-mail-files-SPPcis9g.js";
3
- import { t as sendSignal } from "../signal-command-DNAhZicf.js";
1
+ import { A as readThreadContext, Gt as createAuthenticatedCliApiClient, Tn as getSentEmail } from "../api-command-0FiEAuQi.js";
2
+ import { _ as acquireListenLock } from "../shared-mail-files-MwlVE90c.js";
3
+ import { t as sendSignal } from "../signal-command-COQff2Vq.js";
4
4
  import { AUTO_SIGNAL_KIND_ENV, AUTO_WORKING_RENEW_MS, autoSignalsDisabled, clearWorkingSending, markWorkingSending, readAutoClaim, readWorkingLease, recordRenewer, stopWorkingLease, writeWorkingLease } from "./auto-signals.js";
5
5
  import { join } from "node:path";
6
6
  import { homedir } from "node:os";