@primitivedotdev/cli 3.0.0-preview.23 → 3.0.0-preview.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-command-CP8ir5Pv.js → api-command-DhY2wrh5.js} +2945 -171
- package/dist/{cli-command-names-DteMqL-H.js → cli-command-names-DiNDwwDX.js} +1 -1
- package/dist/{cli-config-DUQEYQ42.js → cli-config-D2MU7PiU.js} +50 -2
- package/dist/{machine-session-CE31cwx2.js → machine-session-BTJXO0vi.js} +5 -5
- package/dist/{notify-session-Dx54UpkT.js → notify-session-DrgOcIT6.js} +3 -3
- package/dist/oclif/auto-signal-worker.js +3 -3
- package/dist/oclif/auto-signals.js +1 -1
- package/dist/oclif/command-not-found.js +1 -1
- package/dist/oclif/index.js +1354 -29
- package/dist/oclif/receiver-heal.js +2 -2
- package/dist/oclif/root-signup-hint.js +1 -1
- package/dist/{repeats-Dj_o6c-X-x61TNLz-.js → repeats-Dj_o6c-X-CK1wU9lP.js} +128 -0
- package/dist/{scoped-chat-Bss3OjFI.js → scoped-chat-DN0qj4AY.js} +1 -1
- package/dist/{signal-command-CA55RTJh.js → signal-command-BmxZqCot.js} +4 -4
- package/package.json +5 -2
package/dist/oclif/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { $ as replyInteractionWarning, $t as resolveDomainNames, A as describeWake, An as
|
|
2
|
-
import { a as canonicalCommandId, c as operationCommandId, i as canonicalCliText, l as retiredCommandTarget, n as COMMAND_RENAMES, o as canonicalCommands, s as canonicalOperation, t as COMMAND_PAIR_RENAMES } from "../cli-command-names-
|
|
1
|
+
import { $ as replyInteractionWarning, $t as resolveDomainNames, A as describeWake, An as isBuiltInRoleKey, At as connectNextSteps, B as wakeRecipientField, Bn as PRIMITIVE_REASON_HEADER, Bt as countFromMeta, C as withApproval, Cn as resolveCliApiRequestConfig, Ct as sendWaitClampNotice, D as openBrowser, Dn as credentialsFromUserLogin, Dt as thrownErrorExitCode, E as listenForCopyHotkey, En as RESTRICTED_ROLE_NOTE, Et as successfulSendOutcome, F as sentInThread, Fn as routeWarningLines, Ft as currentMailSessionKey, G as pendingMailPath, Gn as validateActivityRunId, Gt as focusProfile, H as claimPendingMail, Hn as attachActivityContextFlags, Ht as focusFlagValues, I as serverMuted, In as sanitizeForTerminal, It as formatAlreadySentNotice, J as removePendingMail, Jt as manyDomainsSupported, K as readPendingMail, Kt as joinNames, L as serverRelationship, Ln as shownLine, Lt as FOCUS_ENV, M as formatMailWakeLine, Mn as roleKeyLabel, Mt as generatedAgentName, N as latestOwnOutbound, Nn as roleKeyText, Nt as identitySuggestions, O as explainPendingMailNotFound, On as displayedRoleKey, P as readThreadContext, Pn as switchCurrentOrg, Pt as loadSkillLine, Q as replyExpectation, Qt as readDomainsOrRefusal, Rn as setKnownCommands, Rt as FOCUS_SERVER_SUPPORT, S as terminalApprovalIo, Sn as refuseOrgSelectionForProfile, St as sendOutcomeExitCode, T as formatBrowserLoginInstructions, Tn as CliOrgRefusedError, Tt as serializeErrorPayload, U as clearConsumedPendingMail, Un as cliActivityHeadersFromEnv, Ut as focusFlags, V as wakeRelationship, Vn as PRIMITIVE_RUN_ID_HEADER, Vt as focusEmptyHint, W as clearReadPendingMail, Wn as validateActivityReason, 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 mergeHeadersCaseInsensitive, 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 revokeUserLogin, k as bareAddress, kn as fetchCliOrgs, 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 selectedOrgFromEnv, wt as sentHistoryWindowStart, x as promptLine$2, xn as refreshStoredCliCredentials, xt as sendIdentityFields, y as STEP_UP_TOKEN_FLAG_DESCRIPTION, yn as createCliApiClient, yt as reportSendCommandResult, z as wakeReadCommand, zn as operationManifest, zt as NO_FOCUS } from "../api-command-DhY2wrh5.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-DiNDwwDX.js";
|
|
3
3
|
import { ignoreArgumentStdin } from "./command-stdin.js";
|
|
4
4
|
import { a as runStreamingJson, i as jsonOutputRequested, n as captureOutput, o as thrownErrorBody, r as guardJsonOutputCommands, t as JSON_OUTPUT_FLAG } from "../json-output-BMZrLH47.js";
|
|
5
|
-
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-
|
|
6
|
-
import { C as
|
|
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-
|
|
5
|
+
import { $ as AUTOMATED_VALUES, $n as stopRepeatFromEmail, $t as getThread, A as collectNewAcceptedEmails, At as downloadSentAttachmentArchiveMember, B as REPLY_STATE_UNSUPPORTED_CODE, Bn as runWakeSchedule, Cn as listSentAttachmentArchiveMembers, Ct as deleteMemory, D as transientFailure, Dn as listWakeSchedules, Dt as downloadEmailAttachmentArchiveMember, E as retryingOperation, En as listWakeDispatches, Et as deleteWakeSchedule, F as lateMailReread, Fn as reorderRoutes, G as formatAwaitingCell, Gn as sendEmail, Gt as getKey, H as assertAwaitingFilterRows, Hn as searchEmails, Ht as getFunctionRouting, I as sinceFromFlags, In as replyToEmail, It as getConversation, J as isAwaitingRejectedError, Jn as setMemory, Jt as getOutboundStatus, K as formatRepliesCell, Kn as setFunctionRoute, Kt as getMemory, L as sleep$3, Ln as resendAgentSignupVerification, Lt as getCreditBalance, M as encodeReceivedAtSearchCursor, Mt as getAccessMode, N as fetchEmailSearchPage, Nn as redeemCreditCode, Nt as getAccount, O as waitOutRetryAfter, On as pollCliLogin, Ot as downloadEmailAttachmentByFilename, P as filtersFromFlags, Pn as removeDefaultNetworkMember, Pt as getAgentContactPolicy, Q as AUTOMATED_FLAG_DESCRIPTION, Qn as startCliLogin, Qt as getSentEmail, R as AWAITING_FLAG_DESCRIPTION, Rn as revokeCredential, Rt as getDefaultNetworkAgent, S as describeApiFailure, Sn as listRoutes, T as retryTransient, Tn as listWakeAuthorizations, Tt as deleteWakeAuthorization, U as awaitingRejectedError, Un as searchMemories, Ut as getFunctionTestRunTrace, V as ReplyStateUnsupportedError, Vt as getFunction, W as ensureSearchReportsReplyState, Wn as semanticSearch, Wt as getInboxStatus, Xn as startAgentClaim, Xt as getRepeatingSend, Y as queryUsesAwaiting, Yn as simulateRoute, Yt as getOwnGrant, Z as AUTOMATED_FILTER_UNSUPPORTED_CODE, Zn as startAgentSignup, Zt as getSendFrom, _n as listKeys, _t as createKey, a as REPEAT_IDLE_MAX_MINUTES, an as listAgentContacts, ar as updateRepeatingSend, b as WaitDeadlineReached, bn as listRepeatingSends, bt as createWakeSchedule, cn as listDefaultNetworkAgents, cr as updateWakeSchedule, ct as addDefaultNetworkMember, d as parseRepeatTick, dn as listEmailAttachmentArchiveMembers, dr as whoami, dt as checkDefaultNetworkContactAdmission, en as getWakeSchedule, er as testFunction, et as AutomatedFilterUnsupportedError, f as preparePresenceAliveEmail, fn as listEmails, ft as checkSendability, g as isEmailReceivedEvent, gn as listGroups, gt as createFunction, hn as listFunctions, ht as createEndpoint, i as REPEAT_EVERY_MAX_MINUTES, ir as updateKey, j as cursorFromAcceptedRows, jt as downloadSentAttachmentByFilename, k as SINCE_VALUE_HELP, kn as pullWebhookEvent, l as parseInteractionEnvelope, ln as listDefaultNetworkMembers, lr as verifyAgentClaim, lt as cancelSentEmail, m as repeatStopCommand, mn as listFunctionLogs, mt as completeWebhookEvent, nn as leaveOrganization, nr as updateDefaultNetworkMember, nt as automatedRejectedError, o as REPEAT_MAX_SENDS_MAX, on as listAgentNetworks, or as updateRoute, ot as hasAutomatedVerdict, p as prepareSignalEmail, pn as listEndpoints, pt as cliLogout, q as hasReplyState, qn as setFunctionSecret, qt as getOrgRoutingTopology, rn as listActivityObjects, rr as updateFunction, s as buildRepeatStopBody, sr as updateWakeAuthorization, st as isAutomatedRejectedError, tr as unsetFunctionRoute, tt as assertAutomatedVerdict, u as parsePresenceEnvelope, un as listDomains, ur as verifyAgentSignup, ut as cancelSentEmailByIdempotencyKey, v as parseWebhookEvent, vn as listMailboxAccess, vt as createRoute, w as pauseForTransientFailure, wn as listSentEmails, wt as deleteRoute, x as backoffDelay, xn as listRoles, y as parseFromHeader, yn as listOrganizationPeople, yt as createWakeAuthorization, z as AWAITING_VALUES, zn as rotateKey, zt as getEmail } from "../repeats-Dj_o6c-X-CK1wU9lP.js";
|
|
6
|
+
import { C as installedVersion, S as installedConnectSkillFile, T as readBundledSkill, _ as NotificationOutcomeUnknownError, a as NotificationRetryError, b as connectSkillTarget, c as readConversationStatusContent, d as SESSION_UUID$1, g as NativeSessionNotLoadedError, h as NativeSessionError, i as notificationReceiptPage, l as createListenHandler, m as NativeSessionDisconnectedError, n as notificationSenders, o as isRoutineNotificationContent, p as defaultSessionSocket, r as openSessionNotifications, s as notificationPartReader, t as notificationScope, u as readableDelivery, v as CONNECT_SKILL_NAME, w as readBundledConnectSkill, x as installSkill, y as bundledSkillNames } from "../notify-session-DrgOcIT6.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-D2MU7PiU.js";
|
|
8
8
|
import { C as resolveListenSubscription, S as normalizeListenOrigin, _ as acquireListenLock, a as mailLockBusy, c as mailTime, d as readMailJson, f as removeMailFile, g as ListenStateError, h as writeMailJson, i as mailId, l as privateMailDirectory, m as withMailLock, o as mailObject, u as privateMailPermissions, y as listenIdentity } from "../shared-mail-files-BAQSGxxz.js";
|
|
9
|
-
import { $ as saveConnectionName, A as ContactPolicyReadRetryError, B as AddressNotesApiError, C as RECEIVER_MODES, Ct as upsertManagedBlock, D as registrationSummary, Dt as refreshOwnerMemberAddressPeriodically, E as failedSessionRegistration, Et as addSessionReceiver, F as canonicalContactSelector, G as contactAgentAddress, H as runAddressNotesRequest, I as AgentDisconnectError, J as agentInvitationHash, K as runContactRequest, L as claimOverRevokedSetup, M as NetworkAdmissionPendingError, N as createNotificationContactPolicy, O as registrationSummaryLine, Ot as withOwnerMemberAddress, P as evaluateContactPolicy, Q as refusalAfterReplacement, R as clearRevokedAddresses, S as runAgentConnect, St as readManagedFile, T as verificationReplySubmitted, Tt as readHookLauncherWarning, U as ContactsApiError, V as addressNoteTarget, W as contactAddress, X as readAgentInvitation, Y as connectAgent, Z as receiverStatusCommand, _ as enrollmentResumes, _t as samePath, a as endSession, at as boundSessionProfiles, b as invitationProfileName, bt as inspectManagedBlock, c as pendingSessionDisconnects, ct as describeSessionHookChange, d as registerSession, dt as ephemeralCliReason, et as savedReceiver, f as retryPendingDisconnects, ft as findOnPath, g as enrollAgent, gt as repairClaudeHooks, h as staleSessionAgents, ht as readClaudeSettings, i as connectedProfilesForSession, it as recordHookMailCheck, j as NETWORK_ADMISSION_PENDING_RETRY_MS, k as waitForRegistrations, l as psProcessInfo, lt as describeSessionHookItem, m as runDetached, mt as inspectClaudeHooks, n as OMP_MAIN, nt as releaseRegistrationsForProfile, o as headlessClaudeRun, ot as claudeConfigDir, p as revokeStaleSessionAgents, pt as hasMachineSessionHooks, q as agentConnectionStatus, r as agentConnectionState, rt as installClaudeWakeHook, st as currentCliLocation, t as HOOK_END_GRACE_MS, tt as MACHINE_RUNTIMES, u as readClaudeHookInput, ut as ensureHookLauncher, v as connectWarnings, vt as writeClaudeSettings, w as externalReceivingState, wt as writeManagedFile, x as pollCheckCommand, xt as jsonIndentation, y as defaultAgentProfileName, yt as MachineFileError, z as disconnectAgent } from "../machine-session-
|
|
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-
|
|
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-BTJXO0vi.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-DN0qj4AY.js";
|
|
11
11
|
import { autoSignalEligible, dispatchAutoRead, dispatchAutoWorking, haltAutoWorking, isSentSignal, readWorkingLease, restoreAutoWorking } from "./auto-signals.js";
|
|
12
|
-
import { _ as EventConnection, a as ensureSharedMailSubscription, d as createSharedMailWaiter, f as openSharedMailStore, g as otherParticipants, h as readConversationFollow, i as sharedMailScope, l as KEY_REVOKED_MESSAGE, m as followEmailConversation, n as reconcileChatSend, p as reserveSharedMailSubscription, r as openSharedMailReceiver, s as AGENT_CONNECTION_REQUIRED_MESSAGE, t as sendSignal, u as isConnectedAgentKey, v as EventReceiverError } from "../signal-command-
|
|
12
|
+
import { _ as EventConnection, a as ensureSharedMailSubscription, d as createSharedMailWaiter, f as openSharedMailStore, g as otherParticipants, h as readConversationFollow, i as sharedMailScope, l as KEY_REVOKED_MESSAGE, m as followEmailConversation, n as reconcileChatSend, p as reserveSharedMailSubscription, r as openSharedMailReceiver, s as AGENT_CONNECTION_REQUIRED_MESSAGE, t as sendSignal, u as isConnectedAgentKey, v as EventReceiverError } from "../signal-command-BmxZqCot.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";
|
|
@@ -3106,6 +3106,12 @@ function endedClaimText(claim) {
|
|
|
3106
3106
|
return text !== "" && !/[\r\n]/.test(text) && text.length <= 500 ? text : "cleared";
|
|
3107
3107
|
}
|
|
3108
3108
|
// src/oclif/commands/api.ts
|
|
3109
|
+
const BLOCKED_CUSTOM_HEADERS = /* @__PURE__ */ new Set([
|
|
3110
|
+
"authorization",
|
|
3111
|
+
"cookie",
|
|
3112
|
+
"host",
|
|
3113
|
+
"proxy-authorization"
|
|
3114
|
+
]);
|
|
3109
3115
|
const ALLOWED_METHODS = /* @__PURE__ */ new Set([
|
|
3110
3116
|
"GET",
|
|
3111
3117
|
"POST",
|
|
@@ -3182,6 +3188,14 @@ var ApiCommand = class ApiCommand extends Command {
|
|
|
3182
3188
|
description: "Additional request header as name=value (repeatable; Authorization is managed automatically)",
|
|
3183
3189
|
multiple: true
|
|
3184
3190
|
}),
|
|
3191
|
+
query: Flags.string({
|
|
3192
|
+
char: "q",
|
|
3193
|
+
description: "Query parameter as key=value (repeatable; safely URL-encoded)",
|
|
3194
|
+
multiple: true
|
|
3195
|
+
}),
|
|
3196
|
+
reason: Flags.string({ description: "Short explanation sent as X-Primitive-Reason (also reads PRIMITIVE_REASON)" }),
|
|
3197
|
+
"run-id": Flags.string({ description: "Correlation ID sent as X-Primitive-Run-Id (also reads PRIMITIVE_RUN_ID)" }),
|
|
3198
|
+
"idempotency-key": Flags.string({ description: "Idempotency-Key header for safe retries" }),
|
|
3185
3199
|
"api-key": Flags.string({
|
|
3186
3200
|
description: "Override the Primitive API key for this request",
|
|
3187
3201
|
env: "PRIMITIVE_API_KEY"
|
|
@@ -3209,14 +3223,20 @@ var ApiCommand = class ApiCommand extends Command {
|
|
|
3209
3223
|
});
|
|
3210
3224
|
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
3225
|
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
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3226
|
+
const envActivityHeaders = cliActivityHeadersFromEnv();
|
|
3227
|
+
const explicitFlagsHeaders = {};
|
|
3228
|
+
if (flags.reason !== void 0) explicitFlagsHeaders[PRIMITIVE_REASON_HEADER] = validateActivityReason(flags.reason, "--reason");
|
|
3229
|
+
if (flags["run-id"] !== void 0) explicitFlagsHeaders[PRIMITIVE_RUN_ID_HEADER] = validateActivityRunId(flags["run-id"], "--run-id");
|
|
3230
|
+
if (flags["idempotency-key"] !== void 0) {
|
|
3231
|
+
const key = flags["idempotency-key"].trim();
|
|
3232
|
+
if (!key || key.length > 255 || !/^[\x21-\x7e]+$/.test(key)) throw new Errors.CLIError("--idempotency-key must be 1 to 255 printable ASCII characters without spaces.", { exit: 2 });
|
|
3233
|
+
explicitFlagsHeaders["Idempotency-Key"] = key;
|
|
3234
|
+
}
|
|
3235
|
+
const headers = mergeHeadersCaseInsensitive({ accept: "application/json" }, authenticated.auth.agentPass || authenticated.auth.connectedAgent ? void 0 : authenticated.requestConfig.headers, envActivityHeaders, explicitFlagsHeaders) ?? {};
|
|
3216
3236
|
for (const rawHeader of flags.header ?? []) {
|
|
3217
3237
|
const [name, value] = parseHeaderAssignment(rawHeader);
|
|
3218
3238
|
const lower = name.toLowerCase();
|
|
3219
|
-
if (lower
|
|
3239
|
+
if (BLOCKED_CUSTOM_HEADERS.has(lower)) throw new Errors.CLIError(`${name} header is managed automatically and cannot be overridden with -H.`, { exit: 1 });
|
|
3220
3240
|
for (const existingKey of Object.keys(headers)) if (existingKey.toLowerCase() === lower) delete headers[existingKey];
|
|
3221
3241
|
headers[name] = value;
|
|
3222
3242
|
}
|
|
@@ -3227,12 +3247,19 @@ var ApiCommand = class ApiCommand extends Command {
|
|
|
3227
3247
|
body = await readDataPayload(flags.data);
|
|
3228
3248
|
if (!Object.keys(headers).some((key) => key.toLowerCase() === "content-type")) headers["content-type"] = "application/json";
|
|
3229
3249
|
}
|
|
3230
|
-
const
|
|
3250
|
+
const requestUrl = new URL(`${authenticated.auth.apiBaseUrl.replace(/\/+$/, "")}${path}`);
|
|
3251
|
+
for (const rawQuery of flags.query ?? []) {
|
|
3252
|
+
const eqIdx = rawQuery.indexOf("=");
|
|
3253
|
+
if (eqIdx <= 0) throw new Errors.CLIError(`Invalid --query value "${rawQuery}". Expected key=value.`, { exit: 2 });
|
|
3254
|
+
requestUrl.searchParams.append(rawQuery.slice(0, eqIdx), rawQuery.slice(eqIdx + 1));
|
|
3255
|
+
}
|
|
3231
3256
|
let response;
|
|
3232
3257
|
try {
|
|
3233
|
-
response = await fetch(
|
|
3258
|
+
response = await fetch(requestUrl.toString(), {
|
|
3234
3259
|
method,
|
|
3235
3260
|
headers,
|
|
3261
|
+
redirect: "manual",
|
|
3262
|
+
signal: AbortSignal.timeout(3e4),
|
|
3236
3263
|
...body !== void 0 ? { body } : {}
|
|
3237
3264
|
});
|
|
3238
3265
|
} catch (error) {
|
|
@@ -7290,7 +7317,8 @@ var ConnectCommand = class ConnectCommand extends Command {
|
|
|
7290
7317
|
this.log(`Bound to: ${formatBinding(rebound)}`);
|
|
7291
7318
|
this.log(`Expires at: ${meta.expires_at}`);
|
|
7292
7319
|
if (meta.slice_summary) this.log(`Scope: ${meta.slice_summary}`);
|
|
7293
|
-
this.log(`
|
|
7320
|
+
if (meta.manage_url) this.log(`Manage / extend / promote: ${meta.manage_url}`);
|
|
7321
|
+
this.log(`This pass expires automatically. Only run \`${revokeCommand}\` if explicitly asked to revoke access early.`);
|
|
7294
7322
|
return;
|
|
7295
7323
|
}
|
|
7296
7324
|
const claimed = await claimAccessPassRemote({
|
|
@@ -7309,6 +7337,7 @@ var ConnectCommand = class ConnectCommand extends Command {
|
|
|
7309
7337
|
...claimed.purpose ? { purpose: claimed.purpose } : {},
|
|
7310
7338
|
...claimed.profile_hint ? { profile_hint: claimed.profile_hint } : {},
|
|
7311
7339
|
...claimed.mcp_url ? { mcp_url: claimed.mcp_url } : {},
|
|
7340
|
+
...claimed.manage_url ? { manage_url: claimed.manage_url } : {},
|
|
7312
7341
|
expires_at: claimed.expires_at,
|
|
7313
7342
|
slice_summary: claimed.slice_summary,
|
|
7314
7343
|
claimed_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -7336,6 +7365,7 @@ var ConnectCommand = class ConnectCommand extends Command {
|
|
|
7336
7365
|
this.log(`Bound to: ${formatBinding(stored)}`);
|
|
7337
7366
|
this.log(`Expires at: ${meta.expires_at}`);
|
|
7338
7367
|
if (meta.slice_summary) this.log(`Scope: ${meta.slice_summary}`);
|
|
7368
|
+
if (meta.manage_url) this.log(`Manage / extend / promote: ${meta.manage_url}`);
|
|
7339
7369
|
if (typeof claimed.guide === "string" && claimed.guide.trim()) {
|
|
7340
7370
|
this.log("");
|
|
7341
7371
|
this.log(claimed.guide.trim());
|
|
@@ -7348,7 +7378,7 @@ var ConnectCommand = class ConnectCommand extends Command {
|
|
|
7348
7378
|
this.log(`Preview: ${JSON.stringify(claimed.preview)}`);
|
|
7349
7379
|
}
|
|
7350
7380
|
this.log("");
|
|
7351
|
-
this.log(`
|
|
7381
|
+
this.log(`This pass expires automatically. Do not auto-revoke after answering; only run \`${revokeCommand}\` if the user explicitly asks to end access.`);
|
|
7352
7382
|
} catch (error) {
|
|
7353
7383
|
const message = error instanceof AgentPassAuthError || error instanceof Error ? error.message : String(error);
|
|
7354
7384
|
throw new Errors.CLIError(message, { exit: 1 });
|
|
@@ -8706,6 +8736,151 @@ function noUnderstandingMessage(understanding) {
|
|
|
8706
8736
|
function isRecord$1(value) {
|
|
8707
8737
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
8708
8738
|
}
|
|
8739
|
+
// src/oclif/activity-api.ts
|
|
8740
|
+
const ACTIVITY_KINDS = [
|
|
8741
|
+
"action",
|
|
8742
|
+
"note",
|
|
8743
|
+
"handoff"
|
|
8744
|
+
];
|
|
8745
|
+
const ACTIVITY_STATUSES = [
|
|
8746
|
+
"started",
|
|
8747
|
+
"succeeded",
|
|
8748
|
+
"failed",
|
|
8749
|
+
"skipped",
|
|
8750
|
+
"needs_review"
|
|
8751
|
+
];
|
|
8752
|
+
const ACTIVITY_VISIBILITIES = ["thread", "actor_only"];
|
|
8753
|
+
const ACTIVITY_OWNERSHIPS = [
|
|
8754
|
+
"human",
|
|
8755
|
+
"personal_agent",
|
|
8756
|
+
"org_key",
|
|
8757
|
+
"function",
|
|
8758
|
+
"app",
|
|
8759
|
+
"system"
|
|
8760
|
+
];
|
|
8761
|
+
const TIMELINE_SOURCES = [
|
|
8762
|
+
"all",
|
|
8763
|
+
"primitive",
|
|
8764
|
+
"agent"
|
|
8765
|
+
];
|
|
8766
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
8767
|
+
const ACTION_SLUG_RE = /^[a-z0-9][a-z0-9._:-]{0,127}$/;
|
|
8768
|
+
const IDEMPOTENCY_KEY_RE = /^[\x21-\x7e]{1,255}$/;
|
|
8769
|
+
function assertUuid(value, label) {
|
|
8770
|
+
const trimmed = value.trim();
|
|
8771
|
+
if (!UUID_RE.test(trimmed)) throw new Errors.CLIError(`${label} must be a valid UUID.`, { exit: 2 });
|
|
8772
|
+
return trimmed.toLowerCase();
|
|
8773
|
+
}
|
|
8774
|
+
function assertHttpUrl(value, label) {
|
|
8775
|
+
const trimmed = value.trim();
|
|
8776
|
+
let parsed;
|
|
8777
|
+
try {
|
|
8778
|
+
parsed = new URL(trimmed);
|
|
8779
|
+
} catch {
|
|
8780
|
+
throw new Errors.CLIError(`${label} must be a valid http(s) URL.`, { exit: 2 });
|
|
8781
|
+
}
|
|
8782
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") throw new Errors.CLIError(`${label} must use https:// or http://.`, { exit: 2 });
|
|
8783
|
+
if (trimmed.length > 2048) throw new Errors.CLIError(`${label} must be at most 2048 characters.`, { exit: 2 });
|
|
8784
|
+
return parsed.toString();
|
|
8785
|
+
}
|
|
8786
|
+
function formatActorLabel(actor) {
|
|
8787
|
+
const base = actor.label || actor.kind;
|
|
8788
|
+
if (actor.ownership !== "human" && actor.owner_label) return `${base} (${actor.ownership}, owner: ${actor.owner_label})`;
|
|
8789
|
+
return `${base} (${actor.ownership})`;
|
|
8790
|
+
}
|
|
8791
|
+
function formatTimelineItemLine(item) {
|
|
8792
|
+
const actor = formatActorLabel(item.actor);
|
|
8793
|
+
if (item.source === "primitive") {
|
|
8794
|
+
const reasonPart = item.reason ? ` | reason: ${item.reason}` : "";
|
|
8795
|
+
const runPart = item.run_id ? ` | run: ${item.run_id}` : "";
|
|
8796
|
+
return `${item.occurred_at} [verified] ${item.action} by ${actor}${reasonPart}${runPart}`;
|
|
8797
|
+
}
|
|
8798
|
+
const refPart = item.external_ref?.url ? ` | ${item.external_ref.label || item.external_ref.system}: ${item.external_ref.url}` : item.external_ref ? ` | ${item.external_ref.system}${item.external_ref.id ? `:${item.external_ref.id}` : ""}` : "";
|
|
8799
|
+
const privateTag = item.visibility === "actor_only" ? " [private]" : "";
|
|
8800
|
+
return `${item.occurred_at} [${item.status}]${privateTag} ${item.action} by ${actor} | ${item.summary}${refPart}`;
|
|
8801
|
+
}
|
|
8802
|
+
function sanitizeErrorText(text) {
|
|
8803
|
+
let clean = "";
|
|
8804
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
8805
|
+
const code = text.charCodeAt(i);
|
|
8806
|
+
if (code === 27 && text.charCodeAt(i + 1) === 91) {
|
|
8807
|
+
i += 2;
|
|
8808
|
+
while (i < text.length) {
|
|
8809
|
+
const seqCode = text.charCodeAt(i);
|
|
8810
|
+
if (seqCode >= 64 && seqCode <= 126) break;
|
|
8811
|
+
i += 1;
|
|
8812
|
+
}
|
|
8813
|
+
continue;
|
|
8814
|
+
}
|
|
8815
|
+
if (code === 10 || code === 13 || code === 9) clean += " ";
|
|
8816
|
+
else if (code >= 32 && code !== 127 && (code < 128 || code > 159)) clean += text[i];
|
|
8817
|
+
}
|
|
8818
|
+
return clean.replace(/\s+/g, " ").trim().slice(0, 400);
|
|
8819
|
+
}
|
|
8820
|
+
async function callActivityApi(options) {
|
|
8821
|
+
const authenticated = options.authenticated ?? await createAuthenticatedCliApiClient({
|
|
8822
|
+
configDir: options.configDir,
|
|
8823
|
+
apiKey: options.apiKey,
|
|
8824
|
+
apiBaseUrl: options.apiBaseUrl
|
|
8825
|
+
});
|
|
8826
|
+
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 });
|
|
8827
|
+
const baseUrl = authenticated.auth.apiBaseUrl.replace(/\/+$/, "");
|
|
8828
|
+
const url = new URL(`${baseUrl}${options.path}`);
|
|
8829
|
+
if (options.query) {
|
|
8830
|
+
for (const [key, value] of Object.entries(options.query)) if (value !== void 0 && String(value).length > 0) url.searchParams.set(key, String(value));
|
|
8831
|
+
}
|
|
8832
|
+
let serializedBody;
|
|
8833
|
+
if (options.body !== void 0) serializedBody = JSON.stringify(options.body);
|
|
8834
|
+
const headers = mergeHeadersCaseInsensitive({ accept: options.rawText ? "text/csv, application/json" : "application/json" }, authenticated.auth.agentPass || authenticated.auth.connectedAgent ? void 0 : authenticated.requestConfig.headers, cliActivityHeadersFromEnv(), options.headers, {
|
|
8835
|
+
authorization: `Bearer ${authenticated.auth.apiKey}`,
|
|
8836
|
+
...serializedBody !== void 0 ? { "content-type": "application/json" } : {}
|
|
8837
|
+
}) ?? {};
|
|
8838
|
+
let response;
|
|
8839
|
+
try {
|
|
8840
|
+
response = await fetch(url.toString(), {
|
|
8841
|
+
method: options.method,
|
|
8842
|
+
headers,
|
|
8843
|
+
redirect: "manual",
|
|
8844
|
+
signal: AbortSignal.timeout(3e4),
|
|
8845
|
+
...serializedBody !== void 0 ? { body: serializedBody } : {}
|
|
8846
|
+
});
|
|
8847
|
+
} catch (error) {
|
|
8848
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
8849
|
+
throw new Errors.CLIError(`Primitive API request failed: ${detail}`, { exit: 1 });
|
|
8850
|
+
}
|
|
8851
|
+
const rawText = await response.text();
|
|
8852
|
+
if (!response.ok) {
|
|
8853
|
+
let message = `Primitive API returned HTTP ${response.status}.`;
|
|
8854
|
+
let code;
|
|
8855
|
+
try {
|
|
8856
|
+
const parsed = JSON.parse(rawText);
|
|
8857
|
+
code = parsed.error?.code;
|
|
8858
|
+
if (parsed.error?.message) message = parsed.error.message;
|
|
8859
|
+
} catch {
|
|
8860
|
+
const sanitized = sanitizeErrorText(rawText);
|
|
8861
|
+
if (sanitized) message = sanitized;
|
|
8862
|
+
}
|
|
8863
|
+
const hint = code === "grant_forbidden" ? " Check whether this credential holds mail.activity:read / mail.activity:write." : code === "access_reason_required" ? " Pass --reason \"...\" or set PRIMITIVE_REASON." : "";
|
|
8864
|
+
throw new Errors.CLIError(`${message}${hint}`, { exit: 1 });
|
|
8865
|
+
}
|
|
8866
|
+
if (options.rawText) return {
|
|
8867
|
+
data: void 0,
|
|
8868
|
+
text: rawText,
|
|
8869
|
+
headers: response.headers,
|
|
8870
|
+
status: response.status
|
|
8871
|
+
};
|
|
8872
|
+
let parsed;
|
|
8873
|
+
try {
|
|
8874
|
+
parsed = rawText ? JSON.parse(rawText) : null;
|
|
8875
|
+
} catch {
|
|
8876
|
+
throw new Errors.CLIError("Primitive API returned invalid JSON.", { exit: 1 });
|
|
8877
|
+
}
|
|
8878
|
+
return {
|
|
8879
|
+
data: parsed && typeof parsed === "object" && "data" in parsed ? parsed.data : parsed,
|
|
8880
|
+
headers: response.headers,
|
|
8881
|
+
status: response.status
|
|
8882
|
+
};
|
|
8883
|
+
}
|
|
8709
8884
|
// src/oclif/repeat-message.ts
|
|
8710
8885
|
const UUID$5 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
8711
8886
|
/** The server-verified repeat marker on an email read, if any. */
|
|
@@ -9281,6 +9456,27 @@ async function clearPendingAfterRead(configDir, emailId, known) {
|
|
|
9281
9456
|
} catch {}
|
|
9282
9457
|
}
|
|
9283
9458
|
const NO_SIGNAL_DESCRIPTION = "Do not report working to the sender, and stop a working report an earlier read of this email started; nothing is sent. Only a --context read reports working; on any other read this flag just stops the earlier report. By default, reading mail from the verified owner or a same-organization member (not another agent) that a receiver surfaced to this session reports working in the background until you answer (also disabled by PRIMITIVE_NO_AUTO_SIGNALS=1).";
|
|
9459
|
+
const WITH_ACTIVITY_DESCRIPTION = "Also fetch recent verified mail actions and shared agent work logs for this email's thread (requires mail.activity:read).";
|
|
9460
|
+
async function fetchEmailThreadActivity(command, threadId, flags, authenticated) {
|
|
9461
|
+
if (!threadId) return [];
|
|
9462
|
+
const validThreadId = assertUuid(threadId, "thread_id");
|
|
9463
|
+
return (await callActivityApi({
|
|
9464
|
+
configDir: command.config.configDir,
|
|
9465
|
+
apiKey: flags["api-key"],
|
|
9466
|
+
apiBaseUrl: flags["api-base-url"],
|
|
9467
|
+
authenticated,
|
|
9468
|
+
method: "GET",
|
|
9469
|
+
path: `/threads/${validThreadId}/timeline`,
|
|
9470
|
+
query: {
|
|
9471
|
+
source: "all",
|
|
9472
|
+
limit: 20
|
|
9473
|
+
}
|
|
9474
|
+
})).data.items;
|
|
9475
|
+
}
|
|
9476
|
+
function renderThreadActivitySection(items) {
|
|
9477
|
+
if (items.length === 0) return "\nThread Activity:\n (none recorded yet)";
|
|
9478
|
+
return `\nThread Activity:\n${items.map((item) => ` ${formatTimelineItemLine(item)}`).join("\n")}`;
|
|
9479
|
+
}
|
|
9284
9480
|
/**
|
|
9285
9481
|
* The line a brief ends with once it has started reporting working: the
|
|
9286
9482
|
* agent only knows whether it will act after reading, so the way out has to
|
|
@@ -9303,11 +9499,12 @@ function workingStopLine(command) {
|
|
|
9303
9499
|
async function runBrief(command, flags) {
|
|
9304
9500
|
await runWithTiming(flags.time === true, async () => {
|
|
9305
9501
|
if (flags["no-signal"]) await haltAutoWorking(command.config.configDir, { emailIds: [flags.id] }, "not_acting");
|
|
9306
|
-
const
|
|
9502
|
+
const authenticated = await createAuthenticatedCliApiClient({
|
|
9307
9503
|
configDir: command.config.configDir,
|
|
9308
9504
|
apiKey: flags["api-key"],
|
|
9309
9505
|
apiBaseUrl: flags["api-base-url"]
|
|
9310
9506
|
});
|
|
9507
|
+
const { apiClient, auth, baseUrlOverridden } = authenticated;
|
|
9311
9508
|
const result = await getEmail({
|
|
9312
9509
|
client: apiClient.client,
|
|
9313
9510
|
path: { id: flags.id },
|
|
@@ -9338,25 +9535,28 @@ async function runBrief(command, flags) {
|
|
|
9338
9535
|
isOwnSignal: (sentId) => isSentSignal(command.config.configDir, sentId),
|
|
9339
9536
|
signal: AbortSignal.timeout(3e4)
|
|
9340
9537
|
});
|
|
9538
|
+
const activity = flags["with-activity"] ? await fetchEmailThreadActivity(command, detail.thread_id, flags, authenticated) : void 0;
|
|
9341
9539
|
const stop = !flags["no-signal"] && detail.sender_connected_agent_verified !== true && dispatchAutoWorking({
|
|
9342
9540
|
configDir: command.config.configDir,
|
|
9343
9541
|
emailId: detail.id
|
|
9344
9542
|
}) || !flags["no-signal"] && workingStillRunning(readWorkingLease(command.config.configDir, detail.id)) ? workingStopCommand(detail.id, followUpCommandPrefix()) : null;
|
|
9345
|
-
command.log(flags.json ? JSON.stringify(
|
|
9543
|
+
command.log(flags.json ? JSON.stringify({
|
|
9346
9544
|
...brief,
|
|
9347
|
-
working_signal: { stop_command: stop }
|
|
9348
|
-
|
|
9545
|
+
...stop ? { working_signal: { stop_command: stop } } : {},
|
|
9546
|
+
...activity !== void 0 ? { activity } : {}
|
|
9547
|
+
}, null, 2) : `${renderEmailBrief(brief)}${activity !== void 0 ? renderThreadActivitySection(activity) : ""}${stop ? `\n${workingStopLine(stop)}` : ""}`);
|
|
9349
9548
|
await clearPendingAfterRead(command.config.configDir, detail.id, detail);
|
|
9350
9549
|
});
|
|
9351
9550
|
}
|
|
9352
9551
|
const ROUTE_MISSING_NOTICE = "Note: this server does not offer the readable read yet, so a local compact view was printed.\n";
|
|
9353
9552
|
async function runCompact(command, flags) {
|
|
9354
9553
|
await runWithTiming(flags.time === true, async () => {
|
|
9355
|
-
const
|
|
9554
|
+
const authenticated = await createAuthenticatedCliApiClient({
|
|
9356
9555
|
configDir: command.config.configDir,
|
|
9357
9556
|
apiKey: flags["api-key"],
|
|
9358
9557
|
apiBaseUrl: flags["api-base-url"]
|
|
9359
9558
|
});
|
|
9559
|
+
const { apiClient, auth, baseUrlOverridden } = authenticated;
|
|
9360
9560
|
const fail = async (error) => {
|
|
9361
9561
|
const payload = extractErrorPayload(error);
|
|
9362
9562
|
writeErrorWithHints(payload);
|
|
@@ -9375,7 +9575,11 @@ async function runCompact(command, flags) {
|
|
|
9375
9575
|
...flags.links !== void 0 ? { links: flags.links } : {}
|
|
9376
9576
|
});
|
|
9377
9577
|
if (readable.kind === "ok") {
|
|
9378
|
-
command
|
|
9578
|
+
const activity = flags["with-activity"] ? await fetchEmailThreadActivity(command, readable.data.thread_id, flags, authenticated) : void 0;
|
|
9579
|
+
command.log(JSON.stringify(activity !== void 0 ? {
|
|
9580
|
+
...readable.data,
|
|
9581
|
+
activity
|
|
9582
|
+
} : readable.data, null, 2));
|
|
9379
9583
|
await clearPendingAfterRead(command.config.configDir, readable.data.id, readable.data);
|
|
9380
9584
|
return;
|
|
9381
9585
|
}
|
|
@@ -9393,8 +9597,12 @@ async function runCompact(command, flags) {
|
|
|
9393
9597
|
await fail(result.error);
|
|
9394
9598
|
return;
|
|
9395
9599
|
}
|
|
9600
|
+
const activity = flags["with-activity"] ? await fetchEmailThreadActivity(command, detail.thread_id, flags, authenticated) : void 0;
|
|
9396
9601
|
process.stderr.write(ROUTE_MISSING_NOTICE);
|
|
9397
|
-
command.log(JSON.stringify(
|
|
9602
|
+
command.log(JSON.stringify(activity !== void 0 ? {
|
|
9603
|
+
...buildEmailCompact(detail),
|
|
9604
|
+
activity
|
|
9605
|
+
} : buildEmailCompact(detail), null, 2));
|
|
9398
9606
|
await clearPendingAfterRead(command.config.configDir, detail.id, detail);
|
|
9399
9607
|
});
|
|
9400
9608
|
}
|
|
@@ -9433,7 +9641,8 @@ function createEmailsGetCommand(base) {
|
|
|
9433
9641
|
description: LINKS_DESCRIPTION,
|
|
9434
9642
|
dependsOn: ["compact"]
|
|
9435
9643
|
}),
|
|
9436
|
-
"no-signal": Flags.boolean({ description: NO_SIGNAL_DESCRIPTION })
|
|
9644
|
+
"no-signal": Flags.boolean({ description: NO_SIGNAL_DESCRIPTION }),
|
|
9645
|
+
"with-activity": Flags.boolean({ description: WITH_ACTIVITY_DESCRIPTION })
|
|
9437
9646
|
};
|
|
9438
9647
|
async run() {
|
|
9439
9648
|
if (this.argv.includes("--brief")) {
|
|
@@ -9460,7 +9669,43 @@ function createEmailsGetCommand(base) {
|
|
|
9460
9669
|
await runCompact(this, parsed);
|
|
9461
9670
|
return;
|
|
9462
9671
|
}
|
|
9463
|
-
|
|
9672
|
+
if (parsed["with-activity"]) {
|
|
9673
|
+
await runWithTiming(parsed.time === true, async () => {
|
|
9674
|
+
const authenticated = await createAuthenticatedCliApiClient({
|
|
9675
|
+
configDir: this.config.configDir,
|
|
9676
|
+
apiKey: parsed["api-key"],
|
|
9677
|
+
apiBaseUrl: parsed["api-base-url"]
|
|
9678
|
+
});
|
|
9679
|
+
const { apiClient, auth, baseUrlOverridden } = authenticated;
|
|
9680
|
+
const result = await getEmail({
|
|
9681
|
+
client: apiClient.client,
|
|
9682
|
+
path: { id: parsed.id },
|
|
9683
|
+
responseStyle: "fields"
|
|
9684
|
+
});
|
|
9685
|
+
const detail = result.data?.data;
|
|
9686
|
+
if (result.error || !detail) {
|
|
9687
|
+
const payload = extractErrorPayload(result.error);
|
|
9688
|
+
writeErrorWithHints(payload);
|
|
9689
|
+
surfaceUnauthorizedHint({
|
|
9690
|
+
auth,
|
|
9691
|
+
baseUrlOverridden,
|
|
9692
|
+
configDir: this.config.configDir,
|
|
9693
|
+
payload
|
|
9694
|
+
});
|
|
9695
|
+
if (extractErrorCode(payload) === "not_found") await explainPendingMailNotFound(this.config.configDir, parsed.id);
|
|
9696
|
+
process.exitCode = 1;
|
|
9697
|
+
return;
|
|
9698
|
+
}
|
|
9699
|
+
const activity = await fetchEmailThreadActivity(this, detail.thread_id, parsed, authenticated);
|
|
9700
|
+
this.log(JSON.stringify({
|
|
9701
|
+
...detail,
|
|
9702
|
+
activity
|
|
9703
|
+
}, null, 2));
|
|
9704
|
+
await clearPendingAfterRead(this.config.configDir, detail.id, detail);
|
|
9705
|
+
});
|
|
9706
|
+
return;
|
|
9707
|
+
}
|
|
9708
|
+
this.argv = this.argv.filter((arg) => arg !== "--no-signal" && arg !== "--with-activity");
|
|
9464
9709
|
const before = process.exitCode;
|
|
9465
9710
|
await base.prototype.run.call(this);
|
|
9466
9711
|
if (process.exitCode === before || process.exitCode === 0) await clearPendingAfterRead(this.config.configDir, parsed.id);
|
|
@@ -11501,8 +11746,8 @@ const PRIMITIVE_TEAM_AUTHOR = {
|
|
|
11501
11746
|
name: "Primitive Team",
|
|
11502
11747
|
url: "https://primitive.dev"
|
|
11503
11748
|
};
|
|
11504
|
-
const SDK_VERSION_RANGE = "^3.0.0-preview.
|
|
11505
|
-
const CLI_VERSION_RANGE = "^3.0.0-preview.
|
|
11749
|
+
const SDK_VERSION_RANGE = "^3.0.0-preview.25";
|
|
11750
|
+
const CLI_VERSION_RANGE = "^3.0.0-preview.25";
|
|
11506
11751
|
const ESBUILD_VERSION_RANGE = "^0.27.0";
|
|
11507
11752
|
function renderHandler() {
|
|
11508
11753
|
return `// env.PRIMITIVE_API_KEY, env.PRIMITIVE_WEBHOOK_SECRET, and
|
|
@@ -21192,6 +21437,518 @@ var MachineDoctorCommand = class MachineDoctorCommand extends Command {
|
|
|
21192
21437
|
if (report.summary.fail || report.summary.warn) process.exitCode = 1;
|
|
21193
21438
|
}
|
|
21194
21439
|
};
|
|
21440
|
+
// src/oclif/commands/mail-activity.ts
|
|
21441
|
+
const MAX_DATA_BYTES = 16384;
|
|
21442
|
+
function readUtf8File(filePath, label) {
|
|
21443
|
+
try {
|
|
21444
|
+
return readFileSync(filePath, "utf8");
|
|
21445
|
+
} catch (error) {
|
|
21446
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
21447
|
+
throw new Errors.CLIError(`Could not read ${label} from ${filePath}: ${detail}`, { exit: 2 });
|
|
21448
|
+
}
|
|
21449
|
+
}
|
|
21450
|
+
function parseJsonObjectFlag(raw, label) {
|
|
21451
|
+
let parsed;
|
|
21452
|
+
try {
|
|
21453
|
+
parsed = JSON.parse(raw);
|
|
21454
|
+
} catch (error) {
|
|
21455
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
21456
|
+
throw new Errors.CLIError(`${label} must be valid JSON: ${detail}`, { exit: 2 });
|
|
21457
|
+
}
|
|
21458
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Errors.CLIError(`${label} must be a JSON object.`, { exit: 2 });
|
|
21459
|
+
const bytes = Buffer.byteLength(JSON.stringify(parsed), "utf8");
|
|
21460
|
+
if (bytes > MAX_DATA_BYTES) throw new Errors.CLIError(`${label} exceeds the ${MAX_DATA_BYTES}-byte limit (${bytes} bytes).`, { exit: 2 });
|
|
21461
|
+
return parsed;
|
|
21462
|
+
}
|
|
21463
|
+
function buildExternalRef(flags) {
|
|
21464
|
+
const hasRefFlags = Boolean(flags["ref-system"] || flags["ref-id"] || flags["ref-url"] || flags["ref-label"]);
|
|
21465
|
+
if (flags["external-ref"] && hasRefFlags) throw new Errors.CLIError("Use either --external-ref or --ref-system/--ref-id/--ref-url/--ref-label, not both.", { exit: 2 });
|
|
21466
|
+
if (flags["external-ref"]) {
|
|
21467
|
+
const obj = parseJsonObjectFlag(flags["external-ref"], "--external-ref");
|
|
21468
|
+
if (typeof obj.system !== "string" || !obj.system.trim()) throw new Errors.CLIError("--external-ref must include a non-empty string `system`.", { exit: 2 });
|
|
21469
|
+
const ref = { system: obj.system.trim() };
|
|
21470
|
+
if (typeof obj.id === "string" && obj.id.trim()) ref.id = obj.id.trim();
|
|
21471
|
+
if (typeof obj.url === "string" && obj.url.trim()) ref.url = assertHttpUrl(obj.url, "--external-ref.url");
|
|
21472
|
+
if (typeof obj.label === "string" && obj.label.trim()) ref.label = obj.label.trim();
|
|
21473
|
+
return ref;
|
|
21474
|
+
}
|
|
21475
|
+
if (!hasRefFlags) return void 0;
|
|
21476
|
+
if (!flags["ref-system"]?.trim()) throw new Errors.CLIError("--ref-system is required when setting --ref-id, --ref-url, or --ref-label.", { exit: 2 });
|
|
21477
|
+
const ref = { system: flags["ref-system"].trim() };
|
|
21478
|
+
if (flags["ref-id"]?.trim()) ref.id = flags["ref-id"].trim();
|
|
21479
|
+
if (flags["ref-url"]?.trim()) ref.url = assertHttpUrl(flags["ref-url"], "--ref-url");
|
|
21480
|
+
if (flags["ref-label"]?.trim()) ref.label = flags["ref-label"].trim();
|
|
21481
|
+
return ref;
|
|
21482
|
+
}
|
|
21483
|
+
function validateStatusCsv(raw) {
|
|
21484
|
+
const allowed = new Set(ACTIVITY_STATUSES);
|
|
21485
|
+
const parts = raw.split(",").map((p) => p.trim()).filter(Boolean);
|
|
21486
|
+
if (parts.length === 0 || !parts.every((p) => allowed.has(p))) throw new Errors.CLIError(`--status must be a comma-separated list of: ${ACTIVITY_STATUSES.join(", ")}.`, { exit: 2 });
|
|
21487
|
+
return parts.join(",");
|
|
21488
|
+
}
|
|
21489
|
+
const COMMON_API_FLAGS = {
|
|
21490
|
+
json: Flags.boolean({ description: "Output single-document JSON to stdout" }),
|
|
21491
|
+
time: Flags.boolean({ description: "Print request timing to stderr" }),
|
|
21492
|
+
"api-key": Flags.string({
|
|
21493
|
+
description: "Override the Primitive API key for this request",
|
|
21494
|
+
env: "PRIMITIVE_API_KEY"
|
|
21495
|
+
}),
|
|
21496
|
+
"api-base-url": Flags.string({
|
|
21497
|
+
description: "Override the API base URL",
|
|
21498
|
+
env: "PRIMITIVE_API_BASE_URL",
|
|
21499
|
+
hidden: true
|
|
21500
|
+
})
|
|
21501
|
+
};
|
|
21502
|
+
var ActivityLogCommand = class ActivityLogCommand extends Command {
|
|
21503
|
+
static summary = "Log an agent work note, external action outcome, or handoff";
|
|
21504
|
+
static description = "Record structured work on a Primitive email or thread so humans and other agents see what already happened. Supply a deterministic --idempotency-key per (thread, action) so retries update the same entry cleanly.";
|
|
21505
|
+
static examples = [`<%= config.bin %> activity log --email <email-id> --action brex.upload_invoice --status succeeded --summary "Uploaded Acme invoice #412 to Brex" --ref-system brex --ref-id inv_412 --idempotency-key brex.upload_invoice:v1`, `<%= config.bin %> activity log --thread <thread-id> --kind handoff --status needs_review --summary "Personal invoice detected; needs confirmation"`];
|
|
21506
|
+
static args = { summary: Args.string({
|
|
21507
|
+
description: "Optional positional summary (alternative to --summary)",
|
|
21508
|
+
required: false
|
|
21509
|
+
}) };
|
|
21510
|
+
static flags = {
|
|
21511
|
+
thread: Flags.string({ description: "Thread UUID to attach the activity to" }),
|
|
21512
|
+
email: Flags.string({ description: "Inbound email UUID to anchor the activity to (resolves its thread automatically when --thread is omitted)" }),
|
|
21513
|
+
"sent-email": Flags.string({ description: "Optional outbound sent email UUID related to this work" }),
|
|
21514
|
+
summary: Flags.string({
|
|
21515
|
+
char: "s",
|
|
21516
|
+
description: "One-line human-readable summary (1 to 1000 chars)"
|
|
21517
|
+
}),
|
|
21518
|
+
kind: Flags.string({
|
|
21519
|
+
description: "Entry kind: action, note, or handoff",
|
|
21520
|
+
options: [...ACTIVITY_KINDS]
|
|
21521
|
+
}),
|
|
21522
|
+
action: Flags.string({
|
|
21523
|
+
char: "a",
|
|
21524
|
+
description: "Dot-namespaced action verb (for example brex.upload_invoice)"
|
|
21525
|
+
}),
|
|
21526
|
+
status: Flags.string({
|
|
21527
|
+
description: "Outcome status: started, succeeded, failed, skipped, or needs_review",
|
|
21528
|
+
options: [...ACTIVITY_STATUSES]
|
|
21529
|
+
}),
|
|
21530
|
+
detail: Flags.string({ description: "Optional extended detail (up to 8000 chars)" }),
|
|
21531
|
+
"detail-file": Flags.string({ description: "Read extended detail text from a file" }),
|
|
21532
|
+
"ref-system": Flags.string({ description: "External system name (for example brex, salesforce, linear)" }),
|
|
21533
|
+
"ref-id": Flags.string({ description: "External record ID (requires --ref-system)" }),
|
|
21534
|
+
"ref-url": Flags.string({ description: "External record https:// URL (requires --ref-system)" }),
|
|
21535
|
+
"ref-label": Flags.string({ description: "Display label for the external link (requires --ref-system)" }),
|
|
21536
|
+
"external-ref": Flags.string({ description: "External reference as a JSON object (alternative to --ref-*)" }),
|
|
21537
|
+
data: Flags.string({ description: "Structured metadata JSON object (up to 16 KB)" }),
|
|
21538
|
+
"data-file": Flags.string({ description: "Read structured metadata JSON object from a file" }),
|
|
21539
|
+
"run-id": Flags.string({
|
|
21540
|
+
description: "Agent run correlation ID (defaults to PRIMITIVE_RUN_ID)",
|
|
21541
|
+
env: "PRIMITIVE_RUN_ID"
|
|
21542
|
+
}),
|
|
21543
|
+
"trace-url": Flags.string({ description: "Optional https:// URL to the agent execution trace" }),
|
|
21544
|
+
"idempotency-key": Flags.string({ description: "Deterministic key per (thread, action) so retries upsert in place" }),
|
|
21545
|
+
visibility: Flags.string({
|
|
21546
|
+
description: "Visibility: thread (default, shared) or actor_only (private)",
|
|
21547
|
+
options: [...ACTIVITY_VISIBILITIES]
|
|
21548
|
+
}),
|
|
21549
|
+
...COMMON_API_FLAGS
|
|
21550
|
+
};
|
|
21551
|
+
async run() {
|
|
21552
|
+
const { args, flags } = await this.parse(ActivityLogCommand);
|
|
21553
|
+
const summary = (flags.summary ?? args.summary ?? "").trim();
|
|
21554
|
+
if (!summary) throw new Errors.CLIError("Provide --summary \"...\" (or a positional summary argument).", { exit: 2 });
|
|
21555
|
+
if (summary.length > 1e3) throw new Errors.CLIError("--summary must be at most 1000 characters.", { exit: 2 });
|
|
21556
|
+
if (!flags.thread && !flags.email) throw new Errors.CLIError("Provide --thread <uuid> or --email <uuid>.", { exit: 2 });
|
|
21557
|
+
if (flags.detail !== void 0 && flags["detail-file"] !== void 0) throw new Errors.CLIError("Use either --detail or --detail-file, not both.", { exit: 2 });
|
|
21558
|
+
if (flags.data !== void 0 && flags["data-file"] !== void 0) throw new Errors.CLIError("Use either --data or --data-file, not both.", { exit: 2 });
|
|
21559
|
+
const threadId = flags.thread ? assertUuid(flags.thread, "--thread") : null;
|
|
21560
|
+
const emailId = flags.email ? assertUuid(flags.email, "--email") : null;
|
|
21561
|
+
const sentEmailId = flags["sent-email"] ? assertUuid(flags["sent-email"], "--sent-email") : void 0;
|
|
21562
|
+
if (flags.action && !ACTION_SLUG_RE.test(flags.action.trim())) throw new Errors.CLIError("--action must start with a lowercase letter or digit and use only a-z, 0-9, ., _, :, - (max 128 chars).", { exit: 2 });
|
|
21563
|
+
if (flags["idempotency-key"] && !IDEMPOTENCY_KEY_RE.test(flags["idempotency-key"].trim())) throw new Errors.CLIError("--idempotency-key must be 1 to 255 printable ASCII characters without spaces.", { exit: 2 });
|
|
21564
|
+
const detail = flags["detail-file"] ? readUtf8File(flags["detail-file"], "--detail-file") : flags.detail;
|
|
21565
|
+
if (detail !== void 0 && detail.length > 8e3) throw new Errors.CLIError("Detail must be at most 8000 characters.", { exit: 2 });
|
|
21566
|
+
const data = flags["data-file"] ? parseJsonObjectFlag(readUtf8File(flags["data-file"], "--data-file"), "--data-file") : flags.data ? parseJsonObjectFlag(flags.data, "--data") : void 0;
|
|
21567
|
+
const externalRef = buildExternalRef(flags);
|
|
21568
|
+
const runId = flags["run-id"]?.trim() ? validateActivityRunId(flags["run-id"], "--run-id") : void 0;
|
|
21569
|
+
const traceUrl = flags["trace-url"] ? assertHttpUrl(flags["trace-url"], "--trace-url") : void 0;
|
|
21570
|
+
const body = {
|
|
21571
|
+
summary,
|
|
21572
|
+
...flags.kind ? { kind: flags.kind } : {},
|
|
21573
|
+
...flags.action ? { action: flags.action.trim() } : {},
|
|
21574
|
+
...flags.status ? { status: flags.status } : {},
|
|
21575
|
+
...detail !== void 0 ? { detail } : {},
|
|
21576
|
+
...sentEmailId ? { sent_email_id: sentEmailId } : {},
|
|
21577
|
+
...externalRef ? { external_ref: externalRef } : {},
|
|
21578
|
+
...data ? { data } : {},
|
|
21579
|
+
...runId ? { run_id: runId } : {},
|
|
21580
|
+
...traceUrl ? { trace_url: traceUrl } : {},
|
|
21581
|
+
...flags["idempotency-key"] ? { idempotency_key: flags["idempotency-key"].trim() } : {},
|
|
21582
|
+
...flags.visibility ? { visibility: flags.visibility } : {}
|
|
21583
|
+
};
|
|
21584
|
+
const path = threadId ? `/threads/${threadId}/activities` : `/emails/${emailId}/activities`;
|
|
21585
|
+
if (threadId && emailId) body.email_id = emailId;
|
|
21586
|
+
await runWithTiming(flags.time === true, async () => {
|
|
21587
|
+
const result = await callActivityApi({
|
|
21588
|
+
configDir: this.config.configDir,
|
|
21589
|
+
apiKey: flags["api-key"],
|
|
21590
|
+
apiBaseUrl: flags["api-base-url"],
|
|
21591
|
+
method: "POST",
|
|
21592
|
+
path,
|
|
21593
|
+
body
|
|
21594
|
+
});
|
|
21595
|
+
if (flags.json) {
|
|
21596
|
+
this.log(JSON.stringify(result.data, null, 2));
|
|
21597
|
+
return;
|
|
21598
|
+
}
|
|
21599
|
+
const a = result.data.activity;
|
|
21600
|
+
const verb = result.data.updated ? "Updated" : "Logged";
|
|
21601
|
+
this.log(`${verb} activity ${a.id} (rev ${a.revision}) [${a.status}] ${a.action} on thread ${a.thread_id}`);
|
|
21602
|
+
this.log(`Summary: ${a.summary}`);
|
|
21603
|
+
});
|
|
21604
|
+
}
|
|
21605
|
+
};
|
|
21606
|
+
var ActivityUpdateCommand = class ActivityUpdateCommand extends Command {
|
|
21607
|
+
static summary = "Update an existing thread activity (preserves status history)";
|
|
21608
|
+
static examples = [`<%= config.bin %> activity update <activity-id> --thread <thread-id> --status succeeded --summary "Verified invoice in Brex"`];
|
|
21609
|
+
static args = { activity_id: Args.string({
|
|
21610
|
+
description: "Activity UUID to update",
|
|
21611
|
+
required: true
|
|
21612
|
+
}) };
|
|
21613
|
+
static flags = {
|
|
21614
|
+
thread: Flags.string({
|
|
21615
|
+
description: "Thread UUID owning this activity",
|
|
21616
|
+
required: true
|
|
21617
|
+
}),
|
|
21618
|
+
status: Flags.string({
|
|
21619
|
+
description: "New status: started, succeeded, failed, skipped, or needs_review",
|
|
21620
|
+
options: [...ACTIVITY_STATUSES]
|
|
21621
|
+
}),
|
|
21622
|
+
summary: Flags.string({
|
|
21623
|
+
char: "s",
|
|
21624
|
+
description: "Updated summary (1 to 1000 chars)"
|
|
21625
|
+
}),
|
|
21626
|
+
detail: Flags.string({ description: "Updated detail text (up to 8000 chars)" }),
|
|
21627
|
+
"detail-file": Flags.string({ description: "Read updated detail text from a file" }),
|
|
21628
|
+
"clear-detail": Flags.boolean({ description: "Clear stored detail text (sets null)" }),
|
|
21629
|
+
"ref-system": Flags.string({ description: "External system name" }),
|
|
21630
|
+
"ref-id": Flags.string({ description: "External record ID" }),
|
|
21631
|
+
"ref-url": Flags.string({ description: "External record https:// URL" }),
|
|
21632
|
+
"ref-label": Flags.string({ description: "External record label" }),
|
|
21633
|
+
"external-ref": Flags.string({ description: "External reference JSON object" }),
|
|
21634
|
+
"clear-external-ref": Flags.boolean({ description: "Clear external_ref (sets null)" }),
|
|
21635
|
+
data: Flags.string({ description: "Replacement structured metadata JSON object" }),
|
|
21636
|
+
"data-file": Flags.string({ description: "Read replacement metadata JSON object from a file" }),
|
|
21637
|
+
"run-id": Flags.string({ description: "Updated run correlation ID" }),
|
|
21638
|
+
"clear-run-id": Flags.boolean({ description: "Clear run_id (sets null)" }),
|
|
21639
|
+
"trace-url": Flags.string({ description: "Updated https:// trace URL" }),
|
|
21640
|
+
"clear-trace-url": Flags.boolean({ description: "Clear trace_url (sets null)" }),
|
|
21641
|
+
visibility: Flags.string({
|
|
21642
|
+
description: "Updated visibility: thread or actor_only",
|
|
21643
|
+
options: [...ACTIVITY_VISIBILITIES]
|
|
21644
|
+
}),
|
|
21645
|
+
...COMMON_API_FLAGS
|
|
21646
|
+
};
|
|
21647
|
+
async run() {
|
|
21648
|
+
const { args, flags } = await this.parse(ActivityUpdateCommand);
|
|
21649
|
+
const activityId = assertUuid(args.activity_id, "activity_id");
|
|
21650
|
+
const threadId = assertUuid(flags.thread, "--thread");
|
|
21651
|
+
const body = {};
|
|
21652
|
+
if (flags.status) body.status = flags.status;
|
|
21653
|
+
if (flags.summary !== void 0) {
|
|
21654
|
+
const trimmed = flags.summary.trim();
|
|
21655
|
+
if (!trimmed || trimmed.length > 1e3) throw new Errors.CLIError("--summary must be 1 to 1000 characters.", { exit: 2 });
|
|
21656
|
+
body.summary = trimmed;
|
|
21657
|
+
}
|
|
21658
|
+
if (flags["detail-file"] && flags.detail !== void 0) throw new Errors.CLIError("Use either --detail or --detail-file, not both.", { exit: 2 });
|
|
21659
|
+
if (flags["clear-detail"] && (flags.detail !== void 0 || flags["detail-file"] !== void 0)) throw new Errors.CLIError("--clear-detail cannot be combined with --detail or --detail-file.", { exit: 2 });
|
|
21660
|
+
if (flags["clear-detail"]) body.detail = null;
|
|
21661
|
+
else if (flags["detail-file"] || flags.detail !== void 0) {
|
|
21662
|
+
const detailText = flags["detail-file"] ? readUtf8File(flags["detail-file"], "--detail-file") : flags.detail ?? "";
|
|
21663
|
+
if (detailText.length > 8e3) throw new Errors.CLIError("Detail must be at most 8000 characters.", { exit: 2 });
|
|
21664
|
+
body.detail = detailText;
|
|
21665
|
+
}
|
|
21666
|
+
const hasExternalRefFlag = flags["external-ref"] !== void 0 || flags["ref-system"] !== void 0 || flags["ref-id"] !== void 0 || flags["ref-url"] !== void 0 || flags["ref-label"] !== void 0;
|
|
21667
|
+
if (flags["clear-external-ref"] && hasExternalRefFlag) throw new Errors.CLIError("--clear-external-ref cannot be combined with --external-ref or --ref-* flags.", { exit: 2 });
|
|
21668
|
+
if (flags["clear-external-ref"]) body.external_ref = null;
|
|
21669
|
+
else {
|
|
21670
|
+
const ref = buildExternalRef(flags);
|
|
21671
|
+
if (ref) body.external_ref = ref;
|
|
21672
|
+
}
|
|
21673
|
+
if (flags["data-file"] && flags.data !== void 0) throw new Errors.CLIError("Use either --data or --data-file, not both.", { exit: 2 });
|
|
21674
|
+
if (flags["data-file"]) body.data = parseJsonObjectFlag(readUtf8File(flags["data-file"], "--data-file"), "--data-file");
|
|
21675
|
+
else if (flags.data) body.data = parseJsonObjectFlag(flags.data, "--data");
|
|
21676
|
+
if (flags["clear-run-id"] && flags["run-id"] !== void 0) throw new Errors.CLIError("--clear-run-id cannot be combined with --run-id.", { exit: 2 });
|
|
21677
|
+
if (flags["clear-run-id"]) body.run_id = null;
|
|
21678
|
+
else if (flags["run-id"]) body.run_id = validateActivityRunId(flags["run-id"], "--run-id");
|
|
21679
|
+
if (flags["clear-trace-url"] && flags["trace-url"] !== void 0) throw new Errors.CLIError("--clear-trace-url cannot be combined with --trace-url.", { exit: 2 });
|
|
21680
|
+
if (flags["clear-trace-url"]) body.trace_url = null;
|
|
21681
|
+
else if (flags["trace-url"]) body.trace_url = assertHttpUrl(flags["trace-url"], "--trace-url");
|
|
21682
|
+
if (flags.visibility) body.visibility = flags.visibility;
|
|
21683
|
+
if (Object.keys(body).length === 0) throw new Errors.CLIError("Provide at least one field to update.", { exit: 2 });
|
|
21684
|
+
await runWithTiming(flags.time === true, async () => {
|
|
21685
|
+
const result = await callActivityApi({
|
|
21686
|
+
configDir: this.config.configDir,
|
|
21687
|
+
apiKey: flags["api-key"],
|
|
21688
|
+
apiBaseUrl: flags["api-base-url"],
|
|
21689
|
+
method: "PATCH",
|
|
21690
|
+
path: `/threads/${threadId}/activities/${activityId}`,
|
|
21691
|
+
body
|
|
21692
|
+
});
|
|
21693
|
+
if (flags.json) {
|
|
21694
|
+
this.log(JSON.stringify(result.data, null, 2));
|
|
21695
|
+
return;
|
|
21696
|
+
}
|
|
21697
|
+
const a = result.data.activity;
|
|
21698
|
+
this.log(`Updated activity ${a.id} (rev ${a.revision}) [${a.status}] ${a.action}: ${a.summary}`);
|
|
21699
|
+
});
|
|
21700
|
+
}
|
|
21701
|
+
};
|
|
21702
|
+
var ActivityTimelineCommand = class ActivityTimelineCommand extends Command {
|
|
21703
|
+
static summary = "Show the merged timeline of verified Primitive actions and agent work for a thread";
|
|
21704
|
+
static examples = ["<%= config.bin %> activity timeline <thread-id>", "<%= config.bin %> activity timeline <thread-id> --source agent --json"];
|
|
21705
|
+
static args = { thread_id: Args.string({
|
|
21706
|
+
description: "Thread UUID to inspect",
|
|
21707
|
+
required: true
|
|
21708
|
+
}) };
|
|
21709
|
+
static flags = {
|
|
21710
|
+
source: Flags.string({
|
|
21711
|
+
description: "Filter by source: all (default), primitive, or agent",
|
|
21712
|
+
options: [...TIMELINE_SOURCES],
|
|
21713
|
+
default: "all"
|
|
21714
|
+
}),
|
|
21715
|
+
kind: Flags.string({
|
|
21716
|
+
description: "Filter agent entries by kind: action, note, or handoff",
|
|
21717
|
+
options: [...ACTIVITY_KINDS]
|
|
21718
|
+
}),
|
|
21719
|
+
status: Flags.string({ description: "Comma-separated status filter (for example failed,needs_review)" }),
|
|
21720
|
+
attention: Flags.boolean({ description: "Limit to failed and needs_review agent activities" }),
|
|
21721
|
+
action: Flags.string({ description: "Exact action name filter" }),
|
|
21722
|
+
"actor-ownership": Flags.string({
|
|
21723
|
+
description: "Filter by actor ownership class",
|
|
21724
|
+
options: [...ACTIVITY_OWNERSHIPS]
|
|
21725
|
+
}),
|
|
21726
|
+
"actor-id": Flags.string({ description: "Filter by specific actor UUID" }),
|
|
21727
|
+
"run-id": Flags.string({ description: "Filter by run_id" }),
|
|
21728
|
+
"include-private": Flags.boolean({ description: "Include other actors' actor_only rows (requires activity:read)" }),
|
|
21729
|
+
order: Flags.string({
|
|
21730
|
+
description: "Sort order: desc (default) or asc",
|
|
21731
|
+
options: ["desc", "asc"],
|
|
21732
|
+
default: "desc"
|
|
21733
|
+
}),
|
|
21734
|
+
limit: Flags.integer({
|
|
21735
|
+
description: "Items per page (1 to 200)",
|
|
21736
|
+
min: 1,
|
|
21737
|
+
max: 200,
|
|
21738
|
+
default: 50
|
|
21739
|
+
}),
|
|
21740
|
+
cursor: Flags.string({ description: "Pagination cursor from a previous response" }),
|
|
21741
|
+
...COMMON_API_FLAGS
|
|
21742
|
+
};
|
|
21743
|
+
async run() {
|
|
21744
|
+
const { args, flags } = await this.parse(ActivityTimelineCommand);
|
|
21745
|
+
const threadId = assertUuid(args.thread_id, "thread_id");
|
|
21746
|
+
const status = flags.status ? validateStatusCsv(flags.status) : void 0;
|
|
21747
|
+
const actorId = flags["actor-id"] ? assertUuid(flags["actor-id"], "--actor-id") : void 0;
|
|
21748
|
+
await runWithTiming(flags.time === true, async () => {
|
|
21749
|
+
const result = await callActivityApi({
|
|
21750
|
+
configDir: this.config.configDir,
|
|
21751
|
+
apiKey: flags["api-key"],
|
|
21752
|
+
apiBaseUrl: flags["api-base-url"],
|
|
21753
|
+
method: "GET",
|
|
21754
|
+
path: `/threads/${threadId}/timeline`,
|
|
21755
|
+
query: {
|
|
21756
|
+
source: flags.source,
|
|
21757
|
+
kind: flags.kind,
|
|
21758
|
+
status,
|
|
21759
|
+
attention: flags.attention ? "true" : void 0,
|
|
21760
|
+
action: flags.action,
|
|
21761
|
+
actor_ownership: flags["actor-ownership"],
|
|
21762
|
+
actor_id: actorId,
|
|
21763
|
+
run_id: flags["run-id"],
|
|
21764
|
+
include_private: flags["include-private"] ? "true" : void 0,
|
|
21765
|
+
order: flags.order,
|
|
21766
|
+
limit: flags.limit,
|
|
21767
|
+
cursor: flags.cursor
|
|
21768
|
+
}
|
|
21769
|
+
});
|
|
21770
|
+
if (flags.json) {
|
|
21771
|
+
this.log(JSON.stringify(result.data, null, 2));
|
|
21772
|
+
return;
|
|
21773
|
+
}
|
|
21774
|
+
if (result.data.items.length === 0) {
|
|
21775
|
+
this.log(`No activity recorded for thread ${threadId}.`);
|
|
21776
|
+
return;
|
|
21777
|
+
}
|
|
21778
|
+
for (const item of result.data.items) this.log(formatTimelineItemLine(item));
|
|
21779
|
+
if (result.data.next_cursor) process.stderr.write(`Next page: --cursor ${result.data.next_cursor}\n`);
|
|
21780
|
+
});
|
|
21781
|
+
}
|
|
21782
|
+
};
|
|
21783
|
+
var ActivityListCommand = class ActivityListCommand extends Command {
|
|
21784
|
+
static summary = "Search verified mail actions and agent work across threads in your scope";
|
|
21785
|
+
static examples = [
|
|
21786
|
+
"<%= config.bin %> activity list --attention",
|
|
21787
|
+
"<%= config.bin %> activity list --actor-ownership personal_agent --limit 25",
|
|
21788
|
+
"<%= config.bin %> activity list --run-id run_123 --json",
|
|
21789
|
+
"<%= config.bin %> activity list --format csv > mail-activity.csv"
|
|
21790
|
+
];
|
|
21791
|
+
static flags = {
|
|
21792
|
+
source: Flags.string({
|
|
21793
|
+
description: "Filter by source: all (default), primitive, or agent",
|
|
21794
|
+
options: [...TIMELINE_SOURCES],
|
|
21795
|
+
default: "all"
|
|
21796
|
+
}),
|
|
21797
|
+
thread: Flags.string({ description: "Filter to a thread UUID" }),
|
|
21798
|
+
email: Flags.string({ description: "Filter to an inbound email UUID" }),
|
|
21799
|
+
"sent-email": Flags.string({ description: "Filter to an outbound email UUID" }),
|
|
21800
|
+
kind: Flags.string({
|
|
21801
|
+
description: "Filter agent entries by kind: action, note, or handoff",
|
|
21802
|
+
options: [...ACTIVITY_KINDS]
|
|
21803
|
+
}),
|
|
21804
|
+
status: Flags.string({ description: "Comma-separated status filter" }),
|
|
21805
|
+
attention: Flags.boolean({ description: "Limit to failed and needs_review agent activities" }),
|
|
21806
|
+
action: Flags.string({ description: "Exact action name filter" }),
|
|
21807
|
+
"actor-kind": Flags.string({ description: "Filter by actor kind" }),
|
|
21808
|
+
"actor-ownership": Flags.string({
|
|
21809
|
+
description: "Filter by actor ownership class",
|
|
21810
|
+
options: [...ACTIVITY_OWNERSHIPS]
|
|
21811
|
+
}),
|
|
21812
|
+
"actor-id": Flags.string({ description: "Filter by actor UUID" }),
|
|
21813
|
+
"owner-user-id": Flags.string({ description: "Filter by human owner user UUID" }),
|
|
21814
|
+
"oauth-client-id": Flags.string({ description: "Filter by OAuth client ID" }),
|
|
21815
|
+
"run-id": Flags.string({ description: "Filter by run_id" }),
|
|
21816
|
+
"include-private": Flags.boolean({ description: "Include other actors' actor_only rows (requires activity:read)" }),
|
|
21817
|
+
since: Flags.string({ description: "ISO-8601 lower bound timestamp" }),
|
|
21818
|
+
until: Flags.string({ description: "ISO-8601 upper bound timestamp" }),
|
|
21819
|
+
format: Flags.string({
|
|
21820
|
+
description: "Output format: json (default) or csv",
|
|
21821
|
+
options: ["json", "csv"],
|
|
21822
|
+
default: "json"
|
|
21823
|
+
}),
|
|
21824
|
+
limit: Flags.integer({
|
|
21825
|
+
description: "Items per page (1 to 200)",
|
|
21826
|
+
min: 1,
|
|
21827
|
+
max: 200,
|
|
21828
|
+
default: 50
|
|
21829
|
+
}),
|
|
21830
|
+
cursor: Flags.string({ description: "Pagination cursor" }),
|
|
21831
|
+
...COMMON_API_FLAGS
|
|
21832
|
+
};
|
|
21833
|
+
async run() {
|
|
21834
|
+
const { flags } = await this.parse(ActivityListCommand);
|
|
21835
|
+
if (flags.format === "csv" && flags.json) throw new Errors.CLIError("Cannot combine --format csv with --json.", { exit: 2 });
|
|
21836
|
+
const status = flags.status ? validateStatusCsv(flags.status) : void 0;
|
|
21837
|
+
const query = {
|
|
21838
|
+
source: flags.source,
|
|
21839
|
+
thread_id: flags.thread ? assertUuid(flags.thread, "--thread") : void 0,
|
|
21840
|
+
email_id: flags.email ? assertUuid(flags.email, "--email") : void 0,
|
|
21841
|
+
sent_email_id: flags["sent-email"] ? assertUuid(flags["sent-email"], "--sent-email") : void 0,
|
|
21842
|
+
kind: flags.kind,
|
|
21843
|
+
status,
|
|
21844
|
+
attention: flags.attention ? "true" : void 0,
|
|
21845
|
+
action: flags.action,
|
|
21846
|
+
actor_kind: flags["actor-kind"],
|
|
21847
|
+
actor_ownership: flags["actor-ownership"],
|
|
21848
|
+
actor_id: flags["actor-id"] ? assertUuid(flags["actor-id"], "--actor-id") : void 0,
|
|
21849
|
+
owner_user_id: flags["owner-user-id"] ? assertUuid(flags["owner-user-id"], "--owner-user-id") : void 0,
|
|
21850
|
+
oauth_client_id: flags["oauth-client-id"],
|
|
21851
|
+
run_id: flags["run-id"],
|
|
21852
|
+
include_private: flags["include-private"] ? "true" : void 0,
|
|
21853
|
+
since: flags.since,
|
|
21854
|
+
until: flags.until,
|
|
21855
|
+
format: flags.format,
|
|
21856
|
+
limit: flags.limit,
|
|
21857
|
+
cursor: flags.cursor
|
|
21858
|
+
};
|
|
21859
|
+
await runWithTiming(flags.time === true, async () => {
|
|
21860
|
+
if (flags.format === "csv") {
|
|
21861
|
+
const result = await callActivityApi({
|
|
21862
|
+
configDir: this.config.configDir,
|
|
21863
|
+
apiKey: flags["api-key"],
|
|
21864
|
+
apiBaseUrl: flags["api-base-url"],
|
|
21865
|
+
method: "GET",
|
|
21866
|
+
path: "/activity/mail",
|
|
21867
|
+
query,
|
|
21868
|
+
rawText: true
|
|
21869
|
+
});
|
|
21870
|
+
process.stdout.write(result.text ?? "");
|
|
21871
|
+
const nextCursor = result.headers.get("x-next-cursor");
|
|
21872
|
+
if (nextCursor) process.stderr.write(`Next page: --cursor ${nextCursor}\n`);
|
|
21873
|
+
return;
|
|
21874
|
+
}
|
|
21875
|
+
const result = await callActivityApi({
|
|
21876
|
+
configDir: this.config.configDir,
|
|
21877
|
+
apiKey: flags["api-key"],
|
|
21878
|
+
apiBaseUrl: flags["api-base-url"],
|
|
21879
|
+
method: "GET",
|
|
21880
|
+
path: "/activity/mail",
|
|
21881
|
+
query
|
|
21882
|
+
});
|
|
21883
|
+
if (flags.json) {
|
|
21884
|
+
this.log(JSON.stringify(result.data, null, 2));
|
|
21885
|
+
return;
|
|
21886
|
+
}
|
|
21887
|
+
if (result.data.items.length === 0) {
|
|
21888
|
+
this.log("No mail activity matched these filters within your scope.");
|
|
21889
|
+
return;
|
|
21890
|
+
}
|
|
21891
|
+
for (const item of result.data.items) this.log(formatTimelineItemLine(item));
|
|
21892
|
+
if (result.data.next_cursor) process.stderr.write(`Next page: --cursor ${result.data.next_cursor}\n`);
|
|
21893
|
+
});
|
|
21894
|
+
}
|
|
21895
|
+
};
|
|
21896
|
+
var ActivityAgentsCommand = class ActivityAgentsCommand extends Command {
|
|
21897
|
+
static summary = "List deployed agents, keys, Functions, and apps with mail activity rollups";
|
|
21898
|
+
static examples = ["<%= config.bin %> activity agents", "<%= config.bin %> activity agents --actor-ownership personal_agent --json"];
|
|
21899
|
+
static flags = {
|
|
21900
|
+
"actor-ownership": Flags.string({
|
|
21901
|
+
description: "Filter by actor ownership class",
|
|
21902
|
+
options: [...ACTIVITY_OWNERSHIPS]
|
|
21903
|
+
}),
|
|
21904
|
+
"owner-user-id": Flags.string({ description: "Filter by human owner user UUID" }),
|
|
21905
|
+
"include-private": Flags.boolean({ description: "Include other actors' actor_only work (requires activity:read)" }),
|
|
21906
|
+
since: Flags.string({ description: "ISO-8601 lower bound timestamp" }),
|
|
21907
|
+
until: Flags.string({ description: "ISO-8601 upper bound timestamp" }),
|
|
21908
|
+
limit: Flags.integer({
|
|
21909
|
+
description: "Maximum actors to return (1 to 100)",
|
|
21910
|
+
min: 1,
|
|
21911
|
+
max: 100,
|
|
21912
|
+
default: 50
|
|
21913
|
+
}),
|
|
21914
|
+
...COMMON_API_FLAGS
|
|
21915
|
+
};
|
|
21916
|
+
async run() {
|
|
21917
|
+
const { flags } = await this.parse(ActivityAgentsCommand);
|
|
21918
|
+
const ownerUserId = flags["owner-user-id"] ? assertUuid(flags["owner-user-id"], "--owner-user-id") : void 0;
|
|
21919
|
+
await runWithTiming(flags.time === true, async () => {
|
|
21920
|
+
const result = await callActivityApi({
|
|
21921
|
+
configDir: this.config.configDir,
|
|
21922
|
+
apiKey: flags["api-key"],
|
|
21923
|
+
apiBaseUrl: flags["api-base-url"],
|
|
21924
|
+
method: "GET",
|
|
21925
|
+
path: "/activity/mail/actors",
|
|
21926
|
+
query: {
|
|
21927
|
+
actor_ownership: flags["actor-ownership"],
|
|
21928
|
+
owner_user_id: ownerUserId,
|
|
21929
|
+
include_private: flags["include-private"] ? "true" : void 0,
|
|
21930
|
+
since: flags.since,
|
|
21931
|
+
until: flags.until,
|
|
21932
|
+
limit: flags.limit
|
|
21933
|
+
}
|
|
21934
|
+
});
|
|
21935
|
+
if (flags.json) {
|
|
21936
|
+
this.log(JSON.stringify(result.data, null, 2));
|
|
21937
|
+
return;
|
|
21938
|
+
}
|
|
21939
|
+
if (result.data.actors.length === 0) {
|
|
21940
|
+
this.log("No agents or keys have recorded mail activity in your scope.");
|
|
21941
|
+
return;
|
|
21942
|
+
}
|
|
21943
|
+
for (const entry of result.data.actors) {
|
|
21944
|
+
const who = formatActorLabel(entry.actor);
|
|
21945
|
+
const rollup = `threads=${entry.threads_touched} verified=${entry.verified_events} work=${entry.work_total} (ok=${entry.work_succeeded} fail=${entry.work_failed} review=${entry.work_needs_review})`;
|
|
21946
|
+
const actions = entry.recent_actions.length > 0 ? ` | actions: ${entry.recent_actions.join(", ")}` : "";
|
|
21947
|
+
this.log(`${who} | ${rollup} | last=${entry.last_active_at}${actions}`);
|
|
21948
|
+
}
|
|
21949
|
+
});
|
|
21950
|
+
}
|
|
21951
|
+
};
|
|
21195
21952
|
// src/oclif/commands/memories.ts
|
|
21196
21953
|
var MemoryCliInputError = class extends Error {};
|
|
21197
21954
|
const API_KEY_FLAG = Flags.string({
|
|
@@ -25518,6 +26275,566 @@ var OtpResendCommand = class extends SigninOtpResendCommand {
|
|
|
25518
26275
|
return OTP_COPY;
|
|
25519
26276
|
}
|
|
25520
26277
|
};
|
|
26278
|
+
// src/oclif/skill-installer.ts
|
|
26279
|
+
const DEFAULT_LIVE_SKILL_NAME = "primitive";
|
|
26280
|
+
const SKILL_META_FILENAME = ".primitive-skill.json";
|
|
26281
|
+
const SKILL_ETAG_RE = /^[A-Za-z0-9._-]{1,128}$/;
|
|
26282
|
+
const MAX_SKILL_BYTES = 2097152;
|
|
26283
|
+
const MAX_META_BYTES = 65536;
|
|
26284
|
+
const SKILL_TARGETS = [
|
|
26285
|
+
"claude",
|
|
26286
|
+
"codex",
|
|
26287
|
+
"antigravity",
|
|
26288
|
+
"cursor",
|
|
26289
|
+
"openclaw",
|
|
26290
|
+
"agents"
|
|
26291
|
+
];
|
|
26292
|
+
const SKILL_NAME_RE = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
|
26293
|
+
function validateSkillName(raw) {
|
|
26294
|
+
const trimmed = raw.trim().toLowerCase();
|
|
26295
|
+
if (!SKILL_NAME_RE.test(trimmed)) throw new Errors.CLIError("--name must be 1 to 63 lowercase letters, digits, or hyphens (starting with a letter or digit).", { exit: 2 });
|
|
26296
|
+
if (trimmed === "primitive-connect") throw new Errors.CLIError(`--name cannot be "${CONNECT_SKILL_NAME}", which is reserved for the bundled connection skill.`, { exit: 2 });
|
|
26297
|
+
return trimmed;
|
|
26298
|
+
}
|
|
26299
|
+
function userHome(env) {
|
|
26300
|
+
return env.HOME?.trim() || homedir();
|
|
26301
|
+
}
|
|
26302
|
+
function targetRootDir(target, options) {
|
|
26303
|
+
const home = userHome(options.env);
|
|
26304
|
+
if (options.project) switch (target) {
|
|
26305
|
+
case "claude": return join(options.cwd, ".claude", "skills");
|
|
26306
|
+
case "cursor": return join(options.cwd, ".cursor", "skills");
|
|
26307
|
+
case "openclaw": return join(options.cwd, "skills");
|
|
26308
|
+
case "codex":
|
|
26309
|
+
case "antigravity":
|
|
26310
|
+
case "agents": return join(options.cwd, ".agents", "skills");
|
|
26311
|
+
}
|
|
26312
|
+
switch (target) {
|
|
26313
|
+
case "claude": return join(resolve(options.env.CLAUDE_CONFIG_DIR || join(home, ".claude")), "skills");
|
|
26314
|
+
case "codex": return join(resolve(options.env.CODEX_HOME || join(home, ".codex")), "skills");
|
|
26315
|
+
case "antigravity": return join(home, ".gemini", "config", "skills");
|
|
26316
|
+
case "cursor": return join(home, ".cursor", "skills");
|
|
26317
|
+
case "openclaw": return join(home, ".openclaw", "skills");
|
|
26318
|
+
case "agents": return join(home, ".agents", "skills");
|
|
26319
|
+
}
|
|
26320
|
+
}
|
|
26321
|
+
function detectSkillTargets(options) {
|
|
26322
|
+
const env = options.env ?? process.env;
|
|
26323
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
26324
|
+
const home = userHome(env);
|
|
26325
|
+
const found = [];
|
|
26326
|
+
if (options.project) {
|
|
26327
|
+
found.push("agents");
|
|
26328
|
+
if (existsSync(join(cwd, ".claude"))) found.push("claude");
|
|
26329
|
+
if (existsSync(join(cwd, ".cursor"))) found.push("cursor");
|
|
26330
|
+
return found;
|
|
26331
|
+
}
|
|
26332
|
+
if (env.CLAUDE_CODE_SESSION_ID || existsSync(resolve(env.CLAUDE_CONFIG_DIR || join(home, ".claude")))) found.push("claude");
|
|
26333
|
+
if (env.CODEX_THREAD_ID || env.CODEX_SESSION_ID || existsSync(resolve(env.CODEX_HOME || join(home, ".codex")))) found.push("codex");
|
|
26334
|
+
if (existsSync(join(home, ".gemini", "config"))) found.push("antigravity");
|
|
26335
|
+
if (existsSync(join(home, ".cursor"))) found.push("cursor");
|
|
26336
|
+
if (existsSync(join(home, ".openclaw"))) found.push("openclaw");
|
|
26337
|
+
if (found.length === 0 || existsSync(join(home, ".agents"))) found.push("agents");
|
|
26338
|
+
return found;
|
|
26339
|
+
}
|
|
26340
|
+
function parseTargetSelectors(rawTargets) {
|
|
26341
|
+
if (!rawTargets || rawTargets.length === 0) return ["auto"];
|
|
26342
|
+
const valid = /* @__PURE__ */ new Set([
|
|
26343
|
+
...SKILL_TARGETS,
|
|
26344
|
+
"auto",
|
|
26345
|
+
"all"
|
|
26346
|
+
]);
|
|
26347
|
+
const out = [];
|
|
26348
|
+
for (const item of rawTargets) for (const part of item.split(",")) {
|
|
26349
|
+
const normalized = part.trim().toLowerCase();
|
|
26350
|
+
if (!normalized) continue;
|
|
26351
|
+
if (!valid.has(normalized)) throw new Errors.CLIError(`Unknown --target "${part.trim()}". Use one of: auto, all, ${SKILL_TARGETS.join(", ")}.`, { exit: 2 });
|
|
26352
|
+
out.push(normalized);
|
|
26353
|
+
}
|
|
26354
|
+
return out.length > 0 ? out : ["auto"];
|
|
26355
|
+
}
|
|
26356
|
+
function resolveSkillTargets(options) {
|
|
26357
|
+
const env = options.env ?? process.env;
|
|
26358
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
26359
|
+
const project = Boolean(options.project);
|
|
26360
|
+
const name = validateSkillName(options.name ?? "primitive");
|
|
26361
|
+
if (options.out !== void 0) {
|
|
26362
|
+
if (!options.out.trim()) throw new Errors.CLIError("--out must be a non-empty path.", { exit: 2 });
|
|
26363
|
+
const resolvedOut = resolve(cwd, options.out);
|
|
26364
|
+
const isFilePath = basename(resolvedOut).toLowerCase() === "skill.md";
|
|
26365
|
+
const directory = isFilePath ? dirname(resolvedOut) : resolvedOut;
|
|
26366
|
+
if (basename(directory).toLowerCase() === "primitive-connect") throw new Errors.CLIError(`Refusing to write into "${CONNECT_SKILL_NAME}", which is reserved for the bundled connection skill.`, { exit: 2 });
|
|
26367
|
+
const filePath = isFilePath ? resolvedOut : join(resolvedOut, "SKILL.md");
|
|
26368
|
+
const home = resolve(userHome(env));
|
|
26369
|
+
const boundary = isSubpath(cwd, directory) ? cwd : isSubpath(home, directory) ? home : dirname(directory);
|
|
26370
|
+
return [{
|
|
26371
|
+
target: "custom",
|
|
26372
|
+
directory,
|
|
26373
|
+
filePath,
|
|
26374
|
+
metaPath: join(directory, SKILL_META_FILENAME),
|
|
26375
|
+
boundary
|
|
26376
|
+
}];
|
|
26377
|
+
}
|
|
26378
|
+
const selectors = parseTargetSelectors(options.targets);
|
|
26379
|
+
const expanded = [];
|
|
26380
|
+
for (const selector of selectors) if (selector === "auto") expanded.push(...detectSkillTargets({
|
|
26381
|
+
project,
|
|
26382
|
+
cwd,
|
|
26383
|
+
env
|
|
26384
|
+
}));
|
|
26385
|
+
else if (selector === "all") expanded.push(...SKILL_TARGETS);
|
|
26386
|
+
else expanded.push(selector);
|
|
26387
|
+
const home = resolve(userHome(env));
|
|
26388
|
+
const deduped = [];
|
|
26389
|
+
const seenDirs = /* @__PURE__ */ new Set();
|
|
26390
|
+
for (const target of expanded) {
|
|
26391
|
+
const rootDir = targetRootDir(target, {
|
|
26392
|
+
project,
|
|
26393
|
+
cwd,
|
|
26394
|
+
env
|
|
26395
|
+
});
|
|
26396
|
+
const directory = join(rootDir, name);
|
|
26397
|
+
if (seenDirs.has(directory)) continue;
|
|
26398
|
+
seenDirs.add(directory);
|
|
26399
|
+
const boundary = project ? cwd : isSubpath(home, directory) ? home : dirname(rootDir);
|
|
26400
|
+
deduped.push({
|
|
26401
|
+
target,
|
|
26402
|
+
directory,
|
|
26403
|
+
filePath: join(directory, "SKILL.md"),
|
|
26404
|
+
metaPath: join(directory, SKILL_META_FILENAME),
|
|
26405
|
+
boundary
|
|
26406
|
+
});
|
|
26407
|
+
}
|
|
26408
|
+
return deduped;
|
|
26409
|
+
}
|
|
26410
|
+
function isSubpath(parent, child) {
|
|
26411
|
+
const rel = relative(parent, child);
|
|
26412
|
+
return rel !== "" && !rel.startsWith("..") && !rel.includes(`..${sep}`);
|
|
26413
|
+
}
|
|
26414
|
+
function sha256Text(content) {
|
|
26415
|
+
return createHash("sha256").update(content, "utf8").digest("hex");
|
|
26416
|
+
}
|
|
26417
|
+
function assertNoSymlinkAncestors(targetDir, boundary) {
|
|
26418
|
+
const resolvedDir = resolve(targetDir);
|
|
26419
|
+
const start = boundary && isSubpath(resolve(boundary), resolvedDir) ? resolve(boundary) : dirname(resolvedDir);
|
|
26420
|
+
const rel = relative(start, resolvedDir);
|
|
26421
|
+
const segments = rel ? rel.split(sep).filter(Boolean) : [];
|
|
26422
|
+
let current = start;
|
|
26423
|
+
const checkPoints = segments.length > 0 ? segments : [""];
|
|
26424
|
+
for (const segment of checkPoints) {
|
|
26425
|
+
current = segment ? join(current, segment) : resolvedDir;
|
|
26426
|
+
try {
|
|
26427
|
+
const stat = lstatSync(current);
|
|
26428
|
+
if (stat.isSymbolicLink()) throw new Errors.CLIError(`Refusing to traverse symbolic link: ${current}`, { exit: 1 });
|
|
26429
|
+
if (!stat.isDirectory()) throw new Errors.CLIError(`Expected directory at ${current}, found a non-directory entry.`, { exit: 1 });
|
|
26430
|
+
} catch (error) {
|
|
26431
|
+
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") break;
|
|
26432
|
+
throw error;
|
|
26433
|
+
}
|
|
26434
|
+
}
|
|
26435
|
+
}
|
|
26436
|
+
function assertRegularFileOrMissing(filePath) {
|
|
26437
|
+
try {
|
|
26438
|
+
const stat = lstatSync(filePath);
|
|
26439
|
+
if (stat.isSymbolicLink()) throw new Errors.CLIError(`Refusing to write through symbolic link: ${filePath}`, { exit: 1 });
|
|
26440
|
+
if (!stat.isFile()) throw new Errors.CLIError(`Refusing to overwrite non-regular file: ${filePath}`, { exit: 1 });
|
|
26441
|
+
} catch (error) {
|
|
26442
|
+
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return;
|
|
26443
|
+
throw error;
|
|
26444
|
+
}
|
|
26445
|
+
}
|
|
26446
|
+
function hasConnectFrontmatter(content) {
|
|
26447
|
+
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
26448
|
+
if (!match) return false;
|
|
26449
|
+
return /^name:\s*["']?primitive-connect["']?\s*$/im.test(match[1] ?? "");
|
|
26450
|
+
}
|
|
26451
|
+
function isSkillFilePresent(target) {
|
|
26452
|
+
try {
|
|
26453
|
+
assertNoSymlinkAncestors(target.directory, target.boundary);
|
|
26454
|
+
const stat = lstatSync(target.filePath);
|
|
26455
|
+
return !stat.isSymbolicLink() && stat.isFile();
|
|
26456
|
+
} catch {
|
|
26457
|
+
return false;
|
|
26458
|
+
}
|
|
26459
|
+
}
|
|
26460
|
+
function readInstalledSkillMeta(target) {
|
|
26461
|
+
try {
|
|
26462
|
+
assertNoSymlinkAncestors(target.directory, target.boundary);
|
|
26463
|
+
const dirStat = lstatSync(target.directory);
|
|
26464
|
+
if (dirStat.isSymbolicLink() || !dirStat.isDirectory()) return null;
|
|
26465
|
+
const fileStat = lstatSync(target.filePath);
|
|
26466
|
+
if (fileStat.isSymbolicLink() || !fileStat.isFile() || fileStat.size > MAX_SKILL_BYTES) return null;
|
|
26467
|
+
const metaStat = lstatSync(target.metaPath);
|
|
26468
|
+
if (metaStat.isSymbolicLink() || !metaStat.isFile() || metaStat.size > MAX_META_BYTES) return null;
|
|
26469
|
+
const raw = JSON.parse(readFileSync(target.metaPath, "utf8"));
|
|
26470
|
+
if (typeof raw.etag !== "string" || !SKILL_ETAG_RE.test(raw.etag) || typeof raw.sha256 !== "string" || typeof raw.name !== "string") return null;
|
|
26471
|
+
if (sha256Text(readFileSync(target.filePath, "utf8")) !== raw.sha256) return null;
|
|
26472
|
+
return {
|
|
26473
|
+
name: raw.name,
|
|
26474
|
+
version: typeof raw.version === "string" ? raw.version : "1",
|
|
26475
|
+
etag: raw.etag,
|
|
26476
|
+
sha256: raw.sha256,
|
|
26477
|
+
api_base_url: typeof raw.api_base_url === "string" ? raw.api_base_url : "",
|
|
26478
|
+
org_id: typeof raw.org_id === "string" ? raw.org_id : "",
|
|
26479
|
+
auth_method: typeof raw.auth_method === "string" ? raw.auth_method : null,
|
|
26480
|
+
installed_at: typeof raw.installed_at === "string" ? raw.installed_at : ""
|
|
26481
|
+
};
|
|
26482
|
+
} catch {
|
|
26483
|
+
return null;
|
|
26484
|
+
}
|
|
26485
|
+
}
|
|
26486
|
+
function writeFileAtomically(filePath, content, boundary) {
|
|
26487
|
+
const parent = dirname(filePath);
|
|
26488
|
+
assertNoSymlinkAncestors(parent, boundary);
|
|
26489
|
+
mkdirSync(parent, {
|
|
26490
|
+
recursive: true,
|
|
26491
|
+
mode: 448
|
|
26492
|
+
});
|
|
26493
|
+
assertNoSymlinkAncestors(parent, boundary);
|
|
26494
|
+
assertRegularFileOrMissing(filePath);
|
|
26495
|
+
const tempPath = join(parent, `.tmp-${basename(filePath)}-${randomUUID()}`);
|
|
26496
|
+
try {
|
|
26497
|
+
writeFileSync(tempPath, content, {
|
|
26498
|
+
encoding: "utf8",
|
|
26499
|
+
mode: 384,
|
|
26500
|
+
flag: "wx"
|
|
26501
|
+
});
|
|
26502
|
+
renameSync(tempPath, filePath);
|
|
26503
|
+
} catch (error) {
|
|
26504
|
+
rmSync(tempPath, { force: true });
|
|
26505
|
+
throw error;
|
|
26506
|
+
}
|
|
26507
|
+
}
|
|
26508
|
+
function installSkillToTarget(target, payload, options = {}) {
|
|
26509
|
+
assertNoSymlinkAncestors(target.directory, target.boundary);
|
|
26510
|
+
assertRegularFileOrMissing(target.filePath);
|
|
26511
|
+
assertRegularFileOrMissing(target.metaPath);
|
|
26512
|
+
const hadFile = isSkillFilePresent(target);
|
|
26513
|
+
if (hadFile) {
|
|
26514
|
+
if (hasConnectFrontmatter(readFileSync(target.filePath, "utf8"))) throw new Errors.CLIError(`Refusing to overwrite bundled "${CONNECT_SKILL_NAME}" skill at ${target.filePath}.`, { exit: 2 });
|
|
26515
|
+
}
|
|
26516
|
+
const existing = readInstalledSkillMeta(target);
|
|
26517
|
+
const sha256 = sha256Text(payload.markdown);
|
|
26518
|
+
if (!options.force && existing && existing.etag === payload.etag && existing.sha256 === sha256) return {
|
|
26519
|
+
state: "unchanged",
|
|
26520
|
+
previousEtag: existing.etag
|
|
26521
|
+
};
|
|
26522
|
+
const meta = {
|
|
26523
|
+
name: validateSkillName(payload.name),
|
|
26524
|
+
version: payload.version,
|
|
26525
|
+
etag: payload.etag,
|
|
26526
|
+
sha256,
|
|
26527
|
+
api_base_url: payload.apiBaseUrl,
|
|
26528
|
+
org_id: payload.orgId,
|
|
26529
|
+
auth_method: payload.authMethod,
|
|
26530
|
+
installed_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
26531
|
+
};
|
|
26532
|
+
writeFileAtomically(target.filePath, payload.markdown, target.boundary);
|
|
26533
|
+
writeFileAtomically(target.metaPath, `${JSON.stringify(meta, null, 2)}\n`, target.boundary);
|
|
26534
|
+
return {
|
|
26535
|
+
state: existing || hadFile ? "updated" : "installed",
|
|
26536
|
+
previousEtag: existing?.etag ?? null
|
|
26537
|
+
};
|
|
26538
|
+
}
|
|
26539
|
+
// src/oclif/commands/skill.ts
|
|
26540
|
+
async function fetchCliSkill(options) {
|
|
26541
|
+
const authenticated = await createAuthenticatedCliApiClient({
|
|
26542
|
+
configDir: options.configDir,
|
|
26543
|
+
apiKey: options.apiKey,
|
|
26544
|
+
apiBaseUrl: options.apiBaseUrl
|
|
26545
|
+
});
|
|
26546
|
+
if (!authenticated.auth.apiKey) throw new Errors.CLIError("No Primitive credential is active. Connect with `primitive connect <url>`, set PRIMITIVE_API_KEY, or run `primitive signin`.", { exit: 1 });
|
|
26547
|
+
const headers = mergeHeadersCaseInsensitive(authenticated.auth.agentPass || authenticated.auth.connectedAgent ? void 0 : authenticated.requestConfig.headers, cliActivityHeadersFromEnv(), {
|
|
26548
|
+
accept: "application/json",
|
|
26549
|
+
authorization: `Bearer ${authenticated.auth.apiKey}`,
|
|
26550
|
+
...options.ifNoneMatch && SKILL_ETAG_RE.test(options.ifNoneMatch) ? { "if-none-match": `"${options.ifNoneMatch}"` } : {}
|
|
26551
|
+
}) ?? {};
|
|
26552
|
+
const baseUrl = authenticated.auth.apiBaseUrl.replace(/\/+$/, "");
|
|
26553
|
+
let response;
|
|
26554
|
+
try {
|
|
26555
|
+
response = await fetch(`${baseUrl}/cli/skill`, {
|
|
26556
|
+
method: "GET",
|
|
26557
|
+
headers,
|
|
26558
|
+
redirect: "manual",
|
|
26559
|
+
signal: AbortSignal.timeout(3e4)
|
|
26560
|
+
});
|
|
26561
|
+
} catch (error) {
|
|
26562
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
26563
|
+
throw new Errors.CLIError(`Could not fetch Primitive skill: ${detail}`, { exit: 1 });
|
|
26564
|
+
}
|
|
26565
|
+
if (response.status === 304) {
|
|
26566
|
+
const rawEtag = response.headers.get("etag");
|
|
26567
|
+
return {
|
|
26568
|
+
status: "not_modified",
|
|
26569
|
+
etag: rawEtag ? rawEtag.replace(/^W\//i, "").replace(/^"(.*)"$/, "$1") : options.ifNoneMatch ?? null,
|
|
26570
|
+
apiBaseUrl: baseUrl
|
|
26571
|
+
};
|
|
26572
|
+
}
|
|
26573
|
+
const rawBody = await response.text();
|
|
26574
|
+
let parsed;
|
|
26575
|
+
try {
|
|
26576
|
+
parsed = rawBody ? JSON.parse(rawBody) : null;
|
|
26577
|
+
} catch {
|
|
26578
|
+
parsed = null;
|
|
26579
|
+
}
|
|
26580
|
+
if (!response.ok) {
|
|
26581
|
+
const message = (parsed && typeof parsed === "object" && "error" in parsed ? parsed.error : void 0)?.message || `Primitive API returned HTTP ${response.status} for GET /v1/cli/skill.`;
|
|
26582
|
+
throw new Errors.CLIError(message, { exit: 1 });
|
|
26583
|
+
}
|
|
26584
|
+
const data = parsed && typeof parsed === "object" && "data" in parsed ? parsed.data : void 0;
|
|
26585
|
+
if (!data || typeof data.markdown !== "string" || !data.etag) throw new Errors.CLIError("Unexpected response shape from GET /v1/cli/skill.", { exit: 1 });
|
|
26586
|
+
return {
|
|
26587
|
+
status: "ok",
|
|
26588
|
+
data,
|
|
26589
|
+
apiBaseUrl: baseUrl
|
|
26590
|
+
};
|
|
26591
|
+
}
|
|
26592
|
+
function commonInstalledEtag(etags) {
|
|
26593
|
+
if (etags.length === 0) return null;
|
|
26594
|
+
const first = etags[0];
|
|
26595
|
+
if (!first) return null;
|
|
26596
|
+
return etags.every((value) => value === first) ? first : null;
|
|
26597
|
+
}
|
|
26598
|
+
function reportSkillCheckResult(command, params) {
|
|
26599
|
+
const statuses = params.targets.map((t, index) => {
|
|
26600
|
+
const meta = params.metas[index];
|
|
26601
|
+
const state = meta && params.serverEtag && meta.etag === params.serverEtag ? "fresh" : meta || isSkillFilePresent(t) ? "stale" : "missing";
|
|
26602
|
+
return {
|
|
26603
|
+
target: t.target,
|
|
26604
|
+
path: t.filePath,
|
|
26605
|
+
state,
|
|
26606
|
+
installed_etag: meta?.etag ?? null
|
|
26607
|
+
};
|
|
26608
|
+
});
|
|
26609
|
+
const allFresh = statuses.every((s) => s.state === "fresh");
|
|
26610
|
+
const overall = allFresh ? "fresh" : statuses.every((s) => s.state === "missing") ? "missing" : "stale";
|
|
26611
|
+
if (params.json) command.log(JSON.stringify({
|
|
26612
|
+
state: overall,
|
|
26613
|
+
etag: params.serverEtag,
|
|
26614
|
+
targets: statuses
|
|
26615
|
+
}));
|
|
26616
|
+
else {
|
|
26617
|
+
for (const item of statuses) command.log(`${item.state}\t${item.target}\t${item.path}`);
|
|
26618
|
+
if (!allFresh) process.stderr.write("Skill is out of date or missing. Run `primitive skill install` to update.\n");
|
|
26619
|
+
}
|
|
26620
|
+
if (!allFresh) process.exitCode = 2;
|
|
26621
|
+
}
|
|
26622
|
+
var SkillCommand = class SkillCommand extends Command {
|
|
26623
|
+
static summary = "Print or verify the live Primitive skill tailored to your credential";
|
|
26624
|
+
static description = "Fetch the authenticated, permission- and entitlement-scoped Primitive skill document from the server. Prints SKILL.md to stdout by default so agents and scripts can load it directly without MCP. Use `primitive skill install` to write it into local agent skill directories.";
|
|
26625
|
+
static examples = [
|
|
26626
|
+
"<%= config.bin %> skill",
|
|
26627
|
+
"<%= config.bin %> skill --json",
|
|
26628
|
+
"<%= config.bin %> skill --check",
|
|
26629
|
+
"<%= config.bin %> skill --out ./SKILL.md",
|
|
26630
|
+
"<%= config.bin %> skill install"
|
|
26631
|
+
];
|
|
26632
|
+
static flags = {
|
|
26633
|
+
check: Flags.boolean({ description: "Check whether the installed local skill matches the server ETag (exits 0 if fresh, 2 if stale or missing)" }),
|
|
26634
|
+
out: Flags.string({ description: "Write SKILL.md to this file path (or check freshness against this path with --check)" }),
|
|
26635
|
+
target: Flags.string({
|
|
26636
|
+
description: "Target agent runtime for --check (auto, all, claude, codex, antigravity, cursor, openclaw, agents)",
|
|
26637
|
+
multiple: true
|
|
26638
|
+
}),
|
|
26639
|
+
project: Flags.boolean({ description: "With --check, check project-local skill directories" }),
|
|
26640
|
+
name: Flags.string({
|
|
26641
|
+
description: "Skill directory name when checking installed copies",
|
|
26642
|
+
default: DEFAULT_LIVE_SKILL_NAME
|
|
26643
|
+
}),
|
|
26644
|
+
json: Flags.boolean({ description: "Output structured skill metadata and markdown as JSON" }),
|
|
26645
|
+
time: Flags.boolean({ description: "Print request timing to stderr" }),
|
|
26646
|
+
"api-key": Flags.string({
|
|
26647
|
+
description: "Override the Primitive API key for this request",
|
|
26648
|
+
env: "PRIMITIVE_API_KEY"
|
|
26649
|
+
}),
|
|
26650
|
+
"api-base-url": Flags.string({
|
|
26651
|
+
description: "Override the API base URL",
|
|
26652
|
+
env: "PRIMITIVE_API_BASE_URL",
|
|
26653
|
+
hidden: true
|
|
26654
|
+
})
|
|
26655
|
+
};
|
|
26656
|
+
async run() {
|
|
26657
|
+
const { flags } = await this.parse(SkillCommand);
|
|
26658
|
+
if (flags.out && (flags.project || flags.target && flags.target.length > 0)) throw new Errors.CLIError("--out cannot be combined with --target or --project.", { exit: 2 });
|
|
26659
|
+
if (!flags.check && (flags.project || flags.target && flags.target.length > 0)) throw new Errors.CLIError("--target and --project require --check on `primitive skill`, or use `primitive skill install`.", { exit: 2 });
|
|
26660
|
+
await runWithTiming(flags.time === true, async () => {
|
|
26661
|
+
if (flags.check) {
|
|
26662
|
+
const targets = resolveSkillTargets({
|
|
26663
|
+
targets: flags.target,
|
|
26664
|
+
project: flags.project,
|
|
26665
|
+
out: flags.out,
|
|
26666
|
+
name: flags.name
|
|
26667
|
+
});
|
|
26668
|
+
const metas = targets.map((t) => readInstalledSkillMeta(t));
|
|
26669
|
+
const sharedEtag = commonInstalledEtag(metas.map((m) => m?.etag ?? null));
|
|
26670
|
+
const result = await fetchCliSkill({
|
|
26671
|
+
configDir: this.config.configDir,
|
|
26672
|
+
apiKey: flags["api-key"],
|
|
26673
|
+
apiBaseUrl: flags["api-base-url"],
|
|
26674
|
+
ifNoneMatch: sharedEtag
|
|
26675
|
+
});
|
|
26676
|
+
const serverEtag = result.status === "not_modified" ? result.etag : result.data.etag;
|
|
26677
|
+
reportSkillCheckResult(this, {
|
|
26678
|
+
targets,
|
|
26679
|
+
metas,
|
|
26680
|
+
serverEtag,
|
|
26681
|
+
json: flags.json === true
|
|
26682
|
+
});
|
|
26683
|
+
return;
|
|
26684
|
+
}
|
|
26685
|
+
if (flags.out !== void 0) {
|
|
26686
|
+
const normalizedName = validateSkillName(flags.name);
|
|
26687
|
+
const [target] = resolveSkillTargets({
|
|
26688
|
+
out: flags.out,
|
|
26689
|
+
name: normalizedName
|
|
26690
|
+
});
|
|
26691
|
+
if (!target) throw new Errors.CLIError("Could not resolve --out target.", { exit: 2 });
|
|
26692
|
+
const result = await fetchCliSkill({
|
|
26693
|
+
configDir: this.config.configDir,
|
|
26694
|
+
apiKey: flags["api-key"],
|
|
26695
|
+
apiBaseUrl: flags["api-base-url"]
|
|
26696
|
+
});
|
|
26697
|
+
if (result.status !== "ok") throw new Errors.CLIError("Unexpected 304 response without If-None-Match.", { exit: 1 });
|
|
26698
|
+
const outcome = installSkillToTarget(target, {
|
|
26699
|
+
name: normalizedName,
|
|
26700
|
+
version: result.data.version,
|
|
26701
|
+
etag: result.data.etag,
|
|
26702
|
+
apiBaseUrl: result.apiBaseUrl,
|
|
26703
|
+
orgId: result.data.org_id,
|
|
26704
|
+
authMethod: result.data.auth_method,
|
|
26705
|
+
markdown: result.data.markdown
|
|
26706
|
+
}, { force: true });
|
|
26707
|
+
if (flags.json) this.log(JSON.stringify({
|
|
26708
|
+
state: outcome.state,
|
|
26709
|
+
path: target.filePath,
|
|
26710
|
+
etag: result.data.etag,
|
|
26711
|
+
modules: result.data.modules
|
|
26712
|
+
}));
|
|
26713
|
+
else this.log(`Wrote Primitive skill (${result.data.etag}) to ${target.filePath}`);
|
|
26714
|
+
return;
|
|
26715
|
+
}
|
|
26716
|
+
const result = await fetchCliSkill({
|
|
26717
|
+
configDir: this.config.configDir,
|
|
26718
|
+
apiKey: flags["api-key"],
|
|
26719
|
+
apiBaseUrl: flags["api-base-url"]
|
|
26720
|
+
});
|
|
26721
|
+
if (result.status !== "ok") throw new Errors.CLIError("Unexpected 304 response without If-None-Match.", { exit: 1 });
|
|
26722
|
+
if (flags.json) {
|
|
26723
|
+
this.log(JSON.stringify(result.data, null, 2));
|
|
26724
|
+
return;
|
|
26725
|
+
}
|
|
26726
|
+
process.stdout.write(result.data.markdown.endsWith("\n") ? result.data.markdown : `${result.data.markdown}\n`);
|
|
26727
|
+
});
|
|
26728
|
+
}
|
|
26729
|
+
};
|
|
26730
|
+
var SkillInstallCommand = class SkillInstallCommand extends Command {
|
|
26731
|
+
static summary = "Install or update the live Primitive skill into local agent directories";
|
|
26732
|
+
static description = "Fetch your credential's tailored Primitive skill from the server and atomically write SKILL.md into detected or selected coding-agent skill directories (Claude Code, Codex, Antigravity, Cursor, OpenClaw, or universal ~/.agents/skills).";
|
|
26733
|
+
static examples = [
|
|
26734
|
+
"<%= config.bin %> skill install",
|
|
26735
|
+
"<%= config.bin %> skill install --target claude,codex",
|
|
26736
|
+
"<%= config.bin %> skill install --project",
|
|
26737
|
+
"<%= config.bin %> skill install --check",
|
|
26738
|
+
"<%= config.bin %> skill install --out ./my-agent/SKILL.md"
|
|
26739
|
+
];
|
|
26740
|
+
static flags = {
|
|
26741
|
+
target: Flags.string({
|
|
26742
|
+
description: "Target agent runtime(s): auto (default), all, claude, codex, antigravity, cursor, openclaw, agents",
|
|
26743
|
+
multiple: true
|
|
26744
|
+
}),
|
|
26745
|
+
project: Flags.boolean({ description: "Install into workspace-local skill directories instead of user home" }),
|
|
26746
|
+
out: Flags.string({ description: "Install into an explicit directory or SKILL.md path (cannot combine with --target or --project)" }),
|
|
26747
|
+
name: Flags.string({
|
|
26748
|
+
description: "Skill folder name (default: primitive)",
|
|
26749
|
+
default: DEFAULT_LIVE_SKILL_NAME
|
|
26750
|
+
}),
|
|
26751
|
+
check: Flags.boolean({ description: "Dry-run freshness check against server ETag without writing files (exits 0 fresh, 2 stale/missing)" }),
|
|
26752
|
+
force: Flags.boolean({ description: "Rewrite SKILL.md even if the installed ETag matches" }),
|
|
26753
|
+
json: Flags.boolean({ description: "Output installation summary as JSON" }),
|
|
26754
|
+
time: Flags.boolean({ description: "Print request timing to stderr" }),
|
|
26755
|
+
"api-key": Flags.string({
|
|
26756
|
+
description: "Override the Primitive API key for this request",
|
|
26757
|
+
env: "PRIMITIVE_API_KEY"
|
|
26758
|
+
}),
|
|
26759
|
+
"api-base-url": Flags.string({
|
|
26760
|
+
description: "Override the API base URL",
|
|
26761
|
+
env: "PRIMITIVE_API_BASE_URL",
|
|
26762
|
+
hidden: true
|
|
26763
|
+
})
|
|
26764
|
+
};
|
|
26765
|
+
async run() {
|
|
26766
|
+
const { flags } = await this.parse(SkillInstallCommand);
|
|
26767
|
+
if (flags.out && (flags.project || flags.target && flags.target.length > 0)) throw new Errors.CLIError("--out cannot be combined with --target or --project.", { exit: 2 });
|
|
26768
|
+
await runWithTiming(flags.time === true, async () => {
|
|
26769
|
+
const targets = resolveSkillTargets({
|
|
26770
|
+
targets: flags.target,
|
|
26771
|
+
project: flags.project,
|
|
26772
|
+
out: flags.out,
|
|
26773
|
+
name: flags.name
|
|
26774
|
+
});
|
|
26775
|
+
const metas = targets.map((t) => readInstalledSkillMeta(t));
|
|
26776
|
+
const sharedEtag = flags.force ? null : commonInstalledEtag(metas.map((m) => m?.etag ?? null));
|
|
26777
|
+
const result = await fetchCliSkill({
|
|
26778
|
+
configDir: this.config.configDir,
|
|
26779
|
+
apiKey: flags["api-key"],
|
|
26780
|
+
apiBaseUrl: flags["api-base-url"],
|
|
26781
|
+
ifNoneMatch: sharedEtag
|
|
26782
|
+
});
|
|
26783
|
+
if (flags.check) {
|
|
26784
|
+
const serverEtag = result.status === "not_modified" ? result.etag : result.data.etag;
|
|
26785
|
+
reportSkillCheckResult(this, {
|
|
26786
|
+
targets,
|
|
26787
|
+
metas,
|
|
26788
|
+
serverEtag,
|
|
26789
|
+
json: flags.json === true
|
|
26790
|
+
});
|
|
26791
|
+
return;
|
|
26792
|
+
}
|
|
26793
|
+
if (result.status === "not_modified") {
|
|
26794
|
+
const items = targets.map((t, idx) => ({
|
|
26795
|
+
target: t.target,
|
|
26796
|
+
path: t.filePath,
|
|
26797
|
+
state: "unchanged",
|
|
26798
|
+
previous_etag: metas[idx]?.etag ?? null
|
|
26799
|
+
}));
|
|
26800
|
+
if (flags.json) this.log(JSON.stringify({
|
|
26801
|
+
state: "unchanged",
|
|
26802
|
+
etag: result.etag,
|
|
26803
|
+
targets: items
|
|
26804
|
+
}));
|
|
26805
|
+
else for (const item of items) this.log(`unchanged\t${item.target}\t${item.path}`);
|
|
26806
|
+
return;
|
|
26807
|
+
}
|
|
26808
|
+
const normalizedName = validateSkillName(flags.name);
|
|
26809
|
+
const installed = targets.map((t) => {
|
|
26810
|
+
const outcome = installSkillToTarget(t, {
|
|
26811
|
+
name: normalizedName,
|
|
26812
|
+
version: result.data.version,
|
|
26813
|
+
etag: result.data.etag,
|
|
26814
|
+
apiBaseUrl: result.apiBaseUrl,
|
|
26815
|
+
orgId: result.data.org_id,
|
|
26816
|
+
authMethod: result.data.auth_method,
|
|
26817
|
+
markdown: result.data.markdown
|
|
26818
|
+
}, { force: flags.force });
|
|
26819
|
+
return {
|
|
26820
|
+
target: t.target,
|
|
26821
|
+
path: t.filePath,
|
|
26822
|
+
state: outcome.state,
|
|
26823
|
+
previous_etag: outcome.previousEtag
|
|
26824
|
+
};
|
|
26825
|
+
});
|
|
26826
|
+
const overall = installed.every((i) => i.state === "unchanged") ? "unchanged" : installed.some((i) => i.state === "updated") ? "updated" : "installed";
|
|
26827
|
+
if (flags.json) this.log(JSON.stringify({
|
|
26828
|
+
state: overall,
|
|
26829
|
+
etag: result.data.etag,
|
|
26830
|
+
modules: result.data.modules,
|
|
26831
|
+
policy: result.data.policy,
|
|
26832
|
+
targets: installed
|
|
26833
|
+
}));
|
|
26834
|
+
else for (const item of installed) this.log(`${item.state}\t${item.target}\t${item.path}`);
|
|
26835
|
+
});
|
|
26836
|
+
}
|
|
26837
|
+
};
|
|
25521
26838
|
// src/oclif/commands/skills-install.ts
|
|
25522
26839
|
/**
|
|
25523
26840
|
* Install every skill bundled in the CLI package at `packageRoot`, or only
|
|
@@ -27671,7 +28988,14 @@ const rawCommands = {
|
|
|
27671
28988
|
"wake:authorizations:create": WakeAuthorizationsCreateCommand,
|
|
27672
28989
|
"wake:authorizations:update": WakeAuthorizationsUpdateCommand,
|
|
27673
28990
|
"wake:authorizations:delete": WakeAuthorizationsDeleteCommand,
|
|
27674
|
-
"wake:dispatches:list": WakeDispatchesListCommand
|
|
28991
|
+
"wake:dispatches:list": WakeDispatchesListCommand,
|
|
28992
|
+
skill: SkillCommand,
|
|
28993
|
+
"skill:install": SkillInstallCommand,
|
|
28994
|
+
"activity:log": ActivityLogCommand,
|
|
28995
|
+
"activity:update": ActivityUpdateCommand,
|
|
28996
|
+
"activity:timeline": ActivityTimelineCommand,
|
|
28997
|
+
"activity:list": ActivityListCommand,
|
|
28998
|
+
"activity:agents": ActivityAgentsCommand
|
|
27675
28999
|
};
|
|
27676
29000
|
for (const [oldId, target] of Object.entries(COMMAND_PAIR_RENAMES)) {
|
|
27677
29001
|
const request = generatedCommands[oldId];
|
|
@@ -27687,5 +29011,6 @@ for (const [oldId, target] of Object.entries(COMMAND_PAIR_RENAMES)) {
|
|
|
27687
29011
|
const COMMANDS = canonicalCommands(rawCommands);
|
|
27688
29012
|
for (const command of new Set(Object.values(COMMANDS))) ignoreArgumentStdin(command);
|
|
27689
29013
|
setKnownCommands(Object.keys(COMMANDS), CANONICAL_OPERATION_ALIASES);
|
|
29014
|
+
attachActivityContextFlags(COMMANDS);
|
|
27690
29015
|
guardJsonOutputCommands(COMMANDS);
|
|
27691
29016
|
export { CANONICAL_OPERATION_ALIASES, COMMANDS, COMMAND_RENAMES, lookupOperation, retiredCommandTarget };
|