@humain/humain-code 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/dist/bundle/agent-monitor.js +1 -1
- package/dist/bundle/chunks/{anthropic-messages-FGFIMZUF.js → anthropic-messages-MNISFDZA.js} +2 -2
- package/dist/bundle/chunks/{azure-openai-responses-6JNTC7KO.js → azure-openai-responses-IV74M5OR.js} +3 -3
- package/dist/bundle/chunks/bedrock-converse-stream.js +4 -5
- package/dist/bundle/chunks/{chunk-CVC2GV26.js → chunk-2HZ2V3HS.js} +610 -611
- package/dist/bundle/chunks/{chunk-IJYVMOB4.js → chunk-2PZ46FSM.js} +3 -3
- package/dist/bundle/chunks/{chunk-I6AQOITY.js → chunk-3LP543EX.js} +6 -6
- package/dist/bundle/chunks/{chunk-FDGW5ZTG.js → chunk-4J6BGNX2.js} +6 -6
- package/dist/bundle/chunks/{chunk-EDONIPUJ.js → chunk-4SQUP6IR.js} +7 -7
- package/dist/bundle/chunks/{chunk-P4P7OZ7R.js → chunk-5L4JG6PO.js} +1 -1
- package/dist/bundle/chunks/{chunk-GICL5V54.js → chunk-6PD3T2EF.js} +1 -1
- package/dist/bundle/chunks/{chunk-CFHOPLW5.js → chunk-75CQYZ63.js} +56 -54
- package/dist/bundle/chunks/{chunk-DHW3REC5.js → chunk-A2VPLMF2.js} +1 -1
- package/dist/bundle/chunks/{chunk-AOH2O5CP.js → chunk-DCPACGLH.js} +575 -538
- package/dist/bundle/chunks/{chunk-M4CHQBAI.js → chunk-DLCBSLHW.js} +1 -1
- package/dist/bundle/chunks/chunk-F77J5EQZ.js +3 -0
- package/dist/bundle/chunks/{chunk-T3KDZFM4.js → chunk-FHLLDO7U.js} +7 -6
- package/dist/bundle/chunks/{chunk-AHSNQWZU.js → chunk-FLVBQ6GS.js} +1 -1
- package/dist/bundle/chunks/{chunk-ONR6Q3II.js → chunk-JCTQQ3DX.js} +1 -1
- package/dist/bundle/chunks/{chunk-YRUIJ5AH.js → chunk-JEAM6N22.js} +6 -5
- package/dist/bundle/chunks/{chunk-LDGCU6PD.js → chunk-K7SDY3VJ.js} +1 -1
- package/dist/bundle/chunks/{chunk-IADQJFNH.js → chunk-KM4GQ2BU.js} +5 -4
- package/dist/bundle/chunks/{chunk-JFE52VSN.js → chunk-NCC2FAJN.js} +23 -22
- package/dist/bundle/chunks/{chunk-RO5YPAJH.js → chunk-PS2FJ7M4.js} +1 -1
- package/dist/bundle/chunks/{chunk-HW6HMUXS.js → chunk-SFMDIVZ4.js} +1 -1
- package/dist/bundle/chunks/{chunk-B7NJMF7B.js → chunk-WEFEQEIQ.js} +4 -4
- package/dist/bundle/chunks/{chunk-6DE7LJKV.js → chunk-WW4SILXG.js} +24 -19
- package/dist/bundle/chunks/{cli-BNCWK54K.js → cli-N7KOVPLB.js} +1 -1
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-KI6W3USX.js → cloudflare-workers-ai-system-one-KRMHG2L3.js} +1 -1
- package/dist/bundle/chunks/codemode-worker.js +10 -4
- package/dist/bundle/chunks/{compat-I5VPOXFT.js → compat-MXAZPYDN.js} +9 -9
- package/dist/bundle/chunks/{dist-SKBR3C7C.js → dist-3V7ZSLER.js} +29 -26
- package/dist/bundle/chunks/dist-66CW64M2.js +8 -0
- package/dist/bundle/chunks/{easter-egg-3d-673VRP6Y.js → easter-egg-3d-O2GG2XIG.js} +1 -1
- package/dist/bundle/chunks/{execute-PIUR5MUV.js → execute-LMBACTKA.js} +28 -23
- package/dist/bundle/chunks/{extract-4O5Z5725.js → extract-CXXLVFC5.js} +7 -7
- package/dist/bundle/chunks/{google-generative-ai-635YZEHN.js → google-generative-ai-SBL77OXO.js} +4 -4
- package/dist/bundle/chunks/{google-vertex-I3ZJ3SB2.js → google-vertex-NZBNNXMK.js} +6 -6
- package/dist/bundle/chunks/{host-OQOEIWHK.js → host-SCZ4IKWR.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-OKG5GKXR.js → mistral-conversations-DX4YKJSO.js} +14 -13
- package/dist/bundle/chunks/{openai-codex-responses-6JYZIFT4.js → openai-codex-responses-LZWBQYVP.js} +38 -37
- package/dist/bundle/chunks/{openai-completions-YBNI6CAP.js → openai-completions-7NWH423P.js} +2 -2
- package/dist/bundle/chunks/{openai-decisions-5G5YBFRQ.js → openai-decisions-ALJROWBE.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-C3APJ6MK.js → openai-responses-5YOLHMCF.js} +3 -3
- package/dist/bundle/chunks/{pi-messages-UHYZYEOC.js → pi-messages-NHTQQOPW.js} +1 -1
- package/dist/bundle/chunks/{runtime-KE3HDSRT.js → runtime-UVPDE4CX.js} +1 -1
- package/dist/bundle/chunks/{typesafe-system-one-VYVAMWQV.js → typesafe-system-one-BHJYAZ6E.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-YQPK57CW.js +23 -0
- package/dist/bundle/cli-runtime.js +3 -3
- package/dist/bundle/index.js +6 -6
- package/dist/bundle/rpc-entry.js +2 -2
- package/dist/coordination/adapter/commands-integration.d.ts +2 -2
- package/dist/coordination/adapter/commands-integration.d.ts.map +1 -1
- package/dist/coordination/adapter/commands-integration.js +14 -10
- package/dist/coordination/adapter/commands-integration.js.map +1 -1
- package/dist/coordination/adapter/delivery.d.ts +3 -0
- package/dist/coordination/adapter/delivery.d.ts.map +1 -1
- package/dist/coordination/adapter/delivery.js +4 -1
- package/dist/coordination/adapter/delivery.js.map +1 -1
- package/dist/coordination/adapter/index.d.ts.map +1 -1
- package/dist/coordination/adapter/index.js +26 -2
- package/dist/coordination/adapter/index.js.map +1 -1
- package/dist/coordination/adapter/integration-notices.d.ts +2 -2
- package/dist/coordination/adapter/integration-notices.d.ts.map +1 -1
- package/dist/coordination/adapter/integration-notices.js +5 -3
- package/dist/coordination/adapter/integration-notices.js.map +1 -1
- package/dist/coordination/adapter/integration-tool.d.ts +2 -1
- package/dist/coordination/adapter/integration-tool.d.ts.map +1 -1
- package/dist/coordination/adapter/integration-tool.js +11 -10
- package/dist/coordination/adapter/integration-tool.js.map +1 -1
- package/dist/coordination/adapter/peer-label.d.ts +5 -0
- package/dist/coordination/adapter/peer-label.d.ts.map +1 -0
- package/dist/coordination/adapter/peer-label.js +38 -0
- package/dist/coordination/adapter/peer-label.js.map +1 -0
- package/dist/coordination/adapter/render.d.ts +19 -0
- package/dist/coordination/adapter/render.d.ts.map +1 -0
- package/dist/coordination/adapter/render.js +107 -0
- package/dist/coordination/adapter/render.js.map +1 -0
- package/dist/coordination/adapter/tool.d.ts +12 -3
- package/dist/coordination/adapter/tool.d.ts.map +1 -1
- package/dist/coordination/adapter/tool.js +69 -32
- package/dist/coordination/adapter/tool.js.map +1 -1
- package/dist/coordination/broker/broker.d.ts +4 -1
- package/dist/coordination/broker/broker.d.ts.map +1 -1
- package/dist/coordination/broker/broker.js +146 -60
- package/dist/coordination/broker/broker.js.map +1 -1
- package/dist/coordination/client/client.d.ts.map +1 -1
- package/dist/coordination/client/client.js +10 -2
- package/dist/coordination/client/client.js.map +1 -1
- package/dist/coordination/transport/discovery.d.ts +4 -0
- package/dist/coordination/transport/discovery.d.ts.map +1 -1
- package/dist/coordination/transport/discovery.js +14 -0
- package/dist/coordination/transport/discovery.js.map +1 -1
- package/dist/coordination/transport/protocol.d.ts.map +1 -1
- package/dist/coordination/transport/protocol.js +3 -0
- package/dist/coordination/transport/protocol.js.map +1 -1
- package/dist/coordination/transport/types.d.ts +5 -1
- package/dist/coordination/transport/types.d.ts.map +1 -1
- package/dist/coordination/transport/types.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +6 -2
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +13 -36
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/bedrock-account-reporting.d.ts.map +1 -1
- package/dist/core/bedrock-account-reporting.js +2 -1
- package/dist/core/bedrock-account-reporting.js.map +1 -1
- package/dist/core/cache-warmer.d.ts.map +1 -1
- package/dist/core/cache-warmer.js +2 -2
- package/dist/core/cache-warmer.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +3 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +2 -2
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +2 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/model-runtime.d.ts +2 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +7 -7
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +8 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +6 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +27 -6
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +39 -3
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +5 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +45 -16
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +2 -2
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/write.js +2 -2
- package/dist/core/tools/renderers/write.js.map +1 -1
- package/dist/core/tools/subagent.d.ts +22 -0
- package/dist/core/tools/subagent.d.ts.map +1 -1
- package/dist/core/tools/subagent.js +46 -7
- package/dist/core/tools/subagent.js.map +1 -1
- package/dist/core/trace-client/credential-store.d.ts.map +1 -1
- package/dist/core/trace-client/credential-store.js +2 -0
- package/dist/core/trace-client/credential-store.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +3 -12
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +10 -6
- package/dist/humain/gateway/secret-store.d.ts.map +1 -1
- package/dist/humain/gateway/secret-store.js +26 -12
- package/dist/humain/gateway/secret-store.js.map +1 -1
- package/dist/humain/gateway/session-store.d.ts +2 -2
- package/dist/humain/gateway/session-store.d.ts.map +1 -1
- package/dist/humain/gateway/session-store.js +13 -3
- package/dist/humain/gateway/session-store.js.map +1 -1
- package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/extract.js +4 -2
- package/dist/humain/web-access/vendor/extract.js.map +1 -1
- package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/page-query.js +2 -1
- package/dist/humain/web-access/vendor/page-query.js.map +1 -1
- package/dist/humain/web-access/vendor/query-rewrite.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/query-rewrite.js +2 -1
- package/dist/humain/web-access/vendor/query-rewrite.js.map +1 -1
- package/dist/humain/web-access/vendor/storage.d.ts +2 -0
- package/dist/humain/web-access/vendor/storage.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/storage.js +71 -9
- package/dist/humain/web-access/vendor/storage.js.map +1 -1
- package/dist/humain/web-access/vendor/summary-review.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/summary-review.js +2 -1
- package/dist/humain/web-access/vendor/summary-review.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +3 -3
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
- package/dist/modes/interactive/components/mermaid.js +71 -34
- package/dist/modes/interactive/components/mermaid.js.map +1 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +16 -0
- package/dist/utils/child-process.js.map +1 -1
- package/docs/coordination.md +6 -2
- package/docs/development.md +4 -0
- package/docs/extensions.md +2 -0
- package/docs/providers.md +12 -2
- package/examples/extensions/gondolin/index.ts +1 -1
- package/examples/extensions/ssh.ts +34 -5
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/src/coordination/UPSTREAM.md +17 -0
- package/src/humain/web-access/UPSTREAM.md +11 -0
- package/dist/bundle/chunks/chunk-L6Z6JKKC.js +0 -3
- package/dist/bundle/chunks/dist-TVRQXUY6.js +0 -8
- package/dist/bundle/chunks/virtual-modules-KDUZIB3W.js +0 -23
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mermaid.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/mermaid.ts"],"names":[],"mappings":"AAAA,8HAA8H;AAC9H,OAAO,EAAE,MAAM,EAAE,cAAc,EAAc,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAmB,MAAM,EAAa,MAAM,cAAc,CAAC;AAKlE,uEAAuE;AACvE,IAAI,cAAkC,CAAC;AACvC,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;AAO1C,SAAS,SAAS,CAAC,KAAY;IAC9B,OAAO,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,SAAS,CAAC;AACpG,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY;IAC7B,yFAAyF;IACzF,6EAA6E;IAC7E,yCAAyC;IACzC,MAAM,OAAO,GAAG,IAAI,IAAI,QAAQ,C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AAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpF,MAAM,OAAO,GAAG,iCAAiC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC;gBAC5E,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;gBACrF,OAAO,GAAG,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC;YACvD,CAAC;YACD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;YAC1E,+DAA+D;YAC/D,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QAChD,CAAC,CAAC;aACD,IAAI,CAAC,EAAE,CAAC,CAAC;IACZ,CAAC,CAAC;AACH,CAAC","sourcesContent":["// Derived from Pi-Bolt (MIT, Copyright (c) 2026 OpenSec (Pi-Bolt)), commits b93895d2, a6df6a2c; modified for HUMAIN Code CLI.\nimport { Marked, startsWithText, type Token } from \"@earendil-works/pi-tui\";\nimport { type MermaidArt, render, type Span } from \"grok-mermaid\";\nimport type { MarkdownTransformer } from \"../../../core/extensions/types.ts\";\nimport type { MermaidRenderingMode } from \"../../../core/settings-manager.ts\";\nimport type { Theme } from \"../theme/theme.ts\";\n\n// Made for the first text that names Mermaid: most sessions show none.\nlet markdownParser: Marked | undefined;\nconst MERMAID_TAIL = \"mermaid\".length - 1;\n\ninterface MermaidTransformerOptions {\n\tgetMode: () => MermaidRenderingMode;\n\ttheme?: Theme;\n}\n\nfunction isMermaid(token: Token): token is Token & { type: \"code\"; text: string; lang?: string } {\n\treturn token.type === \"code\" && token.lang?.trim().split(/\\s+/, 1)[0]?.toLowerCase() === \"mermaid\";\n}\n\nfunction codeSpan(line: string): string {\n\t// Encode each diagram row as inline code (` ... `) so Markdown preserves its spacing and\n\t// box-drawing characters. Use a non-breaking space for blank rows because an\n\t// empty code span has no visible height.\n\tconst content = line || \"\\u00a0\";\n\t// CommonMark code spans use matching backtick delimiters, so choose one\n\t// longer than any backtick run in the content (``hel`lo`` -> <code>hel`lo</code>).\n\t// If the content starts or ends with a backtick, separating it from the\n\t// delimiter with a space keeps that backtick as content; CommonMark removes\n\t// the padding when rendering (`` `edge` `` -> <code>`edge`</code>).\n\t// Mermaid labels can preserve backticks, for example:\n\t// `┌──────────────┐ ┌──────────────┐`\n\t// ```│ plain ` tick ├───▶│ two `` ticks │```\n\t// `└──────────────┘ └──────────────┘`\n\tconst longestBacktickRun = Math.max(0, ...Array.from(content.matchAll(/`+/g), (match) => match[0].length));\n\tconst fence = \"`\".repeat(longestBacktickRun + 1);\n\tconst padding = content.startsWith(\"`\") || content.endsWith(\"`\") ? \" \" : \"\";\n\treturn `${fence}${padding}${content}${padding}${fence}`;\n}\n\nfunction styleSpan(span: Span, theme: Theme): string {\n\tswitch (span.cls) {\n\t\tcase \"border\":\n\t\t\treturn theme.fg(\"borderMuted\", span.text);\n\t\tcase \"text\":\n\t\t\treturn theme.fg(\"text\", span.text);\n\t\tcase \"edge\":\n\t\t\treturn theme.fg(\"accent\", span.text);\n\t\tcase \"edgeLabel\":\n\t\t\treturn theme.fg(\"muted\", span.text);\n\t\tcase \"title\":\n\t\t\treturn theme.fg(\"accent\", theme.bold(span.text));\n\t\tcase \"none\":\n\t\t\treturn span.text;\n\t}\n}\n\nfunction themedLines(art: MermaidArt, theme: Theme): string[] {\n\treturn art.styled.map((row) => row.map((span) => styleSpan(span, theme)).join(\"\"));\n}\n\n/** Create a transformer that replaces top-level Mermaid code blocks with Unicode terminal diagrams. */\nexport function createMermaidMarkdownTransformer(options: MermaidTransformerOptions): MarkdownTransformer {\n\t// The last text found not to name Mermaid. A message that streams in is that text with text added: only the added text,\n\t// and the last characters before it that a match could start in, are searched.\n\tlet withoutMermaid: { text: string; tail: string } | undefined;\n\tconst namesMermaid = (markdown: string): boolean => {\n\t\tconst known = withoutMermaid;\n\t\tlet found: boolean;\n\t\tlet tail: string;\n\t\tif (known !== undefined && startsWithText(markdown, known.text)) {\n\t\t\t// Keep the boundary separately: slicing across a joined string can copy the entire reply.\n\t\t\tconst searched = known.tail + markdown.slice(known.text.length);\n\t\t\tfound = /mermaid/i.test(searched);\n\t\t\ttail = searched.slice(Math.max(0, searched.length - MERMAID_TAIL));\n\t\t} else {\n\t\t\tfound = /mermaid/i.test(markdown);\n\t\t\ttail = markdown.slice(Math.max(0, markdown.length - MERMAID_TAIL));\n\t\t}\n\t\twithoutMermaid = found ? undefined : { text: markdown, tail };\n\t\treturn found;\n\t};\n\treturn (markdown, context) => {\n\t\tconst mode = options.getMode();\n\t\tif (\n\t\t\tmode === \"off\" ||\n\t\t\tcontext.messageType === \"assistant-thinking\" ||\n\t\t\t(context.isStreaming && mode !== \"streaming\")\n\t\t) {\n\t\t\treturn markdown;\n\t\t}\n\t\t// A Mermaid block names its language: without the word there is none, and no need to lex the text (again for every\n\t\t// chunk of a message that streams in) to find that out.\n\t\tif (!namesMermaid(markdown)) {\n\t\t\treturn markdown;\n\t\t}\n\n\t\tmarkdownParser ??= new Marked();\n\t\treturn markdownParser\n\t\t\t.lexer(markdown)\n\t\t\t.map((token) => {\n\t\t\t\tif (!isMermaid(token)) return token.raw;\n\t\t\t\tconst art = render(token.text);\n\t\t\t\tif (!art || art.width > context.availableWidth) return token.raw;\n\t\t\t\tif (!context.isStreaming && art.warnings.length > 0) {\n\t\t\t\t\tconst suffix = art.warnings.length > 1 ? ` (+${art.warnings.length - 1} more)` : \"\";\n\t\t\t\t\tconst warning = `Mermaid diagram not rendered: ${art.warnings[0]}${suffix}`;\n\t\t\t\t\tconst styledWarning = options.theme ? options.theme.fg(\"warning\", warning) : warning;\n\t\t\t\t\treturn `${token.raw}\\n${codeSpan(styledWarning)} \\n`;\n\t\t\t\t}\n\t\t\t\tconst lines = options.theme ? themedLines(art, options.theme) : art.plain;\n\t\t\t\t// Markdown hard breaks keep every diagram row on its own line.\n\t\t\t\treturn `${lines.map(codeSpan).join(\" \\n\")}\\n`;\n\t\t\t})\n\t\t\t.join(\"\");\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mermaid.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/mermaid.ts"],"names":[],"mappings":"AAAA,8HAA8H;AAC9H,OAAO,EAAE,MAAM,EAAE,cAAc,EAAc,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAmB,MAAM,EAAa,MAAM,cAAc,CAAC;AAKlE,uEAAuE;AACvE,IAAI,cAAkC,CAAC;AAYvC,SAAS,SAAS,CAAC,KAAY;IAC9B,OAAO,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,SAAS,CAAC;AACpG,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY;IAC7B,yFAAyF;IACzF,6EAA6E;IAC7E,yCAAyC;IACzC,MAAM,OAAO,GAAG,IAAI,IAAI,QAAQ,CAAC;IACjC,wEAAwE;IACxE,mFAAmF;IACnF,wEAAwE;IACxE,4EAA4E;IAC5E,oEAAoE;IACpE,sDAAsD;IACtD,2CAA2C;IAC3C,6CAA6C;IAC7C,2CAA2C;IAC3C,MAAM,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,C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Bolt)), commits b93895d2, a6df6a2c; modified for HUMAIN Code CLI.\nimport { Marked, startsWithText, type Token } from \"@earendil-works/pi-tui\";\nimport { type MermaidArt, render, type Span } from \"grok-mermaid\";\nimport type { MarkdownTransformer } from \"../../../core/extensions/types.ts\";\nimport type { MermaidRenderingMode } from \"../../../core/settings-manager.ts\";\nimport type { Theme } from \"../theme/theme.ts\";\n\n// Made for the first text that names Mermaid: most sessions show none.\nlet markdownParser: Marked | undefined;\n\ninterface MermaidPart {\n\traw: string;\n\tart?: MermaidArt | null;\n}\n\ninterface MermaidTransformerOptions {\n\tgetMode: () => MermaidRenderingMode;\n\ttheme?: Theme;\n}\n\nfunction isMermaid(token: Token): token is Token & { type: \"code\"; text: string; lang?: string } {\n\treturn token.type === \"code\" && token.lang?.trim().split(/\\s+/, 1)[0]?.toLowerCase() === \"mermaid\";\n}\n\nfunction codeSpan(line: string): string {\n\t// Encode each diagram row as inline code (` ... `) so Markdown preserves its spacing and\n\t// box-drawing characters. Use a non-breaking space for blank rows because an\n\t// empty code span has no visible height.\n\tconst content = line || \"\\u00a0\";\n\t// CommonMark code spans use matching backtick delimiters, so choose one\n\t// longer than any backtick run in the content (``hel`lo`` -> <code>hel`lo</code>).\n\t// If the content starts or ends with a backtick, separating it from the\n\t// delimiter with a space keeps that backtick as content; CommonMark removes\n\t// the padding when rendering (`` `edge` `` -> <code>`edge`</code>).\n\t// Mermaid labels can preserve backticks, for example:\n\t// `┌──────────────┐ ┌──────────────┐`\n\t// ```│ plain ` tick ├───▶│ two `` ticks │```\n\t// `└──────────────┘ └──────────────┘`\n\tconst longestBacktickRun = Math.max(0, ...Array.from(content.matchAll(/`+/g), (match) => match[0].length));\n\tconst fence = \"`\".repeat(longestBacktickRun + 1);\n\tconst padding = content.startsWith(\"`\") || content.endsWith(\"`\") ? \" \" : \"\";\n\treturn `${fence}${padding}${content}${padding}${fence}`;\n}\n\nfunction styleSpan(span: Span, theme: Theme): string {\n\tswitch (span.cls) {\n\t\tcase \"border\":\n\t\t\treturn theme.fg(\"borderMuted\", span.text);\n\t\tcase \"text\":\n\t\t\treturn theme.fg(\"text\", span.text);\n\t\tcase \"edge\":\n\t\t\treturn theme.fg(\"accent\", span.text);\n\t\tcase \"edgeLabel\":\n\t\t\treturn theme.fg(\"muted\", span.text);\n\t\tcase \"title\":\n\t\t\treturn theme.fg(\"accent\", theme.bold(span.text));\n\t\tcase \"none\":\n\t\t\treturn span.text;\n\t}\n}\n\nfunction themedLines(art: MermaidArt, theme: Theme): string[] {\n\treturn art.styled.map((row) => row.map((span) => styleSpan(span, theme)).join(\"\"));\n}\n\n/** Create a transformer that replaces top-level Mermaid code blocks with Unicode terminal diagrams. */\nexport function createMermaidMarkdownTransformer(options: MermaidTransformerOptions): MarkdownTransformer {\n\tlet scanned = \"\";\n\tlet tail = \"\";\n\tlet pending = false;\n\tlet carriageReturns = false;\n\tlet completed: { length: number; parts: MermaidPart[] } | undefined;\n\treturn (markdown, context) => {\n\t\tconst mode = options.getMode();\n\t\tif (\n\t\t\tmode === \"off\" ||\n\t\t\tcontext.messageType === \"assistant-thinking\" ||\n\t\t\t(context.isStreaming && mode !== \"streaming\")\n\t\t) {\n\t\t\treturn markdown;\n\t\t}\n\t\tif (context.isStreaming) {\n\t\t\tif (!startsWithText(markdown, scanned)) {\n\t\t\t\tscanned = tail = \"\";\n\t\t\t\tpending = carriageReturns = false;\n\t\t\t\tcompleted = undefined;\n\t\t\t}\n\t\t\t// Keep only a possible fence/header boundary, not the growing prose before it.\n\t\t\tconst added = markdown.slice(scanned.length);\n\t\t\tconst searched = tail + added;\n\t\t\t// This is only a candidate filter; Marked still decides fence grammar and top-level ownership.\n\t\t\tif (/(?:`{3}|~{3})[^\\S\\r\\n]*mermaid/i.test(searched)) {\n\t\t\t\tpending = true;\n\t\t\t\tcompleted = undefined;\n\t\t\t}\n\t\t\tconst partial = /(`{1,3}|~{1,3})([^\\S\\r\\n]*)([a-z]*)$/i.exec(searched);\n\t\t\t// Repeated delimiters and whitespace cannot change whether the language can still match.\n\t\t\ttail =\n\t\t\t\tpartial && \"mermaid\".startsWith(partial[3]!.toLowerCase())\n\t\t\t\t\t? partial[1] + (partial[2] ? \" \" : \"\") + partial[3]\n\t\t\t\t\t: \"\";\n\t\t\tcarriageReturns ||= added.includes(\"\\r\");\n\t\t\tscanned = markdown;\n\t\t\tif (!pending && !carriageReturns && !completed) return markdown;\n\t\t} else {\n\t\t\t// Final parsing remains authoritative, including warnings and Markdown normalization.\n\t\t\tscanned = tail = \"\";\n\t\t\tpending = carriageReturns = false;\n\t\t\tcompleted = undefined;\n\t\t}\n\t\t// Marked normalizes CR/CRLF, so those sources cannot reuse raw append offsets.\n\t\tif ((!context.isStreaming || carriageReturns) && !/mermaid/i.test(markdown)) return markdown;\n\n\t\tlet parts = completed?.parts;\n\t\tlet suffix = completed ? markdown.slice(completed.length) : \"\";\n\t\tif (!parts || carriageReturns) {\n\t\t\tmarkdownParser ??= new Marked();\n\t\t\tconst tokens = markdownParser.lexer(markdown);\n\t\t\tparts = tokens.map((token) => ({ raw: token.raw, art: isMermaid(token) ? render(token.text) : undefined }));\n\t\t\tif (context.isStreaming && !carriageReturns) {\n\t\t\t\tlet offset = 0;\n\t\t\t\tlet settled = true;\n\t\t\t\tfor (const token of tokens) {\n\t\t\t\t\toffset += token.raw.length;\n\t\t\t\t\tif (!isMermaid(token)) continue;\n\t\t\t\t\tconst opening = /^ {0,3}(`{3,}|~{3,})/.exec(token.raw)?.[1];\n\t\t\t\t\t// A closing line at EOF can still grow into diagram content on the next append.\n\t\t\t\t\tif (\n\t\t\t\t\t\t!opening ||\n\t\t\t\t\t\t!new RegExp(`\\\\n {0,3}${opening[0]}{${opening.length},} *(?:\\\\n)?$`).test(token.raw) ||\n\t\t\t\t\t\t!(token.raw.endsWith(\"\\n\") || markdown[offset] === \"\\n\")\n\t\t\t\t\t) {\n\t\t\t\t\t\tsettled = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Raw token concatenation is not lossless for every Markdown construct.\n\t\t\t\tif (settled && tokens.some(isMermaid) && tokens.map((token) => token.raw).join(\"\") === markdown) {\n\t\t\t\t\tcompleted = { length: markdown.length, parts };\n\t\t\t\t\tpending = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tsuffix = \"\";\n\t\t}\n\t\treturn (\n\t\t\tparts\n\t\t\t\t.map(({ raw, art }) => {\n\t\t\t\t\tif (!art || art.width > context.availableWidth) return raw;\n\t\t\t\t\tif (!context.isStreaming && art.warnings.length > 0) {\n\t\t\t\t\t\tconst suffix = art.warnings.length > 1 ? ` (+${art.warnings.length - 1} more)` : \"\";\n\t\t\t\t\t\tconst warning = `Mermaid diagram not rendered: ${art.warnings[0]}${suffix}`;\n\t\t\t\t\t\tconst styledWarning = options.theme ? options.theme.fg(\"warning\", warning) : warning;\n\t\t\t\t\t\treturn `${raw}\\n${codeSpan(styledWarning)} \\n`;\n\t\t\t\t\t}\n\t\t\t\t\tconst lines = options.theme ? themedLines(art, options.theme) : art.plain;\n\t\t\t\t\t// Markdown hard breaks keep every diagram row on its own line.\n\t\t\t\t\treturn `${lines.map(codeSpan).join(\" \\n\")}\\n`;\n\t\t\t\t})\n\t\t\t\t.join(\"\") + suffix\n\t\t);\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"child-process.d.ts","sourceRoot":"","sources":["../../src/utils/child-process.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,mBAAmB,EAGxB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,kCAAkC,EACvC,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAS5C,wBAAgB,YAAY,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,0BAA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M,EAAE,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY,CAAC;AAOnG,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,kCAAkC,GACzC,gBAAgB,CAAC,MAAM,CAAC,CAI1B;AAuCD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,SAAS,GAAG,MAAM,CA0BjG;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA6G1G"}
|
|
@@ -112,6 +112,10 @@ export function waitForChildProcess(child, drainSignal) {
|
|
|
112
112
|
child.stderr?.removeListener("end", onStderrEnd);
|
|
113
113
|
child.stdout?.removeListener("data", onData);
|
|
114
114
|
child.stderr?.removeListener("data", onData);
|
|
115
|
+
child.stdout?.removeListener("pause", onFlowChange);
|
|
116
|
+
child.stderr?.removeListener("pause", onFlowChange);
|
|
117
|
+
child.stdout?.removeListener("resume", onFlowChange);
|
|
118
|
+
child.stderr?.removeListener("resume", onFlowChange);
|
|
115
119
|
};
|
|
116
120
|
const finalize = (code) => {
|
|
117
121
|
if (settled)
|
|
@@ -134,8 +138,16 @@ export function waitForChildProcess(child, drainSignal) {
|
|
|
134
138
|
const armIdleTimer = () => {
|
|
135
139
|
if (postExitTimer)
|
|
136
140
|
clearTimeout(postExitTimer);
|
|
141
|
+
postExitTimer = undefined;
|
|
142
|
+
// Sink backpressure is not idle output: keep buffered pipe bytes until reading resumes.
|
|
143
|
+
if ((!stdoutEnded && child.stdout?.isPaused()) || (!stderrEnded && child.stderr?.isPaused()))
|
|
144
|
+
return;
|
|
137
145
|
postExitTimer = setTimeout(() => finalize(exitCode), EXIT_STDIO_GRACE_MS);
|
|
138
146
|
};
|
|
147
|
+
const onFlowChange = () => {
|
|
148
|
+
if (exited && !settled)
|
|
149
|
+
armIdleTimer();
|
|
150
|
+
};
|
|
139
151
|
const onData = () => {
|
|
140
152
|
// Output is still arriving after exit; defer finalizing so we don't
|
|
141
153
|
// destroy the stream mid-write and truncate the tail.
|
|
@@ -172,6 +184,10 @@ export function waitForChildProcess(child, drainSignal) {
|
|
|
172
184
|
child.stderr?.once("end", onStderrEnd);
|
|
173
185
|
child.stdout?.on("data", onData);
|
|
174
186
|
child.stderr?.on("data", onData);
|
|
187
|
+
child.stdout?.on("pause", onFlowChange);
|
|
188
|
+
child.stderr?.on("pause", onFlowChange);
|
|
189
|
+
child.stdout?.on("resume", onFlowChange);
|
|
190
|
+
child.stderr?.on("resume", onFlowChange);
|
|
175
191
|
child.once("error", onError);
|
|
176
192
|
child.once("exit", onExit);
|
|
177
193
|
child.once("close", onClose);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"child-process.js","sourceRoot":"","sources":["../../src/utils/child-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,IAAI,SAAS,EAClB,SAAS,IAAI,aAAa,GAO1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,WAAW,MAAM,qCAAqC,CAAC;AAC9D,OAAO,cAAc,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE1E,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAQhC,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,IAAc,EAAE,OAAqB;IAClF,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,C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MAAM,CAAC,GAAG,CAAC,CAAC;QACb,CAAC,CAAC;QAEF,MAAM,MAAM,GAAG,CAAC,IAAmB,EAAE,EAAE;YACtC,MAAM,GAAG,IAAI,CAAC;YACd,QAAQ,GAAG,IAAI,CAAC;YAChB,sBAAsB,EAAE,CAAC;YACzB,IAAI,CAAC,OAAO,EAAE,CAAC;gBACd,YAAY,EAAE,CAAC;YAChB,CAAC;QACF,CAAC,CAAC;QAEF,MAAM,OAAO,GAAG,CAAC,IAAmB,EAAE,EAAE;YACvC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC;QAEF,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACvC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACvC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7B,WAAW,EAAE,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACrE,IAAI,WAAW,EAAE,OAAO;YAAE,YAAY,EAAE,CAAC;IAC1C,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n\ttype ChildProcess,\n\ttype ChildProcessByStdio,\n\tspawn as nodeSpawn,\n\tspawnSync as nodeSpawnSync,\n\ttype SpawnOptions,\n\ttype SpawnOptionsWithStdioTuple,\n\ttype SpawnSyncOptionsWithStringEncoding,\n\ttype SpawnSyncReturns,\n\ttype StdioNull,\n\ttype StdioPipe,\n} from \"node:child_process\";\nimport { isAbsolute, join, resolve } from \"node:path\";\nimport type { Readable } from \"node:stream\";\nimport { fileURLToPath } from \"node:url\";\nimport crossSpawn from \"cross-spawn\";\nimport readShebang from \"cross-spawn/lib/util/readShebang.js\";\nimport resolveCommand from \"cross-spawn/lib/util/resolveCommand.js\";\nimport { isProgramFile, windowsPathDirectories } from \"./windows-path.ts\";\n\nconst EXIT_STDIO_GRACE_MS = 100;\n\nexport function spawnProcess(\n\tcommand: string,\n\targs: string[],\n\toptions: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,\n): ChildProcessByStdio<null, Readable, Readable>;\nexport function spawnProcess(command: string, args: string[], options: SpawnOptions): ChildProcess;\nexport function spawnProcess(command: string, args: string[], options: SpawnOptions): ChildProcess {\n\tif (process.platform !== \"win32\") return nodeSpawn(command, args, options);\n\tconst invocation = resolveWindowsInvocation(command, args, options);\n\treturn crossSpawn(invocation.command, invocation.args, options);\n}\n\nexport function spawnProcessSync(\n\tcommand: string,\n\targs: string[],\n\toptions: SpawnSyncOptionsWithStringEncoding,\n): SpawnSyncReturns<string> {\n\tif (process.platform !== \"win32\") return nodeSpawnSync(command, args, options);\n\tconst invocation = resolveWindowsInvocation(command, args, options);\n\treturn crossSpawn.sync(invocation.command, invocation.args, options);\n}\n\nfunction resolveWindowsInvocation(\n\tcommand: string,\n\targs: string[],\n\toptions: Pick<SpawnOptions, \"env\" | \"shell\" | \"cwd\">,\n): { command: string; args: string[] } {\n\tlet file = resolveWindowsCommand(command, options.env);\n\tif (options.shell) return { command: file, args };\n\tconst cwd = typeof options.cwd === \"object\" ? fileURLToPath(options.cwd) : options.cwd;\n\tconst visited = new Set<string>();\n\twhile (true) {\n\t\tfile = resolve(cwd ?? \"\", file);\n\t\t// Match cross-spawn's actual file (including explicit PATHEXT paths) before reading its shebang.\n\t\tconst script = resolveCommand({ command: file, options: { env: options.env } }) ?? file;\n\t\tconst key = script.toLowerCase();\n\t\tif (visited.has(key) || visited.size === 32) {\n\t\t\treturn { command: resolveWindowsCommand(\"shebang-chain\", { PATH: \"\" }), args };\n\t\t}\n\t\tvisited.add(key);\n\t\t// cross-spawn otherwise resolves the shebang interpreter cwd-first and passes its bare name to native spawn.\n\t\t// Unwrap the entire bounded chain so its final pass sees only a file without a shebang.\n\t\tconst interpreter = readShebang(script);\n\t\tif (!interpreter) return { command: script, args };\n\t\tfile = resolveWindowsCommand(interpreter, options.env);\n\t\targs = [script, ...args];\n\t}\n}\n\n// Derived from Pi-Bolt (MIT, Copyright (c) 2026 OpenSec (Pi-Bolt)), commits b93895d2, c6f24dd9; modified for HUMAIN Code CLI.\n/**\n * The file a command named without a path is on Windows, from PATH's absolute directories only. cross-spawn finds one with\n * `which`, which looks in the working directory first: a repository could put an npm.cmd or git.exe of its own there, for\n * the package update check to run before any trust decision. Found nowhere, a path that does not exist, so that spawning it\n * fails as a missing command does. (cross-spawn still runs a .cmd through cmd.exe with its arguments escaped.)\n * Exported for tests; spawnProcess and spawnProcessSync call it on Windows only.\n */\nconst resolvedWindowsCommands = new Map<string, string>();\n\nexport function resolveWindowsCommand(command: string, env: NodeJS.ProcessEnv | undefined): string {\n\tif (/[\\\\/]/.test(command)) return command;\n\tconst source = env ?? process.env;\n\t// (An environment merged from two may have both PATH and Path: PATH, as cross-spawn takes it.)\n\tconst pathKey = \"PATH\" in source ? \"PATH\" : Object.keys(source).find((key) => key.toLowerCase() === \"path\");\n\tconst pathValue = pathKey ? (source[pathKey] ?? \"\") : \"\";\n\tconst key = `${pathValue}\\0${source.PATHEXT ?? \"\"}\\0${command}`;\n\tconst cached = resolvedWindowsCommands.get(key);\n\tif (cached && isProgramFile(cached)) return cached;\n\tresolvedWindowsCommands.delete(key);\n\tconst dirs = windowsPathDirectories(pathValue).filter((dir) => isAbsolute(dir));\n\tconst pathExtensions = (source.PATHEXT ?? \".COM;.EXE;.BAT;.CMD\").split(\";\").filter(Boolean);\n\t// (As `which` has it: a name with a dot is also tried as it is.)\n\tconst extensions = command.includes(\".\") ? [\"\", ...pathExtensions] : pathExtensions;\n\tfor (const dir of dirs) {\n\t\tfor (const extension of extensions) {\n\t\t\tconst file = join(dir, command + extension);\n\t\t\tif (isProgramFile(file)) {\n\t\t\t\tresolvedWindowsCommands.set(key, file);\n\t\t\t\treturn file;\n\t\t\t}\n\t\t}\n\t}\n\t// (In a folder that cannot exist: not one of Windows's own programs of that name, were PATH empty.)\n\t// (`||`: an empty SystemRoot would make the path relative to the working directory.)\n\treturn join(process.env.SystemRoot || \"C:\\\\Windows\", \"humain-code-no-such-command\", `${command}.exe`);\n}\n\n/**\n * Wait for a child process to terminate without hanging on inherited stdio handles.\n *\n * A short-lived child can `exit` while a detached descendant keeps its stdout/stderr\n * pipe open. We must not resolve and destroy the streams on a fixed deadline measured\n * from `exit`, or output still being written past that deadline is silently lost\n * (earendil-works/pi#5303). Instead, after `exit` we wait for the pipes to fall idle:\n * the grace timer is re-armed on every chunk, so an actively writing descendant keeps\n * us reading, while a quiet inherited handle (e.g. a Windows daemonized descendant\n * that never lets `close` fire) still releases us after the grace elapses.\n */\nexport function waitForChildProcess(child: ChildProcess, drainSignal?: AbortSignal): Promise<number | null> {\n\treturn new Promise((resolve, reject) => {\n\t\tlet settled = false;\n\t\tlet exited = false;\n\t\tlet exitCode: number | null = null;\n\t\tlet postExitTimer: NodeJS.Timeout | undefined;\n\t\tlet stdoutEnded = child.stdout === null;\n\t\tlet stderrEnded = child.stderr === null;\n\n\t\tconst cleanup = () => {\n\t\t\tdrainSignal?.removeEventListener(\"abort\", onDrainAbort);\n\t\t\tif (postExitTimer) {\n\t\t\t\tclearTimeout(postExitTimer);\n\t\t\t\tpostExitTimer = undefined;\n\t\t\t}\n\t\t\tchild.removeListener(\"error\", onError);\n\t\t\tchild.removeListener(\"exit\", onExit);\n\t\t\tchild.removeListener(\"close\", onClose);\n\t\t\tchild.stdout?.removeListener(\"end\", onStdoutEnd);\n\t\t\tchild.stderr?.removeListener(\"end\", onStderrEnd);\n\t\t\tchild.stdout?.removeListener(\"data\", onData);\n\t\t\tchild.stderr?.removeListener(\"data\", onData);\n\t\t};\n\n\t\tconst finalize = (code: number | null) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tcleanup();\n\t\t\tchild.stdout?.destroy();\n\t\t\tchild.stderr?.destroy();\n\t\t\tresolve(code);\n\t\t};\n\n\t\t// Cancellation bounds draining even if termination failed or an escaped descendant keeps writing.\n\t\tconst onDrainAbort = () => finalize(child.exitCode);\n\n\t\tconst maybeFinalizeAfterExit = () => {\n\t\t\tif (!exited || settled) return;\n\t\t\tif (stdoutEnded && stderrEnded) {\n\t\t\t\tfinalize(exitCode);\n\t\t\t}\n\t\t};\n\n\t\tconst armIdleTimer = () => {\n\t\t\tif (postExitTimer) clearTimeout(postExitTimer);\n\t\t\tpostExitTimer = setTimeout(() => finalize(exitCode), EXIT_STDIO_GRACE_MS);\n\t\t};\n\n\t\tconst onData = () => {\n\t\t\t// Output is still arriving after exit; defer finalizing so we don't\n\t\t\t// destroy the stream mid-write and truncate the tail.\n\t\t\tif (exited && !settled) armIdleTimer();\n\t\t};\n\n\t\tconst onStdoutEnd = () => {\n\t\t\tstdoutEnded = true;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t};\n\n\t\tconst onStderrEnd = () => {\n\t\t\tstderrEnded = true;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t};\n\n\t\tconst onError = (err: Error) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tcleanup();\n\t\t\treject(err);\n\t\t};\n\n\t\tconst onExit = (code: number | null) => {\n\t\t\texited = true;\n\t\t\texitCode = code;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t\tif (!settled) {\n\t\t\t\tarmIdleTimer();\n\t\t\t}\n\t\t};\n\n\t\tconst onClose = (code: number | null) => {\n\t\t\tfinalize(code);\n\t\t};\n\n\t\tchild.stdout?.once(\"end\", onStdoutEnd);\n\t\tchild.stderr?.once(\"end\", onStderrEnd);\n\t\tchild.stdout?.on(\"data\", onData);\n\t\tchild.stderr?.on(\"data\", onData);\n\t\tchild.once(\"error\", onError);\n\t\tchild.once(\"exit\", onExit);\n\t\tchild.once(\"close\", onClose);\n\t\tdrainSignal?.addEventListener(\"abort\", onDrainAbort, { once: true });\n\t\tif (drainSignal?.aborted) onDrainAbort();\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"child-process.js","sourceRoot":"","sources":["../../src/utils/child-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,IAAI,SAAS,EAClB,SAAS,IAAI,aAAa,GAO1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,WAAW,MAAM,qCAAqC,CAAC;AAC9D,OAAO,cAAc,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE1E,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAQhC,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,IAAc,EAAE,OAAqB;IAClF,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3E,MAAM,UAAU,GAAG,wBAAwB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACpE,OAAO,UAAU,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC/B,OAAe,EACf,IAAc,EACd,OAA2C;IAE3C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;QAAE,OA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E,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QACzC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7B,WAAW,EAAE,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACrE,IAAI,WAAW,EAAE,OAAO;YAAE,YAAY,EAAE,CAAC;IAC1C,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n\ttype ChildProcess,\n\ttype ChildProcessByStdio,\n\tspawn as nodeSpawn,\n\tspawnSync as nodeSpawnSync,\n\ttype SpawnOptions,\n\ttype SpawnOptionsWithStdioTuple,\n\ttype SpawnSyncOptionsWithStringEncoding,\n\ttype SpawnSyncReturns,\n\ttype StdioNull,\n\ttype StdioPipe,\n} from \"node:child_process\";\nimport { isAbsolute, join, resolve } from \"node:path\";\nimport type { Readable } from \"node:stream\";\nimport { fileURLToPath } from \"node:url\";\nimport crossSpawn from \"cross-spawn\";\nimport readShebang from \"cross-spawn/lib/util/readShebang.js\";\nimport resolveCommand from \"cross-spawn/lib/util/resolveCommand.js\";\nimport { isProgramFile, windowsPathDirectories } from \"./windows-path.ts\";\n\nconst EXIT_STDIO_GRACE_MS = 100;\n\nexport function spawnProcess(\n\tcommand: string,\n\targs: string[],\n\toptions: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,\n): ChildProcessByStdio<null, Readable, Readable>;\nexport function spawnProcess(command: string, args: string[], options: SpawnOptions): ChildProcess;\nexport function spawnProcess(command: string, args: string[], options: SpawnOptions): ChildProcess {\n\tif (process.platform !== \"win32\") return nodeSpawn(command, args, options);\n\tconst invocation = resolveWindowsInvocation(command, args, options);\n\treturn crossSpawn(invocation.command, invocation.args, options);\n}\n\nexport function spawnProcessSync(\n\tcommand: string,\n\targs: string[],\n\toptions: SpawnSyncOptionsWithStringEncoding,\n): SpawnSyncReturns<string> {\n\tif (process.platform !== \"win32\") return nodeSpawnSync(command, args, options);\n\tconst invocation = resolveWindowsInvocation(command, args, options);\n\treturn crossSpawn.sync(invocation.command, invocation.args, options);\n}\n\nfunction resolveWindowsInvocation(\n\tcommand: string,\n\targs: string[],\n\toptions: Pick<SpawnOptions, \"env\" | \"shell\" | \"cwd\">,\n): { command: string; args: string[] } {\n\tlet file = resolveWindowsCommand(command, options.env);\n\tif (options.shell) return { command: file, args };\n\tconst cwd = typeof options.cwd === \"object\" ? fileURLToPath(options.cwd) : options.cwd;\n\tconst visited = new Set<string>();\n\twhile (true) {\n\t\tfile = resolve(cwd ?? \"\", file);\n\t\t// Match cross-spawn's actual file (including explicit PATHEXT paths) before reading its shebang.\n\t\tconst script = resolveCommand({ command: file, options: { env: options.env } }) ?? file;\n\t\tconst key = script.toLowerCase();\n\t\tif (visited.has(key) || visited.size === 32) {\n\t\t\treturn { command: resolveWindowsCommand(\"shebang-chain\", { PATH: \"\" }), args };\n\t\t}\n\t\tvisited.add(key);\n\t\t// cross-spawn otherwise resolves the shebang interpreter cwd-first and passes its bare name to native spawn.\n\t\t// Unwrap the entire bounded chain so its final pass sees only a file without a shebang.\n\t\tconst interpreter = readShebang(script);\n\t\tif (!interpreter) return { command: script, args };\n\t\tfile = resolveWindowsCommand(interpreter, options.env);\n\t\targs = [script, ...args];\n\t}\n}\n\n// Derived from Pi-Bolt (MIT, Copyright (c) 2026 OpenSec (Pi-Bolt)), commits b93895d2, c6f24dd9; modified for HUMAIN Code CLI.\n/**\n * The file a command named without a path is on Windows, from PATH's absolute directories only. cross-spawn finds one with\n * `which`, which looks in the working directory first: a repository could put an npm.cmd or git.exe of its own there, for\n * the package update check to run before any trust decision. Found nowhere, a path that does not exist, so that spawning it\n * fails as a missing command does. (cross-spawn still runs a .cmd through cmd.exe with its arguments escaped.)\n * Exported for tests; spawnProcess and spawnProcessSync call it on Windows only.\n */\nconst resolvedWindowsCommands = new Map<string, string>();\n\nexport function resolveWindowsCommand(command: string, env: NodeJS.ProcessEnv | undefined): string {\n\tif (/[\\\\/]/.test(command)) return command;\n\tconst source = env ?? process.env;\n\t// (An environment merged from two may have both PATH and Path: PATH, as cross-spawn takes it.)\n\tconst pathKey = \"PATH\" in source ? \"PATH\" : Object.keys(source).find((key) => key.toLowerCase() === \"path\");\n\tconst pathValue = pathKey ? (source[pathKey] ?? \"\") : \"\";\n\tconst key = `${pathValue}\\0${source.PATHEXT ?? \"\"}\\0${command}`;\n\tconst cached = resolvedWindowsCommands.get(key);\n\tif (cached && isProgramFile(cached)) return cached;\n\tresolvedWindowsCommands.delete(key);\n\tconst dirs = windowsPathDirectories(pathValue).filter((dir) => isAbsolute(dir));\n\tconst pathExtensions = (source.PATHEXT ?? \".COM;.EXE;.BAT;.CMD\").split(\";\").filter(Boolean);\n\t// (As `which` has it: a name with a dot is also tried as it is.)\n\tconst extensions = command.includes(\".\") ? [\"\", ...pathExtensions] : pathExtensions;\n\tfor (const dir of dirs) {\n\t\tfor (const extension of extensions) {\n\t\t\tconst file = join(dir, command + extension);\n\t\t\tif (isProgramFile(file)) {\n\t\t\t\tresolvedWindowsCommands.set(key, file);\n\t\t\t\treturn file;\n\t\t\t}\n\t\t}\n\t}\n\t// (In a folder that cannot exist: not one of Windows's own programs of that name, were PATH empty.)\n\t// (`||`: an empty SystemRoot would make the path relative to the working directory.)\n\treturn join(process.env.SystemRoot || \"C:\\\\Windows\", \"humain-code-no-such-command\", `${command}.exe`);\n}\n\n/**\n * Wait for a child process to terminate without hanging on inherited stdio handles.\n *\n * A short-lived child can `exit` while a detached descendant keeps its stdout/stderr\n * pipe open. We must not resolve and destroy the streams on a fixed deadline measured\n * from `exit`, or output still being written past that deadline is silently lost\n * (earendil-works/pi#5303). Instead, after `exit` we wait for the pipes to fall idle:\n * the grace timer is re-armed on every chunk, so an actively writing descendant keeps\n * us reading, while a quiet inherited handle (e.g. a Windows daemonized descendant\n * that never lets `close` fire) still releases us after the grace elapses.\n */\nexport function waitForChildProcess(child: ChildProcess, drainSignal?: AbortSignal): Promise<number | null> {\n\treturn new Promise((resolve, reject) => {\n\t\tlet settled = false;\n\t\tlet exited = false;\n\t\tlet exitCode: number | null = null;\n\t\tlet postExitTimer: NodeJS.Timeout | undefined;\n\t\tlet stdoutEnded = child.stdout === null;\n\t\tlet stderrEnded = child.stderr === null;\n\n\t\tconst cleanup = () => {\n\t\t\tdrainSignal?.removeEventListener(\"abort\", onDrainAbort);\n\t\t\tif (postExitTimer) {\n\t\t\t\tclearTimeout(postExitTimer);\n\t\t\t\tpostExitTimer = undefined;\n\t\t\t}\n\t\t\tchild.removeListener(\"error\", onError);\n\t\t\tchild.removeListener(\"exit\", onExit);\n\t\t\tchild.removeListener(\"close\", onClose);\n\t\t\tchild.stdout?.removeListener(\"end\", onStdoutEnd);\n\t\t\tchild.stderr?.removeListener(\"end\", onStderrEnd);\n\t\t\tchild.stdout?.removeListener(\"data\", onData);\n\t\t\tchild.stderr?.removeListener(\"data\", onData);\n\t\t\tchild.stdout?.removeListener(\"pause\", onFlowChange);\n\t\t\tchild.stderr?.removeListener(\"pause\", onFlowChange);\n\t\t\tchild.stdout?.removeListener(\"resume\", onFlowChange);\n\t\t\tchild.stderr?.removeListener(\"resume\", onFlowChange);\n\t\t};\n\n\t\tconst finalize = (code: number | null) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tcleanup();\n\t\t\tchild.stdout?.destroy();\n\t\t\tchild.stderr?.destroy();\n\t\t\tresolve(code);\n\t\t};\n\n\t\t// Cancellation bounds draining even if termination failed or an escaped descendant keeps writing.\n\t\tconst onDrainAbort = () => finalize(child.exitCode);\n\n\t\tconst maybeFinalizeAfterExit = () => {\n\t\t\tif (!exited || settled) return;\n\t\t\tif (stdoutEnded && stderrEnded) {\n\t\t\t\tfinalize(exitCode);\n\t\t\t}\n\t\t};\n\n\t\tconst armIdleTimer = () => {\n\t\t\tif (postExitTimer) clearTimeout(postExitTimer);\n\t\t\tpostExitTimer = undefined;\n\t\t\t// Sink backpressure is not idle output: keep buffered pipe bytes until reading resumes.\n\t\t\tif ((!stdoutEnded && child.stdout?.isPaused()) || (!stderrEnded && child.stderr?.isPaused())) return;\n\t\t\tpostExitTimer = setTimeout(() => finalize(exitCode), EXIT_STDIO_GRACE_MS);\n\t\t};\n\n\t\tconst onFlowChange = () => {\n\t\t\tif (exited && !settled) armIdleTimer();\n\t\t};\n\n\t\tconst onData = () => {\n\t\t\t// Output is still arriving after exit; defer finalizing so we don't\n\t\t\t// destroy the stream mid-write and truncate the tail.\n\t\t\tif (exited && !settled) armIdleTimer();\n\t\t};\n\n\t\tconst onStdoutEnd = () => {\n\t\t\tstdoutEnded = true;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t};\n\n\t\tconst onStderrEnd = () => {\n\t\t\tstderrEnded = true;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t};\n\n\t\tconst onError = (err: Error) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tcleanup();\n\t\t\treject(err);\n\t\t};\n\n\t\tconst onExit = (code: number | null) => {\n\t\t\texited = true;\n\t\t\texitCode = code;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t\tif (!settled) {\n\t\t\t\tarmIdleTimer();\n\t\t\t}\n\t\t};\n\n\t\tconst onClose = (code: number | null) => {\n\t\t\tfinalize(code);\n\t\t};\n\n\t\tchild.stdout?.once(\"end\", onStdoutEnd);\n\t\tchild.stderr?.once(\"end\", onStderrEnd);\n\t\tchild.stdout?.on(\"data\", onData);\n\t\tchild.stderr?.on(\"data\", onData);\n\t\tchild.stdout?.on(\"pause\", onFlowChange);\n\t\tchild.stderr?.on(\"pause\", onFlowChange);\n\t\tchild.stdout?.on(\"resume\", onFlowChange);\n\t\tchild.stderr?.on(\"resume\", onFlowChange);\n\t\tchild.once(\"error\", onError);\n\t\tchild.once(\"exit\", onExit);\n\t\tchild.once(\"close\", onClose);\n\t\tdrainSignal?.addEventListener(\"abort\", onDrainAbort, { once: true });\n\t\tif (drainSignal?.aborted) onDrainAbort();\n\t});\n}\n"]}
|
package/docs/coordination.md
CHANGED
|
@@ -10,12 +10,14 @@ Turn it off with `--no-coordinate`, the `coordination.enabled` setting, or `--no
|
|
|
10
10
|
|
|
11
11
|
## Messages
|
|
12
12
|
|
|
13
|
-
The agent uses the `coordination` tool with `peers`, `send`, or `broadcast` for messages. Its record, artifact and handoff actions are described in [Shared records](#shared-records), [Artifacts](#artifacts) and [Handoffs and integration](#handoffs-and-integration). Incoming messages appear
|
|
13
|
+
The agent uses the `coordination` tool with `peers`, `send`, or `broadcast` for messages. Its record, artifact and handoff actions are described in [Shared records](#shared-records), [Artifacts](#artifacts) and [Handoffs and integration](#handoffs-and-integration). Incoming messages appear as advisory cards with `repo · branch — focus (handle)`. The session name replaces a missing focus; missing location parts are omitted. Handles are the shortest unique suffix of a session ID among live sessions, at least four characters, with hyphens removed. They grow when suffixes collide. Metadata is sanitized, bounded and displayed as literal text, never markup or commands.
|
|
14
|
+
|
|
15
|
+
Cards are on by default, with no extra setting. Incoming cards start with `⇠ peer`; outgoing sends start with `⇢ to` and show `✓ delivered`, `⏳ queued`, or `✗ failed: <reason>`. Uncertain delivery stays explicitly uncertain: it is not confirmation or permission to send a new message. The existing expand-tool-output keybinding (`ctrl+o` by default) reveals the full sender or recipient ID and message ID. Inbound expansion also shows the worktree path and the full safety sentence. The model still receives the original full peer header, disclaimer and message body, and unchanged send-result text.
|
|
14
16
|
|
|
15
17
|
### Discover, then message
|
|
16
18
|
|
|
17
19
|
1. Run `coordination action:"peers"` with optional `repo`, `query` and `path` filters. Results are grouped by repository, your repository first. Filters combine with AND: `repo` is a case-insensitive label substring, `query` matches repository, branch, name or focus, and `path` is a prefix of the session's repository-relative working directory or written paths. Each result includes focus and at most five matching written paths per session. Brackets in displayed paths are percent-escaped (`[` as `%5B`, `]` as `%5D`; existing `%` becomes `%25`). Oversized lists are truncated; narrow the filters.
|
|
18
|
-
2. Send to the chosen session with `action:"send" to:"<session id>" text:"..."`. Exact targets resolve first, live sessions before offline ones: a session ID, `to:"<repo>/<name>"` (an exact, case-sensitive repository label and name; both must be defined), or a bare name, which matches case-insensitively in your repository first, then across the device. Only when no exact target matches does a unique ID prefix or the name prefix of a connected session resolve, in your repository first and never to the sender. Multiple matches return `E_AMBIGUOUS_TARGET` with at most five candidates formatted as `<repo>/<name> (<id>)`, followed by `... and N more` when needed. Repository labels and names are self-reported by sessions; the broker does not verify them. Continue the thread with `replyTo:"<message id>"` and send to the original sender's ID.
|
|
20
|
+
2. Send to the chosen session with `action:"send" to:"<session id>" text:"..."`. Exact targets resolve first, live sessions before offline ones: a session ID, `to:"<repo>/<name>"` (an exact, case-sensitive repository label and name; both must be defined), or a bare name, which matches case-insensitively in your repository first, then across the device. After exact IDs and names, a unique live suffix handle resolves device-wide (for example `to:"8b2c"`). Ambiguous handles are refused with full candidate IDs; they never fall through to a prefix guess. Disconnected sessions still need an exact ID or name, or an existing ID prefix. Only when no exact target or live handle matches does a unique ID prefix or the name prefix of a connected session resolve, in your repository first and never to the sender. Multiple matches return `E_AMBIGUOUS_TARGET` with at most five candidates formatted as `<repo>/<name> (<id>)`, followed by `... and N more` when needed. Repository labels and names are self-reported by sessions; the broker does not verify them. Continue the thread with `replyTo:"<message id>"` and send to the original sender's ID.
|
|
19
21
|
3. Only if lookup finds nothing, ask with `action:"broadcast" scope:"device"`. Responders should answer with directed `send`. Broadcast without `scope` defaults to `"repo"`; unrelated repositories receive nothing.
|
|
20
22
|
4. Update `action:"presence_set" focus:"..."` when your task changes materially. An empty focus clears the override.
|
|
21
23
|
|
|
@@ -141,6 +143,8 @@ Without an integration owner, handoffs stay queued and the tool tells the agent
|
|
|
141
143
|
|
|
142
144
|
You assign one owner per repository from the interactive TUI. The `owner`, `writer` and `reconcile` subcommands work only there: print, JSON and RPC modes refuse them and change nothing. Only the read-only `/coordinate owner` status works in every mode.
|
|
143
145
|
|
|
146
|
+
Owner status and integration notices use the same readable labels, for example `Integration owner: forge · main — Release train (8b2c)`. Labels grant no authority. Owner and writer assignments remain human-only, and the target-branch guard and Git approval rules are unchanged.
|
|
147
|
+
|
|
144
148
|
Assignments:
|
|
145
149
|
|
|
146
150
|
| Command | What it does |
|
package/docs/development.md
CHANGED
|
@@ -74,6 +74,10 @@ npm test # Run all tests
|
|
|
74
74
|
npm test -- test/specific.test.ts # Run specific test
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
+
### Efficiency budgets
|
|
78
|
+
|
|
79
|
+
Before releases and for performance changes, run `npm run build` followed by `npm run bench:budgets` from the repository root on an idle machine. The offline workloads measure built Node startup, optional compiled Bun startup, session loading/rendering, streaming Markdown, shell spill output and fullscreen search, with one warm-up and seven measured runs. Any median more than 15% above `bench/budgets/<platform>-<arch>.json` fails; a missing baseline is informational. Review the ranges before establishing or deliberately replacing it with `npm run bench:budgets -- --write-baseline`; this check is not part of `npm run check` or CI.
|
|
80
|
+
|
|
77
81
|
### Published package smoke test
|
|
78
82
|
|
|
79
83
|
After building, run `npm run check:package-install`. It packs the public packages and installs only coding-agent as a direct dependency in a temporary directory outside the repository. Local tarball overrides select declared transitive dependencies without installing development-only packages. The check verifies SDK imports and CLI startup without credentials or model requests.
|
package/docs/extensions.md
CHANGED
|
@@ -2406,6 +2406,8 @@ The `create*ToolDefinition()` factories, such as `createReadToolDefinition()`, r
|
|
|
2406
2406
|
|
|
2407
2407
|
**Operations interfaces:** `ReadOperations`, `WriteOperations`, `EditOperations`, `BashOperations`, `PowerShellOperations`, `LsOperations`, `GrepOperations`, `FindOperations`
|
|
2408
2408
|
|
|
2409
|
+
The `onData` callback in `BashOperations.exec` and `PowerShellOperations.exec` may return a promise to signal backpressure; custom backends must await it or pause both stdout and stderr until it settles, and propagate rejections.
|
|
2410
|
+
|
|
2409
2411
|
For `user_bash`, extensions can reuse HUMAIN Code CLI's local shell backend via `createLocalBashOperations()` (or `createLocalPowerShellOperations()`) instead of reimplementing local process spawning, shell resolution, and process-tree termination.
|
|
2410
2412
|
|
|
2411
2413
|
The `bash` and `powershell` tools also support a spawn hook to adjust the command, cwd, or env before execution:
|
package/docs/providers.md
CHANGED
|
@@ -283,7 +283,16 @@ Both Gateway hosts are reachable only from the HUMAIN corporate network.
|
|
|
283
283
|
|
|
284
284
|
Over SSH or on a machine whose browser cannot reach the terminal, open the **HUMAIN Gateway sign-in (paste code)** link shown in the terminal on any machine, sign in, and paste the one-time `hc_...` code into the masked prompt. The code expires after 2 minutes and works once.
|
|
285
285
|
|
|
286
|
-
The Gateway issues a personal session key, which HUMAIN Code CLI stores in the OS keychain: macOS Keychain, Linux Secret Service
|
|
286
|
+
The Gateway issues a personal session key, which HUMAIN Code CLI stores in the OS keychain: macOS Keychain, Linux Secret Service, or Windows Credential Manager. WSL uses Windows Credential Manager through Windows PowerShell, not a Linux desktop keyring. `auth.json` keeps only the environment, a session ID, and your email. Before opening the browser, sign-in writes, reads back, and deletes a temporary non-session value to verify the store. It never falls back to a plaintext file or another credential backend.
|
|
287
|
+
|
|
288
|
+
#### Linux and WSL prerequisites
|
|
289
|
+
|
|
290
|
+
- **Linux:** Install libsecret's `secret-tool` (`sudo apt install libsecret-tools` on Debian/Ubuntu). Run HUMAIN Code CLI in a D-Bus session with a running, unlocked Secret Service keyring, such as GNOME Keyring or a compatible provider. Installing `secret-tool` alone is not enough. SSH and headless sessions must configure their own D-Bus session and keyring; do not invent a `DBUS_SESSION_BUS_ADDRESS` value.
|
|
291
|
+
- **WSL:** Enable Windows interoperability and make Windows `powershell.exe` available on WSL's `PATH`. Check from WSL with `powershell.exe -NoProfile -NonInteractive -Command '$PSVersionTable.PSVersion.ToString()'`. If it fails, check the `[interop]` settings `enabled` and `appendWindowsPath` in `/etc/wsl.conf`; both normally default to `true`. Apply WSL configuration changes with `wsl.exe --shutdown` from Windows after saving work in all WSL sessions. Linux-native PowerShell (`pwsh`) is not a substitute for Windows Credential Manager.
|
|
292
|
+
|
|
293
|
+
The WSL backend stays Windows Credential Manager even when a Linux keyring is installed or Windows interoperability stops working. If an older version stored your WSL Gateway login in a Linux keyring, sign out and let that version complete pending revocation before upgrading, then sign in again. Existing Linux-keyring credentials are not migrated automatically.
|
|
294
|
+
|
|
295
|
+
To smoke-test WSL persistence, sign in, exit HUMAIN Code CLI, save work, and run `wsl.exe --shutdown` from Windows. Reopen the same distro and confirm an authenticated Gateway request succeeds without another sign-in. Then use `/logout`, restart HUMAIN Code CLI to complete revocation, and confirm the session no longer authenticates. Model listing alone does not verify credential access.
|
|
287
296
|
|
|
288
297
|
### 3. Choose a model
|
|
289
298
|
|
|
@@ -314,7 +323,8 @@ CI and unattended runs are not supported: every session needs an interactive Mic
|
|
|
314
323
|
| `Could not reach HUMAIN Gateway to finish sign-in.` / browser shows `ERR_CONNECTION_CLOSED` | Connect to the HUMAIN corporate network. Staging may require separate access from the Gateway team. |
|
|
315
324
|
| `HUMAIN Gateway sign-in code is invalid or expired.` | Run `/login` again; codes last 2 minutes and work once. |
|
|
316
325
|
| `HUMAIN Gateway requires a newer HUMAIN Code CLI.` | Update HUMAIN Code CLI, then sign in again. |
|
|
317
|
-
| Keychain or Secret Service error | Unlock the keychain,
|
|
326
|
+
| Keychain or Secret Service error | Unlock the keychain. On Linux, check `secret-tool`, the current D-Bus session, and the running Secret Service keyring. |
|
|
327
|
+
| WSL Windows Credential Manager error | Check that Windows `powershell.exe` runs from WSL and Windows interoperability is enabled. Sign in as the Windows user whose credential store holds the session. |
|
|
318
328
|
| `HUMAIN Gateway CLI session unavailable. Sign in again.` | Your access was revoked or rotated; run `/login` again. |
|
|
319
329
|
|
|
320
330
|
## HUMAIN Node
|
|
@@ -347,7 +347,7 @@ function createGondolinBashOps(vm: VM, localCwd: string, shellPath: string): Bas
|
|
|
347
347
|
stdout: "pipe",
|
|
348
348
|
stderr: "pipe",
|
|
349
349
|
});
|
|
350
|
-
for await (const chunk of proc.output()) onData(chunk.data);
|
|
350
|
+
for await (const chunk of proc.output()) await onData(chunk.data);
|
|
351
351
|
const result = await proc;
|
|
352
352
|
return { exitCode: result.exitCode };
|
|
353
353
|
} catch (error) {
|
|
@@ -86,26 +86,55 @@ function createRemoteBashOps(remote: string, remoteCwd: string, localCwd: string
|
|
|
86
86
|
const cmd = `cd ${JSON.stringify(toRemote(cwd))} && ${command}`;
|
|
87
87
|
const child = spawn("ssh", [remote, cmd], { stdio: ["ignore", "pipe", "pipe"] });
|
|
88
88
|
let timedOut = false;
|
|
89
|
+
let pendingOutput: Promise<void> | undefined;
|
|
90
|
+
const onAbort = () => {
|
|
91
|
+
child.stdout.off("data", handleData);
|
|
92
|
+
child.stderr.off("data", handleData);
|
|
93
|
+
child.stdout.resume();
|
|
94
|
+
child.stderr.resume();
|
|
95
|
+
child.kill();
|
|
96
|
+
};
|
|
97
|
+
const failOutput = (error: unknown) => {
|
|
98
|
+
if (timer) clearTimeout(timer);
|
|
99
|
+
signal?.removeEventListener("abort", onAbort);
|
|
100
|
+
onAbort();
|
|
101
|
+
reject(error);
|
|
102
|
+
};
|
|
103
|
+
const handleData = (data: Buffer) => {
|
|
104
|
+
try {
|
|
105
|
+
const pending = onData(data);
|
|
106
|
+
if (pending instanceof Promise) {
|
|
107
|
+
// Both pipes share one sink, so neither may enqueue more until it drains.
|
|
108
|
+
child.stdout.pause();
|
|
109
|
+
child.stderr.pause();
|
|
110
|
+
pendingOutput = pending.then(() => {
|
|
111
|
+
child.stdout.resume();
|
|
112
|
+
child.stderr.resume();
|
|
113
|
+
}, failOutput);
|
|
114
|
+
}
|
|
115
|
+
} catch (error) {
|
|
116
|
+
failOutput(error);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
89
119
|
const timer = timeout
|
|
90
120
|
? setTimeout(() => {
|
|
91
121
|
timedOut = true;
|
|
92
|
-
|
|
122
|
+
onAbort();
|
|
93
123
|
}, timeout * 1000)
|
|
94
124
|
: undefined;
|
|
95
|
-
child.stdout.on("data",
|
|
96
|
-
child.stderr.on("data",
|
|
125
|
+
child.stdout.on("data", handleData);
|
|
126
|
+
child.stderr.on("data", handleData);
|
|
97
127
|
child.on("error", (e) => {
|
|
98
128
|
if (timer) clearTimeout(timer);
|
|
99
129
|
reject(e);
|
|
100
130
|
});
|
|
101
|
-
const onAbort = () => child.kill();
|
|
102
131
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
103
132
|
child.on("close", (code) => {
|
|
104
133
|
if (timer) clearTimeout(timer);
|
|
105
134
|
signal?.removeEventListener("abort", onAbort);
|
|
106
135
|
if (signal?.aborted) reject(new Error("aborted"));
|
|
107
136
|
else if (timedOut) reject(new Error(`timeout:${timeout}`));
|
|
108
|
-
else resolve({ exitCode: code });
|
|
137
|
+
else Promise.resolve(pendingOutput).then(() => resolve({ exitCode: code }), reject);
|
|
109
138
|
});
|
|
110
139
|
}),
|
|
111
140
|
};
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@humain/humain-code",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@humain/humain-code",
|
|
9
|
-
"version": "0.6.
|
|
9
|
+
"version": "0.6.2",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@humain/humain-code-contracts": "0.4.20",
|
package/package.json
CHANGED
|
@@ -29,6 +29,11 @@ Focused regression coverage lives in `test/coordination/upstream-refresh.test.ts
|
|
|
29
29
|
- Removed: Windows TCP transport, Herdr/tmux location, cross-machine relay, handover, `tsx` launch, Pi extension UI.
|
|
30
30
|
- Broker is a side-effect-free class launched through HUMAIN's own executable.
|
|
31
31
|
- Durable mailbox snapshot; `not_injected` receipt; worktree root and branch in presence.
|
|
32
|
+
- Consecutive receipts within an inbound socket read commit mailbox retirements and delivery-proof updates in one
|
|
33
|
+
atomic snapshot before any success or terminal receipt is relayed. Non-receipt frames and read boundaries end
|
|
34
|
+
the batch, without timers or debounce. Failed saves restore mail and delivery records, report `E_PERSIST_FAILED`
|
|
35
|
+
and withhold success, then disconnect the receiver so reconnect redelivers mail and replays terminal receipts
|
|
36
|
+
without reinjection. `broker/broker.ts` remains listed in `upstream.json` under `humainPatches` (HUMAIN #98).
|
|
32
37
|
- Spawn lock and reclaim guard are created atomically with their content (unique temp file, then `link(2)`), so an
|
|
33
38
|
unparsable one is corruption, never a creator mid-write. The lock is released only by its owner token; stale-lock
|
|
34
39
|
reclamation is serialized by a `broker.spawn.lock.reclaim` guard file, removes only the file it re-verified (moved
|
|
@@ -151,6 +156,18 @@ No derived-file header changes: the upstream broker change is not imported, and
|
|
|
151
156
|
implementation in `transport/discovery.ts`, `broker/broker.ts` and `client/client.ts`. Regressions live in
|
|
152
157
|
`test/coordination/upstream-0181.test.ts`. No dependency or manifest change is required.
|
|
153
158
|
|
|
159
|
+
## Readable sessions (HUMAIN #63)
|
|
160
|
+
|
|
161
|
+
- Live suffix handles resolve after exact IDs and names and before prefix guesses. Ambiguous suffixes are refused.
|
|
162
|
+
- The broker computes display handles against the full live roster, including for filtered listings, and passes them
|
|
163
|
+
with sender metadata and resolved delivery recipients. The client validates this metadata; it grants no authority.
|
|
164
|
+
- The HUMAIN adapter renders advisory inbound cards and send-result cards, readable owner status and notices. Model
|
|
165
|
+
headers, safety text and send-result text are unchanged. Human-only assignment, writer gates and Git approval remain.
|
|
166
|
+
|
|
167
|
+
The modified derived files (`broker/broker.ts`, `client/client.ts`, `transport/types.ts`, `transport/protocol.ts`) are
|
|
168
|
+
already listed in `upstream.json` under `humainPatches`; that list remains accurate. Adapter files and
|
|
169
|
+
`transport/discovery.ts` are HUMAIN-owned.
|
|
170
|
+
|
|
154
171
|
## Not vendored
|
|
155
172
|
|
|
156
173
|
`index.ts` (Pi extension), `config.ts`, `herdr-location.ts`, `project-agent.ts`, `handover.ts`,
|
|
@@ -8,6 +8,17 @@ and remains licensed under the upstream MIT license in `vendor/LICENSE`.
|
|
|
8
8
|
and the files carrying HUMAIN-specific patches. Demo video and banner assets are
|
|
9
9
|
not vendored because they are not runtime inputs.
|
|
10
10
|
|
|
11
|
+
HUMAIN's `storage.ts` patch separates session-owned fetch metadata and disk
|
|
12
|
+
references from an 8 MiB hot-payload LRU. Payloads are charged at the UTF-16
|
|
13
|
+
size of their serialized URL fields, including diagnostics and media. Eviction
|
|
14
|
+
leaves ownership intact; disk-backed entries reload on demand, while failed
|
|
15
|
+
spills share the same bounded fallback and report their write error once the
|
|
16
|
+
payload is evicted. Oversized payloads are served from disk without being
|
|
17
|
+
retained. Expiry and the final holder release drop hot payloads. The internal
|
|
18
|
+
pruning API accepts a `maxMemoryBytes` override for deterministic small-budget
|
|
19
|
+
tests; it applies until changed or reset by `clearResults()`. `storage.ts`
|
|
20
|
+
remains listed in `upstream.json` under `humainPatches`.
|
|
21
|
+
|
|
11
22
|
Run `npm run check:web-access-upstream` to detect a newer npm release. The
|
|
12
23
|
HUMAIN Code CLI release script runs this check as a blocking preflight so a
|
|
13
24
|
new upstream release must be reviewed before publishing. Updating requires
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
function combineAbortSignals(signals){let activeSignals=signals.filter(signal=>signal!==void 0);if(activeSignals.length===0)return{cleanup:()=>{}};if(activeSignals.length===1)return{signal:activeSignals[0],cleanup:()=>{}};let controller=new AbortController,listeners=[],abort=signal=>{controller.signal.aborted||controller.abort(signal.reason)};for(let signal of activeSignals){if(signal.aborted){abort(signal);break}let listener=()=>abort(signal);signal.addEventListener("abort",listener,{once:!0}),
|
|
3
|
-
listeners.push({signal,listener})}return{signal:controller.signal,cleanup:()=>{for(let{signal,listener}of listeners)signal.removeEventListener("abort",listener)}}}export{combineAbortSignals};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{AssistantMessageFrameEncoder,StringEnum,createFauxCore,envApiKeyAuth,fauxAssistantMessage,fauxProvider,fauxText,fauxThinking,fauxToolCall,getOverflowPatterns,isContextOverflow,isRecoverableLength,lazyOAuth,reduceAssistantMessageFrames,validateToolArguments,validateToolCall}from"./chunk-HW6HMUXS.js";import{DEFAULT_MAX_AGENT_RETRY_DELAY_MS,getAssistantRetryDelayMs,isRetryableAssistantError,retryAssistantCall,retryDelayMs}from"./chunk-H7Y4QY7K.js";import{cleanupSessionResources,getOpenAICodexTokenIdentity,
|
|
3
|
-
registerSessionResourceCleanup}from"./chunk-DBL35X7L.js";import{StreamingJsonParser,ToolCallArgumentsStream,parseJsonWithRepair,parseStreamingJson,parseStreamingJsonWhileStreaming,parseToolCallArguments,repairJson}from"./chunk-NN53K2QQ.js";import{AI_TELEMETRY_SCHEMA,DEFAULT_NO_PROGRESS_TIMEOUT_MS,InMemoryCredentialStore,InMemoryModelsStore,ModelsError,NoProgressTimeoutError,calculateCost,clampThinkingLevel,collapseSystemMessages,commitLoginCredential,createInitialSystemMessage,createModels,
|
|
4
|
-
createProvider,declarationsEqual,defaultProviderAuthContext,getCurrentSystemMessage,getCurrentSystemPrompt,getCurrentTools,getDeclaredTools,getInitialSystemMessage,getModelType,getSupportedThinkingLevels,getToolStateChanges,hasApi,hasNonAdditiveToolChanges,hasToolRedefinitions,isModelType,lazyApi,lazyStream,modelsAreEqual,normalizeContext,resolveTranscript,resolveTranscriptTools,streamWithProgressTimeout,toToolDeclaration,withoutInitialSystemMessage}from"./chunk-EDONIPUJ.js";import{AssistantMessageEventStream,
|
|
5
|
-
EventStream,createAssistantMessageEventStream}from"./chunk-IJYVMOB4.js";import{PI_AI_VERSION,PI_ATTRIBUTION,appendAssistantMessageDiagnostic,contentText,createAssistantMessageDiagnostic,extractDiagnosticError,formatThrownValue,formatUserAgent,getAttributionHeaders,getClientProduct,getClientVersion,getIdentityHeaders,getOpenCodeSessionHeaders,getSystemMessageText,mergeClientIdentity,renderSystemMessageUpdate,uuidv7,withClientIdentity}from"./chunk-XMZGB3H4.js";import"./chunk-JXWJOIH4.js";export{AI_TELEMETRY_SCHEMA,AssistantMessageEventStream,AssistantMessageFrameEncoder,DEFAULT_MAX_AGENT_RETRY_DELAY_MS,DEFAULT_NO_PROGRESS_TIMEOUT_MS,EventStream,InMemoryCredentialStore,InMemoryModelsStore,ModelsError,NoProgressTimeoutError,PI_AI_VERSION,PI_ATTRIBUTION,StreamingJsonParser,StringEnum,ToolCallArgumentsStream,appendAssistantMessageDiagnostic,calculateCost,clampThinkingLevel,cleanupSessionResources,collapseSystemMessages,commitLoginCredential,contentText,createAssistantMessageDiagnostic,
|
|
6
|
-
createAssistantMessageEventStream,createFauxCore,createInitialSystemMessage,createModels,createProvider,declarationsEqual,defaultProviderAuthContext,envApiKeyAuth,extractDiagnosticError,fauxAssistantMessage,fauxProvider,fauxText,fauxThinking,fauxToolCall,formatThrownValue,formatUserAgent,getAssistantRetryDelayMs,getAttributionHeaders,getClientProduct,getClientVersion,getCurrentSystemMessage,getCurrentSystemPrompt,getCurrentTools,getDeclaredTools,getIdentityHeaders,getInitialSystemMessage,getModelType,
|
|
7
|
-
getOpenAICodexTokenIdentity,getOpenCodeSessionHeaders,getOverflowPatterns,getSupportedThinkingLevels,getSystemMessageText,getToolStateChanges,hasApi,hasNonAdditiveToolChanges,hasToolRedefinitions,isContextOverflow,isModelType,isRecoverableLength,isRetryableAssistantError,lazyApi,lazyOAuth,lazyStream,mergeClientIdentity,modelsAreEqual,normalizeContext,parseJsonWithRepair,parseStreamingJson,parseStreamingJsonWhileStreaming,parseToolCallArguments,reduceAssistantMessageFrames,registerSessionResourceCleanup,
|
|
8
|
-
renderSystemMessageUpdate,repairJson,resolveTranscript,resolveTranscriptTools,retryAssistantCall,retryDelayMs,streamWithProgressTimeout,toToolDeclaration,uuidv7,validateToolArguments,validateToolCall,withClientIdentity,withoutInitialSystemMessage};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{dist_exports as dist_exports3}from"./chunk-B7NJMF7B.js";import{dist_exports as dist_exports2}from"./chunk-AOH2O5CP.js";import"./chunk-ONR6Q3II.js";import"./chunk-RU7ADKA7.js";import"./chunk-M4CHQBAI.js";import"./chunk-AHSNQWZU.js";import"./chunk-JFE52VSN.js";import{all_exports,anthropicMessagesApi,azureOpenAIResponsesApi,bedrockConverseStreamApi,complete,completeSimple,generateImages,generateImagesOpenRouter,getApiProvider,getApiProviders,getImageModel,
|
|
3
|
-
getImageModels,getImageProviders,getImagesApiProvider,getModel,getModels,getProviders,googleGenerativeAIApi,googleVertexApi,mistralConversationsApi,openAICodexResponsesApi,openAICompletionsApi,openAIResponsesApi,piMessagesApi,registerApiProvider,registerBuiltInApiProviders,registerBuiltInImagesApiProviders,registerFauxProvider,registerImagesApiProvider,resetApiProviders,setBedrockProviderModule,stream,streamAnthropic,streamAzureOpenAIResponses,streamGoogle,streamGoogleVertex,streamMistral,streamOpenAICodexResponses,
|
|
4
|
-
streamOpenAICompletions,streamOpenAIResponses,streamSimple,streamSimpleAnthropic,streamSimpleAzureOpenAIResponses,streamSimpleGoogle,streamSimpleGoogleVertex,streamSimpleMistral,streamSimpleOpenAICodexResponses,streamSimpleOpenAICompletions,streamSimpleOpenAIResponses,unregisterApiProviders}from"./chunk-CVC2GV26.js";import"./chunk-YRUIJ5AH.js";import{dist_exports}from"./chunk-CFHOPLW5.js";import"./chunk-XQRYOCHA.js";import"./chunk-DNGJMRJW.js";import"./chunk-6DE7LJKV.js";
|
|
5
|
-
import"./chunk-RO5YPAJH.js";import"./chunk-C6VERWRZ.js";import"./chunk-6E6RHNOU.js";import{ANTHROPIC_API_KEY_ENV,ANTHROPIC_AUTH_TOKEN_ENV,ANTHROPIC_FEDERATION_RULE_ID_ENV,ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,ANTHROPIC_OAUTH_TOKEN_ENV,ANTHROPIC_ORGANIZATION_ID_ENV,ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,ANTHROPIC_WORKSPACE_ID_ENV,findEnvKeys,getEnvApiKey}from"./chunk-KQM7ZGL6.js";import"./chunk-CIA6V3BP.js";import"./chunk-O4DO5RWS.js";import"./chunk-FACBDLFU.js";import{
|
|
6
|
-
compile_exports,value_exports}from"./chunk-LDGCU6PD.js";import{build_exports,typebox_exports}from"./chunk-VEGJT52D.js";import"./chunk-IADQJFNH.js";import"./chunk-2H3LUS62.js";import{AssistantMessageFrameEncoder,createFauxCore,envApiKeyAuth,fauxAssistantMessage,fauxProvider,fauxText,fauxThinking,fauxToolCall,getOverflowPatterns,isContextOverflow,isRecoverableLength,lazyOAuth,reduceAssistantMessageFrames,validateToolArguments,validateToolCall}from"./chunk-HW6HMUXS.js";
|
|
7
|
-
import{DEFAULT_MAX_AGENT_RETRY_DELAY_MS,getAssistantRetryDelayMs,isRetryableAssistantError,retryAssistantCall,retryDelayMs}from"./chunk-H7Y4QY7K.js";import{cleanupSessionResources,getOpenAICodexTokenIdentity,registerSessionResourceCleanup}from"./chunk-DBL35X7L.js";import{StreamingJsonParser,ToolCallArgumentsStream,parseJsonWithRepair,parseStreamingJson,parseStreamingJsonWhileStreaming,parseToolCallArguments,repairJson}from"./chunk-NN53K2QQ.js";import{AI_TELEMETRY_SCHEMA,DEFAULT_NO_PROGRESS_TIMEOUT_MS,
|
|
8
|
-
InMemoryCredentialStore,InMemoryModelsStore,ModelsError,NoProgressTimeoutError,calculateCost,clampThinkingLevel,collapseSystemMessages,commitLoginCredential,createInitialSystemMessage,createModels,createProvider,declarationsEqual,defaultProviderAuthContext,getCurrentSystemMessage,getCurrentSystemPrompt,getCurrentTools,getDeclaredTools,getInitialSystemMessage,getModelType,getSupportedThinkingLevels,getToolStateChanges,hasApi,hasNonAdditiveToolChanges,hasToolRedefinitions,isModelType,lazyApi,lazyStream,
|
|
9
|
-
modelsAreEqual,models_exports,normalizeContext,resolveTranscript,resolveTranscriptTools,streamWithProgressTimeout,toToolDeclaration,withoutInitialSystemMessage}from"./chunk-EDONIPUJ.js";import{AssistantMessageEventStream,EventStream,createAssistantMessageEventStream}from"./chunk-IJYVMOB4.js";import{PI_AI_VERSION,PI_ATTRIBUTION,appendAssistantMessageDiagnostic,contentText,createAssistantMessageDiagnostic,extractDiagnosticError,formatThrownValue,formatUserAgent,getAttributionHeaders,getClientProduct,
|
|
10
|
-
getClientVersion,getIdentityHeaders,getOpenCodeSessionHeaders,getSystemMessageText,mergeClientIdentity,renderSystemMessageUpdate,uuidv7,withClientIdentity}from"./chunk-XMZGB3H4.js";import{__export}from"./chunk-JXWJOIH4.js";var oauth_exports={};var pi_ai_extension_view_exports={};__export(pi_ai_extension_view_exports,{AI_TELEMETRY_SCHEMA:()=>AI_TELEMETRY_SCHEMA,ANTHROPIC_API_KEY_ENV:()=>ANTHROPIC_API_KEY_ENV,ANTHROPIC_AUTH_TOKEN_ENV:()=>ANTHROPIC_AUTH_TOKEN_ENV,ANTHROPIC_FEDERATION_RULE_ID_ENV:()=>ANTHROPIC_FEDERATION_RULE_ID_ENV,ANTHROPIC_IDENTITY_TOKEN_FILE_ENV:()=>ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,ANTHROPIC_OAUTH_TOKEN_ENV:()=>ANTHROPIC_OAUTH_TOKEN_ENV,ANTHROPIC_ORGANIZATION_ID_ENV:()=>ANTHROPIC_ORGANIZATION_ID_ENV,ANTHROPIC_SERVICE_ACCOUNT_ID_ENV:()=>ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,
|
|
11
|
-
ANTHROPIC_WORKSPACE_ID_ENV:()=>ANTHROPIC_WORKSPACE_ID_ENV,AssistantMessageEventStream:()=>AssistantMessageEventStream,AssistantMessageFrameEncoder:()=>AssistantMessageFrameEncoder,DEFAULT_MAX_AGENT_RETRY_DELAY_MS:()=>DEFAULT_MAX_AGENT_RETRY_DELAY_MS,DEFAULT_NO_PROGRESS_TIMEOUT_MS:()=>DEFAULT_NO_PROGRESS_TIMEOUT_MS,EventStream:()=>EventStream,InMemoryCredentialStore:()=>InMemoryCredentialStore,InMemoryModelsStore:()=>InMemoryModelsStore,ModelsError:()=>ModelsError,NoProgressTimeoutError:()=>NoProgressTimeoutError,
|
|
12
|
-
PI_AI_VERSION:()=>PI_AI_VERSION,PI_ATTRIBUTION:()=>PI_ATTRIBUTION,StreamingJsonParser:()=>StreamingJsonParser,StringEnum:()=>StringEnum,ToolCallArgumentsStream:()=>ToolCallArgumentsStream,Type:()=>typebox_exports,anthropicMessagesApi:()=>anthropicMessagesApi,appendAssistantMessageDiagnostic:()=>appendAssistantMessageDiagnostic,azureOpenAIResponsesApi:()=>azureOpenAIResponsesApi,bedrockConverseStreamApi:()=>bedrockConverseStreamApi,calculateCost:()=>calculateCost,clampThinkingLevel:()=>clampThinkingLevel,
|
|
13
|
-
cleanupSessionResources:()=>cleanupSessionResources,collapseSystemMessages:()=>collapseSystemMessages,commitLoginCredential:()=>commitLoginCredential,complete:()=>complete,completeSimple:()=>completeSimple,contentText:()=>contentText,createAssistantMessageDiagnostic:()=>createAssistantMessageDiagnostic,createAssistantMessageEventStream:()=>createAssistantMessageEventStream,createFauxCore:()=>createFauxCore,createInitialSystemMessage:()=>createInitialSystemMessage,createModels:()=>createModels,createProvider:()=>createProvider,
|
|
14
|
-
declarationsEqual:()=>declarationsEqual,defaultProviderAuthContext:()=>defaultProviderAuthContext,envApiKeyAuth:()=>envApiKeyAuth,extractDiagnosticError:()=>extractDiagnosticError,fauxAssistantMessage:()=>fauxAssistantMessage,fauxProvider:()=>fauxProvider,fauxText:()=>fauxText,fauxThinking:()=>fauxThinking,fauxToolCall:()=>fauxToolCall,findEnvKeys:()=>findEnvKeys,formatThrownValue:()=>formatThrownValue,formatUserAgent:()=>formatUserAgent,generateImages:()=>generateImages,generateImagesOpenRouter:()=>generateImagesOpenRouter,
|
|
15
|
-
getApiProvider:()=>getApiProvider,getApiProviders:()=>getApiProviders,getAssistantRetryDelayMs:()=>getAssistantRetryDelayMs,getAttributionHeaders:()=>getAttributionHeaders,getClientProduct:()=>getClientProduct,getClientVersion:()=>getClientVersion,getCurrentSystemMessage:()=>getCurrentSystemMessage,getCurrentSystemPrompt:()=>getCurrentSystemPrompt,getCurrentTools:()=>getCurrentTools,getDeclaredTools:()=>getDeclaredTools,getEnvApiKey:()=>getEnvApiKey,getIdentityHeaders:()=>getIdentityHeaders,getImageModel:()=>getImageModel,
|
|
16
|
-
getImageModels:()=>getImageModels,getImageProviders:()=>getImageProviders,getImagesApiProvider:()=>getImagesApiProvider,getInitialSystemMessage:()=>getInitialSystemMessage,getModel:()=>getModel,getModelType:()=>getModelType,getModels:()=>getModels,getOpenAICodexTokenIdentity:()=>getOpenAICodexTokenIdentity,getOpenCodeSessionHeaders:()=>getOpenCodeSessionHeaders,getOverflowPatterns:()=>getOverflowPatterns,getProviders:()=>getProviders,getSupportedThinkingLevels:()=>getSupportedThinkingLevels,getSystemMessageText:()=>getSystemMessageText,
|
|
17
|
-
getToolStateChanges:()=>getToolStateChanges,googleGenerativeAIApi:()=>googleGenerativeAIApi,googleVertexApi:()=>googleVertexApi,hasApi:()=>hasApi,hasNonAdditiveToolChanges:()=>hasNonAdditiveToolChanges,hasToolRedefinitions:()=>hasToolRedefinitions,isContextOverflow:()=>isContextOverflow,isModelType:()=>isModelType,isRecoverableLength:()=>isRecoverableLength,isRetryableAssistantError:()=>isRetryableAssistantError,lazyApi:()=>lazyApi,lazyOAuth:()=>lazyOAuth,lazyStream:()=>lazyStream,mergeClientIdentity:()=>mergeClientIdentity,
|
|
18
|
-
mistralConversationsApi:()=>mistralConversationsApi,modelsAreEqual:()=>modelsAreEqual,normalizeContext:()=>normalizeContext,openAICodexResponsesApi:()=>openAICodexResponsesApi,openAICompletionsApi:()=>openAICompletionsApi,openAIResponsesApi:()=>openAIResponsesApi,parseJsonWithRepair:()=>parseJsonWithRepair,parseStreamingJson:()=>parseStreamingJson,parseStreamingJsonWhileStreaming:()=>parseStreamingJsonWhileStreaming,parseToolCallArguments:()=>parseToolCallArguments,piMessagesApi:()=>piMessagesApi,
|
|
19
|
-
reduceAssistantMessageFrames:()=>reduceAssistantMessageFrames,registerApiProvider:()=>registerApiProvider,registerBuiltInApiProviders:()=>registerBuiltInApiProviders,registerBuiltInImagesApiProviders:()=>registerBuiltInImagesApiProviders,registerFauxProvider:()=>registerFauxProvider,registerImagesApiProvider:()=>registerImagesApiProvider,registerSessionResourceCleanup:()=>registerSessionResourceCleanup,renderSystemMessageUpdate:()=>renderSystemMessageUpdate,repairJson:()=>repairJson,resetApiProviders:()=>resetApiProviders,
|
|
20
|
-
resolveTranscript:()=>resolveTranscript,resolveTranscriptTools:()=>resolveTranscriptTools,retryAssistantCall:()=>retryAssistantCall,retryDelayMs:()=>retryDelayMs,setBedrockProviderModule:()=>setBedrockProviderModule,stream:()=>stream,streamAnthropic:()=>streamAnthropic,streamAzureOpenAIResponses:()=>streamAzureOpenAIResponses,streamGoogle:()=>streamGoogle,streamGoogleVertex:()=>streamGoogleVertex,streamMistral:()=>streamMistral,streamOpenAICodexResponses:()=>streamOpenAICodexResponses,streamOpenAICompletions:()=>streamOpenAICompletions,
|
|
21
|
-
streamOpenAIResponses:()=>streamOpenAIResponses,streamSimple:()=>streamSimple,streamSimpleAnthropic:()=>streamSimpleAnthropic,streamSimpleAzureOpenAIResponses:()=>streamSimpleAzureOpenAIResponses,streamSimpleGoogle:()=>streamSimpleGoogle,streamSimpleGoogleVertex:()=>streamSimpleGoogleVertex,streamSimpleMistral:()=>streamSimpleMistral,streamSimpleOpenAICodexResponses:()=>streamSimpleOpenAICodexResponses,streamSimpleOpenAICompletions:()=>streamSimpleOpenAICompletions,streamSimpleOpenAIResponses:()=>streamSimpleOpenAIResponses,
|
|
22
|
-
streamWithProgressTimeout:()=>streamWithProgressTimeout,toToolDeclaration:()=>toToolDeclaration,unregisterApiProviders:()=>unregisterApiProviders,uuidv7:()=>uuidv7,validateToolArguments:()=>validateToolArguments,validateToolCall:()=>validateToolCall,withClientIdentity:()=>withClientIdentity,withoutInitialSystemMessage:()=>withoutInitialSystemMessage});function StringEnum(values,options){return typebox_exports.Unsafe({type:"string",enum:values,...options?.description&&{description:options.description},...options?.default&&{default:options.default}})}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":pi_ai_extension_view_exports,"@earendil-works/pi-ai/compat":pi_ai_extension_view_exports,"@earendil-works/pi-ai/models":models_exports,"@earendil-works/pi-ai/oauth":oauth_exports,
|
|
23
|
-
"@earendil-works/pi-ai/providers/all":all_exports,"@earendil-works/pi-coding-agent":dist_exports3,"@mariozechner/pi-agent-core":dist_exports2,"@mariozechner/pi-tui":dist_exports,"@mariozechner/pi-ai":pi_ai_extension_view_exports,"@mariozechner/pi-ai/compat":pi_ai_extension_view_exports,"@mariozechner/pi-ai/models":models_exports,"@mariozechner/pi-ai/oauth":oauth_exports,"@mariozechner/pi-ai/providers/all":all_exports,"@mariozechner/pi-coding-agent":dist_exports3};export{VIRTUAL_MODULES};
|