@humain/humain-code 0.4.13 → 0.4.15

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.
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{dist_exports as dist_exports3}from"./chunk-JQCWRL5K.js";import{compile_exports,dist_exports as dist_exports2,value_exports}from"./chunk-TC7EANW4.js";import"./chunk-OX2IBCCA.js";import"./chunk-COF5P635.js";import"./chunk-NNKA2PAP.js";import"./chunk-TJG52LZB.js";import"./chunk-BVHXWQLD.js";import{all_exports,compat_exports}from"./chunk-JNHXXVLA.js";import{build_exports}from"./chunk-Z74ZYQPX.js";import{dist_exports}from"./chunk-UHLW4KJ7.js";
3
- import"./chunk-XQRYOCHA.js";import"./chunk-DNGJMRJW.js";import"./chunk-36Q5UVQL.js";import"./chunk-UGXYG7HN.js";import"./chunk-QYCOHSI7.js";import"./chunk-H2FY3PEV.js";import"./chunk-KQM7ZGL6.js";import"./chunk-CIA6V3BP.js";import"./chunk-XQZG5HPT.js";import"./chunk-FACBDLFU.js";import"./chunk-4DXXZHY2.js";import"./chunk-YRCLNWFV.js";import"./chunk-MF2NEHP4.js";import"./chunk-FRUFMISJ.js";import"./chunk-YJ3NQWES.js";
2
+ import{dist_exports as dist_exports3}from"./chunk-JRX7GYW3.js";import{compile_exports,dist_exports as dist_exports2,value_exports}from"./chunk-W5YJZKPF.js";import"./chunk-OX2IBCCA.js";import"./chunk-COF5P635.js";import"./chunk-NNKA2PAP.js";import"./chunk-TJG52LZB.js";import"./chunk-BVHXWQLD.js";import{all_exports,compat_exports}from"./chunk-5JHUWRJN.js";import{build_exports}from"./chunk-Z74ZYQPX.js";import{dist_exports}from"./chunk-UHLW4KJ7.js";
3
+ import"./chunk-XQRYOCHA.js";import"./chunk-DNGJMRJW.js";import"./chunk-36Q5UVQL.js";import"./chunk-UGXYG7HN.js";import"./chunk-QYCOHSI7.js";import"./chunk-H2FY3PEV.js";import"./chunk-KQM7ZGL6.js";import"./chunk-CIA6V3BP.js";import"./chunk-XQZG5HPT.js";import"./chunk-FACBDLFU.js";import"./chunk-OEOXBLWI.js";import"./chunk-YRCLNWFV.js";import"./chunk-MF2NEHP4.js";import"./chunk-FRUFMISJ.js";import"./chunk-YJ3NQWES.js";
4
4
  import"./chunk-DBL35X7L.js";import"./chunk-MG5PX4KU.js";import"./chunk-LUL775V7.js";import"./chunk-RYC5BYVE.js";import"./chunk-VEYTRNQC.js";import"./chunk-JXWJOIH4.js";var oauth_exports={};var VIRTUAL_MODULES={typebox:build_exports,"typebox/compile":compile_exports,"typebox/value":value_exports,"@sinclair/typebox":build_exports,"@sinclair/typebox/compile":compile_exports,"@sinclair/typebox/value":value_exports,"@earendil-works/pi-agent-core":dist_exports2,"@earendil-works/pi-tui":dist_exports,"@earendil-works/pi-ai":compat_exports,"@earendil-works/pi-ai/compat":compat_exports,"@earendil-works/pi-ai/oauth":oauth_exports,"@earendil-works/pi-ai/providers/all":all_exports,"@earendil-w\
5
5
  orks/pi-coding-agent":dist_exports3,"@mariozechner/pi-agent-core":dist_exports2,"@mariozechner/pi-tui":dist_exports,"@mariozechner/pi-ai":compat_exports,"@mariozechner/pi-ai/compat":compat_exports,"@mariozechner/pi-ai/oauth":oauth_exports,"@mariozechner/pi-ai/providers/all":all_exports,"@mariozechner/pi-coding-agent":dist_exports3};export{VIRTUAL_MODULES};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
3
- import{configureHttpDispatcher,main,warnIfDeprecatedCommand}from"./chunks/chunk-TC7EANW4.js";import"./chunks/chunk-OX2IBCCA.js";import"./chunks/chunk-COF5P635.js";import"./chunks/chunk-NNKA2PAP.js";import"./chunks/chunk-TJG52LZB.js";import"./chunks/chunk-BVHXWQLD.js";import"./chunks/chunk-JNHXXVLA.js";import"./chunks/chunk-Z74ZYQPX.js";import"./chunks/chunk-UHLW4KJ7.js";import"./chunks/chunk-XQRYOCHA.js";import"./chunks/chunk-DNGJMRJW.js";import"./chunks/chunk-36Q5UVQL.js";import"./chunks/chunk-UGXYG7HN.js";
4
- import"./chunks/chunk-QYCOHSI7.js";import"./chunks/chunk-H2FY3PEV.js";import"./chunks/chunk-KQM7ZGL6.js";import"./chunks/chunk-CIA6V3BP.js";import"./chunks/chunk-XQZG5HPT.js";import"./chunks/chunk-FACBDLFU.js";import"./chunks/chunk-4DXXZHY2.js";import{APP_COMMAND,ENV_PREFIX}from"./chunks/chunk-YRCLNWFV.js";import"./chunks/chunk-MF2NEHP4.js";import"./chunks/chunk-FRUFMISJ.js";import"./chunks/chunk-YJ3NQWES.js";import"./chunks/chunk-DBL35X7L.js";import"./chunks/chunk-MG5PX4KU.js";import"./chunks/chunk-LUL775V7.js";
3
+ import{configureHttpDispatcher,main,warnIfDeprecatedCommand}from"./chunks/chunk-W5YJZKPF.js";import"./chunks/chunk-OX2IBCCA.js";import"./chunks/chunk-COF5P635.js";import"./chunks/chunk-NNKA2PAP.js";import"./chunks/chunk-TJG52LZB.js";import"./chunks/chunk-BVHXWQLD.js";import"./chunks/chunk-5JHUWRJN.js";import"./chunks/chunk-Z74ZYQPX.js";import"./chunks/chunk-UHLW4KJ7.js";import"./chunks/chunk-XQRYOCHA.js";import"./chunks/chunk-DNGJMRJW.js";import"./chunks/chunk-36Q5UVQL.js";import"./chunks/chunk-UGXYG7HN.js";
4
+ import"./chunks/chunk-QYCOHSI7.js";import"./chunks/chunk-H2FY3PEV.js";import"./chunks/chunk-KQM7ZGL6.js";import"./chunks/chunk-CIA6V3BP.js";import"./chunks/chunk-XQZG5HPT.js";import"./chunks/chunk-FACBDLFU.js";import"./chunks/chunk-OEOXBLWI.js";import{APP_COMMAND,ENV_PREFIX}from"./chunks/chunk-YRCLNWFV.js";import"./chunks/chunk-MF2NEHP4.js";import"./chunks/chunk-FRUFMISJ.js";import"./chunks/chunk-YJ3NQWES.js";import"./chunks/chunk-DBL35X7L.js";import"./chunks/chunk-MG5PX4KU.js";import"./chunks/chunk-LUL775V7.js";
5
5
  import"./chunks/chunk-RYC5BYVE.js";import"./chunks/chunk-VEYTRNQC.js";import"./chunks/chunk-JXWJOIH4.js";function setupCli(){process.title=APP_COMMAND,process.env.PI_CODING_AGENT="true",process.env[`${ENV_PREFIX}_CODING_AGENT`]="true",process.env.AI_AGENT="pi",process.emitWarning=(()=>{}),configureHttpDispatcher()}setupCli();warnIfDeprecatedCommand(process.argv.slice(2));main(process.argv.slice(2));
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@earendil-works/pi-tui": "1.2.0",
31
- "@humain/humain-code-contracts": "0.4.13",
31
+ "@humain/humain-code-contracts": "0.4.15",
32
32
  "typebox": "1.3.37"
33
33
  },
34
34
  "devDependencies": {
@@ -1,13 +1,13 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{ShowImagesSelectorComponent,ThemeSelectorComponent}from"./chunks/chunk-JQCWRL5K.js";import{ACCOUNT_RETURN_COOLDOWN_MS,ACCOUNT_RETURN_MAX_COOLDOWN_MS,AgentExecInputError,AgentSession,AgentSessionRuntime,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,
2
+ import{ShowImagesSelectorComponent,ThemeSelectorComponent}from"./chunks/chunk-JRX7GYW3.js";import{ACCOUNT_RETURN_COOLDOWN_MS,ACCOUNT_RETURN_MAX_COOLDOWN_MS,AgentExecInputError,AgentSession,AgentSessionRuntime,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,
3
3
  ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FLOW_ACCOUNT_PERSISTENCE_NOTICE,FLOW_SETUP_TERMINAL_ONLY,FLOW_SUBCOMMANDS,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthAccountPool,OAuthSelectorComponent,RpcClient,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,SkillInvocationMessageComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,
4
4
  VIRTUAL_MODEL_STATE_ENTRY,assessNodeFallback,calculateContextTokens,collectEntriesForBranchSummary,compact,completeFlowArguments,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodemodeExtension,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,
5
5
  createLocalBashOperations,createLocalPowerShellOperations,createLsTool,createLsToolDefinition,createMcpExtension,createPiAgentExecutionHost,createPowerShellTool,createPowerShellToolDefinition,createReadOnlyTools,createReadTool,createReadToolDefinition,createSubagentTool,createSyntheticSourceInfo,createToolSearchExtension,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAgents,discoverAndLoadExtensions,estimateTokens,executeHumainAgentRequest,findCutPoint,
6
6
  findTurnStartIndex,flowBuildUnavailable,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getFlowAccountsHost,getFlowChildLaunchHost,getFlowControlHost,getFlowTraceProducer,getLastAssistantUsage,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,parseArgs,parseFlowCommand,
7
- parseFrontmatter,parseSkillBlock,prepareBranchEntries,prepareChildLaunch,renderDiff,renderFlowHelp,renderTaskWithContext,resolveCliModel,resolveModelScopeWithDiagnostics,runAgentExecMode,runPrintMode,runRpcMode,serializeConversation,shouldCompact,stripFrontmatter,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools}from"./chunks/chunk-TC7EANW4.js";import"./chunks/chunk-OX2IBCCA.js";import"./chunks/chunk-COF5P635.js";import{ArminComponent}from"./chunks/chunk-NNKA2PAP.js";import{ProjectTrustStore,
8
- hasTrustRequiringProjectResources}from"./chunks/chunk-TJG52LZB.js";import{CURRENT_SESSION_VERSION,SessionManager,buildContextEntries,buildSessionContext,buildSessionProjection,convertToLlm,formatDimensionNote,getLatestCompactionEntry,migrateSessionEntries,parseSessionEntries,resizeImage,sessionEntryToContextMessages}from"./chunks/chunk-BVHXWQLD.js";import"./chunks/chunk-JNHXXVLA.js";import{DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,formatSize,truncateHead,truncateLine,truncateTail,truncateToVisualLines}from"./chunks/chunk-Z74ZYQPX.js";
7
+ parseFrontmatter,parseSkillBlock,prepareBranchEntries,prepareChildLaunch,renderDiff,renderFlowHelp,renderTaskWithContext,resolveCliModel,resolveModelScopeWithDiagnostics,runAgentExecMode,runPrintMode,runRpcMode,serializeConversation,shouldCompact,stripFrontmatter,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools}from"./chunks/chunk-W5YJZKPF.js";import"./chunks/chunk-OX2IBCCA.js";import"./chunks/chunk-COF5P635.js";import{ArminComponent}from"./chunks/chunk-NNKA2PAP.js";import{ProjectTrustStore,
8
+ hasTrustRequiringProjectResources}from"./chunks/chunk-TJG52LZB.js";import{CURRENT_SESSION_VERSION,SessionManager,buildContextEntries,buildSessionContext,buildSessionProjection,convertToLlm,formatDimensionNote,getLatestCompactionEntry,migrateSessionEntries,parseSessionEntries,resizeImage,sessionEntryToContextMessages}from"./chunks/chunk-BVHXWQLD.js";import"./chunks/chunk-5JHUWRJN.js";import{DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,formatSize,truncateHead,truncateLine,truncateTail,truncateToVisualLines}from"./chunks/chunk-Z74ZYQPX.js";
9
9
  import{Theme,getLanguageFromPath,getMarkdownTheme,getSelectListTheme,getSettingsListTheme,highlightCode,initTheme,keyHint,keyText,rawKeyHint}from"./chunks/chunk-UHLW4KJ7.js";import"./chunks/chunk-XQRYOCHA.js";import"./chunks/chunk-DNGJMRJW.js";import{readStoredCredential}from"./chunks/chunk-36Q5UVQL.js";import{getPowerShellConfig,getShellConfig}from"./chunks/chunk-UGXYG7HN.js";import"./chunks/chunk-QYCOHSI7.js";import"./chunks/chunk-H2FY3PEV.js";import"./chunks/chunk-KQM7ZGL6.js";import"./chunks/chunk-CIA6V3BP.js";
10
- import"./chunks/chunk-XQZG5HPT.js";import"./chunks/chunk-FACBDLFU.js";import{HUMAIN_AGENT_EXECUTION_FAILURE_CODES,HUMAIN_AGENT_EXECUTION_SCHEMA_VERSION,HumainAgentArtifactSchema,HumainAgentExecutionClaimSchema,HumainAgentExecutionControlsSchema,HumainAgentExecutionOutcomeSchema,HumainAgentExecutionRequestSchema,HumainAgentExecutionResponseSchema,HumainAgentRouteRefSchema,HumainAgentUsageSchema,parseHumainAgentExecutionRequest,parseHumainAgentExecutionResponse}from"./chunks/chunk-4DXXZHY2.js";import{
10
+ import"./chunks/chunk-XQZG5HPT.js";import"./chunks/chunk-FACBDLFU.js";import{HUMAIN_AGENT_EXECUTION_FAILURE_CODES,HUMAIN_AGENT_EXECUTION_SCHEMA_VERSION,HumainAgentArtifactSchema,HumainAgentExecutionClaimSchema,HumainAgentExecutionControlsSchema,HumainAgentExecutionOutcomeSchema,HumainAgentExecutionRequestSchema,HumainAgentExecutionResponseSchema,HumainAgentRouteRefSchema,HumainAgentUsageSchema,parseHumainAgentExecutionRequest,parseHumainAgentExecutionResponse}from"./chunks/chunk-OEOXBLWI.js";import{
11
11
  CONFIG_DIR_NAME,UPSTREAM_PI_VERSION,VERSION,getAgentDir,getDocsPath,getExamplesPath,getPackageDir,getReadmePath}from"./chunks/chunk-YRCLNWFV.js";import"./chunks/chunk-MF2NEHP4.js";import"./chunks/chunk-FRUFMISJ.js";import"./chunks/chunk-YJ3NQWES.js";import"./chunks/chunk-DBL35X7L.js";import"./chunks/chunk-MG5PX4KU.js";import"./chunks/chunk-LUL775V7.js";import"./chunks/chunk-RYC5BYVE.js";import"./chunks/chunk-VEYTRNQC.js";import"./chunks/chunk-JXWJOIH4.js";export{ACCOUNT_RETURN_COOLDOWN_MS,ACCOUNT_RETURN_MAX_COOLDOWN_MS,AgentExecInputError,AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CONFIG_DIR_NAME,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,
12
12
  ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FLOW_ACCOUNT_PERSISTENCE_NOTICE,FLOW_SETUP_TERMINAL_ONLY,FLOW_SUBCOMMANDS,FooterComponent,HUMAIN_AGENT_EXECUTION_FAILURE_CODES,HUMAIN_AGENT_EXECUTION_SCHEMA_VERSION,HumainAgentArtifactSchema,HumainAgentExecutionClaimSchema,HumainAgentExecutionControlsSchema,HumainAgentExecutionOutcomeSchema,HumainAgentExecutionRequestSchema,HumainAgentExecutionResponseSchema,HumainAgentRouteRefSchema,HumainAgentUsageSchema,InteractiveMode,LoginDialogComponent,
13
13
  ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthAccountPool,OAuthSelectorComponent,ProjectTrustStore,RpcClient,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,Theme,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UPSTREAM_PI_VERSION,UserMessageComponent,UserMessageSelectorComponent,VERSION,VIRTUAL_MODEL_STATE_ENTRY,assessNodeFallback,buildContextEntries,
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
3
- import{configureHttpDispatcher,main}from"./chunks/chunk-TC7EANW4.js";import"./chunks/chunk-OX2IBCCA.js";import"./chunks/chunk-COF5P635.js";import"./chunks/chunk-NNKA2PAP.js";import"./chunks/chunk-TJG52LZB.js";import"./chunks/chunk-BVHXWQLD.js";import"./chunks/chunk-JNHXXVLA.js";import"./chunks/chunk-Z74ZYQPX.js";import"./chunks/chunk-UHLW4KJ7.js";import"./chunks/chunk-XQRYOCHA.js";import"./chunks/chunk-DNGJMRJW.js";import"./chunks/chunk-36Q5UVQL.js";import"./chunks/chunk-UGXYG7HN.js";import"./chunks/chunk-QYCOHSI7.js";
4
- import"./chunks/chunk-H2FY3PEV.js";import"./chunks/chunk-KQM7ZGL6.js";import"./chunks/chunk-CIA6V3BP.js";import"./chunks/chunk-XQZG5HPT.js";import"./chunks/chunk-FACBDLFU.js";import"./chunks/chunk-4DXXZHY2.js";import{APP_COMMAND}from"./chunks/chunk-YRCLNWFV.js";import"./chunks/chunk-MF2NEHP4.js";import"./chunks/chunk-FRUFMISJ.js";import"./chunks/chunk-YJ3NQWES.js";import"./chunks/chunk-DBL35X7L.js";import"./chunks/chunk-MG5PX4KU.js";import"./chunks/chunk-LUL775V7.js";import"./chunks/chunk-RYC5BYVE.js";import"./chunks/chunk-VEYTRNQC.js";
3
+ import{configureHttpDispatcher,main}from"./chunks/chunk-W5YJZKPF.js";import"./chunks/chunk-OX2IBCCA.js";import"./chunks/chunk-COF5P635.js";import"./chunks/chunk-NNKA2PAP.js";import"./chunks/chunk-TJG52LZB.js";import"./chunks/chunk-BVHXWQLD.js";import"./chunks/chunk-5JHUWRJN.js";import"./chunks/chunk-Z74ZYQPX.js";import"./chunks/chunk-UHLW4KJ7.js";import"./chunks/chunk-XQRYOCHA.js";import"./chunks/chunk-DNGJMRJW.js";import"./chunks/chunk-36Q5UVQL.js";import"./chunks/chunk-UGXYG7HN.js";import"./chunks/chunk-QYCOHSI7.js";
4
+ import"./chunks/chunk-H2FY3PEV.js";import"./chunks/chunk-KQM7ZGL6.js";import"./chunks/chunk-CIA6V3BP.js";import"./chunks/chunk-XQZG5HPT.js";import"./chunks/chunk-FACBDLFU.js";import"./chunks/chunk-OEOXBLWI.js";import{APP_COMMAND}from"./chunks/chunk-YRCLNWFV.js";import"./chunks/chunk-MF2NEHP4.js";import"./chunks/chunk-FRUFMISJ.js";import"./chunks/chunk-YJ3NQWES.js";import"./chunks/chunk-DBL35X7L.js";import"./chunks/chunk-MG5PX4KU.js";import"./chunks/chunk-LUL775V7.js";import"./chunks/chunk-RYC5BYVE.js";import"./chunks/chunk-VEYTRNQC.js";
5
5
  import"./chunks/chunk-JXWJOIH4.js";process.title=`${APP_COMMAND}-rpc`;process.env.PI_CODING_AGENT="true";process.env.AI_AGENT="pi";process.emitWarning=(()=>{});configureHttpDispatcher();main(["--mode","rpc",...process.argv.slice(2)]);
@@ -3,7 +3,7 @@ import type { AutocompleteItem } from "@earendil-works/pi-tui";
3
3
  * Static vocabulary, parsing, help and completion for the single `/flow` command. Pure and dependency-light on
4
4
  * purpose: the lazy loader uses it before (and without) importing Flow, so help works when Flow is disabled.
5
5
  */
6
- export declare const FLOW_SUBCOMMANDS: readonly ["help", "run", "continue", "list", "status", "cancel", "pause", "resume", "title", "message", "hide", "show", "models", "profile", "setup"];
6
+ export declare const FLOW_SUBCOMMANDS: readonly ["help", "run", "continue", "fix", "list", "status", "cancel", "pause", "resume", "title", "message", "hide", "show", "models", "profile", "setup"];
7
7
  export type FlowSubcommand = (typeof FLOW_SUBCOMMANDS)[number];
8
8
  /** Refusal for `/flow setup` outside the terminal UI: secure account dialogs exist only there. */
9
9
  export declare const FLOW_SETUP_TERMINAL_ONLY = "/flow setup needs the interactive terminal. Use /flow models and /flow profile for changes from other modes.";
@@ -1 +1 @@
1
- {"version":3,"file":"flow-command.d.ts","sourceRoot":"","sources":["../../src/humain/flow-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D;;;GAGG;AAEH,eAAO,MAAM,gBAAgB,YAC5B,MAAM,EACN,KAAK,EACL,UAAU,EACV,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,OAAO,EACP,SAAS,EACT,MAAM,EACN,MAAM,EACN,QAAQ,EACR,SAAS,EACT,OAAO,CACE,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,kGAAkG;AAClG,eAAO,MAAM,wBAAwB,iHAC0E,CAAC;AAkDhH,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC/B,IAAI,EAAE,MAAM,GACV;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,cAAc,CAAA;CAAE,CA2B5F;AAuFD,mHAAmH;AACnH,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAOrD;AAED,8GAA8G;AAC9G,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,EAAE,GAAG,IAAI,CAyB/E"}
1
+ {"version":3,"file":"flow-command.d.ts","sourceRoot":"","sources":["../../src/humain/flow-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D;;;GAGG;AAEH,eAAO,MAAM,gBAAgB,YAC5B,MAAM,EACN,KAAK,EACL,UAAU,EACV,KAAK,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,OAAO,EACP,SAAS,EACT,MAAM,EACN,MAAM,EACN,QAAQ,EACR,SAAS,EACT,OAAO,CACE,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,kGAAkG;AAClG,eAAO,MAAM,wBAAwB,iHAC0E,CAAC;AAmDhH,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC/B,IAAI,EAAE,MAAM,GACV;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,cAAc,CAAA;CAAE,CA8B5F;AAyFD,mHAAmH;AACnH,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAOrD;AAED,8GAA8G;AAC9G,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,EAAE,GAAG,IAAI,CAyB/E"}
@@ -7,6 +7,7 @@ export const FLOW_SUBCOMMANDS = [
7
7
  "help",
8
8
  "run",
9
9
  "continue",
10
+ "fix",
10
11
  "list",
11
12
  "status",
12
13
  "cancel",
@@ -37,6 +38,7 @@ const SUMMARIES = {
37
38
  help: "Show usage and examples",
38
39
  run: "Start work",
39
40
  continue: "Recover an interrupted run",
41
+ fix: "Fix failing checks of a verified-after run",
40
42
  list: "Find recent runs and run IDs",
41
43
  status: "View progress",
42
44
  cancel: "Stop the active run",
@@ -98,6 +100,9 @@ export function parseFlowCommand(args) {
98
100
  if (NO_ARGUMENT_SUBCOMMANDS.has(name) && trimmed) {
99
101
  return { error: `/flow ${name} does not accept arguments. Usage: /flow ${name}` };
100
102
  }
103
+ if (name === "fix" && /\s/.test(trimmed)) {
104
+ return { error: "/flow fix accepts at most one run ID. Usage: /flow fix [run-id]", command: name };
105
+ }
101
106
  if (name === "continue" && /\s/.test(trimmed)) {
102
107
  // `command` lets the loader settle the refused start over rpc.
103
108
  return { error: "/flow continue accepts at most one run ID. Usage: /flow continue [run-id]", command: name };
@@ -118,6 +123,7 @@ const GENERAL_HELP = [
118
123
  helpRow("/flow pause", "pause"),
119
124
  helpRow("/flow resume", "resume"),
120
125
  helpRow("/flow continue [run-id]", "continue"),
126
+ helpRow("/flow fix [run-id]", "fix"),
121
127
  helpRow("/flow title <title>", "title"),
122
128
  helpRow("/flow message <text>", "message"),
123
129
  helpRow("/flow hide", "hide"),
@@ -140,7 +146,7 @@ const RUN_FLAGS = [
140
146
  " --profile ID --lead-size small|standard|large --workflow direct|checked|led|full --effort LEVEL",
141
147
  " --cheap ALIAS --mid ALIAS --premium ALIAS --frontier ALIAS --model <capability>=ALIAS",
142
148
  " --quality-floor F --cost-aggressiveness C --max-retries R --fan-out",
143
- " --context FILE ... --with-last-reply --force --route-only --candidate PATH",
149
+ " --context FILE ... --with-last-reply --force --route-only --candidate PATH --verify-after",
144
150
  " --live-qa --no-live-qa --live-qa-adapter ID --live-qa-scope SCOPE --live-qa-acceptance FILE",
145
151
  ].join("\n");
146
152
  const TOPIC_HELP = {
@@ -159,6 +165,7 @@ const TOPIC_HELP = {
159
165
  "",
160
166
  RUN_FLAGS,
161
167
  ].join("\n"),
168
+ fix: "Fix the failing checks of a run started with --verify-after\n\nUsage:\n /flow fix [run-id]\n\nStarts a new run from that run's local failing-check report. Default: the last such run in this session.",
162
169
  continue: "Recover an interrupted run\n\nUsage:\n /flow continue [run-id]\n\nRecovery requires a safety check and your confirmation.",
163
170
  list: [
164
171
  "Find recent runs and run IDs",
@@ -1 +1 @@
1
- {"version":3,"file":"flow-command.js","sourceRoot":"","sources":["../../src/humain/flow-command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE;;;GAGG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,MAAM;IACN,KAAK;IACL,UAAU;IACV,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,OAAO;IACP,SAAS;IACT,MAAM;IACN,MAAM;IACN,QAAQ;IACR,SAAS;IACT,OAAO;CACE,CAAC;AAIX,kGAAkG;AAClG,MAAM,CAAC,MAAM,wBAAwB,GACpC,8GAA8G,CAAC;AAEhH,uCAAuC;AACvC,MAAM,uBAAuB,GAAgC,IAAI,GAAG,CAAC;IACpE,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,MAAM;IACN,MAAM;IACN,OAAO;CACP,CAAC,CAAC;AAEH,MAAM,SAAS,GAAmC;IACjD,IAAI,EAAE,yBAAyB;IAC/B,GAAG,EAAE,YAAY;IACjB,QAAQ,EAAE,4BAA4B;IACtC,IAAI,EAAE,8BAA8B;IACpC,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,qBAAqB;IAC7B,KAAK,EAAE,gBAAgB;IACvB,MAAM,EAAE,oBAAoB;IAC5B,KAAK,EAAE,uBAAuB;IAC9B,OAAO,EAAE,eAAe;IACxB,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE,8BAA8B;IACpC,MAAM,EAAE,sBAAsB;IAC9B,OAAO,EAAE,qBAAqB;IAC9B,KAAK,EAAE,sCAAsC;CAC7C,CAAC;AAEF,MAAM,kBAAkB,GAAG;IAC1B,MAAM;IACN,MAAM;IACN,UAAU;IACV,OAAO;IACP,KAAK;IACL,QAAQ;IACR,KAAK;IACL,KAAK;IACL,MAAM;IACN,SAAS;IACT,UAAU;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AAC,UAAU,CAAC,MAAM,IAAI,EAAE,CAAC;gBACnC,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC5F,CAAC;IACF,CAAC;SAAM,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,SAAS,CAAC,EAAE,CAAC;QAC9E,KAAK,MAAM,IAAI,IAAI,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,mBAAmB,EAAE,CAAC;YAClF,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,EAAE,CAAC;gBAAE,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3F,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACxC,CAAC","sourcesContent":["import type { AutocompleteItem } from \"@earendil-works/pi-tui\";\nimport { sanitizeForTerminal } from \"../core/trace-client/sanitize.ts\";\n\n/**\n * Static vocabulary, parsing, help and completion for the single `/flow` command. Pure and dependency-light on\n * purpose: the lazy loader uses it before (and without) importing Flow, so help works when Flow is disabled.\n */\n\nexport const FLOW_SUBCOMMANDS = [\n\t\"help\",\n\t\"run\",\n\t\"continue\",\n\t\"list\",\n\t\"status\",\n\t\"cancel\",\n\t\"pause\",\n\t\"resume\",\n\t\"title\",\n\t\"message\",\n\t\"hide\",\n\t\"show\",\n\t\"models\",\n\t\"profile\",\n\t\"setup\",\n] as const;\n\nexport type FlowSubcommand = (typeof FLOW_SUBCOMMANDS)[number];\n\n/** Refusal for `/flow setup` outside the terminal UI: secure account dialogs exist only there. */\nexport const FLOW_SETUP_TERMINAL_ONLY =\n\t\"/flow setup needs the interactive terminal. Use /flow models and /flow profile for changes from other modes.\";\n\n/** Commands that take no arguments. */\nconst NO_ARGUMENT_SUBCOMMANDS: ReadonlySet<FlowSubcommand> = new Set([\n\t\"list\",\n\t\"status\",\n\t\"cancel\",\n\t\"pause\",\n\t\"resume\",\n\t\"hide\",\n\t\"show\",\n\t\"setup\",\n]);\n\nconst SUMMARIES: Record<FlowSubcommand, string> = {\n\thelp: \"Show usage and examples\",\n\trun: \"Start work\",\n\tcontinue: \"Recover an interrupted run\",\n\tlist: \"Find recent runs and run IDs\",\n\tstatus: \"View progress\",\n\tcancel: \"Stop the active run\",\n\tpause: \"Pause new work\",\n\tresume: \"Resume paused work\",\n\ttitle: \"Rename the active run\",\n\tmessage: \"Send guidance\",\n\thide: \"Hide the widget; work continues\",\n\tshow: \"Show the active run's widget\",\n\tmodels: \"Manage model choices\",\n\tprofile: \"Manage run profiles\",\n\tsetup: \"Connect providers and configure Flow\",\n};\n\nconst MODELS_SUBCOMMANDS = [\n\t\"show\",\n\t\"list\",\n\t\"validate\",\n\t\"check\",\n\t\"set\",\n\t\"effort\",\n\t\"use\",\n\t\"new\",\n\t\"pick\",\n\t\"convert\",\n\t\"workflow\",\n];\nconst PROFILE_SUBCOMMANDS = [\"list\", \"show\", \"use\", \"export\", \"import\", \"validate\"];\n\nconst isSubcommand = (value: string): value is FlowSubcommand =>\n\t(FLOW_SUBCOMMANDS as readonly string[]).includes(value);\n\n/** Copy for a recognized subcommand this build does not implement yet. */\nexport function flowBuildUnavailable(command: string): string {\n\treturn `/flow ${sanitizeForTerminal(command)} is not available in this build. Use /flow help to see supported commands.`;\n}\n\n/**\n * Splits `/flow` arguments into subcommand and payload. Consumes the subcommand and exactly one separating\n * whitespace character; the rest of the payload is returned byte-for-byte so goal, message and title text is\n * never split or rejoined. Bare or whitespace-only input means help.\n */\nexport function parseFlowCommand(\n\targs: string,\n): { command: FlowSubcommand; payload: string } | { error: string; command?: FlowSubcommand } {\n\tconst match = /^\\s*(\\S+)([\\s\\S]*)$/.exec(args);\n\tif (!match) return { command: \"help\", payload: \"\" };\n\tconst [, name, rest] = match;\n\tif (!isSubcommand(name)) {\n\t\treturn {\n\t\t\terror: `Unknown Flow command: ${sanitizeForTerminal(name).slice(0, 80)}. Use /flow help to see available commands. To start work: /flow run <goal>`,\n\t\t};\n\t}\n\tconst payload = /^\\s/.test(rest) ? rest.slice(1) : rest;\n\tconst trimmed = payload.trim();\n\tif (name === \"help\" && trimmed) {\n\t\tif (/\\s/.test(trimmed)) return { error: \"/flow help accepts at most one topic. Usage: /flow help [topic]\" };\n\t\tif (!isSubcommand(trimmed)) {\n\t\t\treturn {\n\t\t\t\terror: `No help topic named “${sanitizeForTerminal(trimmed).slice(0, 80)}”. Use /flow help to see available commands.`,\n\t\t\t};\n\t\t}\n\t}\n\tif (NO_ARGUMENT_SUBCOMMANDS.has(name) && trimmed) {\n\t\treturn { error: `/flow ${name} does not accept arguments. Usage: /flow ${name}` };\n\t}\n\tif (name === \"continue\" && /\\s/.test(trimmed)) {\n\t\t// `command` lets the loader settle the refused start over rpc.\n\t\treturn { error: \"/flow continue accepts at most one run ID. Usage: /flow continue [run-id]\", command: name };\n\t}\n\treturn { command: name, payload };\n}\n\nconst helpRow = (usage: string, command: FlowSubcommand) => `${` ${usage}`.padEnd(27)}${SUMMARIES[command]}`;\n\nconst GENERAL_HELP = [\n\t\"Flow — plan, run, and verify work with agents.\",\n\t\"\",\n\t\"Start work\",\n\t\" /flow run <goal> [flags]\",\n\t\"\",\n\t\"Manage a run\",\n\thelpRow(\"/flow list\", \"list\"),\n\thelpRow(\"/flow status\", \"status\"),\n\thelpRow(\"/flow cancel\", \"cancel\"),\n\thelpRow(\"/flow pause\", \"pause\"),\n\thelpRow(\"/flow resume\", \"resume\"),\n\thelpRow(\"/flow continue [run-id]\", \"continue\"),\n\thelpRow(\"/flow title <title>\", \"title\"),\n\thelpRow(\"/flow message <text>\", \"message\"),\n\thelpRow(\"/flow hide\", \"hide\"),\n\thelpRow(\"/flow show\", \"show\"),\n\t\"\",\n\t\"Configure\",\n\thelpRow(\"/flow setup\", \"setup\"),\n\thelpRow(\"/flow models <command>\", \"models\"),\n\thelpRow(\"/flow profile <command>\", \"profile\"),\n\t\"\",\n\t\"Learn more\",\n\t\" /flow help <command> Show usage and examples\",\n\t\"\",\n\t\"Example\",\n\t\" /flow run Fix the login timeout --risk medium\",\n].join(\"\\n\");\n\nconst RUN_FLAGS = [\n\t\"Flags:\",\n\t\" --task-class T --complexity N --risk low|medium|high|critical\",\n\t\" --profile ID --lead-size small|standard|large --workflow direct|checked|led|full --effort LEVEL\",\n\t\" --cheap ALIAS --mid ALIAS --premium ALIAS --frontier ALIAS --model <capability>=ALIAS\",\n\t\" --quality-floor F --cost-aggressiveness C --max-retries R --fan-out\",\n\t\" --context FILE ... --with-last-reply --force --route-only --candidate PATH\",\n\t\" --live-qa --no-live-qa --live-qa-adapter ID --live-qa-scope SCOPE --live-qa-acceptance FILE\",\n].join(\"\\n\");\n\nconst TOPIC_HELP: Record<FlowSubcommand, string> = {\n\thelp: \"Show help\\n\\nUsage:\\n /flow help [command]\",\n\trun: [\n\t\t\"Start a Flow run\",\n\t\t\"\",\n\t\t\"Usage:\",\n\t\t\" /flow run <goal> [flags]\",\n\t\t\"\",\n\t\t\"Example:\",\n\t\t\" /flow run Fix the login timeout --risk medium\",\n\t\t\"\",\n\t\t\"Describe the outcome you want. Flow plans the work,\",\n\t\t\"dispatches agents, and verifies the result.\",\n\t\t\"\",\n\t\tRUN_FLAGS,\n\t].join(\"\\n\"),\n\tcontinue:\n\t\t\"Recover an interrupted run\\n\\nUsage:\\n /flow continue [run-id]\\n\\nRecovery requires a safety check and your confirmation.\",\n\tlist: [\n\t\t\"Find recent runs and run IDs\",\n\t\t\"\",\n\t\t\"Usage:\",\n\t\t\" /flow list\",\n\t\t\"\",\n\t\t\"History examines up to 200 runs by creation time.\",\n\t\t\"Runs without readable execution snapshots are omitted.\",\n\t\t\"Listing does not recover a run or claim ownership.\",\n\t].join(\"\\n\"),\n\tstatus: \"View progress of the active run\\n\\nUsage:\\n /flow status\",\n\tcancel: \"Stop the active run\\n\\nUsage:\\n /flow cancel\",\n\tpause: \"Pause new work. Running agents finish their current turn. No new agents will start.\\n\\nUsage:\\n /flow pause\",\n\tresume: \"Resume paused work\\n\\nUsage:\\n /flow resume\",\n\ttitle: \"Rename the active run\\n\\nUsage:\\n /flow title <title>\",\n\tmessage:\n\t\t\"Send guidance to the running lead. It is held until the lead starts if none is running yet, and sent to the host as a follow-up when no Flow is running.\\n\\nUsage:\\n /flow message <text>\\n\\nUse \\\\n for newlines.\",\n\thide: \"Hide the widget; work continues. Only the current widget is hidden; a new run shows it again. Bring it back with /flow show.\\n\\nUsage:\\n /flow hide\",\n\tshow: \"Show the active run's widget, or the retained final result of the last run until a new run starts.\\n\\nUsage:\\n /flow show\",\n\tmodels: `Flow models\\n\\nView or change the models Flow uses.\\nChanges apply to future runs. Runs already started keep their settings.\\nFlow switches models after a failure only to fallbacks you list.\\nWith no fallbacks configured, Flow will not switch models automatically.\\n\\nUsage:\\n /flow models [${MODELS_SUBCOMMANDS.join(\"|\")}]\\n\\nView current choices:\\n /flow models show`,\n\tprofile: `Flow profiles\\n\\nView and manage saved run settings.\\nChanges apply to future runs. Runs already started keep their settings.\\n\\nUsage:\\n /flow profile [${PROFILE_SUBCOMMANDS.join(\"|\")}]\\n\\nList profiles:\\n /flow profile list`,\n\t// The account sentence must equal FLOW_ACCOUNT_PERSISTENCE_NOTICE; humain-flow-command.test.ts enforces it.\n\tsetup: `Connect providers and configure Flow\\n\\nTerminal only. Use /flow models and /flow profile from other modes.\\nProfile edits remain unsaved until Save. Sign-in and account changes take effect immediately and are not undone by cancelling setup.\\n\\nUsage:\\n /flow setup`,\n};\n\n/** Static help text. An unrecognized topic yields the unknown-topic copy; the parser rejects those before this. */\nexport function renderFlowHelp(topic?: string): string {\n\tconst name = topic?.trim();\n\tif (!name) return GENERAL_HELP;\n\tif (!isSubcommand(name)) {\n\t\treturn `No help topic named “${sanitizeForTerminal(name).slice(0, 80)}”. Use /flow help to see available commands.`;\n\t}\n\treturn TOPIC_HELP[name];\n}\n\n/** Static completion for the argument text after `/flow `: subcommands, then help topics and nested names. */\nexport function completeFlowArguments(prefix: string): AutocompleteItem[] | null {\n\tconst words = prefix.trimStart().split(/\\s+/);\n\tconst [first = \"\", second] = words;\n\tconst items: AutocompleteItem[] = [];\n\tif (words.length === 1) {\n\t\tfor (const command of FLOW_SUBCOMMANDS) {\n\t\t\tif (command.startsWith(first)) {\n\t\t\t\titems.push({\n\t\t\t\t\tvalue: command,\n\t\t\t\t\tlabel: command,\n\t\t\t\t\tdescription: SUMMARIES[command],\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t} else if (words.length === 2 && first === \"help\") {\n\t\tfor (const command of FLOW_SUBCOMMANDS) {\n\t\t\tif (command.startsWith(second ?? \"\"))\n\t\t\t\titems.push({ value: `help ${command}`, label: command, description: SUMMARIES[command] });\n\t\t}\n\t} else if (words.length === 2 && (first === \"models\" || first === \"profile\")) {\n\t\tfor (const name of first === \"models\" ? MODELS_SUBCOMMANDS : PROFILE_SUBCOMMANDS) {\n\t\t\tif (name.startsWith(second ?? \"\")) items.push({ value: `${first} ${name}`, label: name });\n\t\t}\n\t}\n\treturn items.length > 0 ? items : null;\n}\n"]}
1
+ {"version":3,"file":"flow-command.js","sourceRoot":"","sources":["../../src/humain/flow-command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE;;;GAGG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,MAAM;IACN,KAAK;IACL,UAAU;IACV,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,OAAO;IACP,SAAS;IACT,MAAM;IACN,MAAM;IAC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OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC5F,CAAC;IACF,CAAC;SAAM,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,SAAS,CAAC,EAAE,CAAC;QAC9E,KAAK,MAAM,IAAI,IAAI,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,mBAAmB,EAAE,CAAC;YAClF,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,EAAE,CAAC;gBAAE,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3F,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACxC,CAAC","sourcesContent":["import type { AutocompleteItem } from \"@earendil-works/pi-tui\";\nimport { sanitizeForTerminal } from \"../core/trace-client/sanitize.ts\";\n\n/**\n * Static vocabulary, parsing, help and completion for the single `/flow` command. Pure and dependency-light on\n * purpose: the lazy loader uses it before (and without) importing Flow, so help works when Flow is disabled.\n */\n\nexport const FLOW_SUBCOMMANDS = [\n\t\"help\",\n\t\"run\",\n\t\"continue\",\n\t\"fix\",\n\t\"list\",\n\t\"status\",\n\t\"cancel\",\n\t\"pause\",\n\t\"resume\",\n\t\"title\",\n\t\"message\",\n\t\"hide\",\n\t\"show\",\n\t\"models\",\n\t\"profile\",\n\t\"setup\",\n] as const;\n\nexport type FlowSubcommand = (typeof FLOW_SUBCOMMANDS)[number];\n\n/** Refusal for `/flow setup` outside the terminal UI: secure account dialogs exist only there. */\nexport const FLOW_SETUP_TERMINAL_ONLY =\n\t\"/flow setup needs the interactive terminal. Use /flow models and /flow profile for changes from other modes.\";\n\n/** Commands that take no arguments. */\nconst NO_ARGUMENT_SUBCOMMANDS: ReadonlySet<FlowSubcommand> = new Set([\n\t\"list\",\n\t\"status\",\n\t\"cancel\",\n\t\"pause\",\n\t\"resume\",\n\t\"hide\",\n\t\"show\",\n\t\"setup\",\n]);\n\nconst SUMMARIES: Record<FlowSubcommand, string> = {\n\thelp: \"Show usage and examples\",\n\trun: \"Start work\",\n\tcontinue: \"Recover an interrupted run\",\n\tfix: \"Fix failing checks of a verified-after run\",\n\tlist: \"Find recent runs and run IDs\",\n\tstatus: \"View progress\",\n\tcancel: \"Stop the active run\",\n\tpause: \"Pause new work\",\n\tresume: \"Resume paused work\",\n\ttitle: \"Rename the active run\",\n\tmessage: \"Send guidance\",\n\thide: \"Hide the widget; work continues\",\n\tshow: \"Show the active run's widget\",\n\tmodels: \"Manage model choices\",\n\tprofile: \"Manage run profiles\",\n\tsetup: \"Connect providers and configure Flow\",\n};\n\nconst MODELS_SUBCOMMANDS = [\n\t\"show\",\n\t\"list\",\n\t\"validate\",\n\t\"check\",\n\t\"set\",\n\t\"effort\",\n\t\"use\",\n\t\"new\",\n\t\"pick\",\n\t\"convert\",\n\t\"workflow\",\n];\nconst PROFILE_SUBCOMMANDS = [\"list\", \"show\", \"use\", \"export\", \"import\", \"validate\"];\n\nconst isSubcommand = (value: string): value is FlowSubcommand =>\n\t(FLOW_SUBCOMMANDS as readonly string[]).includes(value);\n\n/** Copy for a recognized subcommand this build does not implement yet. */\nexport function flowBuildUnavailable(command: string): string {\n\treturn `/flow ${sanitizeForTerminal(command)} is not available in this build. Use /flow help to see supported commands.`;\n}\n\n/**\n * Splits `/flow` arguments into subcommand and payload. Consumes the subcommand and exactly one separating\n * whitespace character; the rest of the payload is returned byte-for-byte so goal, message and title text is\n * never split or rejoined. Bare or whitespace-only input means help.\n */\nexport function parseFlowCommand(\n\targs: string,\n): { command: FlowSubcommand; payload: string } | { error: string; command?: FlowSubcommand } {\n\tconst match = /^\\s*(\\S+)([\\s\\S]*)$/.exec(args);\n\tif (!match) return { command: \"help\", payload: \"\" };\n\tconst [, name, rest] = match;\n\tif (!isSubcommand(name)) {\n\t\treturn {\n\t\t\terror: `Unknown Flow command: ${sanitizeForTerminal(name).slice(0, 80)}. Use /flow help to see available commands. To start work: /flow run <goal>`,\n\t\t};\n\t}\n\tconst payload = /^\\s/.test(rest) ? rest.slice(1) : rest;\n\tconst trimmed = payload.trim();\n\tif (name === \"help\" && trimmed) {\n\t\tif (/\\s/.test(trimmed)) return { error: \"/flow help accepts at most one topic. Usage: /flow help [topic]\" };\n\t\tif (!isSubcommand(trimmed)) {\n\t\t\treturn {\n\t\t\t\terror: `No help topic named “${sanitizeForTerminal(trimmed).slice(0, 80)}”. Use /flow help to see available commands.`,\n\t\t\t};\n\t\t}\n\t}\n\tif (NO_ARGUMENT_SUBCOMMANDS.has(name) && trimmed) {\n\t\treturn { error: `/flow ${name} does not accept arguments. Usage: /flow ${name}` };\n\t}\n\tif (name === \"fix\" && /\\s/.test(trimmed)) {\n\t\treturn { error: \"/flow fix accepts at most one run ID. Usage: /flow fix [run-id]\", command: name };\n\t}\n\tif (name === \"continue\" && /\\s/.test(trimmed)) {\n\t\t// `command` lets the loader settle the refused start over rpc.\n\t\treturn { error: \"/flow continue accepts at most one run ID. Usage: /flow continue [run-id]\", command: name };\n\t}\n\treturn { command: name, payload };\n}\n\nconst helpRow = (usage: string, command: FlowSubcommand) => `${` ${usage}`.padEnd(27)}${SUMMARIES[command]}`;\n\nconst GENERAL_HELP = [\n\t\"Flow — plan, run, and verify work with agents.\",\n\t\"\",\n\t\"Start work\",\n\t\" /flow run <goal> [flags]\",\n\t\"\",\n\t\"Manage a run\",\n\thelpRow(\"/flow list\", \"list\"),\n\thelpRow(\"/flow status\", \"status\"),\n\thelpRow(\"/flow cancel\", \"cancel\"),\n\thelpRow(\"/flow pause\", \"pause\"),\n\thelpRow(\"/flow resume\", \"resume\"),\n\thelpRow(\"/flow continue [run-id]\", \"continue\"),\n\thelpRow(\"/flow fix [run-id]\", \"fix\"),\n\thelpRow(\"/flow title <title>\", \"title\"),\n\thelpRow(\"/flow message <text>\", \"message\"),\n\thelpRow(\"/flow hide\", \"hide\"),\n\thelpRow(\"/flow show\", \"show\"),\n\t\"\",\n\t\"Configure\",\n\thelpRow(\"/flow setup\", \"setup\"),\n\thelpRow(\"/flow models <command>\", \"models\"),\n\thelpRow(\"/flow profile <command>\", \"profile\"),\n\t\"\",\n\t\"Learn more\",\n\t\" /flow help <command> Show usage and examples\",\n\t\"\",\n\t\"Example\",\n\t\" /flow run Fix the login timeout --risk medium\",\n].join(\"\\n\");\n\nconst RUN_FLAGS = [\n\t\"Flags:\",\n\t\" --task-class T --complexity N --risk low|medium|high|critical\",\n\t\" --profile ID --lead-size small|standard|large --workflow direct|checked|led|full --effort LEVEL\",\n\t\" --cheap ALIAS --mid ALIAS --premium ALIAS --frontier ALIAS --model <capability>=ALIAS\",\n\t\" --quality-floor F --cost-aggressiveness C --max-retries R --fan-out\",\n\t\" --context FILE ... --with-last-reply --force --route-only --candidate PATH --verify-after\",\n\t\" --live-qa --no-live-qa --live-qa-adapter ID --live-qa-scope SCOPE --live-qa-acceptance FILE\",\n].join(\"\\n\");\n\nconst TOPIC_HELP: Record<FlowSubcommand, string> = {\n\thelp: \"Show help\\n\\nUsage:\\n /flow help [command]\",\n\trun: [\n\t\t\"Start a Flow run\",\n\t\t\"\",\n\t\t\"Usage:\",\n\t\t\" /flow run <goal> [flags]\",\n\t\t\"\",\n\t\t\"Example:\",\n\t\t\" /flow run Fix the login timeout --risk medium\",\n\t\t\"\",\n\t\t\"Describe the outcome you want. Flow plans the work,\",\n\t\t\"dispatches agents, and verifies the result.\",\n\t\t\"\",\n\t\tRUN_FLAGS,\n\t].join(\"\\n\"),\n\tfix: \"Fix the failing checks of a run started with --verify-after\\n\\nUsage:\\n /flow fix [run-id]\\n\\nStarts a new run from that run's local failing-check report. Default: the last such run in this session.\",\n\tcontinue:\n\t\t\"Recover an interrupted run\\n\\nUsage:\\n /flow continue [run-id]\\n\\nRecovery requires a safety check and your confirmation.\",\n\tlist: [\n\t\t\"Find recent runs and run IDs\",\n\t\t\"\",\n\t\t\"Usage:\",\n\t\t\" /flow list\",\n\t\t\"\",\n\t\t\"History examines up to 200 runs by creation time.\",\n\t\t\"Runs without readable execution snapshots are omitted.\",\n\t\t\"Listing does not recover a run or claim ownership.\",\n\t].join(\"\\n\"),\n\tstatus: \"View progress of the active run\\n\\nUsage:\\n /flow status\",\n\tcancel: \"Stop the active run\\n\\nUsage:\\n /flow cancel\",\n\tpause: \"Pause new work. Running agents finish their current turn. No new agents will start.\\n\\nUsage:\\n /flow pause\",\n\tresume: \"Resume paused work\\n\\nUsage:\\n /flow resume\",\n\ttitle: \"Rename the active run\\n\\nUsage:\\n /flow title <title>\",\n\tmessage:\n\t\t\"Send guidance to the running lead. It is held until the lead starts if none is running yet, and sent to the host as a follow-up when no Flow is running.\\n\\nUsage:\\n /flow message <text>\\n\\nUse \\\\n for newlines.\",\n\thide: \"Hide the widget; work continues. Only the current widget is hidden; a new run shows it again. Bring it back with /flow show.\\n\\nUsage:\\n /flow hide\",\n\tshow: \"Show the active run's widget, or the retained final result of the last run until a new run starts.\\n\\nUsage:\\n /flow show\",\n\tmodels: `Flow models\\n\\nView or change the models Flow uses.\\nChanges apply to future runs. Runs already started keep their settings.\\nFlow switches models after a failure only to fallbacks you list.\\nWith no fallbacks configured, Flow will not switch models automatically.\\n\\nUsage:\\n /flow models [${MODELS_SUBCOMMANDS.join(\"|\")}]\\n\\nView current choices:\\n /flow models show`,\n\tprofile: `Flow profiles\\n\\nView and manage saved run settings.\\nChanges apply to future runs. Runs already started keep their settings.\\n\\nUsage:\\n /flow profile [${PROFILE_SUBCOMMANDS.join(\"|\")}]\\n\\nList profiles:\\n /flow profile list`,\n\t// The account sentence must equal FLOW_ACCOUNT_PERSISTENCE_NOTICE; humain-flow-command.test.ts enforces it.\n\tsetup: `Connect providers and configure Flow\\n\\nTerminal only. Use /flow models and /flow profile from other modes.\\nProfile edits remain unsaved until Save. Sign-in and account changes take effect immediately and are not undone by cancelling setup.\\n\\nUsage:\\n /flow setup`,\n};\n\n/** Static help text. An unrecognized topic yields the unknown-topic copy; the parser rejects those before this. */\nexport function renderFlowHelp(topic?: string): string {\n\tconst name = topic?.trim();\n\tif (!name) return GENERAL_HELP;\n\tif (!isSubcommand(name)) {\n\t\treturn `No help topic named “${sanitizeForTerminal(name).slice(0, 80)}”. Use /flow help to see available commands.`;\n\t}\n\treturn TOPIC_HELP[name];\n}\n\n/** Static completion for the argument text after `/flow `: subcommands, then help topics and nested names. */\nexport function completeFlowArguments(prefix: string): AutocompleteItem[] | null {\n\tconst words = prefix.trimStart().split(/\\s+/);\n\tconst [first = \"\", second] = words;\n\tconst items: AutocompleteItem[] = [];\n\tif (words.length === 1) {\n\t\tfor (const command of FLOW_SUBCOMMANDS) {\n\t\t\tif (command.startsWith(first)) {\n\t\t\t\titems.push({\n\t\t\t\t\tvalue: command,\n\t\t\t\t\tlabel: command,\n\t\t\t\t\tdescription: SUMMARIES[command],\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t} else if (words.length === 2 && first === \"help\") {\n\t\tfor (const command of FLOW_SUBCOMMANDS) {\n\t\t\tif (command.startsWith(second ?? \"\"))\n\t\t\t\titems.push({ value: `help ${command}`, label: command, description: SUMMARIES[command] });\n\t\t}\n\t} else if (words.length === 2 && (first === \"models\" || first === \"profile\")) {\n\t\tfor (const name of first === \"models\" ? MODELS_SUBCOMMANDS : PROFILE_SUBCOMMANDS) {\n\t\t\tif (name.startsWith(second ?? \"\")) items.push({ value: `${first} ${name}`, label: name });\n\t\t}\n\t}\n\treturn items.length > 0 ? items : null;\n}\n"]}
@@ -96,7 +96,7 @@ const NO_LOADED_RUN_COPY = {
96
96
  show: "No current Flow widget to show.",
97
97
  };
98
98
  /** Only these start (or recover) work, so only their refusals settle an rpc run. */
99
- const START_COMMANDS = new Set(["run", "continue"]);
99
+ const START_COMMANDS = new Set(["run", "continue", "fix"]);
100
100
  function isRecord(value) {
101
101
  return typeof value === "object" && value !== null;
102
102
  }
@@ -1 +1 @@
1
- {"version":3,"file":"flow-loader.js","sourceRoot":"","sources":["../../src/humain/flow-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG/D,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAOvH,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EACN,qBAAqB,EACrB,wBAAwB,EAExB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,GACd,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,+BAA+B,CAAC;AACxE,MAAM,CAAC,MAAM,2BAA2B,GAAG,kCAAkC,CAAC;AAkC9E,IAAI,UAAsC,CAAC;AAC3C,IAAI,aAA0C,CAAC;AAC/C,IAAI,SAA0E,CAAC;AAC/E,IAAI,SAAkE,CAAC;AACvE,IAAI,WAA0D,CAAC;AAE/D,qGAAqG;AACrG,MAAM,UAAU,iBAAiB;IAChC,OAAO,UAAU,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACvC,IAAI,UAAU;QAAE,OAAO,UAAU,CAAC;IAClC,IAAI,cAAc,EAAE;QAAE,OAAO,SAAS,CAAC;IACvC,OAAO,SAAS,EAAE,EAAE,CAAC;AACtB,CAAC;AAED,sHAA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CAAC;oBACH,CAAC;4BAAS,CAAC;wBACV,MAAM,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;oBAC/C,CAAC;oBACD,OAAO;gBACR,CAAC;gBACD,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBAClC,IAAI,CAAC,IAAI,EAAE,CAAC;oBACX,IAAI,CAAC;wBACJ,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;oBACvD,CAAC;4BAAS,CAAC;wBACV,MAAM,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;oBAC/C,CAAC;oBACD,OAAO;gBACR,CAAC;gBACD,wFAAwF;gBACxF,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAC/B,CAAC;SACD,CAAC,CAAC;IACJ,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { createHash, randomBytes } from \"node:crypto\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\nimport type { FlowFailureClass } from \"@humain/humain-code-contracts/flow-common\";\nimport type { FlowEventFrameV1, FlowReceiptV1, FlowStatusV1 } from \"@humain/humain-code-contracts/flow-control\";\nimport { getAgentDir, getBundledFlowPackageDir, getBundledFlowProfilesDir, PACKAGE_NAME, VERSION } from \"../config.ts\";\nimport type {\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionFactory,\n\tRegisteredCommand,\n} from \"../core/extensions/types.ts\";\nimport { createTraceRedactor } from \"../core/trace/redaction.ts\";\nimport { sanitizeForTerminal } from \"../core/trace-client/sanitize.ts\";\nimport {\n\tcompleteFlowArguments,\n\tFLOW_SETUP_TERMINAL_ONLY,\n\ttype FlowSubcommand,\n\tflowBuildUnavailable,\n\tparseFlowCommand,\n\trenderFlowHelp,\n} from \"./flow-command.ts\";\n\n/**\n * Lazy loader for the private @humain/flow package.\n *\n * The CLI entry graph must not statically reach Flow: this module registers one cheap `/flow` stub and two flags, and\n * only loads Flow (one memoized dynamic import) the first time a subcommand needs it. Help, completion, unknown\n * commands and not-yet-available commands are answered statically and never import Flow. Flow is bundled as its own\n * chunk.\n */\n\nexport const HUMAIN_FLOW_DISABLED_ENV = \"HUMAIN_TERMINAL_FLOW_DISABLED\";\nexport const HUMAIN_FLOW_PACKAGE_DIR_ENV = \"HUMAIN_TERMINAL_FLOW_PACKAGE_DIR\";\n\n/** Run-control surface Flow exposes to rpc mode (flow_status/pause/resume/cancel/message). */\nexport interface FlowRpcControl {\n\thandle(input: unknown): Promise<{ receipt: FlowReceiptV1; status?: FlowStatusV1 }>;\n\tactiveRunId(): string | undefined;\n}\n\nexport interface FlowModule {\n\tflowExtension: ExtensionFactory;\n\t/** Documented rpc hook: called once when Flow loads; `writeFrame` carries `flow_event` frames to the rpc host. */\n\tcreateFlowRpcControl?(options: {\n\t\twriteFrame?: (frame: FlowEventFrameV1) => void | Promise<void>;\n\t\tisDisabled?: () => boolean;\n\t\t/** Queues text on the host session as a follow-up (flow_message with no active run). */\n\t\tsendFollowUp?: (text: string) => Promise<void>;\n\t}): FlowRpcControl;\n\t/** B1 profile command; optional so test fakes need not provide it. Methods stay bivariant for the real signatures. */\n\trunFlowProfileCommand?(args: string, ctx: ExtensionCommandContext, deps: { store: unknown }): Promise<unknown>;\n\tcreateProfileStore?(options: { flowDir: string; builtInDir?: string }): unknown;\n}\n\nexport interface HumainFlowLoaderOptions {\n\t/** Test seam. Defaults to the single sanctioned dynamic import of @humain/flow. */\n\timportFlow?: () => Promise<FlowModule>;\n\tenv?: NodeJS.ProcessEnv;\n\t/** Directory holding Flow's agents/assets/package.json. Defaults to the bundled layout's flow/ dir. */\n\tflowPackageDir?: string;\n\t/** Built-in Flow profiles dir. Defaults to the bundled layout's assets/profiles; undefined lets Flow find its own. */\n\tbuiltInProfilesDir?: string;\n\t/** Flow profile store directory. Defaults to `<agentDir>/flow`. */\n\tflowDir?: string;\n}\n\nlet rpcControl: FlowRpcControl | undefined;\nlet disabledProbe: (() => boolean) | undefined;\nlet rpcOutput: ((frame: FlowEventFrameV1) => void | Promise<void>) | undefined;\nlet rpcLoader: (() => Promise<FlowRpcControl | undefined>) | undefined;\nlet rpcFollowUp: ((text: string) => Promise<void>) | undefined;\n\n/** The documented rpc hook: rpc mode reads Flow's run control here and never imports Flow itself. */\nexport function getFlowRpcControl(): FlowRpcControl | undefined {\n\treturn rpcControl;\n}\n\n/**\n * The documented rpc hook: loads Flow through the same lazy-load path the stub commands use and returns its run control.\n * Undefined when Flow is disabled (never loaded then), not wired, or fails to load.\n */\nexport async function loadFlowRpcControl(): Promise<FlowRpcControl | undefined> {\n\tif (rpcControl) return rpcControl;\n\tif (isFlowDisabled()) return undefined;\n\treturn rpcLoader?.();\n}\n\n/** True while Flow is switched off (flow.enabled=false or the env kill switch); rpc mode refuses flow_resume then. */\nexport function isFlowDisabled(): boolean {\n\treturn disabledProbe?.() ?? false;\n}\n\n/** The documented rpc hook: rpc mode registers where Flow's `flow_event` frames are written. */\nexport function setFlowRpcOutput(writer: ((frame: FlowEventFrameV1) => void | Promise<void>) | undefined): void {\n\trpcOutput = writer;\n}\n\n/** The documented rpc hook: rpc mode registers how direct-mode flow_message text is queued as a host follow-up. */\nexport function setFlowRpcFollowUp(queue: ((text: string) => Promise<void>) | undefined): void {\n\trpcFollowUp = queue;\n}\n\ntype CommandOptions = Omit<RegisteredCommand, \"name\" | \"sourceInfo\">;\ntype EventHandler = (...args: unknown[]) => unknown;\n\n/**\n * ExtensionAPI members that only record registrations (see core/extensions/loader.ts). They are staged while Flow's\n * factory runs and applied to the real pi only after the factory and the session_start replay succeed. Reads and\n * actions (getFlag, getSettings, exec, sendMessage, ...) and `events` stay live: they have no registration to undo\n * or are needed by the factory itself. Flow uses none of the live ones that subscribe (`events.on`).\n */\nconst STAGED_MEMBERS = new Set([\n\t\"on\",\n\t\"registerTool\",\n\t\"registerCommand\",\n\t\"registerShortcut\",\n\t\"registerFlag\",\n\t\"registerMessageRenderer\",\n\t\"registerMarkdownTransformer\",\n\t\"registerEntryRenderer\",\n\t\"registerProvider\",\n\t\"unregisterProvider\",\n\t\"registerMcpServer\",\n\t\"unregisterMcpServer\",\n\t\"registerVirtualModel\",\n\t\"unregisterVirtualModel\",\n]);\n\ninterface StagedCall {\n\tmember: string;\n\targs: unknown[];\n\tcancelled: boolean;\n\tunsubscribe?: () => void;\n}\n\nconst FLOW_DESCRIPTION =\n\t\"Plan, run, and verify work with agents. Subcommands: run, continue, list, status, cancel, pause, resume, \" +\n\t\"title, message, hide, show, models, profile, setup. Use /flow help for usage.\";\n\n/**\n * Act on an already loaded run only; with Flow not loaded there is no run, so Flow is never imported for them. They\n * stay reachable when Flow is disabled so a live run can still be stopped. Every other subcommand is refused when\n * disabled.\n */\nconst LOADED_RUN_COMMANDS: ReadonlySet<FlowSubcommand> = new Set([\n\t\"cancel\",\n\t\"status\",\n\t\"pause\",\n\t\"resume\",\n\t\"hide\",\n\t\"show\",\n]);\n/** Kill switch: resume would restart dispatch, so it is refused while Flow is disabled (the others are not). */\nconst AVAILABLE_WHEN_DISABLED: ReadonlySet<FlowSubcommand> = new Set([\"cancel\", \"status\", \"pause\", \"hide\", \"show\"]);\n/** Copy when a loaded-run command finds no Flow loaded, so there is nothing to act on. */\nconst NO_LOADED_RUN_COPY: Partial<Record<FlowSubcommand, string>> = {\n\tcancel: \"No active Flow run to stop.\",\n\tstatus: \"No active Flow run. Start one with /flow run <goal>.\",\n\tpause: \"No active Flow run to pause.\",\n\tresume: \"No paused Flow run to resume.\",\n\thide: \"No current Flow widget to hide.\",\n\tshow: \"No current Flow widget to show.\",\n};\n/** Only these start (or recover) work, so only their refusals settle an rpc run. */\nconst START_COMMANDS: ReadonlySet<FlowSubcommand> = new Set([\"run\", \"continue\"]);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\n/**\n * Print/json mode has no UI: core makes ctx.ui.notify a no-op, so headless notices go to stderr as bare text.\n * Notice text can echo user args or env values, so it is redacted, stripped of terminal escapes, then redacted again\n * with the same redactor: the first pass catches secrets that stripping could otherwise mangle, the second catches\n * secrets that were split by escapes and are rejoined by stripping. Fails closed to a fixed line on any failure.\n * Replacing `ui` snapshots ui (descriptors preserve other ctx getters, so lazy getters on ctx stay live; same approach\n * as the runner's createCommandContext).\n */\nconst NOTICE_WITHHELD = \"[notice withheld: redaction unavailable]\";\n\nfunction safeNotice(message: string): string {\n\ttry {\n\t\tconst redactor = createTraceRedactor({ env: process.env });\n\t\treturn redactor.redactText(sanitizeForTerminal(redactor.redactText(message).text)).text;\n\t} catch {\n\t\treturn NOTICE_WITHHELD;\n\t}\n}\n\nfunction withHeadlessNotices(ctx: ExtensionCommandContext): ExtensionCommandContext {\n\tif (ctx.mode !== \"print\" && ctx.mode !== \"json\") return ctx;\n\tconst ui = Object.defineProperties({}, Object.getOwnPropertyDescriptors(ctx.ui)) as ExtensionCommandContext[\"ui\"];\n\tui.notify = (message: string) => {\n\t\tprocess.stderr.write(`${safeNotice(message)}\\n`);\n\t};\n\tconst wrapped = Object.defineProperties({}, Object.getOwnPropertyDescriptors(ctx)) as ExtensionCommandContext;\n\tObject.defineProperty(wrapped, \"ui\", { value: ui, enumerable: true, configurable: true });\n\treturn wrapped;\n}\n\n/**\n * Mirrors packages/flow emitRefusalSettled: an rpc `/flow run` or `/flow continue` that dispatches nothing still emits one terminal\n * `run_settled` frame so the host stops waiting. Built here because the entry graph must not reach @humain/flow.\n * Print/json refusals exit non-zero (mirrors flow's markHeadlessFailure). Never throws; no-op otherwise.\n */\nasync function settleRefusal(\n\tcommand: FlowSubcommand,\n\tctx: ExtensionCommandContext,\n\tfailureClass: FlowFailureClass,\n): Promise<void> {\n\tif (!START_COMMANDS.has(command)) return;\n\tif (ctx.mode === \"print\" || ctx.mode === \"json\") process.exitCode = 1;\n\tif (ctx.mode !== \"rpc\" || !rpcOutput) return;\n\ttry {\n\t\tconst runId = `flow-refused-${randomBytes(8).toString(\"hex\")}`;\n\t\tconst frame: FlowEventFrameV1 = {\n\t\t\ttype: \"flow_event\",\n\t\t\tevent: {\n\t\t\t\tschema: \"humain-flow-event\",\n\t\t\t\tschemaVersion: 1,\n\t\t\t\teventId: `${runId}.refused`,\n\t\t\t\trunId,\n\t\t\t\tseq: 1,\n\t\t\t\tts: new Date().toISOString(),\n\t\t\t\tprofile: {\n\t\t\t\t\tid: \"unknown\",\n\t\t\t\t\tversion: 1,\n\t\t\t\t\tdigest: createHash(\"sha256\").update(\"unknown\", \"utf8\").digest(\"hex\"),\n\t\t\t\t},\n\t\t\t\tcauses: [],\n\t\t\t\tkind: \"run_settled\",\n\t\t\t\tpayload: { outcome: \"failed\", failureClass, settledCleanly: true, retryOffer: [\"direct\"], totals: {} },\n\t\t\t},\n\t\t};\n\t\tawait rpcOutput(frame);\n\t} catch {\n\t\t// Refusal must still notify; a dead transport is not the command's problem.\n\t}\n}\n\nfunction disabledReason(pi: ExtensionAPI, env: NodeJS.ProcessEnv): string | undefined {\n\tconst raw = env[HUMAIN_FLOW_DISABLED_ENV]?.trim().toLowerCase();\n\tif (raw === \"1\" || raw === \"true\") return `${HUMAIN_FLOW_DISABLED_ENV}=${raw}`;\n\ttry {\n\t\t// `flow` is not a typed Settings key: settings.json keeps unknown keys, so read it raw.\n\t\tconst flow = (pi.getSettings() as Record<string, unknown>).flow;\n\t\tif (isRecord(flow) && flow.enabled === false) return \"setting flow.enabled=false\";\n\t} catch {\n\t\t// Runtime not bound yet: treat as enabled.\n\t}\n\treturn undefined;\n}\n\n/**\n * Run flowExtension against a staging proxy. The `/flow` command is captured (so names never double-register); every other\n * registration is recorded and applied to the real pi only after the factory and the session_start replay succeed, so\n * a failed attempt leaves nothing behind and a retry starts from scratch. Late registration is supported by the\n * extension loader (handlers, tools, commands and flags are written to the live extension object), but\n * `session_start` has already fired by the time Flow loads, so the last session_start event is replayed to Flow's\n * staged session_start handlers.\n *\n * Commit is not transactional for non-handler members: if one throws midway, committed handlers are unsubscribed, and\n * tools/commands/flags/shortcuts/renderers (keyed maps in the extension loader) are simply overwritten on retry.\n */\nasync function runFlowExtension(\n\tpi: ExtensionAPI,\n\tflowExtension: ExtensionFactory,\n\tlastSessionStart: () => unknown[] | undefined,\n): Promise<Map<string, CommandOptions>> {\n\tconst captured = new Map<string, CommandOptions>();\n\tconst staged: StagedCall[] = [];\n\t// After a successful commit the proxy forwards live, so registrations made later (from handlers) reach the real pi.\n\tlet live = false;\n\tconst proxy = new Proxy(pi, {\n\t\tget(target, prop) {\n\t\t\tif (!live && typeof prop === \"string\" && STAGED_MEMBERS.has(prop)) {\n\t\t\t\treturn (...args: unknown[]) => {\n\t\t\t\t\tif (prop === \"registerCommand\" && args[0] === \"flow\") {\n\t\t\t\t\t\tcaptured.set(args[0], args[1] as CommandOptions);\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\tconst call: StagedCall = { member: prop, args, cancelled: false };\n\t\t\t\t\tstaged.push(call);\n\t\t\t\t\tif (prop !== \"on\") return undefined;\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tcall.cancelled = true;\n\t\t\t\t\t\tcall.unsubscribe?.();\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst value: unknown = Reflect.get(target, prop, target);\n\t\t\treturn typeof value === \"function\" ? value.bind(target) : value;\n\t\t},\n\t});\n\tawait flowExtension(proxy);\n\n\tlet replayed: unknown[] | undefined;\n\tfor (let start = lastSessionStart(); start && start !== replayed; start = lastSessionStart()) {\n\t\treplayed = start;\n\t\tfor (const call of staged) {\n\t\t\tif (call.member === \"on\" && call.args[0] === \"session_start\" && !call.cancelled) {\n\t\t\t\tawait (call.args[1] as EventHandler)(...start);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Synchronous from the last replay check: no session_start can slip between replay and commit.\n\tconst committed: Array<() => void> = [];\n\ttry {\n\t\tfor (const call of staged) {\n\t\t\tif (call.cancelled) continue;\n\t\t\tconst result = (Reflect.get(pi, call.member) as (...args: unknown[]) => unknown).apply(pi, call.args);\n\t\t\tif (call.member === \"on\") {\n\t\t\t\tcall.unsubscribe = result as () => void;\n\t\t\t\tcommitted.push(call.unsubscribe);\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tfor (const unsubscribe of committed) unsubscribe();\n\t\tthrow error;\n\t}\n\tlive = true;\n\treturn captured;\n}\n\nfunction isSameCliReleaseFlowDir(dir: string): boolean {\n\tif (!isAbsolute(dir) || VERSION === \"0.0.0\") return false;\n\ttry {\n\t\tconst manifest: unknown = JSON.parse(readFileSync(join(dir, \"package.json\"), \"utf8\"));\n\t\tif (!isRecord(manifest) || manifest.name !== \"@humain/flow\") return false;\n\t} catch {\n\t\treturn false;\n\t}\n\t// Bun ships flow/ beside package.json; bundled Node ships dist/bundle/flow/.\n\tfor (const root of [dirname(dir), resolve(dir, \"../../..\")]) {\n\t\ttry {\n\t\t\tconst manifest: unknown = JSON.parse(readFileSync(join(root, \"package.json\"), \"utf8\"));\n\t\t\tif (isRecord(manifest) && manifest.name === PACKAGE_NAME) return manifest.version === VERSION;\n\t\t} catch {\n\t\t\t// Missing or unreadable release metadata cannot validate an override.\n\t\t}\n\t}\n\treturn false;\n}\n\nexport function createHumainFlowLoaderExtensionFactory(options: HumainFlowLoaderOptions = {}): ExtensionFactory {\n\tconst env = options.env ?? process.env;\n\t// This is the single sanctioned lazy-load boundary for @humain/flow (see AGENTS.md \"No inline imports\" exception).\n\tconst importFlow = options.importFlow ?? (() => import(\"@humain/flow\"));\n\tconst flowPackageDir = options.flowPackageDir ?? getBundledFlowPackageDir();\n\tconst builtInProfilesDir = options.builtInProfilesDir ?? getBundledFlowProfilesDir();\n\tlet flowModule: Promise<FlowModule> | undefined;\n\n\treturn (pi) => {\n\t\tdisabledProbe = () => disabledReason(pi, env) !== undefined;\n\t\tlet lastStart: unknown[] | undefined;\n\t\tlet loaded: Promise<Map<string, CommandOptions>> | undefined;\n\n\t\tpi.on(\"session_start\", (event, ctx) => {\n\t\t\tlastStart = [event, ctx];\n\t\t});\n\t\tpi.registerFlag(\"profile\", { description: \"Flow profile id\", type: \"string\" });\n\t\tpi.registerFlag(\"flow-admission\", { description: \"Flow run admission file (JSON)\", type: \"string\" });\n\n\t\tconst loadModule = async (): Promise<FlowModule> => {\n\t\t\tconst override = env[HUMAIN_FLOW_PACKAGE_DIR_ENV];\n\t\t\tif (override && !isSameCliReleaseFlowDir(override)) delete env[HUMAIN_FLOW_PACKAGE_DIR_ENV];\n\t\t\tif (flowPackageDir && !env[HUMAIN_FLOW_PACKAGE_DIR_ENV]) env[HUMAIN_FLOW_PACKAGE_DIR_ENV] = flowPackageDir;\n\t\t\tflowModule ??= importFlow().then((module) => {\n\t\t\t\trpcControl = module.createFlowRpcControl?.({\n\t\t\t\t\twriteFrame: (frame) => rpcOutput?.(frame),\n\t\t\t\t\tisDisabled: isFlowDisabled,\n\t\t\t\t\tsendFollowUp: (text) =>\n\t\t\t\t\t\trpcFollowUp ? rpcFollowUp(text) : Promise.reject(new Error(\"host unavailable\")),\n\t\t\t\t});\n\t\t\t\treturn module;\n\t\t\t});\n\t\t\ttry {\n\t\t\t\treturn await flowModule;\n\t\t\t} catch (error) {\n\t\t\t\tflowModule = undefined;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t};\n\n\t\trpcLoader = async () => {\n\t\t\ttry {\n\t\t\t\tawait loadModule();\n\t\t\t} catch {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\treturn rpcControl;\n\t\t};\n\n\t\tconst load = (): Promise<Map<string, CommandOptions>> => {\n\t\t\tif (!loaded) {\n\t\t\t\tconst attempt = (async () => {\n\t\t\t\t\tconst module = await loadModule();\n\t\t\t\t\treturn runFlowExtension(pi, module.flowExtension, () => lastStart);\n\t\t\t\t})();\n\t\t\t\tloaded = attempt;\n\t\t\t\t// A failed load must be retryable on the next invocation.\n\t\t\t\tattempt.catch(() => {\n\t\t\t\t\tif (loaded === attempt) loaded = undefined;\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn loaded;\n\t\t};\n\n\t\tpi.registerCommand(\"flow\", {\n\t\t\tdescription: FLOW_DESCRIPTION,\n\t\t\tgetArgumentCompletions: completeFlowArguments,\n\t\t\thandler: async (args: string, rawCtx: ExtensionCommandContext) => {\n\t\t\t\tconst ctx = withHeadlessNotices(rawCtx);\n\t\t\t\tconst refuse = (message: string, level: \"warning\" | \"error\") => {\n\t\t\t\t\tif (ctx.mode === \"print\" || ctx.mode === \"json\") process.exitCode = 1;\n\t\t\t\t\tctx.ui.notify(message, level);\n\t\t\t\t};\n\t\t\t\tconst parsed = parseFlowCommand(args);\n\t\t\t\tif (\"error\" in parsed) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\trefuse(parsed.error, \"error\");\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tif (parsed.command) await settleRefusal(parsed.command, ctx, \"config_invalid\");\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst { command, payload } = parsed;\n\t\t\t\tif (command === \"help\") {\n\t\t\t\t\tctx.ui.notify(renderFlowHelp(payload.trim() || undefined), \"info\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Secure account dialogs exist only in the terminal UI: refuse elsewhere before loading Flow.\n\t\t\t\tif (command === \"setup\" && ctx.mode !== \"tui\") {\n\t\t\t\t\trefuse(FLOW_SETUP_TERMINAL_ONLY, \"error\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst reason = AVAILABLE_WHEN_DISABLED.has(command) ? undefined : disabledReason(pi, env);\n\t\t\t\tif (reason) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tctx.ui.notify(`Flow disabled (${reason}). /flow ${command} is unavailable.`, \"warning\");\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tawait settleRefusal(command, ctx, \"config_invalid\");\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (command === \"profile\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst module = await loadModule();\n\t\t\t\t\t\tif (!module.runFlowProfileCommand || !module.createProfileStore) {\n\t\t\t\t\t\t\tctx.ui.notify(flowBuildUnavailable(command), \"error\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst store = module.createProfileStore({\n\t\t\t\t\t\t\tflowDir: options.flowDir ?? join(getAgentDir(), \"flow\"),\n\t\t\t\t\t\t\t...(builtInProfilesDir !== undefined ? { builtInDir: builtInProfilesDir } : {}),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tawait module.runFlowProfileCommand(payload, ctx, { store });\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`/flow profile failed: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (LOADED_RUN_COMMANDS.has(command) && !loaded) {\n\t\t\t\t\tctx.ui.notify(NO_LOADED_RUN_COPY[command] ?? \"No active Flow run.\", \"info\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet commands: Map<string, CommandOptions>;\n\t\t\t\ttry {\n\t\t\t\t\tcommands = await load();\n\t\t\t\t} catch (error) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Failed to load Flow: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tawait settleRefusal(command, ctx, \"internal\");\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst real = commands.get(\"flow\");\n\t\t\t\tif (!real) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tctx.ui.notify(flowBuildUnavailable(command), \"error\");\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tawait settleRefusal(command, ctx, \"internal\");\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Flow's own dispatcher re-parses the original arguments and slices the payload itself.\n\t\t\t\tawait real.handler(args, ctx);\n\t\t\t},\n\t\t});\n\t};\n}\n"]}
1
+ {"version":3,"file":"flow-loader.js","sourceRoot":"","sources":["../../src/humain/flow-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG/D,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAOvH,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EACN,qBAAqB,EACrB,wBAAwB,EAExB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,GACd,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,+BAA+B,CAAC;AACxE,MAAM,CAAC,MAAM,2BAA2B,GAAG,kCAAkC,CAAC;AAkC9E,IAAI,UAAsC,CAAC;AAC3C,IAAI,aAA0C,CAAC;AAC/C,IAAI,SAA0E,CAAC;AAC/E,IAAI,SAAkE,CAAC;AACvE,IAAI,WAA0D,CAAC;AAE/D,qGAAqG;AACrG,MAAM,UAAU,iBAAiB;IAChC,OAAO,UAAU,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kB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,GAAG,CAAC,EAAE,CAAC,MAAM,CACZ,wBAAwB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAChF,OAAO,CACP,CAAC;oBACH,CAAC;4BAAS,CAAC;wBACV,MAAM,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;oBAC/C,CAAC;oBACD,OAAO;gBACR,CAAC;gBACD,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBAClC,IAAI,CAAC,IAAI,EAAE,CAAC;oBACX,IAAI,CAAC;wBACJ,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;oBACvD,CAAC;4BAAS,CAAC;wBACV,MAAM,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;oBAC/C,CAAC;oBACD,OAAO;gBACR,CAAC;gBACD,wFAAwF;gBACxF,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAC/B,CAAC;SACD,CAAC,CAAC;IACJ,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { createHash, randomBytes } from \"node:crypto\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\nimport type { FlowFailureClass } from \"@humain/humain-code-contracts/flow-common\";\nimport type { FlowEventFrameV1, FlowReceiptV1, FlowStatusV1 } from \"@humain/humain-code-contracts/flow-control\";\nimport { getAgentDir, getBundledFlowPackageDir, getBundledFlowProfilesDir, PACKAGE_NAME, VERSION } from \"../config.ts\";\nimport type {\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionFactory,\n\tRegisteredCommand,\n} from \"../core/extensions/types.ts\";\nimport { createTraceRedactor } from \"../core/trace/redaction.ts\";\nimport { sanitizeForTerminal } from \"../core/trace-client/sanitize.ts\";\nimport {\n\tcompleteFlowArguments,\n\tFLOW_SETUP_TERMINAL_ONLY,\n\ttype FlowSubcommand,\n\tflowBuildUnavailable,\n\tparseFlowCommand,\n\trenderFlowHelp,\n} from \"./flow-command.ts\";\n\n/**\n * Lazy loader for the private @humain/flow package.\n *\n * The CLI entry graph must not statically reach Flow: this module registers one cheap `/flow` stub and two flags, and\n * only loads Flow (one memoized dynamic import) the first time a subcommand needs it. Help, completion, unknown\n * commands and not-yet-available commands are answered statically and never import Flow. Flow is bundled as its own\n * chunk.\n */\n\nexport const HUMAIN_FLOW_DISABLED_ENV = \"HUMAIN_TERMINAL_FLOW_DISABLED\";\nexport const HUMAIN_FLOW_PACKAGE_DIR_ENV = \"HUMAIN_TERMINAL_FLOW_PACKAGE_DIR\";\n\n/** Run-control surface Flow exposes to rpc mode (flow_status/pause/resume/cancel/message). */\nexport interface FlowRpcControl {\n\thandle(input: unknown): Promise<{ receipt: FlowReceiptV1; status?: FlowStatusV1 }>;\n\tactiveRunId(): string | undefined;\n}\n\nexport interface FlowModule {\n\tflowExtension: ExtensionFactory;\n\t/** Documented rpc hook: called once when Flow loads; `writeFrame` carries `flow_event` frames to the rpc host. */\n\tcreateFlowRpcControl?(options: {\n\t\twriteFrame?: (frame: FlowEventFrameV1) => void | Promise<void>;\n\t\tisDisabled?: () => boolean;\n\t\t/** Queues text on the host session as a follow-up (flow_message with no active run). */\n\t\tsendFollowUp?: (text: string) => Promise<void>;\n\t}): FlowRpcControl;\n\t/** B1 profile command; optional so test fakes need not provide it. Methods stay bivariant for the real signatures. */\n\trunFlowProfileCommand?(args: string, ctx: ExtensionCommandContext, deps: { store: unknown }): Promise<unknown>;\n\tcreateProfileStore?(options: { flowDir: string; builtInDir?: string }): unknown;\n}\n\nexport interface HumainFlowLoaderOptions {\n\t/** Test seam. Defaults to the single sanctioned dynamic import of @humain/flow. */\n\timportFlow?: () => Promise<FlowModule>;\n\tenv?: NodeJS.ProcessEnv;\n\t/** Directory holding Flow's agents/assets/package.json. Defaults to the bundled layout's flow/ dir. */\n\tflowPackageDir?: string;\n\t/** Built-in Flow profiles dir. Defaults to the bundled layout's assets/profiles; undefined lets Flow find its own. */\n\tbuiltInProfilesDir?: string;\n\t/** Flow profile store directory. Defaults to `<agentDir>/flow`. */\n\tflowDir?: string;\n}\n\nlet rpcControl: FlowRpcControl | undefined;\nlet disabledProbe: (() => boolean) | undefined;\nlet rpcOutput: ((frame: FlowEventFrameV1) => void | Promise<void>) | undefined;\nlet rpcLoader: (() => Promise<FlowRpcControl | undefined>) | undefined;\nlet rpcFollowUp: ((text: string) => Promise<void>) | undefined;\n\n/** The documented rpc hook: rpc mode reads Flow's run control here and never imports Flow itself. */\nexport function getFlowRpcControl(): FlowRpcControl | undefined {\n\treturn rpcControl;\n}\n\n/**\n * The documented rpc hook: loads Flow through the same lazy-load path the stub commands use and returns its run control.\n * Undefined when Flow is disabled (never loaded then), not wired, or fails to load.\n */\nexport async function loadFlowRpcControl(): Promise<FlowRpcControl | undefined> {\n\tif (rpcControl) return rpcControl;\n\tif (isFlowDisabled()) return undefined;\n\treturn rpcLoader?.();\n}\n\n/** True while Flow is switched off (flow.enabled=false or the env kill switch); rpc mode refuses flow_resume then. */\nexport function isFlowDisabled(): boolean {\n\treturn disabledProbe?.() ?? false;\n}\n\n/** The documented rpc hook: rpc mode registers where Flow's `flow_event` frames are written. */\nexport function setFlowRpcOutput(writer: ((frame: FlowEventFrameV1) => void | Promise<void>) | undefined): void {\n\trpcOutput = writer;\n}\n\n/** The documented rpc hook: rpc mode registers how direct-mode flow_message text is queued as a host follow-up. */\nexport function setFlowRpcFollowUp(queue: ((text: string) => Promise<void>) | undefined): void {\n\trpcFollowUp = queue;\n}\n\ntype CommandOptions = Omit<RegisteredCommand, \"name\" | \"sourceInfo\">;\ntype EventHandler = (...args: unknown[]) => unknown;\n\n/**\n * ExtensionAPI members that only record registrations (see core/extensions/loader.ts). They are staged while Flow's\n * factory runs and applied to the real pi only after the factory and the session_start replay succeed. Reads and\n * actions (getFlag, getSettings, exec, sendMessage, ...) and `events` stay live: they have no registration to undo\n * or are needed by the factory itself. Flow uses none of the live ones that subscribe (`events.on`).\n */\nconst STAGED_MEMBERS = new Set([\n\t\"on\",\n\t\"registerTool\",\n\t\"registerCommand\",\n\t\"registerShortcut\",\n\t\"registerFlag\",\n\t\"registerMessageRenderer\",\n\t\"registerMarkdownTransformer\",\n\t\"registerEntryRenderer\",\n\t\"registerProvider\",\n\t\"unregisterProvider\",\n\t\"registerMcpServer\",\n\t\"unregisterMcpServer\",\n\t\"registerVirtualModel\",\n\t\"unregisterVirtualModel\",\n]);\n\ninterface StagedCall {\n\tmember: string;\n\targs: unknown[];\n\tcancelled: boolean;\n\tunsubscribe?: () => void;\n}\n\nconst FLOW_DESCRIPTION =\n\t\"Plan, run, and verify work with agents. Subcommands: run, continue, list, status, cancel, pause, resume, \" +\n\t\"title, message, hide, show, models, profile, setup. Use /flow help for usage.\";\n\n/**\n * Act on an already loaded run only; with Flow not loaded there is no run, so Flow is never imported for them. They\n * stay reachable when Flow is disabled so a live run can still be stopped. Every other subcommand is refused when\n * disabled.\n */\nconst LOADED_RUN_COMMANDS: ReadonlySet<FlowSubcommand> = new Set([\n\t\"cancel\",\n\t\"status\",\n\t\"pause\",\n\t\"resume\",\n\t\"hide\",\n\t\"show\",\n]);\n/** Kill switch: resume would restart dispatch, so it is refused while Flow is disabled (the others are not). */\nconst AVAILABLE_WHEN_DISABLED: ReadonlySet<FlowSubcommand> = new Set([\"cancel\", \"status\", \"pause\", \"hide\", \"show\"]);\n/** Copy when a loaded-run command finds no Flow loaded, so there is nothing to act on. */\nconst NO_LOADED_RUN_COPY: Partial<Record<FlowSubcommand, string>> = {\n\tcancel: \"No active Flow run to stop.\",\n\tstatus: \"No active Flow run. Start one with /flow run <goal>.\",\n\tpause: \"No active Flow run to pause.\",\n\tresume: \"No paused Flow run to resume.\",\n\thide: \"No current Flow widget to hide.\",\n\tshow: \"No current Flow widget to show.\",\n};\n/** Only these start (or recover) work, so only their refusals settle an rpc run. */\nconst START_COMMANDS: ReadonlySet<FlowSubcommand> = new Set([\"run\", \"continue\", \"fix\"]);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\n/**\n * Print/json mode has no UI: core makes ctx.ui.notify a no-op, so headless notices go to stderr as bare text.\n * Notice text can echo user args or env values, so it is redacted, stripped of terminal escapes, then redacted again\n * with the same redactor: the first pass catches secrets that stripping could otherwise mangle, the second catches\n * secrets that were split by escapes and are rejoined by stripping. Fails closed to a fixed line on any failure.\n * Replacing `ui` snapshots ui (descriptors preserve other ctx getters, so lazy getters on ctx stay live; same approach\n * as the runner's createCommandContext).\n */\nconst NOTICE_WITHHELD = \"[notice withheld: redaction unavailable]\";\n\nfunction safeNotice(message: string): string {\n\ttry {\n\t\tconst redactor = createTraceRedactor({ env: process.env });\n\t\treturn redactor.redactText(sanitizeForTerminal(redactor.redactText(message).text)).text;\n\t} catch {\n\t\treturn NOTICE_WITHHELD;\n\t}\n}\n\nfunction withHeadlessNotices(ctx: ExtensionCommandContext): ExtensionCommandContext {\n\tif (ctx.mode !== \"print\" && ctx.mode !== \"json\") return ctx;\n\tconst ui = Object.defineProperties({}, Object.getOwnPropertyDescriptors(ctx.ui)) as ExtensionCommandContext[\"ui\"];\n\tui.notify = (message: string) => {\n\t\tprocess.stderr.write(`${safeNotice(message)}\\n`);\n\t};\n\tconst wrapped = Object.defineProperties({}, Object.getOwnPropertyDescriptors(ctx)) as ExtensionCommandContext;\n\tObject.defineProperty(wrapped, \"ui\", { value: ui, enumerable: true, configurable: true });\n\treturn wrapped;\n}\n\n/**\n * Mirrors packages/flow emitRefusalSettled: an rpc `/flow run` or `/flow continue` that dispatches nothing still emits one terminal\n * `run_settled` frame so the host stops waiting. Built here because the entry graph must not reach @humain/flow.\n * Print/json refusals exit non-zero (mirrors flow's markHeadlessFailure). Never throws; no-op otherwise.\n */\nasync function settleRefusal(\n\tcommand: FlowSubcommand,\n\tctx: ExtensionCommandContext,\n\tfailureClass: FlowFailureClass,\n): Promise<void> {\n\tif (!START_COMMANDS.has(command)) return;\n\tif (ctx.mode === \"print\" || ctx.mode === \"json\") process.exitCode = 1;\n\tif (ctx.mode !== \"rpc\" || !rpcOutput) return;\n\ttry {\n\t\tconst runId = `flow-refused-${randomBytes(8).toString(\"hex\")}`;\n\t\tconst frame: FlowEventFrameV1 = {\n\t\t\ttype: \"flow_event\",\n\t\t\tevent: {\n\t\t\t\tschema: \"humain-flow-event\",\n\t\t\t\tschemaVersion: 1,\n\t\t\t\teventId: `${runId}.refused`,\n\t\t\t\trunId,\n\t\t\t\tseq: 1,\n\t\t\t\tts: new Date().toISOString(),\n\t\t\t\tprofile: {\n\t\t\t\t\tid: \"unknown\",\n\t\t\t\t\tversion: 1,\n\t\t\t\t\tdigest: createHash(\"sha256\").update(\"unknown\", \"utf8\").digest(\"hex\"),\n\t\t\t\t},\n\t\t\t\tcauses: [],\n\t\t\t\tkind: \"run_settled\",\n\t\t\t\tpayload: { outcome: \"failed\", failureClass, settledCleanly: true, retryOffer: [\"direct\"], totals: {} },\n\t\t\t},\n\t\t};\n\t\tawait rpcOutput(frame);\n\t} catch {\n\t\t// Refusal must still notify; a dead transport is not the command's problem.\n\t}\n}\n\nfunction disabledReason(pi: ExtensionAPI, env: NodeJS.ProcessEnv): string | undefined {\n\tconst raw = env[HUMAIN_FLOW_DISABLED_ENV]?.trim().toLowerCase();\n\tif (raw === \"1\" || raw === \"true\") return `${HUMAIN_FLOW_DISABLED_ENV}=${raw}`;\n\ttry {\n\t\t// `flow` is not a typed Settings key: settings.json keeps unknown keys, so read it raw.\n\t\tconst flow = (pi.getSettings() as Record<string, unknown>).flow;\n\t\tif (isRecord(flow) && flow.enabled === false) return \"setting flow.enabled=false\";\n\t} catch {\n\t\t// Runtime not bound yet: treat as enabled.\n\t}\n\treturn undefined;\n}\n\n/**\n * Run flowExtension against a staging proxy. The `/flow` command is captured (so names never double-register); every other\n * registration is recorded and applied to the real pi only after the factory and the session_start replay succeed, so\n * a failed attempt leaves nothing behind and a retry starts from scratch. Late registration is supported by the\n * extension loader (handlers, tools, commands and flags are written to the live extension object), but\n * `session_start` has already fired by the time Flow loads, so the last session_start event is replayed to Flow's\n * staged session_start handlers.\n *\n * Commit is not transactional for non-handler members: if one throws midway, committed handlers are unsubscribed, and\n * tools/commands/flags/shortcuts/renderers (keyed maps in the extension loader) are simply overwritten on retry.\n */\nasync function runFlowExtension(\n\tpi: ExtensionAPI,\n\tflowExtension: ExtensionFactory,\n\tlastSessionStart: () => unknown[] | undefined,\n): Promise<Map<string, CommandOptions>> {\n\tconst captured = new Map<string, CommandOptions>();\n\tconst staged: StagedCall[] = [];\n\t// After a successful commit the proxy forwards live, so registrations made later (from handlers) reach the real pi.\n\tlet live = false;\n\tconst proxy = new Proxy(pi, {\n\t\tget(target, prop) {\n\t\t\tif (!live && typeof prop === \"string\" && STAGED_MEMBERS.has(prop)) {\n\t\t\t\treturn (...args: unknown[]) => {\n\t\t\t\t\tif (prop === \"registerCommand\" && args[0] === \"flow\") {\n\t\t\t\t\t\tcaptured.set(args[0], args[1] as CommandOptions);\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\tconst call: StagedCall = { member: prop, args, cancelled: false };\n\t\t\t\t\tstaged.push(call);\n\t\t\t\t\tif (prop !== \"on\") return undefined;\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tcall.cancelled = true;\n\t\t\t\t\t\tcall.unsubscribe?.();\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst value: unknown = Reflect.get(target, prop, target);\n\t\t\treturn typeof value === \"function\" ? value.bind(target) : value;\n\t\t},\n\t});\n\tawait flowExtension(proxy);\n\n\tlet replayed: unknown[] | undefined;\n\tfor (let start = lastSessionStart(); start && start !== replayed; start = lastSessionStart()) {\n\t\treplayed = start;\n\t\tfor (const call of staged) {\n\t\t\tif (call.member === \"on\" && call.args[0] === \"session_start\" && !call.cancelled) {\n\t\t\t\tawait (call.args[1] as EventHandler)(...start);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Synchronous from the last replay check: no session_start can slip between replay and commit.\n\tconst committed: Array<() => void> = [];\n\ttry {\n\t\tfor (const call of staged) {\n\t\t\tif (call.cancelled) continue;\n\t\t\tconst result = (Reflect.get(pi, call.member) as (...args: unknown[]) => unknown).apply(pi, call.args);\n\t\t\tif (call.member === \"on\") {\n\t\t\t\tcall.unsubscribe = result as () => void;\n\t\t\t\tcommitted.push(call.unsubscribe);\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tfor (const unsubscribe of committed) unsubscribe();\n\t\tthrow error;\n\t}\n\tlive = true;\n\treturn captured;\n}\n\nfunction isSameCliReleaseFlowDir(dir: string): boolean {\n\tif (!isAbsolute(dir) || VERSION === \"0.0.0\") return false;\n\ttry {\n\t\tconst manifest: unknown = JSON.parse(readFileSync(join(dir, \"package.json\"), \"utf8\"));\n\t\tif (!isRecord(manifest) || manifest.name !== \"@humain/flow\") return false;\n\t} catch {\n\t\treturn false;\n\t}\n\t// Bun ships flow/ beside package.json; bundled Node ships dist/bundle/flow/.\n\tfor (const root of [dirname(dir), resolve(dir, \"../../..\")]) {\n\t\ttry {\n\t\t\tconst manifest: unknown = JSON.parse(readFileSync(join(root, \"package.json\"), \"utf8\"));\n\t\t\tif (isRecord(manifest) && manifest.name === PACKAGE_NAME) return manifest.version === VERSION;\n\t\t} catch {\n\t\t\t// Missing or unreadable release metadata cannot validate an override.\n\t\t}\n\t}\n\treturn false;\n}\n\nexport function createHumainFlowLoaderExtensionFactory(options: HumainFlowLoaderOptions = {}): ExtensionFactory {\n\tconst env = options.env ?? process.env;\n\t// This is the single sanctioned lazy-load boundary for @humain/flow (see AGENTS.md \"No inline imports\" exception).\n\tconst importFlow = options.importFlow ?? (() => import(\"@humain/flow\"));\n\tconst flowPackageDir = options.flowPackageDir ?? getBundledFlowPackageDir();\n\tconst builtInProfilesDir = options.builtInProfilesDir ?? getBundledFlowProfilesDir();\n\tlet flowModule: Promise<FlowModule> | undefined;\n\n\treturn (pi) => {\n\t\tdisabledProbe = () => disabledReason(pi, env) !== undefined;\n\t\tlet lastStart: unknown[] | undefined;\n\t\tlet loaded: Promise<Map<string, CommandOptions>> | undefined;\n\n\t\tpi.on(\"session_start\", (event, ctx) => {\n\t\t\tlastStart = [event, ctx];\n\t\t});\n\t\tpi.registerFlag(\"profile\", { description: \"Flow profile id\", type: \"string\" });\n\t\tpi.registerFlag(\"flow-admission\", { description: \"Flow run admission file (JSON)\", type: \"string\" });\n\n\t\tconst loadModule = async (): Promise<FlowModule> => {\n\t\t\tconst override = env[HUMAIN_FLOW_PACKAGE_DIR_ENV];\n\t\t\tif (override && !isSameCliReleaseFlowDir(override)) delete env[HUMAIN_FLOW_PACKAGE_DIR_ENV];\n\t\t\tif (flowPackageDir && !env[HUMAIN_FLOW_PACKAGE_DIR_ENV]) env[HUMAIN_FLOW_PACKAGE_DIR_ENV] = flowPackageDir;\n\t\t\tflowModule ??= importFlow().then((module) => {\n\t\t\t\trpcControl = module.createFlowRpcControl?.({\n\t\t\t\t\twriteFrame: (frame) => rpcOutput?.(frame),\n\t\t\t\t\tisDisabled: isFlowDisabled,\n\t\t\t\t\tsendFollowUp: (text) =>\n\t\t\t\t\t\trpcFollowUp ? rpcFollowUp(text) : Promise.reject(new Error(\"host unavailable\")),\n\t\t\t\t});\n\t\t\t\treturn module;\n\t\t\t});\n\t\t\ttry {\n\t\t\t\treturn await flowModule;\n\t\t\t} catch (error) {\n\t\t\t\tflowModule = undefined;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t};\n\n\t\trpcLoader = async () => {\n\t\t\ttry {\n\t\t\t\tawait loadModule();\n\t\t\t} catch {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\treturn rpcControl;\n\t\t};\n\n\t\tconst load = (): Promise<Map<string, CommandOptions>> => {\n\t\t\tif (!loaded) {\n\t\t\t\tconst attempt = (async () => {\n\t\t\t\t\tconst module = await loadModule();\n\t\t\t\t\treturn runFlowExtension(pi, module.flowExtension, () => lastStart);\n\t\t\t\t})();\n\t\t\t\tloaded = attempt;\n\t\t\t\t// A failed load must be retryable on the next invocation.\n\t\t\t\tattempt.catch(() => {\n\t\t\t\t\tif (loaded === attempt) loaded = undefined;\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn loaded;\n\t\t};\n\n\t\tpi.registerCommand(\"flow\", {\n\t\t\tdescription: FLOW_DESCRIPTION,\n\t\t\tgetArgumentCompletions: completeFlowArguments,\n\t\t\thandler: async (args: string, rawCtx: ExtensionCommandContext) => {\n\t\t\t\tconst ctx = withHeadlessNotices(rawCtx);\n\t\t\t\tconst refuse = (message: string, level: \"warning\" | \"error\") => {\n\t\t\t\t\tif (ctx.mode === \"print\" || ctx.mode === \"json\") process.exitCode = 1;\n\t\t\t\t\tctx.ui.notify(message, level);\n\t\t\t\t};\n\t\t\t\tconst parsed = parseFlowCommand(args);\n\t\t\t\tif (\"error\" in parsed) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\trefuse(parsed.error, \"error\");\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tif (parsed.command) await settleRefusal(parsed.command, ctx, \"config_invalid\");\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst { command, payload } = parsed;\n\t\t\t\tif (command === \"help\") {\n\t\t\t\t\tctx.ui.notify(renderFlowHelp(payload.trim() || undefined), \"info\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Secure account dialogs exist only in the terminal UI: refuse elsewhere before loading Flow.\n\t\t\t\tif (command === \"setup\" && ctx.mode !== \"tui\") {\n\t\t\t\t\trefuse(FLOW_SETUP_TERMINAL_ONLY, \"error\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst reason = AVAILABLE_WHEN_DISABLED.has(command) ? undefined : disabledReason(pi, env);\n\t\t\t\tif (reason) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tctx.ui.notify(`Flow disabled (${reason}). /flow ${command} is unavailable.`, \"warning\");\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tawait settleRefusal(command, ctx, \"config_invalid\");\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (command === \"profile\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst module = await loadModule();\n\t\t\t\t\t\tif (!module.runFlowProfileCommand || !module.createProfileStore) {\n\t\t\t\t\t\t\tctx.ui.notify(flowBuildUnavailable(command), \"error\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst store = module.createProfileStore({\n\t\t\t\t\t\t\tflowDir: options.flowDir ?? join(getAgentDir(), \"flow\"),\n\t\t\t\t\t\t\t...(builtInProfilesDir !== undefined ? { builtInDir: builtInProfilesDir } : {}),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tawait module.runFlowProfileCommand(payload, ctx, { store });\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`/flow profile failed: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (LOADED_RUN_COMMANDS.has(command) && !loaded) {\n\t\t\t\t\tctx.ui.notify(NO_LOADED_RUN_COPY[command] ?? \"No active Flow run.\", \"info\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet commands: Map<string, CommandOptions>;\n\t\t\t\ttry {\n\t\t\t\t\tcommands = await load();\n\t\t\t\t} catch (error) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Failed to load Flow: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tawait settleRefusal(command, ctx, \"internal\");\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst real = commands.get(\"flow\");\n\t\t\t\tif (!real) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tctx.ui.notify(flowBuildUnavailable(command), \"error\");\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tawait settleRefusal(command, ctx, \"internal\");\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Flow's own dispatcher re-parses the original arguments and slices the payload itself.\n\t\t\t\tawait real.handler(args, ctx);\n\t\t\t},\n\t\t});\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-mode.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAgBH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAc/E,OAAO,EAGN,wBAAwB,EACxB,MAAM,uCAAuC,CAAC;AAa/C,OAAO,KAAK,EAKX,WAAW,EACX,eAAe,EAEf,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACX,UAAU,EACV,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,EACb,WAAW,EACX,eAAe,GACf,MAAM,gBAAgB,CAAC;AAmIxB;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACpC,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,wBAAwB,GAAG,SAAS,GAC5C,WAAW,CA6Bb;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAAC,KAAK,CAAC,CAo/BjF"}
1
+ {"version":3,"file":"rpc-mode.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAgBH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAc/E,OAAO,EAGN,wBAAwB,EACxB,MAAM,uCAAuC,CAAC;AAa/C,OAAO,KAAK,EAKX,WAAW,EACX,eAAe,EAEf,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACX,UAAU,EACV,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,EACb,WAAW,EACX,eAAe,GACf,MAAM,gBAAgB,CAAC;AA0IxB;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACpC,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,wBAAwB,GAAG,SAAS,GAC5C,WAAW,CA6Bb;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAAC,KAAK,CAAC,CAo/BjF"}
@@ -29,7 +29,14 @@ function isRecord(value) {
29
29
  return typeof value === "object" && value !== null && !Array.isArray(value);
30
30
  }
31
31
  // Mirrors FLOW_COMMAND_TYPES in @humain/humain-code-contracts/rpc (not exported there).
32
- const FLOW_RPC_COMMAND_TYPES = new Set(["flow_status", "flow_pause", "flow_resume", "flow_cancel", "flow_message"]);
32
+ const FLOW_RPC_COMMAND_TYPES = new Set([
33
+ "flow_status",
34
+ "flow_pause",
35
+ "flow_resume",
36
+ "flow_cancel",
37
+ "flow_message",
38
+ "flow_repair",
39
+ ]);
33
40
  // Concurrent flow_* handlers (cancel can wait seconds for confirmation); beyond this, commands are rejected.
34
41
  const MAX_INFLIGHT_FLOW_COMMANDS = 32;
35
42
  const MAX_QUEUED_FLOW_FOLLOW_UPS = 64;