@unbrained/pm-cli 2026.9.12 → 2026.9.14
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/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +42 -0
- package/dist/cli/command-namespaces.js +1 -1
- package/dist/cli/commander-usage.js +2 -2
- package/dist/cli/error-guidance.js +1 -1
- package/dist/cli/extension-command-help.d.ts +2 -2
- package/dist/cli/extension-command-help.js +2 -2
- package/dist/cli/main.js +2 -2
- package/dist/cli-bundle/bundle-manifest.json +146 -146
- package/dist/cli-bundle/chunks/chunk-33PER336.js +236 -0
- package/dist/cli-bundle/chunks/{chunk-3ZJDGTYC.js → chunk-5JIJAWIF.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-A2Q64TGR.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-YU75JRTW.js → chunk-B6W5LIXK.js} +43 -43
- package/dist/cli-bundle/chunks/{chunk-GKY655T7.js → chunk-BY3ID7QI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7KF6HCRC.js → chunk-D5AJQU7F.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7H33WPDF.js → chunk-DBHQIS6Z.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TAGDYARO.js → chunk-GQMILIC5.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-2JAY4LFI.js → chunk-NYE6EREL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-67H4PKQ5.js → chunk-O7SRS7Y3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-X6POOZKD.js → chunk-XEV7BHH3.js} +29 -29
- package/dist/cli-bundle/chunks/{chunk-I6VQUHK6.js → chunk-ZYRN2OG3.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-KEZPDR6X.js → register-list-query-B2U36YWL.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-HEXA3ZDM.js → register-mutation-GX42CQYR.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-TEZT65JF.js → register-operations-ZV34KX5E.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-IIL74WUG.js → register-setup-W4OS7IZW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LWJBBM6X.js → chunk-6WZBO4VQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-TTRB47KM.js → chunk-7BUJABHB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2BQ4JSJQ.js → chunk-C5NQVXKE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-CMCSUANO.js +20 -0
- package/dist/cli-bundle/focused-chunks/{chunk-IURELABV.js → chunk-CPQQIVDL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-EIXGDI77.js → chunk-D4FQV6TY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YNBACVQ2.js → chunk-ENJH7CBZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KK7KSXUP.js → chunk-FHQLQOUZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PERRTPIY.js → chunk-FNLAQJES.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-GGDO6VBT.js +30 -0
- package/dist/cli-bundle/focused-chunks/{chunk-7EKXAUKF.js → chunk-KWP3QTN7.js} +53 -53
- package/dist/cli-bundle/focused-chunks/{chunk-SDQOOL34.js → chunk-LFGTCEHX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-5PSYV3AT.js → chunk-N23WTRCC.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-5CRND7UA.js → chunk-O4EROPO3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-UFSMYVZF.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-MFVABYEU.js → chunk-ZFNRD7EN.js} +2 -2
- package/dist/cli-bundle/main.js +20 -20
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +2 -2
- package/dist/cli-bundle/sdk-core.js +28 -28
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +42 -42
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +8 -8
- package/dist/core/output/output.js +3 -3
- package/dist/core/sentry/instrument.js +1 -1
- package/dist/core/telemetry/consent.d.ts +1 -1
- package/dist/core/telemetry/consent.js +2 -2
- package/dist/core/telemetry/policy.d.ts +10 -0
- package/dist/core/telemetry/policy.js +2 -0
- package/dist/core/telemetry/runtime.d.ts +43 -14
- package/dist/core/telemetry/runtime.js +5 -4
- package/dist/sdk/agent/command-suggestions.d.ts +6 -0
- package/dist/sdk/agent/command-suggestions.js +1 -1
- package/dist/sdk/agent/item-addressing.js +1 -1
- package/dist/sdk/agent-capability-contracts.js +1 -1
- package/dist/sdk/cli-bootstrap.js +1 -1
- package/dist/sdk/cli-contracts/command-aliases.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
- package/dist/sdk/cli-contracts/grammar-contracts.d.ts +2 -2
- package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +7 -3
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/completion.js +1 -1
- package/dist/sdk/governance/health.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/telemetry.d.ts +5 -0
- package/dist/sdk/telemetry.js +1 -1
- package/docs/AGENT_UX_CONTRACTS.md +10 -2
- package/docs/CLI_GRAMMAR.md +59 -0
- package/docs/COMMAND_NAMESPACES.md +7 -4
- package/docs/CONFIGURATION.md +48 -3
- package/docs/generated/AGENT_CAPABILITY_ROUTING.md +4 -4
- package/docs/generated/AGENT_COMMAND_SURFACE.md +11 -0
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +12 -1
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +2 -2
- package/marketplace.json +2 -2
- package/package.json +5 -5
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/extensions/guide-shell/index.ts +13 -26
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/dist/cli-bundle/chunks/chunk-DEGRLB6Y.js +0 -235
- package/dist/cli-bundle/chunks/chunk-PTX2JRFR.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-BIOWOU6S.js +0 -30
- package/dist/cli-bundle/focused-chunks/chunk-GAKFECOQ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-VWMP6W7Y.js +0 -20
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
!(function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
1
|
+
!(function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2ca9480d-0ae4-50e8-887e-c4183501d92c")}catch(e2){}})();import{getActiveCommandContext,runActiveCommandOverride,runActiveRendererOverride,runActiveServiceOverrideSync,setActiveCommandResult}from"../extensions/index.js";import{EXIT_CODE}from"../shared/constants.js";import{isHostOutputSuppressed}from"./output-control.js";import{projectMutationResult}from"./mutation-projection.js";import{attachReadOutputContracts}from"../../sdk/context-intent-contracts.js";import{attachOutputTokenAccounting}from"../../sdk/output-token-accounting.js";import{propagateContextUsageServingReceipt}from"../../sdk/context-usage.js";import{isReadOutputBudgetExceeded,resolveReadOutputEncoding}from"../../sdk/read-output-contracts.js";import{encode as encodeToon}from"@toon-format/toon";const DECLARED_PROCESS_EXIT_CODES=new Set(Object.values(EXIT_CODE));const NATIVE_OUTPUT_MARKER="__pm_native_output";let streamErrorHandlersInstalled=false;function isPlainObject(value){return typeof value==="object"&&value!==null&&!Array.isArray(value)}function setActiveCommandResultOmitted(source){const omitted={read_output:{result_omitted:true}};propagateContextUsageServingReceipt(source,omitted);setActiveCommandResult(omitted)}function setActiveCommandDeliveryResult(result,receiptSource,structuredDeliveryPreserved){if(structuredDeliveryPreserved){setActiveCommandResult(result);return}setActiveCommandResultOmitted(receiptSource)}function shouldUseNativeOutput(result){return isPlainObject(result)&&result[NATIVE_OUTPUT_MARKER]===true}function stripNativeOutputMarker(result){if(!isPlainObject(result)||result[NATIVE_OUTPUT_MARKER]!==true){return result}const{[NATIVE_OUTPUT_MARKER]:_marker,...rest}=result;return rest}function isBrokenPipeError(error){return typeof error==="object"&&error!==null&&error.code==="EPIPE"}function markStdoutBrokenPipeExitCode(){if(process.exitCode===void 0||process.exitCode===EXIT_CODE.SUCCESS){process.exitCode=EXIT_CODE.SUCCESS}}function markStderrBrokenPipeExitCode(){if(process.exitCode===void 0||process.exitCode===EXIT_CODE.SUCCESS){process.exitCode=EXIT_CODE.GENERIC_FAILURE}}function markBrokenPipeExitCode(target){if(target==="stdout"){markStdoutBrokenPipeExitCode();return}markStderrBrokenPipeExitCode()}function handleUnhandledStreamError(error){const unhandled=error instanceof Error?error:new Error(String(error));setImmediate(()=>{throw unhandled})}function installStreamErrorHandlers(){if(streamErrorHandlersInstalled){return}streamErrorHandlersInstalled=true;process.stdout.on("error",error=>{if(isBrokenPipeError(error)){markBrokenPipeExitCode("stdout");return}handleUnhandledStreamError(error)});process.stderr.on("error",error=>{if(isBrokenPipeError(error)){markBrokenPipeExitCode("stderr");return}handleUnhandledStreamError(error)})}function writeToStream(target,text){installStreamErrorHandlers();try{if(target==="stdout"){process.stdout.write(text)}else{process.stderr.write(text)}return true}catch(error){if(isBrokenPipeError(error)){markBrokenPipeExitCode(target);return false}throw error}}function writeStdout(text){return writeToStream("stdout",text)}function writeStderr(text){return writeToStream("stderr",text)}function renderScalar(value){if(typeof value==="string")return JSON.stringify(value);if(typeof value==="number"||typeof value==="boolean")return String(value);if(value===null)return"null";return JSON.stringify(value)}function isToonPrimitive(value){return value===null||typeof value==="string"||typeof value==="number"||typeof value==="boolean"}function tabularObjectArray(value){if(value.length===0||!value.every(isPlainObject))return false;const keys=Object.keys(value[0]);return keys.length>0&&value.every(entry=>Object.keys(entry).length===keys.length&&keys.every(key=>Object.hasOwn(entry,key)&&isToonPrimitive(entry[key])))}function indentToon(encoded,depth){const indent=" ".repeat(depth);return encoded.split("\n").map(line=>`${indent}${line}`).join("\n")}function renderToonObjectEntry(key,entry,depth){const indent=" ".repeat(depth);if(!isPlainObject(entry)&&!Array.isArray(entry)){return`${indent}${key}: ${renderScalar(entry)}`}if(Array.isArray(entry)&&entry.length===0){return`${indent}${key}: []`}if(Array.isArray(entry)&&tabularObjectArray(entry)){return indentToon(encodeToon({[key]:entry}),depth)}if(isPlainObject(entry)&&Object.keys(entry).length===0){return`${indent}${key}: {}`}return`${indent}${key}:
|
|
2
2
|
${renderToonValue(entry,depth+1)}`}function compactToonValue(value){if(value===null||value===void 0){return void 0}if(Array.isArray(value)){const compactedEntries=value.map(entry=>compactToonValue(entry)).filter(entry=>entry!==void 0);return compactedEntries.length>0?compactedEntries:void 0}if(isPlainObject(value)){const compacted={};for(const[key,entry]of Object.entries(value)){if(key==="omitted_field_groups"&&Array.isArray(entry)&&entry.length===0){compacted[key]=[];continue}const compactedEntry=compactToonValue(entry);if(compactedEntry!==void 0){compacted[key]=compactedEntry}}return Object.keys(compacted).length>0?compacted:void 0}return value}function renderToonValue(value,depth){const indent=" ".repeat(depth);if(Array.isArray(value)){if(value.length===0)return"[]";if(tabularObjectArray(value)){return indentToon(encodeToon(value),depth)}return value.map(entry=>{if(!isPlainObject(entry)&&!Array.isArray(entry)){return`${indent}- ${renderScalar(entry)}`}const rendered=renderToonValue(entry,depth+1);const lines=rendered.split("\n");const[firstLine,...rest]=lines;if(rest.length===0){return`${indent}- ${firstLine.trimStart()}`}return`${indent}- ${firstLine.trimStart()}
|
|
3
3
|
${rest.join("\n")}`}).join("\n")}if(isPlainObject(value)){const entries=Object.entries(value);if(entries.length===0)return"{}";return entries.map(([key,entry])=>renderToonObjectEntry(key,entry,depth)).join("\n")}return`${indent}${renderScalar(value)}`}function renderDefaultMarkdownResult(value){if(!isPlainObject(value)||value.output_default!=="markdown"){return null}if(typeof value.view!=="string"||!Array.isArray(value.events)||!Array.isArray(value.days)){return null}const lines=[`# pm calendar (${value.view})`,""];const summary=isPlainObject(value.summary)?value.summary:{};lines.push(`- events: ${String(summary.events??0)}`);lines.push("");if(value.events.length===0){lines.push("No calendar events matched the selected filters.");return`${lines.join("\n")}
|
|
4
4
|
`}for(const event of value.events){if(!isPlainObject(event)){continue}const kind=typeof event.kind==="string"?event.kind:"event";const title=typeof event.item_title==="string"?event.item_title:"";const itemId=typeof event.item_id==="string"?event.item_id:"";const reminderText=typeof event.reminder_text==="string"&&event.reminder_text.length>0?` ${event.reminder_text}`:"";lines.push(`- [${kind}] ${itemId} ${title}${reminderText}`.trim())}return`${lines.join("\n")}
|
|
5
|
-
`}function resolveOutputFormat(options){return options.json===true||options.json===void 0&&options.defaultOutputFormat==="json"?"json":"toon"}const LEAN_READ_ENVELOPE_ECHO_KEYS=new Set(["filters","now","projection","sorting"]);function projectLeanJsonValue(value){const compacted=compactToonValue(value);if(!isPlainObject(compacted)||!Array.isArray(compacted.items)){return compacted??null}const projected=Object.fromEntries(Object.entries(compacted).filter(([key])=>!LEAN_READ_ENVELOPE_ECHO_KEYS.has(key)));if(projected.has_more!==true){delete projected.next_cursor}return projected}function projectLinkedTestEvidence(value,lean){if(!isPlainObject(value)||!Array.isArray(value.run_results)){return value}if(!value.run_results.every(isPlainObject)){return value}const rows=value.run_results;const contexts=rows.map(row=>row.execution_context).filter(context=>context!==void 0);const sharedContext=contexts.length===rows.length&&contexts.length>0&&contexts.every(context=>JSON.stringify(context)===JSON.stringify(contexts[0]))?contexts[0]:void 0;const runResults=rows.map(row=>{const{execution_context:_executionContext,stdout,stderr,...rest}=row;if(sharedContext===void 0){return row}if(!lean||row.status!=="passed"){return{...rest,stdout,stderr}}return rest});return{...value,...sharedContext===void 0?{}:{execution_context:sharedContext},run_results:runResults}}function formatBuiltInOutput(result,format){if(format==="json"){return`${JSON.stringify(result,null,2)}
|
|
6
|
-
`}const compactedToon=compactToonValue(result);return compactedToon===void 0?"{}\n":`${renderToonValue(compactedToon,0)}
|
|
5
|
+
`}function resolveOutputFormat(options){return options.json===true||options.json===void 0&&options.defaultOutputFormat==="json"?"json":"toon"}const LEAN_READ_ENVELOPE_ECHO_KEYS=new Set(["filters","now","projection","sorting"]);function projectLeanJsonValue(value){const compacted=compactToonValue(value);if(!isPlainObject(compacted)||!Array.isArray(compacted.items)){return compacted??null}const projected=Object.fromEntries(Object.entries(compacted).filter(([key])=>!LEAN_READ_ENVELOPE_ECHO_KEYS.has(key)));if(projected.has_more!==true){delete projected.next_cursor}return projected}function projectLinkedTestEvidence(value,lean){if(!isPlainObject(value)||!Array.isArray(value.run_results)){return value}if(!value.run_results.every(isPlainObject)){return value}const rows=value.run_results;const contexts=rows.map(row=>row.execution_context).filter(context=>context!==void 0);const sharedContext=contexts.length===rows.length&&contexts.length>0&&contexts.every(context=>JSON.stringify(context)===JSON.stringify(contexts[0]))?contexts[0]:void 0;const runResults=rows.map(row=>{const{execution_context:_executionContext,stdout,stderr,...rest}=row;if(sharedContext===void 0){return row}if(!lean||row.status!=="passed"){return{...rest,stdout,stderr}}return rest});return{...value,...sharedContext===void 0?{}:{execution_context:sharedContext},run_results:runResults}}function projectCompleteBriefList(value){if(!isPlainObject(value)||!Array.isArray(value.items)||Object.hasOwn(value,"details")||!isPlainObject(value.projection)||value.projection.mode!=="brief"||!isPlainObject(value.completeness)||value.completeness.status!=="complete"||[value.completeness.unreadable_item_count,value.completeness.unreadable_directory_count].some(count=>count!==0)||[value.has_more,value.truncated].some(flag=>flag!==false)||value.count!==value.items.length||value.total!==value.count||!isPlainObject(value.omission_receipt)||JSON.stringify(value.omission_receipt.omitted_field_groups)!==JSON.stringify([{name:"full_item_fields",restore_with:"--full"}])){return value}const{total:_total,has_more:_hasMore,truncated:_truncated,next_cursor:_nextCursor,completeness:_completeness,projection:_projection,now:_now,omission_receipt:_omissions,sorting,...rest}=value;return{...rest,...isPlainObject(sorting)&&sorting.sort==="default"?{}:{sorting},details:"--full"}}function formatBuiltInOutput(result,format){if(format==="json"){return`${JSON.stringify(result,null,2)}
|
|
6
|
+
`}const compactedToon=compactToonValue(projectCompleteBriefList(result));return compactedToon===void 0?"{}\n":`${renderToonValue(compactedToon,0)}
|
|
7
7
|
`}function resolveOutputService(effectiveResult,nativeOutput,options,format){const serviceOverride=nativeOutput?{handled:false,result:effectiveResult,warnings:[]}:runActiveServiceOverrideSync("output_format",{command:options.command,args:options.commandArgs,command_options:options.commandOptions,global:{...options},pm_root:options.pmRoot,format,options:{...options},result:effectiveResult});const legacyPayloadEchoWarning=serviceOverride.warnings.find(warning=>warning.startsWith("extension_output_format_payload_echo_deprecated:"));if(legacyPayloadEchoWarning!==void 0){writeStderr(`Warning: ${legacyPayloadEchoWarning}. Returning context.payload now declines safely for compatibility; migrate the override to declineServiceOverride() or { handled: false }.
|
|
8
8
|
`)}if(serviceOverride.handled&&typeof serviceOverride.result==="string"){return{result:serviceOverride.result,rendered:serviceOverride.result.endsWith("\n")?serviceOverride.result:`${serviceOverride.result}
|
|
9
9
|
`,structuredDeliveryPreserved:false}}return{result:serviceOverride.handled?serviceOverride.result:effectiveResult,rendered:null,structuredDeliveryPreserved:!serviceOverride.handled||isPlainObject(serviceOverride.result)}}function formatEffectiveOutput(effectiveResult,nativeOutput,options){const activeCommandContext=getActiveCommandContext();const command=options.command??activeCommandContext?.command;const commandOptions={...activeCommandContext?.options,...options.commandOptions,...Object.fromEntries([["outputInclude",options.outputInclude],["outputLimit",options.outputLimit],["outputBudget",options.outputBudget],["outputFormat",options.outputFormat],["outputSession",options.outputSession],["outputCursor",options.outputCursor],["outputRowContract",options.outputRowContract]].filter(entry=>entry[1]!==void 0))};const format=resolveReadOutputEncoding(command??"",commandOptions)??resolveOutputFormat(options);const resolvedCommandOptions={...commandOptions,resolvedOutputFormat:format};const effectiveOptions={...options,command,commandOptions:resolvedCommandOptions};const service=resolveOutputService(effectiveResult,nativeOutput,effectiveOptions,format);if(service.rendered!==null){setActiveCommandResultOmitted(effectiveResult);return service.rendered}const outputResult=service.result;propagateContextUsageServingReceipt(effectiveResult,outputResult);const projectedOutputResult=command==="test"?projectLinkedTestEvidence(outputResult,options.lean===true):outputResult;const intentOutputResult=attachReadOutputContracts(command,resolvedCommandOptions,projectedOutputResult);if(isReadOutputBudgetExceeded(intentOutputResult)){process.exitCode||=EXIT_CODE.USAGE}let{structuredDeliveryPreserved}=service;const renderResolvedOutput=value=>{if(format==="toon"){const markdownDefault=renderDefaultMarkdownResult(value);if(markdownDefault!==null)return markdownDefault}const rendererOverride=nativeOutput?{rendered:null}:runActiveRendererOverride(format,value);if(rendererOverride.rendered!==null){structuredDeliveryPreserved=false;return rendererOverride.rendered.endsWith("\n")?rendererOverride.rendered:`${rendererOverride.rendered}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!(function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f5bf9c68-8526-5c19-ac46-655cf348f0bb")}catch(e2){}})();import{createRequire}from"node:module";import{resolvePmCliVersion}from"../packages/root.js";const OPT_OUT_VALUES=new Set(["1","true","yes","on"]);function isSentryDisabled(){if(OPT_OUT_VALUES.has((process.env.PM_SENTRY_DISABLED??"").trim().toLowerCase()))return true;if(OPT_OUT_VALUES.has((process.env.PM_TELEMETRY_DISABLED??"").trim().toLowerCase()))return true;if(process.env.VITEST||process.env.VITEST_WORKER_ID)return true;return false}const SENSITIVE_KEY_PATTERN=/(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|credentials|bearer|dsn)/i;const INLINE_SENSITIVE_ASSIGNMENT_RE=new RegExp(`\\b(${SENSITIVE_KEY_PATTERN.source})\\s*[:=]\\s*([^\\s,;]+)`,"giu");const ABSOLUTE_PATH_TOKEN_RE=/(^|[\s"'`(=])\/(?:[^\s"'`),;]+)/g;const FILE_URL_PATH_RE=/file:\/\/\/?[^\s"'`),;]+/giu;const WINDOWS_PATH_TOKEN_RE=/\b[A-Za-z]:\\[^\s"'`),;]+/g;const PRIVATE_IP_RE=/\b(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g;const PATH_FIELD_KEY_PATTERN=/(?:^|[_-])(path|filename|file|module|cwd|dir|directory|location|source|script)s?$/i;const MAX_KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS=15;const KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS=["[starter-extension] activating","[starter-extension] all 8 capabilities registered.","[starter-extension] commands:","[starter] preflight check for workspace","[starter] output_format service override active","[pm-ext-ts-starter] activating","[pm-ext-ts-starter] all capabilities registered.","run `pm init` first to initialise a pm workspace"];function looksLikeFilesystemPath(value){const normalized=value.trim();if(normalized.length===0){return false}if(normalized.startsWith("/")||normalized.startsWith("file://")){return true}if(/^[A-Za-z]:\\/.test(normalized)||normalized.startsWith("\\\\")){return true}return normalized.includes("/home/")}function scrubString(value,keyHint){if(keyHint&&PATH_FIELD_KEY_PATTERN.test(keyHint)&&looksLikeFilesystemPath(value)){return"[scrubbed_path]"}const scrubbed=value.replaceAll(INLINE_SENSITIVE_ASSIGNMENT_RE,(_m,key)=>`${key}=[scrubbed]`).replaceAll(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/giu,"[scrubbed_email]").replaceAll(/bearer\s+[a-z0-9._=-]+/giu,"bearer [scrubbed]").replaceAll(/sntr[ysu]_[A-Za-z0-9_-]+/g,"[scrubbed_sentry_token]").replaceAll(PRIVATE_IP_RE,"[scrubbed_ip]").replaceAll(FILE_URL_PATH_RE,"[scrubbed_path]").replaceAll(WINDOWS_PATH_TOKEN_RE,"[scrubbed_path]").replaceAll(ABSOLUTE_PATH_TOKEN_RE,(_match,prefix)=>`${prefix}[scrubbed_path]`);if(looksLikeFilesystemPath(scrubbed)){return"[scrubbed_path]"}return scrubbed}function scrubEventData(obj){const result={};for(const[key,value]of Object.entries(obj)){if(SENSITIVE_KEY_PATTERN.test(key)){result[key]="[scrubbed]"}else if(typeof value==="string"){result[key]=scrubString(value,key)}else if(Array.isArray(value)){result[key]=value.map(entry=>{if(typeof entry==="string"){return scrubString(entry,key)}if(entry&&typeof entry==="object"){return scrubEventData(entry)}return entry})}else if(value&&typeof value==="object"){result[key]=scrubEventData(value)}else{result[key]=value}}return result}function scrubStackFrame(frame){for(const key of["filename","absPath","abs_path","module"]){const rawValue=frame[key];if(typeof rawValue==="string"){frame[key]=scrubString(rawValue,key)}}const contextLine=frame.context_line;if(typeof contextLine==="string"){frame.context_line=scrubString(contextLine,"context_line")}for(const key of["pre_context","post_context"]){const context=frame[key];if(!Array.isArray(context)){continue}frame[key]=context.map(entry=>typeof entry==="string"?scrubString(entry,key):entry)}if(frame.vars&&typeof frame.vars==="object"){frame.vars=scrubEventData(frame.vars)}if(frame.data&&typeof frame.data==="object"){frame.data=scrubEventData(frame.data)}}const requireFromInstrument=createRequire(import.meta.url);const defaultSentryLoader=()=>requireFromInstrument("@sentry/node");let _sentry;let _initDone=false;let _loadSentry=defaultSentryLoader;const PM_CLI_SENTRY_DSN="https://bf7ad2ec76c0051c2ee94e48e8bd6868@o4510603477712896.ingest.de.sentry.io/4511316775338064";function hasPmCliErrorPrefix(value){return/^\s*PmCliError:/.test(value)}function isKnownNoisyConsoleMessage(value){const normalized=value.trim().toLowerCase();if(normalized.length===0){return false}return KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS.some(pattern=>normalized.includes(pattern))}function isKnownNoisyConsoleEvent(event){if(event.logger!=="console"){return false}if(typeof event.message==="string"&&isKnownNoisyConsoleMessage(event.message)){return true}return Array.isArray(event.exception?.values)&&event.exception.values.some(entry=>typeof entry.value==="string"&&isKnownNoisyConsoleMessage(entry.value))}function isNodeRuntimeWarningEvent(event){if(event.logger!=="console")return false;const isRuntimeWarning=value=>typeof value==="string"&&/^\(node:\d+\) MaxListenersExceededWarning: Possible EventEmitter memory leak detected\./.test(value);if(isRuntimeWarning(event.message))return true;return Array.isArray(event.exception?.values)&&event.exception.values.some(entry=>isRuntimeWarning(entry.value))}function isExpectedCliErrorEvent(event){if(event.exception?.values?.some(ex=>ex.type==="PmCliError"))return true;if(event.exception?.values?.some(ex=>typeof ex.value==="string"&&hasPmCliErrorPrefix(ex.value)))return true;if(event.logger==="console"&&typeof event.message==="string"&&hasPmCliErrorPrefix(event.message))return true;return false}function isPmCliErrorBreadcrumb(breadcrumb){return breadcrumb.category==="console"&&typeof breadcrumb.message==="string"&&hasPmCliErrorPrefix(breadcrumb.message)}function isKnownNoisyConsoleBreadcrumb(breadcrumb){return breadcrumb.category==="console"&&typeof breadcrumb.message==="string"&&isKnownNoisyConsoleMessage(breadcrumb.message)}function resolveCliVersion(){return resolvePmCliVersion(import.meta.url,["../../.."])??"0.0.0"}function resolveEnvironment(){const explicit=process.env.SENTRY_ENVIRONMENT?.trim();if(explicit&&explicit.length>0)return explicit;if(process.env.VITEST||process.env.VITEST_WORKER_ID||process.env.NODE_ENV==="test")return"test";if(process.env.CI)return"ci";return"production"}const DEFAULT_TRACES_SAMPLE_RATE=.2;function resolveTracesSampleRate(){const raw=process.env.SENTRY_TRACES_SAMPLE_RATE?.trim();if(!raw)return DEFAULT_TRACES_SAMPLE_RATE;const parsed=Number(raw);if(!Number.isFinite(parsed)||parsed<0||parsed>1){return DEFAULT_TRACES_SAMPLE_RATE}return parsed}function scrubSentryExceptionValues(event){if(!event.exception?.values){return}for(const exception of event.exception.values){if(exception.value){exception.value=scrubString(exception.value,"value")}if(exception.stacktrace?.frames){for(const frame of exception.stacktrace.frames){scrubStackFrame(frame)}}}}function scrubSentryBreadcrumbs(event){if(!event.breadcrumbs){return}for(const breadcrumb of event.breadcrumbs){if(breadcrumb.message){breadcrumb.message=scrubString(breadcrumb.message)}if(breadcrumb.data&&typeof breadcrumb.data==="object"){breadcrumb.data=scrubEventData(breadcrumb.data)}}}function scrubSentryContexts(event){if(!event.contexts){return}for(const[ctxKey,ctx]of Object.entries(event.contexts)){if(ctx&&typeof ctx==="object"){event.contexts[ctxKey]=scrubEventData(ctx)}}}function scrubSentryRecordField(event,key){const target=event;const value=target[key];if(value&&typeof value==="object"){target[key]=scrubEventData(value)}}const beforeSend=event=>{if(isExpectedCliErrorEvent(event)||isKnownNoisyConsoleEvent(event))return null;if(isNodeRuntimeWarningEvent(event)){event.level="warning";event.tags={...event.tags,"pm.diagnostic_class":"node_runtime_warning"}}if(event.message)event.message=scrubString(event.message,"message");if(event.transaction)event.transaction=scrubString(event.transaction,"transaction");scrubSentryExceptionValues(event);scrubSentryBreadcrumbs(event);scrubSentryRecordField(event,"extra");scrubSentryContexts(event);for(const key of["request","user","tags"])scrubSentryRecordField(event,key);return event};const beforeSendTransaction=event=>{if(event.breadcrumbs){event.breadcrumbs=event.breadcrumbs.filter(breadcrumb=>!isPmCliErrorBreadcrumb(breadcrumb)&&!isKnownNoisyConsoleBreadcrumb(breadcrumb));scrubSentryBreadcrumbs(event)}scrubSentryContexts(event);return event};const beforeBreadcrumb=breadcrumb=>{if(isPmCliErrorBreadcrumb(breadcrumb)||isKnownNoisyConsoleBreadcrumb(breadcrumb))return null;if(breadcrumb.message)breadcrumb.message=scrubString(breadcrumb.message,"message");if(breadcrumb.data&&typeof breadcrumb.data==="object"){breadcrumb.data=scrubEventData(breadcrumb.data)}return breadcrumb};async function ensureSentryInit(){if(_initDone)return _sentry;_initDone=true;if(isSentryDisabled())return void 0;const SentryModule=_loadSentry();_sentry=SentryModule;const dsn=process.env.SENTRY_DSN?.trim()||PM_CLI_SENTRY_DSN;const release=resolveCliVersion();SentryModule.init({dsn,release:`pm-cli@${release}`,environment:resolveEnvironment(),tracesSampleRate:resolveTracesSampleRate(),enableLogs:true,attachStacktrace:true,normalizeDepth:6,shutdownTimeout:3e3,sendDefaultPii:false,serverName:void 0,integrations:[SentryModule.extraErrorDataIntegration({depth:4}),SentryModule.captureConsoleIntegration({levels:["warn","error"]})],initialScope:{tags:{"cli.name":"pm-cli","cli.version":release,"runtime.node":process.version,"runtime.platform":process.platform,"runtime.arch":process.arch}},beforeSend,beforeSendTransaction,beforeBreadcrumb});return SentryModule}function getSentry(){return _sentry}const _testOnly={isExpectedCliErrorEvent,isKnownNoisyConsoleEvent,isNodeRuntimeWarningEvent,isPmCliErrorBreadcrumb,isKnownNoisyConsoleBreadcrumb,scrubString,scrubEventData,resolveTracesSampleRate,KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS,MAX_KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS,defaultSentryLoader,setSentryLoaderForTests(loader){_loadSentry=loader??defaultSentryLoader},resetSentryStateForTests(){_sentry=void 0;_initDone=false}};export{_testOnly,ensureSentryInit,getSentry};
|
|
1
|
+
!(function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="12bf6794-9410-5683-bb83-a0da8d2614a7")}catch(e2){}})();import{createRequire}from"node:module";import{resolvePmCliVersion}from"../packages/root.js";import{resolveTelemetryEnvironmentPolicy}from"../telemetry/policy.js";const OPT_OUT_VALUES=new Set(["1","true","yes","on"]);function isSentryDisabled(){if(OPT_OUT_VALUES.has((process.env.PM_SENTRY_DISABLED??"").trim().toLowerCase()))return true;if(resolveTelemetryEnvironmentPolicy().telemetry_disabled)return true;if(typeof process.env.VITEST==="string"||typeof process.env.VITEST_WORKER_ID==="string")return true;return false}const SENSITIVE_KEY_PATTERN=/(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|credentials|bearer|dsn)/i;const INLINE_SENSITIVE_ASSIGNMENT_RE=new RegExp(`\\b(${SENSITIVE_KEY_PATTERN.source})\\s*[:=]\\s*([^\\s,;]+)`,"giu");const ABSOLUTE_PATH_TOKEN_RE=/(^|[\s"'`(=])\/(?:[^\s"'`),;]+)/g;const FILE_URL_PATH_RE=/file:\/\/\/?[^\s"'`),;]+/giu;const WINDOWS_PATH_TOKEN_RE=/\b[A-Za-z]:\\[^\s"'`),;]+/g;const PRIVATE_IP_RE=/\b(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g;const PATH_FIELD_KEY_PATTERN=/(?:^|[_-])(path|filename|file|module|cwd|dir|directory|location|source|script)s?$/i;const MAX_KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS=15;const KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS=["[starter-extension] activating","[starter-extension] all 8 capabilities registered.","[starter-extension] commands:","[starter] preflight check for workspace","[starter] output_format service override active","[pm-ext-ts-starter] activating","[pm-ext-ts-starter] all capabilities registered.","run `pm init` first to initialise a pm workspace"];function looksLikeFilesystemPath(value){const normalized=value.trim();if(normalized.length===0){return false}if(normalized.startsWith("/")||normalized.startsWith("file://")){return true}if(/^[A-Za-z]:\\/.test(normalized)||normalized.startsWith("\\\\")){return true}return normalized.includes("/home/")}function scrubString(value,keyHint){if(keyHint&&PATH_FIELD_KEY_PATTERN.test(keyHint)&&looksLikeFilesystemPath(value)){return"[scrubbed_path]"}const scrubbed=value.replaceAll(INLINE_SENSITIVE_ASSIGNMENT_RE,(_m,key)=>`${key}=[scrubbed]`).replaceAll(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/giu,"[scrubbed_email]").replaceAll(/bearer\s+[a-z0-9._=-]+/giu,"bearer [scrubbed]").replaceAll(/sntr[ysu]_[A-Za-z0-9_-]+/g,"[scrubbed_sentry_token]").replaceAll(PRIVATE_IP_RE,"[scrubbed_ip]").replaceAll(FILE_URL_PATH_RE,"[scrubbed_path]").replaceAll(WINDOWS_PATH_TOKEN_RE,"[scrubbed_path]").replaceAll(ABSOLUTE_PATH_TOKEN_RE,(_match,prefix)=>`${prefix}[scrubbed_path]`);if(looksLikeFilesystemPath(scrubbed)){return"[scrubbed_path]"}return scrubbed}function scrubEventData(obj){const result={};for(const[key,value]of Object.entries(obj)){if(SENSITIVE_KEY_PATTERN.test(key)){result[key]="[scrubbed]"}else if(typeof value==="string"){result[key]=scrubString(value,key)}else if(Array.isArray(value)){result[key]=value.map(entry=>{if(typeof entry==="string"){return scrubString(entry,key)}if(entry&&typeof entry==="object"){return scrubEventData(entry)}return entry})}else if(value&&typeof value==="object"){result[key]=scrubEventData(value)}else{result[key]=value}}return result}function scrubStackFrame(frame){for(const key of["filename","absPath","abs_path","module"]){const rawValue=frame[key];if(typeof rawValue==="string"){frame[key]=scrubString(rawValue,key)}}const contextLine=frame.context_line;if(typeof contextLine==="string"){frame.context_line=scrubString(contextLine,"context_line")}for(const key of["pre_context","post_context"]){const context=frame[key];if(!Array.isArray(context)){continue}frame[key]=context.map(entry=>typeof entry==="string"?scrubString(entry,key):entry)}if(frame.vars&&typeof frame.vars==="object"){frame.vars=scrubEventData(frame.vars)}if(frame.data&&typeof frame.data==="object"){frame.data=scrubEventData(frame.data)}}const requireFromInstrument=createRequire(import.meta.url);const defaultSentryLoader=()=>requireFromInstrument("@sentry/node");let _sentry;let _initDone=false;let _loadSentry=defaultSentryLoader;const PM_CLI_SENTRY_DSN="https://bf7ad2ec76c0051c2ee94e48e8bd6868@o4510603477712896.ingest.de.sentry.io/4511316775338064";function hasPmCliErrorPrefix(value){return/^\s*PmCliError:/.test(value)}function isKnownNoisyConsoleMessage(value){const normalized=value.trim().toLowerCase();if(normalized.length===0){return false}return KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS.some(pattern=>normalized.includes(pattern))}function isKnownNoisyConsoleEvent(event){if(event.logger!=="console"){return false}if(typeof event.message==="string"&&isKnownNoisyConsoleMessage(event.message)){return true}return Array.isArray(event.exception?.values)&&event.exception.values.some(entry=>typeof entry.value==="string"&&isKnownNoisyConsoleMessage(entry.value))}function isNodeRuntimeWarningEvent(event){if(event.logger!=="console")return false;const isRuntimeWarning=value=>typeof value==="string"&&/^\(node:\d+\) MaxListenersExceededWarning: Possible EventEmitter memory leak detected\./.test(value);if(isRuntimeWarning(event.message))return true;return Array.isArray(event.exception?.values)&&event.exception.values.some(entry=>isRuntimeWarning(entry.value))}function isExpectedCliErrorEvent(event){if(event.exception?.values?.some(ex=>ex.type==="PmCliError"))return true;if(event.exception?.values?.some(ex=>typeof ex.value==="string"&&hasPmCliErrorPrefix(ex.value)))return true;if(event.logger==="console"&&typeof event.message==="string"&&hasPmCliErrorPrefix(event.message))return true;return false}function isPmCliErrorBreadcrumb(breadcrumb){return breadcrumb.category==="console"&&typeof breadcrumb.message==="string"&&hasPmCliErrorPrefix(breadcrumb.message)}function isKnownNoisyConsoleBreadcrumb(breadcrumb){return breadcrumb.category==="console"&&typeof breadcrumb.message==="string"&&isKnownNoisyConsoleMessage(breadcrumb.message)}function resolveCliVersion(){return resolvePmCliVersion(import.meta.url,["../../.."])??"0.0.0"}function resolveEnvironment(){const explicit=process.env.SENTRY_ENVIRONMENT?.trim();if(explicit&&explicit.length>0)return explicit;if(process.env.VITEST||process.env.VITEST_WORKER_ID||process.env.NODE_ENV==="test")return"test";if(process.env.CI)return"ci";return"production"}const DEFAULT_TRACES_SAMPLE_RATE=.2;function resolveTracesSampleRate(){const raw=process.env.SENTRY_TRACES_SAMPLE_RATE?.trim();if(!raw)return DEFAULT_TRACES_SAMPLE_RATE;const parsed=Number(raw);if(!Number.isFinite(parsed)||parsed<0||parsed>1){return DEFAULT_TRACES_SAMPLE_RATE}return parsed}function scrubSentryExceptionValues(event){if(!event.exception?.values){return}for(const exception of event.exception.values){if(exception.value){exception.value=scrubString(exception.value,"value")}if(exception.stacktrace?.frames){for(const frame of exception.stacktrace.frames){scrubStackFrame(frame)}}}}function scrubSentryBreadcrumbs(event){if(!event.breadcrumbs){return}for(const breadcrumb of event.breadcrumbs){if(breadcrumb.message){breadcrumb.message=scrubString(breadcrumb.message)}if(breadcrumb.data&&typeof breadcrumb.data==="object"){breadcrumb.data=scrubEventData(breadcrumb.data)}}}function scrubSentryContexts(event){if(!event.contexts){return}for(const[ctxKey,ctx]of Object.entries(event.contexts)){if(ctx&&typeof ctx==="object"){event.contexts[ctxKey]=scrubEventData(ctx)}}}function scrubSentryRecordField(event,key){const target=event;const value=target[key];if(value&&typeof value==="object"){target[key]=scrubEventData(value)}}const beforeSend=event=>{if(isExpectedCliErrorEvent(event)||isKnownNoisyConsoleEvent(event))return null;if(isNodeRuntimeWarningEvent(event)){event.level="warning";event.tags={...event.tags,"pm.diagnostic_class":"node_runtime_warning"}}if(event.message)event.message=scrubString(event.message,"message");if(event.transaction)event.transaction=scrubString(event.transaction,"transaction");scrubSentryExceptionValues(event);scrubSentryBreadcrumbs(event);scrubSentryRecordField(event,"extra");scrubSentryContexts(event);for(const key of["request","user","tags"])scrubSentryRecordField(event,key);return event};const beforeSendTransaction=event=>{if(event.breadcrumbs){event.breadcrumbs=event.breadcrumbs.filter(breadcrumb=>!isPmCliErrorBreadcrumb(breadcrumb)&&!isKnownNoisyConsoleBreadcrumb(breadcrumb));scrubSentryBreadcrumbs(event)}scrubSentryContexts(event);return event};const beforeBreadcrumb=breadcrumb=>{if(isPmCliErrorBreadcrumb(breadcrumb)||isKnownNoisyConsoleBreadcrumb(breadcrumb))return null;if(breadcrumb.message)breadcrumb.message=scrubString(breadcrumb.message,"message");if(breadcrumb.data&&typeof breadcrumb.data==="object"){breadcrumb.data=scrubEventData(breadcrumb.data)}return breadcrumb};async function ensureSentryInit(){if(_initDone)return _sentry;_initDone=true;if(isSentryDisabled())return void 0;const SentryModule=_loadSentry();_sentry=SentryModule;const dsn=process.env.SENTRY_DSN?.trim()||PM_CLI_SENTRY_DSN;const release=resolveCliVersion();SentryModule.init({dsn,release:`pm-cli@${release}`,environment:resolveEnvironment(),tracesSampleRate:resolveTracesSampleRate(),enableLogs:true,attachStacktrace:true,normalizeDepth:6,shutdownTimeout:3e3,sendDefaultPii:false,serverName:void 0,integrations:[SentryModule.extraErrorDataIntegration({depth:4}),SentryModule.captureConsoleIntegration({levels:["warn","error"]})],initialScope:{tags:{"cli.name":"pm-cli","cli.version":release,"runtime.node":process.version,"runtime.platform":process.platform,"runtime.arch":process.arch}},beforeSend,beforeSendTransaction,beforeBreadcrumb});return SentryModule}function getSentry(){return _sentry}const _testOnly={isExpectedCliErrorEvent,isKnownNoisyConsoleEvent,isNodeRuntimeWarningEvent,isPmCliErrorBreadcrumb,isKnownNoisyConsoleBreadcrumb,scrubString,scrubEventData,resolveTracesSampleRate,KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS,MAX_KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS,defaultSentryLoader,setSentryLoaderForTests(loader){_loadSentry=loader??defaultSentryLoader},resetSentryStateForTests(){_sentry=void 0;_initDone=false}};export{_testOnly,ensureSentryInit,getSentry};
|
|
2
2
|
//# sourceMappingURL=instrument.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { GlobalOptions } from "../shared/command-types.js";
|
|
2
|
-
/**
|
|
2
|
+
/** Prompt eligible interactive users once, persisting their choice without interrupting commands on failure. */
|
|
3
3
|
export declare function maybeRunFirstUseTelemetryPrompt(commandPath: string, globalOptions: GlobalOptions): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
!(function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
1
|
+
!(function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="91cfc9cf-9ab1-5c9f-803d-f378e9963c4a")}catch(e2){}})();import readline from"node:readline/promises";import{stdin as input,stdout as output}from"node:process";import{resolveGlobalPmRoot}from"../store/paths.js";import{readSettings,writeSettings}from"../store/settings.js";import{resolveTelemetryEnvironmentPolicy}from"./policy.js";const TELEMETRY_PROMPT_DISABLE_ENV="PM_TELEMETRY_PROMPT";const TELEMETRY_PROMPT_DISABLE_VALUES=new Set(["0","false","no","off"]);const TELEMETRY_PROMPT_SKIPPED_COMMANDS=new Set(["init","completion","completion-statuses","completion-tags","completion-types"]);function parseBooleanLike(value){if(typeof value!=="string"){return false}return TELEMETRY_PROMPT_DISABLE_VALUES.has(value.trim().toLowerCase())}function isTruthyEnvValue(value){if(typeof value!=="string"){return false}const normalized=value.trim().toLowerCase();if(normalized.length===0){return false}return!TELEMETRY_PROMPT_DISABLE_VALUES.has(normalized)}function shouldSkipTelemetryPrompt(commandPath,globalOptions){if(globalOptions.json===true||globalOptions.quiet===true){return true}if(process.stdin.isTTY!==true||process.stdout.isTTY!==true){return true}if(parseBooleanLike(process.env[TELEMETRY_PROMPT_DISABLE_ENV])){return true}if(isTruthyEnvValue(process.env.CI)){return true}const normalizedCommandPath=commandPath.trim().toLowerCase();if(normalizedCommandPath.length===0){return true}return TELEMETRY_PROMPT_SKIPPED_COMMANDS.has(normalizedCommandPath)}function parseTelemetryPromptAnswer(answer){const normalized=answer.trim().toLowerCase();if(normalized==="n"||normalized==="no"){return false}return true}async function promptTelemetryConsent(currentDefault){const defaultLabel=currentDefault?"Y/n":"y/N";const prompt=`pm telemetry helps improve reliability and usage diagnostics.
|
|
2
2
|
It is enabled by default and can be changed anytime via:
|
|
3
3
|
pm config global set telemetry-tracking --policy disabled
|
|
4
|
-
Enable telemetry now? [${defaultLabel}] `;const rl=readline.createInterface({input,output});try{const answer=await rl.question(prompt);if(answer.trim().length===0){return currentDefault}return parseTelemetryPromptAnswer(answer)}finally{rl.close()}}async function maybeRunFirstUseTelemetryPrompt(commandPath,globalOptions){if(shouldSkipTelemetryPrompt(commandPath,globalOptions)){return}try{const globalPmRoot=resolveGlobalPmRoot(process.cwd());const settings=await readSettings(globalPmRoot);if(settings.telemetry.first_run_prompt_completed){return}const enabled=await promptTelemetryConsent(settings.telemetry.enabled);settings.telemetry.enabled=enabled;settings.telemetry.first_run_prompt_completed=true;await writeSettings(globalPmRoot,settings,"telemetry:first_run_prompt");output.write(`Telemetry ${enabled?"enabled":"disabled"} for this CLI install. Update any time with pm config global set telemetry-tracking --policy ${enabled?"disabled":"enabled"}.
|
|
4
|
+
Enable telemetry now? [${defaultLabel}] `;const rl=readline.createInterface({input,output});try{const answer=await rl.question(prompt);if(answer.trim().length===0){return currentDefault}return parseTelemetryPromptAnswer(answer)}finally{rl.close()}}async function maybeRunFirstUseTelemetryPrompt(commandPath,globalOptions){if(resolveTelemetryEnvironmentPolicy().telemetry_disabled||shouldSkipTelemetryPrompt(commandPath,globalOptions)){return}try{const globalPmRoot=resolveGlobalPmRoot(process.cwd());const settings=await readSettings(globalPmRoot);if(settings.telemetry.first_run_prompt_completed){return}const enabled=await promptTelemetryConsent(settings.telemetry.enabled);settings.telemetry.enabled=enabled;settings.telemetry.first_run_prompt_completed=true;await writeSettings(globalPmRoot,settings,"telemetry:first_run_prompt");output.write(`Telemetry ${enabled?"enabled":"disabled"} for this CLI install. Update any time with pm config global set telemetry-tracking --policy ${enabled?"disabled":"enabled"}.
|
|
5
5
|
`)}catch{}}export{maybeRunFirstUseTelemetryPrompt};
|
|
6
6
|
//# sourceMappingURL=consent.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Supported explicit classifications for intentional telemetry delivery. */
|
|
2
|
+
export declare const PM_TELEMETRY_SOURCE_CONTEXT_VALUES: readonly ["user", "automation", "test", "dogfood"];
|
|
3
|
+
/** Resolve explicit read sampling only for core-only invocations with no write-capable extensions. */
|
|
4
|
+
export declare function resolveTelemetryReadSampleRate(command: string, noExtensions: boolean, env?: Readonly<Record<string, string | undefined>>): number;
|
|
5
|
+
/** Explain process opt-outs without reading settings or creating installation identity. */
|
|
6
|
+
export declare function resolveTelemetryEnvironmentPolicy(env?: Readonly<Record<string, string | undefined>>): {
|
|
7
|
+
telemetry_disabled: boolean;
|
|
8
|
+
do_not_track: boolean;
|
|
9
|
+
test_suppressed: boolean;
|
|
10
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!(function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f22e54f3-7ade-5af3-8344-9c133b4da8b5")}catch(e2){}})();const TRUE_VALUES=new Set(["1","true","yes","on"]);const PM_TELEMETRY_SOURCE_CONTEXT_VALUES=["user","automation","test","dogfood"];const SOURCE_CONTEXTS=new Set(PM_TELEMETRY_SOURCE_CONTEXT_VALUES);const SAMPLEABLE_READS=new Set(["stats","ops stats","list","get","next","context","activity","aggregate"]);function resolveTelemetryReadSampleRate(command,noExtensions,env=process.env){const raw=env.PM_TELEMETRY_READ_SAMPLE_RATE?.trim();if(!raw||!noExtensions||!SAMPLEABLE_READS.has(command))return 1;const rate=Number(raw);return Number.isFinite(rate)&&rate>0&&rate<=1?rate:1}function telemetryEnvironmentFlag(key,env){return TRUE_VALUES.has((env[key]??"").trim().toLowerCase())}function resolveTelemetryEnvironmentPolicy(env=process.env){const doNotTrack=telemetryEnvironmentFlag("DO_NOT_TRACK",env);const override=(env.PM_TELEMETRY_SOURCE_CONTEXT??"").trim().toLowerCase();const inferredTest=typeof env.VITEST==="string"||typeof env.VITEST_WORKER_ID==="string"||(env.NODE_ENV??"").trim().toLowerCase()==="test";const testSuppressed=inferredTest&&!SOURCE_CONTEXTS.has(override)&&!telemetryEnvironmentFlag("PM_TELEMETRY_SEND_TEST_EVENTS",env);return{telemetry_disabled:doNotTrack||testSuppressed||telemetryEnvironmentFlag("PM_TELEMETRY_DISABLED",env)||telemetryEnvironmentFlag("PM_NO_TELEMETRY",env),do_not_track:doNotTrack,test_suppressed:testSuppressed}}export{PM_TELEMETRY_SOURCE_CONTEXT_VALUES,resolveTelemetryEnvironmentPolicy,resolveTelemetryReadSampleRate};
|
|
2
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PM_TELEMETRY_SOURCE_CONTEXT_VALUES } from "./policy.js";
|
|
1
2
|
import type { GlobalOptions } from "../shared/command-types.js";
|
|
2
3
|
import { type TelemetryErrorCategory } from "../shared/constants.js";
|
|
3
4
|
import { type TelemetryCommandResolution, type TelemetryCommandTaxonomy, type TelemetryResolutionStage } from "./observability.js";
|
|
@@ -5,8 +6,7 @@ import { type TelemetryCommandResolution, type TelemetryCommandTaxonomy, type Te
|
|
|
5
6
|
export declare const TELEMETRY_SCHEMA_VERSION = 1;
|
|
6
7
|
/** Public contract for telemetry max queue entry attempts, shared by SDK and presentation-layer consumers. */
|
|
7
8
|
export declare const TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS = 15;
|
|
8
|
-
|
|
9
|
-
export declare const PM_TELEMETRY_SOURCE_CONTEXT_VALUES: readonly ["user", "automation", "test", "dogfood"];
|
|
9
|
+
export { PM_TELEMETRY_SOURCE_CONTEXT_VALUES } from "./policy.js";
|
|
10
10
|
/** Wait for the most recent background flush to settle. Test-only helper. */
|
|
11
11
|
export declare function waitForPendingFlush(): Promise<void>;
|
|
12
12
|
interface TelemetryEvent {
|
|
@@ -51,13 +51,15 @@ interface PendingOtelSpan {
|
|
|
51
51
|
}
|
|
52
52
|
type TelemetryCaptureLevel = "minimal" | "redacted" | "max";
|
|
53
53
|
type TelemetrySourceContext = (typeof PM_TELEMETRY_SOURCE_CONTEXT_VALUES)[number];
|
|
54
|
-
type TelemetrySourceContextSource = "inferred" | "env_override";
|
|
54
|
+
type TelemetrySourceContextSource = "inferred" | "env_override" | "env_override_rejected";
|
|
55
55
|
interface ResolvedTelemetrySourceContext {
|
|
56
56
|
source_context: TelemetrySourceContext;
|
|
57
57
|
source_context_source: TelemetrySourceContextSource;
|
|
58
58
|
}
|
|
59
59
|
/** Documents the active telemetry command payload exchanged by command, SDK, and package integrations. */
|
|
60
60
|
export interface ActiveTelemetryCommand {
|
|
61
|
+
/** Inclusion probability for successful sampled reads; failures are retained at probability one. */
|
|
62
|
+
sample_rate?: number;
|
|
61
63
|
/** ISO 8601 timestamp recording when started occurred. */
|
|
62
64
|
started_at: string;
|
|
63
65
|
/** Elapsed time in milliseconds for started at. */
|
|
@@ -70,7 +72,7 @@ export interface ActiveTelemetryCommand {
|
|
|
70
72
|
pm_version: string;
|
|
71
73
|
/** Value that configures or reports source context for this contract. */
|
|
72
74
|
source_context: TelemetrySourceContext;
|
|
73
|
-
/**
|
|
75
|
+
/** Whether attribution was inferred, explicitly accepted, or inferred after rejecting an override without retaining its value. */
|
|
74
76
|
source_context_source: TelemetrySourceContextSource;
|
|
75
77
|
/** Value that configures or reports installation id for this contract. */
|
|
76
78
|
installation_id: string;
|
|
@@ -175,14 +177,19 @@ declare function parseBooleanTrueLike(value: string | undefined): boolean;
|
|
|
175
177
|
declare function resolveTelemetryHttpTimeoutMs(): number;
|
|
176
178
|
/** POST a JSON payload with one total timeout that covers DNS, connection, TLS, and response completion. */
|
|
177
179
|
declare function postTelemetryJson(endpoint: string, headers: Record<string, string>, body: string): Promise<number>;
|
|
180
|
+
/** Use a trimmed package version when provided, falling back to 0.0.0 for an unknown producer version. */
|
|
178
181
|
declare function normalizePmVersion(value: string | undefined): string;
|
|
182
|
+
/** Trim a supplied diagnostic code and omit missing or whitespace-only codes from event payloads. */
|
|
179
183
|
declare function normalizeTelemetryErrorCode(value: string | undefined): string | undefined;
|
|
184
|
+
/** Preserve finite non-negative integer exit codes; otherwise derive zero for success and one for failure. */
|
|
180
185
|
declare function normalizeTelemetryExitCode(exitCode: number | undefined, ok: boolean): number;
|
|
186
|
+
/** Omit categories for successful outcomes; preserve explicit failure categories or derive them from a stable error code. */
|
|
181
187
|
declare function normalizeTelemetryErrorCategory(params: {
|
|
182
188
|
ok: boolean;
|
|
183
189
|
errorCode?: string;
|
|
184
190
|
errorCategory?: TelemetryErrorCategory;
|
|
185
191
|
}): TelemetryErrorCategory | undefined;
|
|
192
|
+
/** Resolve explicit attribution and explain rejected input without retaining its value. */
|
|
186
193
|
declare function resolveTelemetrySourceContext(globalOptions: GlobalOptions): ResolvedTelemetrySourceContext;
|
|
187
194
|
/**
|
|
188
195
|
* Builds privacy-bounded author and agent dimensions for a telemetry payload.
|
|
@@ -193,7 +200,8 @@ declare function resolveTelemetrySourceContext(globalOptions: GlobalOptions): Re
|
|
|
193
200
|
* agent-driven invocations can be segmented in Sentry/dashboards while the same
|
|
194
201
|
* author hashes differently across installations. Because the field is a one-way
|
|
195
202
|
* hash, it intentionally bypasses the {@link SENSITIVE_KEYWORDS} redaction path.
|
|
196
|
-
* Harness and model
|
|
203
|
+
* Harness and model hashes remain installation-keyed. Only allowlisted harness
|
|
204
|
+
* names and a CI boolean are also exposed across installations.
|
|
197
205
|
* Model source is a fixed enum and can be emitted directly. The local
|
|
198
206
|
* invocation/session identifier is deliberately excluded at every capture
|
|
199
207
|
* level. At minimal capture only presence booleans are surfaced.
|
|
@@ -216,12 +224,13 @@ declare function buildOtelSpanRequest(activeCommand: ActiveTelemetryCommand, out
|
|
|
216
224
|
exit_code?: number;
|
|
217
225
|
error_code?: string;
|
|
218
226
|
error_category?: TelemetryErrorCategory;
|
|
219
|
-
}, finishedAtIso: string, durationMs: number): {
|
|
227
|
+
}, finishedAtIso: string, durationMs: number, sampleRate?: number): {
|
|
220
228
|
endpoint: string;
|
|
221
229
|
payload: unknown;
|
|
222
230
|
} | null;
|
|
223
231
|
/** Build a bounded, capture-level-sanitized result preview. Omit undefined object values as JSON does so optional fields cannot prevent completion telemetry. */
|
|
224
232
|
declare function summarizeResult(result: unknown, captureLevel?: Exclude<TelemetryCaptureLevel, "minimal">): Record<string, unknown>;
|
|
233
|
+
/** Build invocation metadata for the selected capture level; minimal capture retains digests while richer levels include sanitized inputs and hashed runtime context. */
|
|
225
234
|
declare function buildCommandStartPayload(params: {
|
|
226
235
|
captureLevel: TelemetryCaptureLevel;
|
|
227
236
|
context: TelemetryCommandContext;
|
|
@@ -231,6 +240,7 @@ declare function buildCommandStartPayload(params: {
|
|
|
231
240
|
cwdHash: string;
|
|
232
241
|
installationId: string;
|
|
233
242
|
}): Record<string, unknown>;
|
|
243
|
+
/** Build completion diagnostics with sanitized errors and failure fingerprints; minimal capture omits start timestamps and result previews. */
|
|
234
244
|
declare function buildCommandFinishPayload(params: {
|
|
235
245
|
captureLevel: TelemetryCaptureLevel;
|
|
236
246
|
pmVersion: string;
|
|
@@ -247,6 +257,7 @@ declare function buildCommandFinishPayload(params: {
|
|
|
247
257
|
commandResolution: TelemetryCommandResolution;
|
|
248
258
|
resolutionStage: TelemetryResolutionStage;
|
|
249
259
|
}): Record<string, unknown>;
|
|
260
|
+
/** Build error diagnostics at the selected capture level, hashing attempted inputs and redacting error text even in minimal mode. */
|
|
250
261
|
declare function buildCommandErrorPayload(params: {
|
|
251
262
|
captureLevel: TelemetryCaptureLevel;
|
|
252
263
|
pmVersion: string;
|
|
@@ -265,43 +276,62 @@ declare function buildCommandErrorPayload(params: {
|
|
|
265
276
|
errorCategory: TelemetryErrorCategory;
|
|
266
277
|
exitCode: number;
|
|
267
278
|
}): Record<string, unknown>;
|
|
279
|
+
/** Append an event as an independent queue transaction; compound capture transactions use the private writer while already holding the mutex. */
|
|
268
280
|
declare function enqueueTelemetryEvent(globalPmRoot: string, event: TelemetryEvent): Promise<void>;
|
|
281
|
+
/** Recover well-shaped event envelopes from JSONL while discarding malformed lines so one corrupt record cannot strand delivery. */
|
|
269
282
|
declare function parseQueueLines(raw: string): QueuedTelemetryEvent[];
|
|
283
|
+
/** Allow immediate retry when scheduling metadata is absent or malformed; otherwise compare its timestamp with the current time. */
|
|
270
284
|
declare function isDueForRetryAt(nextAttemptAfter: string | undefined): boolean;
|
|
285
|
+
/** Apply the shared due-time policy to an event envelope without altering its retry metadata. */
|
|
271
286
|
declare function isDueForRetry(entry: QueuedTelemetryEvent): boolean;
|
|
287
|
+
/** Convert a finite retention duration to a cutoff using at least one whole day; invalid durations fall back to one day. */
|
|
272
288
|
declare function retentionCutoffMs(retentionDays: number): number;
|
|
289
|
+
/** Expire only events with a valid occurrence timestamp before the cutoff; unknown dates do not establish expiration. */
|
|
273
290
|
declare function isExpiredQueueEntry(entry: QueuedTelemetryEvent, cutoffMs: number): boolean;
|
|
291
|
+
/** Preserve event order while removing oversized, expired, and attempt-exhausted envelopes; return the retained snapshot and removal count. */
|
|
274
292
|
declare function pruneExpiredQueueEntries(entries: QueuedTelemetryEvent[], retentionDays: number): {
|
|
275
293
|
entries: QueuedTelemetryEvent[];
|
|
276
294
|
prunedCount: number;
|
|
277
295
|
};
|
|
296
|
+
/** Atomically replace the event snapshot with bounded retries for transient filesystem failures; mutation callers must hold the queue mutex. */
|
|
278
297
|
declare function rewriteQueue(globalPmRoot: string, entries: QueuedTelemetryEvent[]): Promise<void>;
|
|
298
|
+
/** Recognize only access, busy, and permission filesystem codes as transient atomic-rewrite failures. */
|
|
279
299
|
declare function isRetryableQueueRewriteError(error: unknown): boolean;
|
|
300
|
+
/** Yield for the requested retry delay without synchronously blocking the process. */
|
|
280
301
|
declare function sleep(milliseconds: number): Promise<void>;
|
|
281
|
-
/**
|
|
302
|
+
/** Serialize an independent pending-span append; compound completion capture calls the private writer under its existing queue transaction. */
|
|
282
303
|
declare function enqueuePendingOtelSpan(globalPmRoot: string, request: {
|
|
283
304
|
endpoint: string;
|
|
284
305
|
payload: unknown;
|
|
285
306
|
}): Promise<void>;
|
|
307
|
+
/** Recover valid pending span envelopes from JSONL, skip malformed rows, and assign stable content-derived IDs to legacy entries for reconciliation. */
|
|
286
308
|
declare function parsePendingOtelSpanLines(raw: string): PendingOtelSpan[];
|
|
309
|
+
/** Compare valid enqueue timestamps with the retention cutoff; retain unknown or malformed dates rather than inventing an age. */
|
|
287
310
|
declare function isExpiredPendingOtelSpan(entry: PendingOtelSpan, cutoffMs: number): boolean;
|
|
311
|
+
/** Drop oversized, expired, and attempt-exhausted spans, then keep the newest entries within the pending-span cap and report every removal. */
|
|
288
312
|
declare function prunePendingOtelSpans(entries: PendingOtelSpan[], retentionDays: number): {
|
|
289
313
|
entries: PendingOtelSpan[];
|
|
290
314
|
prunedCount: number;
|
|
291
315
|
};
|
|
316
|
+
/** Atomically replace the span snapshot, retrying transient filesystem contention; callers coordinate mutations with the queue mutex. */
|
|
292
317
|
declare function rewritePendingOtelSpans(globalPmRoot: string, entries: PendingOtelSpan[]): Promise<void>;
|
|
293
|
-
/** Drain the pending OTLP span queue and POST due spans to their traces endpoint. Runs only inside the flush worker (detached child) or the inline test path, so the foreground command never makes OTLP network calls. Failures increment per-span attempts with backoff and are retried by a later flush; runtime state records OTLP export diagnostics for `pm health` (GH-205). */
|
|
294
318
|
/** Re-read the spans queue under the mutation serializer and rewrite it with the processed spans removed/updated by id, preserving any spans a concurrent foreground process appended during the (network) flush window. `succeededIds` are dropped; `failedUpdates` patch attempts/next_attempt_after by id; all other (incl. newly-appended) entries are retained, then pruned. Returns the count of spans left in the queue. Mirrors removeFlushedEntriesFromCurrentQueue. */
|
|
295
319
|
declare function reconcilePendingOtelSpansAfterFlush(globalPmRoot: string, retentionDays: number, succeededIds: ReadonlySet<string>, failedUpdates: ReadonlyMap<string, {
|
|
296
320
|
attempts: number;
|
|
297
321
|
next_attempt_after: string;
|
|
298
322
|
}>): Promise<number>;
|
|
323
|
+
/** POST due spans outside the mutation mutex, then reconcile successes and retry metadata against the current queue; publish export diagnostics for health inspection. */
|
|
299
324
|
declare function flushPendingOtelSpans(globalPmRoot: string, retentionDays: number): Promise<void>;
|
|
300
325
|
/** Flush both telemetry artifacts under the same worker invocation: the event ingest queue and the pending OTLP span queue. Used by the detached flush worker and the inline (test) path so OTLP export always happens off the foreground command's critical path. */
|
|
301
326
|
declare function flushTelemetryArtifacts(globalPmRoot: string, endpoint: string, retentionDays: number): Promise<void>;
|
|
302
|
-
|
|
327
|
+
export { withQueueMutation as withTelemetryQueueMutation };
|
|
328
|
+
/** Serialize complete queue transactions across processes. The per-acquisition wait defaults to five seconds for maintenance; foreground capture supplies a shorter budget. PM_LOCK_WAIT_MS remains an explicit override. Never hold the lock during network I/O. */
|
|
329
|
+
declare function withQueueMutation<T>(operation: () => Promise<T>, globalPmRoot?: string, waitMs?: number): Promise<T>;
|
|
330
|
+
/** Read the current event snapshot, treating a missing or blank queue as empty and dropping malformed records through the shared parser. */
|
|
303
331
|
declare function readCurrentQueueEntries(globalPmRoot: string): Promise<QueuedTelemetryEvent[]>;
|
|
332
|
+
/** Remove acknowledged event IDs and expired entries from a fresh locked snapshot, returning the retained queue including intervening appends. */
|
|
304
333
|
declare function removeFlushedEntriesFromCurrentQueue(globalPmRoot: string, flushedIds: ReadonlySet<string>, retentionDays: number): Promise<QueuedTelemetryEvent[]>;
|
|
334
|
+
/** Send one due event batch without holding the mutation mutex, then reconcile its result against the current queue and record delivery diagnostics. */
|
|
305
335
|
declare function flushQueue(globalPmRoot: string, endpoint: string, retentionDays: number): Promise<void>;
|
|
306
336
|
declare function acquireTelemetryFlushLock(globalPmRoot: string): Promise<boolean>;
|
|
307
337
|
declare function isFreshDirectoryLock(lockPath: string, staleMs: number): boolean;
|
|
@@ -380,12 +410,11 @@ export declare const _testOnly: {
|
|
|
380
410
|
};
|
|
381
411
|
declare function flushQueueWithProcessLock(globalPmRoot: string, endpoint: string, retentionDays: number): Promise<void>;
|
|
382
412
|
declare function scheduleTelemetryFlush(globalPmRoot: string, endpoint: string, retentionDays: number): void;
|
|
383
|
-
/**
|
|
413
|
+
/** Best-effort drain of event and span queues when both process consent and persisted settings permit delivery. */
|
|
384
414
|
export declare function flushTelemetryQueueNow(globalPmRoot?: string): Promise<void>;
|
|
385
|
-
/**
|
|
415
|
+
/** Atomically validate consent, initialize identity, and capture an invocation; defer sampled reads until their outcome determines pair retention and schedule delivery after releasing the mutex. */
|
|
386
416
|
export declare function startTelemetryCommand(context: TelemetryCommandContext): Promise<ActiveTelemetryCommand | null>;
|
|
387
|
-
/**
|
|
417
|
+
/** Complete an invocation only while process consent, saved consent, and its installation identity still agree; retain failed reads and weight selected successful pairs. */
|
|
388
418
|
export declare function finishTelemetryCommand(activeCommand: ActiveTelemetryCommand | null, outcome: TelemetryCommandOutcome): Promise<void>;
|
|
389
|
-
/**
|
|
419
|
+
/** Atomically validate consent and append a sanitized command error with its installation identity; schedule delivery only after releasing the queue mutex. */
|
|
390
420
|
export declare function emitTelemetryErrorEvent(context: TelemetryErrorEventContext): Promise<void>;
|
|
391
|
-
export {};
|