@humain/terminal 0.0.3-beta.2 → 0.0.4-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/bun/cli.d.ts.map +1 -1
  3. package/dist/bun/cli.js +0 -1
  4. package/dist/bun/cli.js.map +1 -1
  5. package/dist/core/agent-session.d.ts.map +1 -1
  6. package/dist/core/agent-session.js +7 -1
  7. package/dist/core/agent-session.js.map +1 -1
  8. package/dist/core/sdk.d.ts.map +1 -1
  9. package/dist/core/sdk.js +1 -1
  10. package/dist/core/sdk.js.map +1 -1
  11. package/dist/core/session-manager.d.ts +4 -0
  12. package/dist/core/session-manager.d.ts.map +1 -1
  13. package/dist/core/session-manager.js +46 -22
  14. package/dist/core/session-manager.js.map +1 -1
  15. package/dist/core/tools/index.d.ts +2 -1
  16. package/dist/core/tools/index.d.ts.map +1 -1
  17. package/dist/core/tools/index.js +9 -1
  18. package/dist/core/tools/index.js.map +1 -1
  19. package/dist/core/tools/subagent.d.ts +82 -0
  20. package/dist/core/tools/subagent.d.ts.map +1 -0
  21. package/dist/core/tools/subagent.js +980 -0
  22. package/dist/core/tools/subagent.js.map +1 -0
  23. package/dist/humain/bedrock-provider/vendor/index.bundle.d.mts +3 -0
  24. package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +1509 -0
  25. package/dist/humain/index.d.ts.map +1 -1
  26. package/dist/humain/index.js +3 -0
  27. package/dist/humain/index.js.map +1 -1
  28. package/dist/humain/mcp-adapter/vendor/CHANGELOG.md +36 -0
  29. package/dist/humain/mcp-adapter/vendor/README.md +47 -5
  30. package/dist/humain/mcp-adapter/vendor/cli.js +163 -1
  31. package/dist/humain/mcp-adapter/vendor/commands.ts +128 -22
  32. package/dist/humain/mcp-adapter/vendor/config.ts +25 -7
  33. package/dist/humain/mcp-adapter/vendor/direct-tools.ts +5 -4
  34. package/dist/humain/mcp-adapter/vendor/index.bundle.mjs +1663 -458
  35. package/dist/humain/mcp-adapter/vendor/index.ts +219 -32
  36. package/dist/humain/mcp-adapter/vendor/init.ts +36 -4
  37. package/dist/humain/mcp-adapter/vendor/lifecycle.ts +315 -24
  38. package/dist/humain/mcp-adapter/vendor/mcp-auth-flow.ts +39 -6
  39. package/dist/humain/mcp-adapter/vendor/mcp-bearer-store.ts +387 -0
  40. package/dist/humain/mcp-adapter/vendor/mcp-callback-server.ts +27 -3
  41. package/dist/humain/mcp-adapter/vendor/mcp-code.ts +4 -0
  42. package/dist/humain/mcp-adapter/vendor/mcp-panel.ts +42 -13
  43. package/dist/humain/mcp-adapter/vendor/metadata-cache.ts +32 -21
  44. package/dist/humain/mcp-adapter/vendor/package-mcp-loader.ts +168 -0
  45. package/dist/humain/mcp-adapter/vendor/package.json +179 -177
  46. package/dist/humain/mcp-adapter/vendor/proxy-modes.ts +5 -4
  47. package/dist/humain/mcp-adapter/vendor/request-headers-command.ts +31 -37
  48. package/dist/humain/mcp-adapter/vendor/search-ranking.ts +92 -22
  49. package/dist/humain/mcp-adapter/vendor/server-manager.ts +140 -2
  50. package/dist/humain/mcp-adapter/vendor/session-recovery.ts +7 -0
  51. package/dist/humain/mcp-adapter/vendor/tool-approval.ts +15 -2
  52. package/dist/humain/mcp-adapter/vendor/tool-result-renderer.ts +44 -4
  53. package/dist/humain/mcp-adapter/vendor/types.ts +2 -0
  54. package/dist/humain/mcp-adapter/vendor/ui-server.ts +18 -16
  55. package/dist/humain/mcp-adapter/vendor/utils.ts +70 -0
  56. package/dist/humain/web-access/vendor/anysearch.d.ts.map +1 -1
  57. package/dist/humain/web-access/vendor/anysearch.js +3 -2
  58. package/dist/humain/web-access/vendor/anysearch.js.map +1 -1
  59. package/dist/humain/web-access/vendor/brave.d.ts.map +1 -1
  60. package/dist/humain/web-access/vendor/brave.js +14 -4
  61. package/dist/humain/web-access/vendor/brave.js.map +1 -1
  62. package/dist/humain/web-access/vendor/curator-page.d.ts +3 -0
  63. package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
  64. package/dist/humain/web-access/vendor/curator-page.js +4 -1
  65. package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
  66. package/dist/humain/web-access/vendor/curator-server.d.ts +3 -0
  67. package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
  68. package/dist/humain/web-access/vendor/curator-server.js +6 -0
  69. package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
  70. package/dist/humain/web-access/vendor/exa.d.ts.map +1 -1
  71. package/dist/humain/web-access/vendor/exa.js +16 -7
  72. package/dist/humain/web-access/vendor/exa.js.map +1 -1
  73. package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
  74. package/dist/humain/web-access/vendor/extract.js +31 -3
  75. package/dist/humain/web-access/vendor/extract.js.map +1 -1
  76. package/dist/humain/web-access/vendor/gemini-search.d.ts +2 -2
  77. package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
  78. package/dist/humain/web-access/vendor/gemini-search.js +25 -4
  79. package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
  80. package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
  81. package/dist/humain/web-access/vendor/index.js +36 -49
  82. package/dist/humain/web-access/vendor/index.js.map +1 -1
  83. package/dist/humain/web-access/vendor/page-query.d.ts +1 -2
  84. package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
  85. package/dist/humain/web-access/vendor/page-query.js +5 -2
  86. package/dist/humain/web-access/vendor/page-query.js.map +1 -1
  87. package/dist/humain/web-access/vendor/parallel-mcp.d.ts +10 -0
  88. package/dist/humain/web-access/vendor/parallel-mcp.d.ts.map +1 -0
  89. package/dist/humain/web-access/vendor/parallel-mcp.js +224 -0
  90. package/dist/humain/web-access/vendor/parallel-mcp.js.map +1 -0
  91. package/dist/humain/web-access/vendor/parallel.d.ts +1 -0
  92. package/dist/humain/web-access/vendor/parallel.d.ts.map +1 -1
  93. package/dist/humain/web-access/vendor/parallel.js +2 -2
  94. package/dist/humain/web-access/vendor/parallel.js.map +1 -1
  95. package/dist/humain/web-access/vendor/query-rewrite.d.ts +3 -0
  96. package/dist/humain/web-access/vendor/query-rewrite.d.ts.map +1 -0
  97. package/dist/humain/web-access/vendor/query-rewrite.js +42 -0
  98. package/dist/humain/web-access/vendor/query-rewrite.js.map +1 -0
  99. package/dist/humain/web-access/vendor/serper.d.ts +4 -0
  100. package/dist/humain/web-access/vendor/serper.d.ts.map +1 -0
  101. package/dist/humain/web-access/vendor/serper.js +206 -0
  102. package/dist/humain/web-access/vendor/serper.js.map +1 -0
  103. package/dist/humain/web-access/vendor/summary-model-scope.d.ts +5 -0
  104. package/dist/humain/web-access/vendor/summary-model-scope.d.ts.map +1 -1
  105. package/dist/humain/web-access/vendor/summary-model-scope.js +10 -5
  106. package/dist/humain/web-access/vendor/summary-model-scope.js.map +1 -1
  107. package/dist/humain/web-access/vendor/summary-review.d.ts.map +1 -1
  108. package/dist/humain/web-access/vendor/summary-review.js +40 -14
  109. package/dist/humain/web-access/vendor/summary-review.js.map +1 -1
  110. package/dist/humain/web-access/vendor/tavily.d.ts.map +1 -1
  111. package/dist/humain/web-access/vendor/tavily.js +14 -4
  112. package/dist/humain/web-access/vendor/tavily.js.map +1 -1
  113. package/dist/humain/web-access/vendor/utils.d.ts +10 -0
  114. package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
  115. package/dist/humain/web-access/vendor/utils.js +70 -0
  116. package/dist/humain/web-access/vendor/utils.js.map +1 -1
  117. package/dist/humain/web-access/vendor/valyu.d.ts +6 -0
  118. package/dist/humain/web-access/vendor/valyu.d.ts.map +1 -0
  119. package/dist/humain/web-access/vendor/valyu.js +194 -0
  120. package/dist/humain/web-access/vendor/valyu.js.map +1 -0
  121. package/docs/extensions.md +1 -1
  122. package/examples/extensions/README.md +1 -1
  123. package/examples/extensions/subagent/README.md +24 -147
  124. package/npm-shrinkwrap.json +7 -2
  125. package/package.json +7 -2
  126. package/src/humain/mcp-adapter/UPSTREAM.md +1 -1
  127. package/src/humain/mcp-adapter/upstream.json +3 -3
  128. package/src/humain/mcp-adapter/vendor/CHANGELOG.md +36 -0
  129. package/src/humain/web-access/UPSTREAM.md +1 -1
  130. package/src/humain/web-access/upstream.json +4 -4
  131. package/dist/bun/register-bedrock.d.ts +0 -2
  132. package/dist/bun/register-bedrock.d.ts.map +0 -1
  133. package/dist/bun/register-bedrock.js +0 -4
  134. package/dist/bun/register-bedrock.js.map +0 -1
  135. package/examples/extensions/subagent/agents.ts +0 -126
  136. package/examples/extensions/subagent/index.ts +0 -1015
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humain/terminal",
3
- "version": "0.0.3-beta.2",
3
+ "version": "0.0.4-beta.1",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "humainTerminalConfig": {
@@ -54,13 +54,14 @@
54
54
  "clean": "shx rm -rf dist",
55
55
  "build": "tsgo -p tsconfig.build.json && shx chmod +x dist/cli.js dist/rpc-entry.js && npm run copy-assets",
56
56
  "build:binary": "npm --prefix ../tui run build && npm --prefix ../telemetry run build && npm --prefix ../ai run build && npm --prefix ../agent run build && npm --prefix ../protocol run build && npm --prefix ../client run build && npm run build && bun build --compile --no-compile-autoload-bunfig ./dist/bun/cli.js ./src/utils/image-resize-worker.ts --outfile dist/pi && npm run copy-binary-assets",
57
- "copy-assets": "shx mkdir -p dist/modes/interactive/theme && shx cp src/modes/interactive/theme/*.json dist/modes/interactive/theme/ && shx mkdir -p dist/modes/interactive/assets && shx cp src/modes/interactive/assets/*.png dist/modes/interactive/assets/ && shx mkdir -p dist/core/export-html/vendor && shx cp src/core/export-html/template.html src/core/export-html/template.css src/core/export-html/template.js dist/core/export-html/ && shx cp src/core/export-html/vendor/*.js dist/core/export-html/vendor/ && shx mkdir -p dist/humain/mcp-adapter/vendor && shx cp -r src/humain/mcp-adapter/vendor/* dist/humain/mcp-adapter/vendor/",
57
+ "copy-assets": "shx mkdir -p dist/modes/interactive/theme && shx cp src/modes/interactive/theme/*.json dist/modes/interactive/theme/ && shx mkdir -p dist/modes/interactive/assets && shx cp src/modes/interactive/assets/*.png dist/modes/interactive/assets/ && shx mkdir -p dist/core/export-html/vendor && shx cp src/core/export-html/template.html src/core/export-html/template.css src/core/export-html/template.js dist/core/export-html/ && shx cp src/core/export-html/vendor/*.js dist/core/export-html/vendor/ && shx mkdir -p dist/humain/mcp-adapter/vendor && shx cp -r src/humain/mcp-adapter/vendor/* dist/humain/mcp-adapter/vendor/ && shx mkdir -p dist/humain/bedrock-provider/vendor && shx cp -r src/humain/bedrock-provider/vendor/* dist/humain/bedrock-provider/vendor/",
58
58
  "copy-binary-assets": "shx cp package.json dist/ && shx cp README.md dist/ && shx cp CHANGELOG.md dist/ && shx mkdir -p dist/theme && shx cp src/modes/interactive/theme/*.json dist/theme/ && shx mkdir -p dist/assets && shx cp src/modes/interactive/assets/*.png dist/assets/ && shx mkdir -p dist/export-html/vendor && shx cp src/core/export-html/template.html dist/export-html/ && shx cp src/core/export-html/vendor/*.js dist/export-html/vendor/ && shx cp -r docs dist/ && shx cp -r examples dist/ && shx cp ../../node_modules/@silvia-odwyer/photon-node/photon_rs_bg.wasm dist/",
59
59
  "test": "vitest --run",
60
60
  "shrinkwrap": "node ../../scripts/generate-coding-agent-shrinkwrap.mjs",
61
61
  "prepublishOnly": "npm run clean && npm run build && npm run shrinkwrap"
62
62
  },
63
63
  "dependencies": {
64
+ "@aws-sdk/client-bedrock-runtime": "3.1048.0",
64
65
  "@earendil-works/pi-agent-core": "0.84.1",
65
66
  "@earendil-works/pi-ai": "0.84.1",
66
67
  "@earendil-works/pi-client": "0.84.1",
@@ -72,6 +73,7 @@
72
73
  "@mozilla/readability": "0.6.0",
73
74
  "@napi-rs/keyring": "1.3.0",
74
75
  "@silvia-odwyer/photon-node": "0.3.4",
76
+ "@smithy/node-http-handler": "4.7.3",
75
77
  "chalk": "5.6.2",
76
78
  "ajv": "8.20.0",
77
79
  "ajv-formats": "3.0.1",
@@ -82,10 +84,13 @@
82
84
  "highlight.js": "10.7.3",
83
85
  "hosted-git-info": "9.0.3",
84
86
  "ignore": "7.0.5",
87
+ "http-proxy-agent": "7.0.2",
88
+ "https-proxy-agent": "7.0.6",
85
89
  "jiti": "2.7.0",
86
90
  "linkedom": "0.16.11",
87
91
  "minimatch": "10.2.5",
88
92
  "p-limit": "6.1.0",
93
+ "partial-json": "0.1.7",
89
94
  "open": "10.2.0",
90
95
  "promise.try": "2.0.1",
91
96
  "proper-lockfile": "4.1.2",
@@ -1,7 +1,7 @@
1
1
  # pi-mcp-adapter upstream tracking
2
2
 
3
3
  HUMAIN Terminal vendors [`pi-mcp-adapter`](https://github.com/nicobailon/pi-mcp-adapter)
4
- version `2.26.0` so MCP support is available without a separate VM installation.
4
+ version `2.27.0` so MCP support is available without a separate VM installation.
5
5
 
6
6
  The unmodified upstream package is recorded in `upstream.json`. During updates:
7
7
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-mcp-adapter",
3
3
  "repository": "https://github.com/nicobailon/pi-mcp-adapter",
4
- "version": "2.26.0",
5
- "tarball": "https://registry.npmjs.org/pi-mcp-adapter/-/pi-mcp-adapter-2.26.0.tgz",
6
- "integrity": "sha512-S1L1cTvYdDUIkNGvg/dR1v3ljfxeq6nAA8ffnB+xB5nZH4DSU8Ks9KdmKgmEH4TAEsSxGgv194i6WYORHF0Clg=="
4
+ "version": "2.27.0",
5
+ "tarball": "https://registry.npmjs.org/pi-mcp-adapter/-/pi-mcp-adapter-2.27.0.tgz",
6
+ "integrity": "sha512-IM9dfGhou5Q5AJqwkm1kW1+WXyMsvL53GEO4JVYukzvTxNPHn2b+Zi49+JAnOhlaOpEq5vEodUSJXmpghik+lw=="
7
7
  }
@@ -7,6 +7,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.27.0] - 2026-08-20
11
+
12
+ ### Highlights
13
+ - MCP servers can now come from packages, runtime extension APIs, or the usual config files.
14
+ - Static bearer tokens can use the OS credential store, with a stdin-only CLI for safer token management.
15
+ - Long-lived sessions recover better when remote MCP servers are slow, refreshed, or reconnected.
16
+ - OAuth flows clean up their callback listener when idle and work better inside nested terminal UI prompts.
17
+ - Search, metadata cache writes, direct-tool counts, and UI stream pruning now do less repeated work.
18
+
19
+ ### Added
20
+ - `/pi-mcp` now works as an alias for `/mcp` when a host reserves `/mcp`. Thanks to [@inxeoz](https://github.com/inxeoz) for #391.
21
+ - `registerMcpServer({ pi, name, definition })` lets other extensions register and dispose session-scoped MCP servers at runtime. Registrations are proxy-tool-only, never persisted, and duplicate names fail closed. Thanks to [@bendavis78](https://github.com/bendavis78) and [@fmoda3](https://github.com/fmoda3) for the runtime API request in #376/#382.
22
+ - Pi packages can ship prefixed MCP server definitions with `pi.mcp` manifest entries, without asking users to edit MCP config files. Thanks to [@bendavis78](https://github.com/bendavis78) for #376 and [@fmoda3](https://github.com/fmoda3) for the manifest design.
23
+ - Static bearer tokens can opt into OS credential-store lookup with URL-bound records by setting `bearerTokenStore: true`. The new `pi-mcp-adapter token set|status|remove <server>` CLI reads tokens from stdin and never accepts a token as an argument. Thanks to [@AlexanderBartash](https://github.com/AlexanderBartash) for issue #366.
24
+
25
+ ### Changed
26
+ - Search ranking now reuses normalized MCP tool fields and keyword tokens per catalog.
27
+ - Per-request header commands collect process cleanup data in one snapshot per pass, reducing cold HTTP connect overhead.
28
+ - Metadata cache saves write compact JSON while preserving atomic replacement and cross-process merges.
29
+ - High-frequency UI stream event-log pruning tracks the latest checkpoint event ID instead of rescanning retained patches.
30
+ - The MCP panel reuses direct-tool counts and token totals across renders while keeping toggle and reconnect updates immediate.
31
+
32
+ ### Fixed
33
+ - Short-lived `mcpScript` workers no longer emit false unmanaged file-descriptor warnings on Node 24. Thanks to [@blalor](https://github.com/blalor) for PR #407.
34
+ - OAuth callback listeners are released after idle auth flows, and MCP pickers stay hidden while nested OAuth input is active. Thanks to [@trevorleibert-mixpanel](https://github.com/trevorleibert-mixpanel) for PRs #403 and #404.
35
+ - Request-header command cleanup can scan large process lists without overflowing `spawnSync`'s 1 MiB default buffer, which previously caused spurious `HTTP request headers command cleanup failed: ps exited with code unknown` refresh failures on busy hosts. Thanks to [@rtfpessoa](https://github.com/rtfpessoa) for PR #399.
36
+ - Slow but healthy remote keep-alive servers are no longer marked failed when a bounded tools/list refresh times out. Thanks to [@brightmeowso](https://github.com/brightmeowso) for #400.
37
+ - Cached metadata reconstruction now reuses one selector candidate index, avoiding repeated scans of large cached catalogs at startup.
38
+ - MCP status consumers no longer see a connected catalog before Pi's model-facing tool surface is current. The first connected status snapshot now waits for direct-tool synchronization. Thanks to [@dmorn](https://github.com/dmorn) for PR #380.
39
+ - JSON-string MCP tool-call arguments are normalized before approval and transport, preserving all fields and embedded quotes. Thanks to [@sebbean](https://github.com/sebbean) for PR #377.
40
+ - Session tool approvals are scoped to the approved argument payload instead of every later call to the same tool. Thanks to [@spaceshipmike](https://github.com/spaceshipmike) for #367.
41
+ - MCP panel commands no longer hang in RPC, JSON, and print modes when terminal-only custom UI is unavailable. Thanks to [@shixin-guo](https://github.com/shixin-guo) for PR #365.
42
+ - Compact MCP rows now show a bounded tool-input preview and skip leading blank output lines in collapsed result previews.
43
+ - MCP gateway requests nested inside proxy `args` are recovered instead of silently showing status, and invalid nested gateway requests now fail with guidance. Thanks to [@ibrmora](https://github.com/ibrmora) for #363.
44
+ - Remote keep-alive tool catalogs refresh before user input, adapter-triggered turns, and health checks. Expired Streamable HTTP sessions reconnect so long-lived Pi sessions can discover replacement catalogs without restarting. Thanks to [@dmorn](https://github.com/dmorn) for #369 and PR #370.
45
+
10
46
  ## [2.26.0] - 2026-08-14
11
47
 
12
48
  ### Added
@@ -1,7 +1,7 @@
1
1
  # pi-web-access upstream tracking
2
2
 
3
3
  The vendored implementation in `vendor/` is based on
4
- [`pi-web-access`](https://github.com/nicobailon/pi-web-access) version `0.23.0`
4
+ [`pi-web-access`](https://github.com/nicobailon/pi-web-access) version `0.24.0`
5
5
  and remains licensed under the upstream MIT license in `vendor/LICENSE`.
6
6
 
7
7
  `upstream.json` records the npm tarball URL, SHA-1 shasum, SHA-512 integrity,
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "pi-web-access",
3
3
  "repository": "https://github.com/nicobailon/pi-web-access",
4
- "version": "0.23.0",
5
- "tarball": "https://registry.npmjs.org/pi-web-access/-/pi-web-access-0.23.0.tgz",
6
- "shasum": "342020d636c49c956044a2ea2713d677c67c923f",
7
- "integrity": "sha512-RrMaR/1iI1E7LNBkthUzD8yaPmMhAYY/EzBm+bAN9QA1I8g5YBpLVrD97+d6ezsGN6qdOX0E++psBj12i74kRw==",
4
+ "version": "0.24.0",
5
+ "tarball": "https://registry.npmjs.org/pi-web-access/-/pi-web-access-0.24.0.tgz",
6
+ "shasum": "ddef685aa273ecfb8459193d3fbfad9490ad59a9",
7
+ "integrity": "sha512-BVosva1tGDhHveaGpFnc++YS5+pzmWVzJ/5B+1xBavkRjAgyDvMpA1EfVL+GYIviAxXKck9JyRGVzo4ASV7snA==",
8
8
  "humainPatches": [
9
9
  "extract.ts",
10
10
  "gemini-search.ts",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=register-bedrock.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register-bedrock.d.ts","sourceRoot":"","sources":["../../src/bun/register-bedrock.ts"],"names":[],"mappings":"","sourcesContent":["import { bedrockProviderModule } from \"@earendil-works/pi-ai/bedrock-provider\";\nimport { setBedrockProviderModule } from \"@earendil-works/pi-ai/compat\";\n\nsetBedrockProviderModule(bedrockProviderModule);\n"]}
@@ -1,4 +0,0 @@
1
- import { bedrockProviderModule } from "@earendil-works/pi-ai/bedrock-provider";
2
- import { setBedrockProviderModule } from "@earendil-works/pi-ai/compat";
3
- setBedrockProviderModule(bedrockProviderModule);
4
- //# sourceMappingURL=register-bedrock.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register-bedrock.js","sourceRoot":"","sources":["../../src/bun/register-bedrock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAExE,wBAAwB,CAAC,qBAAqB,CAAC,CAAC","sourcesContent":["import { bedrockProviderModule } from \"@earendil-works/pi-ai/bedrock-provider\";\nimport { setBedrockProviderModule } from \"@earendil-works/pi-ai/compat\";\n\nsetBedrockProviderModule(bedrockProviderModule);\n"]}
@@ -1,126 +0,0 @@
1
- /**
2
- * Agent discovery and configuration
3
- */
4
-
5
- import * as fs from "node:fs";
6
- import * as path from "node:path";
7
- import { CONFIG_DIR_NAME, getAgentDir, parseFrontmatter } from "@humain/terminal";
8
-
9
- export type AgentScope = "user" | "project" | "both";
10
-
11
- export interface AgentConfig {
12
- name: string;
13
- description: string;
14
- tools?: string[];
15
- model?: string;
16
- systemPrompt: string;
17
- source: "user" | "project";
18
- filePath: string;
19
- }
20
-
21
- export interface AgentDiscoveryResult {
22
- agents: AgentConfig[];
23
- projectAgentsDir: string | null;
24
- }
25
-
26
- function loadAgentsFromDir(dir: string, source: "user" | "project"): AgentConfig[] {
27
- const agents: AgentConfig[] = [];
28
-
29
- if (!fs.existsSync(dir)) {
30
- return agents;
31
- }
32
-
33
- let entries: fs.Dirent[];
34
- try {
35
- entries = fs.readdirSync(dir, { withFileTypes: true });
36
- } catch {
37
- return agents;
38
- }
39
-
40
- for (const entry of entries) {
41
- if (!entry.name.endsWith(".md")) continue;
42
- if (!entry.isFile() && !entry.isSymbolicLink()) continue;
43
-
44
- const filePath = path.join(dir, entry.name);
45
- let content: string;
46
- try {
47
- content = fs.readFileSync(filePath, "utf-8");
48
- } catch {
49
- continue;
50
- }
51
-
52
- const { frontmatter, body } = parseFrontmatter<Record<string, string>>(content);
53
-
54
- if (!frontmatter.name || !frontmatter.description) {
55
- continue;
56
- }
57
-
58
- const tools = frontmatter.tools
59
- ?.split(",")
60
- .map((t: string) => t.trim())
61
- .filter(Boolean);
62
-
63
- agents.push({
64
- name: frontmatter.name,
65
- description: frontmatter.description,
66
- tools: tools && tools.length > 0 ? tools : undefined,
67
- model: frontmatter.model,
68
- systemPrompt: body,
69
- source,
70
- filePath,
71
- });
72
- }
73
-
74
- return agents;
75
- }
76
-
77
- function isDirectory(p: string): boolean {
78
- try {
79
- return fs.statSync(p).isDirectory();
80
- } catch {
81
- return false;
82
- }
83
- }
84
-
85
- function findNearestProjectAgentsDir(cwd: string): string | null {
86
- let currentDir = cwd;
87
- while (true) {
88
- const candidate = path.join(currentDir, CONFIG_DIR_NAME, "agents");
89
- if (isDirectory(candidate)) return candidate;
90
-
91
- const parentDir = path.dirname(currentDir);
92
- if (parentDir === currentDir) return null;
93
- currentDir = parentDir;
94
- }
95
- }
96
-
97
- export function discoverAgents(cwd: string, scope: AgentScope): AgentDiscoveryResult {
98
- const userDir = path.join(getAgentDir(), "agents");
99
- const projectAgentsDir = findNearestProjectAgentsDir(cwd);
100
-
101
- const userAgents = scope === "project" ? [] : loadAgentsFromDir(userDir, "user");
102
- const projectAgents = scope === "user" || !projectAgentsDir ? [] : loadAgentsFromDir(projectAgentsDir, "project");
103
-
104
- const agentMap = new Map<string, AgentConfig>();
105
-
106
- if (scope === "both") {
107
- for (const agent of userAgents) agentMap.set(agent.name, agent);
108
- for (const agent of projectAgents) agentMap.set(agent.name, agent);
109
- } else if (scope === "user") {
110
- for (const agent of userAgents) agentMap.set(agent.name, agent);
111
- } else {
112
- for (const agent of projectAgents) agentMap.set(agent.name, agent);
113
- }
114
-
115
- return { agents: Array.from(agentMap.values()), projectAgentsDir };
116
- }
117
-
118
- export function formatAgentList(agents: AgentConfig[], maxItems: number): { text: string; remaining: number } {
119
- if (agents.length === 0) return { text: "none", remaining: 0 };
120
- const listed = agents.slice(0, maxItems);
121
- const remaining = agents.length - listed.length;
122
- return {
123
- text: listed.map((a) => `${a.name} (${a.source}): ${a.description}`).join("; "),
124
- remaining,
125
- };
126
- }