primcli 3.0.0-preview.23 → 3.0.0-preview.25

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.
@@ -49,7 +49,7 @@ const COMMAND_RENAMES = {
49
49
  "account:leave-organization": "roles-and-members:leave",
50
50
  "account:show": "account:get",
51
51
  "account:update-account": "account:update",
52
- "activity:list-activity-objects": "activity:list",
52
+ "activity:list-activity-objects": "activity:objects",
53
53
  "address-notes:delete-address-note": "address-notes:delete",
54
54
  "address-notes:get-address-note": "address-notes:get",
55
55
  "address-notes:get-public-address-note": "address-notes:get-public",
@@ -15,6 +15,50 @@ import { dirname, join, resolve } from "node:path";
15
15
  * `ReceivedEmail` type from the webhook parsing surface.
16
16
  */
17
17
  const DEFAULT_API_BASE_URL = "https://api.primitive.dev/v1";
18
+ const PRIMITIVE_REASON_HEADER = "X-Primitive-Reason";
19
+ const PRIMITIVE_RUN_ID_HEADER = "X-Primitive-Run-Id";
20
+ const MAX_ACTIVITY_REASON_LENGTH = 500;
21
+ const ACTIVITY_RUN_ID_REGEX = /^[A-Za-z0-9._:/-]{1,128}$/;
22
+ function trimAsciiSpaceTab(value) {
23
+ let start = 0;
24
+ let end = value.length;
25
+ while (start < end && (value[start] === " " || value[start] === " ")) start += 1;
26
+ while (end > start && (value[end - 1] === " " || value[end - 1] === " ")) end -= 1;
27
+ return value.slice(start, end);
28
+ }
29
+ /** Validate and normalize an X-Primitive-Reason header value. */
30
+ function validateActivityReason(raw) {
31
+ if (/[\r\n\0]/.test(raw)) throw new TypeError("reason must not contain newline or null control characters");
32
+ const normalized = trimAsciiSpaceTab(raw.replace(/[ \t]+/g, " "));
33
+ if (!normalized) throw new TypeError("reason must not be empty");
34
+ for (let i = 0; i < normalized.length; i += 1) {
35
+ const code = normalized.charCodeAt(i);
36
+ if (code < 32 || code > 126) throw new TypeError("reason must contain only printable ASCII characters");
37
+ }
38
+ if (normalized.length > MAX_ACTIVITY_REASON_LENGTH) throw new TypeError(`reason must be at most ${MAX_ACTIVITY_REASON_LENGTH} characters`);
39
+ return normalized;
40
+ }
41
+ /** Validate and normalize an X-Primitive-Run-Id header value. */
42
+ function validateActivityRunId(raw) {
43
+ const trimmed = trimAsciiSpaceTab(raw);
44
+ if (!trimmed || !ACTIVITY_RUN_ID_REGEX.test(trimmed)) throw new TypeError("runId must be 1 to 128 characters matching [A-Za-z0-9._:/-]");
45
+ return trimmed;
46
+ }
47
+ function mergeDefaultActivityHeaders(existing, reason, runId) {
48
+ if (reason === void 0 && runId === void 0) return existing;
49
+ const headers = new Headers();
50
+ if (existing instanceof Headers) existing.forEach((value, key) => {
51
+ headers.set(key, value);
52
+ });
53
+ else if (Array.isArray(existing)) {
54
+ for (const [key, value] of existing) if (value !== void 0 && value !== null) headers.set(key, String(value));
55
+ } else if (existing && typeof existing === "object") {
56
+ for (const [key, value] of Object.entries(existing)) if (value !== void 0 && value !== null) headers.set(key, String(value));
57
+ }
58
+ if (reason !== void 0) headers.set(PRIMITIVE_REASON_HEADER, validateActivityReason(reason));
59
+ if (runId !== void 0) headers.set(PRIMITIVE_RUN_ID_HEADER, validateActivityRunId(runId));
60
+ return Object.fromEntries(headers.entries());
61
+ }
18
62
  function createDefaultAuth(apiKey) {
19
63
  return (security) => {
20
64
  if (security.type === "http" && security.scheme === "bearer") return apiKey;
@@ -23,10 +67,12 @@ function createDefaultAuth(apiKey) {
23
67
  var PrimitiveApiClient = class {
24
68
  client;
25
69
  constructor(options = {}) {
26
- const { apiKey, auth, apiBaseUrl = DEFAULT_API_BASE_URL, ...config } = options;
70
+ const { apiKey, auth, apiBaseUrl = DEFAULT_API_BASE_URL, reason, runId, headers, ...config } = options;
27
71
  const resolvedAuth = auth ?? createDefaultAuth(apiKey);
72
+ const resolvedHeaders = mergeDefaultActivityHeaders(headers, reason, runId);
28
73
  this.client = createClient(createConfig({
29
74
  ...config,
75
+ ...resolvedHeaders !== void 0 ? { headers: resolvedHeaders } : {},
30
76
  auth: resolvedAuth,
31
77
  baseUrl: apiBaseUrl
32
78
  }));
@@ -316,6 +362,7 @@ function parseStoredAgentPass(raw) {
316
362
  ...typeof raw.purpose === "string" ? { purpose: raw.purpose } : {},
317
363
  ...typeof raw.profile_hint === "string" ? { profile_hint: raw.profile_hint } : {},
318
364
  ...typeof raw.mcp_url === "string" ? { mcp_url: raw.mcp_url } : {},
365
+ ...typeof raw.manage_url === "string" ? { manage_url: raw.manage_url } : {},
319
366
  expires_at: raw.expires_at,
320
367
  slice_summary: typeof raw.slice_summary === "string" ? raw.slice_summary : null,
321
368
  claimed_at: typeof raw.claimed_at === "string" ? raw.claimed_at : (/* @__PURE__ */ new Date()).toISOString(),
@@ -375,7 +422,7 @@ function loadActiveAgentPass(params) {
375
422
  if (explicitProfile) throw new AgentPassAuthError(`Access Pass profile "${explicitProfile}" selected by ${AGENT_PASS_PROFILE_ENV} is not saved on this machine. Run \`primitive connect --profile ${explicitProfile} <url>\` or unset ${AGENT_PASS_PROFILE_ENV}.`);
376
423
  return null;
377
424
  }
378
- if (isAgentPassExpired(pass, params.now)) throw new AgentPassAuthError(`The Primitive Access Pass bound to ${slot.binding.kind === "session" ? "this session" : slot.binding.kind === "profile" ? `profile "${slot.binding.profile}"` : "this machine"} (${pass.label}) has ${pass.revoked_at ? "been revoked" : `expired at ${pass.expires_at}`}. Refusing to fall back to any other login. Request a fresh Access Pass and run \`primitive connect <url>\`, or run \`primitive disconnect --local-only\` to clear the binding.`);
425
+ if (pass.revoked_at) throw new AgentPassAuthError(`The Primitive Access Pass bound to ${slot.binding.kind === "session" ? "this session" : slot.binding.kind === "profile" ? `profile "${slot.binding.profile}"` : "this machine"} (${pass.label}) has been revoked. Refusing to fall back to any other login. Request a fresh Access Pass and run \`primitive connect <url>\`, or run \`primitive disconnect --local-only\` to clear the binding.`);
379
426
  return {
380
427
  pass,
381
428
  path: slot.path
@@ -454,6 +501,7 @@ async function claimAccessPassRemote(params) {
454
501
  purpose,
455
502
  profile_hint: typeof data.profile_hint === "string" && data.profile_hint.trim() ? data.profile_hint.trim() : null,
456
503
  mcp_url: typeof data.mcp_url === "string" && data.mcp_url.trim() ? data.mcp_url.trim() : null,
504
+ manage_url: typeof data.manage_url === "string" && data.manage_url.trim() ? data.manage_url.trim() : null,
457
505
  expires_at: expiresAt,
458
506
  slice_summary: deriveSliceSummary(data, grantSummary),
459
507
  grant_summary: grantSummary,
@@ -1,12 +1,12 @@
1
- import { B as parseConnectedAgentProfile, F as agentProfileName, H as profileAlreadyConnectedMessage, I as agentProfilesDirectory, L as connectedAgentIdentity, M as AGENT_PROFILE_ENV, N as AgentConnectionSetupError, P as agentProfileDirectory, R as connectedApiBaseUrl, V as parseOwnerMemberAddress, W as saveConnectedAgentProfile, at as detectAgentRuntime, ct as PrimitiveApiClient, x as loadCliCredentials, z as loadConnectedAgentProfile } from "./cli-config-DUQEYQ42.js";
2
- import { An as putAgentContact, Ft as getContact, Gn as sendEmail, Hn as searchEmails, Mn as putContact, Pt as getAgentContactPolicy, St as deleteContact, an as listAgentContacts, fr as __exportAll, in as listAgentConnections, jn as putAgentContactPolicy, sn as listContacts, tn as inviteAgentConnection, un as listDomains, wn as listSentEmails, xt as deleteAgentContact, zt as getEmail } from "./repeats-Dj_o6c-X-x61TNLz-.js";
3
- import { bn as refreshStoredCliCredentials, jt as defaultConnectionName, kt as cliInvocation, xn as refuseOrgSelectionForProfile } from "./api-command-CP8ir5Pv.js";
1
+ import { B as parseConnectedAgentProfile, F as agentProfileName, H as profileAlreadyConnectedMessage, I as agentProfilesDirectory, L as connectedAgentIdentity, M as AGENT_PROFILE_ENV, N as AgentConnectionSetupError, P as agentProfileDirectory, R as connectedApiBaseUrl, V as parseOwnerMemberAddress, W as saveConnectedAgentProfile, at as detectAgentRuntime, ct as PrimitiveApiClient, x as loadCliCredentials, z as loadConnectedAgentProfile } from "./cli-config-D2MU7PiU.js";
2
+ import { An as putAgentContact, Ft as getContact, Gn as sendEmail, Hn as searchEmails, Mn as putContact, Pt as getAgentContactPolicy, St as deleteContact, an as listAgentContacts, fr as __exportAll, in as listAgentConnections, jn as putAgentContactPolicy, sn as listContacts, tn as inviteAgentConnection, un as listDomains, wn as listSentEmails, xt as deleteAgentContact, zt as getEmail } from "./repeats-Dj_o6c-X-CK1wU9lP.js";
3
+ import { Sn as refuseOrgSelectionForProfile, jt as defaultConnectionName, kt as cliInvocation, xn as refreshStoredCliCredentials } from "./api-command-DhY2wrh5.js";
4
4
  import { _ as acquireListenLock, b as listenLockHeld, c as mailTime, d as readMailJson, f as removeMailFile, g as ListenStateError, h as writeMailJson, i as mailId, l as privateMailDirectory, o as mailObject, p as syncMailDirectory, r as mailAddress, s as mailString } from "./shared-mail-files-BAQSGxxz.js";
5
- import { C as readBundledConnectSkill, a as NotificationRetryError, b as installSkill, d as SESSION_UUID, f as connectNativeSession, m as NativeSessionDisconnectedError, p as defaultSessionSocket, t as notificationScope } from "./notify-session-Dx54UpkT.js";
5
+ import { a as NotificationRetryError, d as SESSION_UUID, f as connectNativeSession, m as NativeSessionDisconnectedError, p as defaultSessionSocket, t as notificationScope, w as readBundledConnectSkill, x as installSkill } from "./notify-session-DrgOcIT6.js";
6
6
  import { a as backgroundListenStatus, d as stopBackgroundListen } from "./listen-background-DyBYca28.js";
7
7
  import { t as readSharedMailOwner } from "./shared-mail-watch-DdtgJOrV.js";
8
8
  import { withoutOrgSelection } from "./oclif/global-org-flag.js";
9
- import { o as scopedChatSenderTrust } from "./scoped-chat-Bss3OjFI.js";
9
+ import { o as scopedChatSenderTrust } from "./scoped-chat-DN0qj4AY.js";
10
10
  import { accessSync, chmodSync, closeSync, constants, copyFileSync, existsSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, rmdirSync, statSync, unlinkSync, writeFileSync } from "node:fs";
11
11
  import { createHash, randomUUID } from "node:crypto";
12
12
  import { basename, delimiter, dirname, isAbsolute, join, resolve } from "node:path";
@@ -1,5 +1,5 @@
1
- import { _ as isTrustedSender, c as classifySignalContent, g as isEmailReceivedEvent, kt as downloadEmailAttachmentPart, v as parseWebhookEvent } from "./repeats-Dj_o6c-X-x61TNLz-.js";
2
- import { R as skillFirstLine, et as wakeInteractionSentence, z as wakeReadCommand } from "./api-command-CP8ir5Pv.js";
1
+ import { _ as isTrustedSender, c as classifySignalContent, g as isEmailReceivedEvent, kt as downloadEmailAttachmentPart, v as parseWebhookEvent } from "./repeats-Dj_o6c-X-CK1wU9lP.js";
2
+ import { R as skillFirstLine, et as wakeInteractionSentence, z as wakeReadCommand } from "./api-command-DhY2wrh5.js";
3
3
  import { _ as acquireListenLock, g as ListenStateError, y as listenIdentity } from "./shared-mail-files-BAQSGxxz.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";
@@ -1483,4 +1483,4 @@ async function openSessionNotifications(options) {
1483
1483
  }
1484
1484
  var ContactNoticeSuppressed = class extends Error {};
1485
1485
  var ContactNoticeDeferred = class extends Error {};
1486
- export { readBundledConnectSkill as C, installedVersion as S, NotificationOutcomeUnknownError as _, NotificationRetryError as a, installSkill as b, readConversationStatusContent as c, SESSION_UUID as d, connectNativeSession as f, NativeSessionNotLoadedError as g, NativeSessionError as h, notificationReceiptPage as i, createListenHandler as l, NativeSessionDisconnectedError as m, notificationSenders as n, isRoutineNotificationContent as o, defaultSessionSocket as p, openSessionNotifications as r, notificationPartReader as s, notificationScope as t, readableDelivery as u, bundledSkillNames as v, readBundledSkill as w, installedConnectSkillFile as x, connectSkillTarget as y };
1486
+ export { installedVersion as C, installedConnectSkillFile as S, readBundledSkill as T, NotificationOutcomeUnknownError as _, NotificationRetryError as a, connectSkillTarget as b, readConversationStatusContent as c, SESSION_UUID as d, connectNativeSession as f, NativeSessionNotLoadedError as g, NativeSessionError as h, notificationReceiptPage as i, createListenHandler as l, NativeSessionDisconnectedError as m, notificationSenders as n, isRoutineNotificationContent as o, defaultSessionSocket as p, openSessionNotifications as r, notificationPartReader as s, notificationScope as t, readableDelivery as u, CONNECT_SKILL_NAME as v, readBundledConnectSkill as w, installSkill as x, bundledSkillNames as y };
@@ -1,8 +1,8 @@
1
- import { Qt as getSentEmail } from "../repeats-Dj_o6c-X-x61TNLz-.js";
2
- import { P as readThreadContext, vn as createAuthenticatedCliApiClient } from "../api-command-CP8ir5Pv.js";
1
+ import { Qt as getSentEmail } from "../repeats-Dj_o6c-X-CK1wU9lP.js";
2
+ import { P as readThreadContext, vn as createAuthenticatedCliApiClient } from "../api-command-DhY2wrh5.js";
3
3
  import { AUTO_SIGNAL_KIND_ENV, AUTO_WORKING_RENEW_MS, autoSignalsDisabled, clearWorkingSending, markWorkingSending, readAutoClaim, readWorkingLease, recordRenewer, stopWorkingLease, writeWorkingLease } from "./auto-signals.js";
4
4
  import { _ as acquireListenLock } from "../shared-mail-files-BAQSGxxz.js";
5
- import { t as sendSignal } from "../signal-command-CA55RTJh.js";
5
+ import { t as sendSignal } from "../signal-command-BmxZqCot.js";
6
6
  import { join } from "node:path";
7
7
  import { homedir } from "node:os";
8
8
  // src/oclif/auto-signal-worker.ts
@@ -1,4 +1,4 @@
1
- import { n as isPlainChatReply, o as scopedChatSenderTrust } from "../scoped-chat-Bss3OjFI.js";
1
+ import { n as isPlainChatReply, o as scopedChatSenderTrust } from "../scoped-chat-DN0qj4AY.js";
2
2
  import { d as readMailJson, h as writeMailJson, i as mailId, l as privateMailDirectory, r as mailAddress } from "../shared-mail-files-BAQSGxxz.js";
3
3
  import { existsSync, readFileSync, readdirSync, unlinkSync, writeFileSync } from "node:fs";
4
4
  import { randomUUID } from "node:crypto";
@@ -1,4 +1,4 @@
1
- import { n as COMMAND_RENAMES } from "../cli-command-names-DteMqL-H.js";
1
+ import { n as COMMAND_RENAMES } from "../cli-command-names-DiNDwwDX.js";
2
2
  import { i as jsonOutputRequested } from "../json-output-BMZrLH47.js";
3
3
  // src/oclif/command-not-found.ts
4
4
  /** At most this many commands are suggested for one word. */