@ironbee-ai/cli 0.30.0 → 0.32.0

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.
Files changed (125) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/analytics/claude/emit.js +1 -1
  3. package/dist/analytics/claude/state.js +1 -1
  4. package/dist/analytics/codex/events-emit.js +2 -2
  5. package/dist/analytics/codex/subagent-transcripts.js +3 -3
  6. package/dist/clients/claude/agents/ironbee-scenario.md +4 -1
  7. package/dist/clients/claude/agents/ironbee-verifier.md +21 -3
  8. package/dist/clients/claude/hooks/activity-end.js +1 -1
  9. package/dist/clients/claude/hooks/activity-start.js +1 -1
  10. package/dist/clients/claude/hooks/clear-verdict.js +1 -1
  11. package/dist/clients/claude/hooks/require-verdict.js +2 -2
  12. package/dist/clients/claude/hooks/require-verification.js +4 -4
  13. package/dist/clients/claude/hooks/session-end.js +1 -1
  14. package/dist/clients/claude/hooks/session-start.js +4 -4
  15. package/dist/clients/claude/hooks/session-status.js +2 -2
  16. package/dist/clients/claude/hooks/subagent-start.js +1 -1
  17. package/dist/clients/claude/hooks/subagent-stop.js +1 -1
  18. package/dist/clients/claude/hooks/track-action-monitor.js +1 -1
  19. package/dist/clients/claude/hooks/track-action.js +1 -1
  20. package/dist/clients/claude/hooks/verify-gate.js +4 -4
  21. package/dist/clients/claude/index.js +4 -4
  22. package/dist/clients/claude/platforms/scenario.android.md +1 -0
  23. package/dist/clients/claude/platforms/scenario.terminal.md +26 -0
  24. package/dist/clients/claude/platforms/skill.android.md +4 -0
  25. package/dist/clients/claude/platforms/skill.browser.md +1 -1
  26. package/dist/clients/claude/platforms/skill.terminal.md +62 -0
  27. package/dist/clients/claude/process-analytics.js +1 -1
  28. package/dist/clients/claude/statusline-toggle.js +2 -2
  29. package/dist/clients/codex/agents/ironbee-scenario.md +3 -0
  30. package/dist/clients/codex/agents/ironbee-verifier.md +20 -2
  31. package/dist/clients/codex/commands/ironbee-manage-scenario/SKILL.main.md +3 -0
  32. package/dist/clients/codex/commands/ironbee-search-scenario/SKILL.main.md +3 -0
  33. package/dist/clients/codex/commands/ironbee-sync-scenario/SKILL.main.md +3 -0
  34. package/dist/clients/codex/commands/ironbee-verify/SKILL.main.md +3 -0
  35. package/dist/clients/codex/hooks/activity-end.js +1 -1
  36. package/dist/clients/codex/hooks/activity-start.js +1 -1
  37. package/dist/clients/codex/hooks/clear-verdict.js +3 -3
  38. package/dist/clients/codex/hooks/require-verdict.js +2 -2
  39. package/dist/clients/codex/hooks/require-verification.js +3 -3
  40. package/dist/clients/codex/hooks/session-start.js +3 -3
  41. package/dist/clients/codex/hooks/subagent-start.js +1 -1
  42. package/dist/clients/codex/hooks/subagent-stop.js +1 -1
  43. package/dist/clients/codex/hooks/track-action-monitor.js +1 -1
  44. package/dist/clients/codex/hooks/track-action-pre.js +1 -1
  45. package/dist/clients/codex/hooks/track-action.js +1 -1
  46. package/dist/clients/codex/hooks/verify-gate.js +1 -1
  47. package/dist/clients/codex/index.js +2 -2
  48. package/dist/clients/codex/platforms/command-verify.android.md +1 -0
  49. package/dist/clients/codex/platforms/command-verify.terminal.md +61 -0
  50. package/dist/clients/codex/platforms/rule.android.md +2 -1
  51. package/dist/clients/codex/platforms/rule.terminal.md +31 -0
  52. package/dist/clients/codex/platforms/scenario.android.md +1 -0
  53. package/dist/clients/codex/platforms/scenario.terminal.md +36 -0
  54. package/dist/clients/codex/platforms/skill.android.md +4 -0
  55. package/dist/clients/codex/platforms/skill.browser.md +1 -1
  56. package/dist/clients/codex/platforms/skill.terminal.md +57 -0
  57. package/dist/clients/codex/process-analytics.js +2 -2
  58. package/dist/clients/codex/rules/ironbee-verification.main.md +3 -0
  59. package/dist/clients/codex/skills/ironbee-verification.main.md +3 -0
  60. package/dist/clients/codex/thread-map.js +1 -1
  61. package/dist/clients/codex/util.js +44 -31
  62. package/dist/clients/cursor/commands/ironbee-manage-scenario/SKILL.md +3 -0
  63. package/dist/clients/cursor/commands/ironbee-search-scenario/SKILL.md +3 -0
  64. package/dist/clients/cursor/commands/ironbee-sync-scenario/SKILL.md +3 -0
  65. package/dist/clients/cursor/commands/ironbee-verify/SKILL.md +3 -0
  66. package/dist/clients/cursor/hooks/activity-end.js +1 -1
  67. package/dist/clients/cursor/hooks/activity-start.js +1 -1
  68. package/dist/clients/cursor/hooks/clear-verdict.js +1 -1
  69. package/dist/clients/cursor/hooks/require-verdict.js +2 -2
  70. package/dist/clients/cursor/hooks/require-verification.js +3 -3
  71. package/dist/clients/cursor/hooks/session-end.js +1 -1
  72. package/dist/clients/cursor/hooks/session-start.js +4 -4
  73. package/dist/clients/cursor/hooks/track-action-monitor.js +1 -1
  74. package/dist/clients/cursor/hooks/track-action.js +1 -1
  75. package/dist/clients/cursor/hooks/verify-gate.js +1 -1
  76. package/dist/clients/cursor/index.js +1 -1
  77. package/dist/clients/cursor/platforms/command-verify.android.md +1 -0
  78. package/dist/clients/cursor/platforms/command-verify.terminal.md +61 -0
  79. package/dist/clients/cursor/platforms/rule.android.md +2 -1
  80. package/dist/clients/cursor/platforms/rule.terminal.md +31 -0
  81. package/dist/clients/cursor/platforms/scenario.android.md +1 -0
  82. package/dist/clients/cursor/platforms/scenario.terminal.md +29 -0
  83. package/dist/clients/cursor/platforms/skill.android.md +4 -0
  84. package/dist/clients/cursor/platforms/skill.browser.md +1 -1
  85. package/dist/clients/cursor/platforms/skill.terminal.md +54 -0
  86. package/dist/clients/cursor/rules/ironbee-verification.mdc +3 -0
  87. package/dist/clients/cursor/skills/ironbee-verification.md +9 -0
  88. package/dist/commands/config.js +2 -2
  89. package/dist/commands/hook.js +10 -10
  90. package/dist/commands/import.js +3 -3
  91. package/dist/commands/install.js +1 -1
  92. package/dist/commands/process-job-file.js +1 -1
  93. package/dist/commands/queue.js +16 -16
  94. package/dist/commands/scenario.js +1 -1
  95. package/dist/commands/status.js +1 -1
  96. package/dist/commands/terminal.js +1 -0
  97. package/dist/commands/uninstall.js +1 -1
  98. package/dist/commands/verify.js +2 -2
  99. package/dist/hooks/core/actions.js +7 -7
  100. package/dist/hooks/core/session-state.js +1 -1
  101. package/dist/hooks/core/verification-context.js +19 -15
  102. package/dist/hooks/core/verify-gate.js +25 -20
  103. package/dist/import/claude/events/tool-call.js +1 -1
  104. package/dist/import/codex/events/tool-call.js +1 -1
  105. package/dist/import/marker.js +2 -2
  106. package/dist/import/skip.js +1 -1
  107. package/dist/index.js +1 -1
  108. package/dist/lib/config.js +1 -1
  109. package/dist/lib/install-version.js +1 -1
  110. package/dist/lib/platform-section.js +5 -4
  111. package/dist/lib/runtime-paths.js +1 -0
  112. package/dist/lib/scenario-staleness.js +1 -1
  113. package/dist/otel/claude/daemon/process.js +1 -1
  114. package/dist/otel/claude/daemon/reprocess.js +1 -1
  115. package/dist/otel/claude/daemon/response-usage.js +2 -2
  116. package/dist/queue/drain.js +1 -1
  117. package/dist/queue/flush.js +1 -1
  118. package/dist/queue/paths.js +1 -1
  119. package/dist/queue/process-file.js +2 -2
  120. package/dist/queue/spawn.js +1 -1
  121. package/dist/tui/config/schema.js +1 -1
  122. package/dist/tui/platforms/area.js +2 -2
  123. package/dist/tui/queue/read.js +4 -4
  124. package/dist/tui/sessions/read.js +2 -2
  125. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var N=Object.defineProperty;var t=(r,n)=>N(r,"name",{value:n,configurable:!0});var i=require("commander"),c=require("fs"),l=require("path"),m=require("./commands/install"),g=require("./commands/uninstall"),p=require("./commands/update"),f=require("./commands/hook"),C=require("./commands/status"),u=require("./commands/verify"),b=require("./commands/queue"),v=require("./commands/process-job-file"),y=require("./clients/codex/cli"),h=require("./commands/browser"),$=require("./commands/node"),j=require("./commands/backend"),w=require("./commands/android"),I=require("./commands/verification"),k=require("./commands/telemetry"),B=require("./commands/privacy"),F=require("./commands/config"),T=require("./tui"),q=require("./commands/register"),A=require("./commands/unregister"),L=require("./commands/import"),R=require("./clients/claude/cli"),S=require("./commands/login"),U=require("./commands/scenario"),x=require("./queue"),P=require("./lib/icon"),s=require("./lib/version"),e=require("./lib/output");const d=JSON.parse((0,c.readFileSync)((0,l.join)(__dirname,"../package.json"),"utf-8"));(0,x.registerQueueHandlers)();const o=new i.Command;o.name("ironbee").description(d.description).version(d.version),o.addCommand(S.loginCommand),o.addCommand(m.installCommand),o.addCommand(g.uninstallCommand),o.addCommand(p.updateCommand),o.addCommand(C.statusCommand),o.addCommand(u.verifyCommand),o.addCommand(b.queueCommand),o.addCommand(h.browserCommand),o.addCommand($.nodeCommand),o.addCommand(j.backendCommand),o.addCommand(w.androidCommand),o.addCommand(I.verificationCommand),o.addCommand(k.telemetryCommand),o.addCommand(B.privacyCommand),o.addCommand(R.claudeCommand),o.addCommand(y.codexCommand),o.addCommand(F.configCommand),o.addCommand(T.tuiCommand),o.addCommand(q.registerCommand),o.addCommand(A.unregisterCommand),o.addCommand(L.importCommand),o.addCommand(U.scenarioCommand),o.addCommand(v.processJobFileCommand),o.addCommand(f.hookCommand);const O=process.argv[2]==="hook"||process.argv[2]==="process-job-file"||process.argv[2]==="claude"&&process.argv[3]==="process-analytics"||process.argv[2]==="codex"&&process.argv[3]==="process-analytics"||process.argv[2]==="claude"&&process.argv[3]==="otel"&&process.argv[4]==="run";if(process.argv.length===2){(0,P.printBanner)(),console.log(),console.log(` ${e.pc.bold("IronBee CLI")} ${e.pc.dim(`v${(0,s.getLocalVersion)()}`)}`),console.log(` ${e.pc.dim(d.description)}`),console.log(),console.log(` ${e.pc.bold(e.pc.cyan("Usage:"))} ${e.pc.green("ironbee")} ${e.pc.dim("<command> [options]")}`),console.log(),console.log(` ${e.pc.bold(e.pc.cyan("Commands:"))}`);const r=[{name:"install",args:"[project-dir]",desc:"Install hooks + guidance files into a project (--all: every registered project)"},{name:"uninstall",args:"[project-dir]",desc:"Remove IronBee from a project (--all: every registered project)"},{name:"update",args:"",desc:"Update IronBee CLI to the latest version"},{name:"tui",args:"[area]",desc:"Interactive full-screen UI (config \xB7 platforms \xB7 projects \xB7 sessions \xB7 queue \xB7 import)"},{name:"status",args:"[project-dir]",desc:"Show verification status for active sessions"},{name:"verify",args:"[session-id]",desc:"Dry-run verdict validation"},{name:"browser",args:"<enable|disable>",desc:"Toggle the browser verification cycle (default-on)"},{name:"node",args:"<enable|disable>",desc:"Toggle the Node.js runtime debug cycle (opt-in)"},{name:"backend",args:"<enable|disable>",desc:"Toggle the backend protocol cycle (opt-in)"},{name:"android",args:"<enable|disable>",desc:"Toggle the Android mobile verification cycle (opt-in)"},{name:"verification",args:"<enable|disable>",desc:"Master toggle (enable = enforce; disable = monitoring-only)"},{name:"telemetry",args:"<enable|disable>",desc:"Anonymous PostHog telemetry toggle"},{name:"privacy",args:"<enable|disable>",desc:"Privacy mode \u2014 redact devtools tool detail / screenshots / recordings from collector"},{name:"claude statusline",args:"<enable|disable>",desc:"Claude statusline integration (Claude-only)"},{name:"claude otel",args:"<run|status|stop|retry>",desc:"Claude OTEL collector daemon (Claude-only)"},{name:"config",args:"<get|set|unset|list>",desc:"Read or write project / global / local config"},{name:"register",args:"[-p <dir>]",desc:"Add a project to the user-home inventory (no artifact writes)"},{name:"unregister",args:"[-p <dir>]",desc:"Remove a project from the inventory (no artifact writes)"},{name:"queue",args:"<status|drain|\u2026>",desc:"Inspect / drain the background job queue"},{name:"import",args:"",desc:"Import historical Claude sessions to the collector"}],n=t(a=>a.args.length>0?`${a.name} ${a.args}`:a.name,"term"),H=Math.max(...r.map(a=>n(a).length));for(const a of r){const J=a.args.length>0?`${e.pc.green(a.name)} ${e.pc.dim(a.args)}`:e.pc.green(a.name),M=" ".repeat(H-n(a).length);console.log(` ${J}${M} ${a.desc}`)}console.log(),console.log(` ${e.pc.dim("Run")} ${e.pc.cyan("ironbee <command> --help")} ${e.pc.dim("for more info on a command.")}`),console.log()}else O?o.parse(process.argv):(async()=>{await o.parseAsync(process.argv),(0,s.checkForUpdates)().catch(()=>{});const r=process.argv[2];r==="install"||r==="uninstall"||r==="update"||await(0,m.syncSchemaIfChanged)()})();
2
+ "use strict";var O=Object.defineProperty;var t=(r,n)=>O(r,"name",{value:n,configurable:!0});var i=require("commander"),c=require("fs"),l=require("path"),m=require("./commands/install"),g=require("./commands/uninstall"),p=require("./commands/update"),f=require("./commands/hook"),C=require("./commands/status"),u=require("./commands/verify"),b=require("./commands/queue"),v=require("./commands/process-job-file"),y=require("./clients/codex/cli"),h=require("./commands/browser"),$=require("./commands/node"),j=require("./commands/backend"),w=require("./commands/android"),I=require("./commands/terminal"),k=require("./commands/verification"),T=require("./commands/telemetry"),B=require("./commands/privacy"),F=require("./commands/config"),q=require("./tui"),A=require("./commands/register"),L=require("./commands/unregister"),R=require("./commands/import"),S=require("./clients/claude/cli"),U=require("./commands/login"),x=require("./commands/scenario"),P=require("./queue"),H=require("./lib/icon"),s=require("./lib/version"),e=require("./lib/output");const d=JSON.parse((0,c.readFileSync)((0,l.join)(__dirname,"../package.json"),"utf-8"));(0,P.registerQueueHandlers)();const o=new i.Command;o.name("ironbee").description(d.description).version(d.version),o.addCommand(U.loginCommand),o.addCommand(m.installCommand),o.addCommand(g.uninstallCommand),o.addCommand(p.updateCommand),o.addCommand(C.statusCommand),o.addCommand(u.verifyCommand),o.addCommand(b.queueCommand),o.addCommand(h.browserCommand),o.addCommand($.nodeCommand),o.addCommand(j.backendCommand),o.addCommand(w.androidCommand),o.addCommand(I.terminalCommand),o.addCommand(k.verificationCommand),o.addCommand(T.telemetryCommand),o.addCommand(B.privacyCommand),o.addCommand(S.claudeCommand),o.addCommand(y.codexCommand),o.addCommand(F.configCommand),o.addCommand(q.tuiCommand),o.addCommand(A.registerCommand),o.addCommand(L.unregisterCommand),o.addCommand(R.importCommand),o.addCommand(x.scenarioCommand),o.addCommand(v.processJobFileCommand),o.addCommand(f.hookCommand);const _=process.argv[2]==="hook"||process.argv[2]==="process-job-file"||process.argv[2]==="claude"&&process.argv[3]==="process-analytics"||process.argv[2]==="codex"&&process.argv[3]==="process-analytics"||process.argv[2]==="claude"&&process.argv[3]==="otel"&&process.argv[4]==="run";if(process.argv.length===2){(0,H.printBanner)(),console.log(),console.log(` ${e.pc.bold("IronBee CLI")} ${e.pc.dim(`v${(0,s.getLocalVersion)()}`)}`),console.log(` ${e.pc.dim(d.description)}`),console.log(),console.log(` ${e.pc.bold(e.pc.cyan("Usage:"))} ${e.pc.green("ironbee")} ${e.pc.dim("<command> [options]")}`),console.log(),console.log(` ${e.pc.bold(e.pc.cyan("Commands:"))}`);const r=[{name:"install",args:"[project-dir]",desc:"Install hooks + guidance files into a project (--all: every registered project)"},{name:"uninstall",args:"[project-dir]",desc:"Remove IronBee from a project (--all: every registered project)"},{name:"update",args:"",desc:"Update IronBee CLI to the latest version"},{name:"tui",args:"[area]",desc:"Interactive full-screen UI (config \xB7 platforms \xB7 projects \xB7 sessions \xB7 queue \xB7 import)"},{name:"status",args:"[project-dir]",desc:"Show verification status for active sessions"},{name:"verify",args:"[session-id]",desc:"Dry-run verdict validation"},{name:"browser",args:"<enable|disable>",desc:"Toggle the browser verification cycle (default-on)"},{name:"node",args:"<enable|disable>",desc:"Toggle the Node.js runtime debug cycle (opt-in)"},{name:"backend",args:"<enable|disable>",desc:"Toggle the backend protocol cycle (opt-in)"},{name:"android",args:"<enable|disable>",desc:"Toggle the Android mobile verification cycle (opt-in)"},{name:"terminal",args:"<enable|disable>",desc:"Toggle the terminal interaction verification cycle (opt-in)"},{name:"verification",args:"<enable|disable>",desc:"Master toggle (enable = enforce; disable = monitoring-only)"},{name:"telemetry",args:"<enable|disable>",desc:"Anonymous PostHog telemetry toggle"},{name:"privacy",args:"<enable|disable>",desc:"Privacy mode \u2014 redact devtools tool detail / screenshots / recordings from collector"},{name:"claude statusline",args:"<enable|disable>",desc:"Claude statusline integration (Claude-only)"},{name:"claude otel",args:"<run|status|stop|retry>",desc:"Claude OTEL collector daemon (Claude-only)"},{name:"config",args:"<get|set|unset|list>",desc:"Read or write project / global / local config"},{name:"register",args:"[-p <dir>]",desc:"Add a project to the user-home inventory (no artifact writes)"},{name:"unregister",args:"[-p <dir>]",desc:"Remove a project from the inventory (no artifact writes)"},{name:"queue",args:"<status|drain|\u2026>",desc:"Inspect / drain the background job queue"},{name:"import",args:"",desc:"Import historical Claude sessions to the collector"}],n=t(a=>a.args.length>0?`${a.name} ${a.args}`:a.name,"term"),J=Math.max(...r.map(a=>n(a).length));for(const a of r){const M=a.args.length>0?`${e.pc.green(a.name)} ${e.pc.dim(a.args)}`:e.pc.green(a.name),N=" ".repeat(J-n(a).length);console.log(` ${M}${N} ${a.desc}`)}console.log(),console.log(` ${e.pc.dim("Run")} ${e.pc.cyan("ironbee <command> --help")} ${e.pc.dim("for more info on a command.")}`),console.log()}else _?o.parse(process.argv):(async()=>{await o.parseAsync(process.argv),(0,s.checkForUpdates)().catch(()=>{});const r=process.argv[2];r==="install"||r==="uninstall"||r==="update"||await(0,m.syncSchemaIfChanged)()})();
@@ -1 +1 @@
1
- "use strict";var _=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var ge=Object.prototype.hasOwnProperty;var o=(n,e)=>_(n,"name",{value:e,configurable:!0});var de=(n,e)=>{for(var t in e)_(n,t,{get:e[t],enumerable:!0})},be=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of fe(e))!ge.call(n,i)&&i!==t&&_(n,i,{get:()=>e[i],enumerable:!(r=ue(e,i))||r.enumerable});return n};var pe=n=>be(_({},"__esModule",{value:!0}),n);var Sn={};de(Sn,{ALL_CYCLES:()=>Ee,CONFIG_TARGETS_BY_PRECEDENCE:()=>je,CYCLES_ENABLED_BY_DEFAULT:()=>P,CYCLE_DEFAULT_VERIFY_PATTERNS:()=>$,CYCLE_TOOL_PREFIXES:()=>_e,CYCLE_TO_SERVER:()=>ye,DEFAULT_ANDROID_ALWAYS_REQUIRED:()=>G,DEFAULT_ANDROID_EVIDENCE_PATHS:()=>Q,DEFAULT_ANDROID_VERIFY_PATTERNS:()=>U,DEFAULT_BACKEND_ALWAYS_REQUIRED:()=>H,DEFAULT_BACKEND_EVIDENCE_PATHS:()=>W,DEFAULT_BACKEND_VERIFY_PATTERNS:()=>V,DEFAULT_BROWSER_ALWAYS_REQUIRED:()=>K,DEFAULT_BROWSER_VERIFY_PATTERNS:()=>M,DEFAULT_IGNORED_VERIFY_PATTERNS:()=>q,DEFAULT_NODE_ALWAYS_REQUIRED:()=>Y,DEFAULT_NODE_EVIDENCE_PATHS:()=>X,DEFAULT_NODE_VERIFY_PATTERNS:()=>F,DEFAULT_OAUTH_USAGE_TTL_SECONDS:()=>ee,DEFAULT_OTEL_EMIT_MIN_INTERVAL_SECONDS:()=>re,DEFAULT_OTEL_ENSURE_MIN_INTERVAL_SECONDS:()=>oe,DEFAULT_OTEL_IDLE_TIMEOUT_SECONDS:()=>te,DEFAULT_OTEL_PORT:()=>ne,DEFAULT_VERIFICATION_CONTEXT_COMMIT_DEPTH:()=>ae,DEFAULT_VERIFICATION_CONTEXT_MAX_BYTES:()=>se,ENV_OVERRIDES:()=>R,OPTIONAL_CYCLES:()=>T,applyEnvOverrides:()=>z,findActiveEnvOverride:()=>Be,getActiveCycles:()=>J,getAnalyticsEmitOnStopMinIntervalSeconds:()=>On,getAndroidDevToolsMcpEntry:()=>Ze,getAutoVerifyEnabled:()=>ie,getBackendDevToolsMcpEntry:()=>Je,getCaptureFileChangeset:()=>xn,getClaudeOauthAccessEnabled:()=>an,getClaudeOauthAccessUsageTtlSeconds:()=>fn,getCodexVerifierMode:()=>cn,getConfigLayerPaths:()=>w,getMaxChangesetBytes:()=>wn,getMaxRetries:()=>en,getMcpServerEntry:()=>Qe,getNodeDevToolsMcpEntry:()=>ze,getOTELEmitMinIntervalSeconds:()=>En,getOTELEnsureMinIntervalSeconds:()=>pn,getOTELIdleTimeoutSeconds:()=>bn,getOTELPort:()=>dn,getPrivacyEnabled:()=>le,getRequiredToolsConfig:()=>Pe,getStatusLineEmitMinIntervalSeconds:()=>sn,getStatusLineRefreshInterval:()=>yn,getStatusLineRenderDefault:()=>rn,getTargetConfigPath:()=>Oe,getTelemetryEnabled:()=>ce,getVerificationContextCommitDepth:()=>An,getVerificationContextEnabled:()=>Cn,getVerificationContextMaxBytes:()=>vn,getVerificationContextSource:()=>mn,getVerificationEnabled:()=>O,getVerificationMode:()=>Tn,getVerificationModel:()=>Ae,getVerificationStrict:()=>_n,isAnalyticsApiRequestEventsEnabled:()=>Bn,isAnalyticsEmitOnStopEnabled:()=>jn,isAnalyticsEnabled:()=>Rn,isAnalyticsStepEventsEnabled:()=>hn,isAnalyticsTurnEventsEnabled:()=>kn,isAutoModeAllowlistEnabled:()=>ln,isClaudeTrustWorkspaceEnabled:()=>un,isCollectorConfigured:()=>j,isCycleEnabled:()=>De,isCyclePatternsActive:()=>Z,isIgnoredVerifyPath:()=>In,isJobQueueEnabled:()=>nn,isOTELEnabled:()=>gn,isRecordingEnabled:()=>tn,isSessionStatusEnabled:()=>on,loadConfig:()=>c,matchesAny:()=>E,requiresVerification:()=>Ne,resolveConfigTargetFromFlags:()=>ke,resolveIgnoredVerifyPatterns:()=>x});module.exports=pe(Sn);var y=require("fs"),p=require("path"),I=require("os"),D=require("./logger");const T=["node","backend","android"],Ee=["browser",...T],P=new Set(["browser"]),ye={browser:"browser-devtools",node:"node-devtools",backend:"backend-devtools",android:"android-devtools"},_e={browser:"bdt_",node:"ndt_",backend:"bedt_",android:"adt_"},M=["*.ts","*.tsx","*.js","*.jsx","*.mjs","*.cjs","*.vue","*.svelte","*.html","*.htm","*.css","*.scss","*.sass","*.less","*.styl","*.py","*.rb","*.erb","*.go","*.rs","*.java","*.kt","*.kts","*.swift","*.c","*.cpp","*.h","*.hpp","*.cs","*.php","*.dart","*.ex","*.exs","*.erl","*.lua","*.r","*.R","*.scala","*.clj","*.cljs","*.zig","*.nim","*.hbs","*.ejs","*.pug","*.jade","*.astro"],F=["server/**/*.{ts,js,mjs,cjs}","src/server/**/*.{ts,js,mjs,cjs}","backend/**/*.{ts,js,mjs,cjs}","api/**/*.{ts,js,mjs,cjs}","src/api/**/*.{ts,js,mjs,cjs}","pages/api/**/*.{ts,js,mjs,cjs}","app/api/**/*.{ts,js,mjs,cjs}","routes/**/*.{ts,js,mjs,cjs}","**/server.{ts,js,mjs,cjs}"],V=["server/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","src/server/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","backend/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","api/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","src/api/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","pages/api/**/*.{ts,js,mjs,cjs}","app/api/**/*.{ts,js,mjs,cjs}","routes/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","controllers/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","handlers/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","services/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","**/server.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","**/main.{go,py,java,rb,kt,scala}"],U=["android/**/*.{kt,java}","app/src/**/*.{kt,java}","mobile/**/*.{kt,java}","src/main/kotlin/**/*.kt","src/main/java/**/*.java","**/*.{kt,java}","**/res/**/*.xml","**/AndroidManifest.xml"],$={browser:M,node:F,backend:V,android:U},q=["**/*.spec.*","**/*.test.*","**/__tests__/**","**/__mocks__/**"];function x(n){const e=n.ignoredVerifyPatterns??[];return[...q,...e]}o(x,"resolveIgnoredVerifyPatterns");const K=["bdt_navigation_go-to","bdt_content_take-screenshot","bdt_a11y_take-aria-snapshot","bdt_o11y_get-console-messages"],Y=["ndt_debug_connect"],X=[{name:"probe",allOf:[{anyOf:["ndt_debug_put-tracepoint","ndt_debug_put-logpoint","ndt_debug_put-exceptionpoint"]},"ndt_debug_get-probe-snapshots"]},{name:"log",allOf:["ndt_debug_get-logs"]}],H=[],W=[{name:"protocol-call",allOf:[{anyOf:["bedt_request_http","bedt_request_grpc","bedt_request_graphql","bedt_request_websocket-open","bedt_request_replay"]}]},{name:"log-evidence",allOf:["bedt_log_register-source",{anyOf:["bedt_log_read","bedt_log_read-multi","bedt_log_follow"]}]},{name:"db-evidence",allOf:["bedt_db_connect",{anyOf:["bedt_db_query","bedt_db_describe-table","bedt_db_list-tables","bedt_db_snapshot","bedt_db_diff","bedt_db_get-changes"]}]}],G=["adt_device_connect"],Q=[{name:"device-evidence",allOf:[{anyOf:["adt_device_launch-app","adt_interaction_tap","adt_interaction_double-tap","adt_interaction_long-press","adt_interaction_input-text","adt_interaction_swipe","adt_interaction_scroll","adt_interaction_press-key","adt_interaction_deep-link"]},"adt_content_take-screenshot","adt_a11y_take-ui-snapshot"]},{name:"log-evidence",allOf:[{anyOf:["adt_o11y_log-read","adt_o11y_log-follow"]}]}],Ce=3;function h(n){if(!(0,y.existsSync)(n))return{};try{return JSON.parse((0,y.readFileSync)(n,"utf-8"))}catch(e){return D.logger.debug(`failed to parse config ${n}: ${e}`),{}}}o(h,"loadJsonFile");function me(n,e){if(!Object.prototype.hasOwnProperty.call(n,"verification"))return;const t=n.verification;if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`Invalid IronBee config in ${e}: 'verification' must be an object. Expected shape: { "enable": boolean }.`);const r=t;if(Object.prototype.hasOwnProperty.call(r,"enable")&&typeof r.enable!="boolean")throw new Error(`Invalid IronBee config in ${e}: 'verification.enable' must be boolean. Got ${typeof r.enable}.`);if(Object.prototype.hasOwnProperty.call(r,"auto")&&typeof r.auto!="boolean")throw new Error(`Invalid IronBee config in ${e}: 'verification.auto' must be boolean. Got ${typeof r.auto}.`);if(Object.prototype.hasOwnProperty.call(r,"strict")&&typeof r.strict!="boolean")throw new Error(`Invalid IronBee config in ${e}: 'verification.strict' must be boolean. Got ${typeof r.strict}.`);if(Object.prototype.hasOwnProperty.call(r,"model")){const i=r.model,s=typeof i=="string",l=i!==null&&typeof i=="object"&&!Array.isArray(i)&&Object.values(i).every(a=>typeof a=="string");if(!s&&!l)throw new Error(`Invalid IronBee config in ${e}: 'verification.model' must be a string (applies to all clients) or an object of string values (per-client, e.g. { "claude": "sonnet", "codex": "gpt-5.5" }). Got ${Array.isArray(i)?"array":typeof i}.`)}}o(me,"assertVerificationShape");function Ae(n,e){const t=n.verification?.model;if(typeof t=="string")return t.length>0?t:void 0;if(t&&typeof t=="object"){const r=t[e];return typeof r=="string"&&r.length>0?r:void 0}}o(Ae,"getVerificationModel");function ve(n,e){if(!Object.prototype.hasOwnProperty.call(n,"telemetry"))return;const t=n.telemetry;if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`Invalid IronBee config in ${e}: 'telemetry' must be an object. Expected shape: { "enable": boolean }.`);const r=t;if(Object.prototype.hasOwnProperty.call(r,"enable")&&typeof r.enable!="boolean")throw new Error(`Invalid IronBee config in ${e}: 'telemetry.enable' must be boolean. Got ${typeof r.enable}.`)}o(ve,"assertTelemetryShape");function Ie(n,e){if(!Object.prototype.hasOwnProperty.call(n,"privacy"))return;const t=n.privacy;if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`Invalid IronBee config in ${e}: 'privacy' must be an object. Expected shape: { "enable": boolean }.`);const r=t;if(Object.prototype.hasOwnProperty.call(r,"enable")&&typeof r.enable!="boolean")throw new Error(`Invalid IronBee config in ${e}: 'privacy.enable' must be boolean. Got ${typeof r.enable}.`)}o(Ie,"assertPrivacyShape");function C(n,e){if(!(n===void 0&&e===void 0))return{...n??{},...e??{}}}o(C,"mergeCycleConfig");function B(n,e){const t={...n,...e};return t.browser=C(n.browser,e.browser),t.node=C(n.node,e.node),t.backend=C(n.backend,e.backend),t.android=C(n.android,e.android),t.claude=we(n.claude,e.claude),t.codex=Re(n.codex,e.codex),t.verification=xe(n.verification,e.verification),t.verificationContext=Te(n.verificationContext,e.verificationContext),t}o(B,"mergeConfigLayers");function Te(n,e){if(!(n===void 0&&e===void 0))return{...n??{},...e??{}}}o(Te,"mergeVerificationContextConfig");function xe(n,e){if(!(n===void 0&&e===void 0))return{...n??{},...e??{}}}o(xe,"mergeVerificationConfig");function we(n,e){if(n===void 0&&e===void 0)return;const t={...n??{},...e??{}};return(n?.oauthAccess!==void 0||e?.oauthAccess!==void 0)&&(t.oauthAccess={...n?.oauthAccess??{},...e?.oauthAccess??{}}),(n?.autoModeAllowlist!==void 0||e?.autoModeAllowlist!==void 0)&&(t.autoModeAllowlist={...n?.autoModeAllowlist??{},...e?.autoModeAllowlist??{}}),t}o(we,"mergeClaudeConfig");function Re(n,e){if(n===void 0&&e===void 0)return;const t={...n??{},...e??{}};return(n?.verifier!==void 0||e?.verifier!==void 0)&&(t.verifier={...n?.verifier??{},...e?.verifier??{}}),t}o(Re,"mergeCodexConfig");function w(n){return{global:(0,p.join)((0,I.homedir)(),".ironbee","config.json"),project:n?(0,p.join)(n,".ironbee","config.json"):void 0,local:n?(0,p.join)(n,".ironbee","config.local.json"):void 0}}o(w,"getConfigLayerPaths");const je=["global","project","local"];function Oe(n,e){const t=w(e);if(n==="global")return t.global;if(n==="project"){if(t.project===void 0)throw new Error("Project layer requested but no projectDir was provided.");return t.project}if(t.local===void 0)throw new Error("Local layer requested but no projectDir was provided.");return t.local}o(Oe,"getTargetConfigPath");function ke(n){if(n.global===!0&&n.local===!0)throw new Error("Pass at most one of --global / --local.");return n.global===!0?"global":n.local===!0?"local":"project"}o(ke,"resolveConfigTargetFromFlags");function A(n){const e=h(n);return(0,y.existsSync)(n)&&(me(e,n),ve(e,n),Ie(e,n)),e}o(A,"loadAndValidateLayer");const R=[{envVar:"IRONBEE_API_KEY",configPath:"collector.apiKey"},{envVar:"IRONBEE_OAUTH_TOKEN",configPath:"collector.oauthToken"}];function he(n,e,t){const r=e.split(".");let i=n;for(let s=0;s<r.length-1;s++){const l=r[s],a=i[l];a!=null&&typeof a=="object"&&!Array.isArray(a)?i[l]={...a}:i[l]={},i=i[l]}i[r[r.length-1]]=t}o(he,"setAtConfigPath");function z(n){let e;for(const t of R){const r=process.env[t.envVar];if(r===void 0||r.length===0)continue;e===void 0&&(e={...n});const i=t.coerce?t.coerce(r):r;he(e,t.configPath,i)}return e??n}o(z,"applyEnvOverrides");function Be(n){for(const e of R){if(e.configPath!==n)continue;const t=process.env[e.envVar];if(t!==void 0&&t.length>0)return e}}o(Be,"findActiveEnvOverride");function c(n){const e=w(n),t=A(e.global),r=e.project?A(e.project):{},i=e.local?A(e.local):{},s=B(B(t,r),i);return z(s)}o(c,"loadConfig");function Se(n){let e=n.replace(/\{([^}]+)\}/g,(t,r)=>`(${r.split(",").map(i=>i.trim()).join("|")})`);return e=e.replace(/\*\*\//g,"\0DSS\0").replace(/\*\*/g,"\0DS\0").replace(/\*/g,"\0SS\0").replace(/\?/g,"\0QM\0"),e=e.replace(/[.+^$\\[\]]/g,"\\$&"),e=e.replace(/\x00DSS\x00/g,"(?:.*/)?").replace(/\x00DS\x00/g,".*").replace(/\x00SS\x00/g,"[^/]*").replace(/\x00QM\x00/g,"[^/]"),new RegExp(`(^|/)${e}$`)}o(Se,"globToRegExp");function E(n,e){const t=n.replace(/\\/g,"/");for(const r of e)if(Se(r).test(t))return!0;return!1}o(E,"matchesAny");function Le(n,e){if(e==="browser")return n.browser;if(e==="node")return n.node;if(e==="backend")return n.backend;if(e==="android")return n.android}o(Le,"getCycleBlock");function v(n,e){const t=Le(n,e);if(t!==void 0&&t.enable===!1)return[];const r=$[e]??[];if(t===void 0)return P.has(e)?[...r]:[];if(Array.isArray(t.verifyPatterns)&&t.verifyPatterns.length===0)return[];const i=t.verifyPatterns??r,s=t.additionalVerifyPatterns??[];return[...i,...s]}o(v,"getCyclePatterns");function J(n,e){const t=x(e);if(t.length>0&&E(n,t))return[];const r=[];E(n,v(e,"browser"))&&r.push("browser");for(const i of T){const s=v(e,i);s.length>0&&E(n,s)&&r.push(i)}return r}o(J,"getActiveCycles");function Ne(n,e){return J(n,e).length>0}o(Ne,"requiresVerification");function De(n,e){return O(n)?Z(n,e):!1}o(De,"isCycleEnabled");function Z(n,e){return v(n,e).length>0}o(Z,"isCyclePatternsActive");function Pe(n,e){let t,r;if(e==="browser"?(t=n.browser?.alwaysRequired??K,r=n.browser?.evidencePaths??[]):e==="node"?(t=n.node?.alwaysRequired??Y,r=n.node?.evidencePaths??X):e==="backend"?(t=n.backend?.alwaysRequired??H,r=n.backend?.evidencePaths??W):e==="android"?(t=n.android?.alwaysRequired??G,r=n.android?.evidencePaths??Q):(t=[],r=[]),t.length===0&&r.length===0)throw new Error(`Invalid required-tools config for cycle '${e}': both 'alwaysRequired' and 'evidencePaths' are empty. At least one must specify required tools.`);return{alwaysRequired:t,evidencePaths:r}}o(Pe,"getRequiredToolsConfig");const S="npx",Me="^0.13.2",L=["-y",`@ironbee-ai/devtools@${Me}`],Fe={TOOL_NAME_PREFIX:"bdt_",TOOL_INPUT_METADATA_ENABLE:"true",SCENARIOS_DIR:".ironbee/scenarios/bdt"},Ve={PLATFORM:"node",TOOL_NAME_PREFIX:"ndt_",TOOL_INPUT_METADATA_ENABLE:"true",SCENARIOS_DIR:".ironbee/scenarios/ndt"},Ue={PLATFORM:"backend",TOOL_NAME_PREFIX:"bedt_",TOOL_INPUT_METADATA_ENABLE:"true",SCENARIOS_DIR:".ironbee/scenarios/bedt"},$e={PLATFORM:"android",TOOL_NAME_PREFIX:"adt_",TOOL_INPUT_METADATA_ENABLE:"true",SCENARIOS_DIR:".ironbee/scenarios/adt"},qe={BROWSER_DEVTOOLS_INSTALL_CHROMIUM:"true"},Ke={},Ye={},Xe={};function He(n){return ce(n)?{}:{TELEMETRY_ENABLE:"false"}}o(He,"buildTelemetryEnv");function We(n){return le(n)?{COLLECTOR_EVENTS_TOOL_DETAILS_ENABLE:"false",COLLECTOR_ARTIFACTS_ENABLE:"false"}:{}}o(We,"buildPrivacyEnv");function Ge(n,e){if(!j(n))return{};const t=n.collector,i=h((0,p.join)((0,I.homedir)(),".ironbee","config.json")).collector??{},s=typeof i.oauthToken=="string"&&i.oauthToken.length>0,l=typeof i.apiKey=="string"&&i.apiKey.length>0;let a;t.oauthToken?a=s?"X-OAuth-Token=${file:~/.ironbee/config.json#collector.oauthToken}":`X-OAuth-Token=${t.oauthToken}`:a=l?"X-API-Key=${file:~/.ironbee/config.json#collector.apiKey}":`X-API-Key=${t.apiKey}`;const u={OTEL_ENABLE:"true",OTEL_EXPORTER_HTTP_URL:t.url,OTEL_EXPORTER_HTTP_HEADERS:a,OTEL_EXPORTER_TYPE:"otlp/http-protobuf"};return e==="browser"&&(u.OTEL_INSTRUMENTATION_USER_INTERACTION_EVENTS="change,input,click",u.BROWSER_HEADLESS_ENABLE="true"),u}o(Ge,"buildOTELEnv");function m(n,e,t,r,i){const s=Ge(n,i),l=He(n),a=We(n),u=n[e];if(u&&typeof u=="object"&&!Array.isArray(u)){const f=u;if(f.mcp&&typeof f.mcp=="object"&&!Array.isArray(f.mcp)){const g={...f.mcp},d={...s,...l,...a,...g.env??{},...t};return g.env=d,g}const k={};if(f.env&&typeof f.env=="object"&&!Array.isArray(f.env)){const g=f.env;for(const d of Object.keys(g))typeof g[d]=="string"&&(k[d]=g[d])}return{command:S,args:[...L],env:{...r,...s,...l,...a,...k,...t}}}return{command:S,args:[...L],env:{...r,...s,...l,...a,...t}}}o(m,"buildMcpEntry");function Qe(n){const e=c(n);return m(e,"browserDevTools",Fe,qe,"browser")}o(Qe,"getMcpServerEntry");function ze(n){const e=c(n);return m(e,"nodeDevTools",Ve,Ke,"node")}o(ze,"getNodeDevToolsMcpEntry");function Je(n){const e=c(n);return m(e,"backendDevTools",Ue,Ye,"backend")}o(Je,"getBackendDevToolsMcpEntry");function Ze(n){const e=c(n);return m(e,"androidDevTools",$e,Xe,"android")}o(Ze,"getAndroidDevToolsMcpEntry");function en(n){return typeof n.maxRetries=="number"&&n.maxRetries>0?n.maxRetries:Ce}o(en,"getMaxRetries");function j(n){if(process.env.IRONBEE_COLLECTOR==="false")return!1;const e=n.collector;if(!e||e.enable===!1||typeof e.url!="string"||e.url.length===0)return!1;const t=typeof e.oauthToken=="string"&&e.oauthToken.length>0,r=typeof e.apiKey=="string"&&e.apiKey.length>0;return!(!t&&!r)}o(j,"isCollectorConfigured");function nn(n){const e=c(n);return b(e,e.jobQueue)}o(nn,"isJobQueueEnabled");function tn(n){const e=c(n);return b(e,e.recording)}o(tn,"isRecordingEnabled");function on(n){return b(n,n.statusLine)}o(on,"isSessionStatusEnabled");function rn(n){const e=n.statusLine;return e!==void 0&&e.renderDefault===!0}o(rn,"getStatusLineRenderDefault");function sn(n){const e=n.statusLine?.emitMinIntervalSeconds;return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:10}o(sn,"getStatusLineEmitMinIntervalSeconds");const ee=60;function an(n){return n.claude?.oauthAccess?.enable!==!1}o(an,"getClaudeOauthAccessEnabled");function cn(n){return n.codex?.verifier?.mode==="main-agent"?"main-agent":"sub-agent"}o(cn,"getCodexVerifierMode");function ln(n){return n.claude?.autoModeAllowlist?.enable!==!1}o(ln,"isAutoModeAllowlistEnabled");function un(n){return n.claude?.trustWorkspace?.enable!==!1}o(un,"isClaudeTrustWorkspaceEnabled");function fn(n){const e=n.claude?.oauthAccess?.usageTtlSeconds;return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:ee}o(fn,"getClaudeOauthAccessUsageTtlSeconds");const ne=15986,te=600,oe=30,re=0;function gn(n){return b(n,n.otel)}o(gn,"isOTELEnabled");function dn(n){const e=n.otel?.port;return typeof e=="number"&&Number.isInteger(e)&&e>0&&e<65536?e:ne}o(dn,"getOTELPort");function bn(n){const e=n.otel?.idleTimeoutSeconds;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:te}o(bn,"getOTELIdleTimeoutSeconds");function pn(n){const e=n.otel?.ensureMinIntervalSeconds;return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:oe}o(pn,"getOTELEnsureMinIntervalSeconds");function En(n){const e=n.otel?.emitMinIntervalSeconds;return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:re}o(En,"getOTELEmitMinIntervalSeconds");function yn(n){const e=n.statusLine?.refreshInterval;if(typeof e=="number"&&Number.isFinite(e)&&e>=1)return e}o(yn,"getStatusLineRefreshInterval");function b(n,e){return e!=null&&typeof e=="object"&&!Array.isArray(e)?e.enable!==!1:j(n)}o(b,"isFeatureEnabledWithCollectorAutoEnable");function Nn(n){return n==null||typeof n!="object"||Array.isArray(n)?!1:n.enable!==!1}o(Nn,"isPresenceEnabled");function O(n){const e=n.verification;return e==null||typeof e!="object"||Array.isArray(e)?!0:e.enable!==!1}o(O,"getVerificationEnabled");function ie(n){const e=n.verification;return e==null||typeof e!="object"||Array.isArray(e)?!1:e.auto===!0}o(ie,"getAutoVerifyEnabled");function _n(n){const e=n.verification;return e==null||typeof e!="object"||Array.isArray(e)?!1:e.strict===!0}o(_n,"getVerificationStrict");const se=65536,ae=1;function Cn(n){const e=n.verificationContext;return e==null||typeof e!="object"||Array.isArray(e)?!0:e.enable!==!1}o(Cn,"getVerificationContextEnabled");function mn(n){return n.verificationContext?.source==="actions"?"actions":"git"}o(mn,"getVerificationContextSource");function An(n){const e=n.verificationContext?.commitDepth;return typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.floor(e):ae}o(An,"getVerificationContextCommitDepth");function vn(n){const e=n.verificationContext?.maxBytes;return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.floor(e):se}o(vn,"getVerificationContextMaxBytes");function In(n,e){const t=x(n);return t.length>0&&E(e,t)}o(In,"isIgnoredVerifyPath");function Tn(n){return O(n)?ie(n)?"enforce":"assist":"monitor"}o(Tn,"getVerificationMode");function ce(n){const e=n.telemetry;return e==null||typeof e!="object"||Array.isArray(e)?!0:e.enable!==!1}o(ce,"getTelemetryEnabled");function le(n){const e=n.privacy;return e==null||typeof e!="object"||Array.isArray(e)?!1:e.enable===!0}o(le,"getPrivacyEnabled");const N=65536;function xn(n){const e=n.fileChange;return!e||typeof e!="object"||Array.isArray(e)?!1:e.captureChangeset===!0}o(xn,"getCaptureFileChangeset");function wn(n){const e=n.fileChange;if(!e||typeof e!="object"||Array.isArray(e))return N;const t=e.maxChangesetBytes;return typeof t!="number"||!Number.isFinite(t)||t<=0?N:Math.floor(t)}o(wn,"getMaxChangesetBytes");function Rn(n){const e=c(n);return b(e,e.analytics)}o(Rn,"isAnalyticsEnabled");function jn(n){const t=c(n).analytics;return t===null||typeof t!="object"||Array.isArray(t)?!0:t.emitOnStop!==!1}o(jn,"isAnalyticsEmitOnStopEnabled");function On(n){const t=c(n).analytics;if(t===null||typeof t!="object"||Array.isArray(t))return 0;const r=t.emitOnStopMinIntervalSeconds;return typeof r=="number"&&r>=0?r:0}o(On,"getAnalyticsEmitOnStopMinIntervalSeconds");function kn(n){const t=c(n).analytics;return t===null||typeof t!="object"||Array.isArray(t)?!1:t.emitTurnEvents===!0}o(kn,"isAnalyticsTurnEventsEnabled");function hn(n){const t=c(n).analytics;return t===null||typeof t!="object"||Array.isArray(t)?!1:t.emitStepEvents===!0}o(hn,"isAnalyticsStepEventsEnabled");function Bn(n){const t=c(n).analytics;return t===null||typeof t!="object"||Array.isArray(t)?!0:t.emitApiRequestEvents!==!1}o(Bn,"isAnalyticsApiRequestEventsEnabled");0&&(module.exports={ALL_CYCLES,CONFIG_TARGETS_BY_PRECEDENCE,CYCLES_ENABLED_BY_DEFAULT,CYCLE_DEFAULT_VERIFY_PATTERNS,CYCLE_TOOL_PREFIXES,CYCLE_TO_SERVER,DEFAULT_ANDROID_ALWAYS_REQUIRED,DEFAULT_ANDROID_EVIDENCE_PATHS,DEFAULT_ANDROID_VERIFY_PATTERNS,DEFAULT_BACKEND_ALWAYS_REQUIRED,DEFAULT_BACKEND_EVIDENCE_PATHS,DEFAULT_BACKEND_VERIFY_PATTERNS,DEFAULT_BROWSER_ALWAYS_REQUIRED,DEFAULT_BROWSER_VERIFY_PATTERNS,DEFAULT_IGNORED_VERIFY_PATTERNS,DEFAULT_NODE_ALWAYS_REQUIRED,DEFAULT_NODE_EVIDENCE_PATHS,DEFAULT_NODE_VERIFY_PATTERNS,DEFAULT_OAUTH_USAGE_TTL_SECONDS,DEFAULT_OTEL_EMIT_MIN_INTERVAL_SECONDS,DEFAULT_OTEL_ENSURE_MIN_INTERVAL_SECONDS,DEFAULT_OTEL_IDLE_TIMEOUT_SECONDS,DEFAULT_OTEL_PORT,DEFAULT_VERIFICATION_CONTEXT_COMMIT_DEPTH,DEFAULT_VERIFICATION_CONTEXT_MAX_BYTES,ENV_OVERRIDES,OPTIONAL_CYCLES,applyEnvOverrides,findActiveEnvOverride,getActiveCycles,getAnalyticsEmitOnStopMinIntervalSeconds,getAndroidDevToolsMcpEntry,getAutoVerifyEnabled,getBackendDevToolsMcpEntry,getCaptureFileChangeset,getClaudeOauthAccessEnabled,getClaudeOauthAccessUsageTtlSeconds,getCodexVerifierMode,getConfigLayerPaths,getMaxChangesetBytes,getMaxRetries,getMcpServerEntry,getNodeDevToolsMcpEntry,getOTELEmitMinIntervalSeconds,getOTELEnsureMinIntervalSeconds,getOTELIdleTimeoutSeconds,getOTELPort,getPrivacyEnabled,getRequiredToolsConfig,getStatusLineEmitMinIntervalSeconds,getStatusLineRefreshInterval,getStatusLineRenderDefault,getTargetConfigPath,getTelemetryEnabled,getVerificationContextCommitDepth,getVerificationContextEnabled,getVerificationContextMaxBytes,getVerificationContextSource,getVerificationEnabled,getVerificationMode,getVerificationModel,getVerificationStrict,isAnalyticsApiRequestEventsEnabled,isAnalyticsEmitOnStopEnabled,isAnalyticsEnabled,isAnalyticsStepEventsEnabled,isAnalyticsTurnEventsEnabled,isAutoModeAllowlistEnabled,isClaudeTrustWorkspaceEnabled,isCollectorConfigured,isCycleEnabled,isCyclePatternsActive,isIgnoredVerifyPath,isJobQueueEnabled,isOTELEnabled,isRecordingEnabled,isSessionStatusEnabled,loadConfig,matchesAny,requiresVerification,resolveConfigTargetFromFlags,resolveIgnoredVerifyPatterns});
1
+ "use strict";var C=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var be=Object.prototype.hasOwnProperty;var o=(n,e)=>C(n,"name",{value:e,configurable:!0});var Ee=(n,e)=>{for(var t in e)C(n,t,{get:e[t],enumerable:!0})},ye=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of pe(e))!be.call(n,i)&&i!==t&&C(n,i,{get:()=>e[i],enumerable:!(r=de(e,i))||r.enumerable});return n};var _e=n=>ye(C({},"__esModule",{value:!0}),n);var Un={};Ee(Un,{ALL_CYCLES:()=>me,CONFIG_TARGETS_BY_PRECEDENCE:()=>ke,CYCLES_ENABLED_BY_DEFAULT:()=>P,CYCLE_DEFAULT_VERIFY_PATTERNS:()=>q,CYCLE_TOOL_PREFIXES:()=>Ae,CYCLE_TO_SERVER:()=>Ce,DEFAULT_ANDROID_ALWAYS_REQUIRED:()=>Q,DEFAULT_ANDROID_EVIDENCE_PATHS:()=>z,DEFAULT_ANDROID_VERIFY_PATTERNS:()=>U,DEFAULT_BACKEND_ALWAYS_REQUIRED:()=>W,DEFAULT_BACKEND_EVIDENCE_PATHS:()=>G,DEFAULT_BACKEND_VERIFY_PATTERNS:()=>V,DEFAULT_BROWSER_ALWAYS_REQUIRED:()=>K,DEFAULT_BROWSER_VERIFY_PATTERNS:()=>M,DEFAULT_IGNORED_VERIFY_PATTERNS:()=>Y,DEFAULT_NODE_ALWAYS_REQUIRED:()=>X,DEFAULT_NODE_EVIDENCE_PATHS:()=>H,DEFAULT_NODE_VERIFY_PATTERNS:()=>F,DEFAULT_OAUTH_USAGE_TTL_SECONDS:()=>oe,DEFAULT_OTEL_EMIT_MIN_INTERVAL_SECONDS:()=>ae,DEFAULT_OTEL_ENSURE_MIN_INTERVAL_SECONDS:()=>se,DEFAULT_OTEL_IDLE_TIMEOUT_SECONDS:()=>ie,DEFAULT_OTEL_PORT:()=>re,DEFAULT_TERMINAL_ALWAYS_REQUIRED:()=>J,DEFAULT_TERMINAL_EVIDENCE_PATHS:()=>Z,DEFAULT_TERMINAL_VERIFY_PATTERNS:()=>$,DEFAULT_VERIFICATION_CONTEXT_COMMIT_DEPTH:()=>ue,DEFAULT_VERIFICATION_CONTEXT_MAX_BYTES:()=>le,ENV_OVERRIDES:()=>R,OPTIONAL_CYCLES:()=>T,applyEnvOverrides:()=>ee,findActiveEnvOverride:()=>De,getActiveCycles:()=>ne,getAnalyticsEmitOnStopMinIntervalSeconds:()=>Pn,getAndroidDevToolsMcpEntry:()=>sn,getAutoVerifyEnabled:()=>ce,getBackendDevToolsMcpEntry:()=>rn,getCaptureFileChangeset:()=>Nn,getClaudeOauthAccessEnabled:()=>pn,getClaudeOauthAccessUsageTtlSeconds:()=>_n,getCodexVerifierMode:()=>bn,getConfigLayerPaths:()=>j,getMaxChangesetBytes:()=>Ln,getMaxRetries:()=>cn,getMcpServerEntry:()=>tn,getNodeDevToolsMcpEntry:()=>on,getOTELEmitMinIntervalSeconds:()=>vn,getOTELEnsureMinIntervalSeconds:()=>In,getOTELIdleTimeoutSeconds:()=>An,getOTELPort:()=>Cn,getPrivacyEnabled:()=>ge,getRequiredToolsConfig:()=>Ue,getStatusLineEmitMinIntervalSeconds:()=>dn,getStatusLineRefreshInterval:()=>Tn,getStatusLineRenderDefault:()=>gn,getTargetConfigPath:()=>Ne,getTelemetryEnabled:()=>fe,getTerminalDevToolsMcpEntry:()=>an,getVerificationContextCommitDepth:()=>wn,getVerificationContextEnabled:()=>jn,getVerificationContextMaxBytes:()=>On,getVerificationContextMessage:()=>hn,getVerificationContextSource:()=>Rn,getVerificationEnabled:()=>O,getVerificationMode:()=>kn,getVerificationModel:()=>Te,getVerificationStrict:()=>xn,isAnalyticsApiRequestEventsEnabled:()=>Vn,isAnalyticsEmitOnStopEnabled:()=>Dn,isAnalyticsEnabled:()=>Sn,isAnalyticsStepEventsEnabled:()=>Fn,isAnalyticsTurnEventsEnabled:()=>Mn,isAutoModeAllowlistEnabled:()=>En,isClaudeTrustWorkspaceEnabled:()=>yn,isCollectorConfigured:()=>w,isCycleEnabled:()=>Ve,isCyclePatternsActive:()=>te,isIgnoredVerifyPath:()=>Bn,isJobQueueEnabled:()=>ln,isOTELEnabled:()=>mn,isRecordingEnabled:()=>un,isSessionStatusEnabled:()=>fn,loadConfig:()=>c,matchesAny:()=>_,requiresVerification:()=>Fe,resolveConfigTargetFromFlags:()=>Le,resolveIgnoredVerifyPatterns:()=>x});module.exports=_e(Un);var m=require("fs"),y=require("path"),v=require("os"),D=require("./logger");const T=["node","backend","android","terminal"],me=["browser",...T],P=new Set(["browser"]),Ce={browser:"browser-devtools",node:"node-devtools",backend:"backend-devtools",android:"android-devtools",terminal:"terminal-devtools"},Ae={browser:"bdt_",node:"ndt_",backend:"bedt_",android:"adt_",terminal:"tdt_"},M=["*.ts","*.tsx","*.js","*.jsx","*.mjs","*.cjs","*.vue","*.svelte","*.html","*.htm","*.css","*.scss","*.sass","*.less","*.styl","*.py","*.rb","*.erb","*.go","*.rs","*.java","*.kt","*.kts","*.swift","*.c","*.cpp","*.h","*.hpp","*.cs","*.php","*.dart","*.ex","*.exs","*.erl","*.lua","*.r","*.R","*.scala","*.clj","*.cljs","*.zig","*.nim","*.hbs","*.ejs","*.pug","*.jade","*.astro"],F=["server/**/*.{ts,js,mjs,cjs}","src/server/**/*.{ts,js,mjs,cjs}","backend/**/*.{ts,js,mjs,cjs}","api/**/*.{ts,js,mjs,cjs}","src/api/**/*.{ts,js,mjs,cjs}","pages/api/**/*.{ts,js,mjs,cjs}","app/api/**/*.{ts,js,mjs,cjs}","routes/**/*.{ts,js,mjs,cjs}","**/server.{ts,js,mjs,cjs}"],V=["server/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","src/server/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","backend/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","api/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","src/api/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","pages/api/**/*.{ts,js,mjs,cjs}","app/api/**/*.{ts,js,mjs,cjs}","routes/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","controllers/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","handlers/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","services/**/*.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","**/server.{ts,js,mjs,cjs,py,go,java,rb,cs,rs,kt,scala,ex,exs,php,clj}","**/main.{go,py,java,rb,kt,scala}"],U=["android/**/*.{kt,java}","app/src/**/*.{kt,java}","mobile/**/*.{kt,java}","src/main/kotlin/**/*.kt","src/main/java/**/*.java","**/*.{kt,java}","**/res/**/*.xml","**/AndroidManifest.xml"],$=["cli/**/*.{ts,js,mjs,cjs,py,go,rs,rb,java,kt}","cmd/**/*.{go,ts,js,mjs,cjs,py,rs}","**/cli/**/*.{ts,js,mjs,cjs,py,go,rs,rb,java,kt}","**/cmd/**/*.{go,ts,js,mjs,cjs,py,rs}","**/commands/**/*.{ts,js,mjs,cjs,py,go,rs,rb}","bin/**","**/bin/**/*.{ts,js,mjs,cjs,py,go,rs,rb,sh}","**/cli.{ts,js,mjs,cjs,py,go,rs,rb}","**/main.{go,rs}","**/*.{sh,bash,zsh,fish}"],q={browser:M,node:F,backend:V,android:U,terminal:$},Y=["**/*.spec.*","**/*.test.*","**/__tests__/**","**/__mocks__/**"];function x(n){const e=n.ignoredVerifyPatterns??[];return[...Y,...e]}o(x,"resolveIgnoredVerifyPatterns");const K=["bdt_navigation_go-to","bdt_content_take-screenshot","bdt_a11y_take-aria-snapshot","bdt_o11y_get-console-messages"],X=["ndt_debug_connect"],H=[{name:"probe",allOf:[{anyOf:["ndt_debug_put-tracepoint","ndt_debug_put-logpoint","ndt_debug_put-exceptionpoint"]},"ndt_debug_get-probe-snapshots"]},{name:"log",allOf:["ndt_debug_get-logs"]}],W=[],G=[{name:"protocol-call",allOf:[{anyOf:["bedt_request_http","bedt_request_grpc","bedt_request_graphql","bedt_request_websocket-open","bedt_request_replay"]}]},{name:"log-evidence",allOf:["bedt_log_register-source",{anyOf:["bedt_log_read","bedt_log_read-multi","bedt_log_follow"]}]},{name:"db-evidence",allOf:["bedt_db_connect",{anyOf:["bedt_db_query","bedt_db_describe-table","bedt_db_list-tables","bedt_db_snapshot","bedt_db_diff","bedt_db_get-changes"]}]}],Q=["adt_device_connect"],z=[{name:"device-evidence",allOf:[{anyOf:["adt_device_launch-app","adt_interaction_tap","adt_interaction_double-tap","adt_interaction_long-press","adt_interaction_input-text","adt_interaction_swipe","adt_interaction_scroll","adt_interaction_press-key","adt_interaction_deep-link"]},"adt_content_take-screenshot","adt_a11y_take-ui-snapshot"]},{name:"log-evidence",allOf:[{anyOf:["adt_o11y_log-read","adt_o11y_log-follow"]}]},{name:"network-evidence",allOf:["adt_o11y_get-http-requests"]}],J=[],Z=[{name:"run-evidence",allOf:["tdt_pty_run"]},{name:"interactive-evidence",allOf:["tdt_pty_start",{anyOf:["tdt_interaction_send-keys","tdt_interaction_send-text"]},"tdt_content_capture"]}],Ie=3;function B(n){if(!(0,m.existsSync)(n))return{};try{return JSON.parse((0,m.readFileSync)(n,"utf-8"))}catch(e){return D.logger.debug(`failed to parse config ${n}: ${e}`),{}}}o(B,"loadJsonFile");function ve(n,e){if(!Object.prototype.hasOwnProperty.call(n,"verification"))return;const t=n.verification;if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`Invalid IronBee config in ${e}: 'verification' must be an object. Expected shape: { "enable": boolean }.`);const r=t;if(Object.prototype.hasOwnProperty.call(r,"enable")&&typeof r.enable!="boolean")throw new Error(`Invalid IronBee config in ${e}: 'verification.enable' must be boolean. Got ${typeof r.enable}.`);if(Object.prototype.hasOwnProperty.call(r,"auto")&&typeof r.auto!="boolean")throw new Error(`Invalid IronBee config in ${e}: 'verification.auto' must be boolean. Got ${typeof r.auto}.`);if(Object.prototype.hasOwnProperty.call(r,"strict")&&typeof r.strict!="boolean")throw new Error(`Invalid IronBee config in ${e}: 'verification.strict' must be boolean. Got ${typeof r.strict}.`);if(Object.prototype.hasOwnProperty.call(r,"model")){const i=r.model,s=typeof i=="string",l=i!==null&&typeof i=="object"&&!Array.isArray(i)&&Object.values(i).every(a=>typeof a=="string");if(!s&&!l)throw new Error(`Invalid IronBee config in ${e}: 'verification.model' must be a string (applies to all clients) or an object of string values (per-client, e.g. { "claude": "sonnet", "codex": "gpt-5.5" }). Got ${Array.isArray(i)?"array":typeof i}.`)}if(Object.prototype.hasOwnProperty.call(r,"context")){const i=r.context;if(i===null||typeof i!="object"||Array.isArray(i))throw new Error(`Invalid IronBee config in ${e}: 'verification.context' must be an object. Expected shape: { "enable"?: boolean, "source"?: "git"|"actions", "commitDepth"?: number, "maxBytes"?: number, "message"?: string }. Got ${Array.isArray(i)?"array":i===null?"null":typeof i}.`)}}o(ve,"assertVerificationShape");function Te(n,e){const t=n.verification?.model;if(typeof t=="string")return t.length>0?t:void 0;if(t&&typeof t=="object"){const r=t[e];return typeof r=="string"&&r.length>0?r:void 0}}o(Te,"getVerificationModel");function xe(n,e){if(!Object.prototype.hasOwnProperty.call(n,"telemetry"))return;const t=n.telemetry;if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`Invalid IronBee config in ${e}: 'telemetry' must be an object. Expected shape: { "enable": boolean }.`);const r=t;if(Object.prototype.hasOwnProperty.call(r,"enable")&&typeof r.enable!="boolean")throw new Error(`Invalid IronBee config in ${e}: 'telemetry.enable' must be boolean. Got ${typeof r.enable}.`)}o(xe,"assertTelemetryShape");function je(n,e){if(!Object.prototype.hasOwnProperty.call(n,"privacy"))return;const t=n.privacy;if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`Invalid IronBee config in ${e}: 'privacy' must be an object. Expected shape: { "enable": boolean }.`);const r=t;if(Object.prototype.hasOwnProperty.call(r,"enable")&&typeof r.enable!="boolean")throw new Error(`Invalid IronBee config in ${e}: 'privacy.enable' must be boolean. Got ${typeof r.enable}.`)}o(je,"assertPrivacyShape");function p(n,e){if(!(n===void 0&&e===void 0))return{...n??{},...e??{}}}o(p,"mergeCycleConfig");function k(n,e){const t={...n,...e};return t.browser=p(n.browser,e.browser),t.node=p(n.node,e.node),t.backend=p(n.backend,e.backend),t.android=p(n.android,e.android),t.terminal=p(n.terminal,e.terminal),t.claude=he(n.claude,e.claude),t.codex=Be(n.codex,e.codex),t.verification=Oe(n.verification,e.verification),t.runtime=Re(n.runtime,e.runtime),t}o(k,"mergeConfigLayers");function Re(n,e){if(!(n===void 0&&e===void 0))return{...n??{},...e??{}}}o(Re,"mergeRuntimeConfig");function we(n,e){if(!(n===void 0&&e===void 0))return{...n??{},...e??{}}}o(we,"mergeVerificationContextConfig");function Oe(n,e){if(n===void 0&&e===void 0)return;const t={...n??{},...e??{}},r=we(n?.context,e?.context);return r!==void 0?t.context=r:delete t.context,t}o(Oe,"mergeVerificationConfig");function he(n,e){if(n===void 0&&e===void 0)return;const t={...n??{},...e??{}};return(n?.oauthAccess!==void 0||e?.oauthAccess!==void 0)&&(t.oauthAccess={...n?.oauthAccess??{},...e?.oauthAccess??{}}),(n?.autoModeAllowlist!==void 0||e?.autoModeAllowlist!==void 0)&&(t.autoModeAllowlist={...n?.autoModeAllowlist??{},...e?.autoModeAllowlist??{}}),t}o(he,"mergeClaudeConfig");function Be(n,e){if(n===void 0&&e===void 0)return;const t={...n??{},...e??{}};return(n?.verifier!==void 0||e?.verifier!==void 0)&&(t.verifier={...n?.verifier??{},...e?.verifier??{}}),t}o(Be,"mergeCodexConfig");function j(n){return{global:(0,y.join)((0,v.homedir)(),".ironbee","config.json"),project:n?(0,y.join)(n,".ironbee","config.json"):void 0,local:n?(0,y.join)(n,".ironbee","config.local.json"):void 0}}o(j,"getConfigLayerPaths");const ke=["global","project","local"];function Ne(n,e){const t=j(e);if(n==="global")return t.global;if(n==="project"){if(t.project===void 0)throw new Error("Project layer requested but no projectDir was provided.");return t.project}if(t.local===void 0)throw new Error("Local layer requested but no projectDir was provided.");return t.local}o(Ne,"getTargetConfigPath");function Le(n){if(n.global===!0&&n.local===!0)throw new Error("Pass at most one of --global / --local.");return n.global===!0?"global":n.local===!0?"local":"project"}o(Le,"resolveConfigTargetFromFlags");function A(n){const e=B(n);return(0,m.existsSync)(n)&&(ve(e,n),xe(e,n),je(e,n)),e}o(A,"loadAndValidateLayer");const R=[{envVar:"IRONBEE_API_KEY",configPath:"collector.apiKey"},{envVar:"IRONBEE_OAUTH_TOKEN",configPath:"collector.oauthToken"}];function Se(n,e,t){const r=e.split(".");let i=n;for(let s=0;s<r.length-1;s++){const l=r[s],a=i[l];a!=null&&typeof a=="object"&&!Array.isArray(a)?i[l]={...a}:i[l]={},i=i[l]}i[r[r.length-1]]=t}o(Se,"setAtConfigPath");function ee(n){let e;for(const t of R){const r=process.env[t.envVar];if(r===void 0||r.length===0)continue;e===void 0&&(e={...n});const i=t.coerce?t.coerce(r):r;Se(e,t.configPath,i)}return e??n}o(ee,"applyEnvOverrides");function De(n){for(const e of R){if(e.configPath!==n)continue;const t=process.env[e.envVar];if(t!==void 0&&t.length>0)return e}}o(De,"findActiveEnvOverride");function c(n){const e=j(n),t=A(e.global),r=e.project?A(e.project):{},i=e.local?A(e.local):{},s=k(k(t,r),i);return ee(s)}o(c,"loadConfig");function Pe(n){let e=n.replace(/\{([^}]+)\}/g,(t,r)=>`(${r.split(",").map(i=>i.trim()).join("|")})`);return e=e.replace(/\*\*\//g,"\0DSS\0").replace(/\*\*/g,"\0DS\0").replace(/\*/g,"\0SS\0").replace(/\?/g,"\0QM\0"),e=e.replace(/[.+^$\\[\]]/g,"\\$&"),e=e.replace(/\x00DSS\x00/g,"(?:.*/)?").replace(/\x00DS\x00/g,".*").replace(/\x00SS\x00/g,"[^/]*").replace(/\x00QM\x00/g,"[^/]"),new RegExp(`(^|/)${e}$`)}o(Pe,"globToRegExp");function _(n,e){const t=n.replace(/\\/g,"/");for(const r of e)if(Pe(r).test(t))return!0;return!1}o(_,"matchesAny");function Me(n,e){if(e==="browser")return n.browser;if(e==="node")return n.node;if(e==="backend")return n.backend;if(e==="android")return n.android;if(e==="terminal")return n.terminal}o(Me,"getCycleBlock");function I(n,e){const t=Me(n,e);if(t!==void 0&&t.enable===!1)return[];const r=q[e]??[];if(t===void 0)return P.has(e)?[...r]:[];if(Array.isArray(t.verifyPatterns)&&t.verifyPatterns.length===0)return[];const i=t.verifyPatterns??r,s=t.additionalVerifyPatterns??[];return[...i,...s]}o(I,"getCyclePatterns");function ne(n,e){const t=x(e);if(t.length>0&&_(n,t))return[];const r=[];_(n,I(e,"browser"))&&r.push("browser");for(const i of T){const s=I(e,i);s.length>0&&_(n,s)&&r.push(i)}return r}o(ne,"getActiveCycles");function Fe(n,e){return ne(n,e).length>0}o(Fe,"requiresVerification");function Ve(n,e){return O(n)?te(n,e):!1}o(Ve,"isCycleEnabled");function te(n,e){return I(n,e).length>0}o(te,"isCyclePatternsActive");function Ue(n,e){let t,r;if(e==="browser"?(t=n.browser?.alwaysRequired??K,r=n.browser?.evidencePaths??[]):e==="node"?(t=n.node?.alwaysRequired??X,r=n.node?.evidencePaths??H):e==="backend"?(t=n.backend?.alwaysRequired??W,r=n.backend?.evidencePaths??G):e==="android"?(t=n.android?.alwaysRequired??Q,r=n.android?.evidencePaths??z):e==="terminal"?(t=n.terminal?.alwaysRequired??J,r=n.terminal?.evidencePaths??Z):(t=[],r=[]),t.length===0&&r.length===0)throw new Error(`Invalid required-tools config for cycle '${e}': both 'alwaysRequired' and 'evidencePaths' are empty. At least one must specify required tools.`);return{alwaysRequired:t,evidencePaths:r}}o(Ue,"getRequiredToolsConfig");const N="npx",$e="^0.14.0",L=["-y",`@ironbee-ai/devtools@${$e}`],qe={TOOL_NAME_PREFIX:"bdt_",TOOL_INPUT_METADATA_ENABLE:"true",SCENARIOS_DIR:".ironbee/scenarios/bdt"},Ye={PLATFORM:"node",TOOL_NAME_PREFIX:"ndt_",TOOL_INPUT_METADATA_ENABLE:"true",SCENARIOS_DIR:".ironbee/scenarios/ndt"},Ke={PLATFORM:"backend",TOOL_NAME_PREFIX:"bedt_",TOOL_INPUT_METADATA_ENABLE:"true",SCENARIOS_DIR:".ironbee/scenarios/bedt"},Xe={PLATFORM:"android",TOOL_NAME_PREFIX:"adt_",TOOL_INPUT_METADATA_ENABLE:"true",SCENARIOS_DIR:".ironbee/scenarios/adt"},He={PLATFORM:"terminal",TOOL_NAME_PREFIX:"tdt_",TOOL_INPUT_METADATA_ENABLE:"true",SCENARIOS_DIR:".ironbee/scenarios/tdt"},We={BROWSER_DEVTOOLS_INSTALL_CHROMIUM:"true"},Ge={},Qe={},ze={},Je={};function Ze(n){return fe(n)?{}:{TELEMETRY_ENABLE:"false"}}o(Ze,"buildTelemetryEnv");function en(n){return ge(n)?{COLLECTOR_EVENTS_TOOL_DETAILS_ENABLE:"false",COLLECTOR_ARTIFACTS_ENABLE:"false"}:{}}o(en,"buildPrivacyEnv");function nn(n,e){if(!w(n))return{};const t=n.collector,i=B((0,y.join)((0,v.homedir)(),".ironbee","config.json")).collector??{},s=typeof i.oauthToken=="string"&&i.oauthToken.length>0,l=typeof i.apiKey=="string"&&i.apiKey.length>0;let a;t.oauthToken?a=s?"X-OAuth-Token=${file:~/.ironbee/config.json#collector.oauthToken}":`X-OAuth-Token=${t.oauthToken}`:a=l?"X-API-Key=${file:~/.ironbee/config.json#collector.apiKey}":`X-API-Key=${t.apiKey}`;const u={OTEL_ENABLE:"true",OTEL_EXPORTER_HTTP_URL:t.url,OTEL_EXPORTER_HTTP_HEADERS:a,OTEL_EXPORTER_TYPE:"otlp/http-protobuf"};return e==="browser"&&(u.OTEL_INSTRUMENTATION_USER_INTERACTION_EVENTS="change,input,click",u.BROWSER_HEADLESS_ENABLE="true"),u}o(nn,"buildOTELEnv");function b(n,e,t,r,i){const s=nn(n,i),l=Ze(n),a=en(n),u=n[e];if(u&&typeof u=="object"&&!Array.isArray(u)){const f=u;if(f.mcp&&typeof f.mcp=="object"&&!Array.isArray(f.mcp)){const g={...f.mcp},d={...s,...l,...a,...g.env??{},...t};return g.env=d,g}const h={};if(f.env&&typeof f.env=="object"&&!Array.isArray(f.env)){const g=f.env;for(const d of Object.keys(g))typeof g[d]=="string"&&(h[d]=g[d])}return{command:N,args:[...L],env:{...r,...s,...l,...a,...h,...t}}}return{command:N,args:[...L],env:{...r,...s,...l,...a,...t}}}o(b,"buildMcpEntry");function tn(n){const e=c(n);return b(e,"browserDevTools",qe,We,"browser")}o(tn,"getMcpServerEntry");function on(n){const e=c(n);return b(e,"nodeDevTools",Ye,Ge,"node")}o(on,"getNodeDevToolsMcpEntry");function rn(n){const e=c(n);return b(e,"backendDevTools",Ke,Qe,"backend")}o(rn,"getBackendDevToolsMcpEntry");function sn(n){const e=c(n);return b(e,"androidDevTools",Xe,ze,"android")}o(sn,"getAndroidDevToolsMcpEntry");function an(n){const e=c(n);return b(e,"terminalDevTools",He,Je,"terminal")}o(an,"getTerminalDevToolsMcpEntry");function cn(n){return typeof n.maxRetries=="number"&&n.maxRetries>0?n.maxRetries:Ie}o(cn,"getMaxRetries");function w(n){if(process.env.IRONBEE_COLLECTOR==="false")return!1;const e=n.collector;if(!e||e.enable===!1||typeof e.url!="string"||e.url.length===0)return!1;const t=typeof e.oauthToken=="string"&&e.oauthToken.length>0,r=typeof e.apiKey=="string"&&e.apiKey.length>0;return!(!t&&!r)}o(w,"isCollectorConfigured");function ln(n){const e=c(n);return E(e,e.jobQueue)}o(ln,"isJobQueueEnabled");function un(n){const e=c(n);return E(e,e.recording)}o(un,"isRecordingEnabled");function fn(n){return E(n,n.statusLine)}o(fn,"isSessionStatusEnabled");function gn(n){const e=n.statusLine;return e!==void 0&&e.renderDefault===!0}o(gn,"getStatusLineRenderDefault");function dn(n){const e=n.statusLine?.emitMinIntervalSeconds;return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:10}o(dn,"getStatusLineEmitMinIntervalSeconds");const oe=60;function pn(n){return n.claude?.oauthAccess?.enable!==!1}o(pn,"getClaudeOauthAccessEnabled");function bn(n){return n.codex?.verifier?.mode==="main-agent"?"main-agent":"sub-agent"}o(bn,"getCodexVerifierMode");function En(n){return n.claude?.autoModeAllowlist?.enable!==!1}o(En,"isAutoModeAllowlistEnabled");function yn(n){return n.claude?.trustWorkspace?.enable!==!1}o(yn,"isClaudeTrustWorkspaceEnabled");function _n(n){const e=n.claude?.oauthAccess?.usageTtlSeconds;return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:oe}o(_n,"getClaudeOauthAccessUsageTtlSeconds");const re=15986,ie=600,se=30,ae=0;function mn(n){return E(n,n.otel)}o(mn,"isOTELEnabled");function Cn(n){const e=n.otel?.port;return typeof e=="number"&&Number.isInteger(e)&&e>0&&e<65536?e:re}o(Cn,"getOTELPort");function An(n){const e=n.otel?.idleTimeoutSeconds;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:ie}o(An,"getOTELIdleTimeoutSeconds");function In(n){const e=n.otel?.ensureMinIntervalSeconds;return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:se}o(In,"getOTELEnsureMinIntervalSeconds");function vn(n){const e=n.otel?.emitMinIntervalSeconds;return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:ae}o(vn,"getOTELEmitMinIntervalSeconds");function Tn(n){const e=n.statusLine?.refreshInterval;if(typeof e=="number"&&Number.isFinite(e)&&e>=1)return e}o(Tn,"getStatusLineRefreshInterval");function E(n,e){return e!=null&&typeof e=="object"&&!Array.isArray(e)?e.enable!==!1:w(n)}o(E,"isFeatureEnabledWithCollectorAutoEnable");function qn(n){return n==null||typeof n!="object"||Array.isArray(n)?!1:n.enable!==!1}o(qn,"isPresenceEnabled");function O(n){const e=n.verification;return e==null||typeof e!="object"||Array.isArray(e)?!0:e.enable!==!1}o(O,"getVerificationEnabled");function ce(n){const e=n.verification;return e==null||typeof e!="object"||Array.isArray(e)?!1:e.auto===!0}o(ce,"getAutoVerifyEnabled");function xn(n){const e=n.verification;return e==null||typeof e!="object"||Array.isArray(e)?!1:e.strict===!0}o(xn,"getVerificationStrict");const le=65536,ue=1;function jn(n){const e=n.verification?.context;return e==null||typeof e!="object"||Array.isArray(e)?!0:e.enable!==!1}o(jn,"getVerificationContextEnabled");function Rn(n){return n.verification?.context?.source==="actions"?"actions":"git"}o(Rn,"getVerificationContextSource");function wn(n){const e=n.verification?.context?.commitDepth;return typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.floor(e):ue}o(wn,"getVerificationContextCommitDepth");function On(n){const e=n.verification?.context?.maxBytes;return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.floor(e):le}o(On,"getVerificationContextMaxBytes");function hn(n){const e=n.verification?.context?.message;return typeof e=="string"?e.trim():""}o(hn,"getVerificationContextMessage");function Bn(n,e){const t=x(n);return t.length>0&&_(e,t)}o(Bn,"isIgnoredVerifyPath");function kn(n){return O(n)?ce(n)?"enforce":"assist":"monitor"}o(kn,"getVerificationMode");function fe(n){const e=n.telemetry;return e==null||typeof e!="object"||Array.isArray(e)?!0:e.enable!==!1}o(fe,"getTelemetryEnabled");function ge(n){const e=n.privacy;return e==null||typeof e!="object"||Array.isArray(e)?!1:e.enable===!0}o(ge,"getPrivacyEnabled");const S=65536;function Nn(n){const e=n.fileChange;return!e||typeof e!="object"||Array.isArray(e)?!1:e.captureChangeset===!0}o(Nn,"getCaptureFileChangeset");function Ln(n){const e=n.fileChange;if(!e||typeof e!="object"||Array.isArray(e))return S;const t=e.maxChangesetBytes;return typeof t!="number"||!Number.isFinite(t)||t<=0?S:Math.floor(t)}o(Ln,"getMaxChangesetBytes");function Sn(n){const e=c(n);return E(e,e.analytics)}o(Sn,"isAnalyticsEnabled");function Dn(n){const t=c(n).analytics;return t===null||typeof t!="object"||Array.isArray(t)?!0:t.emitOnStop!==!1}o(Dn,"isAnalyticsEmitOnStopEnabled");function Pn(n){const t=c(n).analytics;if(t===null||typeof t!="object"||Array.isArray(t))return 0;const r=t.emitOnStopMinIntervalSeconds;return typeof r=="number"&&r>=0?r:0}o(Pn,"getAnalyticsEmitOnStopMinIntervalSeconds");function Mn(n){const t=c(n).analytics;return t===null||typeof t!="object"||Array.isArray(t)?!1:t.emitTurnEvents===!0}o(Mn,"isAnalyticsTurnEventsEnabled");function Fn(n){const t=c(n).analytics;return t===null||typeof t!="object"||Array.isArray(t)?!1:t.emitStepEvents===!0}o(Fn,"isAnalyticsStepEventsEnabled");function Vn(n){const t=c(n).analytics;return t===null||typeof t!="object"||Array.isArray(t)?!0:t.emitApiRequestEvents!==!1}o(Vn,"isAnalyticsApiRequestEventsEnabled");0&&(module.exports={ALL_CYCLES,CONFIG_TARGETS_BY_PRECEDENCE,CYCLES_ENABLED_BY_DEFAULT,CYCLE_DEFAULT_VERIFY_PATTERNS,CYCLE_TOOL_PREFIXES,CYCLE_TO_SERVER,DEFAULT_ANDROID_ALWAYS_REQUIRED,DEFAULT_ANDROID_EVIDENCE_PATHS,DEFAULT_ANDROID_VERIFY_PATTERNS,DEFAULT_BACKEND_ALWAYS_REQUIRED,DEFAULT_BACKEND_EVIDENCE_PATHS,DEFAULT_BACKEND_VERIFY_PATTERNS,DEFAULT_BROWSER_ALWAYS_REQUIRED,DEFAULT_BROWSER_VERIFY_PATTERNS,DEFAULT_IGNORED_VERIFY_PATTERNS,DEFAULT_NODE_ALWAYS_REQUIRED,DEFAULT_NODE_EVIDENCE_PATHS,DEFAULT_NODE_VERIFY_PATTERNS,DEFAULT_OAUTH_USAGE_TTL_SECONDS,DEFAULT_OTEL_EMIT_MIN_INTERVAL_SECONDS,DEFAULT_OTEL_ENSURE_MIN_INTERVAL_SECONDS,DEFAULT_OTEL_IDLE_TIMEOUT_SECONDS,DEFAULT_OTEL_PORT,DEFAULT_TERMINAL_ALWAYS_REQUIRED,DEFAULT_TERMINAL_EVIDENCE_PATHS,DEFAULT_TERMINAL_VERIFY_PATTERNS,DEFAULT_VERIFICATION_CONTEXT_COMMIT_DEPTH,DEFAULT_VERIFICATION_CONTEXT_MAX_BYTES,ENV_OVERRIDES,OPTIONAL_CYCLES,applyEnvOverrides,findActiveEnvOverride,getActiveCycles,getAnalyticsEmitOnStopMinIntervalSeconds,getAndroidDevToolsMcpEntry,getAutoVerifyEnabled,getBackendDevToolsMcpEntry,getCaptureFileChangeset,getClaudeOauthAccessEnabled,getClaudeOauthAccessUsageTtlSeconds,getCodexVerifierMode,getConfigLayerPaths,getMaxChangesetBytes,getMaxRetries,getMcpServerEntry,getNodeDevToolsMcpEntry,getOTELEmitMinIntervalSeconds,getOTELEnsureMinIntervalSeconds,getOTELIdleTimeoutSeconds,getOTELPort,getPrivacyEnabled,getRequiredToolsConfig,getStatusLineEmitMinIntervalSeconds,getStatusLineRefreshInterval,getStatusLineRenderDefault,getTargetConfigPath,getTelemetryEnabled,getTerminalDevToolsMcpEntry,getVerificationContextCommitDepth,getVerificationContextEnabled,getVerificationContextMaxBytes,getVerificationContextMessage,getVerificationContextSource,getVerificationEnabled,getVerificationMode,getVerificationModel,getVerificationStrict,isAnalyticsApiRequestEventsEnabled,isAnalyticsEmitOnStopEnabled,isAnalyticsEnabled,isAnalyticsStepEventsEnabled,isAnalyticsTurnEventsEnabled,isAutoModeAllowlistEnabled,isClaudeTrustWorkspaceEnabled,isCollectorConfigured,isCycleEnabled,isCyclePatternsActive,isIgnoredVerifyPath,isJobQueueEnabled,isOTELEnabled,isRecordingEnabled,isSessionStatusEnabled,loadConfig,matchesAny,requiresVerification,resolveConfigTargetFromFlags,resolveIgnoredVerifyPatterns});
@@ -1 +1 @@
1
- "use strict";var r=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var L=(e,S)=>{for(var o in S)r(e,o,{get:S[o],enumerable:!0})},N=(e,S,o,t)=>{if(S&&typeof S=="object"||typeof S=="function")for(let n of E(S))!I.call(e,n)&&n!==o&&r(e,n,{get:()=>S[n],enumerable:!(t=A(S,n))||t.enumerable});return e};var _=e=>N(r({},"__esModule",{value:!0}),e);var c={};L(c,{INSTALL_SCHEMA_VERSION:()=>b});module.exports=_(c);const b=9;0&&(module.exports={INSTALL_SCHEMA_VERSION});
1
+ "use strict";var r=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var L=(e,S)=>{for(var o in S)r(e,o,{get:S[o],enumerable:!0})},N=(e,S,o,t)=>{if(S&&typeof S=="object"||typeof S=="function")for(let n of E(S))!I.call(e,n)&&n!==o&&r(e,n,{get:()=>S[n],enumerable:!(t=A(S,n))||t.enumerable});return e};var _=e=>N(r({},"__esModule",{value:!0}),e);var c={};L(c,{INSTALL_SCHEMA_VERSION:()=>b});module.exports=_(c);const b=13;0&&(module.exports={INSTALL_SCHEMA_VERSION});
@@ -1,7 +1,8 @@
1
- "use strict";var p=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var c=(e,n)=>p(e,"name",{value:n,configurable:!0});var O=(e,n)=>{for(var t in n)p(e,t,{get:n[t],enumerable:!0})},j=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of E(n))!T.call(e,r)&&r!==t&&p(e,r,{get:()=>n[r],enumerable:!(i=F(n,r))||i.enumerable});return e};var B=e=>j(p({},"__esModule",{value:!0}),e);var _={};O(_,{PLATFORM_TARGETS:()=>v,applyPlatformSection:()=>R,applyPlatformToProjectFiles:()=>P,fragmentFilename:()=>$,readFragment:()=>A,syncPlatformSectionsToConfig:()=>C,togglePlatformSectionInFile:()=>w});module.exports=B(_);var l=require("fs"),m=require("./logger"),h=require("./config");const S={browser:["<!-- Browser cycle verification is OFF for this project."," - To verify frontend / UI changes by driving a real browser (DOM, console,"," screenshots, accessibility, network): run `ironbee browser enable` to enable."," This file will be auto-updated with the browser-cycle guidance."," - When OFF, do NOT invoke any `bdt_*` tools voluntarily \u2014 there is no"," active browser-cycle gate, so calling them only wastes cycles. -->"].join(`
1
+ "use strict";var p=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var l=(e,n)=>p(e,"name",{value:n,configurable:!0});var O=(e,n)=>{for(var t in n)p(e,t,{get:n[t],enumerable:!0})},j=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of x(n))!E.call(e,r)&&r!==t&&p(e,r,{get:()=>n[r],enumerable:!(i=F(n,r))||i.enumerable});return e};var B=e=>j(p({},"__esModule",{value:!0}),e);var _={};O(_,{PLATFORM_TARGETS:()=>v,applyPlatformSection:()=>R,applyPlatformToProjectFiles:()=>P,fragmentFilename:()=>$,readFragment:()=>A,syncPlatformSectionsToConfig:()=>C,togglePlatformSectionInFile:()=>w});module.exports=B(_);var c=require("fs"),m=require("./logger"),b=require("./config");const L={browser:["<!-- Browser cycle verification is OFF for this project."," - To verify frontend / UI changes by driving a real browser (DOM, console,"," screenshots, accessibility, network): run `ironbee browser enable` to enable."," This file will be auto-updated with the browser-cycle guidance."," - When OFF, do NOT invoke any `bdt_*` tools voluntarily \u2014 there is no"," active browser-cycle gate, so calling them only wastes cycles. -->"].join(`
2
2
  `),node:["<!-- Node.js runtime debug verification is OFF for this project."," - If your backend is Node.js and you want non-blocking debugger probes:"," run `ironbee node enable` to enable. This file will be auto-updated"," with the node-cycle guidance."," - If your backend isn't Node.js (Java / Python / Go / Rust / .NET / Ruby / PHP / Elixir / \u2026):"," leave this OFF \u2014 `ndt_*` tools only attach to V8/Node processes and will fail elsewhere."," - When OFF, do NOT invoke any `ndt_*` tools voluntarily. -->"].join(`
3
3
  `),backend:["<!-- Backend protocol verification is OFF for this project."," - To verify backend services by driving real protocol calls (HTTP / gRPC /"," GraphQL / WebSocket) \u2014 runtime- and language-agnostic \u2014 run `ironbee"," backend enable`. This file will be auto-updated with the backend-cycle"," guidance."," - When OFF, do NOT invoke any `bedt_*` tools voluntarily. -->"].join(`
4
4
  `),android:["<!-- Android mobile verification is OFF for this project."," - To verify Android app changes by driving a real device or emulator (UI"," interactions, Logcat, screenshots): run `ironbee android enable`."," This file will be auto-updated with the android-cycle guidance."," - When OFF, do NOT invoke any `adt_*` tools voluntarily. -->"].join(`
5
- `)};function L(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c(L,"escapeRegex");function I(e){return new RegExp(`<!--IRONBEE:PLATFORM:${L(e)}(?::([\\w-]+))?-->`,"g")}c(I,"startMarkerRegex");function M(e,n){return n.length>0?`<!--/IRONBEE:PLATFORM:${e}:${n}-->`:`<!--/IRONBEE:PLATFORM:${e}-->`}c(M,"endMarkerFor");function N(e,n,t){const i=I(n),r=[],d=new Set;let s=i.exec(e);for(;s!==null;){const o=s[1]??"",a=s.index+s[0].length,f=M(n,o),b=e.indexOf(f,a);if(b===-1){const g=t?` in ${t}`:"",u=o.length>0?`${n}:${o}`:n;m.logger.debug(`platform-section ${u}: start marker found without matching end marker${g}`),s=i.exec(e);continue}if(d.has(o)){const g=t?` in ${t}`:"",u=o.length>0?`${n}:${o}`:n;m.logger.warn(`platform-section ${u}: multiple marker blocks with the same key${g} \u2014 only the first will be updated. Either consolidate the blocks or use distinct keys (\`IRONBEE:PLATFORM:${n}:<key>\`) per position.`),s=i.exec(e);continue}d.add(o),r.push({key:o,startEnd:a,endIdx:b}),s=i.exec(e)}return r}c(N,"findMarkerBlocks");function R(e,n,t,i){const r=typeof t=="function"?t:()=>t,d=N(e,n,i);if(d.length===0)return e;const s=S[n];if(s===void 0)throw new Error(`No placeholder registered for platform '${n}'.`);let o=e;for(let a=d.length-1;a>=0;a--){const f=d[a],b=r(f.key)??s,g=o.substring(0,f.startEnd),u=o.substring(f.endIdx);o=`${g}
6
- ${b}
7
- ${u}`}return o}c(R,"applyPlatformSection");function $(e,n,t){return t.length>0?`${e}.${n}.${t}.md`:`${e}.${n}.md`}c($,"fragmentFilename");function A(e,n){const t=`${e}/${n}`;if(!(0,l.existsSync)(t))throw new Error(`Platform fragment not found: ${t}`);return(0,l.readFileSync)(t,"utf-8").trimEnd()}c(A,"readFragment");function w(e,n,t){if(!(0,l.existsSync)(e))return!1;const i=(0,l.readFileSync)(e,"utf-8"),r=R(i,n,t,e);return r===i?!1:((0,l.writeFileSync)(e,r),!0)}c(w,"togglePlatformSectionInFile");const v={claude:[{projectRelativePath:".claude/agents/ironbee-verifier.md",fragmentBase:"skill"},{projectRelativePath:".claude/agents/ironbee-scenario.md",fragmentBase:"scenario"}],cursor:[{projectRelativePath:".cursor/skills/ironbee-verification.md",fragmentBase:"skill"},{projectRelativePath:".cursor/rules/ironbee-verification.mdc",fragmentBase:"rule"},{projectRelativePath:".cursor/skills/ironbee-verify/SKILL.md",fragmentBase:"command-verify"},{projectRelativePath:".cursor/skills/ironbee-manage-scenario/SKILL.md",fragmentBase:"scenario"},{projectRelativePath:".cursor/skills/ironbee-search-scenario/SKILL.md",fragmentBase:"scenario"},{projectRelativePath:".cursor/skills/ironbee-sync-scenario/SKILL.md",fragmentBase:"scenario"}],codex:[]};function P(e,n,t,i,r){const d=[],s=Object.keys(v),o=r===void 0?s:s.filter(a=>r.includes(a));for(const a of o){const f=v[a],b=i(a);for(const g of f){const u=`${e}/${g.projectRelativePath}`;if(!(0,l.existsSync)(u))continue;w(u,n,t?y=>{const k=`${b}/${$(g.fragmentBase,n,y)}`;if(!(0,l.existsSync)(k)){const x=y.length>0?`${n}:${y}`:n;return m.logger.warn(`platform-section ${x}: missing fragment ${k} for ${g.projectRelativePath} \u2014 falling back to placeholder.`),null}return(0,l.readFileSync)(k,"utf-8").trimEnd()}:null)&&d.push(g.projectRelativePath)}}return d}c(P,"applyPlatformToProjectFiles");function C(e,n){const t=(0,h.loadConfig)(e);for(const i of h.ALL_CYCLES){const r=(0,h.isCycleEnabled)(t,i);P(e,i,r,n)}}c(C,"syncPlatformSectionsToConfig");0&&(module.exports={PLATFORM_TARGETS,applyPlatformSection,applyPlatformToProjectFiles,fragmentFilename,readFragment,syncPlatformSectionsToConfig,togglePlatformSectionInFile});
5
+ `),terminal:["<!-- Terminal interaction verification is OFF for this project."," - To verify CLI / REPL / TUI changes by driving the program in a PTY"," (send input, read output): run `ironbee terminal enable`. This file"," will be auto-updated with the terminal-cycle guidance."," - When OFF, do NOT invoke any `tdt_*` tools voluntarily. -->"].join(`
6
+ `)};function S(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}l(S,"escapeRegex");function I(e){return new RegExp(`<!--IRONBEE:PLATFORM:${S(e)}(?::([\\w-]+))?-->`,"g")}l(I,"startMarkerRegex");function M(e,n){return n.length>0?`<!--/IRONBEE:PLATFORM:${e}:${n}-->`:`<!--/IRONBEE:PLATFORM:${e}-->`}l(M,"endMarkerFor");function N(e,n,t){const i=I(n),r=[],d=new Set;let s=i.exec(e);for(;s!==null;){const o=s[1]??"",a=s.index+s[0].length,f=M(n,o),h=e.indexOf(f,a);if(h===-1){const g=t?` in ${t}`:"",u=o.length>0?`${n}:${o}`:n;m.logger.debug(`platform-section ${u}: start marker found without matching end marker${g}`),s=i.exec(e);continue}if(d.has(o)){const g=t?` in ${t}`:"",u=o.length>0?`${n}:${o}`:n;m.logger.warn(`platform-section ${u}: multiple marker blocks with the same key${g} \u2014 only the first will be updated. Either consolidate the blocks or use distinct keys (\`IRONBEE:PLATFORM:${n}:<key>\`) per position.`),s=i.exec(e);continue}d.add(o),r.push({key:o,startEnd:a,endIdx:h}),s=i.exec(e)}return r}l(N,"findMarkerBlocks");function R(e,n,t,i){const r=typeof t=="function"?t:()=>t,d=N(e,n,i);if(d.length===0)return e;const s=L[n];if(s===void 0)throw new Error(`No placeholder registered for platform '${n}'.`);let o=e;for(let a=d.length-1;a>=0;a--){const f=d[a],h=r(f.key)??s,g=o.substring(0,f.startEnd),u=o.substring(f.endIdx);o=`${g}
7
+ ${h}
8
+ ${u}`}return o}l(R,"applyPlatformSection");function $(e,n,t){return t.length>0?`${e}.${n}.${t}.md`:`${e}.${n}.md`}l($,"fragmentFilename");function A(e,n){const t=`${e}/${n}`;if(!(0,c.existsSync)(t))throw new Error(`Platform fragment not found: ${t}`);return(0,c.readFileSync)(t,"utf-8").trimEnd()}l(A,"readFragment");function w(e,n,t){if(!(0,c.existsSync)(e))return!1;const i=(0,c.readFileSync)(e,"utf-8"),r=R(i,n,t,e);return r===i?!1:((0,c.writeFileSync)(e,r),!0)}l(w,"togglePlatformSectionInFile");const v={claude:[{projectRelativePath:".claude/agents/ironbee-verifier.md",fragmentBase:"skill"},{projectRelativePath:".claude/agents/ironbee-scenario.md",fragmentBase:"scenario"}],cursor:[{projectRelativePath:".cursor/skills/ironbee-verification.md",fragmentBase:"skill"},{projectRelativePath:".cursor/rules/ironbee-verification.mdc",fragmentBase:"rule"},{projectRelativePath:".cursor/skills/ironbee-verify/SKILL.md",fragmentBase:"command-verify"},{projectRelativePath:".cursor/skills/ironbee-manage-scenario/SKILL.md",fragmentBase:"scenario"},{projectRelativePath:".cursor/skills/ironbee-search-scenario/SKILL.md",fragmentBase:"scenario"},{projectRelativePath:".cursor/skills/ironbee-sync-scenario/SKILL.md",fragmentBase:"scenario"}],codex:[]};function P(e,n,t,i,r){const d=[],s=Object.keys(v),o=r===void 0?s:s.filter(a=>r.includes(a));for(const a of o){const f=v[a],h=i(a);for(const g of f){const u=`${e}/${g.projectRelativePath}`;if(!(0,c.existsSync)(u))continue;w(u,n,t?y=>{const k=`${h}/${$(g.fragmentBase,n,y)}`;if(!(0,c.existsSync)(k)){const T=y.length>0?`${n}:${y}`:n;return m.logger.warn(`platform-section ${T}: missing fragment ${k} for ${g.projectRelativePath} \u2014 falling back to placeholder.`),null}return(0,c.readFileSync)(k,"utf-8").trimEnd()}:null)&&d.push(g.projectRelativePath)}}return d}l(P,"applyPlatformToProjectFiles");function C(e,n){const t=(0,b.loadConfig)(e);for(const i of b.ALL_CYCLES){const r=(0,b.isCycleEnabled)(t,i);P(e,i,r,n)}}l(C,"syncPlatformSectionsToConfig");0&&(module.exports={PLATFORM_TARGETS,applyPlatformSection,applyPlatformToProjectFiles,fragmentFilename,readFragment,syncPlatformSectionsToConfig,togglePlatformSectionInFile});
@@ -0,0 +1 @@
1
+ "use strict";var c=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var e=(n,t)=>c(n,"name",{value:t,configurable:!0});var w=(n,t)=>{for(var i in t)c(n,i,{get:t[i],enumerable:!0})},y=(n,t,i,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of N(t))!_.call(n,o)&&o!==i&&c(n,o,{get:()=>t[o],enumerable:!(s=I(t,o))||s.enumerable});return n};var A=n=>y(c({},"__esModule",{value:!0}),n);var T={};w(T,{IRONBEE_DIRNAME:()=>a,_clearRuntimeLocationCache:()=>v,encodeProjectDir:()=>R,externalRuntimeRoot:()=>d,otelRawDir:()=>b,projectIronbeeDir:()=>x,resolveRuntimeLocation:()=>L,runtimeDir:()=>h,sessionActionsFile:()=>C,sessionAnalyticsDir:()=>B,sessionDir:()=>u,sessionLogFile:()=>O,sessionsRoot:()=>E});module.exports=A(T);var l=require("crypto"),p=require("fs"),m=require("os"),r=require("path");const a=".ironbee",M="IRONBEE_RUNTIME_LOCATION";function x(n){return(0,r.join)(n,a)}e(x,"projectIronbeeDir");function f(n){const t=(0,r.isAbsolute)(n)?n:(0,r.resolve)(n);try{return(0,p.realpathSync)(t)}catch{return t}}e(f,"canonicalProjectDir");function R(n){const t=f(n),i=(0,l.createHash)("sha256").update(t).digest("hex").slice(0,16);return`${((0,r.basename)(t)||"root").replace(/[^A-Za-z0-9._-]/g,"_").slice(0,40)||"root"}-${i}`}e(R,"encodeProjectDir");function d(n){return(0,r.join)((0,m.homedir)(),a,"projects",R(n))}e(d,"externalRuntimeRoot");const g=new Map;function j(n){try{const i=require("./config").loadConfig(n).runtime?.location;if(i==="in-project")return"in-project";if(i==="external")return"external"}catch{}return"external"}e(j,"configRuntimeLocation");function L(n){const t=process.env[M];if(t==="in-project"||t==="external")return t;const i=f(n),s=g.get(i);if(s!==void 0)return s;const o=j(n);return g.set(i,o),o}e(L,"resolveRuntimeLocation");function v(){g.clear()}e(v,"_clearRuntimeLocationCache");function h(n){return L(n)==="in-project"?(0,r.join)(n,a):d(n)}e(h,"runtimeDir");function E(n){return(0,r.join)(h(n),"sessions")}e(E,"sessionsRoot");function u(n,t){return(0,r.join)(E(n),t)}e(u,"sessionDir");function B(n,t){return(0,r.join)(u(n,t),"analytics")}e(B,"sessionAnalyticsDir");function C(n,t){return(0,r.join)(u(n,t),"actions.jsonl")}e(C,"sessionActionsFile");function O(n,t){return(0,r.join)(u(n,t),"session.log")}e(O,"sessionLogFile");function b(n){return(0,r.join)(x(n),"otel")}e(b,"otelRawDir");0&&(module.exports={IRONBEE_DIRNAME,_clearRuntimeLocationCache,encodeProjectDir,externalRuntimeRoot,otelRawDir,projectIronbeeDir,resolveRuntimeLocation,runtimeDir,sessionActionsFile,sessionAnalyticsDir,sessionDir,sessionLogFile,sessionsRoot});
@@ -1 +1 @@
1
- "use strict";var h=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var l=(e,n)=>h(e,"name",{value:n,configurable:!0});var E=(e,n)=>{for(var s in n)h(e,s,{get:n[s],enumerable:!0})},F=(e,n,s,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of P(n))!C.call(e,r)&&r!==s&&h(e,r,{get:()=>n[r],enumerable:!(a=k(n,r))||a.enumerable});return e};var x=e=>F(h({},"__esModule",{value:!0}),e);var A={};E(A,{checkScenarioFreshness:()=>V,coverageGaps:()=>O});module.exports=x(A);var g=require("fs"),p=require("path"),f=require("./git"),b=require("./config"),y=require("./logger");const S={bdt:"browser",ndt:"node",bedt:"backend",adt:"android"};function v(e){return e.length>7?e.slice(0,7):e}l(v,"shortSha");function $(e){const n=e.metadata;if(n===null||typeof n!="object")return{};const s=n.ironbee;return s!==null&&typeof s=="object"?s:{}}l($,"readIronBeeMeta");function w(e){const n=(0,p.join)(e,".ironbee","scenarios");if(!(0,g.existsSync)(n))return[];const s=[];for(const a of Object.keys(S)){const r=(0,p.join)(n,a);if(!(0,g.existsSync)(r))continue;let t;try{t=(0,g.readdirSync)(r).filter(o=>o.endsWith(".json"))}catch(o){y.logger.debug(`scenario-staleness: cannot read ${r}: ${o instanceof Error?o.message:o}`);continue}for(const o of t){const c=(0,p.join)(r,o);let i;try{i=JSON.parse((0,g.readFileSync)(c,"utf-8"))}catch(m){y.logger.debug(`scenario-staleness: bad JSON ${c}: ${m instanceof Error?m.message:m}`);continue}const u=typeof i.name=="string"&&i.name.length>0?i.name:o.replace(/\.json$/,""),d=$(i),R=Array.isArray(d.coveredPaths)?d.coveredPaths.filter(m=>typeof m=="string"):[];s.push({name:u,platform:S[a],file:c,coveredPaths:R,commit:typeof d.commit=="string"&&d.commit.length>0?d.commit:void 0,liveValidated:typeof d.liveValidated=="boolean"?d.liveValidated:void 0})}}return s}l(w,"readScenarioEntries");function V(e){const n=w(e);if(n.length===0)return[];const s=(0,f.isGitRepo)(e),a=new Map,r=[];for(const t of n){const o={name:t.name,platform:t.platform,file:t.file,coveredPaths:t.coveredPaths,commit:t.commit,liveValidated:t.liveValidated,changedCoveredPaths:[]};if(!s){r.push({...o,state:"unknown",reason:"not a git repository"});continue}if(t.coveredPaths.length===0){r.push({...o,state:"unknown",reason:"no ironbee.coveredPaths metadata"});continue}if(t.commit===void 0){r.push({...o,state:"unknown",reason:"no ironbee.commit baseline"});continue}if(!(0,f.gitCommitExists)(e,t.commit)){r.push({...o,state:"unknown",reason:`baseline commit ${v(t.commit)} not in history`});continue}let c;const i=a.get(t.commit);i!==void 0?c=i:(c=(0,f.gitChangedPathsSince)(e,t.commit),a.set(t.commit,c));const u=c.filter(d=>(0,b.matchesAny)(d,t.coveredPaths));if(u.length>0){r.push({...o,state:"stale",reason:`${u.length} covered file(s) changed since ${v(t.commit)}`,changedCoveredPaths:u});continue}if(t.liveValidated===!1){r.push({...o,state:"stale",reason:"authored as a draft \u2014 not live-validated by a passing run"});continue}r.push({...o,state:"fresh",reason:`no covered files changed since ${v(t.commit)}`})}return r}l(V,"checkScenarioFreshness");function O(e,n){const s=w(e),a=Array.from(new Set(n.filter(o=>o.length>0))),r=[],t=[];for(const o of a){const c=s.filter(i=>i.coveredPaths.length>0&&(0,b.matchesAny)(o,i.coveredPaths)).map(i=>i.name);c.length>0?r.push({path:o,scenarios:c}):t.push(o)}return{scenarioCount:s.length,covered:r,gaps:t,changed:a}}l(O,"coverageGaps");0&&(module.exports={checkScenarioFreshness,coverageGaps});
1
+ "use strict";var h=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var l=(e,n)=>h(e,"name",{value:n,configurable:!0});var E=(e,n)=>{for(var s in n)h(e,s,{get:n[s],enumerable:!0})},F=(e,n,s,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of P(n))!C.call(e,r)&&r!==s&&h(e,r,{get:()=>n[r],enumerable:!(a=k(n,r))||a.enumerable});return e};var x=e=>F(h({},"__esModule",{value:!0}),e);var A={};E(A,{checkScenarioFreshness:()=>V,coverageGaps:()=>O});module.exports=x(A);var g=require("fs"),p=require("path"),f=require("./git"),b=require("./config"),y=require("./logger");const S={bdt:"browser",ndt:"node",bedt:"backend",adt:"android",tdt:"terminal"};function v(e){return e.length>7?e.slice(0,7):e}l(v,"shortSha");function $(e){const n=e.metadata;if(n===null||typeof n!="object")return{};const s=n.ironbee;return s!==null&&typeof s=="object"?s:{}}l($,"readIronBeeMeta");function w(e){const n=(0,p.join)(e,".ironbee","scenarios");if(!(0,g.existsSync)(n))return[];const s=[];for(const a of Object.keys(S)){const r=(0,p.join)(n,a);if(!(0,g.existsSync)(r))continue;let t;try{t=(0,g.readdirSync)(r).filter(o=>o.endsWith(".json"))}catch(o){y.logger.debug(`scenario-staleness: cannot read ${r}: ${o instanceof Error?o.message:o}`);continue}for(const o of t){const c=(0,p.join)(r,o);let i;try{i=JSON.parse((0,g.readFileSync)(c,"utf-8"))}catch(u){y.logger.debug(`scenario-staleness: bad JSON ${c}: ${u instanceof Error?u.message:u}`);continue}const m=typeof i.name=="string"&&i.name.length>0?i.name:o.replace(/\.json$/,""),d=$(i),R=Array.isArray(d.coveredPaths)?d.coveredPaths.filter(u=>typeof u=="string"):[];s.push({name:m,platform:S[a],file:c,coveredPaths:R,commit:typeof d.commit=="string"&&d.commit.length>0?d.commit:void 0,liveValidated:typeof d.liveValidated=="boolean"?d.liveValidated:void 0})}}return s}l(w,"readScenarioEntries");function V(e){const n=w(e);if(n.length===0)return[];const s=(0,f.isGitRepo)(e),a=new Map,r=[];for(const t of n){const o={name:t.name,platform:t.platform,file:t.file,coveredPaths:t.coveredPaths,commit:t.commit,liveValidated:t.liveValidated,changedCoveredPaths:[]};if(!s){r.push({...o,state:"unknown",reason:"not a git repository"});continue}if(t.coveredPaths.length===0){r.push({...o,state:"unknown",reason:"no ironbee.coveredPaths metadata"});continue}if(t.commit===void 0){r.push({...o,state:"unknown",reason:"no ironbee.commit baseline"});continue}if(!(0,f.gitCommitExists)(e,t.commit)){r.push({...o,state:"unknown",reason:`baseline commit ${v(t.commit)} not in history`});continue}let c;const i=a.get(t.commit);i!==void 0?c=i:(c=(0,f.gitChangedPathsSince)(e,t.commit),a.set(t.commit,c));const m=c.filter(d=>(0,b.matchesAny)(d,t.coveredPaths));if(m.length>0){r.push({...o,state:"stale",reason:`${m.length} covered file(s) changed since ${v(t.commit)}`,changedCoveredPaths:m});continue}if(t.liveValidated===!1){r.push({...o,state:"stale",reason:"authored as a draft \u2014 not live-validated by a passing run"});continue}r.push({...o,state:"fresh",reason:`no covered files changed since ${v(t.commit)}`})}return r}l(V,"checkScenarioFreshness");function O(e,n){const s=w(e),a=Array.from(new Set(n.filter(o=>o.length>0))),r=[],t=[];for(const o of a){const c=s.filter(i=>i.coveredPaths.length>0&&(0,b.matchesAny)(o,i.coveredPaths)).map(i=>i.name);c.length>0?r.push({path:o,scenarios:c}):t.push(o)}return{scenarioCount:s.length,covered:r,gaps:t,changed:a}}l(O,"coverageGaps");0&&(module.exports={checkScenarioFreshness,coverageGaps});
@@ -1 +1 @@
1
- "use strict";var l=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var o=(e,n)=>l(e,"name",{value:n,configurable:!0});var E=(e,n)=>{for(var t in n)l(e,t,{get:n[t],enumerable:!0})},T=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of w(n))!k.call(e,r)&&r!==t&&l(e,r,{get:()=>n[r],enumerable:!(s=B(n,r))||s.enumerable});return e};var v=e=>T(l({},"__esModule",{value:!0}),e);var I={};E(I,{processBodyFile:()=>P});module.exports=v(I);var p=require("fs"),c=require("path"),a=require("../../../lib/logger"),m=require("../context/util"),_=require("../context/classify"),b=require("../context/build"),d=require("./paths");const y=3,x=50;function C(e){return new Promise(n=>{setTimeout(n,e)})}o(C,"delay");function i(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}o(i,"isObject");function F(e){try{const n=JSON.parse((0,p.readFileSync)(e,"utf8"));return i(n)?n:null}catch{return null}}o(F,"readJsonObject");function q(e){return i(e)&&typeof e.model=="string"&&e.model.length>0?e.model:null}o(q,"modelFromBody");function A(e){if(!i(e)||!i(e.metadata))return null;const n=e.metadata.user_id;if(typeof n!="string")return null;try{const t=JSON.parse(n);if(i(t)&&typeof t.session_id=="string")return t.session_id}catch{}return null}o(A,"sessionIdFromBody");function N(e,n){const t=F((0,c.join)(e,".ironbee","sessions",n,"state.json"));if(!t)return{};const s={};return typeof t.userEmail=="string"&&(s.user_email=t.userEmail),(t.usageType==="api"||t.usageType==="subscription")&&(s.usage_type=t.usageType),typeof t.usagePlan=="string"&&(s.usage_plan=t.usagePlan),typeof t.projectName=="string"&&(s.projectName=t.projectName),s}o(N,"readSessionState");async function P(e){const n=(0,d.projectDirFromBodyRef)(e.body_ref);if(n===null)return a.logger.warn(`otel: refusing body_ref outside a .ironbee/otel dir: ${e.body_ref}`),null;let t=null;for(let f=0;f<y;f++){try{t=(0,p.readFileSync)(e.body_ref,"utf8")}catch{return null}if(e.body_length===null||(0,m.byteLen)(t)===e.body_length||f===y-1)break;await C(x)}if(t===null)return null;let s;try{s=JSON.parse(t)}catch{return a.logger.debug(`otel: unparseable body file ${e.body_ref}`),null}const r=e.session_id??A(s);if(!r)return a.logger.debug(`otel: no session_id for ${e.body_ref}; skipping`),null;const u=N(n,r),S=e.project_name??u.projectName??(0,c.basename)(n),g=q(s)??e.model,j=(0,_.classifyRequestBody)(s,g),R={session_id:r,project_name:S,model:g,query_source:e.query_source,agent_id:e.agent_id,sequence_number:e.sequence_number,timestamp:e.timestamp,request_uuid:(0,d.requestUuidFromBodyRef)(e.body_ref),user_email:u.user_email,usage_type:u.usage_type,usage_plan:u.usage_plan};return{event:(0,b.buildSessionContextEvent)(R,j),projectDir:n,bodyRef:e.body_ref}}o(P,"processBodyFile");0&&(module.exports={processBodyFile});
1
+ "use strict";var l=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var o=(e,n)=>l(e,"name",{value:n,configurable:!0});var E=(e,n)=>{for(var t in n)l(e,t,{get:n[t],enumerable:!0})},T=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of k(n))!v.call(e,r)&&r!==t&&l(e,r,{get:()=>n[r],enumerable:!(s=w(n,r))||s.enumerable});return e};var x=e=>T(l({},"__esModule",{value:!0}),e);var h={};E(h,{processBodyFile:()=>I});module.exports=x(h);var p=require("fs"),c=require("path"),a=require("../../../lib/logger"),m=require("../context/util"),_=require("../context/classify"),b=require("../context/build"),d=require("./paths"),S=require("../../../lib/runtime-paths");const y=3,C=50;function F(e){return new Promise(n=>{setTimeout(n,e)})}o(F,"delay");function i(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}o(i,"isObject");function q(e){try{const n=JSON.parse((0,p.readFileSync)(e,"utf8"));return i(n)?n:null}catch{return null}}o(q,"readJsonObject");function A(e){return i(e)&&typeof e.model=="string"&&e.model.length>0?e.model:null}o(A,"modelFromBody");function N(e){if(!i(e)||!i(e.metadata))return null;const n=e.metadata.user_id;if(typeof n!="string")return null;try{const t=JSON.parse(n);if(i(t)&&typeof t.session_id=="string")return t.session_id}catch{}return null}o(N,"sessionIdFromBody");function P(e,n){const t=q((0,c.join)((0,S.sessionDir)(e,n),"state.json"));if(!t)return{};const s={};return typeof t.userEmail=="string"&&(s.user_email=t.userEmail),(t.usageType==="api"||t.usageType==="subscription")&&(s.usage_type=t.usageType),typeof t.usagePlan=="string"&&(s.usage_plan=t.usagePlan),typeof t.projectName=="string"&&(s.projectName=t.projectName),s}o(P,"readSessionState");async function I(e){const n=(0,d.projectDirFromBodyRef)(e.body_ref);if(n===null)return a.logger.warn(`otel: refusing body_ref outside a .ironbee/otel dir: ${e.body_ref}`),null;let t=null;for(let f=0;f<y;f++){try{t=(0,p.readFileSync)(e.body_ref,"utf8")}catch{return null}if(e.body_length===null||(0,m.byteLen)(t)===e.body_length||f===y-1)break;await F(C)}if(t===null)return null;let s;try{s=JSON.parse(t)}catch{return a.logger.debug(`otel: unparseable body file ${e.body_ref}`),null}const r=e.session_id??N(s);if(!r)return a.logger.debug(`otel: no session_id for ${e.body_ref}; skipping`),null;const u=P(n,r),j=e.project_name??u.projectName??(0,c.basename)(n),g=A(s)??e.model,R=(0,_.classifyRequestBody)(s,g),B={session_id:r,project_name:j,model:g,query_source:e.query_source,agent_id:e.agent_id,sequence_number:e.sequence_number,timestamp:e.timestamp,request_uuid:(0,d.requestUuidFromBodyRef)(e.body_ref),user_email:u.user_email,usage_type:u.usage_type,usage_plan:u.usage_plan};return{event:(0,b.buildSessionContextEvent)(B,R),projectDir:n,bodyRef:e.body_ref}}o(I,"processBodyFile");0&&(module.exports={processBodyFile});
@@ -1 +1 @@
1
- "use strict";var i=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var u=(t,e)=>i(t,"name",{value:e,configurable:!0});var j=(t,e)=>{for(var r in e)i(t,r,{get:e[r],enumerable:!0})},g=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of h(e))!y.call(t,o)&&o!==r&&i(t,o,{get:()=>e[o],enumerable:!(n=b(e,o))||n.enumerable});return t};var q=t=>g(i({},"__esModule",{value:!0}),t);var E={};j(E,{countOrphanFiles:()=>_,reprocessOrphans:()=>S});module.exports=q(E);var s=require("fs"),c=require("path"),l=require("../../../lib/projects-registry"),p=require("../../../lib/logger");function _(){let t;try{t=(0,l.listProjects)()}catch{return 0}let e=0;for(const r of t)try{for(const n of(0,s.readdirSync)((0,c.join)(r.path,".ironbee","otel")))n.endsWith(".request.json")&&(e+=1)}catch{}return e}u(_,"countOrphanFiles");function M(t,e){return{body_ref:t,sequence_number:null,model:"",query_source:null,agent_id:null,body_length:null,session_id:null,project_name:null,timestamp:e,from_catchup:!0}}u(M,"orphanMeta");function S(t){let e;try{e=(0,l.listProjects)()}catch(n){return p.logger.debug(`otel: reprocess could not read project registry: ${n instanceof Error?n.message:String(n)}`),0}let r=0;for(const n of e){const o=(0,c.join)(n.path,".ironbee","otel");let f;try{f=(0,s.readdirSync)(o)}catch{continue}for(const m of f){const a=(0,c.join)(o,m);if(m.endsWith(".request.json")){let d=Date.now();try{d=(0,s.statSync)(a).mtimeMs}catch{continue}t.submit(M(a,d)),r+=1}else if(m.endsWith(".response.json"))try{(0,s.unlinkSync)(a)}catch{}}}return r>0&&p.logger.debug(`otel: reprocess resubmitted ${r} orphan request bodies`),r}u(S,"reprocessOrphans");0&&(module.exports={countOrphanFiles,reprocessOrphans});
1
+ "use strict";var i=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var u=(e,t)=>i(e,"name",{value:t,configurable:!0});var g=(e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})},q=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of b(t))!j.call(e,o)&&o!==r&&i(e,o,{get:()=>t[o],enumerable:!(n=y(t,o))||n.enumerable});return e};var _=e=>q(i({},"__esModule",{value:!0}),e);var O={};g(O,{countOrphanFiles:()=>M,reprocessOrphans:()=>E});module.exports=_(O);var s=require("fs"),h=require("path"),a=require("../../../lib/projects-registry"),l=require("../../../lib/logger"),p=require("../../../lib/runtime-paths");function M(){let e;try{e=(0,a.listProjects)()}catch{return 0}let t=0;for(const r of e)try{for(const n of(0,s.readdirSync)((0,p.otelRawDir)(r.path)))n.endsWith(".request.json")&&(t+=1)}catch{}return t}u(M,"countOrphanFiles");function S(e,t){return{body_ref:e,sequence_number:null,model:"",query_source:null,agent_id:null,body_length:null,session_id:null,project_name:null,timestamp:t,from_catchup:!0}}u(S,"orphanMeta");function E(e){let t;try{t=(0,a.listProjects)()}catch(n){return l.logger.debug(`otel: reprocess could not read project registry: ${n instanceof Error?n.message:String(n)}`),0}let r=0;for(const n of t){const o=(0,p.otelRawDir)(n.path);let f;try{f=(0,s.readdirSync)(o)}catch{continue}for(const c of f){const m=(0,h.join)(o,c);if(c.endsWith(".request.json")){let d=Date.now();try{d=(0,s.statSync)(m).mtimeMs}catch{continue}e.submit(S(m,d)),r+=1}else if(c.endsWith(".response.json"))try{(0,s.unlinkSync)(m)}catch{}}}return r>0&&l.logger.debug(`otel: reprocess resubmitted ${r} orphan request bodies`),r}u(E,"reprocessOrphans");0&&(module.exports={countOrphanFiles,reprocessOrphans});
@@ -1,3 +1,3 @@
1
- "use strict";var g=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var i=(e,n)=>g(e,"name",{value:n,configurable:!0});var x=(e,n)=>{for(var t in n)g(e,t,{get:n[t],enumerable:!0})},E=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of L(n))!q.call(e,o)&&o!==t&&g(e,o,{get:()=>n[o],enumerable:!(r=O(n,o))||r.enumerable});return e};var T=e=>E(g({},"__esModule",{value:!0}),e);var j={};x(j,{classifyQuerySource:()=>R,extractResponseUsage:()=>k,otelRequestsSidecarPath:()=>h,recordResponseUsage:()=>F});module.exports=T(j);var c=require("fs"),f=require("path"),_=require("../../../lib/logger"),y=require("./paths");const N=new Set(["repl_main_thread","sdk","compact"]),U=new Set(["prompt_suggestion","generate_session_title"]);function R(e){return e==null||e.length===0?"main":e.startsWith("agent:")||e==="subagent"?"subagent":N.has(e)?"main":U.has(e)?"feature":"unknown"}i(R,"classifyQuerySource");function s(e,n){for(const t of e.attributes??[])if(t&&t.key===n&&typeof t.value?.stringValue=="string")return t.value.stringValue}i(s,"strAttr");function v(e){const n=s(e,"event.timestamp");if(n){const r=Date.parse(n);if(Number.isFinite(r))return r}const t=e.timeUnixNano??e.observedTimeUnixNano;if(t)try{return Number(BigInt(t)/1000000n)}catch{}return 0}i(v,"resolveTsMs");function P(e){return e.replace(/\[[^\]]*\]/g,"").trim()}i(P,"normalizeModel");function a(e){return typeof e=="number"&&Number.isFinite(e)?e:0}i(a,"numField");function k(e){const n=s(e,"body_ref");if(!n)return null;const t=(0,y.projectDirFromBodyRef)(n);if(t===null)return null;const r=s(e,"query_source"),o=R(r);if(o==="main")return null;if(o==="unknown")return _.logger.debug(`otel: unclassified query_source '${r??""}' \u2014 not folded into session_analytics (classify in response-usage.ts if it should be)`),null;const l=s(e,"request_id"),p=s(e,"session.id");if(!l||!p)return null;let d;try{d=JSON.parse((0,c.readFileSync)(n,"utf-8"))}catch{return null}const u=d.usage??{},m=u.cache_creation??{},b=u.server_tool_use??{},w=P(s(e,"model")??(typeof d.model=="string"?d.model:"")),S={request_id:l,message_id:typeof d.id=="string"?d.id:null,model:w,query_source:r,timestamp_ms:v(e),input_tokens:a(u.input_tokens),output_tokens:a(u.output_tokens),cache_read_tokens:a(u.cache_read_input_tokens),cache_creation_tokens:a(u.cache_creation_input_tokens),cache_creation_5m_tokens:a(m.ephemeral_5m_input_tokens),cache_creation_1h_tokens:a(m.ephemeral_1h_input_tokens),web_search_requests:a(b.web_search_requests),speed:typeof u.speed=="string"?u.speed:void 0};return{sessionId:p,projectDir:t,record:S}}i(k,"extractResponseUsage");function h(e,n){return(0,f.join)(e,".ironbee","sessions",n,"analytics","otel-requests.jsonl")}i(h,"otelRequestsSidecarPath");function I(e){const n=process.env.IRONBEE_OTEL_CAPTURE;if(n)try{const t=s(e,"body_ref");let r=null,o=null;if(t!==void 0)try{const l=JSON.parse((0,c.readFileSync)(t,"utf-8"));r=l.usage??null,o=l.id??null}catch{}(0,c.appendFileSync)(n,JSON.stringify({query_source:s(e,"query_source")??null,request_id:s(e,"request_id")??null,session_id:s(e,"session.id")??null,model:s(e,"model")??null,message_id:o,agent_id_attr:s(e,"agent.id")??null,prompt_id_attr:s(e,"prompt.id")??null,usage:r})+`
2
- `)}catch{}}i(I,"captureAllResponses");function F(e){I(e);const n=k(e);if(n!==null)try{const t=h(n.projectDir,n.sessionId);(0,c.mkdirSync)((0,f.dirname)(t),{recursive:!0}),(0,c.appendFileSync)(t,JSON.stringify(n.record)+`
1
+ "use strict";var g=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var i=(e,n)=>g(e,"name",{value:n,configurable:!0});var E=(e,n)=>{for(var t in n)g(e,t,{get:n[t],enumerable:!0})},T=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of q(n))!x.call(e,o)&&o!==t&&g(e,o,{get:()=>n[o],enumerable:!(r=L(n,o))||r.enumerable});return e};var N=e=>T(g({},"__esModule",{value:!0}),e);var j={};E(j,{classifyQuerySource:()=>k,extractResponseUsage:()=>h,otelRequestsSidecarPath:()=>b,recordResponseUsage:()=>F});module.exports=N(j);var c=require("fs"),f=require("path"),_=require("../../../lib/logger"),y=require("./paths"),R=require("../../../lib/runtime-paths");const U=new Set(["repl_main_thread","sdk","compact"]),v=new Set(["prompt_suggestion","generate_session_title"]);function k(e){return e==null||e.length===0?"main":e.startsWith("agent:")||e==="subagent"?"subagent":U.has(e)?"main":v.has(e)?"feature":"unknown"}i(k,"classifyQuerySource");function s(e,n){for(const t of e.attributes??[])if(t&&t.key===n&&typeof t.value?.stringValue=="string")return t.value.stringValue}i(s,"strAttr");function P(e){const n=s(e,"event.timestamp");if(n){const r=Date.parse(n);if(Number.isFinite(r))return r}const t=e.timeUnixNano??e.observedTimeUnixNano;if(t)try{return Number(BigInt(t)/1000000n)}catch{}return 0}i(P,"resolveTsMs");function I(e){return e.replace(/\[[^\]]*\]/g,"").trim()}i(I,"normalizeModel");function a(e){return typeof e=="number"&&Number.isFinite(e)?e:0}i(a,"numField");function h(e){const n=s(e,"body_ref");if(!n)return null;const t=(0,y.projectDirFromBodyRef)(n);if(t===null)return null;const r=s(e,"query_source"),o=k(r);if(o==="main")return null;if(o==="unknown")return _.logger.debug(`otel: unclassified query_source '${r??""}' \u2014 not folded into session_analytics (classify in response-usage.ts if it should be)`),null;const l=s(e,"request_id"),p=s(e,"session.id");if(!l||!p)return null;let d;try{d=JSON.parse((0,c.readFileSync)(n,"utf-8"))}catch{return null}const u=d.usage??{},m=u.cache_creation??{},w=u.server_tool_use??{},S=I(s(e,"model")??(typeof d.model=="string"?d.model:"")),O={request_id:l,message_id:typeof d.id=="string"?d.id:null,model:S,query_source:r,timestamp_ms:P(e),input_tokens:a(u.input_tokens),output_tokens:a(u.output_tokens),cache_read_tokens:a(u.cache_read_input_tokens),cache_creation_tokens:a(u.cache_creation_input_tokens),cache_creation_5m_tokens:a(m.ephemeral_5m_input_tokens),cache_creation_1h_tokens:a(m.ephemeral_1h_input_tokens),web_search_requests:a(w.web_search_requests),speed:typeof u.speed=="string"?u.speed:void 0};return{sessionId:p,projectDir:t,record:O}}i(h,"extractResponseUsage");function b(e,n){return(0,f.join)((0,R.sessionAnalyticsDir)(e,n),"otel-requests.jsonl")}i(b,"otelRequestsSidecarPath");function A(e){const n=process.env.IRONBEE_OTEL_CAPTURE;if(n)try{const t=s(e,"body_ref");let r=null,o=null;if(t!==void 0)try{const l=JSON.parse((0,c.readFileSync)(t,"utf-8"));r=l.usage??null,o=l.id??null}catch{}(0,c.appendFileSync)(n,JSON.stringify({query_source:s(e,"query_source")??null,request_id:s(e,"request_id")??null,session_id:s(e,"session.id")??null,model:s(e,"model")??null,message_id:o,agent_id_attr:s(e,"agent.id")??null,prompt_id_attr:s(e,"prompt.id")??null,usage:r})+`
2
+ `)}catch{}}i(A,"captureAllResponses");function F(e){A(e);const n=h(e);if(n!==null)try{const t=b(n.projectDir,n.sessionId);(0,c.mkdirSync)((0,f.dirname)(t),{recursive:!0}),(0,c.appendFileSync)(t,JSON.stringify(n.record)+`
3
3
  `)}catch(t){_.logger.debug(`otel: failed to write otel-requests sidecar: ${t instanceof Error?t.message:String(t)}`)}}i(F,"recordResponseUsage");0&&(module.exports={classifyQuerySource,extractResponseUsage,otelRequestsSidecarPath,recordResponseUsage});
@@ -1 +1 @@
1
- "use strict";var m=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var c=(n,t)=>m(n,"name",{value:t,configurable:!0});var D=(n,t)=>{for(var r in t)m(n,r,{get:t[r],enumerable:!0})},k=(n,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of S(t))!E.call(n,e)&&e!==r&&m(n,e,{get:()=>t[e],enumerable:!(s=y(t,e))||s.enumerable});return n};var _=n=>k(m({},"__esModule",{value:!0}),n);var j={};D(j,{drain:()=>O});module.exports=_(j);var o=require("fs"),p=require("path"),R=require("./snapshot"),b=require("./process-file"),i=require("./paths");async function O(n,t,r){(0,i.validateSessionId)(t);const s=(0,i.queueDir)(n,t),e={snapshotsProcessed:0,snapshotsRemaining:0,cleanedQueueDir:!1,snapshotsSkippedRecent:0};if(!(0,o.existsSync)(s))return e;const a=r?.skipRecentMs??0;let u=null;try{u=(0,R.snapshot)(n,t)}catch{}const{eligible:f,skipped:l}=h(s,a,u);e.snapshotsSkippedRecent=l;for(const g of f)try{await(0,b.processFile)(g,{registry:r?.registry}),e.snapshotsProcessed++}catch{}return e.snapshotsRemaining=h(s,0,null).eligible.length,e.cleanedQueueDir=T(n,t),e}c(O,"drain");function h(n,t,r){let s;try{s=(0,o.readdirSync)(n)}catch{return{eligible:[],skipped:0}}const e=Date.now(),a=[];let u=0;for(const f of s){if(!i.SNAPSHOT_FILENAME_REGEX.test(f))continue;const l=(0,p.join)(n,f);if(r!==null&&l===r){a.push(l);continue}if(t>0)try{const g=(0,o.statSync)(l).mtimeMs;if(e-g<t){u++;continue}}catch{}a.push(l)}return a.sort(),{eligible:a,skipped:u}}c(h,"listSnapshots");function T(n,t){const r=(0,i.queueDir)(n,t);let s;try{s=(0,o.readdirSync)(r)}catch{return!1}for(const e of s)if(e==="jobs.jsonl"&&d((0,p.join)(r,e))>0||i.SNAPSHOT_FILENAME_REGEX.test(e)||(e==="dead-letter.jsonl"||i.DEAD_LETTER_ROTATED_REGEX.test(e))&&d((0,p.join)(r,e))>0)return!1;for(const e of s)if(e==="jobs.jsonl"||e==="dead-letter.jsonl"||i.DEAD_LETTER_ROTATED_REGEX.test(e)||e==="worker.log"||i.WORKER_LOG_ROTATED_REGEX.test(e))try{(0,o.unlinkSync)((0,p.join)(r,e))}catch{}try{return(0,o.rmdirSync)(r),!0}catch{return!1}}c(T,"tryCleanupQueueDir");function d(n){try{return(0,o.statSync)(n).size}catch{return 0}}c(d,"fileSize");0&&(module.exports={drain});
1
+ "use strict";var m=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var c=(n,t)=>m(n,"name",{value:t,configurable:!0});var D=(n,t)=>{for(var r in t)m(n,r,{get:t[r],enumerable:!0})},k=(n,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of S(t))!E.call(n,e)&&e!==r&&m(n,e,{get:()=>t[e],enumerable:!(s=y(t,e))||s.enumerable});return n};var _=n=>k(m({},"__esModule",{value:!0}),n);var j={};D(j,{drain:()=>O});module.exports=_(j);var o=require("fs"),p=require("path"),R=require("./snapshot"),b=require("./process-file"),i=require("./paths");async function O(n,t,r){(0,i.validateSessionId)(t);const s=(0,i.queueDir)(n,t),e={snapshotsProcessed:0,snapshotsRemaining:0,cleanedQueueDir:!1,snapshotsSkippedRecent:0};if(!(0,o.existsSync)(s))return e;const a=r?.skipRecentMs??0;let u=null;try{u=(0,R.snapshot)(n,t)}catch{}const{eligible:f,skipped:l}=h(s,a,u);e.snapshotsSkippedRecent=l;for(const g of f)try{await(0,b.processFile)(g,{registry:r?.registry,projectDir:n,sessionId:t}),e.snapshotsProcessed++}catch{}return e.snapshotsRemaining=h(s,0,null).eligible.length,e.cleanedQueueDir=T(n,t),e}c(O,"drain");function h(n,t,r){let s;try{s=(0,o.readdirSync)(n)}catch{return{eligible:[],skipped:0}}const e=Date.now(),a=[];let u=0;for(const f of s){if(!i.SNAPSHOT_FILENAME_REGEX.test(f))continue;const l=(0,p.join)(n,f);if(r!==null&&l===r){a.push(l);continue}if(t>0)try{const g=(0,o.statSync)(l).mtimeMs;if(e-g<t){u++;continue}}catch{}a.push(l)}return a.sort(),{eligible:a,skipped:u}}c(h,"listSnapshots");function T(n,t){const r=(0,i.queueDir)(n,t);let s;try{s=(0,o.readdirSync)(r)}catch{return!1}for(const e of s)if(e==="jobs.jsonl"&&d((0,p.join)(r,e))>0||i.SNAPSHOT_FILENAME_REGEX.test(e)||(e==="dead-letter.jsonl"||i.DEAD_LETTER_ROTATED_REGEX.test(e))&&d((0,p.join)(r,e))>0)return!1;for(const e of s)if(e==="jobs.jsonl"||e==="dead-letter.jsonl"||i.DEAD_LETTER_ROTATED_REGEX.test(e)||e==="worker.log"||i.WORKER_LOG_ROTATED_REGEX.test(e))try{(0,o.unlinkSync)((0,p.join)(r,e))}catch{}try{return(0,o.rmdirSync)(r),!0}catch{return!1}}c(T,"tryCleanupQueueDir");function d(n){try{return(0,o.statSync)(n).size}catch{return 0}}c(d,"fileSize");0&&(module.exports={drain});
@@ -1 +1 @@
1
- "use strict";var l=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var a=(t,e)=>l(t,"name",{value:e,configurable:!0});var A=(t,e)=>{for(var n in e)l(t,n,{get:e[n],enumerable:!0})},x=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of F(e))!T.call(t,s)&&s!==n&&l(t,s,{get:()=>e[s],enumerable:!(r=w(e,s))||r.enumerable});return t};var B=t=>x(l({},"__esModule",{value:!0}),t);var N={};A(N,{DEFAULT_AUTO_FLUSH_INTERVAL_SECONDS:()=>y,DEFAULT_AUTO_FLUSH_SIZE_BYTES:()=>E,SESSION_END_SKIP_RECENT_MS:()=>k,flushInBackground:()=>_,flushStragglersInBackground:()=>I,flushSynchronously:()=>z,maybeAutoFlush:()=>O});module.exports=B(N);var i=require("fs"),S=require("../lib/config"),u=require("../lib/logger"),p=require("./drain"),o=require("./paths"),b=require("./snapshot"),g=require("./spawn");const E=32*1024,y=60;function _(t,e){try{(0,o.validateSessionId)(e);const n=(0,b.snapshot)(t,e);n!==null&&(0,g.spawnDetachedWorker)(n)}catch(n){u.logger.debug(`queue flushInBackground failed: ${n instanceof Error?n.message:n}`)}}a(_,"flushInBackground");function I(t,e){try{(0,o.validateSessionId)(e);const n=(0,o.queueDir)(t,e);if(!(0,i.existsSync)(n)||!(0,i.readdirSync)(n).some(c=>o.SNAPSHOT_FILENAME_REGEX.test(c)))return;(0,g.spawnDetachedDrainer)(t,e)}catch(n){u.logger.debug(`queue flushStragglersInBackground failed: ${n instanceof Error?n.message:n}`)}}a(I,"flushStragglersInBackground");function O(t,e){try{const n=(0,S.loadConfig)(t),r=n.jobQueue?.autoFlushSizeBytes,s=typeof r=="number"?r:E,c=n.jobQueue?.autoFlushIntervalSeconds,m=typeof c=="number"?c:y,d=s>0,h=m>0;if(!d&&!h)return;const D=(0,o.liveQueueFile)(t,e),f=(0,i.statSync)(D);if(f.size<=0)return;const v=d&&f.size>=s,R=h&&Date.now()-f.birthtimeMs>=m*1e3;(v||R)&&_(t,e)}catch(n){u.logger.debug(`queue maybeAutoFlush skipped: ${n instanceof Error?n.message:n}`)}}a(O,"maybeAutoFlush");const k=2e3;async function z(t,e,n){try{(0,o.validateSessionId)(e);const r={...n,skipRecentMs:n?.skipRecentMs??k};return await(0,p.drain)(t,e,r)}catch(r){return u.logger.debug(`queue flushSynchronously failed: ${r instanceof Error?r.message:r}`),{snapshotsProcessed:0,snapshotsRemaining:0,cleanedQueueDir:!1,snapshotsSkippedRecent:0}}}a(z,"flushSynchronously");0&&(module.exports={DEFAULT_AUTO_FLUSH_INTERVAL_SECONDS,DEFAULT_AUTO_FLUSH_SIZE_BYTES,SESSION_END_SKIP_RECENT_MS,flushInBackground,flushStragglersInBackground,flushSynchronously,maybeAutoFlush});
1
+ "use strict";var l=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var a=(t,e)=>l(t,"name",{value:e,configurable:!0});var A=(t,e)=>{for(var n in e)l(t,n,{get:e[n],enumerable:!0})},x=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of F(e))!T.call(t,s)&&s!==n&&l(t,s,{get:()=>e[s],enumerable:!(r=w(e,s))||r.enumerable});return t};var B=t=>x(l({},"__esModule",{value:!0}),t);var N={};A(N,{DEFAULT_AUTO_FLUSH_INTERVAL_SECONDS:()=>y,DEFAULT_AUTO_FLUSH_SIZE_BYTES:()=>E,SESSION_END_SKIP_RECENT_MS:()=>k,flushInBackground:()=>_,flushStragglersInBackground:()=>O,flushSynchronously:()=>I,maybeAutoFlush:()=>z});module.exports=B(N);var i=require("fs"),S=require("../lib/config"),u=require("../lib/logger"),p=require("./drain"),o=require("./paths"),b=require("./snapshot"),g=require("./spawn");const E=32*1024,y=60;function _(t,e){try{(0,o.validateSessionId)(e);const n=(0,b.snapshot)(t,e);n!==null&&(0,g.spawnDetachedWorker)(n,t,e)}catch(n){u.logger.debug(`queue flushInBackground failed: ${n instanceof Error?n.message:n}`)}}a(_,"flushInBackground");function O(t,e){try{(0,o.validateSessionId)(e);const n=(0,o.queueDir)(t,e);if(!(0,i.existsSync)(n)||!(0,i.readdirSync)(n).some(c=>o.SNAPSHOT_FILENAME_REGEX.test(c)))return;(0,g.spawnDetachedDrainer)(t,e)}catch(n){u.logger.debug(`queue flushStragglersInBackground failed: ${n instanceof Error?n.message:n}`)}}a(O,"flushStragglersInBackground");function z(t,e){try{const n=(0,S.loadConfig)(t),r=n.jobQueue?.autoFlushSizeBytes,s=typeof r=="number"?r:E,c=n.jobQueue?.autoFlushIntervalSeconds,m=typeof c=="number"?c:y,d=s>0,h=m>0;if(!d&&!h)return;const v=(0,o.liveQueueFile)(t,e),f=(0,i.statSync)(v);if(f.size<=0)return;const D=d&&f.size>=s,R=h&&Date.now()-f.birthtimeMs>=m*1e3;(D||R)&&_(t,e)}catch(n){u.logger.debug(`queue maybeAutoFlush skipped: ${n instanceof Error?n.message:n}`)}}a(z,"maybeAutoFlush");const k=2e3;async function I(t,e,n){try{(0,o.validateSessionId)(e);const r={...n,skipRecentMs:n?.skipRecentMs??k};return await(0,p.drain)(t,e,r)}catch(r){return u.logger.debug(`queue flushSynchronously failed: ${r instanceof Error?r.message:r}`),{snapshotsProcessed:0,snapshotsRemaining:0,cleanedQueueDir:!1,snapshotsSkippedRecent:0}}}a(I,"flushSynchronously");0&&(module.exports={DEFAULT_AUTO_FLUSH_INTERVAL_SECONDS,DEFAULT_AUTO_FLUSH_SIZE_BYTES,SESSION_END_SKIP_RECENT_MS,flushInBackground,flushStragglersInBackground,flushSynchronously,maybeAutoFlush});
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var i=(r,n)=>u(r,"name",{value:n,configurable:!0});var D=(r,n)=>{for(var t in n)u(r,t,{get:n[t],enumerable:!0})},b=(r,n,t,g)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of h(n))!w.call(r,o)&&o!==t&&u(r,o,{get:()=>n[o],enumerable:!(g=m(n,o))||g.enumerable});return r};var j=r=>b(u({},"__esModule",{value:!0}),r);var F={};D(F,{DEAD_LETTER_ROTATED_REGEX:()=>R,SESSION_ID_MAX_LEN:()=>c,SNAPSHOT_FILENAME_REGEX:()=>S,WORKER_LOG_ROTATED_REGEX:()=>_,deadLetterFile:()=>q,liveQueueFile:()=>T,parseSnapshotPath:()=>O,queueDir:()=>a,resolveProjectDir:()=>v,sessionDir:()=>E,sessionsRoot:()=>d,snapshotFile:()=>$,validateSessionId:()=>A,workerLogFile:()=>L});module.exports=j(F);var e=require("path"),s=require("./types"),p=require("../clients/agent-project-dir");const S=/^jobs-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.jsonl$/,R=/^dead-letter-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.jsonl$/,_=/^worker-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.log$/,c=128;function v(r){return(0,p.resolveAgentProjectDir)(r)}i(v,"resolveProjectDir");function A(r){if(typeof r!="string"||r.length===0)throw new s.InvalidSessionIdError("session id is empty");if(r.length>c)throw new s.InvalidSessionIdError(`session id exceeds ${c} chars`);if(r==="."||r==="..")throw new s.InvalidSessionIdError("session id is a reserved path component");for(let n=0;n<r.length;n++){const t=r.charCodeAt(n);if(t<32||t===127)throw new s.InvalidSessionIdError("session id contains ASCII control character")}if(r.includes("/")||r.includes("\\")||r.includes("\0"))throw new s.InvalidSessionIdError("session id contains path separator or null byte")}i(A,"validateSessionId");function d(r){return(0,e.join)(r,".ironbee","sessions")}i(d,"sessionsRoot");function E(r,n){return(0,e.join)(d(r),n)}i(E,"sessionDir");function a(r,n){return(0,e.join)(E(r,n),"queue")}i(a,"queueDir");function T(r,n){return(0,e.join)(a(r,n),"jobs.jsonl")}i(T,"liveQueueFile");function $(r,n,t){return(0,e.join)(a(r,n),`jobs-${t}.jsonl`)}i($,"snapshotFile");function q(r,n){return(0,e.join)(a(r,n),"dead-letter.jsonl")}i(q,"deadLetterFile");function L(r,n){return(0,e.join)(a(r,n),"worker.log")}i(L,"workerLogFile");function O(r){const n=(0,e.basename)(r),t=(0,e.dirname)(r),g=(0,e.dirname)(t),o=(0,e.dirname)(g),l=(0,e.dirname)(o),x=(0,e.dirname)(l);if((0,e.basename)(t)!=="queue"||(0,e.basename)(o)!=="sessions"||(0,e.basename)(l)!==".ironbee")throw new Error(`snapshot path is not under a valid session queue dir: ${r}`);const f=(0,e.basename)(g);if(f.length===0||f===".")throw new Error(`snapshot path is not under a valid session queue dir: ${r}`);return{projectDir:x,sessionId:f,filename:n}}i(O,"parseSnapshotPath");0&&(module.exports={DEAD_LETTER_ROTATED_REGEX,SESSION_ID_MAX_LEN,SNAPSHOT_FILENAME_REGEX,WORKER_LOG_ROTATED_REGEX,deadLetterFile,liveQueueFile,parseSnapshotPath,queueDir,resolveProjectDir,sessionDir,sessionsRoot,snapshotFile,validateSessionId,workerLogFile});
1
+ "use strict";var u=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var i=(r,n)=>u(r,"name",{value:n,configurable:!0});var D=(r,n)=>{for(var t in n)u(r,t,{get:n[t],enumerable:!0})},S=(r,n,t,g)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of h(n))!w.call(r,o)&&o!==t&&u(r,o,{get:()=>n[o],enumerable:!(g=x(n,o))||g.enumerable});return r};var R=r=>S(u({},"__esModule",{value:!0}),r);var G={};D(G,{DEAD_LETTER_ROTATED_REGEX:()=>j,SESSION_ID_MAX_LEN:()=>l,SNAPSHOT_FILENAME_REGEX:()=>b,WORKER_LOG_ROTATED_REGEX:()=>_,deadLetterFile:()=>L,liveQueueFile:()=>$,parseSnapshotPath:()=>F,queueDir:()=>a,resolveProjectDir:()=>v,sessionDir:()=>m,sessionsRoot:()=>T,snapshotFile:()=>q,validateSessionId:()=>A,workerLogFile:()=>O});module.exports=R(G);var e=require("path"),s=require("./types"),d=require("../clients/agent-project-dir"),f=require("../lib/runtime-paths");const b=/^jobs-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.jsonl$/,j=/^dead-letter-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.jsonl$/,_=/^worker-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.log$/,l=128;function v(r){return(0,d.resolveAgentProjectDir)(r)}i(v,"resolveProjectDir");function A(r){if(typeof r!="string"||r.length===0)throw new s.InvalidSessionIdError("session id is empty");if(r.length>l)throw new s.InvalidSessionIdError(`session id exceeds ${l} chars`);if(r==="."||r==="..")throw new s.InvalidSessionIdError("session id is a reserved path component");for(let n=0;n<r.length;n++){const t=r.charCodeAt(n);if(t<32||t===127)throw new s.InvalidSessionIdError("session id contains ASCII control character")}if(r.includes("/")||r.includes("\\")||r.includes("\0"))throw new s.InvalidSessionIdError("session id contains path separator or null byte")}i(A,"validateSessionId");function T(r){return(0,f.sessionsRoot)(r)}i(T,"sessionsRoot");function m(r,n){return(0,f.sessionDir)(r,n)}i(m,"sessionDir");function a(r,n){return(0,e.join)(m(r,n),"queue")}i(a,"queueDir");function $(r,n){return(0,e.join)(a(r,n),"jobs.jsonl")}i($,"liveQueueFile");function q(r,n,t){return(0,e.join)(a(r,n),`jobs-${t}.jsonl`)}i(q,"snapshotFile");function L(r,n){return(0,e.join)(a(r,n),"dead-letter.jsonl")}i(L,"deadLetterFile");function O(r,n){return(0,e.join)(a(r,n),"worker.log")}i(O,"workerLogFile");function F(r){const n=(0,e.basename)(r),t=(0,e.dirname)(r),g=(0,e.dirname)(t),o=(0,e.dirname)(g),p=(0,e.dirname)(o),E=(0,e.dirname)(p);if((0,e.basename)(t)!=="queue"||(0,e.basename)(o)!=="sessions"||(0,e.basename)(p)!==".ironbee")throw new Error(`snapshot path is not under a valid session queue dir: ${r}`);const c=(0,e.basename)(g);if(c.length===0||c===".")throw new Error(`snapshot path is not under a valid session queue dir: ${r}`);return{projectDir:E,sessionId:c,filename:n}}i(F,"parseSnapshotPath");0&&(module.exports={DEAD_LETTER_ROTATED_REGEX,SESSION_ID_MAX_LEN,SNAPSHOT_FILENAME_REGEX,WORKER_LOG_ROTATED_REGEX,deadLetterFile,liveQueueFile,parseSnapshotPath,queueDir,resolveProjectDir,sessionDir,sessionsRoot,snapshotFile,validateSessionId,workerLogFile});
@@ -1,2 +1,2 @@
1
- "use strict";var k=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var h=(r,o)=>k(r,"name",{value:o,configurable:!0});var H=(r,o)=>{for(var c in o)k(r,c,{get:o[c],enumerable:!0})},P=(r,o,c,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of N(o))!_.call(r,n)&&n!==c&&k(r,n,{get:()=>o[n],enumerable:!(l=L(o,n))||l.enumerable});return r};var I=r=>P(k({},"__esModule",{value:!0}),r);var C={};H(C,{processFile:()=>J});module.exports=I(C);var E=require("fs"),R=require("path"),S=require("readline"),m=require("./types"),A=require("./paths"),T=require("./registry"),y=require("./dead-letter"),j=require("./worker-log");async function J(r,o){if(!(0,E.existsSync)(r))return;const{projectDir:c,sessionId:l}=(0,A.parseSnapshotPath)(r),n=new j.WorkerLog(c,l),f=o?.registry??(0,T.snapshotRegistry)(),i=[],s=[];try{await x(r,e=>{if(e.length!==0)try{const t=JSON.parse(e);if(!B(t)){s.push({raw:e,message:"not a valid job envelope"});return}i.push(t)}catch(t){const b=t instanceof Error?t.message:String(t);s.push({raw:e,message:b})}})}catch(e){const t=e instanceof Error?e.message:String(e);n.error(`failed to read ${r}: ${t}; leaving file`);return}if(n.info(`START path=${r} lines=${i.length+s.length} parse_errors=${s.length}`),f.size===0&&i.length>0){const e=`registry is empty but snapshot has ${i.length} job(s) \u2014 every job will be dead-lettered. Did registerQueueHandlers() fail to wire handlers?`;n.warn(e);try{process.stderr.write(`ironbee queue WARN: ${e}
2
- `)}catch{}}for(const e of s)try{(0,y.deadLetterParseError)({projectDir:c,sessionId:l,sourceFile:r},e.raw,`parse-error: ${e.message}`),n.info(`DEAD_LETTER parse-error from=${(0,R.basename)(r)}`)}catch(t){const b=t instanceof Error?t.message:String(t);n.error(`failed to dead-letter parse-error: ${b}; leaving file`);return}const a=new Map;for(const e of i){const t=a.get(e.type);t?t.push(e):a.set(e.type,[e])}const d=[...a.keys()].sort();let $=s.length,u=0;for(const e of d){const t=a.get(e),b=f.get(e);if(!b){for(const g of t)try{(0,y.deadLetterParsed)({projectDir:c,sessionId:l,sourceFile:r},g,`no-handler-registered:${e}`),$++}catch(w){const p=w instanceof Error?w.message:String(w);n.error(`failed to dead-letter unhandled job ${g.id}: ${p}; leaving file`);return}n.info(`NO_HANDLER type=${e} count=${t.length}`);continue}try{await b.dispatch(t),u+=t.length,n.info(`BATCH_OK type=${e} count=${t.length}`)}catch(g){if(g instanceof m.TransientError){n.warn(`TRANSIENT type=${e}: ${g.message}; leaving file for retry`);return}if(g instanceof m.AuthError){n.error(`AUTH type=${e}: ${g.message}; leaving file; operator must fix credentials`);return}if(g instanceof m.BadRequestBatchError){n.warn(`BATCH_400 type=${e}: ${g.message}; falling back to per-job dispatch`);const p=await D(b,t,r,c,l,n);if(p.bailed)return;u+=p.ok,$+=p.dead;continue}const w=g instanceof Error?g.message:String(g);n.error(`BATCH_UNEXPECTED type=${e}: ${w}`);for(const p of t)try{(0,y.deadLetterParsed)({projectDir:c,sessionId:l,sourceFile:r},p,`unexpected:${w}`),$++}catch(v){const F=v instanceof Error?v.message:String(v);n.error(`failed to dead-letter unexpected-batch job ${p.id}: ${F}; leaving file`);return}}}try{(0,E.unlinkSync)(r),n.info(`DONE path=${(0,R.basename)(r)} lines_ok=${u} lines_dead=${$}`)}catch(e){const t=e instanceof Error?e.message:String(e);n.warn(`UNLINK_FAILED path=${r}: ${t}; leaving file for re-processing`)}}h(J,"processFile");async function D(r,o,c,l,n,f){let i=0,s=0;for(const a of o)try{await r.dispatchSingle(a),i++}catch(d){if(d instanceof m.BadRequestError){try{(0,y.deadLetterParsed)({projectDir:l,sessionId:n,sourceFile:c},a,d.message),s++}catch(u){const e=u instanceof Error?u.message:String(u);return f.error(`failed to dead-letter bad-request job ${a.id}: ${e}; leaving file`),{ok:i,dead:s,bailed:!0}}continue}if(d instanceof m.TransientError)return f.warn(`TRANSIENT_DURING_FALLBACK job=${a.id}: ${d.message}; leaving file`),{ok:i,dead:s,bailed:!0};if(d instanceof m.AuthError)return f.error(`AUTH_DURING_FALLBACK job=${a.id}: ${d.message}; leaving file`),{ok:i,dead:s,bailed:!0};const $=d instanceof Error?d.message:String(d);try{(0,y.deadLetterParsed)({projectDir:l,sessionId:n,sourceFile:c},a,`unexpected:${$}`),s++}catch(u){const e=u instanceof Error?u.message:String(u);return f.error(`failed to dead-letter unexpected job ${a.id}: ${e}; leaving file`),{ok:i,dead:s,bailed:!0}}}return{ok:i,dead:s,bailed:!1}}h(D,"fallbackPerJob");function x(r,o){return new Promise((c,l)=>{const n=(0,E.createReadStream)(r,{encoding:"utf-8"}),f=(0,S.createInterface)({input:n,crlfDelay:1/0});let i=null;f.on("line",s=>{if(!i)try{o(s)}catch(a){i=a instanceof Error?a:new Error(String(a)),f.close(),n.destroy()}}),f.on("close",()=>{i?l(i):c()}),n.on("error",s=>{l(s)})})}h(x,"readLinesStreaming");function B(r){if(typeof r!="object"||r===null)return!1;const o=r;return typeof o.id=="string"&&typeof o.type=="string"&&typeof o.created_at=="string"&&"data"in o}h(B,"isJob");0&&(module.exports={processFile});
1
+ "use strict";var k=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var h=(r,t)=>k(r,"name",{value:t,configurable:!0});var N=(r,t)=>{for(var c in t)k(r,c,{get:t[c],enumerable:!0})},_=(r,t,c,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of F(t))!L.call(r,n)&&n!==c&&k(r,n,{get:()=>t[n],enumerable:!(l=D(t,n))||l.enumerable});return r};var H=r=>_(k({},"__esModule",{value:!0}),r);var C={};N(C,{processFile:()=>P});module.exports=H(C);var E=require("fs"),R=require("path"),S=require("readline"),m=require("./types"),j=require("./paths"),A=require("./registry"),y=require("./dead-letter"),T=require("./worker-log");async function P(r,t){if(!(0,E.existsSync)(r))return;const{projectDir:c,sessionId:l}=t?.projectDir!==void 0&&t?.sessionId!==void 0?{projectDir:t.projectDir,sessionId:t.sessionId}:(0,j.parseSnapshotPath)(r),n=new T.WorkerLog(c,l),d=t?.registry??(0,A.snapshotRegistry)(),i=[],s=[];try{await x(r,e=>{if(e.length!==0)try{const o=JSON.parse(e);if(!B(o)){s.push({raw:e,message:"not a valid job envelope"});return}i.push(o)}catch(o){const b=o instanceof Error?o.message:String(o);s.push({raw:e,message:b})}})}catch(e){const o=e instanceof Error?e.message:String(e);n.error(`failed to read ${r}: ${o}; leaving file`);return}if(n.info(`START path=${r} lines=${i.length+s.length} parse_errors=${s.length}`),d.size===0&&i.length>0){const e=`registry is empty but snapshot has ${i.length} job(s) \u2014 every job will be dead-lettered. Did registerQueueHandlers() fail to wire handlers?`;n.warn(e);try{process.stderr.write(`ironbee queue WARN: ${e}
2
+ `)}catch{}}for(const e of s)try{(0,y.deadLetterParseError)({projectDir:c,sessionId:l,sourceFile:r},e.raw,`parse-error: ${e.message}`),n.info(`DEAD_LETTER parse-error from=${(0,R.basename)(r)}`)}catch(o){const b=o instanceof Error?o.message:String(o);n.error(`failed to dead-letter parse-error: ${b}; leaving file`);return}const a=new Map;for(const e of i){const o=a.get(e.type);o?o.push(e):a.set(e.type,[e])}const f=[...a.keys()].sort();let $=s.length,u=0;for(const e of f){const o=a.get(e),b=d.get(e);if(!b){for(const g of o)try{(0,y.deadLetterParsed)({projectDir:c,sessionId:l,sourceFile:r},g,`no-handler-registered:${e}`),$++}catch(w){const p=w instanceof Error?w.message:String(w);n.error(`failed to dead-letter unhandled job ${g.id}: ${p}; leaving file`);return}n.info(`NO_HANDLER type=${e} count=${o.length}`);continue}try{await b.dispatch(o),u+=o.length,n.info(`BATCH_OK type=${e} count=${o.length}`)}catch(g){if(g instanceof m.TransientError){n.warn(`TRANSIENT type=${e}: ${g.message}; leaving file for retry`);return}if(g instanceof m.AuthError){n.error(`AUTH type=${e}: ${g.message}; leaving file; operator must fix credentials`);return}if(g instanceof m.BadRequestBatchError){n.warn(`BATCH_400 type=${e}: ${g.message}; falling back to per-job dispatch`);const p=await J(b,o,r,c,l,n);if(p.bailed)return;u+=p.ok,$+=p.dead;continue}const w=g instanceof Error?g.message:String(g);n.error(`BATCH_UNEXPECTED type=${e}: ${w}`);for(const p of o)try{(0,y.deadLetterParsed)({projectDir:c,sessionId:l,sourceFile:r},p,`unexpected:${w}`),$++}catch(v){const I=v instanceof Error?v.message:String(v);n.error(`failed to dead-letter unexpected-batch job ${p.id}: ${I}; leaving file`);return}}}try{(0,E.unlinkSync)(r),n.info(`DONE path=${(0,R.basename)(r)} lines_ok=${u} lines_dead=${$}`)}catch(e){const o=e instanceof Error?e.message:String(e);n.warn(`UNLINK_FAILED path=${r}: ${o}; leaving file for re-processing`)}}h(P,"processFile");async function J(r,t,c,l,n,d){let i=0,s=0;for(const a of t)try{await r.dispatchSingle(a),i++}catch(f){if(f instanceof m.BadRequestError){try{(0,y.deadLetterParsed)({projectDir:l,sessionId:n,sourceFile:c},a,f.message),s++}catch(u){const e=u instanceof Error?u.message:String(u);return d.error(`failed to dead-letter bad-request job ${a.id}: ${e}; leaving file`),{ok:i,dead:s,bailed:!0}}continue}if(f instanceof m.TransientError)return d.warn(`TRANSIENT_DURING_FALLBACK job=${a.id}: ${f.message}; leaving file`),{ok:i,dead:s,bailed:!0};if(f instanceof m.AuthError)return d.error(`AUTH_DURING_FALLBACK job=${a.id}: ${f.message}; leaving file`),{ok:i,dead:s,bailed:!0};const $=f instanceof Error?f.message:String(f);try{(0,y.deadLetterParsed)({projectDir:l,sessionId:n,sourceFile:c},a,`unexpected:${$}`),s++}catch(u){const e=u instanceof Error?u.message:String(u);return d.error(`failed to dead-letter unexpected job ${a.id}: ${e}; leaving file`),{ok:i,dead:s,bailed:!0}}}return{ok:i,dead:s,bailed:!1}}h(J,"fallbackPerJob");function x(r,t){return new Promise((c,l)=>{const n=(0,E.createReadStream)(r,{encoding:"utf-8"}),d=(0,S.createInterface)({input:n,crlfDelay:1/0});let i=null;d.on("line",s=>{if(!i)try{t(s)}catch(a){i=a instanceof Error?a:new Error(String(a)),d.close(),n.destroy()}}),d.on("close",()=>{i?l(i):c()}),n.on("error",s=>{l(s)})})}h(x,"readLinesStreaming");function B(r){if(typeof r!="object"||r===null)return!1;const t=r;return typeof t.id=="string"&&typeof t.type=="string"&&typeof t.created_at=="string"&&"data"in t}h(B,"isJob");0&&(module.exports={processFile});
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var i=(r,n)=>t(r,"name",{value:n,configurable:!0});var p=(r,n)=>{for(var s in n)t(r,s,{get:n[s],enumerable:!0})},v=(r,n,s,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of m(n))!u.call(r,e)&&e!==s&&t(r,e,{get:()=>n[e],enumerable:!(o=g(n,e))||o.enumerable});return r};var h=r=>v(t({},"__esModule",{value:!0}),r);var x={};p(x,{DRAINER_SKIP_RECENT_MS:()=>a,spawnDetachedDrainer:()=>f,spawnDetachedWorker:()=>l});module.exports=h(x);var c=require("child_process");function d(){const r=process.env.IRONBEE_BIN;if(r)return{command:r,args:[]};const n=process.argv[0],s=process.argv[1]??"";return s.endsWith("index.js")||s.endsWith("index.ts")?{command:n,args:[s]}:{command:"ironbee",args:[]}}i(d,"resolveInvocation");function l(r){const{command:n,args:s}=d(),o=[...s,"process-job-file",r];(0,c.spawn)(n,o,{detached:!0,stdio:"ignore",env:process.env}).unref()}i(l,"spawnDetachedWorker");const a=5e3;function f(r,n){const{command:s,args:o}=d(),e=[...o,"queue","drain","--session",n,"--project-dir",r,"--skip-recent-ms",String(a)];(0,c.spawn)(s,e,{detached:!0,stdio:"ignore",env:process.env}).unref()}i(f,"spawnDetachedDrainer");0&&(module.exports={DRAINER_SKIP_RECENT_MS,spawnDetachedDrainer,spawnDetachedWorker});
1
+ "use strict";var t=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var i=(n,s)=>t(n,"name",{value:s,configurable:!0});var v=(n,s)=>{for(var r in s)t(n,r,{get:s[r],enumerable:!0})},h=(n,s,r,o)=>{if(s&&typeof s=="object"||typeof s=="function")for(let e of p(s))!u.call(n,e)&&e!==r&&t(n,e,{get:()=>s[e],enumerable:!(o=m(s,e))||o.enumerable});return n};var l=n=>h(t({},"__esModule",{value:!0}),n);var E={};v(E,{DRAINER_SKIP_RECENT_MS:()=>a,spawnDetachedDrainer:()=>x,spawnDetachedWorker:()=>f});module.exports=l(E);var c=require("child_process");function g(){const n=process.env.IRONBEE_BIN;if(n)return{command:n,args:[]};const s=process.argv[0],r=process.argv[1]??"";return r.endsWith("index.js")||r.endsWith("index.ts")?{command:s,args:[r]}:{command:"ironbee",args:[]}}i(g,"resolveInvocation");function f(n,s,r){const{command:o,args:e}=g(),d=[...e,"process-job-file",n,"--project",s,"--session",r];(0,c.spawn)(o,d,{detached:!0,stdio:"ignore",env:process.env}).unref()}i(f,"spawnDetachedWorker");const a=5e3;function x(n,s){const{command:r,args:o}=g(),e=[...o,"queue","drain","--session",s,"--project-dir",n,"--skip-recent-ms",String(a)];(0,c.spawn)(r,e,{detached:!0,stdio:"ignore",env:process.env}).unref()}i(x,"spawnDetachedDrainer");0&&(module.exports={DRAINER_SKIP_RECENT_MS,spawnDetachedDrainer,spawnDetachedWorker});