@borgee/agents-host 0.2.101 → 0.2.110

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 (84) hide show
  1. package/README.md +77 -5
  2. package/dist/agents-host.d.ts +8 -0
  3. package/dist/agents-host.js +355 -23
  4. package/dist/catalog-worker.js +21 -0
  5. package/dist/catalog-worker.js.map +7 -0
  6. package/dist/chat/chat-control-plane.d.ts +7 -2
  7. package/dist/chat/normalized-input.d.ts +9 -0
  8. package/dist/chat/normalized-input.js +24 -0
  9. package/dist/chat/sdk-chat-control-plane.d.ts +18 -3
  10. package/dist/chat/sdk-chat-control-plane.js +44 -9
  11. package/dist/cli-args.d.ts +1 -1
  12. package/dist/cli-args.js +13 -4
  13. package/dist/config.d.ts +3 -1
  14. package/dist/config.js +25 -0
  15. package/dist/context/injection.d.ts +16 -0
  16. package/dist/context/injection.js +37 -21
  17. package/dist/context/prompt.d.ts +12 -0
  18. package/dist/context/prompt.js +25 -0
  19. package/dist/context/turn-preparation.d.ts +2 -1
  20. package/dist/context/turn-preparation.js +15 -0
  21. package/dist/gateway/localhost-gateway.js +33 -8
  22. package/dist/hosted-turn-content.js +3 -2
  23. package/dist/local-config.js +34 -1
  24. package/dist/managed-daemon.js +15 -0
  25. package/dist/native-environment.d.ts +2 -0
  26. package/dist/native-environment.js +9 -0
  27. package/dist/native-protocol-types/codec.d.ts +49 -0
  28. package/dist/native-protocol-types/commands.d.ts +71 -0
  29. package/dist/native-protocol-types/compatibility.d.ts +5 -0
  30. package/dist/native-protocol-types/cursor.d.ts +7 -0
  31. package/dist/native-protocol-types/envelope.d.ts +1105 -0
  32. package/dist/native-protocol-types/file-changes.d.ts +20 -0
  33. package/dist/native-protocol-types/history.d.ts +487 -0
  34. package/dist/native-protocol-types/index.d.ts +18 -0
  35. package/dist/native-protocol-types/interactions.d.ts +619 -0
  36. package/dist/native-protocol-types/messages.d.ts +2482 -0
  37. package/dist/native-protocol-types/public-validation.d.ts +10 -0
  38. package/dist/native-protocol-types/remote-host-uplink.d.ts +67 -0
  39. package/dist/native-protocol-types/resources.d.ts +126 -0
  40. package/dist/native-protocol-types/session-settings.d.ts +22 -0
  41. package/dist/native-protocol-types/snapshot.d.ts +575 -0
  42. package/dist/native-protocol-types/timeline.d.ts +1503 -0
  43. package/dist/native-protocol-types/tool-result.d.ts +26 -0
  44. package/dist/native-protocol-types/uplink.d.ts +56 -0
  45. package/dist/native-protocol-types/version.d.ts +5 -0
  46. package/dist/native-provider-types/commands.d.ts +51 -0
  47. package/dist/native-provider-types/control.d.ts +192 -0
  48. package/dist/native-provider-types/file-changes.d.ts +9 -0
  49. package/dist/native-provider-types/index.d.ts +8 -0
  50. package/dist/native-provider-types/interactions.d.ts +7 -0
  51. package/dist/native-provider-types/observation.d.ts +209 -0
  52. package/dist/native-provider-types/provider.d.ts +124 -0
  53. package/dist/native-provider-types/session-settings.d.ts +17 -0
  54. package/dist/native-provider-types/testing.d.ts +27 -0
  55. package/dist/native-provider-types/tool-result.d.ts +21 -0
  56. package/dist/native-providers.d.ts +21 -0
  57. package/dist/native-providers.js +18402 -0
  58. package/dist/native-providers.js.map +7 -0
  59. package/dist/plugin-sdk.js +10640 -225
  60. package/dist/plugin-sdk.js.map +4 -4
  61. package/dist/policy/copilot-permission.js +1 -8
  62. package/dist/providers/copilot/sdk-session.js +8 -1
  63. package/dist/providers/create-provider.js +20 -0
  64. package/dist/providers/normalized/adapter.d.ts +107 -0
  65. package/dist/providers/normalized/adapter.js +1650 -0
  66. package/dist/providers/normalized/control-policy.d.ts +5 -0
  67. package/dist/providers/normalized/control-policy.js +12 -0
  68. package/dist/providers/normalized/interactions.d.ts +3 -0
  69. package/dist/providers/normalized/interactions.js +39 -0
  70. package/dist/providers/normalized/legacy-input-ownership.d.ts +34 -0
  71. package/dist/providers/normalized/legacy-input-ownership.js +123 -0
  72. package/dist/providers/normalized/session-management.d.ts +67 -0
  73. package/dist/providers/normalized/session-management.js +334 -0
  74. package/dist/providers/normalized/session-ownership.d.ts +3 -0
  75. package/dist/providers/normalized/session-ownership.js +90 -0
  76. package/dist/providers/provider-adapter.d.ts +43 -1
  77. package/dist/providers/provider-adapter.js +8 -0
  78. package/dist/types.d.ts +34 -9
  79. package/dist/vendor/agent-provider-codex/LICENSE +211 -0
  80. package/dist/vendor/agent-provider-codex/NOTICE +13 -0
  81. package/package.json +22 -13
  82. package/skills/borgee-agent/SKILL.md +1 -1
  83. package/skills/borgee-agent/scripts/borgee-agent.mjs +24 -3
  84. package/skills/borgee-agent/scripts/borgee-agent.py +28 -2
package/README.md CHANGED
@@ -101,7 +101,7 @@ Rollback and hardening controls stay explicit:
101
101
  - `AGENTS_HOST_INTERNAL_DISABLED_COMPATIBILITY_GATES=<comma-list>` disables shipped gates for rollback
102
102
  - `AGENTS_HOST_INTERNAL_PROVIDER_IMPLEMENTATIONS=copilot:v1` forces Copilot back to the v1 adapter while its v2 gate stays enabled; stale `claude:v1|v2` entries are tolerated as no-ops for compatibility
103
103
  - `AGENTS_HOST_INTERNAL_POLICY_MODE=enforce` hardens the shipped `policy-audit-enforcement` gate beyond its default `audit-only` mode
104
- - `AGENTS_HOST_INTERNAL_DISABLED_COMPATIBILITY_GATES=provider-idle-shutdown` keeps every provider runtime process resident again; `PROVIDER_IDLE_SHUTDOWN_MINUTES=0` does the same without touching gates
104
+ - `AGENTS_HOST_INTERNAL_DISABLED_COMPATIBILITY_GATES=provider-idle-shutdown` keeps legacy provider runtime processes resident again; `PROVIDER_IDLE_SHUTDOWN_MINUTES=0` does the same without touching gates
105
105
 
106
106
  Or with the CLI:
107
107
 
@@ -237,13 +237,85 @@ Notes:
237
237
  | `AGENTS_HOST_DISABLE_UPDATE_CHECK` | — | no | off | Set to `1` to skip the advisory startup update check. |
238
238
  | `BORGEE_AGENT_NAME` | `--name` | no | `Assistant` | Display name used in prompts |
239
239
  | `RUNTIME_PROVIDER` | `--provider` | no | `claude` | `claude`, `copilot`, or `codex` |
240
+ | `PROVIDER_OUTPUT_MODE` | `--provider-output-mode` | no | `legacy` | Select `legacy` or `normalized` explicitly. The selection does not change provider identity. |
241
+ | `NATIVE_PROVIDER_COMMAND` | `--native-provider-command` | no | pinned native executable | Executable path used only by the normalized provider; not a shell command or an ACP argument string. |
240
242
  | `CLAUDE_COMMAND` / `CLAUDE_ARGS` | `--claude-command` / `--claude-args` | no | `claude-agent-acp` / empty | Local Claude ACP adapter command + args. The shipped bundled `claude-agent-acp` path requires empty `CLAUDE_ARGS`; non-empty args are only valid when `CLAUDE_COMMAND` points at a custom ACP adapter command. Legacy `claude --print --permission-mode bypassPermissions` is tolerated as a compatibility alias. |
241
243
  | `CODEX_COMMAND` / `CODEX_ARGS` | `--codex-command` / `--codex-args` | no | `codex-acp` / empty | Local Codex ACP adapter command + args. The default launch resolves the bundled `@agentclientprotocol/codex-acp` entrypoint. |
242
- | `COPILOT_COMMAND` / `COPILOT_ARGS` | `--copilot-command` / `--copilot-args` | no | `copilot` / parsed but ignored | Local Copilot CLI command. The host resolves it to an executable and starts the SDK headless JSON-RPC runtime; legacy `COPILOT_ARGS` remain ignored. |
244
+ | `CODEX_CONNECTION_MODE` | `--codex-connection-mode` | no | `stdio` | Normalized Codex transport: `shared` attaches to a daemon, `stdio` owns a native process. Legacy mode keeps its ACP adapter. |
245
+ | `CODEX_TRUST_SHARED` | local YAML `codexTrustShared` | normalized Codex shared only | unset | Explicit local consent to control the shared Codex daemon with its existing native permissions. |
246
+ | `CODEX_SHARED_SOCKET_PATH` | local YAML `codexSharedSocketPath` | no | native `CODEX_HOME` control socket | Absolute Unix socket path for normalized shared Codex. The daemon must already be running; there is no stdio fallback. Requires explicit shared mode; incompatible with default or explicit stdio mode. |
247
+ | `SESSION_WORKSPACE_ROOT` | local YAML `sessionWorkspaceRoot` | no | unset | Existing absolute directory for explicit independent normalized Codex Session creation. An unset root disables Create only; discovery and opening preserve existing native Workspaces. |
248
+ | `COPILOT_COMMAND` / `COPILOT_ARGS` | `--copilot-command` / `--copilot-args` | no | `copilot` / parsed but ignored | Legacy Copilot CLI command. The host resolves it to an executable and starts the SDK headless JSON-RPC runtime; legacy `COPILOT_ARGS` remain ignored. Neither setting selects the normalized executable. |
243
249
  | `COPILOT_SESSION_TTL_MINUTES` | `--copilot-session-ttl-minutes` | no | `2880` | Idle TTL for per-channel Copilot SDK sessions |
244
- | `PROVIDER_IDLE_SHUTDOWN_MINUTES` | `--provider-idle-shutdown-minutes` | no | `10` | Idle window before the agent's shared provider runtime **process** is shut down and re-spawned on the next turn. Applies to Claude, Codex, and Copilot. `0` keeps the process resident. Must be non-negative and no larger than the Node.js timer limit (~35791.39 minutes); anything else is rejected at startup. |
250
+ | `PROVIDER_IDLE_SHUTDOWN_MINUTES` | `--provider-idle-shutdown-minutes` | no | `10` | Idle window before the legacy provider runtime **process** is shut down and re-spawned on the next turn. Applies to legacy Claude, Codex, and Copilot; normalized adapters do not use this timer. `0` keeps the process resident. Must be non-negative and no larger than the Node.js timer limit (~35791.39 minutes); anything else is rejected at startup. |
245
251
 
246
- `COPILOT_SESSION_TTL_MINUTES` and `PROVIDER_IDLE_SHUTDOWN_MINUTES` are two different layers and do not replace each other. The first evicts an individual idle Copilot SDK *session* inside a running runtime process. The second shuts the shared provider *process* itself down once every channel it hosts is idle, for all three providers, and takes every live session in that process with it. See [Conversation memory](#conversation-memory) for what happens to those sessions afterwards.
252
+ `COPILOT_SESSION_TTL_MINUTES` and `PROVIDER_IDLE_SHUTDOWN_MINUTES` are two different layers and do not replace each other. The first evicts an individual idle Copilot SDK *session* inside a running runtime process. The second shuts the legacy provider *process* itself down once every channel it hosts is idle and takes every live session in that process with it. Normalized Codex does not use this timer: shared mode releases only its attachment, while stdio mode owns the native process lifetime. See [Conversation memory](#conversation-memory) for what happens to those sessions afterwards.
253
+
254
+ ## Choosing legacy or normalized output
255
+
256
+ Claude, Codex, and Copilot keep legacy output when no mode is configured. Select normalized Copilot explicitly to use the common normalized adapter with the Copilot provider over official SDK stdio:
257
+
258
+ ```bash
259
+ agents-host start https://your-borgee-server bgr_xxxxxxxx --provider copilot --provider-output-mode normalized
260
+ agents-host start-managed https://your-borgee-server bgr_xxxxxxxx --provider copilot --provider-output-mode normalized
261
+ ```
262
+
263
+ Use `--native-provider-command /absolute/path/to/copilot` only when overriding the pinned normalized executable. `--copilot-command`, `--copilot-args`, and the legacy idle timers remain settings for the separate legacy adapter. Select `--provider-output-mode legacy` to return to that adapter; switching adapters does not migrate their session stores.
264
+
265
+ For positional `start` and full `start-managed`, an explicit CLI flag overrides its environment variable. An omitted flag preserves the environment value. Repeating a full managed start preserves a saved Agent's output mode and native executable unless the flag or environment variable explicitly supplies a replacement. Bare `start-managed <serverUrl>` resumes the saved configuration and rejects Agent flags.
266
+
267
+ File-based startup owns its provider settings: `start --config` rejects single-agent flags, and ambient `PROVIDER_OUTPUT_MODE` / `NATIVE_PROVIDER_COMMAND` do not override YAML. Agent entries override host `defaults`. The same `providerOutputMode` and `nativeProviderCommand` fields work in JSON specs supplied to `generate-config` and `apply-managed`; neither command needs separate mode flags.
268
+
269
+ ```yaml
270
+ # agents-host.yaml
271
+ borgeeBaseUrl: https://your-borgee-server
272
+ defaults:
273
+ providerOutputMode: legacy
274
+ ```
275
+
276
+ ```yaml
277
+ # agents/copilot.yaml
278
+ key: copilot
279
+ name: Copilot
280
+ apiKey: bgr_xxxxxxxx
281
+ provider: copilot
282
+ providerOutputMode: normalized
283
+ ```
284
+
285
+ The normalized Copilot provider owns its stdio runtime and closes it with the Host lifecycle. Its available controls come from negotiated native capabilities; selecting normalized output does not enable independent native Session management for Copilot.
286
+
287
+ ## Normalized Codex connections
288
+
289
+ Normalized Codex uses `stdio` mode by default: the Host owns a native `codex app-server` process without requiring a shared daemon or shared trust. The mode may also be selected explicitly:
290
+
291
+ ```bash
292
+ agents-host start https://your-borgee-server bgr_xxxxxxxx --provider codex --provider-output-mode normalized
293
+ agents-host start-managed https://your-borgee-server bgr_xxxxxxxx --provider codex --provider-output-mode normalized --codex-connection-mode stdio
294
+ ```
295
+
296
+ The environment entrypoint accepts `CODEX_CONNECTION_MODE=shared|stdio`; local YAML and generated JSON accept `codexConnectionMode: shared|stdio` in host defaults or Agent entries. CLI flags override environment values, Agent entries override host defaults, and repeated managed startup preserves the saved mode unless explicitly replaced. A mode change restarts that Agent's Host instance while retaining its state root and native session mappings. `--native-provider-command /absolute/path/to/codex` selects the normalized executable; legacy Codex keeps its separate ACP command and ignores native connection selection.
297
+
298
+ Both connection modes preserve the configured native approval and sandbox policy. Choosing stdio changes process ownership and transport; it does not grant shared-daemon trust or impose additional permission restrictions. A configured `codexSharedSocketPath` / `CODEX_SHARED_SOCKET_PATH` is rejected with default or explicit normalized stdio. Neither socket configuration nor shared trust selects shared mode implicitly; socket-only configurations must add `codexConnectionMode: shared` or `CODEX_CONNECTION_MODE=shared`. In mixed-mode local configurations, put shared socket overrides on the shared Agents rather than in host defaults; an Agent cannot clear an inherited socket with `null` or an empty value.
299
+
300
+ For shared mode, prepare a daemon with a compatible installed Codex CLI before starting the Host. Select its absolute executable path explicitly; `app-server daemon start` is available in Codex 0.154.0:
301
+
302
+ ```bash
303
+ CODEX_BIN=/absolute/path/to/codex
304
+ "$CODEX_BIN" app-server daemon start
305
+ BORGEE_BASE_URL=https://your-borgee-server.example \
306
+ BORGEE_AGENT_API_KEY=your-agent-key \
307
+ RUNTIME_PROVIDER=codex \
308
+ PROVIDER_OUTPUT_MODE=normalized \
309
+ CODEX_CONNECTION_MODE=shared \
310
+ CODEX_TRUST_SHARED=true \
311
+ node packages/agents-host/dist/index.js
312
+ ```
313
+
314
+ Use the same `CODEX_HOME` as the local native clients. The default control socket is `$CODEX_HOME/app-server-control/app-server-control.sock`, with `~/.codex` as the native home fallback. Set `CODEX_SHARED_SOCKET_PATH` to an absolute socket path when using another daemon. Local YAML accepts `providerOutputMode: normalized`, `codexConnectionMode: shared`, `codexTrustShared: true`, and `codexSharedSocketPath` in defaults or the Agent entry.
315
+
316
+ Explicit New allocates an exclusive `yyMMdd/HHmmss${rand}` directory beneath `sessionWorkspaceRoot`, using the Host machine's local time. Configure this value in local YAML defaults or the Agent entry, or set `SESSION_WORKSPACE_ROOT` for the environment entrypoint. Discovery is not restricted to this root. Management requires Agent Owner authority, and mutations require a writable channel; independent Sessions never replace the ordinary Messages default. Ownership claims use the existing atomic file-store implementation under `independent-sessions/codex.json`. Only committed claims survive restart; a native creation whose claim cannot be saved stays unconfirmed. Reopening a Session does not create a fallback identity or submit an initial message, and successful admission alone does not guarantee empty-session persistence across native daemon restart.
317
+
318
+ Trust grants access under the daemon's existing native approval and sandbox policy. Without explicit local trust the Host rejects shared mode; it never falls back to stdio. Closing a shared attachment leaves the daemon and other clients running. A lost shared socket suspends controls while the provider reconnects and restores the same native Session from authoritative state; uncertain inputs are not replayed. Stdio process loss stops observation and rejects pending operations without automatically replacing the process or resubmitting input. Legacy mode retains its existing process and permission behavior.
247
319
 
248
320
  ## Local-config mode
249
321
 
@@ -500,7 +572,7 @@ We keep no transcript or history store of our own — only the native session id
500
572
 
501
573
  ### Idle adapter shutdown
502
574
 
503
- Each of those subprocesses is shut down once every channel it hosts has been idle for `PROVIDER_IDLE_SHUTDOWN_MINUTES` (default `10`), and a fresh one is spawned lazily on the next turn. "Idle" means the host has no active turn, no queued turn, no provider session start in flight, and nothing still being processed for any channel of that agent; a turn that arrives mid-shutdown waits for the teardown and then starts the replacement rather than failing. Only the provider subprocess is recycled — the agent stays connected to Borgee, the loopback gateway keeps running, and the agents-host process itself is untouched.
575
+ In legacy mode, each of those subprocesses is shut down once every channel it hosts has been idle for `PROVIDER_IDLE_SHUTDOWN_MINUTES` (default `10`), and a fresh one is spawned lazily on the next turn. "Idle" means the host has no active turn, no queued turn, no provider session start in flight, and nothing still being processed for any channel of that agent; a turn that arrives mid-shutdown waits for the teardown and then starts the replacement rather than failing. Only the provider subprocess is recycled — the agent stays connected to Borgee, the loopback gateway keeps running, and the agents-host process itself is untouched.
504
576
 
505
577
  Conversation memory normally survives the recycle. Before the process goes away the host closes each live provider session, and on the next turn it reopens the persisted session id against the CLI's on-disk store — Claude and Codex through ACP `session/resume`, Copilot through SDK session resume. This is the same restore path a host restart takes, and its ordinary outcome is that the model still remembers the conversation.
506
578
 
@@ -9,6 +9,8 @@ import type { AgentsHostConfig } from './types.js';
9
9
  */
10
10
  export declare class AgentsHost {
11
11
  private readonly config;
12
+ private executionTelemetry?;
13
+ private readonly normalizedStateOwners;
12
14
  private readonly runtime;
13
15
  private readonly provider;
14
16
  private readonly borgee;
@@ -64,6 +66,7 @@ export declare class AgentsHost {
64
66
  private runClaimedExecution;
65
67
  private runMessageWithExecutionTelemetry;
66
68
  private createExecutionTelemetryReporter;
69
+ private handleSelectedSessionMessage;
67
70
  private dispatchAutonomousReply;
68
71
  private handleLegacyMessage;
69
72
  private handleCollaborationMessage;
@@ -145,6 +148,11 @@ export declare class AgentsHost {
145
148
  private updateMissedCollaborationDiagnostic;
146
149
  private noteWakeSuppressedAttentionPolicy;
147
150
  private runUngatedTurn;
151
+ private handleSessionControl;
152
+ private handleRetainedControl;
153
+ private handleNativeInput;
154
+ private postTurnReply;
155
+ private beginNormalizedExecution;
148
156
  private executeTurn;
149
157
  /**
150
158
  * Opens this turn's report on the activity rail.