@primitivedotdev/cli 3.0.0-preview.21 → 3.0.0-preview.23
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/README.md +12 -1
- package/dist/{api-command-Bab30eNp.js → api-command-CP8ir5Pv.js} +536 -209
- package/dist/{cli-command-names-BYbYdipl.js → cli-command-names-DteMqL-H.js} +43 -1
- package/dist/{cli-config-Ms_0vNjq.js → cli-config-DUQEYQ42.js} +489 -4
- package/dist/{json-output-xgN0ZLWP.js → json-output-BMZrLH47.js} +1 -1
- package/dist/{machine-session-cfgMKQ_U.js → machine-session-CE31cwx2.js} +6 -6
- package/dist/{notify-session-BRK9_xSb.js → notify-session-Dx54UpkT.js} +2 -2
- package/dist/oclif/auto-signal-worker.js +3 -3
- package/dist/oclif/auto-signals.js +1 -1
- package/dist/oclif/command-not-found.js +3 -2
- package/dist/oclif/index.js +849 -83
- package/dist/oclif/proxy-auto-detect.js +1 -1
- package/dist/oclif/receiver-heal.js +2 -3
- package/dist/oclif/root-signup-hint.js +1 -1
- package/dist/{repeats-Dj_o6c-X-CraZzs4t.js → repeats-Dj_o6c-X-x61TNLz-.js} +55 -4
- package/dist/{scoped-chat-YucNhX6U.js → scoped-chat-Bss3OjFI.js} +1 -1
- package/dist/{shared-mail-watch-BAPMsFNv.js → shared-mail-watch-DdtgJOrV.js} +12 -0
- package/dist/{signal-command-AOnn_Him.js → signal-command-CA55RTJh.js} +11 -7
- package/package.json +5 -5
package/dist/oclif/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { $t as
|
|
2
|
-
import { a as
|
|
1
|
+
import { $ as replyInteractionWarning, $t as resolveDomainNames, A as describeWake, An as revokeUserLogin, At as connectNextSteps, B as wakeRecipientField, Bt as countFromMeta, C as withApproval, Cn as selectedOrgFromEnv, Ct as sendWaitClampNotice, D as openBrowser, Dn as displayedRoleKey, Dt as thrownErrorExitCode, E as listenForCopyHotkey, En as credentialsFromUserLogin, Et as successfulSendOutcome, F as sentInThread, Fn as sanitizeForTerminal, Ft as currentMailSessionKey, G as pendingMailPath, Gt as focusProfile, H as claimPendingMail, Ht as focusFlagValues, I as serverMuted, In as shownLine, It as formatAlreadySentNotice, J as removePendingMail, Jt as manyDomainsSupported, K as readPendingMail, Kt as joinNames, L as serverRelationship, Ln as setKnownCommands, Lt as FOCUS_ENV, M as formatMailWakeLine, Mn as roleKeyText, Mt as generatedAgentName, N as latestOwnOutbound, Nn as switchCurrentOrg, Nt as identitySuggestions, O as explainPendingMailNotFound, On as fetchCliOrgs, P as readThreadContext, Pn as routeWarningLines, Pt as loadSkillLine, Q as replyExpectation, Qt as readDomainsOrRefusal, Rn as operationManifest, Rt as FOCUS_SERVER_SUPPORT, S as terminalApprovalIo, Sn as resolveCliApiRequestConfig, St as sendOutcomeExitCode, T as formatBrowserLoginInstructions, Tn as RESTRICTED_ROLE_NOTE, Tt as serializeErrorPayload, U as clearConsumedPendingMail, Ut as focusFlags, V as wakeRelationship, Vt as focusEmptyHint, W as clearReadPendingMail, Wt as focusForCorpus, X as interactionNextActions, Xt as oneDomainAtATimeError, Y as interactionHumanLine, Yt as normalizeDomainNames, Z as readEmailInteraction, Zt as queryScopesItself, _ as BROWSER_FLAG_DESCRIPTION, _t as formatSendRecordFailureSummary, a as createOperationCommand, an as withFlagSuggestion, at as assertValidIdempotencyKey, b as approveThenRerunHint, bn as refreshStoredCliCredentials, bt as sendErrorMessage, c as formatErrorPayload, cn as readCallerMailFor, ct as checkPriorReplies, d as networkErrorHint, dn as fetchBoundedPages, dt as excludeSignalReplies, en as resolveFocus, f as readTextFileFlag, fn as withBooleanFlagValues, ft as followUpCommandPrefix, g as writeErrorWithHints, gn as ConnectedAgentKeyRequiredError, gt as formatSendFailureSummary, h as surfaceUnauthorizedHint, hn as withAttachmentWait, ht as formatPriorRepliesWarning, i as TIME_FLAG_DESCRIPTION, in as writeFocusLine, it as apiResultHttpStatus, j as displayAddress, jn as roleKeyLabel, k as bareAddress, kn as isBuiltInRoleKey, kt as cliInvocation, l as hasControlCharacter$1, ln as formatFact, lt as classifySendError, m as runWithTiming, mn as ATTACHMENT_WAIT_MAX_MS, mt as formatPriorRepliesCheckSkipped, n as API_ERROR_CODES, nn as withFocusMeta, nt as MAX_SEND_WAIT_TIMEOUT_MS, o as extractErrorCode, on as emptyEmailListHint, ot as buildFollowUpCommand, p as refusesCredential, pn as ATTACHMENT_WAIT_FLAG_DESCRIPTION, pt as formatDeletedEarlierSendNotice, q as recordPendingMail, qt as loadSavedFocus, r as PAGED_LIMIT_MAX, rn as withoutFocus, rt as SEND_OUTCOME_HELP, s as extractErrorPayload, sn as mailReach, st as buildThrownSendFailureEnvelope, t as API_BASE_URL_FLAG_DESCRIPTION, tn as saveFocus, tt as IDEMPOTENCY_KEY_FLAG_DESCRIPTION, u as isGrantRefusal, un as isEmailId, ut as deriveSendIdempotencyKey, v as STEP_UP_HEADER$1, vn as createAuthenticatedCliApiClient, vt as priorRepliesThatWentOut, w as canOfferCopyHotkey, wn as CliOrgRefusedError, wt as sentHistoryWindowStart, x as promptLine$2, xn as refuseOrgSelectionForProfile, xt as sendIdentityFields, y as STEP_UP_TOKEN_FLAG_DESCRIPTION, yn as createCliApiClient, yt as reportSendCommandResult, z as wakeReadCommand, zt as NO_FOCUS } from "../api-command-CP8ir5Pv.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-DteMqL-H.js";
|
|
3
3
|
import { ignoreArgumentStdin } from "./command-stdin.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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
|
+
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-x61TNLz-.js";
|
|
6
|
+
import { C as readBundledConnectSkill, S as installedVersion, _ as NotificationOutcomeUnknownError, a as NotificationRetryError, b as installSkill, 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 bundledSkillNames, w as readBundledSkill, x as installedConnectSkillFile, y as connectSkillTarget } from "../notify-session-Dx54UpkT.js";
|
|
7
|
+
import { $ as loadCachedAgentPassByToken, A as saveActiveChatState, C as resolveCliAuth, D as deleteChatState, E as chatStatePath, F as agentProfileName, G as AGENT_PASS_PROFILE_ENV, I as agentProfilesDirectory, J as agentPassTokenSha256, K as AgentPassAuthError, M as AGENT_PROFILE_ENV, N as AgentConnectionSetupError, O as loadActiveChatState, P as agentProfileDirectory, T as saveSignupCredentials, U as requireDefaultLoginProfile, X as deleteAgentPass, Y as claimAccessPassRemote, Z as isAgentPassExpired, _ as credentialsPath, a as normalizeCliEnvironmentName, at as detectAgentRuntime, b as detectPrimitiveKeyEnvMisname, c as removeCliEnvironment, ct as PrimitiveApiClient, d as upsertCliEnvironment, et as parseAccessPassInput, g as credentialsLockPath, h as cliAccessTokenExpiresAt, i as loadCliConfig, it as saveAgentPass, j as AGENT_ADDRESS_ENV, k as loadChatConversationByLocalId, l as resolveConfigEnvironment, m as acquireCliCredentialsLock, n as deleteCliConfig, nt as resolveAgentPassSlot, o as parseHeaderAssignment, ot as detectRuntimeSession, q as agentPassMetadata, r as emptyCliConfig, rt as revokeAccessPassRemote, s as redactCliEnvironment, st as runtimeSessionVariableList, tt as readAgentPassFile, u as saveCliConfig, v as deleteCliCredentials, w as saveCliCredentials, x as loadCliCredentials, y as deleteCliCredentialsLock, z as loadConnectedAgentProfile } from "../cli-config-DUQEYQ42.js";
|
|
7
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";
|
|
8
|
-
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 { 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-
|
|
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-CE31cwx2.js";
|
|
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-Bss3OjFI.js";
|
|
10
11
|
import { autoSignalEligible, dispatchAutoRead, dispatchAutoWorking, haltAutoWorking, isSentSignal, readWorkingLease, restoreAutoWorking } from "./auto-signals.js";
|
|
11
|
-
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 { a as thrownErrorBody, i as runStreamingJson, n as guardJsonOutputCommands, r as jsonOutputRequested, t as JSON_OUTPUT_FLAG } from "../json-output-xgN0ZLWP.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-CA55RTJh.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";
|
|
@@ -70,6 +70,173 @@ const CLI_OMITTED_OPERATION_IDS = /* @__PURE__ */ new Set([
|
|
|
70
70
|
const rawCliOperationManifest = operationManifest.filter((operation) => !CLI_OMITTED_OPERATION_IDS.has(`${operation.tagCommand}:${operation.command}`));
|
|
71
71
|
/** CLI presentation names; the SDK manifest above retains its API identity. */
|
|
72
72
|
const cliOperationManifest = rawCliOperationManifest.map(canonicalOperation);
|
|
73
|
+
// src/oclif/command-pairs.ts
|
|
74
|
+
function flagsOf(command) {
|
|
75
|
+
return {
|
|
76
|
+
...command.flags,
|
|
77
|
+
...command.enableJsonFlag ? { json: JSON_OUTPUT_FLAG } : {}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function booleanFlag(flag) {
|
|
81
|
+
return flag?.type === "boolean" || flag?.options?.length === 2 && flag.options.includes("true") && flag.options.includes("false");
|
|
82
|
+
}
|
|
83
|
+
function delegateArgv(command, values, names, args) {
|
|
84
|
+
const definitions = flagsOf(command);
|
|
85
|
+
const argv = [];
|
|
86
|
+
for (const name of names) {
|
|
87
|
+
if (name === "json" && definitions[name] === void 0) continue;
|
|
88
|
+
const value = values[name];
|
|
89
|
+
if (value === void 0) continue;
|
|
90
|
+
const definition = definitions[name];
|
|
91
|
+
for (const item of Array.isArray(value) ? value : [value]) if (definition?.type === "boolean") argv.push(item === false ? `--no-${name}` : `--${name}`);
|
|
92
|
+
else argv.push(`--${name}=${String(item)}`);
|
|
93
|
+
}
|
|
94
|
+
const positional = Object.keys(command.args ?? {}).flatMap((name) => args[name] === void 0 ? [] : [String(args[name])]);
|
|
95
|
+
if (positional.length) argv.push("--", ...positional);
|
|
96
|
+
return argv;
|
|
97
|
+
}
|
|
98
|
+
/** One path with task inputs and structured request inputs, never two aliases. */
|
|
99
|
+
function combineCommandPair(task, request, options = {}) {
|
|
100
|
+
ignoreArgumentStdin(task);
|
|
101
|
+
ignoreArgumentStdin(request);
|
|
102
|
+
const taskFlags = flagsOf(task);
|
|
103
|
+
const requestFlags = flagsOf(request);
|
|
104
|
+
const flags = {};
|
|
105
|
+
for (const [name, flag] of Object.entries({
|
|
106
|
+
...requestFlags,
|
|
107
|
+
...taskFlags
|
|
108
|
+
})) {
|
|
109
|
+
const a = taskFlags[name];
|
|
110
|
+
const b = requestFlags[name];
|
|
111
|
+
flags[name] = {
|
|
112
|
+
...flag,
|
|
113
|
+
required: false,
|
|
114
|
+
default: a && b ? void 0 : flag.default,
|
|
115
|
+
...booleanFlag(a) && booleanFlag(b) ? {
|
|
116
|
+
type: "boolean",
|
|
117
|
+
allowNo: a?.allowNo || b?.allowNo || a?.type !== b?.type
|
|
118
|
+
} : {},
|
|
119
|
+
...typeof a?.max === "number" && typeof b?.max === "number" ? { max: Math.max(a.max, b.max) } : {}
|
|
120
|
+
};
|
|
121
|
+
if (flags[name]?.type === "boolean") delete flags[name].options;
|
|
122
|
+
}
|
|
123
|
+
const taskArgs = task.args ?? {};
|
|
124
|
+
const requestArgs = request.args ?? {};
|
|
125
|
+
const args = Object.fromEntries(Object.entries(Object.keys(taskArgs).length ? taskArgs : requestArgs).map(([name, argument]) => [name, {
|
|
126
|
+
...argument,
|
|
127
|
+
required: false,
|
|
128
|
+
ignoreStdin: true
|
|
129
|
+
}]));
|
|
130
|
+
const parseFlags = Object.fromEntries(Object.entries(flags).map(([name, flag]) => {
|
|
131
|
+
const neutral = {
|
|
132
|
+
...flag,
|
|
133
|
+
parse: async (value) => value
|
|
134
|
+
};
|
|
135
|
+
for (const key of [
|
|
136
|
+
"required",
|
|
137
|
+
"default",
|
|
138
|
+
"exclusive",
|
|
139
|
+
"exactlyOne",
|
|
140
|
+
"atLeastOne",
|
|
141
|
+
"dependsOn",
|
|
142
|
+
"relationships",
|
|
143
|
+
"min",
|
|
144
|
+
"max",
|
|
145
|
+
"options"
|
|
146
|
+
]) delete neutral[key];
|
|
147
|
+
return [name, neutral];
|
|
148
|
+
}));
|
|
149
|
+
const requestHelp = request.helpInputs;
|
|
150
|
+
const requiredTaskFlags = Object.keys(taskFlags).filter((name) => taskFlags[name]?.required);
|
|
151
|
+
const taskInput = [...Object.keys(taskArgs).filter((name) => taskArgs[name]?.required).map((name) => `<${name}>`), ...requiredTaskFlags.map((name) => `--${name}`)].join(" ");
|
|
152
|
+
class CombinedCommand extends Command {
|
|
153
|
+
static pairedCommand = true;
|
|
154
|
+
static summary = options.storedRedeploy ? request.summary : task.summary ?? request.summary;
|
|
155
|
+
static description = canonicalCliText(`${options.storedRedeploy ? "Redeploy the function's stored source, or pass --file to upload a new bundle with the existing secret and deployment-wait options.\n\n" : ""}${task.description ?? ""}\n\n${taskInput ? `Readable input form: ${taskInput}. Alternatively, use the request fields below or JSON.\n\n` : ""}Inputs exclusive to the readable form cannot be mixed with request-only fields. With --json, the result is in data and existing pagination metadata is preserved.\n\n${request.description ?? ""}`);
|
|
156
|
+
static helpInputs = {
|
|
157
|
+
requiredFlags: [.../* @__PURE__ */ new Set([...requiredTaskFlags, ...requestHelp?.requiredFlags ?? []])],
|
|
158
|
+
requiredJsonFields: requestHelp?.requiredJsonFields ?? []
|
|
159
|
+
};
|
|
160
|
+
static examples = task.examples?.map((example) => typeof example === "string" ? canonicalCliText(example) : {
|
|
161
|
+
...example,
|
|
162
|
+
command: canonicalCliText(example.command)
|
|
163
|
+
});
|
|
164
|
+
static flags = flags;
|
|
165
|
+
static args = args;
|
|
166
|
+
async run() {
|
|
167
|
+
const argv = withBooleanFlagValues(this.argv, flags);
|
|
168
|
+
const parsed = await this.parse({
|
|
169
|
+
flags: parseFlags,
|
|
170
|
+
args,
|
|
171
|
+
strict: true
|
|
172
|
+
}, argv).catch((error) => {
|
|
173
|
+
throw withFlagSuggestion(error, Object.keys(flags));
|
|
174
|
+
});
|
|
175
|
+
const values = parsed.flags;
|
|
176
|
+
const givenFlags = new Set(parsed.raw.flatMap((token) => token.type === "flag" ? [token.flag] : []));
|
|
177
|
+
const suppliedArgs = Object.entries(parsed.args).filter(([, value]) => value !== void 0);
|
|
178
|
+
const requestOnly = Object.keys(requestFlags).filter((name) => name !== "json" && !(name in taskFlags) && givenFlags.has(name));
|
|
179
|
+
const taskOnly = Object.keys(taskFlags).filter((name) => !(name in requestFlags) && givenFlags.has(name));
|
|
180
|
+
const needsRequest = requestOnly.length > 0 || suppliedArgs.some(([name]) => !(name in taskArgs)) || Object.entries(values).some(([name, value]) => {
|
|
181
|
+
if (!(name in requestFlags)) return false;
|
|
182
|
+
const limit = taskFlags[name]?.max;
|
|
183
|
+
const numeric = typeof value === "number" ? value : typeof value === "string" && value.trim() !== "" ? Number(value) : NaN;
|
|
184
|
+
return value === "" || value === false && taskFlags[name]?.type === "boolean" && !taskFlags[name]?.allowNo || Number.isFinite(numeric) && limit !== void 0 && numeric > limit;
|
|
185
|
+
}) || options.storedRedeploy === true && values.file === void 0;
|
|
186
|
+
if (needsRequest && taskOnly.length > 0) throw new Errors.CLIError(`Cannot combine ${taskOnly.map((name) => `--${name}`).join(", ")} with structured request input. Use the task flags together, or supply the request with API fields and JSON.`, { exit: 2 });
|
|
187
|
+
if (needsRequest && suppliedArgs.some(([name]) => !(name in requestArgs))) throw new Errors.CLIError("Positional task values cannot be combined with structured request flags. Put those values in the request's flags or JSON body.", { exit: 2 });
|
|
188
|
+
const selected = needsRequest ? request : task;
|
|
189
|
+
const forwarded = delegateArgv(selected, values, givenFlags, parsed.args);
|
|
190
|
+
if (values.json !== true) {
|
|
191
|
+
await selected.run(forwarded, this.config);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const output = captureOutput();
|
|
195
|
+
let thrown;
|
|
196
|
+
try {
|
|
197
|
+
await selected.run(forwarded, this.config);
|
|
198
|
+
} catch (error) {
|
|
199
|
+
thrown = error;
|
|
200
|
+
} finally {
|
|
201
|
+
output.restore();
|
|
202
|
+
}
|
|
203
|
+
const text = output.stdout.join("");
|
|
204
|
+
if (text.trim() && thrown === void 0 && !process.exitCode) {
|
|
205
|
+
const value = JSON.parse(text);
|
|
206
|
+
const document = value !== null && typeof value === "object" && !Array.isArray(value) && ("data" in value || "error" in value) ? value : { data: value };
|
|
207
|
+
if (!("error" in document) && document.success === void 0) document.success = true;
|
|
208
|
+
if (options.listPage && !("error" in document)) {
|
|
209
|
+
const page = document.data;
|
|
210
|
+
if (page !== null && typeof page === "object" && !Array.isArray(page)) {
|
|
211
|
+
const fields = page;
|
|
212
|
+
if (Array.isArray(fields.items)) {
|
|
213
|
+
const cursor = options.listPage === "keys" ? fields.next_cursor : fields.cursor;
|
|
214
|
+
document.data = fields.items;
|
|
215
|
+
document.meta = {
|
|
216
|
+
...document.meta,
|
|
217
|
+
cursor: cursor ?? null,
|
|
218
|
+
...options.listPage === "keys" ? { has_more: Boolean(cursor) } : { can_invite: fields.can_invite }
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (options.listPage === "members" && Array.isArray(document.data)) document.data = document.data.map((person) => {
|
|
224
|
+
if (person === null || typeof person !== "object") return person;
|
|
225
|
+
const row = person;
|
|
226
|
+
return typeof row.role === "string" ? {
|
|
227
|
+
...row,
|
|
228
|
+
role: displayedRoleKey(row.role)
|
|
229
|
+
} : row;
|
|
230
|
+
});
|
|
231
|
+
if (Array.isArray(document.data) && document.meta === void 0) document.meta = {};
|
|
232
|
+
this.log(JSON.stringify(document));
|
|
233
|
+
} else if (text) process.stdout.write(text);
|
|
234
|
+
for (const chunk of output.stderr) process.stderr.write(chunk);
|
|
235
|
+
if (thrown !== void 0) throw thrown;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return CombinedCommand;
|
|
239
|
+
}
|
|
73
240
|
// src/oclif/commands/activity.ts
|
|
74
241
|
const API_KEY_FLAG$3 = Flags.string({
|
|
75
242
|
description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
|
|
@@ -2938,6 +3105,160 @@ function endedClaimText(claim) {
|
|
|
2938
3105
|
const text = claim.trim();
|
|
2939
3106
|
return text !== "" && !/[\r\n]/.test(text) && text.length <= 500 ? text : "cleared";
|
|
2940
3107
|
}
|
|
3108
|
+
// src/oclif/commands/api.ts
|
|
3109
|
+
const ALLOWED_METHODS = /* @__PURE__ */ new Set([
|
|
3110
|
+
"GET",
|
|
3111
|
+
"POST",
|
|
3112
|
+
"PUT",
|
|
3113
|
+
"PATCH",
|
|
3114
|
+
"DELETE",
|
|
3115
|
+
"HEAD"
|
|
3116
|
+
]);
|
|
3117
|
+
function normalizeApiPath(rawPath) {
|
|
3118
|
+
const trimmed = rawPath.trim();
|
|
3119
|
+
if (!trimmed) throw new Errors.CLIError("API path must not be empty.", { exit: 1 });
|
|
3120
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(trimmed) || trimmed.startsWith("//")) throw new Errors.CLIError("Pass a relative API path like /emails or /drafts, not a full URL.", { exit: 1 });
|
|
3121
|
+
const withSlash = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
3122
|
+
let relative = withSlash;
|
|
3123
|
+
if (/^\/v1(?:$|[/?#])/.test(withSlash)) {
|
|
3124
|
+
const rest = withSlash.slice(3);
|
|
3125
|
+
relative = rest === "" || rest.startsWith("?") || rest.startsWith("#") ? `/${rest}` : rest;
|
|
3126
|
+
}
|
|
3127
|
+
const pathOnly = relative.split(/[?#]/, 1)[0] ?? "";
|
|
3128
|
+
let decodedPath;
|
|
3129
|
+
try {
|
|
3130
|
+
decodedPath = decodeURIComponent(pathOnly);
|
|
3131
|
+
} catch {
|
|
3132
|
+
throw new Errors.CLIError("API path contains invalid percent-encoding.", { exit: 1 });
|
|
3133
|
+
}
|
|
3134
|
+
const segments = decodedPath.split("/");
|
|
3135
|
+
if (segments.includes("..") || segments.includes(".")) throw new Errors.CLIError("API path must not contain relative dot segments (. or ..).", { exit: 1 });
|
|
3136
|
+
const resolved = new URL(`/v1${relative}`, "https://primitive.invalid");
|
|
3137
|
+
if (resolved.origin !== "https://primitive.invalid" || resolved.pathname !== "/v1" && !resolved.pathname.startsWith("/v1/")) throw new Errors.CLIError("API path must stay within /v1.", { exit: 1 });
|
|
3138
|
+
return relative;
|
|
3139
|
+
}
|
|
3140
|
+
async function readDataPayload(raw) {
|
|
3141
|
+
if (raw === "@-") {
|
|
3142
|
+
const chunks = [];
|
|
3143
|
+
for await (const chunk of process.stdin) chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
3144
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
3145
|
+
}
|
|
3146
|
+
if (raw.startsWith("@")) {
|
|
3147
|
+
const filePath = raw.slice(1);
|
|
3148
|
+
try {
|
|
3149
|
+
return readFileSync(filePath, "utf8");
|
|
3150
|
+
} catch (error) {
|
|
3151
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
3152
|
+
throw new Errors.CLIError(`Could not read request body from ${filePath}: ${detail}`, { exit: 1 });
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
return raw;
|
|
3156
|
+
}
|
|
3157
|
+
var ApiCommand = class ApiCommand extends Command {
|
|
3158
|
+
static summary = "Send an authenticated request to the Primitive REST API";
|
|
3159
|
+
static description = "Make an authenticated HTTP request against the Primitive v1 API using the active session Access Pass, PRIMITIVE_API_KEY, or saved OAuth login. Useful for exploring new or beta endpoints such as /drafts and /email-rules/:id/dry-run without manually passing bearer tokens.";
|
|
3160
|
+
static examples = [
|
|
3161
|
+
"<%= config.bin %> api GET /emails?limit=10",
|
|
3162
|
+
"<%= config.bin %> api GET /drafts",
|
|
3163
|
+
`<%= config.bin %> api POST /emails/11111111-1111-4111-8111-111111111111/drafts -d '{"body_text":"Thanks for sending this over."}'`
|
|
3164
|
+
];
|
|
3165
|
+
static args = {
|
|
3166
|
+
method: Args.string({
|
|
3167
|
+
description: "HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD)",
|
|
3168
|
+
required: true
|
|
3169
|
+
}),
|
|
3170
|
+
path: Args.string({
|
|
3171
|
+
description: "API path relative to /v1 (for example /emails, /drafts, or /v1/drafts)",
|
|
3172
|
+
required: true
|
|
3173
|
+
})
|
|
3174
|
+
};
|
|
3175
|
+
static flags = {
|
|
3176
|
+
data: Flags.string({
|
|
3177
|
+
char: "d",
|
|
3178
|
+
description: "Request body as a JSON string, @path/to/file.json, or @- to read from stdin"
|
|
3179
|
+
}),
|
|
3180
|
+
header: Flags.string({
|
|
3181
|
+
char: "H",
|
|
3182
|
+
description: "Additional request header as name=value (repeatable; Authorization is managed automatically)",
|
|
3183
|
+
multiple: true
|
|
3184
|
+
}),
|
|
3185
|
+
"api-key": Flags.string({
|
|
3186
|
+
description: "Override the Primitive API key for this request",
|
|
3187
|
+
env: "PRIMITIVE_API_KEY"
|
|
3188
|
+
}),
|
|
3189
|
+
"api-base-url": Flags.string({
|
|
3190
|
+
description: "Override the API base URL",
|
|
3191
|
+
env: "PRIMITIVE_API_BASE_URL",
|
|
3192
|
+
hidden: true
|
|
3193
|
+
}),
|
|
3194
|
+
include: Flags.boolean({
|
|
3195
|
+
char: "i",
|
|
3196
|
+
description: "Include HTTP status line before the response body"
|
|
3197
|
+
}),
|
|
3198
|
+
json: Flags.boolean({ description: "Ensure stdout contains valid JSON (wraps non-JSON responses when needed)" })
|
|
3199
|
+
};
|
|
3200
|
+
async run() {
|
|
3201
|
+
const { args, flags } = await this.parse(ApiCommand);
|
|
3202
|
+
const method = args.method.trim().toUpperCase();
|
|
3203
|
+
if (!ALLOWED_METHODS.has(method)) throw new Errors.CLIError(`Unsupported HTTP method "${args.method}". Use one of: ${[...ALLOWED_METHODS].join(", ")}.`, { exit: 1 });
|
|
3204
|
+
const path = normalizeApiPath(args.path);
|
|
3205
|
+
const authenticated = await createAuthenticatedCliApiClient({
|
|
3206
|
+
apiBaseUrl: flags["api-base-url"],
|
|
3207
|
+
apiKey: flags["api-key"],
|
|
3208
|
+
configDir: this.config.configDir
|
|
3209
|
+
});
|
|
3210
|
+
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 });
|
|
3211
|
+
if (flags.data !== void 0 && (method === "GET" || method === "HEAD")) throw new Errors.CLIError(`Request body (-d/--data) cannot be used with HTTP ${method}.`, { exit: 1 });
|
|
3212
|
+
const headers = {
|
|
3213
|
+
accept: "application/json",
|
|
3214
|
+
...authenticated.auth.agentPass || authenticated.auth.connectedAgent ? {} : authenticated.requestConfig.headers ?? {}
|
|
3215
|
+
};
|
|
3216
|
+
for (const rawHeader of flags.header ?? []) {
|
|
3217
|
+
const [name, value] = parseHeaderAssignment(rawHeader);
|
|
3218
|
+
const lower = name.toLowerCase();
|
|
3219
|
+
if (lower === "authorization") throw new Errors.CLIError("Authorization header is managed automatically and cannot be overridden with -H.", { exit: 1 });
|
|
3220
|
+
for (const existingKey of Object.keys(headers)) if (existingKey.toLowerCase() === lower) delete headers[existingKey];
|
|
3221
|
+
headers[name] = value;
|
|
3222
|
+
}
|
|
3223
|
+
for (const existingKey of Object.keys(headers)) if (existingKey.toLowerCase() === "authorization") delete headers[existingKey];
|
|
3224
|
+
headers.authorization = `Bearer ${authenticated.auth.apiKey}`;
|
|
3225
|
+
let body;
|
|
3226
|
+
if (flags.data !== void 0) {
|
|
3227
|
+
body = await readDataPayload(flags.data);
|
|
3228
|
+
if (!Object.keys(headers).some((key) => key.toLowerCase() === "content-type")) headers["content-type"] = "application/json";
|
|
3229
|
+
}
|
|
3230
|
+
const url = `${authenticated.auth.apiBaseUrl.replace(/\/+$/, "")}${path}`;
|
|
3231
|
+
let response;
|
|
3232
|
+
try {
|
|
3233
|
+
response = await fetch(url, {
|
|
3234
|
+
method,
|
|
3235
|
+
headers,
|
|
3236
|
+
...body !== void 0 ? { body } : {}
|
|
3237
|
+
});
|
|
3238
|
+
} catch (error) {
|
|
3239
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
3240
|
+
throw new Errors.CLIError(`API request failed: ${detail}`, { exit: 1 });
|
|
3241
|
+
}
|
|
3242
|
+
const rawBody = method === "HEAD" ? "" : await response.text();
|
|
3243
|
+
let parsedJson;
|
|
3244
|
+
let isJson = false;
|
|
3245
|
+
if (rawBody.trim().length > 0) try {
|
|
3246
|
+
parsedJson = JSON.parse(rawBody);
|
|
3247
|
+
isJson = true;
|
|
3248
|
+
} catch {
|
|
3249
|
+
isJson = false;
|
|
3250
|
+
}
|
|
3251
|
+
if (flags.include && !flags.json) this.log(`HTTP ${response.status} ${response.statusText}`.trim());
|
|
3252
|
+
if (isJson) this.log(JSON.stringify(parsedJson, null, 2));
|
|
3253
|
+
else if (flags.json) this.log(JSON.stringify({
|
|
3254
|
+
status: response.status,
|
|
3255
|
+
body: rawBody
|
|
3256
|
+
}));
|
|
3257
|
+
else if (rawBody.length > 0) process.stdout.write(rawBody.endsWith("\n") ? rawBody : `${rawBody}\n`);
|
|
3258
|
+
else if (!response.ok && !flags.include) this.log(`HTTP ${response.status} ${response.statusText}`.trim());
|
|
3259
|
+
if (!response.ok) process.exitCode = 1;
|
|
3260
|
+
}
|
|
3261
|
+
};
|
|
2941
3262
|
// src/oclif/commands/billing.ts
|
|
2942
3263
|
const BILLING_PAGE_PATH = "/app/settings/billing";
|
|
2943
3264
|
const BILLING_CLI_NOTE = "Reading and managing billing from the CLI will come in a future release.";
|
|
@@ -6894,6 +7215,146 @@ var ConfigCommand = class extends ConfigListCommand {
|
|
|
6894
7215
|
static summary = "Manage Primitive CLI request environments";
|
|
6895
7216
|
static description = "Manage local Primitive CLI request environments for API endpoint overrides and request headers.";
|
|
6896
7217
|
};
|
|
7218
|
+
// src/oclif/commands/connect.ts
|
|
7219
|
+
async function readStdinText() {
|
|
7220
|
+
if (process.stdin.isTTY) return "";
|
|
7221
|
+
const chunks = [];
|
|
7222
|
+
for await (const chunk of process.stdin) chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
7223
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
7224
|
+
}
|
|
7225
|
+
function formatBinding(pass) {
|
|
7226
|
+
if (pass.binding.kind === "session") return `${pass.binding.runtime} session ${pass.binding.session}`;
|
|
7227
|
+
if (pass.binding.kind === "profile") return `profile ${pass.binding.profile} (select with ${AGENT_PASS_PROFILE_ENV}=${pass.binding.profile})`;
|
|
7228
|
+
return "default local pass binding";
|
|
7229
|
+
}
|
|
7230
|
+
var ConnectCommand = class ConnectCommand extends Command {
|
|
7231
|
+
static summary = "Claim a Primitive Access Pass for this agent session";
|
|
7232
|
+
static description = "Claim a presigned Primitive Access Pass URL or pit_v1_ token, save the scoped credential locally with 0600 permissions bound to the active coding session (or --profile), and print the pass guide and scope summary without ever printing the secret API key. Re-running with the same pass reuses the local claim cache idempotently.";
|
|
7233
|
+
static examples = [
|
|
7234
|
+
"<%= config.bin %> connect https://api.primitive.dev/v1/access/pit_v1_example",
|
|
7235
|
+
"echo 'https://api.primitive.dev/v1/access/pit_v1_example' | <%= config.bin %> connect --json",
|
|
7236
|
+
"<%= config.bin %> connect --profile invoices pit_v1_example"
|
|
7237
|
+
];
|
|
7238
|
+
static args = { pass: Args.string({
|
|
7239
|
+
description: "Presigned Access Pass URL (https://.../v1/access/pit_v1_...) or pit_v1_ token. Omit to read from piped stdin.",
|
|
7240
|
+
required: false
|
|
7241
|
+
}) };
|
|
7242
|
+
static flags = {
|
|
7243
|
+
profile: Flags.string({ description: "Bind the claimed pass to a named local profile instead of auto-detecting the active session" }),
|
|
7244
|
+
"api-base-url": Flags.string({
|
|
7245
|
+
description: "Override the API base URL when claiming a bare pit_v1_ token",
|
|
7246
|
+
env: "PRIMITIVE_API_BASE_URL",
|
|
7247
|
+
hidden: true
|
|
7248
|
+
}),
|
|
7249
|
+
json: Flags.boolean({ description: "Print safe pass metadata, preview, and guide as JSON (never prints the API key)" })
|
|
7250
|
+
};
|
|
7251
|
+
async run() {
|
|
7252
|
+
const { args, flags } = await this.parse(ConnectCommand);
|
|
7253
|
+
try {
|
|
7254
|
+
const rawInput = args.pass ?? await readStdinText();
|
|
7255
|
+
const { token, apiBaseUrl } = parseAccessPassInput(rawInput, flags["api-base-url"]);
|
|
7256
|
+
const slot = resolveAgentPassSlot({
|
|
7257
|
+
configDir: this.config.configDir,
|
|
7258
|
+
profile: flags.profile
|
|
7259
|
+
});
|
|
7260
|
+
const revokeCommand = slot.binding.kind === "profile" ? `primitive disconnect --profile ${slot.binding.profile}` : "primitive disconnect";
|
|
7261
|
+
const tokenHash = agentPassTokenSha256(token);
|
|
7262
|
+
try {
|
|
7263
|
+
const existing = readAgentPassFile(slot.path);
|
|
7264
|
+
if (existing && !isAgentPassExpired(existing) && 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`);
|
|
7265
|
+
} catch {}
|
|
7266
|
+
const cached = loadCachedAgentPassByToken({
|
|
7267
|
+
configDir: this.config.configDir,
|
|
7268
|
+
token
|
|
7269
|
+
});
|
|
7270
|
+
if (cached) {
|
|
7271
|
+
const rebound = {
|
|
7272
|
+
...cached,
|
|
7273
|
+
binding: slot.binding
|
|
7274
|
+
};
|
|
7275
|
+
saveAgentPass({
|
|
7276
|
+
configDir: this.config.configDir,
|
|
7277
|
+
pass: rebound,
|
|
7278
|
+
slotPath: slot.path
|
|
7279
|
+
});
|
|
7280
|
+
const meta = agentPassMetadata(rebound);
|
|
7281
|
+
if (flags.json) {
|
|
7282
|
+
this.log(JSON.stringify({
|
|
7283
|
+
status: "reused",
|
|
7284
|
+
pass: meta,
|
|
7285
|
+
revoke_command: revokeCommand
|
|
7286
|
+
}));
|
|
7287
|
+
return;
|
|
7288
|
+
}
|
|
7289
|
+
this.log(`Reused saved Access Pass "${meta.label}" (${meta.mode}).`);
|
|
7290
|
+
this.log(`Bound to: ${formatBinding(rebound)}`);
|
|
7291
|
+
this.log(`Expires at: ${meta.expires_at}`);
|
|
7292
|
+
if (meta.slice_summary) this.log(`Scope: ${meta.slice_summary}`);
|
|
7293
|
+
this.log(`Run \`${revokeCommand}\` when finished to revoke this pass.`);
|
|
7294
|
+
return;
|
|
7295
|
+
}
|
|
7296
|
+
const claimed = await claimAccessPassRemote({
|
|
7297
|
+
token,
|
|
7298
|
+
apiBaseUrl
|
|
7299
|
+
});
|
|
7300
|
+
const stored = {
|
|
7301
|
+
version: 1,
|
|
7302
|
+
auth_method: "agent_pass",
|
|
7303
|
+
api_key: claimed.api_key,
|
|
7304
|
+
api_base_url: claimed.api_base_url,
|
|
7305
|
+
pass_id: claimed.pass_id,
|
|
7306
|
+
key_id: claimed.key_id,
|
|
7307
|
+
label: claimed.label,
|
|
7308
|
+
mode: claimed.mode,
|
|
7309
|
+
...claimed.purpose ? { purpose: claimed.purpose } : {},
|
|
7310
|
+
...claimed.profile_hint ? { profile_hint: claimed.profile_hint } : {},
|
|
7311
|
+
...claimed.mcp_url ? { mcp_url: claimed.mcp_url } : {},
|
|
7312
|
+
expires_at: claimed.expires_at,
|
|
7313
|
+
slice_summary: claimed.slice_summary,
|
|
7314
|
+
claimed_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7315
|
+
revoked_at: null,
|
|
7316
|
+
token_sha256: tokenHash,
|
|
7317
|
+
binding: slot.binding
|
|
7318
|
+
};
|
|
7319
|
+
saveAgentPass({
|
|
7320
|
+
configDir: this.config.configDir,
|
|
7321
|
+
pass: stored,
|
|
7322
|
+
slotPath: slot.path
|
|
7323
|
+
});
|
|
7324
|
+
const meta = agentPassMetadata(stored);
|
|
7325
|
+
if (flags.json) {
|
|
7326
|
+
this.log(JSON.stringify({
|
|
7327
|
+
status: "connected",
|
|
7328
|
+
pass: meta,
|
|
7329
|
+
preview: claimed.preview,
|
|
7330
|
+
guide: claimed.guide,
|
|
7331
|
+
revoke_command: revokeCommand
|
|
7332
|
+
}));
|
|
7333
|
+
return;
|
|
7334
|
+
}
|
|
7335
|
+
this.log(`Connected with Access Pass "${meta.label}" (${meta.mode}).`);
|
|
7336
|
+
this.log(`Bound to: ${formatBinding(stored)}`);
|
|
7337
|
+
this.log(`Expires at: ${meta.expires_at}`);
|
|
7338
|
+
if (meta.slice_summary) this.log(`Scope: ${meta.slice_summary}`);
|
|
7339
|
+
if (typeof claimed.guide === "string" && claimed.guide.trim()) {
|
|
7340
|
+
this.log("");
|
|
7341
|
+
this.log(claimed.guide.trim());
|
|
7342
|
+
} else if (claimed.guide && typeof claimed.guide === "object") {
|
|
7343
|
+
this.log("");
|
|
7344
|
+
this.log(JSON.stringify(claimed.guide, null, 2));
|
|
7345
|
+
}
|
|
7346
|
+
if (claimed.preview) {
|
|
7347
|
+
this.log("");
|
|
7348
|
+
this.log(`Preview: ${JSON.stringify(claimed.preview)}`);
|
|
7349
|
+
}
|
|
7350
|
+
this.log("");
|
|
7351
|
+
this.log(`When finished, revoke this pass with: ${revokeCommand}`);
|
|
7352
|
+
} catch (error) {
|
|
7353
|
+
const message = error instanceof AgentPassAuthError || error instanceof Error ? error.message : String(error);
|
|
7354
|
+
throw new Errors.CLIError(message, { exit: 1 });
|
|
7355
|
+
}
|
|
7356
|
+
}
|
|
7357
|
+
};
|
|
6897
7358
|
// src/oclif/commands/contact-request-shared.ts
|
|
6898
7359
|
async function contactCommandContext(command, flags, purpose = "Contact requests") {
|
|
6899
7360
|
const { apiClient, auth } = await createAuthenticatedCliApiClient({
|
|
@@ -7330,6 +7791,86 @@ var CreditsBalanceCommand = class CreditsBalanceCommand extends Command {
|
|
|
7330
7791
|
});
|
|
7331
7792
|
}
|
|
7332
7793
|
};
|
|
7794
|
+
// src/oclif/commands/disconnect.ts
|
|
7795
|
+
var DisconnectCommand = class DisconnectCommand extends Command {
|
|
7796
|
+
static summary = "Revoke and clear the active Primitive Access Pass";
|
|
7797
|
+
static description = "Revoke the Access Pass bound to the current coding session (or --profile) via POST /v1/keys/me/revoke and remove its local 0600 credential file. Use --local-only to clear an expired or unreadable local binding without contacting the API.";
|
|
7798
|
+
static examples = [
|
|
7799
|
+
"<%= config.bin %> disconnect",
|
|
7800
|
+
"<%= config.bin %> disconnect --profile invoices",
|
|
7801
|
+
"<%= config.bin %> disconnect --local-only --json"
|
|
7802
|
+
];
|
|
7803
|
+
static flags = {
|
|
7804
|
+
profile: Flags.string({ description: "Disconnect a named Access Pass profile" }),
|
|
7805
|
+
"local-only": Flags.boolean({ description: "Delete the local Access Pass file without calling POST /v1/keys/me/revoke" }),
|
|
7806
|
+
json: Flags.boolean({ description: "Print disconnect status as JSON" })
|
|
7807
|
+
};
|
|
7808
|
+
async run() {
|
|
7809
|
+
const { flags } = await this.parse(DisconnectCommand);
|
|
7810
|
+
try {
|
|
7811
|
+
const slot = resolveAgentPassSlot({
|
|
7812
|
+
configDir: this.config.configDir,
|
|
7813
|
+
profile: flags.profile
|
|
7814
|
+
});
|
|
7815
|
+
let stored = null;
|
|
7816
|
+
let unreadableSlot = false;
|
|
7817
|
+
try {
|
|
7818
|
+
stored = readAgentPassFile(slot.path);
|
|
7819
|
+
} catch (error) {
|
|
7820
|
+
if (!flags["local-only"]) {
|
|
7821
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
7822
|
+
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.`);
|
|
7823
|
+
}
|
|
7824
|
+
unreadableSlot = existsSync(slot.path);
|
|
7825
|
+
}
|
|
7826
|
+
if (!stored && !unreadableSlot) {
|
|
7827
|
+
if (flags.json) {
|
|
7828
|
+
this.log(JSON.stringify({
|
|
7829
|
+
status: "not_connected",
|
|
7830
|
+
binding: slot.binding,
|
|
7831
|
+
revoked: false
|
|
7832
|
+
}));
|
|
7833
|
+
return;
|
|
7834
|
+
}
|
|
7835
|
+
this.log("No active Access Pass is bound to this session.");
|
|
7836
|
+
return;
|
|
7837
|
+
}
|
|
7838
|
+
let revoked = false;
|
|
7839
|
+
let alreadyRevoked = false;
|
|
7840
|
+
if (!flags["local-only"] && stored) {
|
|
7841
|
+
const result = await revokeAccessPassRemote({
|
|
7842
|
+
apiKey: stored.api_key,
|
|
7843
|
+
apiBaseUrl: stored.api_base_url
|
|
7844
|
+
});
|
|
7845
|
+
revoked = result.revoked;
|
|
7846
|
+
alreadyRevoked = result.alreadyRevoked;
|
|
7847
|
+
}
|
|
7848
|
+
deleteAgentPass({
|
|
7849
|
+
configDir: this.config.configDir,
|
|
7850
|
+
slotPath: slot.path,
|
|
7851
|
+
tokenSha256: stored?.token_sha256 || void 0
|
|
7852
|
+
});
|
|
7853
|
+
if (flags.json) {
|
|
7854
|
+
this.log(JSON.stringify({
|
|
7855
|
+
status: "disconnected",
|
|
7856
|
+
label: stored?.label ?? null,
|
|
7857
|
+
binding: slot.binding,
|
|
7858
|
+
revoked,
|
|
7859
|
+
already_revoked: alreadyRevoked,
|
|
7860
|
+
local_only: Boolean(flags["local-only"])
|
|
7861
|
+
}));
|
|
7862
|
+
return;
|
|
7863
|
+
}
|
|
7864
|
+
const name = stored?.label ? ` "${stored.label}"` : "";
|
|
7865
|
+
if (flags["local-only"]) this.log(`Cleared local Access Pass${name} binding without contacting Primitive.`);
|
|
7866
|
+
else if (alreadyRevoked) this.log(`Disconnected Access Pass${name} (key was already expired or revoked on Primitive).`);
|
|
7867
|
+
else this.log(`Revoked and disconnected Access Pass${name}.`);
|
|
7868
|
+
} catch (error) {
|
|
7869
|
+
const message = error instanceof AgentPassAuthError || error instanceof Error ? error.message : String(error);
|
|
7870
|
+
throw new Errors.CLIError(message, { exit: 1 });
|
|
7871
|
+
}
|
|
7872
|
+
}
|
|
7873
|
+
};
|
|
7333
7874
|
// src/oclif/commands/doctor.ts
|
|
7334
7875
|
const MIN_NODE_MAJOR = 22;
|
|
7335
7876
|
function renderRow({ label, outcome }) {
|
|
@@ -7581,6 +8122,34 @@ function checkReceiverStart(configDir, profileName) {
|
|
|
7581
8122
|
return null;
|
|
7582
8123
|
}
|
|
7583
8124
|
}
|
|
8125
|
+
async function checkAgentPassGrant(apiBaseUrl, apiKey) {
|
|
8126
|
+
try {
|
|
8127
|
+
const response = await fetch(`${apiBaseUrl.replace(/\/+$/, "")}/whoami/grant`, {
|
|
8128
|
+
method: "GET",
|
|
8129
|
+
headers: {
|
|
8130
|
+
authorization: `Bearer ${apiKey}`,
|
|
8131
|
+
accept: "application/json"
|
|
8132
|
+
}
|
|
8133
|
+
});
|
|
8134
|
+
const payload = await response.json().catch(() => null);
|
|
8135
|
+
if (!response.ok) return {
|
|
8136
|
+
status: "fail",
|
|
8137
|
+
message: `Access Pass rejected by API (${payload?.error && typeof payload.error === "object" ? JSON.stringify(payload.error).slice(0, 300) : `HTTP ${response.status}`})`,
|
|
8138
|
+
hint: "The Access Pass may have expired or been revoked. Run `primitive disconnect --local-only` and reconnect with a fresh pass."
|
|
8139
|
+
};
|
|
8140
|
+
const perms = Array.isArray(payload?.data?.permissions) ? payload.data.permissions.length : null;
|
|
8141
|
+
return {
|
|
8142
|
+
status: "ok",
|
|
8143
|
+
message: perms !== null ? `verified via /whoami/grant (${perms} permission${perms === 1 ? "" : "s"})` : "verified via /whoami/grant"
|
|
8144
|
+
};
|
|
8145
|
+
} catch (error) {
|
|
8146
|
+
return {
|
|
8147
|
+
status: "fail",
|
|
8148
|
+
message: `Could not reach /whoami/grant: ${error instanceof Error ? error.message : String(error)}`,
|
|
8149
|
+
hint: "Check network connectivity and proxy settings."
|
|
8150
|
+
};
|
|
8151
|
+
}
|
|
8152
|
+
}
|
|
7584
8153
|
var DoctorCommand = class DoctorCommand extends Command {
|
|
7585
8154
|
static description = `Run a one-shot environment health check: Node version, proxy env, CLI auth resolution, /account reachability, and verified-domain status. With PRIMITIVE_AGENT_PROFILE selected, reports saved identity offline and points to whoami and exact listener status instead of account-only checks. Prints actionable hints for each warning or failure.`;
|
|
7586
8155
|
static summary = "Check the local environment and live API for common problems";
|
|
@@ -7608,15 +8177,30 @@ var DoctorCommand = class DoctorCommand extends Command {
|
|
|
7608
8177
|
label: "Proxy env",
|
|
7609
8178
|
outcome: checkProxy()
|
|
7610
8179
|
});
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
8180
|
+
let resolvedAuth = null;
|
|
8181
|
+
let authError = null;
|
|
8182
|
+
try {
|
|
8183
|
+
resolvedAuth = resolveCliAuth({
|
|
8184
|
+
apiKey: flags["api-key"],
|
|
8185
|
+
apiBaseUrl: flags["api-base-url"],
|
|
8186
|
+
configDir: this.config.configDir
|
|
8187
|
+
});
|
|
8188
|
+
} catch (error) {
|
|
8189
|
+
if (error instanceof AgentPassAuthError) authError = error.message;
|
|
8190
|
+
else throw error;
|
|
8191
|
+
}
|
|
8192
|
+
const connected = resolvedAuth?.connectedAgent;
|
|
8193
|
+
const activePass = resolvedAuth?.agentPass;
|
|
8194
|
+
const apiKeyCheck = authError ? {
|
|
8195
|
+
status: "fail",
|
|
8196
|
+
message: authError
|
|
8197
|
+
} : connected ? {
|
|
7617
8198
|
status: "warn",
|
|
7618
8199
|
message: `Saved connected profile ${connected.profileName} for ${connected.agentAddress} (offline; live authentication and receiving not verified)`,
|
|
7619
8200
|
hint: `Use \`${AGENT_PROFILE_ENV}=${connected.profileName} ${cliInvocation(process.argv[1])} whoami --json\` for saved identity and \`${receiverStatusCommand(this.config.configDir, connected.profileName).command}\` for this profile's receiver.`
|
|
8201
|
+
} : activePass ? {
|
|
8202
|
+
status: "ok",
|
|
8203
|
+
message: `Access Pass "${activePass.label}" (${activePass.mode}, expires ${activePass.expires_at})`
|
|
7620
8204
|
} : checkApiKey({
|
|
7621
8205
|
apiKey: flags["api-key"],
|
|
7622
8206
|
configDir: this.config.configDir
|
|
@@ -7631,23 +8215,31 @@ var DoctorCommand = class DoctorCommand extends Command {
|
|
|
7631
8215
|
outcome: receiverStart
|
|
7632
8216
|
});
|
|
7633
8217
|
if (!connected && apiKeyCheck.status !== "fail") {
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
apiBaseUrl: flags["api-base-url"],
|
|
7637
|
-
configDir: this.config.configDir
|
|
7638
|
-
});
|
|
7639
|
-
if (auth.apiKey !== void 0) {
|
|
7640
|
-
const accountCheck = await checkAccount(apiClient);
|
|
8218
|
+
if (activePass && resolvedAuth?.apiKey) {
|
|
8219
|
+
const grantOutcome = await checkAgentPassGrant(resolvedAuth.apiBaseUrl, resolvedAuth.apiKey);
|
|
7641
8220
|
rows.push({
|
|
7642
8221
|
label: "API auth",
|
|
7643
|
-
outcome:
|
|
8222
|
+
outcome: grantOutcome
|
|
8223
|
+
});
|
|
8224
|
+
} else {
|
|
8225
|
+
const { apiClient, auth } = await createAuthenticatedCliApiClient({
|
|
8226
|
+
apiKey: flags["api-key"],
|
|
8227
|
+
apiBaseUrl: flags["api-base-url"],
|
|
8228
|
+
configDir: this.config.configDir
|
|
7644
8229
|
});
|
|
7645
|
-
if (
|
|
7646
|
-
const
|
|
8230
|
+
if (auth.apiKey !== void 0) {
|
|
8231
|
+
const accountCheck = await checkAccount(apiClient);
|
|
7647
8232
|
rows.push({
|
|
7648
|
-
label: "
|
|
7649
|
-
outcome:
|
|
8233
|
+
label: "API auth",
|
|
8234
|
+
outcome: accountCheck.outcome
|
|
7650
8235
|
});
|
|
8236
|
+
if (accountCheck.outcome.status === "ok") {
|
|
8237
|
+
const domainsOutcome = await checkDomains(apiClient);
|
|
8238
|
+
rows.push({
|
|
8239
|
+
label: "Domains",
|
|
8240
|
+
outcome: domainsOutcome
|
|
8241
|
+
});
|
|
8242
|
+
}
|
|
7651
8243
|
}
|
|
7652
8244
|
}
|
|
7653
8245
|
}
|
|
@@ -8018,7 +8610,7 @@ var EmailsFactsCommand = class EmailsFactsCommand extends Command {
|
|
|
8018
8610
|
static summary = "Show what the classifier read from an email";
|
|
8019
8611
|
static description = `Show what the classifier read from a received email, from its understanding.facts (\`primitive emails get <id> --json\`): one fact per line with its value and confidence, for example \`is_cold_outreach: true at 0.69\`, or \`topics: [billing, invoice] at 0.80\` for a multi fact. An email with no classification yet, or none to read, prints why on stderr and nothing on stdout; with --json it prints the classification, or null.
|
|
8020
8612
|
|
|
8021
|
-
These are the facts as the classifier wrote them; a test's results[].values shows what a rule's conditions compared.`;
|
|
8613
|
+
With --json, the classification or null is in data, alongside success and meta. These are the facts as the classifier wrote them; a test's results[].values shows what a rule's conditions compared.`;
|
|
8022
8614
|
static examples = ["<%= config.bin %> emails facts 3f0e1c2a-8b7d-4c6e-9a1b-2d3e4f5a6b7c", "<%= config.bin %> emails facts --id 3f0e1c2a-8b7d-4c6e-9a1b-2d3e4f5a6b7c --json"];
|
|
8023
8615
|
static args = { id: Args.string({
|
|
8024
8616
|
description: ID_DESCRIPTION,
|
|
@@ -8026,7 +8618,7 @@ These are the facts as the classifier wrote them; a test's results[].values show
|
|
|
8026
8618
|
}) };
|
|
8027
8619
|
static flags = {
|
|
8028
8620
|
id: Flags.string({ description: ID_DESCRIPTION }),
|
|
8029
|
-
json: Flags.boolean({ description: "Print the classification (id, vocabulary, classified_at, facts)
|
|
8621
|
+
json: Flags.boolean({ description: "Print success, data and meta as one JSON document. data is the classification (id, vocabulary, classified_at, facts), or null when the email has none. A failure prints the error with exit_code." }),
|
|
8030
8622
|
"api-key": Flags.string({
|
|
8031
8623
|
description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
|
|
8032
8624
|
env: "PRIMITIVE_API_KEY"
|
|
@@ -8069,10 +8661,16 @@ These are the facts as the classifier wrote them; a test's results[].values show
|
|
|
8069
8661
|
process.exitCode = 1;
|
|
8070
8662
|
return;
|
|
8071
8663
|
}
|
|
8072
|
-
const
|
|
8664
|
+
const envelope = read.data;
|
|
8665
|
+
const understanding = envelope?.data?.understanding;
|
|
8073
8666
|
const classification = classificationFromUnderstanding(understanding);
|
|
8074
8667
|
if (flags.json) {
|
|
8075
|
-
this.log(JSON.stringify(
|
|
8668
|
+
this.log(JSON.stringify({
|
|
8669
|
+
...envelope,
|
|
8670
|
+
success: true,
|
|
8671
|
+
data: classification,
|
|
8672
|
+
meta: envelope?.meta ?? {}
|
|
8673
|
+
}, null, 2));
|
|
8076
8674
|
return;
|
|
8077
8675
|
}
|
|
8078
8676
|
const lines = classification ? Object.entries(classification.facts).map(([name, fact]) => formatFact(name, isRecord$1(fact) ? fact : {})) : [];
|
|
@@ -8872,7 +9470,7 @@ function createEmailsGetCommand(base) {
|
|
|
8872
9470
|
}
|
|
8873
9471
|
// src/oclif/commands/emails-latest.ts
|
|
8874
9472
|
const DEFAULT_LIMIT$2 = 10;
|
|
8875
|
-
const
|
|
9473
|
+
const API_PAGE_MAXIMUM = 100;
|
|
8876
9474
|
const SUBJECT_DISPLAY_WIDTH = 50;
|
|
8877
9475
|
const ADDRESS_DISPLAY_WIDTH = 32;
|
|
8878
9476
|
const ID_DISPLAY_WIDTH_SHORT = 8;
|
|
@@ -8906,7 +9504,7 @@ function formatHeader$1(idWidth) {
|
|
|
8906
9504
|
return `${"ID".padEnd(idWidth)} ${"RECEIVED (UTC)".padEnd(RECEIVED_DISPLAY_WIDTH)} ${"FROM".padEnd(ADDRESS_DISPLAY_WIDTH)} ${"TO".padEnd(ADDRESS_DISPLAY_WIDTH)} ${"AWAITING".padEnd(AWAITING_DISPLAY_WIDTH)} ${"REPLIES".padEnd(REPLIES_DISPLAY_WIDTH)} SUBJECT`;
|
|
8907
9505
|
}
|
|
8908
9506
|
var EmailsLatestCommand = class EmailsLatestCommand extends Command {
|
|
8909
|
-
static description = `Print the N most recent inbound emails as a one-line-per-row text table. Designed for quick triage and visual scanning. For programmatic access, use \`primitive emails list\` (full JSON envelope, cursor pagination, filters) or pass \`--json\` here for the same
|
|
9507
|
+
static description = `Print the N most recent inbound emails as a one-line-per-row text table. Designed for quick triage and visual scanning. For programmatic access, use \`primitive emails list\` (full JSON envelope, cursor pagination, filters) or pass \`--json\` here for the same response envelope, including cursor pagination.
|
|
8910
9508
|
|
|
8911
9509
|
ID display is TTY-aware. When STDOUT is a terminal, the table truncates each row's id to the first ${ID_DISPLAY_WIDTH_SHORT} characters for readability. When STDOUT is piped or redirected (the row stream is being consumed by another command), the full UUID is printed so the id can be fed straight back into \`emails:get\`, \`emails:delete\`, etc. without a separate \`--json\` round-trip.
|
|
8912
9510
|
|
|
@@ -8916,7 +9514,8 @@ var EmailsLatestCommand = class EmailsLatestCommand extends Command {
|
|
|
8916
9514
|
static summary = "Show the most recent inbound emails as a compact table";
|
|
8917
9515
|
static examples = [
|
|
8918
9516
|
"<%= config.bin %> emails latest",
|
|
8919
|
-
"<%= config.bin %> emails latest --limit
|
|
9517
|
+
"<%= config.bin %> emails latest --limit 200",
|
|
9518
|
+
"<%= config.bin %> emails latest --cursor <cursor> --json",
|
|
8920
9519
|
"<%= config.bin %> emails latest | head -1 | awk '{print $1}' # full UUID since piped",
|
|
8921
9520
|
"<%= config.bin %> emails latest --json | jq '.data[0].id'",
|
|
8922
9521
|
"<%= config.bin %> emails latest --awaiting you"
|
|
@@ -8932,11 +9531,12 @@ var EmailsLatestCommand = class EmailsLatestCommand extends Command {
|
|
|
8932
9531
|
hidden: true
|
|
8933
9532
|
}),
|
|
8934
9533
|
limit: Flags.integer({
|
|
8935
|
-
description: `Number of rows to print (1-${
|
|
9534
|
+
description: `Number of rows to print (1-${PAGED_LIMIT_MAX}, default ${DEFAULT_LIMIT$2}), fetched in pages of at most ${API_PAGE_MAXIMUM}. Continue with --cursor for more.`,
|
|
8936
9535
|
default: DEFAULT_LIMIT$2,
|
|
8937
9536
|
min: 1,
|
|
8938
|
-
max:
|
|
9537
|
+
max: PAGED_LIMIT_MAX
|
|
8939
9538
|
}),
|
|
9539
|
+
cursor: Flags.string({ description: "Continue from meta.cursor of a previous listing. The next cursor is printed on stderr, or in meta.cursor with --json." }),
|
|
8940
9540
|
awaiting: Flags.string({
|
|
8941
9541
|
description: AWAITING_FLAG_DESCRIPTION,
|
|
8942
9542
|
options: [...AWAITING_VALUES]
|
|
@@ -8963,14 +9563,25 @@ var EmailsLatestCommand = class EmailsLatestCommand extends Command {
|
|
|
8963
9563
|
});
|
|
8964
9564
|
const query = {
|
|
8965
9565
|
limit: flags.limit,
|
|
9566
|
+
...flags.cursor !== void 0 ? { cursor: flags.cursor } : {},
|
|
8966
9567
|
...awaiting ? { awaiting } : {},
|
|
8967
9568
|
...focus.params
|
|
8968
9569
|
};
|
|
8969
|
-
const
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
9570
|
+
const paged = await fetchBoundedPages({
|
|
9571
|
+
wanted: flags.limit,
|
|
9572
|
+
maximum: API_PAGE_MAXIMUM,
|
|
9573
|
+
cursor: flags.cursor,
|
|
9574
|
+
call: (limit, cursor) => listEmails({
|
|
9575
|
+
client: apiClient.client,
|
|
9576
|
+
query: {
|
|
9577
|
+
...query,
|
|
9578
|
+
limit,
|
|
9579
|
+
cursor
|
|
9580
|
+
},
|
|
9581
|
+
responseStyle: "fields"
|
|
9582
|
+
})
|
|
8973
9583
|
});
|
|
9584
|
+
const result = paged.result;
|
|
8974
9585
|
if (result.error) {
|
|
8975
9586
|
const errorPayload = extractErrorPayload(result.error);
|
|
8976
9587
|
if (awaiting && isAwaitingRejectedError(errorPayload)) {
|
|
@@ -8988,7 +9599,7 @@ var EmailsLatestCommand = class EmailsLatestCommand extends Command {
|
|
|
8988
9599
|
process.exitCode = 1;
|
|
8989
9600
|
return;
|
|
8990
9601
|
}
|
|
8991
|
-
const envelope = result.data;
|
|
9602
|
+
const envelope = paged.envelope ?? result.data;
|
|
8992
9603
|
if (awaiting) try {
|
|
8993
9604
|
assertAwaitingFilterRows(envelope?.data ?? [], "GET /emails");
|
|
8994
9605
|
} catch (error) {
|
|
@@ -8998,7 +9609,12 @@ var EmailsLatestCommand = class EmailsLatestCommand extends Command {
|
|
|
8998
9609
|
return;
|
|
8999
9610
|
}
|
|
9000
9611
|
const rows = envelope?.data ?? [];
|
|
9001
|
-
const note = rows.length === 0
|
|
9612
|
+
const note = (rows.length === 0 && (flags.cursor !== void 0 || envelope?.meta?.cursor) ? emptyEmailListHint({
|
|
9613
|
+
filterFlags: awaiting ? [`--awaiting ${awaiting}`] : [],
|
|
9614
|
+
...flags.cursor !== void 0 ? { pastFlag: "--cursor" } : {},
|
|
9615
|
+
nextCursor: envelope?.meta?.cursor,
|
|
9616
|
+
caller: null
|
|
9617
|
+
}) : null) ?? (rows.length === 0 ? await focusEmptyHint(focus, async () => {
|
|
9002
9618
|
const counted = await listEmails({
|
|
9003
9619
|
client: apiClient.client,
|
|
9004
9620
|
query: {
|
|
@@ -9009,9 +9625,10 @@ var EmailsLatestCommand = class EmailsLatestCommand extends Command {
|
|
|
9009
9625
|
responseStyle: "fields"
|
|
9010
9626
|
});
|
|
9011
9627
|
return counted.error ? null : countFromMeta(counted.data);
|
|
9012
|
-
}) : null;
|
|
9628
|
+
}) : null);
|
|
9013
9629
|
if (flags.json) {
|
|
9014
9630
|
const document = withFocusMeta(envelope ?? null, focus);
|
|
9631
|
+
if (paged.note) process.stderr.write(`${paged.note}\n`);
|
|
9015
9632
|
this.log(JSON.stringify(note && document ? {
|
|
9016
9633
|
...document,
|
|
9017
9634
|
summary: note
|
|
@@ -9019,6 +9636,8 @@ var EmailsLatestCommand = class EmailsLatestCommand extends Command {
|
|
|
9019
9636
|
return;
|
|
9020
9637
|
}
|
|
9021
9638
|
writeFocusLine(focus, false);
|
|
9639
|
+
if (envelope?.meta?.cursor) process.stderr.write(`next cursor: ${envelope.meta.cursor}\n`);
|
|
9640
|
+
if (paged.note) process.stderr.write(`${paged.note}\n`);
|
|
9022
9641
|
if (rows.length === 0) {
|
|
9023
9642
|
if (note) {
|
|
9024
9643
|
process.stderr.write(`${note}\n`);
|
|
@@ -9555,7 +10174,7 @@ const commonFlags$1 = {
|
|
|
9555
10174
|
};
|
|
9556
10175
|
const FOCUS_DESCRIPTION = `Which domains mail listings and searches show.
|
|
9557
10176
|
|
|
9558
|
-
On a credential that reads mail on more than one domain, listings and searches are refused until a focus is chosen: \`primitive focus set <domain...>\` to see only those domains, or \`primitive focus set --all\` to see every domain. The choice is saved for this profile (the
|
|
10177
|
+
On a credential that reads mail on more than one domain, listings and searches are refused until a focus is chosen: \`primitive focus set <domain...>\` to see only those domains, or \`primitive focus set --all\` to see every domain. The choice is saved for this profile (the current login, or the connected agent selected by PRIMITIVE_AGENT_PROFILE), never in a credential file.
|
|
9559
10178
|
|
|
9560
10179
|
A focus applies to \`emails list\`, \`emails latest\`, \`emails search\`, \`search\`, \`emails watch\`, \`inbox next\`, \`sent list\` and \`semantic-search\`. Every focused command says so on stderr, and under --json in \`meta.focus\`. It never applies to reads by id or to notifications (\`listen\`, \`wait\`, \`emails wait\`, \`agent check-mail\`).
|
|
9561
10180
|
|
|
@@ -9566,13 +10185,18 @@ async function readState(command, flags, lookupOptional = false) {
|
|
|
9566
10185
|
apiKey: flags["api-key"],
|
|
9567
10186
|
apiBaseUrl: flags["api-base-url"]
|
|
9568
10187
|
});
|
|
9569
|
-
const readable = await
|
|
10188
|
+
const { readable, refusal } = await readDomainsOrRefusal(apiClient.client);
|
|
9570
10189
|
const fallbackOrg = auth.connectedAgent?.orgId ?? auth.credentials?.org_id ?? null;
|
|
9571
|
-
if (!readable && lookupOptional && fallbackOrg) return {
|
|
10190
|
+
if (!readable && lookupOptional && (fallbackOrg || refusal)) return {
|
|
9572
10191
|
profile: focusProfile(command.config.configDir, auth),
|
|
9573
10192
|
orgId: fallbackOrg,
|
|
9574
|
-
readable: null
|
|
10193
|
+
readable: null,
|
|
10194
|
+
refusal
|
|
9575
10195
|
};
|
|
10196
|
+
if (!readable && refusal) throw new Errors.CLIError(refusal.message.replace(/\.?$/, "."), {
|
|
10197
|
+
exit: 1,
|
|
10198
|
+
code: refusal.code
|
|
10199
|
+
});
|
|
9576
10200
|
if (!readable) throw new Errors.CLIError("Could not read this credential's domains; retry in a moment.", {
|
|
9577
10201
|
exit: 1,
|
|
9578
10202
|
code: "focus_lookup_failed"
|
|
@@ -9589,7 +10213,7 @@ async function readState(command, flags, lookupOptional = false) {
|
|
|
9589
10213
|
};
|
|
9590
10214
|
}
|
|
9591
10215
|
function profileLabel(profile) {
|
|
9592
|
-
return profile.kind === "agent" ? `agent profile ${profile.name}` : "the
|
|
10216
|
+
return profile.kind === "agent" ? `agent profile ${profile.name}` : "the current login";
|
|
9593
10217
|
}
|
|
9594
10218
|
function describeChoice(choice) {
|
|
9595
10219
|
if (!choice) return "none chosen";
|
|
@@ -9620,7 +10244,7 @@ var FocusCommand = class FocusCommand extends Command {
|
|
|
9620
10244
|
async run() {
|
|
9621
10245
|
const { flags } = await this.parse(FocusCommand);
|
|
9622
10246
|
const state = await readState(this, flags, true);
|
|
9623
|
-
const choice = loadSavedFocus(state.profile, state.orgId)?.choice ?? null;
|
|
10247
|
+
const choice = (state.orgId ? loadSavedFocus(state.profile, state.orgId) : null)?.choice ?? null;
|
|
9624
10248
|
const session = process.env["PRIMITIVE_FOCUS_DOMAINS"]?.trim() || null;
|
|
9625
10249
|
const names = state.readable?.domains.map((d) => d.name) ?? null;
|
|
9626
10250
|
if (flags.json) {
|
|
@@ -9629,10 +10253,16 @@ var FocusCommand = class FocusCommand extends Command {
|
|
|
9629
10253
|
saved: choiceJson(choice),
|
|
9630
10254
|
session_override: session,
|
|
9631
10255
|
domains: names,
|
|
9632
|
-
applies: names === null ? null : names.length > 1
|
|
10256
|
+
applies: names === null ? null : names.length > 1,
|
|
10257
|
+
...state.refusal ? { refusal: state.refusal } : {}
|
|
9633
10258
|
}, null, 2));
|
|
9634
10259
|
return;
|
|
9635
10260
|
}
|
|
10261
|
+
if (state.refusal) {
|
|
10262
|
+
if (choice) this.log(`Focus for ${profileLabel(state.profile)}: ${describeChoice(choice)}.`);
|
|
10263
|
+
this.log(state.refusal.message.replace(/\.?$/, "."));
|
|
10264
|
+
return;
|
|
10265
|
+
}
|
|
9636
10266
|
if (names !== null && names.length <= 1) {
|
|
9637
10267
|
this.log(`This credential reads mail on ${names.length === 1 ? `one domain, ${names[0]}` : "no verified domain"}, so listings are never focused.`);
|
|
9638
10268
|
return;
|
|
@@ -9705,7 +10335,7 @@ ${FOCUS_DESCRIPTION}`;
|
|
|
9705
10335
|
const { flags } = await this.parse(FocusClearCommand);
|
|
9706
10336
|
const state = await readState(this, flags, true);
|
|
9707
10337
|
let had = false;
|
|
9708
|
-
saveFocus(state.profile, state.orgId, (current) => {
|
|
10338
|
+
if (state.orgId) saveFocus(state.profile, state.orgId, (current) => {
|
|
9709
10339
|
had = Boolean(current?.choice);
|
|
9710
10340
|
return null;
|
|
9711
10341
|
});
|
|
@@ -10871,8 +11501,8 @@ const PRIMITIVE_TEAM_AUTHOR = {
|
|
|
10871
11501
|
name: "Primitive Team",
|
|
10872
11502
|
url: "https://primitive.dev"
|
|
10873
11503
|
};
|
|
10874
|
-
const SDK_VERSION_RANGE = "^3.0.0-preview.
|
|
10875
|
-
const CLI_VERSION_RANGE = "^3.0.0-preview.
|
|
11504
|
+
const SDK_VERSION_RANGE = "^3.0.0-preview.23";
|
|
11505
|
+
const CLI_VERSION_RANGE = "^3.0.0-preview.23";
|
|
10876
11506
|
const ESBUILD_VERSION_RANGE = "^0.27.0";
|
|
10877
11507
|
function renderHandler() {
|
|
10878
11508
|
return `// env.PRIMITIVE_API_KEY, env.PRIMITIVE_WEBHOOK_SECRET, and
|
|
@@ -12294,7 +12924,7 @@ async function runSetSecret(api, params) {
|
|
|
12294
12924
|
};
|
|
12295
12925
|
}
|
|
12296
12926
|
var FunctionsSetSecretCommand = class FunctionsSetSecretCommand extends Command {
|
|
12297
|
-
static description = `Write a function secret and optionally redeploy so the new value lands in the running handler.
|
|
12927
|
+
static description = `Write a function secret and optionally redeploy so the new value lands in the running handler.
|
|
12298
12928
|
|
|
12299
12929
|
Without --redeploy this is a plain secret upsert: the value is
|
|
12300
12930
|
encrypted at rest but is NOT visible to the running handler until
|
|
@@ -13873,6 +14503,46 @@ var WhoamiCommand = class WhoamiCommand extends Command {
|
|
|
13873
14503
|
}, 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}`);
|
|
13874
14504
|
return;
|
|
13875
14505
|
}
|
|
14506
|
+
if (auth.agentPass) {
|
|
14507
|
+
const pass = auth.agentPass;
|
|
14508
|
+
let grant = null;
|
|
14509
|
+
const response = await fetch(`${auth.apiBaseUrl.replace(/\/+$/, "")}/whoami/grant`, {
|
|
14510
|
+
method: "GET",
|
|
14511
|
+
headers: {
|
|
14512
|
+
authorization: `Bearer ${auth.apiKey ?? ""}`,
|
|
14513
|
+
accept: "application/json"
|
|
14514
|
+
}
|
|
14515
|
+
});
|
|
14516
|
+
const payload = await response.json().catch(() => null);
|
|
14517
|
+
if (!response.ok) {
|
|
14518
|
+
const errorPayload = extractErrorPayload(payload ?? { message: `HTTP ${response.status}` });
|
|
14519
|
+
writeErrorWithHints(errorPayload);
|
|
14520
|
+
process.exitCode = 1;
|
|
14521
|
+
return;
|
|
14522
|
+
}
|
|
14523
|
+
grant = payload?.data ?? null;
|
|
14524
|
+
const revokeCommand = pass.binding.kind === "profile" ? `primitive disconnect --profile ${pass.binding.profile}` : "primitive disconnect";
|
|
14525
|
+
if (flags.json) {
|
|
14526
|
+
this.log(JSON.stringify({
|
|
14527
|
+
auth_method: "agent_pass",
|
|
14528
|
+
pass,
|
|
14529
|
+
grant,
|
|
14530
|
+
revoke_command: revokeCommand
|
|
14531
|
+
}, null, 2));
|
|
14532
|
+
return;
|
|
14533
|
+
}
|
|
14534
|
+
const perms = Array.isArray(grant?.permissions) ? grant.permissions.filter((p) => typeof p === "string") : [];
|
|
14535
|
+
const lines = [
|
|
14536
|
+
`Authenticated with Access Pass "${pass.label}" (${pass.mode})`,
|
|
14537
|
+
`Expires at: ${pass.expires_at}`,
|
|
14538
|
+
`API origin: ${auth.apiBaseUrl}`
|
|
14539
|
+
];
|
|
14540
|
+
if (pass.slice_summary) lines.push(`Scope: ${pass.slice_summary}`);
|
|
14541
|
+
if (perms.length > 0) lines.push(`Permissions: ${perms.join(", ")}`);
|
|
14542
|
+
lines.push(`Disconnect and revoke: ${revokeCommand}`);
|
|
14543
|
+
this.log(lines.join("\n"));
|
|
14544
|
+
return;
|
|
14545
|
+
}
|
|
13876
14546
|
if (isConnectedChatCredential(auth.apiKey)) throw new Errors.CLIError("This connection credential cannot inspect an account. Select its saved profile with PRIMITIVE_AGENT_PROFILE to inspect the connected identity offline.", { exit: 1 });
|
|
13877
14547
|
if (flags.check !== void 0) {
|
|
13878
14548
|
const check = flags.check.trim();
|
|
@@ -14222,7 +14892,7 @@ function expiryFromFlags(flags) {
|
|
|
14222
14892
|
function unwrap(data) {
|
|
14223
14893
|
return data?.data ?? data;
|
|
14224
14894
|
}
|
|
14225
|
-
async function call(request) {
|
|
14895
|
+
async function call(request, keepEnvelope = false) {
|
|
14226
14896
|
try {
|
|
14227
14897
|
const result = await request;
|
|
14228
14898
|
if (result.error !== void 0 || !result.response?.ok) return {
|
|
@@ -14234,7 +14904,8 @@ async function call(request) {
|
|
|
14234
14904
|
};
|
|
14235
14905
|
return {
|
|
14236
14906
|
ok: true,
|
|
14237
|
-
data: unwrap(result.data)
|
|
14907
|
+
data: unwrap(result.data),
|
|
14908
|
+
...keepEnvelope ? { envelope: result.data } : {}
|
|
14238
14909
|
};
|
|
14239
14910
|
} catch (error) {
|
|
14240
14911
|
return {
|
|
@@ -14640,13 +15311,16 @@ var KeysListCommand = class KeysListCommand extends Command {
|
|
|
14640
15311
|
"api-key": API_KEY_FLAG$1,
|
|
14641
15312
|
"api-base-url": API_BASE_URL_FLAG$2,
|
|
14642
15313
|
"include-revoked": Flags.boolean({ description: "List revoked keys too, each marked [revoked] with when it was revoked." }),
|
|
14643
|
-
json: Flags.boolean({ description: "Print the keys
|
|
15314
|
+
json: Flags.boolean({ description: "Print the keys in data, with continuation in meta.cursor." })
|
|
14644
15315
|
};
|
|
14645
15316
|
async run() {
|
|
14646
15317
|
const { flags } = await this.parse(KeysListCommand);
|
|
14647
15318
|
const includeRevoked = flags["include-revoked"] === true;
|
|
14648
15319
|
const auth = await authenticate(this, flags);
|
|
14649
15320
|
const items = [];
|
|
15321
|
+
let envelope = {};
|
|
15322
|
+
let meta = {};
|
|
15323
|
+
const warnings = [];
|
|
14650
15324
|
let cursor;
|
|
14651
15325
|
for (let page = 0; page < LIST_PAGE_LIMIT; page += 1) {
|
|
14652
15326
|
const result = await call(listKeys({
|
|
@@ -14655,20 +15329,40 @@ var KeysListCommand = class KeysListCommand extends Command {
|
|
|
14655
15329
|
cursor,
|
|
14656
15330
|
include_revoked: includeRevoked ? "true" : void 0
|
|
14657
15331
|
}
|
|
14658
|
-
}));
|
|
15332
|
+
}), true);
|
|
14659
15333
|
if (!result.ok) {
|
|
14660
15334
|
await reportKeysError(this, result, auth, Boolean(flags.json));
|
|
14661
15335
|
return;
|
|
14662
15336
|
}
|
|
15337
|
+
envelope = {
|
|
15338
|
+
...envelope,
|
|
15339
|
+
...result.envelope
|
|
15340
|
+
};
|
|
15341
|
+
meta = {
|
|
15342
|
+
...meta,
|
|
15343
|
+
...result.envelope?.meta
|
|
15344
|
+
};
|
|
15345
|
+
if (Array.isArray(result.envelope?.warnings)) warnings.push(...result.envelope.warnings);
|
|
14663
15346
|
items.push(...result.data.items);
|
|
14664
15347
|
cursor = result.data.next_cursor ?? void 0;
|
|
14665
15348
|
if (!cursor) break;
|
|
14666
15349
|
}
|
|
14667
15350
|
if (flags.json) {
|
|
14668
|
-
this.log(JSON.stringify(
|
|
15351
|
+
this.log(JSON.stringify({
|
|
15352
|
+
...envelope,
|
|
15353
|
+
success: true,
|
|
15354
|
+
data: items,
|
|
15355
|
+
meta: {
|
|
15356
|
+
...meta,
|
|
15357
|
+
cursor: cursor ?? null,
|
|
15358
|
+
has_more: Boolean(cursor)
|
|
15359
|
+
},
|
|
15360
|
+
...warnings.length ? { warnings } : {}
|
|
15361
|
+
}));
|
|
14669
15362
|
return;
|
|
14670
15363
|
}
|
|
14671
15364
|
this.log(formatKeyRows(items, { includeRevoked }));
|
|
15365
|
+
if (cursor) process.stderr.write(`next cursor: ${cursor}\n`);
|
|
14672
15366
|
}
|
|
14673
15367
|
};
|
|
14674
15368
|
var KeysGetCommand = class KeysGetCommand extends Command {
|
|
@@ -15132,9 +15826,13 @@ function revokeCascadeLines(data) {
|
|
|
15132
15826
|
var KeysRevokeCommand = class KeysRevokeCommand extends Command {
|
|
15133
15827
|
static description = `Revoke an API key. It stops working at once. What the organization owns keeps working; what the key itself owns, such as its own webhooks, keeps working only while someone can still act for it, such as a key of the same rotation that still works. What it set up or owns is listed for review, each with whether anything still acts for it and, for a webhook, whether it still delivers received mail. Keys it replaced that are still in their rotation overlap are revoked with it, except any you may not revoke; the output counts both, and names them and the key acting for each item when you may read the organization's keys.
|
|
15134
15828
|
|
|
15135
|
-
Asks for confirmation first; pass --yes to
|
|
15829
|
+
Asks for confirmation first; pass --yes to confirm in scripts. JSON and non-interactive mode never prompt, so use --yes --json for scripted JSON output. Revoking runs directly. If your organization requires approval, the command prints the approval link, opens it where it can and waits for the one-time token; in a script, approve and run it again with --step-up-token.`;
|
|
15136
15830
|
static summary = "Revoke an API key";
|
|
15137
|
-
static examples = [
|
|
15831
|
+
static examples = [
|
|
15832
|
+
"<%= config.bin %> keys revoke 0f0e0d0c-0b0a-4908-8706-050403020100",
|
|
15833
|
+
"<%= config.bin %> keys revoke 0f0e0d0c-0b0a-4908-8706-050403020100 --yes",
|
|
15834
|
+
"<%= config.bin %> keys revoke 0f0e0d0c-0b0a-4908-8706-050403020100 --yes --json"
|
|
15835
|
+
];
|
|
15138
15836
|
static args = { id: Args.string({
|
|
15139
15837
|
description: "The key's id.",
|
|
15140
15838
|
required: true
|
|
@@ -15153,7 +15851,13 @@ var KeysRevokeCommand = class KeysRevokeCommand extends Command {
|
|
|
15153
15851
|
async run() {
|
|
15154
15852
|
const { args, flags } = await this.parse(KeysRevokeCommand);
|
|
15155
15853
|
if (!flags.yes) {
|
|
15156
|
-
if (flags.json || !(process.stdin.isTTY && process.stderr.isTTY))
|
|
15854
|
+
if (flags.json || !(process.stdin.isTTY && process.stderr.isTTY)) throw Object.assign(new Errors.CLIError("Confirmation required: pass --yes to revoke without a prompt. --json and non-interactive mode never prompt.", { exit: 2 }), {
|
|
15855
|
+
code: "usage_error",
|
|
15856
|
+
details: {
|
|
15857
|
+
reason: "confirmation_required",
|
|
15858
|
+
required_flags: ["--yes"]
|
|
15859
|
+
}
|
|
15860
|
+
});
|
|
15157
15861
|
const answer = await promptLine$2(`Revoke key ${args.id}? It stops working at once. [y/N] `);
|
|
15158
15862
|
if (!/^y(es)?$/i.test(answer.trim())) {
|
|
15159
15863
|
process.stderr.write("Cancelled. The key still works.\n");
|
|
@@ -22797,7 +23501,7 @@ const SHARED_FLAGS = {
|
|
|
22797
23501
|
}),
|
|
22798
23502
|
json: Flags.boolean({ description: "Print the response data as JSON." })
|
|
22799
23503
|
};
|
|
22800
|
-
async function runRead(command, flags, read, format, after) {
|
|
23504
|
+
async function runRead(command, flags, read, format, after, keepEnvelope = false) {
|
|
22801
23505
|
const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
|
|
22802
23506
|
apiKey: flags["api-key"],
|
|
22803
23507
|
apiBaseUrl: flags["api-base-url"],
|
|
@@ -22817,7 +23521,7 @@ async function runRead(command, flags, read, format, after) {
|
|
|
22817
23521
|
return;
|
|
22818
23522
|
}
|
|
22819
23523
|
const data = result.data?.data;
|
|
22820
|
-
command.log(flags.json ? JSON.stringify(data, null, 2) : format(data));
|
|
23524
|
+
command.log(flags.json ? JSON.stringify(keepEnvelope ? result.data : data, null, 2) : format(data));
|
|
22821
23525
|
if (!flags.json) after?.(data);
|
|
22822
23526
|
}
|
|
22823
23527
|
function formatRoles(list) {
|
|
@@ -22855,9 +23559,10 @@ function mailAccessText(person) {
|
|
|
22855
23559
|
function formatMembers(list) {
|
|
22856
23560
|
if (list.items.length === 0) return "No members.";
|
|
22857
23561
|
return list.items.map((person) => {
|
|
22858
|
-
const role = printable(person.
|
|
23562
|
+
const role = printable(roleKeyLabel(person.role));
|
|
23563
|
+
const assigned = person.role_id && person.role_name ? ` assigned role: ${printable(person.role_name)}` : "";
|
|
22859
23564
|
const agents = person.agents.length > 0 ? ` ${person.agents.length} agent${person.agents.length === 1 ? "" : "s"}` : "";
|
|
22860
|
-
return `${printable(person.name)} ${person.work_email ?? "no work email"} ${role} ${person.user_id}${agents}${mailAccessText(person)}`;
|
|
23565
|
+
return `${printable(person.name)} ${person.work_email ?? "no work email"} ${role}${assigned} ${person.user_id}${agents}${mailAccessText(person)}`;
|
|
22861
23566
|
}).join("\n");
|
|
22862
23567
|
}
|
|
22863
23568
|
function formatAccessMode(mode) {
|
|
@@ -22877,11 +23582,11 @@ var RolesListCommand = class RolesListCommand extends Command {
|
|
|
22877
23582
|
}
|
|
22878
23583
|
};
|
|
22879
23584
|
var RolesMembersCommand = class RolesMembersCommand extends Command {
|
|
22880
|
-
static description = "List the organization's members with their
|
|
23585
|
+
static description = "List the organization's members with their built-in role, using the same name as whoami and org list. An assigned template or custom role is labeled separately. The built-in label does not grant permissions; mail access shows what they can read or send where you can see it. Rows include name, work email, user id and directory agents. With --json, data is the members array: role is the displayed built-in key; role_name and role_id keep the assigned role's metadata. meta.cursor continues the listing and meta.can_invite says whether you can invite members.";
|
|
22881
23586
|
static summary = "List members and their roles";
|
|
22882
23587
|
static examples = [
|
|
22883
|
-
"<%= config.bin %>
|
|
22884
|
-
"<%= config.bin %>
|
|
23588
|
+
"<%= config.bin %> members list",
|
|
23589
|
+
"<%= config.bin %> members list --query alice",
|
|
22885
23590
|
"<%= config.bin %> members list --json"
|
|
22886
23591
|
];
|
|
22887
23592
|
static flags = {
|
|
@@ -22892,7 +23597,7 @@ var RolesMembersCommand = class RolesMembersCommand extends Command {
|
|
|
22892
23597
|
min: 1,
|
|
22893
23598
|
max: 100
|
|
22894
23599
|
}),
|
|
22895
|
-
cursor: Flags.string({ description: "The next page's cursor: printed on stderr as `next cursor: <value>`, or `cursor` with --json." })
|
|
23600
|
+
cursor: Flags.string({ description: "The next page's cursor: printed on stderr as `next cursor: <value>`, or `meta.cursor` with --json." })
|
|
22896
23601
|
};
|
|
22897
23602
|
async run() {
|
|
22898
23603
|
const { flags } = await this.parse(RolesMembersCommand);
|
|
@@ -22907,7 +23612,7 @@ var RolesMembersCommand = class RolesMembersCommand extends Command {
|
|
|
22907
23612
|
responseStyle: "fields"
|
|
22908
23613
|
}), formatMembers, (list) => {
|
|
22909
23614
|
if (list.cursor) process.stderr.write(`next cursor: ${list.cursor}\n`);
|
|
22910
|
-
});
|
|
23615
|
+
}, true);
|
|
22911
23616
|
}
|
|
22912
23617
|
};
|
|
22913
23618
|
var RolesGroupsCommand = class RolesGroupsCommand extends Command {
|
|
@@ -24912,6 +25617,31 @@ const sessionOnlyFlag = Flags.boolean({
|
|
|
24912
25617
|
exclusive: ["all-sessions"]
|
|
24913
25618
|
});
|
|
24914
25619
|
const jsonFlag = Flags.boolean({ description: "Print JSON (already the default)" });
|
|
25620
|
+
const serverFlags = {
|
|
25621
|
+
"api-key": Flags.string({
|
|
25622
|
+
description: "Primitive API key override",
|
|
25623
|
+
env: "PRIMITIVE_API_KEY"
|
|
25624
|
+
}),
|
|
25625
|
+
"api-base-url": Flags.string({
|
|
25626
|
+
description: "Override the API base URL",
|
|
25627
|
+
env: "PRIMITIVE_API_BASE_URL",
|
|
25628
|
+
hidden: true
|
|
25629
|
+
}),
|
|
25630
|
+
address: Flags.string({ description: "Address whose thread mute changes. Defaults to the connected agent's address; required for other credentials." })
|
|
25631
|
+
};
|
|
25632
|
+
function localProfile(command, flags) {
|
|
25633
|
+
const agent = resolveCliAuth({
|
|
25634
|
+
configDir: command.config.configDir,
|
|
25635
|
+
apiKey: flags["api-key"],
|
|
25636
|
+
apiBaseUrl: flags["api-base-url"]
|
|
25637
|
+
}).connectedAgent;
|
|
25638
|
+
if (flags.address !== void 0 && flags.address.toLowerCase() !== agent?.agentAddress.toLowerCase()) return void 0;
|
|
25639
|
+
return agent?.profileName;
|
|
25640
|
+
}
|
|
25641
|
+
function requireLocalProfile(command, profile) {
|
|
25642
|
+
if (!profile) command.error("Local thread mutes require a connected agent profile for the requested address. Set PRIMITIVE_AGENT_PROFILE to that profile.");
|
|
25643
|
+
return profile;
|
|
25644
|
+
}
|
|
24915
25645
|
function profileName(command) {
|
|
24916
25646
|
const name = resolveCliAuth({ configDir: command.config.configDir }).connectedAgent?.profileName;
|
|
24917
25647
|
if (!name) command.error("Thread mutes belong to a connected agent profile. Set PRIMITIVE_AGENT_PROFILE to the profile whose wakes should change.");
|
|
@@ -24948,11 +25678,12 @@ function errorMessage(payload) {
|
|
|
24948
25678
|
* caller can fall back to a local mute. A 404 for an unknown thread names
|
|
24949
25679
|
* the thread and is reported separately.
|
|
24950
25680
|
*/
|
|
24951
|
-
async function callMuteApi(client, method, id) {
|
|
25681
|
+
async function callMuteApi(client, method, id, address) {
|
|
24952
25682
|
const response = await client[method]({
|
|
24953
25683
|
security,
|
|
24954
25684
|
url: "/threads/{id}/mute",
|
|
24955
25685
|
path: { id },
|
|
25686
|
+
...address === void 0 ? {} : { query: { address } },
|
|
24956
25687
|
responseStyle: "fields"
|
|
24957
25688
|
});
|
|
24958
25689
|
if (response.error === void 0) return {
|
|
@@ -24970,8 +25701,12 @@ async function callMuteApi(client, method, id) {
|
|
|
24970
25701
|
payload: response.error
|
|
24971
25702
|
};
|
|
24972
25703
|
}
|
|
24973
|
-
async function apiClient(command) {
|
|
24974
|
-
const { apiClient } = await createAuthenticatedCliApiClient({
|
|
25704
|
+
async function apiClient(command, flags = {}) {
|
|
25705
|
+
const { apiClient } = await createAuthenticatedCliApiClient({
|
|
25706
|
+
configDir: command.config.configDir,
|
|
25707
|
+
apiKey: flags["api-key"],
|
|
25708
|
+
apiBaseUrl: flags["api-base-url"]
|
|
25709
|
+
});
|
|
24975
25710
|
return apiClient.client;
|
|
24976
25711
|
}
|
|
24977
25712
|
function failWith(payload) {
|
|
@@ -24981,9 +25716,14 @@ function failWith(payload) {
|
|
|
24981
25716
|
const UNSUPPORTED_NOTE = "This server does not keep thread mutes yet, so the mute is stored locally for this profile.";
|
|
24982
25717
|
var ThreadsMuteCommand = class ThreadsMuteCommand extends Command {
|
|
24983
25718
|
static summary = "Stop wakes for one thread";
|
|
24984
|
-
static description = "Mutes the thread for
|
|
24985
|
-
static examples = [
|
|
25719
|
+
static description = "Mutes the thread for --address on the server, defaulting to the connected agent's address, so no session or runtime using the address is woken by it. Other credentials must provide --address. Mail in it is still received and readable, reads report it as muted, and its delivery event is completed so it is not redelivered. With --session-only the mute is stored locally and applies only to the current Claude Code or Codex session. A server without thread mutes gets a local mute instead: the current runtime session's, or with --all-sessions (or outside a session) every session on the profile. Local mutes require the requested address's connected profile.";
|
|
25720
|
+
static examples = [
|
|
25721
|
+
"PRIMITIVE_AGENT_PROFILE=work <%= config.bin %> threads mute --id <thread-id>",
|
|
25722
|
+
"PRIMITIVE_AGENT_PROFILE=work <%= config.bin %> threads mute --id <thread-id> --session-only",
|
|
25723
|
+
"<%= config.bin %> threads mute --id <thread-id> --address member@example.com"
|
|
25724
|
+
];
|
|
24986
25725
|
static flags = {
|
|
25726
|
+
...serverFlags,
|
|
24987
25727
|
id: idFlag,
|
|
24988
25728
|
"session-only": sessionOnlyFlag,
|
|
24989
25729
|
"all-sessions": allSessionsFlag,
|
|
@@ -24992,9 +25732,10 @@ var ThreadsMuteCommand = class ThreadsMuteCommand extends Command {
|
|
|
24992
25732
|
async run() {
|
|
24993
25733
|
const { flags } = await this.parse(ThreadsMuteCommand);
|
|
24994
25734
|
const id = threadId(this, flags.id);
|
|
24995
|
-
const profile =
|
|
25735
|
+
const profile = localProfile(this, flags);
|
|
25736
|
+
if (flags["session-only"]) requireLocalProfile(this, profile);
|
|
24996
25737
|
if (!flags["session-only"]) {
|
|
24997
|
-
const result = await callMuteApi(await apiClient(this), "put", id);
|
|
25738
|
+
const result = await callMuteApi(await apiClient(this, flags), "put", id, flags.address);
|
|
24998
25739
|
if (result.kind === "ok") {
|
|
24999
25740
|
const data = record(result.data);
|
|
25000
25741
|
this.log(JSON.stringify({
|
|
@@ -25008,10 +25749,11 @@ var ThreadsMuteCommand = class ThreadsMuteCommand extends Command {
|
|
|
25008
25749
|
return;
|
|
25009
25750
|
}
|
|
25010
25751
|
if (result.kind !== "unsupported") return failWith(result.payload);
|
|
25752
|
+
requireLocalProfile(this, profile);
|
|
25011
25753
|
process.stderr.write(`${UNSUPPORTED_NOTE}\n`);
|
|
25012
25754
|
}
|
|
25013
25755
|
const session = flags["session-only"] ? requireSession(this) : muteSession(flags["all-sessions"]);
|
|
25014
|
-
const { mute, changed } = await muteThread(this.config.configDir, profile, id, session);
|
|
25756
|
+
const { mute, changed } = await muteThread(this.config.configDir, requireLocalProfile(this, profile), id, session);
|
|
25015
25757
|
this.log(JSON.stringify({
|
|
25016
25758
|
thread_id: mute.thread_id,
|
|
25017
25759
|
muted: true,
|
|
@@ -25024,9 +25766,10 @@ var ThreadsMuteCommand = class ThreadsMuteCommand extends Command {
|
|
|
25024
25766
|
};
|
|
25025
25767
|
var ThreadsUnmuteCommand = class ThreadsUnmuteCommand extends Command {
|
|
25026
25768
|
static summary = "Resume wakes for one muted thread";
|
|
25027
|
-
static description = "Removes the server mute for
|
|
25769
|
+
static description = "Removes the server mute for --address, defaulting to the connected agent's address. Other credentials must provide --address. For that address's connected profile, also removes this session's local mute for the thread, or every local mute with --all-sessions (also the default outside a runtime session). With --session-only only this session's local mute is removed. Reports any local mute that still applies.";
|
|
25028
25770
|
static examples = ["PRIMITIVE_AGENT_PROFILE=work <%= config.bin %> threads unmute --id <thread-id>"];
|
|
25029
25771
|
static flags = {
|
|
25772
|
+
...serverFlags,
|
|
25030
25773
|
id: idFlag,
|
|
25031
25774
|
"session-only": sessionOnlyFlag,
|
|
25032
25775
|
"all-sessions": allSessionsFlag,
|
|
@@ -25035,15 +25778,24 @@ var ThreadsUnmuteCommand = class ThreadsUnmuteCommand extends Command {
|
|
|
25035
25778
|
async run() {
|
|
25036
25779
|
const { flags } = await this.parse(ThreadsUnmuteCommand);
|
|
25037
25780
|
const id = threadId(this, flags.id);
|
|
25038
|
-
const profile =
|
|
25781
|
+
const profile = localProfile(this, flags);
|
|
25782
|
+
if (flags["session-only"]) requireLocalProfile(this, profile);
|
|
25039
25783
|
let server = null;
|
|
25040
25784
|
if (!flags["session-only"]) {
|
|
25041
|
-
const result = await callMuteApi(await apiClient(this), "delete", id);
|
|
25785
|
+
const result = await callMuteApi(await apiClient(this, flags), "delete", id, flags.address);
|
|
25042
25786
|
if (result.kind === "error") return failWith(result.payload);
|
|
25787
|
+
if (!profile) {
|
|
25788
|
+
if (result.kind === "ok") {
|
|
25789
|
+
this.log(JSON.stringify(result.data, null, 2));
|
|
25790
|
+
return;
|
|
25791
|
+
}
|
|
25792
|
+
if (result.kind === "thread_not_found") return failWith(result.payload);
|
|
25793
|
+
requireLocalProfile(this, profile);
|
|
25794
|
+
}
|
|
25043
25795
|
server = result.kind === "ok" ? "unmuted" : result.kind === "thread_not_found" ? "not_found" : "unsupported";
|
|
25044
25796
|
}
|
|
25045
25797
|
const session = flags["session-only"] ? requireSession(this) : muteSession(flags["all-sessions"]);
|
|
25046
|
-
const { removed, remaining } = await unmuteThread(this.config.configDir, profile, id, session, { allScopes: session === null });
|
|
25798
|
+
const { removed, remaining } = await unmuteThread(this.config.configDir, requireLocalProfile(this, profile), id, session, { allScopes: session === null });
|
|
25047
25799
|
const stillMuted = session === null ? remaining : remaining.filter((mute) => mute.session === null || mute.session === session);
|
|
25048
25800
|
this.log(JSON.stringify({
|
|
25049
25801
|
thread_id: id,
|
|
@@ -26870,6 +27622,9 @@ const rawCommands = {
|
|
|
26870
27622
|
"org:secrets:list": OrgSecretsListCommand,
|
|
26871
27623
|
"org:secrets:set": OrgSecretsSetCommand,
|
|
26872
27624
|
"org:secrets:remove": OrgSecretsRemoveCommand,
|
|
27625
|
+
connect: ConnectCommand,
|
|
27626
|
+
disconnect: DisconnectCommand,
|
|
27627
|
+
api: ApiCommand,
|
|
26873
27628
|
"payloads:push": PayloadsPushCommand,
|
|
26874
27629
|
"payloads:pull": PayloadsPullCommand,
|
|
26875
27630
|
"functions:test": FunctionsTestFunctionCommand,
|
|
@@ -26918,6 +27673,17 @@ const rawCommands = {
|
|
|
26918
27673
|
"wake:authorizations:delete": WakeAuthorizationsDeleteCommand,
|
|
26919
27674
|
"wake:dispatches:list": WakeDispatchesListCommand
|
|
26920
27675
|
};
|
|
27676
|
+
for (const [oldId, target] of Object.entries(COMMAND_PAIR_RENAMES)) {
|
|
27677
|
+
const request = generatedCommands[oldId];
|
|
27678
|
+
if (!request) continue;
|
|
27679
|
+
const taskEntry = Object.entries(rawCommands).find(([id]) => !Object.hasOwn(COMMAND_PAIR_RENAMES, id) && canonicalCommandId(id) === target);
|
|
27680
|
+
if (!taskEntry) throw new Error(`Missing task command for ${oldId}`);
|
|
27681
|
+
const combined = combineCommandPair(taskEntry[1], request, {
|
|
27682
|
+
storedRedeploy: oldId === "functions:redeploy-function",
|
|
27683
|
+
listPage: oldId === "credentials:list-keys" ? "keys" : oldId === "projects:list-organization-people" ? "members" : void 0
|
|
27684
|
+
});
|
|
27685
|
+
for (const id of Object.keys(rawCommands)) if (canonicalCommandId(id) === target) rawCommands[id] = combined;
|
|
27686
|
+
}
|
|
26921
27687
|
const COMMANDS = canonicalCommands(rawCommands);
|
|
26922
27688
|
for (const command of new Set(Object.values(COMMANDS))) ignoreArgumentStdin(command);
|
|
26923
27689
|
setKnownCommands(Object.keys(COMMANDS), CANONICAL_OPERATION_ALIASES);
|