primcli 3.0.0-preview.25 → 3.0.0-preview.27
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/dist/{api-command-DhY2wrh5.js → api-command-B-nuABGm.js} +105 -46
- package/dist/{cli-command-names-DiNDwwDX.js → cli-command-names-no0f7d7s.js} +6 -0
- package/dist/{cli-config-D2MU7PiU.js → cli-config-CwZJQIcn.js} +283 -23
- package/dist/{machine-session-BTJXO0vi.js → machine-session-1utuweTi.js} +3 -3
- package/dist/{notify-session-DrgOcIT6.js → notify-session-CM4_ZYe9.js} +1 -1
- package/dist/oclif/auto-signal-worker.js +2 -2
- package/dist/oclif/command-not-found.js +1 -1
- package/dist/oclif/index.js +463 -119
- package/dist/oclif/receiver-heal.js +2 -2
- package/dist/oclif/root-signup-hint.js +1 -1
- package/dist/{signal-command-BmxZqCot.js → signal-command-D4ZIidPX.js} +2 -2
- package/dist/skills/primitive-connect/SKILL.md +5 -6
- package/dist/skills/primitive-connect/references/access-passes.md +32 -0
- package/dist/skills/primitive-connect.json +4 -3
- package/package.json +1 -1
package/dist/oclif/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { a as canonicalCommandId, c as operationCommandId, i as canonicalCliText, l as retiredCommandTarget, n as COMMAND_RENAMES, o as canonicalCommands, s as canonicalOperation, t as COMMAND_PAIR_RENAMES } from "../cli-command-names-
|
|
1
|
+
import { $ as replyExpectation, $t as readDomainsOrRefusal, A as bareAddress, An as fetchCliOrgs, At as cliInvocation, B as wakeReadCommand, Bn as operationManifest, Bt as NO_FOCUS, C as terminalApprovalIo, Cn as refuseOrgSelectionForProfile, Ct as sendOutcomeExitCode, D as listenForCopyHotkey, Dn as RESTRICTED_ROLE_NOTE, Dt as successfulSendOutcome, E as formatBrowserLoginInstructions, En as CliOrgRefusedError, Et as serializeErrorPayload, F as readThreadContext, Fn as switchCurrentOrg, Ft as loadSkillLine, G as clearReadPendingMail, Gn as validateActivityReason, Gt as focusForCorpus, H as wakeRelationship, Hn as PRIMITIVE_RUN_ID_HEADER, Ht as focusEmptyHint, I as sentInThread, In as routeWarningLines, It as currentMailSessionKey, J as recordPendingMail, Jt as loadSavedFocus, K as pendingMailPath, Kn as validateActivityRunId, Kt as focusProfile, L as serverMuted, Ln as sanitizeForTerminal, Lt as formatAlreadySentNotice, M as displayAddress, Mn as revokeUserLogin, N as formatMailWakeLine, Nn as roleKeyLabel, Nt as generatedAgentName, O as openBrowser, On as credentialsFromUserLogin, Ot as thrownErrorExitCode, P as latestOwnOutbound, Pn as roleKeyText, Pt as identitySuggestions, Q as readEmailInteraction, Qt as queryScopesItself, R as serverRelationship, Rn as shownLine, Rt as FOCUS_ENV, S as promptLine$2, Sn as refreshStoredCliCredentials, St as sendIdentityFields, T as canOfferCopyHotkey, Tn as selectedOrgFromEnv, Tt as sentHistoryWindowStart, U as claimPendingMail, Un as attachActivityContextFlags, Ut as focusFlagValues, V as wakeRecipientField, Vn as PRIMITIVE_REASON_HEADER, Vt as countFromMeta, W as clearConsumedPendingMail, Wn as cliActivityHeadersFromEnv, Wt as focusFlags, X as interactionHumanLine, Xt as normalizeDomainNames, Y as removePendingMail, Yt as manyDomainsSupported, Z as interactionNextActions, Zt as oneDomainAtATimeError, _ as writeErrorWithHints, _n as ConnectedAgentKeyRequiredError, _t as formatSendFailureSummary, a as agentPassErrorHint, an as writeFocusLine, at as apiResultHttpStatus, b as STEP_UP_TOKEN_FLAG_DESCRIPTION, bn as createCliApiClient, bt as reportSendCommandResult, c as extractErrorPayload, cn as mailReach, ct as buildThrownSendFailureEnvelope, d as isGrantRefusal, dn as isEmailId, dt as deriveSendIdempotencyKey, en as resolveDomainNames, et as replyInteractionWarning, f as networkErrorHint, fn as fetchBoundedPages, ft as excludeSignalReplies, g as surfaceUnauthorizedHint, gn as withAttachmentWait, gt as formatPriorRepliesWarning, h as runWithTiming, hn as ATTACHMENT_WAIT_MAX_MS, ht as formatPriorRepliesCheckSkipped, i as TIME_FLAG_DESCRIPTION, in as withoutFocus, it as SEND_OUTCOME_HELP, j as describeWake, jn as isBuiltInRoleKey, jt as connectNextSteps, k as explainPendingMailNotFound, kn as displayedRoleKey, l as formatErrorPayload, ln as readCallerMailFor, lt as checkPriorReplies, m as refusesCredential, mn as ATTACHMENT_WAIT_FLAG_DESCRIPTION, mt as formatDeletedEarlierSendNotice, n as API_ERROR_CODES, nn as saveFocus, nt as IDEMPOTENCY_KEY_FLAG_DESCRIPTION, o as createOperationCommand, on as withFlagSuggestion, ot as assertValidIdempotencyKey, p as readTextFileFlag, pn as withBooleanFlagValues, pt as followUpCommandPrefix, q as readPendingMail, qt as joinNames, r as PAGED_LIMIT_MAX, rn as withFocusMeta, rt as MAX_SEND_WAIT_TIMEOUT_MS, s as extractErrorCode, sn as emptyEmailListHint, st as buildFollowUpCommand, t as API_BASE_URL_FLAG_DESCRIPTION, tn as resolveFocus, u as hasControlCharacter$1, un as formatFact, ut as classifySendError, v as BROWSER_FLAG_DESCRIPTION, vt as formatSendRecordFailureSummary, w as withApproval, wn as resolveCliApiRequestConfig, wt as sendWaitClampNotice, x as approveThenRerunHint, xn as mergeHeadersCaseInsensitive, xt as sendErrorMessage, y as STEP_UP_HEADER$1, yn as createAuthenticatedCliApiClient, yt as priorRepliesThatWentOut, zn as setKnownCommands, zt as FOCUS_SERVER_SUPPORT } from "../api-command-B-nuABGm.js";
|
|
2
|
+
import { a as canonicalCommandId, c as operationCommandId, i as canonicalCliText, l as retiredCommandTarget, n as COMMAND_RENAMES, o as canonicalCommands, s as canonicalOperation, t as COMMAND_PAIR_RENAMES } from "../cli-command-names-no0f7d7s.js";
|
|
3
3
|
import { ignoreArgumentStdin } from "./command-stdin.js";
|
|
4
4
|
import { a as runStreamingJson, i as jsonOutputRequested, n as captureOutput, o as thrownErrorBody, r as guardJsonOutputCommands, t as JSON_OUTPUT_FLAG } from "../json-output-BMZrLH47.js";
|
|
5
5
|
import { $ as AUTOMATED_VALUES, $n as stopRepeatFromEmail, $t as getThread, A as collectNewAcceptedEmails, At as downloadSentAttachmentArchiveMember, B as REPLY_STATE_UNSUPPORTED_CODE, Bn as runWakeSchedule, Cn as listSentAttachmentArchiveMembers, Ct as deleteMemory, D as transientFailure, Dn as listWakeSchedules, Dt as downloadEmailAttachmentArchiveMember, E as retryingOperation, En as listWakeDispatches, Et as deleteWakeSchedule, F as lateMailReread, Fn as reorderRoutes, G as formatAwaitingCell, Gn as sendEmail, Gt as getKey, H as assertAwaitingFilterRows, Hn as searchEmails, Ht as getFunctionRouting, I as sinceFromFlags, In as replyToEmail, It as getConversation, J as isAwaitingRejectedError, Jn as setMemory, Jt as getOutboundStatus, K as formatRepliesCell, Kn as setFunctionRoute, Kt as getMemory, L as sleep$3, Ln as resendAgentSignupVerification, Lt as getCreditBalance, M as encodeReceivedAtSearchCursor, Mt as getAccessMode, N as fetchEmailSearchPage, Nn as redeemCreditCode, Nt as getAccount, O as waitOutRetryAfter, On as pollCliLogin, Ot as downloadEmailAttachmentByFilename, P as filtersFromFlags, Pn as removeDefaultNetworkMember, Pt as getAgentContactPolicy, Q as AUTOMATED_FLAG_DESCRIPTION, Qn as startCliLogin, Qt as getSentEmail, R as AWAITING_FLAG_DESCRIPTION, Rn as revokeCredential, Rt as getDefaultNetworkAgent, S as describeApiFailure, Sn as listRoutes, T as retryTransient, Tn as listWakeAuthorizations, Tt as deleteWakeAuthorization, U as awaitingRejectedError, Un as searchMemories, Ut as getFunctionTestRunTrace, V as ReplyStateUnsupportedError, Vt as getFunction, W as ensureSearchReportsReplyState, Wn as semanticSearch, Wt as getInboxStatus, Xn as startAgentClaim, Xt as getRepeatingSend, Y as queryUsesAwaiting, Yn as simulateRoute, Yt as getOwnGrant, Z as AUTOMATED_FILTER_UNSUPPORTED_CODE, Zn as startAgentSignup, Zt as getSendFrom, _n as listKeys, _t as createKey, a as REPEAT_IDLE_MAX_MINUTES, an as listAgentContacts, ar as updateRepeatingSend, b as WaitDeadlineReached, bn as listRepeatingSends, bt as createWakeSchedule, cn as listDefaultNetworkAgents, cr as updateWakeSchedule, ct as addDefaultNetworkMember, d as parseRepeatTick, dn as listEmailAttachmentArchiveMembers, dr as whoami, dt as checkDefaultNetworkContactAdmission, en as getWakeSchedule, er as testFunction, et as AutomatedFilterUnsupportedError, f as preparePresenceAliveEmail, fn as listEmails, ft as checkSendability, g as isEmailReceivedEvent, gn as listGroups, gt as createFunction, hn as listFunctions, ht as createEndpoint, i as REPEAT_EVERY_MAX_MINUTES, ir as updateKey, j as cursorFromAcceptedRows, jt as downloadSentAttachmentByFilename, k as SINCE_VALUE_HELP, kn as pullWebhookEvent, l as parseInteractionEnvelope, ln as listDefaultNetworkMembers, lr as verifyAgentClaim, lt as cancelSentEmail, m as repeatStopCommand, mn as listFunctionLogs, mt as completeWebhookEvent, nn as leaveOrganization, nr as updateDefaultNetworkMember, nt as automatedRejectedError, o as REPEAT_MAX_SENDS_MAX, on as listAgentNetworks, or as updateRoute, ot as hasAutomatedVerdict, p as prepareSignalEmail, pn as listEndpoints, pt as cliLogout, q as hasReplyState, qn as setFunctionSecret, qt as getOrgRoutingTopology, rn as listActivityObjects, rr as updateFunction, s as buildRepeatStopBody, sr as updateWakeAuthorization, st as isAutomatedRejectedError, tr as unsetFunctionRoute, tt as assertAutomatedVerdict, u as parsePresenceEnvelope, un as listDomains, ur as verifyAgentSignup, ut as cancelSentEmailByIdempotencyKey, v as parseWebhookEvent, vn as listMailboxAccess, vt as createRoute, w as pauseForTransientFailure, wn as listSentEmails, wt as deleteRoute, x as backoffDelay, xn as listRoles, y as parseFromHeader, yn as listOrganizationPeople, yt as createWakeAuthorization, z as AWAITING_VALUES, zn as rotateKey, zt as getEmail } from "../repeats-Dj_o6c-X-CK1wU9lP.js";
|
|
6
|
-
import { C as installedVersion, S as installedConnectSkillFile, T as readBundledSkill, _ as NotificationOutcomeUnknownError, a as NotificationRetryError, b as connectSkillTarget, c as readConversationStatusContent, d as SESSION_UUID$1, g as NativeSessionNotLoadedError, h as NativeSessionError, i as notificationReceiptPage, l as createListenHandler, m as NativeSessionDisconnectedError, n as notificationSenders, o as isRoutineNotificationContent, p as defaultSessionSocket, r as openSessionNotifications, s as notificationPartReader, t as notificationScope, u as readableDelivery, v as CONNECT_SKILL_NAME, w as readBundledConnectSkill, x as installSkill, y as bundledSkillNames } from "../notify-session-
|
|
7
|
-
import { $ as
|
|
6
|
+
import { C as installedVersion, S as installedConnectSkillFile, T as readBundledSkill, _ as NotificationOutcomeUnknownError, a as NotificationRetryError, b as connectSkillTarget, c as readConversationStatusContent, d as SESSION_UUID$1, g as NativeSessionNotLoadedError, h as NativeSessionError, i as notificationReceiptPage, l as createListenHandler, m as NativeSessionDisconnectedError, n as notificationSenders, o as isRoutineNotificationContent, p as defaultSessionSocket, r as openSessionNotifications, s as notificationPartReader, t as notificationScope, u as readableDelivery, v as CONNECT_SKILL_NAME, w as readBundledConnectSkill, x as installSkill, y as bundledSkillNames } from "../notify-session-CM4_ZYe9.js";
|
|
7
|
+
import { $ as agentPassMetadata, A as removeCliLockState, B as agentProfileDirectory, D as CliAuthLockedError, E as saveSignupCredentials, F as loadChatConversationByLocalId, G as loadConnectedAgentProfile, H as agentProfilesDirectory, I as saveActiveChatState, L as AGENT_ADDRESS_ENV, M as chatStatePath, N as deleteChatState, O as parseUnlockDurationSeconds, P as loadActiveChatState, Q as AgentPassAuthError, R as AGENT_PROFILE_ENV, S as loadCliCredentials, T as saveCliCredentials, V as agentProfileName, Y as requireDefaultLoginProfile, Z as AGENT_PASS_PROFILE_ENV, _ as credentialsPath, a as normalizeCliEnvironmentName, at as parseAccessPassInput, b as detectPrimitiveKeyEnvMisname, c as removeCliEnvironment, ct as revokeAccessPassRemote, d as upsertCliEnvironment, dt as detectAgentRuntime, et as agentPassTokenSha256, ft as detectRuntimeSession, g as credentialsLockPath, h as cliAccessTokenExpiresAt, i as loadCliConfig, it as loadCachedAgentPassByToken, j as writeCliLockState, k as readCliLockState, l as resolveConfigEnvironment, lt as saveAgentPass, m as acquireCliCredentialsLock, mt as PrimitiveApiClient, n as deleteCliConfig, nt as deleteAgentPass, o as parseHeaderAssignment, ot as readAgentPassFile, pt as runtimeSessionVariableList, r as emptyCliConfig, s as redactCliEnvironment, st as resolveAgentPassSlot, tt as claimAccessPassRemote, u as saveCliConfig, ut as syncAgentPassMetadataFromGrant, v as deleteCliCredentials, w as resolveCliAuth, x as hasStoredCliLogin, y as deleteCliCredentialsLock, z as AgentConnectionSetupError } from "../cli-config-CwZJQIcn.js";
|
|
8
8
|
import { C as resolveListenSubscription, S as normalizeListenOrigin, _ as acquireListenLock, a as mailLockBusy, c as mailTime, d as readMailJson, f as removeMailFile, g as ListenStateError, h as writeMailJson, i as mailId, l as privateMailDirectory, m as withMailLock, o as mailObject, u as privateMailPermissions, y as listenIdentity } from "../shared-mail-files-BAQSGxxz.js";
|
|
9
|
-
import { $ as saveConnectionName, A as ContactPolicyReadRetryError, B as AddressNotesApiError, C as RECEIVER_MODES, Ct as upsertManagedBlock, D as registrationSummary, Dt as refreshOwnerMemberAddressPeriodically, E as failedSessionRegistration, Et as addSessionReceiver, F as canonicalContactSelector, G as contactAgentAddress, H as runAddressNotesRequest, I as AgentDisconnectError, J as agentInvitationHash, K as runContactRequest, L as claimOverRevokedSetup, M as NetworkAdmissionPendingError, N as createNotificationContactPolicy, O as registrationSummaryLine, Ot as withOwnerMemberAddress, P as evaluateContactPolicy, Q as refusalAfterReplacement, R as clearRevokedAddresses, S as runAgentConnect, St as readManagedFile, T as verificationReplySubmitted, Tt as readHookLauncherWarning, U as ContactsApiError, V as addressNoteTarget, W as contactAddress, X as readAgentInvitation, Y as connectAgent, Z as receiverStatusCommand, _ as enrollmentResumes, _t as samePath, a as endSession, at as boundSessionProfiles, b as invitationProfileName, bt as inspectManagedBlock, c as pendingSessionDisconnects, ct as describeSessionHookChange, d as registerSession, dt as ephemeralCliReason, et as savedReceiver, f as retryPendingDisconnects, ft as findOnPath, g as enrollAgent, gt as repairClaudeHooks, h as staleSessionAgents, ht as readClaudeSettings, i as connectedProfilesForSession, it as recordHookMailCheck, j as NETWORK_ADMISSION_PENDING_RETRY_MS, k as waitForRegistrations, l as psProcessInfo, lt as describeSessionHookItem, m as runDetached, mt as inspectClaudeHooks, n as OMP_MAIN, nt as releaseRegistrationsForProfile, o as headlessClaudeRun, ot as claudeConfigDir, p as revokeStaleSessionAgents, pt as hasMachineSessionHooks, q as agentConnectionStatus, r as agentConnectionState, rt as installClaudeWakeHook, st as currentCliLocation, t as HOOK_END_GRACE_MS, tt as MACHINE_RUNTIMES, u as readClaudeHookInput, ut as ensureHookLauncher, v as connectWarnings, vt as writeClaudeSettings, w as externalReceivingState, wt as writeManagedFile, x as pollCheckCommand, xt as jsonIndentation, y as defaultAgentProfileName, yt as MachineFileError, z as disconnectAgent } from "../machine-session-
|
|
9
|
+
import { $ as saveConnectionName, A as ContactPolicyReadRetryError, B as AddressNotesApiError, C as RECEIVER_MODES, Ct as upsertManagedBlock, D as registrationSummary, Dt as refreshOwnerMemberAddressPeriodically, E as failedSessionRegistration, Et as addSessionReceiver, F as canonicalContactSelector, G as contactAgentAddress, H as runAddressNotesRequest, I as AgentDisconnectError, J as agentInvitationHash, K as runContactRequest, L as claimOverRevokedSetup, M as NetworkAdmissionPendingError, N as createNotificationContactPolicy, O as registrationSummaryLine, Ot as withOwnerMemberAddress, P as evaluateContactPolicy, Q as refusalAfterReplacement, R as clearRevokedAddresses, S as runAgentConnect, St as readManagedFile, T as verificationReplySubmitted, Tt as readHookLauncherWarning, U as ContactsApiError, V as addressNoteTarget, W as contactAddress, X as readAgentInvitation, Y as connectAgent, Z as receiverStatusCommand, _ as enrollmentResumes, _t as samePath, a as endSession, at as boundSessionProfiles, b as invitationProfileName, bt as inspectManagedBlock, c as pendingSessionDisconnects, ct as describeSessionHookChange, d as registerSession, dt as ephemeralCliReason, et as savedReceiver, f as retryPendingDisconnects, ft as findOnPath, g as enrollAgent, gt as repairClaudeHooks, h as staleSessionAgents, ht as readClaudeSettings, i as connectedProfilesForSession, it as recordHookMailCheck, j as NETWORK_ADMISSION_PENDING_RETRY_MS, k as waitForRegistrations, l as psProcessInfo, lt as describeSessionHookItem, m as runDetached, mt as inspectClaudeHooks, n as OMP_MAIN, nt as releaseRegistrationsForProfile, o as headlessClaudeRun, ot as claudeConfigDir, p as revokeStaleSessionAgents, pt as hasMachineSessionHooks, q as agentConnectionStatus, r as agentConnectionState, rt as installClaudeWakeHook, st as currentCliLocation, t as HOOK_END_GRACE_MS, tt as MACHINE_RUNTIMES, u as readClaudeHookInput, ut as ensureHookLauncher, v as connectWarnings, vt as writeClaudeSettings, w as externalReceivingState, wt as writeManagedFile, x as pollCheckCommand, xt as jsonIndentation, y as defaultAgentProfileName, yt as MachineFileError, z as disconnectAgent } from "../machine-session-1utuweTi.js";
|
|
10
10
|
import { a as readBeforeDeadline, c as readPresenceProjection, i as readApiBeforeDeadline, n as isPlainChatReply, o as scopedChatSenderTrust, r as isScopedChatReply, s as presenceDisposition, t as isConnectedChatCredential } from "../scoped-chat-DN0qj4AY.js";
|
|
11
11
|
import { autoSignalEligible, dispatchAutoRead, dispatchAutoWorking, haltAutoWorking, isSentSignal, readWorkingLease, restoreAutoWorking } from "./auto-signals.js";
|
|
12
|
-
import { _ as EventConnection, a as ensureSharedMailSubscription, d as createSharedMailWaiter, f as openSharedMailStore, g as otherParticipants, h as readConversationFollow, i as sharedMailScope, l as KEY_REVOKED_MESSAGE, m as followEmailConversation, n as reconcileChatSend, p as reserveSharedMailSubscription, r as openSharedMailReceiver, s as AGENT_CONNECTION_REQUIRED_MESSAGE, t as sendSignal, u as isConnectedAgentKey, v as EventReceiverError } from "../signal-command-
|
|
12
|
+
import { _ as EventConnection, a as ensureSharedMailSubscription, d as createSharedMailWaiter, f as openSharedMailStore, g as otherParticipants, h as readConversationFollow, i as sharedMailScope, l as KEY_REVOKED_MESSAGE, m as followEmailConversation, n as reconcileChatSend, p as reserveSharedMailSubscription, r as openSharedMailReceiver, s as AGENT_CONNECTION_REQUIRED_MESSAGE, t as sendSignal, u as isConnectedAgentKey, v as EventReceiverError } from "../signal-command-D4ZIidPX.js";
|
|
13
13
|
import { a as backgroundListenStatus, c as runBackgroundListen, d as stopBackgroundListen, f as verifyBackgroundListenTarget, o as backgroundListenToken, r as backgroundListenConfiguration, u as startBackgroundListen } from "../listen-background-DyBYca28.js";
|
|
14
14
|
import { ORG_SELECTION_ENV } from "./global-org-flag.js";
|
|
15
15
|
import { n as createConfig, t as createClient } from "../client.gen-6rZvmHfx.js";
|
|
16
16
|
import { Args, Command, Errors, Flags, ux } from "@oclif/core";
|
|
17
17
|
import { appendFileSync, chmodSync, closeSync, constants, cpSync, existsSync, fstatSync, fsyncSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
18
18
|
import { createHash, randomUUID, scryptSync } from "node:crypto";
|
|
19
|
-
import path, { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
19
|
+
import path, { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
|
|
20
20
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
21
21
|
import { createInterface } from "node:readline/promises";
|
|
22
22
|
import { homedir, hostname } from "node:os";
|
|
@@ -3106,6 +3106,17 @@ function endedClaimText(claim) {
|
|
|
3106
3106
|
return text !== "" && !/[\r\n]/.test(text) && text.length <= 500 ? text : "cleared";
|
|
3107
3107
|
}
|
|
3108
3108
|
// src/oclif/commands/api.ts
|
|
3109
|
+
function parseApiHeaderFlag(raw) {
|
|
3110
|
+
const colonIdx = raw.indexOf(":");
|
|
3111
|
+
const eqIdx = raw.indexOf("=");
|
|
3112
|
+
if (colonIdx > 0 && (eqIdx === -1 || colonIdx < eqIdx)) {
|
|
3113
|
+
const name = raw.slice(0, colonIdx).trim();
|
|
3114
|
+
const value = raw.slice(colonIdx + 1).trim();
|
|
3115
|
+
if (!/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/.test(name)) throw new Errors.CLIError(`Invalid header name "${name}" in -H "${raw}".`, { exit: 2 });
|
|
3116
|
+
return [name, value];
|
|
3117
|
+
}
|
|
3118
|
+
return parseHeaderAssignment(raw);
|
|
3119
|
+
}
|
|
3109
3120
|
const BLOCKED_CUSTOM_HEADERS = /* @__PURE__ */ new Set([
|
|
3110
3121
|
"authorization",
|
|
3111
3122
|
"cookie",
|
|
@@ -3234,7 +3245,7 @@ var ApiCommand = class ApiCommand extends Command {
|
|
|
3234
3245
|
}
|
|
3235
3246
|
const headers = mergeHeadersCaseInsensitive({ accept: "application/json" }, authenticated.auth.agentPass || authenticated.auth.connectedAgent ? void 0 : authenticated.requestConfig.headers, envActivityHeaders, explicitFlagsHeaders) ?? {};
|
|
3236
3247
|
for (const rawHeader of flags.header ?? []) {
|
|
3237
|
-
const [name, value] =
|
|
3248
|
+
const [name, value] = parseApiHeaderFlag(rawHeader);
|
|
3238
3249
|
const lower = name.toLowerCase();
|
|
3239
3250
|
if (BLOCKED_CUSTOM_HEADERS.has(lower)) throw new Errors.CLIError(`${name} header is managed automatically and cannot be overridden with -H.`, { exit: 1 });
|
|
3240
3251
|
for (const existingKey of Object.keys(headers)) if (existingKey.toLowerCase() === lower) delete headers[existingKey];
|
|
@@ -3255,7 +3266,7 @@ var ApiCommand = class ApiCommand extends Command {
|
|
|
3255
3266
|
}
|
|
3256
3267
|
let response;
|
|
3257
3268
|
try {
|
|
3258
|
-
response = await fetch(requestUrl.toString(), {
|
|
3269
|
+
response = await authenticated.fetch(requestUrl.toString(), {
|
|
3259
3270
|
method,
|
|
3260
3271
|
headers,
|
|
3261
3272
|
redirect: "manual",
|
|
@@ -3283,7 +3294,15 @@ var ApiCommand = class ApiCommand extends Command {
|
|
|
3283
3294
|
}));
|
|
3284
3295
|
else if (rawBody.length > 0) process.stdout.write(rawBody.endsWith("\n") ? rawBody : `${rawBody}\n`);
|
|
3285
3296
|
else if (!response.ok && !flags.include) this.log(`HTTP ${response.status} ${response.statusText}`.trim());
|
|
3286
|
-
if (!response.ok)
|
|
3297
|
+
if (!response.ok) {
|
|
3298
|
+
if (!flags.json && authenticated.auth.source === "agent-pass" && authenticated.auth.agentPass && (response.status === 401 || response.status === 403)) {
|
|
3299
|
+
const errPayload = extractErrorPayload(parsedJson ?? { message: `HTTP ${response.status}` });
|
|
3300
|
+
const code = extractErrorCode(errPayload) ?? (response.status === 401 ? "unauthorized" : "grant_forbidden");
|
|
3301
|
+
const hint = agentPassErrorHint(authenticated.auth.agentPass, code);
|
|
3302
|
+
if (hint) process.stderr.write(`${hint}\n`);
|
|
3303
|
+
}
|
|
3304
|
+
process.exitCode = 1;
|
|
3305
|
+
}
|
|
3287
3306
|
}
|
|
3288
3307
|
};
|
|
3289
3308
|
// src/oclif/commands/billing.ts
|
|
@@ -7270,7 +7289,6 @@ var ConnectCommand = class ConnectCommand extends Command {
|
|
|
7270
7289
|
profile: Flags.string({ description: "Bind the claimed pass to a named local profile instead of auto-detecting the active session" }),
|
|
7271
7290
|
"api-base-url": Flags.string({
|
|
7272
7291
|
description: "Override the API base URL when claiming a bare pit_v1_ token",
|
|
7273
|
-
env: "PRIMITIVE_API_BASE_URL",
|
|
7274
7292
|
hidden: true
|
|
7275
7293
|
}),
|
|
7276
7294
|
json: Flags.boolean({ description: "Print safe pass metadata, preview, and guide as JSON (never prints the API key)" })
|
|
@@ -7279,7 +7297,9 @@ var ConnectCommand = class ConnectCommand extends Command {
|
|
|
7279
7297
|
const { args, flags } = await this.parse(ConnectCommand);
|
|
7280
7298
|
try {
|
|
7281
7299
|
const rawInput = args.pass ?? await readStdinText();
|
|
7282
|
-
const
|
|
7300
|
+
const hasExplicitUrl = /https?:\/\//i.test(rawInput);
|
|
7301
|
+
const effectiveBaseUrlOverride = flags["api-base-url"] ?? (hasExplicitUrl ? void 0 : process.env.PRIMITIVE_API_BASE_URL);
|
|
7302
|
+
const { token, apiBaseUrl } = parseAccessPassInput(rawInput, effectiveBaseUrlOverride);
|
|
7283
7303
|
const slot = resolveAgentPassSlot({
|
|
7284
7304
|
configDir: this.config.configDir,
|
|
7285
7305
|
profile: flags.profile
|
|
@@ -7288,8 +7308,9 @@ var ConnectCommand = class ConnectCommand extends Command {
|
|
|
7288
7308
|
const tokenHash = agentPassTokenSha256(token);
|
|
7289
7309
|
try {
|
|
7290
7310
|
const existing = readAgentPassFile(slot.path);
|
|
7291
|
-
if (existing && !
|
|
7311
|
+
if (existing && !existing.revoked_at && existing.token_sha256 !== tokenHash) process.stderr.write(`Warning: replacing active Access Pass "${existing.label}" in this slot without revoking it. Run \`${revokeCommand}\` before connecting if you want to revoke the previous pass.\n`);
|
|
7292
7312
|
} catch {}
|
|
7313
|
+
if (slot.binding.kind === "default" && (hasStoredCliLogin(this.config.configDir) || Boolean(process.env.PRIMITIVE_API_KEY?.trim()))) process.stderr.write("Note: No agent session ID was detected, so this Access Pass is active as the default local binding and overrides your global CLI auth until cleared. Use `--profile <name>` to isolate it, or `primitive disconnect --local-only` when done.\n");
|
|
7293
7314
|
const cached = loadCachedAgentPassByToken({
|
|
7294
7315
|
configDir: this.config.configDir,
|
|
7295
7316
|
token
|
|
@@ -7309,6 +7330,7 @@ var ConnectCommand = class ConnectCommand extends Command {
|
|
|
7309
7330
|
this.log(JSON.stringify({
|
|
7310
7331
|
status: "reused",
|
|
7311
7332
|
pass: meta,
|
|
7333
|
+
skill_command: "primitive skill",
|
|
7312
7334
|
revoke_command: revokeCommand
|
|
7313
7335
|
}));
|
|
7314
7336
|
return;
|
|
@@ -7318,6 +7340,7 @@ var ConnectCommand = class ConnectCommand extends Command {
|
|
|
7318
7340
|
this.log(`Expires at: ${meta.expires_at}`);
|
|
7319
7341
|
if (meta.slice_summary) this.log(`Scope: ${meta.slice_summary}`);
|
|
7320
7342
|
if (meta.manage_url) this.log(`Manage / extend / promote: ${meta.manage_url}`);
|
|
7343
|
+
this.log("Live scoped skill: `primitive skill` (or `primitive skill install`)");
|
|
7321
7344
|
this.log(`This pass expires automatically. Only run \`${revokeCommand}\` if explicitly asked to revoke access early.`);
|
|
7322
7345
|
return;
|
|
7323
7346
|
}
|
|
@@ -7357,6 +7380,7 @@ var ConnectCommand = class ConnectCommand extends Command {
|
|
|
7357
7380
|
pass: meta,
|
|
7358
7381
|
preview: claimed.preview,
|
|
7359
7382
|
guide: claimed.guide,
|
|
7383
|
+
skill_command: "primitive skill",
|
|
7360
7384
|
revoke_command: revokeCommand
|
|
7361
7385
|
}));
|
|
7362
7386
|
return;
|
|
@@ -7366,6 +7390,7 @@ var ConnectCommand = class ConnectCommand extends Command {
|
|
|
7366
7390
|
this.log(`Expires at: ${meta.expires_at}`);
|
|
7367
7391
|
if (meta.slice_summary) this.log(`Scope: ${meta.slice_summary}`);
|
|
7368
7392
|
if (meta.manage_url) this.log(`Manage / extend / promote: ${meta.manage_url}`);
|
|
7393
|
+
this.log("Live scoped skill: `primitive skill` (or `primitive skill install`)");
|
|
7369
7394
|
if (typeof claimed.guide === "string" && claimed.guide.trim()) {
|
|
7370
7395
|
this.log("");
|
|
7371
7396
|
this.log(claimed.guide.trim());
|
|
@@ -7851,9 +7876,15 @@ var DisconnectCommand = class DisconnectCommand extends Command {
|
|
|
7851
7876
|
const detail = error instanceof Error ? error.message : String(error);
|
|
7852
7877
|
throw new AgentPassAuthError(`Saved Access Pass could not be read for remote revocation (${detail}). Revoke it in the Primitive dashboard or re-run with --local-only to delete the local file.`);
|
|
7853
7878
|
}
|
|
7854
|
-
|
|
7879
|
+
try {
|
|
7880
|
+
lstatSync(slot.path);
|
|
7881
|
+
unreadableSlot = true;
|
|
7882
|
+
} catch {
|
|
7883
|
+
unreadableSlot = false;
|
|
7884
|
+
}
|
|
7855
7885
|
}
|
|
7856
7886
|
if (!stored && !unreadableSlot) {
|
|
7887
|
+
const scopeHint = slot.binding.kind === "session" ? "this session" : slot.binding.kind === "profile" ? `profile "${slot.binding.profile}"` : "this machine";
|
|
7857
7888
|
if (flags.json) {
|
|
7858
7889
|
this.log(JSON.stringify({
|
|
7859
7890
|
status: "not_connected",
|
|
@@ -7862,7 +7893,7 @@ var DisconnectCommand = class DisconnectCommand extends Command {
|
|
|
7862
7893
|
}));
|
|
7863
7894
|
return;
|
|
7864
7895
|
}
|
|
7865
|
-
this.log(
|
|
7896
|
+
this.log(`No active Access Pass is bound to ${scopeHint}.`);
|
|
7866
7897
|
return;
|
|
7867
7898
|
}
|
|
7868
7899
|
let revoked = false;
|
|
@@ -8152,31 +8183,51 @@ function checkReceiverStart(configDir, profileName) {
|
|
|
8152
8183
|
return null;
|
|
8153
8184
|
}
|
|
8154
8185
|
}
|
|
8155
|
-
async function checkAgentPassGrant(
|
|
8186
|
+
async function checkAgentPassGrant(params) {
|
|
8187
|
+
const { apiBaseUrl, apiKey, configDir, pass } = params;
|
|
8188
|
+
const disconnectCmd = pass.binding.kind === "profile" ? `primitive disconnect --profile ${pass.binding.profile} --local-only` : "primitive disconnect --local-only";
|
|
8156
8189
|
try {
|
|
8157
8190
|
const response = await fetch(`${apiBaseUrl.replace(/\/+$/, "")}/whoami/grant`, {
|
|
8158
8191
|
method: "GET",
|
|
8159
8192
|
headers: {
|
|
8193
|
+
...cliActivityHeadersFromEnv(),
|
|
8160
8194
|
authorization: `Bearer ${apiKey}`,
|
|
8161
8195
|
accept: "application/json"
|
|
8162
8196
|
}
|
|
8163
8197
|
});
|
|
8164
8198
|
const payload = await response.json().catch(() => null);
|
|
8165
|
-
if (!response.ok)
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8199
|
+
if (!response.ok) {
|
|
8200
|
+
const detail = payload?.error && typeof payload.error === "object" ? JSON.stringify(payload.error).slice(0, 300) : `HTTP ${response.status}`;
|
|
8201
|
+
const extendHint = pass.manage_url ? ` Ask the owner to extend it at ${pass.manage_url}?action=extend&add=4h, or run \`${disconnectCmd}\` to clear the binding.` : ` Run \`${disconnectCmd}\` and reconnect with a fresh pass.`;
|
|
8202
|
+
return {
|
|
8203
|
+
syncedPass: pass,
|
|
8204
|
+
outcome: {
|
|
8205
|
+
status: "fail",
|
|
8206
|
+
message: `Access Pass rejected by API (${detail})`,
|
|
8207
|
+
hint: `The Access Pass may have expired or been revoked.${extendHint}`
|
|
8208
|
+
}
|
|
8209
|
+
};
|
|
8210
|
+
}
|
|
8211
|
+
const { pass: syncedPass, permissions } = syncAgentPassMetadataFromGrant({
|
|
8212
|
+
configDir,
|
|
8213
|
+
pass,
|
|
8214
|
+
grantData: payload?.data ?? null
|
|
8215
|
+
});
|
|
8171
8216
|
return {
|
|
8172
|
-
|
|
8173
|
-
|
|
8217
|
+
syncedPass,
|
|
8218
|
+
outcome: {
|
|
8219
|
+
status: "ok",
|
|
8220
|
+
message: permissions.length > 0 ? `verified via /whoami/grant (${permissions.length} permission${permissions.length === 1 ? "" : "s"})` : "verified via /whoami/grant"
|
|
8221
|
+
}
|
|
8174
8222
|
};
|
|
8175
8223
|
} catch (error) {
|
|
8176
8224
|
return {
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8225
|
+
syncedPass: pass,
|
|
8226
|
+
outcome: {
|
|
8227
|
+
status: "fail",
|
|
8228
|
+
message: `Could not reach /whoami/grant: ${error instanceof Error ? error.message : String(error)}`,
|
|
8229
|
+
hint: "Check network connectivity and proxy settings."
|
|
8230
|
+
}
|
|
8180
8231
|
};
|
|
8181
8232
|
}
|
|
8182
8233
|
}
|
|
@@ -8207,6 +8258,22 @@ var DoctorCommand = class DoctorCommand extends Command {
|
|
|
8207
8258
|
label: "Proxy env",
|
|
8208
8259
|
outcome: checkProxy()
|
|
8209
8260
|
});
|
|
8261
|
+
const lockState = readCliLockState(this.config.configDir);
|
|
8262
|
+
if (lockState.status === "locked") rows.push({
|
|
8263
|
+
label: "Global auth lock",
|
|
8264
|
+
outcome: {
|
|
8265
|
+
status: "ok",
|
|
8266
|
+
message: `Locked since ${lockState.lockedAt} (only Access Passes and connected profiles allowed; unlock with \`primitive unlock --for 15m\`)`
|
|
8267
|
+
}
|
|
8268
|
+
});
|
|
8269
|
+
else if (lockState.status === "temporarily_unlocked") rows.push({
|
|
8270
|
+
label: "Global auth lock",
|
|
8271
|
+
outcome: {
|
|
8272
|
+
status: "warn",
|
|
8273
|
+
message: `Temporarily unlocked until ${lockState.unlockedUntil} (auto-relocks)`,
|
|
8274
|
+
hint: "Run `primitive lock` to re-lock earlier."
|
|
8275
|
+
}
|
|
8276
|
+
});
|
|
8210
8277
|
let resolvedAuth = null;
|
|
8211
8278
|
let authError = null;
|
|
8212
8279
|
try {
|
|
@@ -8216,7 +8283,7 @@ var DoctorCommand = class DoctorCommand extends Command {
|
|
|
8216
8283
|
configDir: this.config.configDir
|
|
8217
8284
|
});
|
|
8218
8285
|
} catch (error) {
|
|
8219
|
-
if (error instanceof AgentPassAuthError) authError = error.message;
|
|
8286
|
+
if (error instanceof AgentPassAuthError || error instanceof CliAuthLockedError) authError = error.message;
|
|
8220
8287
|
else throw error;
|
|
8221
8288
|
}
|
|
8222
8289
|
const connected = resolvedAuth?.connectedAgent;
|
|
@@ -8246,7 +8313,17 @@ var DoctorCommand = class DoctorCommand extends Command {
|
|
|
8246
8313
|
});
|
|
8247
8314
|
if (!connected && apiKeyCheck.status !== "fail") {
|
|
8248
8315
|
if (activePass && resolvedAuth?.apiKey) {
|
|
8249
|
-
const grantOutcome = await checkAgentPassGrant(
|
|
8316
|
+
const { outcome: grantOutcome, syncedPass } = await checkAgentPassGrant({
|
|
8317
|
+
apiBaseUrl: resolvedAuth.apiBaseUrl,
|
|
8318
|
+
apiKey: resolvedAuth.apiKey,
|
|
8319
|
+
configDir: this.config.configDir,
|
|
8320
|
+
pass: activePass
|
|
8321
|
+
});
|
|
8322
|
+
const authRow = rows.find((r) => r.label === "Auth");
|
|
8323
|
+
if (authRow) authRow.outcome = {
|
|
8324
|
+
status: "ok",
|
|
8325
|
+
message: `Access Pass "${syncedPass.label}" (${syncedPass.mode}, expires ${syncedPass.expires_at})`
|
|
8326
|
+
};
|
|
8250
8327
|
rows.push({
|
|
8251
8328
|
label: "API auth",
|
|
8252
8329
|
outcome: grantOutcome
|
|
@@ -8401,10 +8478,7 @@ var DomainsZoneFileCommand = class DomainsZoneFileCommand extends Command {
|
|
|
8401
8478
|
if (!domainId) throw new Errors.CLIError("Could not resolve a domain id.", { exit: 1 });
|
|
8402
8479
|
let response;
|
|
8403
8480
|
try {
|
|
8404
|
-
response = await fetch(zoneFileUrl(requestConfig.resolvedApiBaseUrl, domainId, flags["outbound-only"], flags["inbound-only"]), { headers: {
|
|
8405
|
-
...requestConfig.headers ?? {},
|
|
8406
|
-
...auth.apiKey ? { authorization: `Bearer ${auth.apiKey}` } : {}
|
|
8407
|
-
} });
|
|
8481
|
+
response = await fetch(zoneFileUrl(requestConfig.resolvedApiBaseUrl, domainId, flags["outbound-only"], flags["inbound-only"]), { headers: mergeHeadersCaseInsensitive(requestConfig.headers, cliActivityHeadersFromEnv(), auth.apiKey ? { authorization: `Bearer ${auth.apiKey}` } : void 0) ?? {} });
|
|
8408
8482
|
} catch (error) {
|
|
8409
8483
|
writeErrorWithHints(error);
|
|
8410
8484
|
process.exitCode = 1;
|
|
@@ -8831,13 +8905,10 @@ async function callActivityApi(options) {
|
|
|
8831
8905
|
}
|
|
8832
8906
|
let serializedBody;
|
|
8833
8907
|
if (options.body !== void 0) serializedBody = JSON.stringify(options.body);
|
|
8834
|
-
const headers = mergeHeadersCaseInsensitive({ accept: options.rawText ? "text/csv, application/json" : "application/json" },
|
|
8835
|
-
authorization: `Bearer ${authenticated.auth.apiKey}`,
|
|
8836
|
-
...serializedBody !== void 0 ? { "content-type": "application/json" } : {}
|
|
8837
|
-
}) ?? {};
|
|
8908
|
+
const headers = mergeHeadersCaseInsensitive({ accept: options.rawText ? "text/csv, application/json" : "application/json" }, options.headers, serializedBody !== void 0 ? { "content-type": "application/json" } : void 0) ?? {};
|
|
8838
8909
|
let response;
|
|
8839
8910
|
try {
|
|
8840
|
-
response = await fetch(url.toString(), {
|
|
8911
|
+
response = await authenticated.fetch(url.toString(), {
|
|
8841
8912
|
method: options.method,
|
|
8842
8913
|
headers,
|
|
8843
8914
|
redirect: "manual",
|
|
@@ -8860,8 +8931,11 @@ async function callActivityApi(options) {
|
|
|
8860
8931
|
const sanitized = sanitizeErrorText(rawText);
|
|
8861
8932
|
if (sanitized) message = sanitized;
|
|
8862
8933
|
}
|
|
8863
|
-
const hint = code === "grant_forbidden" ? " Check whether this credential holds mail.activity:read / mail.activity:write." : code === "access_reason_required" ? " Pass --reason \"...\" or set PRIMITIVE_REASON." : "";
|
|
8864
|
-
throw new Errors.CLIError(`${message}${hint}`, {
|
|
8934
|
+
const hint = code === "grant_forbidden" ? " Check whether this credential holds mail.activity:read / mail.activity:write." : code === "access_reason_required" ? " Pass --reason \"...\" or set PRIMITIVE_REASON." : code === "feature_not_enabled" ? " Mail activity tracking is not enabled for this organization." : code === "activity_header_invalid" ? " Check --reason / PRIMITIVE_REASON (1-500 printable ASCII) and --run-id / PRIMITIVE_RUN_ID ([A-Za-z0-9._:/-], 1-128 chars)." : "";
|
|
8935
|
+
throw new Errors.CLIError(`${message}${hint}`, {
|
|
8936
|
+
exit: 1,
|
|
8937
|
+
...code ? { code } : {}
|
|
8938
|
+
});
|
|
8865
8939
|
}
|
|
8866
8940
|
if (options.rawText) return {
|
|
8867
8941
|
data: void 0,
|
|
@@ -9535,7 +9609,7 @@ async function runBrief(command, flags) {
|
|
|
9535
9609
|
isOwnSignal: (sentId) => isSentSignal(command.config.configDir, sentId),
|
|
9536
9610
|
signal: AbortSignal.timeout(3e4)
|
|
9537
9611
|
});
|
|
9538
|
-
const
|
|
9612
|
+
const activities = flags["with-activity"] ? await fetchEmailThreadActivity(command, detail.thread_id, flags, authenticated) : void 0;
|
|
9539
9613
|
const stop = !flags["no-signal"] && detail.sender_connected_agent_verified !== true && dispatchAutoWorking({
|
|
9540
9614
|
configDir: command.config.configDir,
|
|
9541
9615
|
emailId: detail.id
|
|
@@ -9543,8 +9617,8 @@ async function runBrief(command, flags) {
|
|
|
9543
9617
|
command.log(flags.json ? JSON.stringify({
|
|
9544
9618
|
...brief,
|
|
9545
9619
|
...stop ? { working_signal: { stop_command: stop } } : {},
|
|
9546
|
-
...
|
|
9547
|
-
}, null, 2) : `${renderEmailBrief(brief)}${
|
|
9620
|
+
...activities !== void 0 ? { activities } : {}
|
|
9621
|
+
}, null, 2) : `${renderEmailBrief(brief)}${activities !== void 0 ? renderThreadActivitySection(activities) : ""}${stop ? `\n${workingStopLine(stop)}` : ""}`);
|
|
9548
9622
|
await clearPendingAfterRead(command.config.configDir, detail.id, detail);
|
|
9549
9623
|
});
|
|
9550
9624
|
}
|
|
@@ -9575,10 +9649,10 @@ async function runCompact(command, flags) {
|
|
|
9575
9649
|
...flags.links !== void 0 ? { links: flags.links } : {}
|
|
9576
9650
|
});
|
|
9577
9651
|
if (readable.kind === "ok") {
|
|
9578
|
-
const
|
|
9579
|
-
command.log(JSON.stringify(
|
|
9652
|
+
const activities = flags["with-activity"] ? await fetchEmailThreadActivity(command, readable.data.thread_id, flags, authenticated) : void 0;
|
|
9653
|
+
command.log(JSON.stringify(activities !== void 0 ? {
|
|
9580
9654
|
...readable.data,
|
|
9581
|
-
|
|
9655
|
+
activities
|
|
9582
9656
|
} : readable.data, null, 2));
|
|
9583
9657
|
await clearPendingAfterRead(command.config.configDir, readable.data.id, readable.data);
|
|
9584
9658
|
return;
|
|
@@ -9597,11 +9671,11 @@ async function runCompact(command, flags) {
|
|
|
9597
9671
|
await fail(result.error);
|
|
9598
9672
|
return;
|
|
9599
9673
|
}
|
|
9600
|
-
const
|
|
9674
|
+
const activities = flags["with-activity"] ? await fetchEmailThreadActivity(command, detail.thread_id, flags, authenticated) : void 0;
|
|
9601
9675
|
process.stderr.write(ROUTE_MISSING_NOTICE);
|
|
9602
|
-
command.log(JSON.stringify(
|
|
9676
|
+
command.log(JSON.stringify(activities !== void 0 ? {
|
|
9603
9677
|
...buildEmailCompact(detail),
|
|
9604
|
-
|
|
9678
|
+
activities
|
|
9605
9679
|
} : buildEmailCompact(detail), null, 2));
|
|
9606
9680
|
await clearPendingAfterRead(command.config.configDir, detail.id, detail);
|
|
9607
9681
|
});
|
|
@@ -9696,16 +9770,22 @@ function createEmailsGetCommand(base) {
|
|
|
9696
9770
|
process.exitCode = 1;
|
|
9697
9771
|
return;
|
|
9698
9772
|
}
|
|
9699
|
-
const
|
|
9700
|
-
|
|
9773
|
+
const activities = await fetchEmailThreadActivity(this, detail.thread_id, parsed, authenticated);
|
|
9774
|
+
const enrichedDetail = {
|
|
9701
9775
|
...detail,
|
|
9702
|
-
|
|
9703
|
-
}
|
|
9776
|
+
activities
|
|
9777
|
+
};
|
|
9778
|
+
const output = parsed.json ? {
|
|
9779
|
+
...result.data,
|
|
9780
|
+
success: true,
|
|
9781
|
+
data: enrichedDetail
|
|
9782
|
+
} : enrichedDetail;
|
|
9783
|
+
this.log(JSON.stringify(output, null, 2));
|
|
9704
9784
|
await clearPendingAfterRead(this.config.configDir, detail.id, detail);
|
|
9705
9785
|
});
|
|
9706
9786
|
return;
|
|
9707
9787
|
}
|
|
9708
|
-
this.argv = this.argv.filter((arg) => arg !== "--no-signal" && arg !== "--with-activity");
|
|
9788
|
+
this.argv = this.argv.filter((arg) => arg !== "--no-signal" && !arg.startsWith("--no-signal=") && arg !== "--with-activity" && !arg.startsWith("--with-activity="));
|
|
9709
9789
|
const before = process.exitCode;
|
|
9710
9790
|
await base.prototype.run.call(this);
|
|
9711
9791
|
if (process.exitCode === before || process.exitCode === 0) await clearPendingAfterRead(this.config.configDir, parsed.id);
|
|
@@ -11746,8 +11826,8 @@ const PRIMITIVE_TEAM_AUTHOR = {
|
|
|
11746
11826
|
name: "Primitive Team",
|
|
11747
11827
|
url: "https://primitive.dev"
|
|
11748
11828
|
};
|
|
11749
|
-
const SDK_VERSION_RANGE = "^3.0.0-preview.
|
|
11750
|
-
const CLI_VERSION_RANGE = "^3.0.0-preview.
|
|
11829
|
+
const SDK_VERSION_RANGE = "^3.0.0-preview.27";
|
|
11830
|
+
const CLI_VERSION_RANGE = "^3.0.0-preview.27";
|
|
11751
11831
|
const ESBUILD_VERSION_RANGE = "^0.27.0";
|
|
11752
11832
|
function renderHandler() {
|
|
11753
11833
|
return `// env.PRIMITIVE_API_KEY, env.PRIMITIVE_WEBHOOK_SECRET, and
|
|
@@ -14748,42 +14828,54 @@ var WhoamiCommand = class WhoamiCommand extends Command {
|
|
|
14748
14828
|
}, null, 2) : `${identity.agentAddress}\nSelected by: ${selectedBy}. Prefix a command with \`PRIMITIVE_AGENT_PROFILE=\` to run it as the member login instead.\nSaved connected-agent profile: ${identity.profileName}\nAgent address: ${identity.agentAddress}\nOwner personal address (send reports here): ${identity.ownerMemberAddress ?? "unknown; reply to the member who wrote to you"}\nControl address (setup and presence only): ${identity.ownerAddress}\nAPI origin: ${identity.apiBaseUrl}\n${guidance}\nSaved profile status: ${statusCommand}`);
|
|
14749
14829
|
return;
|
|
14750
14830
|
}
|
|
14751
|
-
if (auth.agentPass) {
|
|
14752
|
-
|
|
14753
|
-
|
|
14754
|
-
|
|
14755
|
-
|
|
14756
|
-
|
|
14757
|
-
|
|
14758
|
-
|
|
14759
|
-
|
|
14760
|
-
|
|
14831
|
+
if (auth.agentPass && flags.check === void 0) {
|
|
14832
|
+
let response;
|
|
14833
|
+
try {
|
|
14834
|
+
response = await fetch(`${auth.apiBaseUrl.replace(/\/+$/, "")}/whoami/grant`, {
|
|
14835
|
+
method: "GET",
|
|
14836
|
+
headers: {
|
|
14837
|
+
...cliActivityHeadersFromEnv(),
|
|
14838
|
+
authorization: `Bearer ${auth.apiKey ?? ""}`,
|
|
14839
|
+
accept: "application/json"
|
|
14840
|
+
}
|
|
14841
|
+
});
|
|
14842
|
+
} catch (error) {
|
|
14843
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
14844
|
+
throw new Errors.CLIError(`Could not reach /whoami/grant: ${detail}`, { exit: 1 });
|
|
14845
|
+
}
|
|
14761
14846
|
const payload = await response.json().catch(() => null);
|
|
14762
14847
|
if (!response.ok) {
|
|
14763
14848
|
const errorPayload = extractErrorPayload(payload ?? { message: `HTTP ${response.status}` });
|
|
14764
|
-
writeErrorWithHints(errorPayload);
|
|
14849
|
+
writeErrorWithHints(errorPayload, response, { auth });
|
|
14765
14850
|
process.exitCode = 1;
|
|
14766
14851
|
return;
|
|
14767
14852
|
}
|
|
14768
|
-
grant = payload?.data ?? null;
|
|
14853
|
+
const grant = payload?.data ?? null;
|
|
14854
|
+
const { pass, permissions: perms } = syncAgentPassMetadataFromGrant({
|
|
14855
|
+
configDir: this.config.configDir,
|
|
14856
|
+
pass: auth.agentPass,
|
|
14857
|
+
grantData: grant
|
|
14858
|
+
});
|
|
14769
14859
|
const revokeCommand = pass.binding.kind === "profile" ? `primitive disconnect --profile ${pass.binding.profile}` : "primitive disconnect";
|
|
14770
14860
|
if (flags.json) {
|
|
14771
14861
|
this.log(JSON.stringify({
|
|
14772
14862
|
auth_method: "agent_pass",
|
|
14773
14863
|
pass,
|
|
14774
14864
|
grant,
|
|
14865
|
+
skill_command: "primitive skill",
|
|
14775
14866
|
revoke_command: revokeCommand
|
|
14776
14867
|
}, null, 2));
|
|
14777
14868
|
return;
|
|
14778
14869
|
}
|
|
14779
|
-
const perms = Array.isArray(grant?.permissions) ? grant.permissions.filter((p) => typeof p === "string") : [];
|
|
14780
14870
|
const lines = [
|
|
14781
14871
|
`Authenticated with Access Pass "${pass.label}" (${pass.mode})`,
|
|
14782
14872
|
`Expires at: ${pass.expires_at}`,
|
|
14783
14873
|
`API origin: ${auth.apiBaseUrl}`
|
|
14784
14874
|
];
|
|
14785
14875
|
if (pass.slice_summary) lines.push(`Scope: ${pass.slice_summary}`);
|
|
14876
|
+
if (pass.manage_url) lines.push(`Manage / extend / promote: ${pass.manage_url}`);
|
|
14786
14877
|
if (perms.length > 0) lines.push(`Permissions: ${perms.join(", ")}`);
|
|
14878
|
+
lines.push("Live scoped skill: `primitive skill`");
|
|
14787
14879
|
lines.push(`Disconnect and revoke: ${revokeCommand}`);
|
|
14788
14880
|
this.log(lines.join("\n"));
|
|
14789
14881
|
return;
|
|
@@ -18748,6 +18840,74 @@ var ListenPendingCommand = class ListenPendingCommand extends Command {
|
|
|
18748
18840
|
}, null, 2));
|
|
18749
18841
|
}
|
|
18750
18842
|
};
|
|
18843
|
+
// src/oclif/commands/lock.ts
|
|
18844
|
+
var LockCommand = class LockCommand extends Command {
|
|
18845
|
+
static summary = "Lock global CLI credentials so agents must use scoped Access Passes";
|
|
18846
|
+
static description = "Blocks global OAuth login (credentials.json), ambient PRIMITIVE_API_KEY, and ad-hoc --api-key overrides until you run `primitive unlock` in an interactive terminal. Scoped Access Passes (`primitive connect <url>`) and connected agent profiles (PRIMITIVE_AGENT_PROFILE) continue to work normally while locked.";
|
|
18847
|
+
static examples = [
|
|
18848
|
+
"<%= config.bin %> lock",
|
|
18849
|
+
"<%= config.bin %> lock --reason 'Keep admin login safe from local agent sessions'",
|
|
18850
|
+
"<%= config.bin %> lock --status"
|
|
18851
|
+
];
|
|
18852
|
+
static flags = {
|
|
18853
|
+
reason: Flags.string({ description: "Optional note shown when a locked global credential is blocked" }),
|
|
18854
|
+
status: Flags.boolean({ description: "Show the current lock status without changing it" }),
|
|
18855
|
+
json: Flags.boolean({ description: "Print the lock status as JSON" })
|
|
18856
|
+
};
|
|
18857
|
+
async run() {
|
|
18858
|
+
const { flags } = await this.parse(LockCommand);
|
|
18859
|
+
try {
|
|
18860
|
+
if (flags.status) {
|
|
18861
|
+
const state = readCliLockState(this.config.configDir);
|
|
18862
|
+
if (flags.json) {
|
|
18863
|
+
this.log(JSON.stringify(state));
|
|
18864
|
+
return;
|
|
18865
|
+
}
|
|
18866
|
+
if (state.status === "locked") {
|
|
18867
|
+
this.log(`Global Primitive credentials are LOCKED (since ${state.lockedAt}).`);
|
|
18868
|
+
if (state.reason) this.log(`Reason: ${state.reason}`);
|
|
18869
|
+
this.log("Allowed while locked: scoped Access Passes (`primitive connect <url>`) and PRIMITIVE_AGENT_PROFILE.");
|
|
18870
|
+
this.log("To temporarily use your global login: `primitive unlock --for 15m`.");
|
|
18871
|
+
return;
|
|
18872
|
+
}
|
|
18873
|
+
if (state.status === "temporarily_unlocked") {
|
|
18874
|
+
this.log(`Global Primitive credentials are temporarily unlocked until ${state.unlockedUntil} (will auto-relock).`);
|
|
18875
|
+
this.log("Run `primitive lock` to re-lock immediately.");
|
|
18876
|
+
return;
|
|
18877
|
+
}
|
|
18878
|
+
this.log("Global Primitive credentials are unlocked.");
|
|
18879
|
+
this.log("Run `primitive lock` to prevent agent sessions from accidentally using your global login or PRIMITIVE_API_KEY.");
|
|
18880
|
+
return;
|
|
18881
|
+
}
|
|
18882
|
+
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
18883
|
+
const reason = flags.reason?.trim() || null;
|
|
18884
|
+
const record = {
|
|
18885
|
+
version: 1,
|
|
18886
|
+
locked: true,
|
|
18887
|
+
locked_at: nowIso,
|
|
18888
|
+
unlocked_until: null,
|
|
18889
|
+
...reason ? { reason } : {}
|
|
18890
|
+
};
|
|
18891
|
+
writeCliLockState(this.config.configDir, record);
|
|
18892
|
+
if (flags.json) {
|
|
18893
|
+
this.log(JSON.stringify({
|
|
18894
|
+
status: "locked",
|
|
18895
|
+
locked: true,
|
|
18896
|
+
locked_at: nowIso,
|
|
18897
|
+
reason
|
|
18898
|
+
}));
|
|
18899
|
+
return;
|
|
18900
|
+
}
|
|
18901
|
+
this.log("Locked global Primitive credentials on this machine.");
|
|
18902
|
+
this.log("Blocked: saved OAuth login, ambient PRIMITIVE_API_KEY, and ad-hoc --api-key overrides.");
|
|
18903
|
+
this.log("Allowed: scoped Access Passes (`primitive connect <url>`) and PRIMITIVE_AGENT_PROFILE.");
|
|
18904
|
+
this.log("When you need your global login in your terminal: run `primitive unlock --for 15m` (auto-relocks) or `primitive unlock`.");
|
|
18905
|
+
} catch (error) {
|
|
18906
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
18907
|
+
throw new Errors.CLIError(message, { exit: 1 });
|
|
18908
|
+
}
|
|
18909
|
+
}
|
|
18910
|
+
};
|
|
18751
18911
|
// src/oclif/commands/login.ts
|
|
18752
18912
|
const MAX_CLI_LOGIN_POLL_INTERVAL_SECONDS = 60;
|
|
18753
18913
|
/** How long a login waits for an in-flight agent registration on this machine. */
|
|
@@ -20027,6 +20187,10 @@ async function runLogoutWithCredentialLock(params) {
|
|
|
20027
20187
|
throw error;
|
|
20028
20188
|
}
|
|
20029
20189
|
const freshCredentials = authenticated.auth.credentials ?? credentials;
|
|
20190
|
+
if (authenticated.auth.source === "agent-pass" && authenticated.auth.agentPass) {
|
|
20191
|
+
const disconnectCmd = authenticated.auth.agentPass.binding.kind === "profile" ? `primitive disconnect --profile ${authenticated.auth.agentPass.binding.profile}` : "primitive disconnect";
|
|
20192
|
+
throw cliError$1(`An Access Pass ("${authenticated.auth.agentPass.label}") is active in this context. Run \`${disconnectCmd}\` to disconnect the Access Pass, or run \`primitive logout\` outside the bound session to log out of your saved Primitive CLI login.`);
|
|
20193
|
+
}
|
|
20030
20194
|
const result = await deps.cliLogout({
|
|
20031
20195
|
body: { key_id: freshCredentials.oauth_grant_id },
|
|
20032
20196
|
client: authenticated.apiClient.client,
|
|
@@ -21461,9 +21625,9 @@ function parseJsonObjectFlag(raw, label) {
|
|
|
21461
21625
|
return parsed;
|
|
21462
21626
|
}
|
|
21463
21627
|
function buildExternalRef(flags) {
|
|
21464
|
-
const hasRefFlags =
|
|
21465
|
-
if (flags["external-ref"] && hasRefFlags) throw new Errors.CLIError("Use either --external-ref or --ref-system/--ref-id/--ref-url/--ref-label, not both.", { exit: 2 });
|
|
21466
|
-
if (flags["external-ref"]) {
|
|
21628
|
+
const hasRefFlags = flags["ref-system"] !== void 0 || flags["ref-id"] !== void 0 || flags["ref-url"] !== void 0 || flags["ref-label"] !== void 0;
|
|
21629
|
+
if (flags["external-ref"] !== void 0 && hasRefFlags) throw new Errors.CLIError("Use either --external-ref or --ref-system/--ref-id/--ref-url/--ref-label, not both.", { exit: 2 });
|
|
21630
|
+
if (flags["external-ref"] !== void 0) {
|
|
21467
21631
|
const obj = parseJsonObjectFlag(flags["external-ref"], "--external-ref");
|
|
21468
21632
|
if (typeof obj.system !== "string" || !obj.system.trim()) throw new Errors.CLIError("--external-ref must include a non-empty string `system`.", { exit: 2 });
|
|
21469
21633
|
const ref = { system: obj.system.trim() };
|
|
@@ -21556,17 +21720,17 @@ var ActivityLogCommand = class ActivityLogCommand extends Command {
|
|
|
21556
21720
|
if (!flags.thread && !flags.email) throw new Errors.CLIError("Provide --thread <uuid> or --email <uuid>.", { exit: 2 });
|
|
21557
21721
|
if (flags.detail !== void 0 && flags["detail-file"] !== void 0) throw new Errors.CLIError("Use either --detail or --detail-file, not both.", { exit: 2 });
|
|
21558
21722
|
if (flags.data !== void 0 && flags["data-file"] !== void 0) throw new Errors.CLIError("Use either --data or --data-file, not both.", { exit: 2 });
|
|
21559
|
-
const threadId = flags.thread ? assertUuid(flags.thread, "--thread") : null;
|
|
21560
|
-
const emailId = flags.email ? assertUuid(flags.email, "--email") : null;
|
|
21561
|
-
const sentEmailId = flags["sent-email"] ? assertUuid(flags["sent-email"], "--sent-email") : void 0;
|
|
21562
|
-
if (flags.action && !ACTION_SLUG_RE.test(flags.action.trim())) throw new Errors.CLIError("--action must start with a lowercase letter or digit and use only a-z, 0-9, ., _, :, - (max 128 chars).", { exit: 2 });
|
|
21563
|
-
if (flags["idempotency-key"] && !IDEMPOTENCY_KEY_RE.test(flags["idempotency-key"].trim())) throw new Errors.CLIError("--idempotency-key must be 1 to 255 printable ASCII characters without spaces.", { exit: 2 });
|
|
21564
|
-
const detail = flags["detail-file"] ? readUtf8File(flags["detail-file"], "--detail-file") : flags.detail;
|
|
21723
|
+
const threadId = flags.thread !== void 0 ? assertUuid(flags.thread, "--thread") : null;
|
|
21724
|
+
const emailId = flags.email !== void 0 ? assertUuid(flags.email, "--email") : null;
|
|
21725
|
+
const sentEmailId = flags["sent-email"] !== void 0 ? assertUuid(flags["sent-email"], "--sent-email") : void 0;
|
|
21726
|
+
if (flags.action !== void 0 && !ACTION_SLUG_RE.test(flags.action.trim())) throw new Errors.CLIError("--action must start with a lowercase letter or digit and use only a-z, 0-9, ., _, :, - (max 128 chars).", { exit: 2 });
|
|
21727
|
+
if (flags["idempotency-key"] !== void 0 && !IDEMPOTENCY_KEY_RE.test(flags["idempotency-key"].trim())) throw new Errors.CLIError("--idempotency-key must be 1 to 255 printable ASCII characters without spaces.", { exit: 2 });
|
|
21728
|
+
const detail = flags["detail-file"] !== void 0 ? readUtf8File(flags["detail-file"], "--detail-file") : flags.detail;
|
|
21565
21729
|
if (detail !== void 0 && detail.length > 8e3) throw new Errors.CLIError("Detail must be at most 8000 characters.", { exit: 2 });
|
|
21566
|
-
const data = flags["data-file"] ? parseJsonObjectFlag(readUtf8File(flags["data-file"], "--data-file"), "--data-file") : flags.data ? parseJsonObjectFlag(flags.data, "--data") : void 0;
|
|
21730
|
+
const data = flags["data-file"] !== void 0 ? parseJsonObjectFlag(readUtf8File(flags["data-file"], "--data-file"), "--data-file") : flags.data !== void 0 ? parseJsonObjectFlag(flags.data, "--data") : void 0;
|
|
21567
21731
|
const externalRef = buildExternalRef(flags);
|
|
21568
|
-
const runId = flags["run-id"]
|
|
21569
|
-
const traceUrl = flags["trace-url"] ? assertHttpUrl(flags["trace-url"], "--trace-url") : void 0;
|
|
21732
|
+
const runId = flags["run-id"] !== void 0 ? validateActivityRunId(flags["run-id"], "--run-id") : void 0;
|
|
21733
|
+
const traceUrl = flags["trace-url"] !== void 0 ? assertHttpUrl(flags["trace-url"], "--trace-url") : void 0;
|
|
21570
21734
|
const body = {
|
|
21571
21735
|
summary,
|
|
21572
21736
|
...flags.kind ? { kind: flags.kind } : {},
|
|
@@ -21655,11 +21819,11 @@ var ActivityUpdateCommand = class ActivityUpdateCommand extends Command {
|
|
|
21655
21819
|
if (!trimmed || trimmed.length > 1e3) throw new Errors.CLIError("--summary must be 1 to 1000 characters.", { exit: 2 });
|
|
21656
21820
|
body.summary = trimmed;
|
|
21657
21821
|
}
|
|
21658
|
-
if (flags["detail-file"] && flags.detail !== void 0) throw new Errors.CLIError("Use either --detail or --detail-file, not both.", { exit: 2 });
|
|
21822
|
+
if (flags["detail-file"] !== void 0 && flags.detail !== void 0) throw new Errors.CLIError("Use either --detail or --detail-file, not both.", { exit: 2 });
|
|
21659
21823
|
if (flags["clear-detail"] && (flags.detail !== void 0 || flags["detail-file"] !== void 0)) throw new Errors.CLIError("--clear-detail cannot be combined with --detail or --detail-file.", { exit: 2 });
|
|
21660
21824
|
if (flags["clear-detail"]) body.detail = null;
|
|
21661
|
-
else if (flags["detail-file"] || flags.detail !== void 0) {
|
|
21662
|
-
const detailText = flags["detail-file"] ? readUtf8File(flags["detail-file"], "--detail-file") : flags.detail ?? "";
|
|
21825
|
+
else if (flags["detail-file"] !== void 0 || flags.detail !== void 0) {
|
|
21826
|
+
const detailText = flags["detail-file"] !== void 0 ? readUtf8File(flags["detail-file"], "--detail-file") : flags.detail ?? "";
|
|
21663
21827
|
if (detailText.length > 8e3) throw new Errors.CLIError("Detail must be at most 8000 characters.", { exit: 2 });
|
|
21664
21828
|
body.detail = detailText;
|
|
21665
21829
|
}
|
|
@@ -21670,15 +21834,15 @@ var ActivityUpdateCommand = class ActivityUpdateCommand extends Command {
|
|
|
21670
21834
|
const ref = buildExternalRef(flags);
|
|
21671
21835
|
if (ref) body.external_ref = ref;
|
|
21672
21836
|
}
|
|
21673
|
-
if (flags["data-file"] && flags.data !== void 0) throw new Errors.CLIError("Use either --data or --data-file, not both.", { exit: 2 });
|
|
21674
|
-
if (flags["data-file"]) body.data = parseJsonObjectFlag(readUtf8File(flags["data-file"], "--data-file"), "--data-file");
|
|
21675
|
-
else if (flags.data) body.data = parseJsonObjectFlag(flags.data, "--data");
|
|
21837
|
+
if (flags["data-file"] !== void 0 && flags.data !== void 0) throw new Errors.CLIError("Use either --data or --data-file, not both.", { exit: 2 });
|
|
21838
|
+
if (flags["data-file"] !== void 0) body.data = parseJsonObjectFlag(readUtf8File(flags["data-file"], "--data-file"), "--data-file");
|
|
21839
|
+
else if (flags.data !== void 0) body.data = parseJsonObjectFlag(flags.data, "--data");
|
|
21676
21840
|
if (flags["clear-run-id"] && flags["run-id"] !== void 0) throw new Errors.CLIError("--clear-run-id cannot be combined with --run-id.", { exit: 2 });
|
|
21677
21841
|
if (flags["clear-run-id"]) body.run_id = null;
|
|
21678
|
-
else if (flags["run-id"]) body.run_id = validateActivityRunId(flags["run-id"], "--run-id");
|
|
21842
|
+
else if (flags["run-id"] !== void 0) body.run_id = validateActivityRunId(flags["run-id"], "--run-id");
|
|
21679
21843
|
if (flags["clear-trace-url"] && flags["trace-url"] !== void 0) throw new Errors.CLIError("--clear-trace-url cannot be combined with --trace-url.", { exit: 2 });
|
|
21680
21844
|
if (flags["clear-trace-url"]) body.trace_url = null;
|
|
21681
|
-
else if (flags["trace-url"]) body.trace_url = assertHttpUrl(flags["trace-url"], "--trace-url");
|
|
21845
|
+
else if (flags["trace-url"] !== void 0) body.trace_url = assertHttpUrl(flags["trace-url"], "--trace-url");
|
|
21682
21846
|
if (flags.visibility) body.visibility = flags.visibility;
|
|
21683
21847
|
if (Object.keys(body).length === 0) throw new Errors.CLIError("Provide at least one field to update.", { exit: 2 });
|
|
21684
21848
|
await runWithTiming(flags.time === true, async () => {
|
|
@@ -21743,8 +21907,8 @@ var ActivityTimelineCommand = class ActivityTimelineCommand extends Command {
|
|
|
21743
21907
|
async run() {
|
|
21744
21908
|
const { args, flags } = await this.parse(ActivityTimelineCommand);
|
|
21745
21909
|
const threadId = assertUuid(args.thread_id, "thread_id");
|
|
21746
|
-
const status = flags.status ? validateStatusCsv(flags.status) : void 0;
|
|
21747
|
-
const actorId = flags["actor-id"] ? assertUuid(flags["actor-id"], "--actor-id") : void 0;
|
|
21910
|
+
const status = flags.status !== void 0 ? validateStatusCsv(flags.status) : void 0;
|
|
21911
|
+
const actorId = flags["actor-id"] !== void 0 ? assertUuid(flags["actor-id"], "--actor-id") : void 0;
|
|
21748
21912
|
await runWithTiming(flags.time === true, async () => {
|
|
21749
21913
|
const result = await callActivityApi({
|
|
21750
21914
|
configDir: this.config.configDir,
|
|
@@ -21833,20 +21997,20 @@ var ActivityListCommand = class ActivityListCommand extends Command {
|
|
|
21833
21997
|
async run() {
|
|
21834
21998
|
const { flags } = await this.parse(ActivityListCommand);
|
|
21835
21999
|
if (flags.format === "csv" && flags.json) throw new Errors.CLIError("Cannot combine --format csv with --json.", { exit: 2 });
|
|
21836
|
-
const status = flags.status ? validateStatusCsv(flags.status) : void 0;
|
|
22000
|
+
const status = flags.status !== void 0 ? validateStatusCsv(flags.status) : void 0;
|
|
21837
22001
|
const query = {
|
|
21838
22002
|
source: flags.source,
|
|
21839
|
-
thread_id: flags.thread ? assertUuid(flags.thread, "--thread") : void 0,
|
|
21840
|
-
email_id: flags.email ? assertUuid(flags.email, "--email") : void 0,
|
|
21841
|
-
sent_email_id: flags["sent-email"] ? assertUuid(flags["sent-email"], "--sent-email") : void 0,
|
|
22003
|
+
thread_id: flags.thread !== void 0 ? assertUuid(flags.thread, "--thread") : void 0,
|
|
22004
|
+
email_id: flags.email !== void 0 ? assertUuid(flags.email, "--email") : void 0,
|
|
22005
|
+
sent_email_id: flags["sent-email"] !== void 0 ? assertUuid(flags["sent-email"], "--sent-email") : void 0,
|
|
21842
22006
|
kind: flags.kind,
|
|
21843
22007
|
status,
|
|
21844
22008
|
attention: flags.attention ? "true" : void 0,
|
|
21845
22009
|
action: flags.action,
|
|
21846
22010
|
actor_kind: flags["actor-kind"],
|
|
21847
22011
|
actor_ownership: flags["actor-ownership"],
|
|
21848
|
-
actor_id: flags["actor-id"] ? assertUuid(flags["actor-id"], "--actor-id") : void 0,
|
|
21849
|
-
owner_user_id: flags["owner-user-id"] ? assertUuid(flags["owner-user-id"], "--owner-user-id") : void 0,
|
|
22012
|
+
actor_id: flags["actor-id"] !== void 0 ? assertUuid(flags["actor-id"], "--actor-id") : void 0,
|
|
22013
|
+
owner_user_id: flags["owner-user-id"] !== void 0 ? assertUuid(flags["owner-user-id"], "--owner-user-id") : void 0,
|
|
21850
22014
|
oauth_client_id: flags["oauth-client-id"],
|
|
21851
22015
|
run_id: flags["run-id"],
|
|
21852
22016
|
include_private: flags["include-private"] ? "true" : void 0,
|
|
@@ -21915,7 +22079,7 @@ var ActivityAgentsCommand = class ActivityAgentsCommand extends Command {
|
|
|
21915
22079
|
};
|
|
21916
22080
|
async run() {
|
|
21917
22081
|
const { flags } = await this.parse(ActivityAgentsCommand);
|
|
21918
|
-
const ownerUserId = flags["owner-user-id"] ? assertUuid(flags["owner-user-id"], "--owner-user-id") : void 0;
|
|
22082
|
+
const ownerUserId = flags["owner-user-id"] !== void 0 ? assertUuid(flags["owner-user-id"], "--owner-user-id") : void 0;
|
|
21919
22083
|
await runWithTiming(flags.time === true, async () => {
|
|
21920
22084
|
const result = await callActivityApi({
|
|
21921
22085
|
configDir: this.config.configDir,
|
|
@@ -26361,12 +26525,27 @@ function resolveSkillTargets(options) {
|
|
|
26361
26525
|
if (options.out !== void 0) {
|
|
26362
26526
|
if (!options.out.trim()) throw new Errors.CLIError("--out must be a non-empty path.", { exit: 2 });
|
|
26363
26527
|
const resolvedOut = resolve(cwd, options.out);
|
|
26364
|
-
const
|
|
26528
|
+
const base = basename(resolvedOut);
|
|
26529
|
+
const hasTrailingSep = /[\\/]$/.test(options.out.trim());
|
|
26530
|
+
const existingDir = (() => {
|
|
26531
|
+
try {
|
|
26532
|
+
return lstatSync(resolvedOut).isDirectory();
|
|
26533
|
+
} catch {
|
|
26534
|
+
return false;
|
|
26535
|
+
}
|
|
26536
|
+
})();
|
|
26537
|
+
const ext = extname(base);
|
|
26538
|
+
const isFilePath = !hasTrailingSep && !existingDir && (base.toLowerCase() === "skill.md" || ext.length > 1 && !base.startsWith("."));
|
|
26365
26539
|
const directory = isFilePath ? dirname(resolvedOut) : resolvedOut;
|
|
26366
|
-
if (basename(directory).toLowerCase() === "primitive-connect") throw new Errors.CLIError(`Refusing to write into "${CONNECT_SKILL_NAME}", which is reserved for the bundled connection skill.`, { exit: 2 });
|
|
26540
|
+
if (basename(directory).toLowerCase() === "primitive-connect" || isFilePath && base.toLowerCase() === `primitive-connect.md`) throw new Errors.CLIError(`Refusing to write into "${CONNECT_SKILL_NAME}", which is reserved for the bundled connection skill.`, { exit: 2 });
|
|
26367
26541
|
const filePath = isFilePath ? resolvedOut : join(resolvedOut, "SKILL.md");
|
|
26368
26542
|
const home = resolve(userHome(env));
|
|
26369
|
-
const
|
|
26543
|
+
const matchedHomeRoot = SKILL_TARGETS.map((t) => targetRootDir(t, {
|
|
26544
|
+
project: false,
|
|
26545
|
+
cwd,
|
|
26546
|
+
env
|
|
26547
|
+
})).find((rootDir) => isSubpath(rootDir, directory));
|
|
26548
|
+
const boundary = matchedHomeRoot ? matchedHomeRoot : isSubpath(cwd, directory) ? cwd : isSubpath(home, directory) ? home : dirname(directory);
|
|
26370
26549
|
return [{
|
|
26371
26550
|
target: "custom",
|
|
26372
26551
|
directory,
|
|
@@ -26384,7 +26563,6 @@ function resolveSkillTargets(options) {
|
|
|
26384
26563
|
}));
|
|
26385
26564
|
else if (selector === "all") expanded.push(...SKILL_TARGETS);
|
|
26386
26565
|
else expanded.push(selector);
|
|
26387
|
-
const home = resolve(userHome(env));
|
|
26388
26566
|
const deduped = [];
|
|
26389
26567
|
const seenDirs = /* @__PURE__ */ new Set();
|
|
26390
26568
|
for (const target of expanded) {
|
|
@@ -26396,7 +26574,7 @@ function resolveSkillTargets(options) {
|
|
|
26396
26574
|
const directory = join(rootDir, name);
|
|
26397
26575
|
if (seenDirs.has(directory)) continue;
|
|
26398
26576
|
seenDirs.add(directory);
|
|
26399
|
-
const boundary = project ? cwd :
|
|
26577
|
+
const boundary = project ? cwd : rootDir;
|
|
26400
26578
|
deduped.push({
|
|
26401
26579
|
target,
|
|
26402
26580
|
directory,
|
|
@@ -26417,6 +26595,16 @@ function sha256Text(content) {
|
|
|
26417
26595
|
function assertNoSymlinkAncestors(targetDir, boundary) {
|
|
26418
26596
|
const resolvedDir = resolve(targetDir);
|
|
26419
26597
|
const start = boundary && isSubpath(resolve(boundary), resolvedDir) ? resolve(boundary) : dirname(resolvedDir);
|
|
26598
|
+
try {
|
|
26599
|
+
if (!statSync(start).isDirectory()) throw new Errors.CLIError(`Expected directory at ${start}, found a non-directory entry.`, { exit: 1 });
|
|
26600
|
+
} catch (error) {
|
|
26601
|
+
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") try {
|
|
26602
|
+
if (lstatSync(start).isSymbolicLink()) throw new Errors.CLIError(`Refusing to traverse dangling symbolic link: ${start}`, { exit: 1 });
|
|
26603
|
+
} catch (lstatError) {
|
|
26604
|
+
if (!(lstatError && typeof lstatError === "object" && "code" in lstatError && lstatError.code === "ENOENT")) throw lstatError;
|
|
26605
|
+
}
|
|
26606
|
+
else throw error;
|
|
26607
|
+
}
|
|
26420
26608
|
const rel = relative(start, resolvedDir);
|
|
26421
26609
|
const segments = rel ? rel.split(sep).filter(Boolean) : [];
|
|
26422
26610
|
let current = start;
|
|
@@ -26448,6 +26636,13 @@ function hasConnectFrontmatter(content) {
|
|
|
26448
26636
|
if (!match) return false;
|
|
26449
26637
|
return /^name:\s*["']?primitive-connect["']?\s*$/im.test(match[1] ?? "");
|
|
26450
26638
|
}
|
|
26639
|
+
function applySkillFrontmatterName(markdown, normalizedName) {
|
|
26640
|
+
if (normalizedName === "primitive") return markdown;
|
|
26641
|
+
const match = markdown.match(/^(---\r?\n)([\s\S]*?)(\r?\n---(?:\r?\n|$))/);
|
|
26642
|
+
if (!match) return markdown;
|
|
26643
|
+
const [, open, body, close] = match;
|
|
26644
|
+
return `${open}${(body ?? "").replace(/^(name:\s*)(["']?)primitive\2(\s*)$/m, `$1$2${normalizedName}$2$3`)}${close}${markdown.slice(match[0].length)}`;
|
|
26645
|
+
}
|
|
26451
26646
|
function isSkillFilePresent(target) {
|
|
26452
26647
|
try {
|
|
26453
26648
|
assertNoSymlinkAncestors(target.directory, target.boundary);
|
|
@@ -26505,22 +26700,78 @@ function writeFileAtomically(filePath, content, boundary) {
|
|
|
26505
26700
|
throw error;
|
|
26506
26701
|
}
|
|
26507
26702
|
}
|
|
26703
|
+
function readMarkerMetadata(metaPath) {
|
|
26704
|
+
let metaStat;
|
|
26705
|
+
try {
|
|
26706
|
+
metaStat = lstatSync(metaPath);
|
|
26707
|
+
} catch (error) {
|
|
26708
|
+
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return {
|
|
26709
|
+
exists: false,
|
|
26710
|
+
meta: null
|
|
26711
|
+
};
|
|
26712
|
+
throw error;
|
|
26713
|
+
}
|
|
26714
|
+
if (metaStat.isSymbolicLink() || !metaStat.isFile() || metaStat.size > MAX_META_BYTES) return {
|
|
26715
|
+
exists: true,
|
|
26716
|
+
meta: null
|
|
26717
|
+
};
|
|
26718
|
+
try {
|
|
26719
|
+
const raw = JSON.parse(readFileSync(metaPath, "utf8"));
|
|
26720
|
+
if (typeof raw.etag !== "string" || !SKILL_ETAG_RE.test(raw.etag) || typeof raw.sha256 !== "string" || typeof raw.name !== "string") return {
|
|
26721
|
+
exists: true,
|
|
26722
|
+
meta: null
|
|
26723
|
+
};
|
|
26724
|
+
return {
|
|
26725
|
+
exists: true,
|
|
26726
|
+
meta: {
|
|
26727
|
+
name: raw.name,
|
|
26728
|
+
version: typeof raw.version === "string" ? raw.version : "1",
|
|
26729
|
+
etag: raw.etag,
|
|
26730
|
+
sha256: raw.sha256,
|
|
26731
|
+
api_base_url: typeof raw.api_base_url === "string" ? raw.api_base_url : "",
|
|
26732
|
+
org_id: typeof raw.org_id === "string" ? raw.org_id : "",
|
|
26733
|
+
auth_method: typeof raw.auth_method === "string" ? raw.auth_method : null,
|
|
26734
|
+
installed_at: typeof raw.installed_at === "string" ? raw.installed_at : ""
|
|
26735
|
+
}
|
|
26736
|
+
};
|
|
26737
|
+
} catch {
|
|
26738
|
+
return {
|
|
26739
|
+
exists: true,
|
|
26740
|
+
meta: null
|
|
26741
|
+
};
|
|
26742
|
+
}
|
|
26743
|
+
}
|
|
26508
26744
|
function installSkillToTarget(target, payload, options = {}) {
|
|
26509
26745
|
assertNoSymlinkAncestors(target.directory, target.boundary);
|
|
26510
26746
|
assertRegularFileOrMissing(target.filePath);
|
|
26511
26747
|
assertRegularFileOrMissing(target.metaPath);
|
|
26512
26748
|
const hadFile = isSkillFilePresent(target);
|
|
26749
|
+
const marker = readMarkerMetadata(target.metaPath);
|
|
26750
|
+
let locallyModified = false;
|
|
26513
26751
|
if (hadFile) {
|
|
26514
|
-
|
|
26752
|
+
const stat = lstatSync(target.filePath);
|
|
26753
|
+
let existingText = null;
|
|
26754
|
+
if (stat.size <= MAX_SKILL_BYTES) {
|
|
26755
|
+
existingText = readFileSync(target.filePath, "utf8");
|
|
26756
|
+
if (hasConnectFrontmatter(existingText)) throw new Errors.CLIError(`Refusing to overwrite bundled "${CONNECT_SKILL_NAME}" skill at ${target.filePath}.`, { exit: 2 });
|
|
26757
|
+
}
|
|
26758
|
+
if (!marker.exists) {
|
|
26759
|
+
if (!options.force) throw new Errors.CLIError(`Refusing to overwrite unmanaged skill file at ${target.filePath} (missing ${SKILL_META_FILENAME}). Pass --force to overwrite it, or pass --name to install under a different skill directory.`, { exit: 2 });
|
|
26760
|
+
} else if (marker.meta) {
|
|
26761
|
+
const currentHash = existingText !== null ? sha256Text(existingText) : null;
|
|
26762
|
+
if (currentHash === null || currentHash !== marker.meta.sha256) locallyModified = true;
|
|
26763
|
+
}
|
|
26515
26764
|
}
|
|
26765
|
+
const normalizedName = validateSkillName(payload.name);
|
|
26766
|
+
const markdown = applySkillFrontmatterName(payload.markdown, normalizedName);
|
|
26516
26767
|
const existing = readInstalledSkillMeta(target);
|
|
26517
|
-
const sha256 = sha256Text(
|
|
26768
|
+
const sha256 = sha256Text(markdown);
|
|
26518
26769
|
if (!options.force && existing && existing.etag === payload.etag && existing.sha256 === sha256) return {
|
|
26519
26770
|
state: "unchanged",
|
|
26520
26771
|
previousEtag: existing.etag
|
|
26521
26772
|
};
|
|
26522
26773
|
const meta = {
|
|
26523
|
-
name:
|
|
26774
|
+
name: normalizedName,
|
|
26524
26775
|
version: payload.version,
|
|
26525
26776
|
etag: payload.etag,
|
|
26526
26777
|
sha256,
|
|
@@ -26529,11 +26780,13 @@ function installSkillToTarget(target, payload, options = {}) {
|
|
|
26529
26780
|
auth_method: payload.authMethod,
|
|
26530
26781
|
installed_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
26531
26782
|
};
|
|
26532
|
-
writeFileAtomically(target.filePath,
|
|
26783
|
+
writeFileAtomically(target.filePath, markdown, target.boundary);
|
|
26533
26784
|
writeFileAtomically(target.metaPath, `${JSON.stringify(meta, null, 2)}\n`, target.boundary);
|
|
26785
|
+
const warning = locallyModified ? `Overwrote locally modified ${target.filePath} with the live Primitive skill from the server.` : void 0;
|
|
26534
26786
|
return {
|
|
26535
26787
|
state: existing || hadFile ? "updated" : "installed",
|
|
26536
|
-
previousEtag: existing?.etag ?? null
|
|
26788
|
+
previousEtag: existing?.etag ?? marker.meta?.etag ?? null,
|
|
26789
|
+
...warning ? { warning } : {}
|
|
26537
26790
|
};
|
|
26538
26791
|
}
|
|
26539
26792
|
// src/oclif/commands/skill.ts
|
|
@@ -26544,15 +26797,14 @@ async function fetchCliSkill(options) {
|
|
|
26544
26797
|
apiBaseUrl: options.apiBaseUrl
|
|
26545
26798
|
});
|
|
26546
26799
|
if (!authenticated.auth.apiKey) throw new Errors.CLIError("No Primitive credential is active. Connect with `primitive connect <url>`, set PRIMITIVE_API_KEY, or run `primitive signin`.", { exit: 1 });
|
|
26547
|
-
const headers =
|
|
26800
|
+
const headers = {
|
|
26548
26801
|
accept: "application/json",
|
|
26549
|
-
authorization: `Bearer ${authenticated.auth.apiKey}`,
|
|
26550
26802
|
...options.ifNoneMatch && SKILL_ETAG_RE.test(options.ifNoneMatch) ? { "if-none-match": `"${options.ifNoneMatch}"` } : {}
|
|
26551
|
-
}
|
|
26803
|
+
};
|
|
26552
26804
|
const baseUrl = authenticated.auth.apiBaseUrl.replace(/\/+$/, "");
|
|
26553
26805
|
let response;
|
|
26554
26806
|
try {
|
|
26555
|
-
response = await fetch(`${baseUrl}/cli/skill`, {
|
|
26807
|
+
response = await authenticated.fetch(`${baseUrl}/cli/skill`, {
|
|
26556
26808
|
method: "GET",
|
|
26557
26809
|
headers,
|
|
26558
26810
|
redirect: "manual",
|
|
@@ -26578,8 +26830,13 @@ async function fetchCliSkill(options) {
|
|
|
26578
26830
|
parsed = null;
|
|
26579
26831
|
}
|
|
26580
26832
|
if (!response.ok) {
|
|
26581
|
-
const
|
|
26582
|
-
|
|
26833
|
+
const errObj = parsed && typeof parsed === "object" && "error" in parsed ? parsed.error : void 0;
|
|
26834
|
+
const code = errObj?.code;
|
|
26835
|
+
const message = errObj?.message || `Primitive API returned HTTP ${response.status} for GET /v1/cli/skill.`;
|
|
26836
|
+
throw new Errors.CLIError(message, {
|
|
26837
|
+
exit: 1,
|
|
26838
|
+
...code ? { code } : {}
|
|
26839
|
+
});
|
|
26583
26840
|
}
|
|
26584
26841
|
const data = parsed && typeof parsed === "object" && "data" in parsed ? parsed.data : void 0;
|
|
26585
26842
|
if (!data || typeof data.markdown !== "string" || !data.etag) throw new Errors.CLIError("Unexpected response shape from GET /v1/cli/skill.", { exit: 1 });
|
|
@@ -26611,7 +26868,11 @@ function reportSkillCheckResult(command, params) {
|
|
|
26611
26868
|
if (params.json) command.log(JSON.stringify({
|
|
26612
26869
|
state: overall,
|
|
26613
26870
|
etag: params.serverEtag,
|
|
26614
|
-
targets: statuses
|
|
26871
|
+
targets: statuses,
|
|
26872
|
+
...!allFresh ? { error: {
|
|
26873
|
+
code: overall === "missing" ? "skill_missing" : "skill_stale",
|
|
26874
|
+
message: overall === "missing" ? "Installed Primitive skill is missing. Run `primitive skill install` to install." : "Installed Primitive skill is out of date. Run `primitive skill install` to update."
|
|
26875
|
+
} } : {}
|
|
26615
26876
|
}));
|
|
26616
26877
|
else {
|
|
26617
26878
|
for (const item of statuses) command.log(`${item.state}\t${item.target}\t${item.path}`);
|
|
@@ -26704,11 +26965,13 @@ var SkillCommand = class SkillCommand extends Command {
|
|
|
26704
26965
|
authMethod: result.data.auth_method,
|
|
26705
26966
|
markdown: result.data.markdown
|
|
26706
26967
|
}, { force: true });
|
|
26968
|
+
if (outcome.warning) process.stderr.write(`Warning: ${outcome.warning}\n`);
|
|
26707
26969
|
if (flags.json) this.log(JSON.stringify({
|
|
26708
26970
|
state: outcome.state,
|
|
26709
26971
|
path: target.filePath,
|
|
26710
26972
|
etag: result.data.etag,
|
|
26711
|
-
modules: result.data.modules
|
|
26973
|
+
modules: result.data.modules,
|
|
26974
|
+
...outcome.warning ? { warning: outcome.warning } : {}
|
|
26712
26975
|
}));
|
|
26713
26976
|
else this.log(`Wrote Primitive skill (${result.data.etag}) to ${target.filePath}`);
|
|
26714
26977
|
return;
|
|
@@ -26749,7 +27012,7 @@ var SkillInstallCommand = class SkillInstallCommand extends Command {
|
|
|
26749
27012
|
default: DEFAULT_LIVE_SKILL_NAME
|
|
26750
27013
|
}),
|
|
26751
27014
|
check: Flags.boolean({ description: "Dry-run freshness check against server ETag without writing files (exits 0 fresh, 2 stale/missing)" }),
|
|
26752
|
-
force: Flags.boolean({ description: "Rewrite SKILL.md even if the installed ETag matches" }),
|
|
27015
|
+
force: Flags.boolean({ description: "Rewrite SKILL.md even if the installed ETag matches or an unmanaged file exists" }),
|
|
26753
27016
|
json: Flags.boolean({ description: "Output installation summary as JSON" }),
|
|
26754
27017
|
time: Flags.boolean({ description: "Print request timing to stderr" }),
|
|
26755
27018
|
"api-key": Flags.string({
|
|
@@ -26816,11 +27079,13 @@ var SkillInstallCommand = class SkillInstallCommand extends Command {
|
|
|
26816
27079
|
authMethod: result.data.auth_method,
|
|
26817
27080
|
markdown: result.data.markdown
|
|
26818
27081
|
}, { force: flags.force });
|
|
27082
|
+
if (outcome.warning) process.stderr.write(`Warning: ${outcome.warning}\n`);
|
|
26819
27083
|
return {
|
|
26820
27084
|
target: t.target,
|
|
26821
27085
|
path: t.filePath,
|
|
26822
27086
|
state: outcome.state,
|
|
26823
|
-
previous_etag: outcome.previousEtag
|
|
27087
|
+
previous_etag: outcome.previousEtag,
|
|
27088
|
+
...outcome.warning ? { warning: outcome.warning } : {}
|
|
26824
27089
|
};
|
|
26825
27090
|
});
|
|
26826
27091
|
const overall = installed.every((i) => i.state === "unchanged") ? "unchanged" : installed.some((i) => i.state === "updated") ? "updated" : "installed";
|
|
@@ -27169,6 +27434,77 @@ var ThreadsMutedCommand = class ThreadsMutedCommand extends Command {
|
|
|
27169
27434
|
this.log(JSON.stringify(entries, null, 2));
|
|
27170
27435
|
}
|
|
27171
27436
|
};
|
|
27437
|
+
// src/oclif/commands/unlock.ts
|
|
27438
|
+
var UnlockCommand = class UnlockCommand extends Command {
|
|
27439
|
+
static summary = "Unlock global CLI credentials (permanently or temporarily with auto-relock)";
|
|
27440
|
+
static description = "Unlocks global Primitive CLI credentials previously locked with `primitive lock`. Refuses non-interactive shells by default so AI agents cannot unlock your global admin credentials on their own. Pass `--for 15m` to unlock temporarily and auto-relock.";
|
|
27441
|
+
static examples = [
|
|
27442
|
+
"<%= config.bin %> unlock --for 15m",
|
|
27443
|
+
"<%= config.bin %> unlock --for 1h",
|
|
27444
|
+
"<%= config.bin %> unlock"
|
|
27445
|
+
];
|
|
27446
|
+
static flags = {
|
|
27447
|
+
for: Flags.string({ description: "Temporarily unlock for a bounded duration before automatically re-locking (for example: 15m, 1h, 4h)" }),
|
|
27448
|
+
"force-non-interactive": Flags.boolean({
|
|
27449
|
+
description: "Allow unlocking outside an interactive TTY (intended for human-authored scripts only; AI agents must not pass this)",
|
|
27450
|
+
hidden: true
|
|
27451
|
+
}),
|
|
27452
|
+
json: Flags.boolean({ description: "Print the unlock result as JSON" })
|
|
27453
|
+
};
|
|
27454
|
+
async run() {
|
|
27455
|
+
const { flags } = await this.parse(UnlockCommand);
|
|
27456
|
+
try {
|
|
27457
|
+
if (!process.stdin.isTTY && !flags["force-non-interactive"]) throw new Errors.CLIError([
|
|
27458
|
+
"Refusing to unlock global Primitive credentials from a non-interactive shell.",
|
|
27459
|
+
"AI agents: Do NOT unlock the user's global admin credentials. Ask the user to share a scoped Access Pass (`primitive connect <url>`) or ask the user to run `primitive unlock` directly in their own terminal.",
|
|
27460
|
+
"Humans: Run `primitive unlock --for 15m` or `primitive unlock` directly in your interactive terminal."
|
|
27461
|
+
].join("\n"), { exit: 1 });
|
|
27462
|
+
if (flags.for) {
|
|
27463
|
+
const seconds = parseUnlockDurationSeconds(flags.for);
|
|
27464
|
+
const nowMs = Date.now();
|
|
27465
|
+
const existing = readCliLockState(this.config.configDir, () => nowMs);
|
|
27466
|
+
const lockedAt = existing.status === "unlocked" ? new Date(nowMs).toISOString() : existing.lockedAt;
|
|
27467
|
+
const reason = existing.status === "unlocked" ? null : existing.reason;
|
|
27468
|
+
const unlockedUntil = new Date(nowMs + seconds * 1e3).toISOString();
|
|
27469
|
+
writeCliLockState(this.config.configDir, {
|
|
27470
|
+
version: 1,
|
|
27471
|
+
locked: true,
|
|
27472
|
+
locked_at: lockedAt,
|
|
27473
|
+
unlocked_until: unlockedUntil,
|
|
27474
|
+
...reason ? { reason } : {}
|
|
27475
|
+
});
|
|
27476
|
+
if (flags.json) {
|
|
27477
|
+
this.log(JSON.stringify({
|
|
27478
|
+
status: "temporarily_unlocked",
|
|
27479
|
+
locked: false,
|
|
27480
|
+
unlocked_until: unlockedUntil
|
|
27481
|
+
}));
|
|
27482
|
+
return;
|
|
27483
|
+
}
|
|
27484
|
+
this.log(`Unlocked global Primitive credentials until ${unlockedUntil} (will auto-relock).`);
|
|
27485
|
+
this.log("Run `primitive lock` to re-lock earlier.");
|
|
27486
|
+
return;
|
|
27487
|
+
}
|
|
27488
|
+
const removed = removeCliLockState(this.config.configDir);
|
|
27489
|
+
if (flags.json) {
|
|
27490
|
+
this.log(JSON.stringify({
|
|
27491
|
+
status: "unlocked",
|
|
27492
|
+
locked: false,
|
|
27493
|
+
was_locked: removed
|
|
27494
|
+
}));
|
|
27495
|
+
return;
|
|
27496
|
+
}
|
|
27497
|
+
if (removed) {
|
|
27498
|
+
this.log("Unlocked global Primitive credentials.");
|
|
27499
|
+
this.log("Run `primitive lock` again when you want to protect global credentials from agent sessions.");
|
|
27500
|
+
} else this.log("Global Primitive credentials were already unlocked.");
|
|
27501
|
+
} catch (error) {
|
|
27502
|
+
if (error instanceof Errors.CLIError) throw error;
|
|
27503
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
27504
|
+
throw new Errors.CLIError(message, { exit: 1 });
|
|
27505
|
+
}
|
|
27506
|
+
}
|
|
27507
|
+
};
|
|
27172
27508
|
// src/oclif/commands/version.ts
|
|
27173
27509
|
/** The facts `--version` prints, as fields. `node` is Node's version without its leading v. */
|
|
27174
27510
|
function versionInfo(config) {
|
|
@@ -28801,7 +29137,13 @@ const OVERRIDDEN_OPERATION_IDS = /* @__PURE__ */ new Set([
|
|
|
28801
29137
|
"inbox:get-inbox-status",
|
|
28802
29138
|
"search:semantic-search",
|
|
28803
29139
|
"credits:redeem-credit-code",
|
|
28804
|
-
"cli:list-cli-orgs"
|
|
29140
|
+
"cli:list-cli-orgs",
|
|
29141
|
+
"activity:create-email-activity",
|
|
29142
|
+
"activity:create-thread-activity",
|
|
29143
|
+
"activity:get-thread-timeline",
|
|
29144
|
+
"activity:list-mail-activity-actors",
|
|
29145
|
+
"activity:list-org-mail-activity",
|
|
29146
|
+
"activity:update-thread-activity"
|
|
28805
29147
|
]);
|
|
28806
29148
|
const generatedCommands = Object.fromEntries(rawCliOperationManifest.filter((operation) => !OVERRIDDEN_OPERATION_IDS.has(operationId(operation))).map((operation) => [operationId(operation), createOperationCommand(canonicalOperation(operation))]));
|
|
28807
29149
|
generatedCommands["emails:get-email"] = createEmailsGetCommand(generatedCommands["emails:get-email"]);
|
|
@@ -28941,6 +29283,8 @@ const rawCommands = {
|
|
|
28941
29283
|
"org:secrets:remove": OrgSecretsRemoveCommand,
|
|
28942
29284
|
connect: ConnectCommand,
|
|
28943
29285
|
disconnect: DisconnectCommand,
|
|
29286
|
+
lock: LockCommand,
|
|
29287
|
+
unlock: UnlockCommand,
|
|
28944
29288
|
api: ApiCommand,
|
|
28945
29289
|
"payloads:push": PayloadsPushCommand,
|
|
28946
29290
|
"payloads:pull": PayloadsPullCommand,
|