@north-light/crouter 0.3.318 → 0.3.319
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/README.md +0 -3
- package/dist/api/client.js +2 -912
- package/dist/api/dto/attach.js +0 -13
- package/dist/api/dto/bash-jobs.js +1 -9
- package/dist/api/dto/broker-ops.js +0 -6
- package/dist/api/dto/broker.js +0 -20
- package/dist/api/dto/canvas.js +0 -2
- package/dist/api/dto/chat-inventory.js +0 -11
- package/dist/api/dto/common.js +1 -15
- package/dist/api/dto/config.js +0 -3
- package/dist/api/dto/crons.js +1 -10
- package/dist/api/dto/files.js +0 -7
- package/dist/api/dto/focus.js +0 -10
- package/dist/api/dto/health.js +0 -2
- package/dist/api/dto/human-requests.js +0 -4
- package/dist/api/dto/human.js +0 -4
- package/dist/api/dto/inbox.js +0 -4
- package/dist/api/dto/lifecycle.js +0 -3
- package/dist/api/dto/mail.js +0 -1
- package/dist/api/dto/memory.js +0 -6
- package/dist/api/dto/messages.js +0 -2
- package/dist/api/dto/model-config.js +0 -1
- package/dist/api/dto/modelauth.js +0 -4
- package/dist/api/dto/node-outcomes.js +0 -2
- package/dist/api/dto/nodes.js +0 -3
- package/dist/api/dto/profiles.js +1 -4
- package/dist/api/dto/recovery.js +0 -1
- package/dist/api/dto/reports.js +0 -2
- package/dist/api/dto/review-comments.js +0 -5
- package/dist/api/dto/reviews.js +0 -5
- package/dist/api/dto/subscriptions.js +0 -2
- package/dist/api/dto/worktree.js +0 -6
- package/dist/api/errors.js +1 -40
- package/dist/api/index.js +1 -33
- package/dist/api/plugin-manifest-schema.js +0 -23
- package/dist/api/routes.js +1 -147
- package/dist/build-root.js +1 -198
- package/dist/cli.js +3 -99
- package/dist/clients/attach/ansi-cells.js +1 -137
- package/dist/clients/attach/chrome/bash-jobs.js +1 -31
- package/dist/clients/attach/chrome/canvas-panels.js +1 -194
- package/dist/clients/attach/chrome/completion-bell.js +1 -89
- package/dist/clients/attach/chrome/cron-wait.js +1 -34
- package/dist/clients/attach/chrome/git-info.js +2 -44
- package/dist/clients/attach/chrome/header.js +1 -30
- package/dist/clients/attach/chrome/inbox-strip.js +1 -199
- package/dist/clients/attach/chrome/recap.js +1 -19
- package/dist/clients/attach/chrome/review-wait.js +1 -22
- package/dist/clients/attach/chrome/roster.js +4 -275
- package/dist/clients/attach/chrome/status-line.js +1 -117
- package/dist/clients/attach/chrome/ticket-panel.js +1 -280
- package/dist/clients/attach/chrome/widgets.js +1 -51
- package/dist/clients/attach/command.js +1 -107
- package/dist/clients/attach/config.js +1 -274
- package/dist/clients/attach/input/capabilities.js +1 -104
- package/dist/clients/attach/input/clipboard-image.js +3 -220
- package/dist/clients/attach/input/completion-frecency.js +1 -141
- package/dist/clients/attach/input/controller.js +7 -377
- package/dist/clients/attach/input/overlay-owner.js +1 -199
- package/dist/clients/attach/input/ref-autocomplete.js +2 -176
- package/dist/clients/attach/input/titled-editor.js +4 -859
- package/dist/clients/attach/overlays/auth.js +2 -271
- package/dist/clients/attach/overlays/dialogs.js +2 -102
- package/dist/clients/attach/overlays/file-review.js +2 -128
- package/dist/clients/attach/overlays/graph.js +1 -661
- package/dist/clients/attach/overlays/help.js +1 -211
- package/dist/clients/attach/overlays/mcp.js +1 -302
- package/dist/clients/attach/overlays/pickers.js +1 -163
- package/dist/clients/attach/render/activity-slot.js +1 -13
- package/dist/clients/attach/render/assistant-message.js +1 -56
- package/dist/clients/attach/render/card-presentation.js +5 -218
- package/dist/clients/attach/render/chat-view.js +5 -1708
- package/dist/clients/attach/render/condensed-history.js +1 -60
- package/dist/clients/attach/render/context-message.js +1 -63
- package/dist/clients/attach/render/crtr-output.js +17 -905
- package/dist/clients/attach/render/diagram.js +7 -111
- package/dist/clients/attach/render/edit-diff.js +5 -304
- package/dist/clients/attach/render/glyph-codepoints.js +1 -42
- package/dist/clients/attach/render/group-activity.js +2 -263
- package/dist/clients/attach/render/group-recap.js +1 -152
- package/dist/clients/attach/render/markdown-source.js +5 -266
- package/dist/clients/attach/render/measured-container.js +1 -322
- package/dist/clients/attach/render/page-block.js +1 -183
- package/dist/clients/attach/render/scroll-animation.js +1 -80
- package/dist/clients/attach/render/tool-calls.js +3 -361
- package/dist/clients/attach/render/transcript-copy.js +2 -81
- package/dist/clients/attach/render/transcript-search.js +1 -152
- package/dist/clients/attach/render/viewport.js +1 -184
- package/dist/clients/attach/session/banner.js +1 -29
- package/dist/clients/attach/session/bindings.js +1 -71
- package/dist/clients/attach/session/chrome-refresh.js +1 -94
- package/dist/clients/attach/session/connection.js +1 -186
- package/dist/clients/attach/session/context.js +0 -16
- package/dist/clients/attach/session/editor-frame.js +1 -142
- package/dist/clients/attach/session/editor-inventory.js +6 -160
- package/dist/clients/attach/session/file-links.js +1 -68
- package/dist/clients/attach/session/focus-events.js +1 -12
- package/dist/clients/attach/session/frame.js +1 -214
- package/dist/clients/attach/session/frames.js +1 -188
- package/dist/clients/attach/session/identity.js +1 -26
- package/dist/clients/attach/session/input-wiring.js +1 -140
- package/dist/clients/attach/session/invariant.js +1 -15
- package/dist/clients/attach/session/keys.js +1 -77
- package/dist/clients/attach/session/layout.js +1 -59
- package/dist/clients/attach/session/mouse.js +1 -78
- package/dist/clients/attach/session/pane-focus.js +1 -42
- package/dist/clients/attach/session/pane-tag.js +1 -112
- package/dist/clients/attach/session/pi-assets.js +1 -24
- package/dist/clients/attach/session/pi-oauth-flows.js +1 -21
- package/dist/clients/attach/session/profile-files.js +1 -228
- package/dist/clients/attach/session/reconnect.js +1 -175
- package/dist/clients/attach/session/selection.js +3 -108
- package/dist/clients/attach/session/state-sync.js +1 -67
- package/dist/clients/attach/session/surface-frame.js +1 -73
- package/dist/clients/attach/session/surface-host.js +1 -255
- package/dist/clients/attach/session/teardown.js +5 -94
- package/dist/clients/attach/session/transcript-search.js +3 -151
- package/dist/clients/attach/session/whip-achievements.js +2 -145
- package/dist/clients/attach/session/whip.js +1 -362
- package/dist/clients/attach/slash/dispatch.js +1 -706
- package/dist/clients/attach/slash/prompt-preview.js +1 -121
- package/dist/clients/attach/viewer.js +441 -441
- package/dist/clients/conversation/projection.js +1 -324
- package/dist/clients/conversation/submit.js +1 -51
- package/dist/clients/inbox/controller.js +1 -701
- package/dist/clients/inbox/dto-adapt.js +1 -93
- package/dist/clients/inbox/layout.js +1 -9
- package/dist/clients/inbox/page-adapter.js +1 -55
- package/dist/clients/inbox/resolve.js +1 -35
- package/dist/clients/inbox/review/anchors.js +1 -89
- package/dist/clients/inbox/review/comments-client.js +1 -98
- package/dist/clients/inbox/review/companion-pane.js +1 -82
- package/dist/clients/inbox/review/document-surface.js +2 -1188
- package/dist/clients/inbox/review/frame.js +1 -216
- package/dist/clients/inbox/review/keys.js +1 -123
- package/dist/clients/inbox/review/launch.js +1 -151
- package/dist/clients/inbox/review/live-source.js +1 -160
- package/dist/clients/inbox/review/nvim.js +1 -44
- package/dist/clients/inbox/review/remap.js +1 -157
- package/dist/clients/inbox/review/review-client.js +1 -123
- package/dist/clients/inbox/review/roundtrip.js +3 -36
- package/dist/clients/inbox/review/state.js +4 -315
- package/dist/clients/inbox/review-adapter.js +1 -43
- package/dist/clients/inbox/surface.js +1 -152
- package/dist/clients/inbox/tui/ansi.js +3 -321
- package/dist/clients/inbox/tui/input.js +5 -392
- package/dist/clients/inbox/tui/keys.js +1 -104
- package/dist/clients/inbox/tui/page-body.js +1 -66
- package/dist/clients/inbox/tui/panel.js +1 -84
- package/dist/clients/inbox/tui/render.js +2 -368
- package/dist/clients/inbox/tui/slots.js +3 -134
- package/dist/clients/inbox/tui/types.js +0 -1
- package/dist/clients/inbox/tui.js +1 -86
- package/dist/clients/surfaces/host.js +0 -1
- package/dist/commands/api-client.js +4 -290
- package/dist/commands/attention.js +1 -215
- package/dist/commands/canvas-browse.js +1 -70
- package/dist/commands/canvas-config.js +2 -192
- package/dist/commands/canvas-history/grep.js +7 -85
- package/dist/commands/canvas-history/read.js +3 -50
- package/dist/commands/canvas-history/search.js +10 -99
- package/dist/commands/canvas-history/shared.js +1 -139
- package/dist/commands/canvas-history/stats.js +6 -68
- package/dist/commands/canvas-history.js +1 -32
- package/dist/commands/canvas-issue.js +14 -149
- package/dist/commands/canvas-prune.js +1 -108
- package/dist/commands/canvas-roster.js +1 -69
- package/dist/commands/canvas-snapshot.js +1 -34
- package/dist/commands/canvas-use.js +1 -61
- package/dist/commands/canvas.js +1 -49
- package/dist/commands/chord.js +1 -241
- package/dist/commands/cron.js +11 -534
- package/dist/commands/dashboard.js +1 -85
- package/dist/commands/human/components.js +3 -77
- package/dist/commands/human/feedback.js +1 -112
- package/dist/commands/human/prompts.js +1 -331
- package/dist/commands/human/queue.js +1 -191
- package/dist/commands/human/request.js +1 -266
- package/dist/commands/human/review.js +1 -288
- package/dist/commands/human/shared.js +1 -67
- package/dist/commands/human.js +4 -60
- package/dist/commands/memory/delete.js +1 -100
- package/dist/commands/memory/edit.js +21 -219
- package/dist/commands/memory/find.js +2 -244
- package/dist/commands/memory/history.js +5 -199
- package/dist/commands/memory/lint.js +1 -107
- package/dist/commands/memory/list.js +1 -142
- package/dist/commands/memory/move.js +1 -223
- package/dist/commands/memory/origin.js +1 -130
- package/dist/commands/memory/read.js +6 -232
- package/dist/commands/memory/shared.js +12 -802
- package/dist/commands/memory/write.js +13 -235
- package/dist/commands/memory.js +1 -30
- package/dist/commands/node/bash.js +5 -245
- package/dist/commands/node/create.js +3 -332
- package/dist/commands/node/inspect.js +12 -300
- package/dist/commands/node/lifecycle.js +2 -453
- package/dist/commands/node/message.js +1 -161
- package/dist/commands/node/outcome.js +4 -134
- package/dist/commands/node/pyramid.js +2 -79
- package/dist/commands/node/subscription.js +1 -78
- package/dist/commands/node/wait.js +7 -163
- package/dist/commands/node-context.js +2 -159
- package/dist/commands/node-inspect-artifacts.js +8 -109
- package/dist/commands/node-lifecycle-revive.js +1 -217
- package/dist/commands/node-snapshot.js +1 -37
- package/dist/commands/node-transcript.js +1 -62
- package/dist/commands/node-worktree.js +1 -138
- package/dist/commands/node.js +1 -29
- package/dist/commands/pkg/browse/actions.js +1 -198
- package/dist/commands/pkg/browse/catalog.js +1 -466
- package/dist/commands/pkg/browse/command-view.js +1 -191
- package/dist/commands/pkg/browse/detail-panel.js +1 -402
- package/dist/commands/pkg/browse/doc-view.js +1 -89
- package/dist/commands/pkg/browse/list-panel.js +2 -168
- package/dist/commands/pkg/browse/model.js +1 -36
- package/dist/commands/pkg/browse/shell.js +1 -640
- package/dist/commands/pkg/browse.js +1 -27
- package/dist/commands/pkg/market-inspect.js +1 -141
- package/dist/commands/pkg/market-manage.js +1 -327
- package/dist/commands/pkg/market.js +1 -14
- package/dist/commands/pkg/plugin-inspect.js +1 -168
- package/dist/commands/pkg/plugin-manage.js +17 -1109
- package/dist/commands/pkg/plugin.js +1 -14
- package/dist/commands/pkg/shared.js +1 -62
- package/dist/commands/pkg.js +1 -21
- package/dist/commands/profile/default.js +1 -139
- package/dist/commands/profile/delete.js +1 -66
- package/dist/commands/profile/env.js +3 -188
- package/dist/commands/profile/kind.js +2 -35
- package/dist/commands/profile/list.js +1 -43
- package/dist/commands/profile/meta.js +1 -67
- package/dist/commands/profile/new.js +1 -115
- package/dist/commands/profile/pause.js +1 -59
- package/dist/commands/profile/project.js +1 -113
- package/dist/commands/profile/rename.js +1 -38
- package/dist/commands/profile/show.js +1 -52
- package/dist/commands/profile.js +1 -35
- package/dist/commands/push.js +9 -265
- package/dist/commands/revive.js +10 -181
- package/dist/commands/surface/node/cycle.js +1 -83
- package/dist/commands/surface/node/focus.js +1 -81
- package/dist/commands/surface/node/id.js +1 -38
- package/dist/commands/surface/node/pin.js +1 -42
- package/dist/commands/surface/node/placement.js +1 -134
- package/dist/commands/surface-edit.js +1 -157
- package/dist/commands/surface-inbox.js +1 -98
- package/dist/commands/surface-inspect.js +1 -39
- package/dist/commands/surface-node.js +1 -19
- package/dist/commands/surface-reload.js +2 -134
- package/dist/commands/surface-tmux-spread.js +1 -214
- package/dist/commands/surface.js +1 -28
- package/dist/commands/sys/branch.js +1 -19
- package/dist/commands/sys/config.js +1 -353
- package/dist/commands/sys/context/admin/actions.js +2 -246
- package/dist/commands/sys/context/admin/detail-panel.js +1 -247
- package/dist/commands/sys/context/admin/docs-panel.js +1 -191
- package/dist/commands/sys/context/admin/list-view.js +1 -183
- package/dist/commands/sys/context/admin/model.js +1 -229
- package/dist/commands/sys/context/admin/rail-panel.js +1 -227
- package/dist/commands/sys/context/admin/read-view.js +2 -194
- package/dist/commands/sys/context/admin/shell.js +1 -910
- package/dist/commands/sys/context/admin.js +2 -126
- package/dist/commands/sys/context/doc.js +3 -197
- package/dist/commands/sys/context/prompt-review.js +11 -291
- package/dist/commands/sys/context/resolve.js +10 -489
- package/dist/commands/sys/context/sysprompt.js +5 -96
- package/dist/commands/sys/context.js +1 -20
- package/dist/commands/sys/daemon.js +1 -313
- package/dist/commands/sys/doctor.js +1 -617
- package/dist/commands/sys/feedback.js +7 -228
- package/dist/commands/sys/logs.js +3 -129
- package/dist/commands/sys/migrate.js +1 -94
- package/dist/commands/sys/panels/broker-limits-panel.js +2 -110
- package/dist/commands/sys/panels/dependencies-panel.js +1 -80
- package/dist/commands/sys/panels/keybindings-panel.js +1 -703
- package/dist/commands/sys/panels/models-panel.js +1 -1133
- package/dist/commands/sys/panels/plugins-panel.js +1 -80
- package/dist/commands/sys/panels/prefs-panel.js +1 -85
- package/dist/commands/sys/panels/profiles-panel.js +1 -601
- package/dist/commands/sys/panels/provider-panel.js +1 -538
- package/dist/commands/sys/settings-shell.js +1 -400
- package/dist/commands/sys/settings.js +1 -46
- package/dist/commands/sys/setup-core.js +6 -579
- package/dist/commands/sys/setup-settings-runner.js +1 -16
- package/dist/commands/sys/setup-wizard.js +1 -279
- package/dist/commands/sys/setup.js +1 -34
- package/dist/commands/sys/shared.js +1 -81
- package/dist/commands/sys/support/prepare.js +3 -239
- package/dist/commands/sys/support/submit.js +6 -524
- package/dist/commands/sys/support.js +1 -18
- package/dist/commands/sys/sync-deps.js +15 -498
- package/dist/commands/sys/sync-project-guidance.js +4 -481
- package/dist/commands/sys/sync-shared.js +1 -49
- package/dist/commands/sys/sync-skills.js +2 -311
- package/dist/commands/sys/sync.js +1 -18
- package/dist/commands/sys/update.js +1 -147
- package/dist/commands/sys/worktrees.js +5 -53
- package/dist/commands/sys.js +1 -18
- package/dist/core/activity-signal.js +2 -38
- package/dist/core/asset-root.js +1 -18
- package/dist/core/auth-file.js +2 -179
- package/dist/core/auth-interaction.js +3 -94
- package/dist/core/auto-update.js +4 -94
- package/dist/core/bash-guard.js +11 -393
- package/dist/core/bash-jobs.js +7 -411
- package/dist/core/bootstrap.js +2 -53
- package/dist/core/broker-client/client.js +1 -184
- package/dist/core/broker-client/index.js +1 -13
- package/dist/core/broker-client/transport-relay.js +1 -157
- package/dist/core/broker-client/transport-socket.js +1 -179
- package/dist/core/broker-client/transport.js +1 -26
- package/dist/core/canvas/attention.js +1 -47
- package/dist/core/canvas/boot-id.js +1 -26
- package/dist/core/canvas/boot.js +1 -186
- package/dist/core/canvas/browse/app.js +3 -919
- package/dist/core/canvas/browse/model.js +1 -477
- package/dist/core/canvas/browse/pins.js +1 -29
- package/dist/core/canvas/browse/render.js +3 -1055
- package/dist/core/canvas/canvas.js +15 -922
- package/dist/core/canvas/crons.js +11 -481
- package/dist/core/canvas/daemon-owner.js +2 -146
- package/dist/core/canvas/db.js +2 -100
- package/dist/core/canvas/deliveries.js +22 -283
- package/dist/core/canvas/delivery-contract.js +1 -8
- package/dist/core/canvas/executions.js +1 -68
- package/dist/core/canvas/extensions.js +1 -83
- package/dist/core/canvas/focuses.js +1 -77
- package/dist/core/canvas/history.js +24 -860
- package/dist/core/canvas/index.js +1 -15
- package/dist/core/canvas/install-id.js +1 -84
- package/dist/core/canvas/labels.js +1 -43
- package/dist/core/canvas/meta-file.js +1 -89
- package/dist/core/canvas/migrations.js +41 -1150
- package/dist/core/canvas/nav-model.js +1 -231
- package/dist/core/canvas/nav-render.js +1 -260
- package/dist/core/canvas/node-order.js +1 -37
- package/dist/core/canvas/node-recap.js +2 -67
- package/dist/core/canvas/node-sql-migration.js +2 -209
- package/dist/core/canvas/paths.js +1 -153
- package/dist/core/canvas/pid.js +4 -683
- package/dist/core/canvas/recovery.js +3 -565
- package/dist/core/canvas/remote-canvas-source.js +1 -288
- package/dist/core/canvas/remote-transport.js +1 -57
- package/dist/core/canvas/render-source.js +10 -635
- package/dist/core/canvas/sessions.js +1 -78
- package/dist/core/canvas/source.js +1 -47
- package/dist/core/canvas/status-glyph.js +1 -132
- package/dist/core/canvas/telemetry.js +1 -35
- package/dist/core/canvas/types.js +1 -6
- package/dist/core/canvas/waits.js +4 -68
- package/dist/core/canvas/worktrees.js +1 -93
- package/dist/core/clipboard-text.js +1 -57
- package/dist/core/command-hooks/artifact.js +1 -145
- package/dist/core/command-hooks/catalog.js +1 -38
- package/dist/core/command-hooks/compose.js +1 -99
- package/dist/core/command-hooks/discovery.js +1 -228
- package/dist/core/command-hooks/help.js +1 -18
- package/dist/core/command-hooks/index.js +1 -7
- package/dist/core/command-hooks/lifecycle-catalog.js +1 -9
- package/dist/core/command-hooks/lifecycle-create.js +1 -51
- package/dist/core/command-hooks/report.js +1 -28
- package/dist/core/command-hooks/schema.js +1 -157
- package/dist/core/command-hooks/transport/exec-invoke.js +1 -276
- package/dist/core/command-hooks/transport/exec-lifecycle.js +1 -211
- package/dist/core/command-manifests/manifest.js +1 -324
- package/dist/core/command-manifests/registry.js +1 -118
- package/dist/core/command-manifests/schema.js +1 -736
- package/dist/core/command-plugins/bundle.js +1 -261
- package/dist/core/command-plugins/compose.js +1 -65
- package/dist/core/command-plugins/discovery.js +1 -245
- package/dist/core/command-plugins/endpoint.js +1 -48
- package/dist/core/command-plugins/extensions.js +1 -166
- package/dist/core/command-plugins/help-addenda.js +1 -44
- package/dist/core/command-plugins/presence.js +1 -17
- package/dist/core/command-plugins/revalidate.js +2 -152
- package/dist/core/command-plugins/transport/exec-invoke.js +1 -215
- package/dist/core/command-plugins/transport/http-fetch.js +1 -68
- package/dist/core/command-plugins/transport/http-invoke.js +3 -546
- package/dist/core/command.js +10 -739
- package/dist/core/config.js +1 -1059
- package/dist/core/document-lines.js +3 -6
- package/dist/core/env-name.js +1 -9
- package/dist/core/errors.js +1 -52
- package/dist/core/events/emit.js +1 -17
- package/dist/core/events/envelope.js +1 -84
- package/dist/core/events/errors.js +1 -69
- package/dist/core/events/index.js +1 -4
- package/dist/core/events/operation-id.js +1 -24
- package/dist/core/events/read.js +1 -623
- package/dist/core/events/serialize.js +1 -199
- package/dist/core/events/source.js +1 -31
- package/dist/core/events/types.js +1 -11
- package/dist/core/exclusive-lock.js +1 -197
- package/dist/core/fault-classifier.js +1 -96
- package/dist/core/feed/feed.js +7 -202
- package/dist/core/feed/inbox-migrate.js +3 -135
- package/dist/core/feed/inbox.js +10 -122
- package/dist/core/feed/messages.js +6 -212
- package/dist/core/frontmatter.js +1 -35
- package/dist/core/fs-utils.js +3 -202
- package/dist/core/git.js +2 -103
- package/dist/core/help.js +9 -310
- package/dist/core/host-exports/builtins.js +9 -68
- package/dist/core/host-exports/export.js +3 -124
- package/dist/core/human/action-binding.js +1 -40
- package/dist/core/human/answer-text.js +5 -100
- package/dist/core/human/answer.js +1 -119
- package/dist/core/human/claim.js +3 -67
- package/dist/core/human/completion.js +1 -27
- package/dist/core/human/component-docs.js +78 -272
- package/dist/core/human/convention.js +2 -82
- package/dist/core/human/feedback-companion.js +1 -106
- package/dist/core/human/feedback.js +1 -88
- package/dist/core/human/page-authoring.js +1 -19
- package/dist/core/human/page-catalog.js +1 -172
- package/dist/core/human/page-errors.js +1 -7
- package/dist/core/human/page-eval.js +1 -125
- package/dist/core/human/page-html-markdown.js +8 -260
- package/dist/core/human/page-markdown.js +17 -295
- package/dist/core/human/page-schema.js +1 -373
- package/dist/core/human/page-synth.js +8 -27
- package/dist/core/human/page.js +1 -198
- package/dist/core/human/requests.js +15 -466
- package/dist/core/human/review-schema.js +1 -34
- package/dist/core/human/root.js +1 -11
- package/dist/core/human/scan.js +1 -69
- package/dist/core/human/summary.js +1 -5
- package/dist/core/human/tickets.js +1 -171
- package/dist/core/human/types.js +0 -1
- package/dist/core/human/visible-paths.js +1 -77
- package/dist/core/human-actions.js +1 -101
- package/dist/core/inspector/chrome.js +1 -14
- package/dist/core/inspector/contract.js +0 -1
- package/dist/core/inspector/core.js +2 -295
- package/dist/core/inspector/host.js +4 -538
- package/dist/core/inspector/model.js +2 -226
- package/dist/core/inspector/text.js +6 -45
- package/dist/core/inspector/transport.js +1 -36
- package/dist/core/inspector/tui.js +2 -295
- package/dist/core/installed-plugins.js +1 -78
- package/dist/core/io.js +7 -356
- package/dist/core/keybindings/attach-control.js +1 -42
- package/dist/core/keybindings/background-bash.js +1 -33
- package/dist/core/keybindings/catalog.js +1 -256
- package/dist/core/keybindings/inbox.js +1 -25
- package/dist/core/keybindings/index.js +1 -7
- package/dist/core/keybindings/match.js +1 -127
- package/dist/core/keybindings/persistence.js +1 -49
- package/dist/core/keybindings/resolve.js +1 -348
- package/dist/core/keybindings/types.js +0 -1
- package/dist/core/locked-file.js +1 -118
- package/dist/core/log.js +3 -27
- package/dist/core/manifest-recovery.js +1 -72
- package/dist/core/manifest-stale.js +1 -39
- package/dist/core/manifest.js +1 -20
- package/dist/core/memory/doc-link-grammar.js +2 -109
- package/dist/core/memory/extensions.js +1 -221
- package/dist/core/memory/history.js +6 -268
- package/dist/core/memory/identity.js +1 -181
- package/dist/core/memory/inline-ref-grammar.js +1 -98
- package/dist/core/memory/inline-ref-guidance.js +2 -35
- package/dist/core/memory/inline-ref-inventory.js +1 -59
- package/dist/core/memory/lint.js +2 -671
- package/dist/core/memory/project-namespace.js +2 -85
- package/dist/core/memory/repository-association.js +1 -129
- package/dist/core/memory/tree.js +1 -93
- package/dist/core/memory-resolver.js +2 -611
- package/dist/core/model-config.js +1 -107
- package/dist/core/model-routes.js +1 -201
- package/dist/core/nested-stores.js +2 -166
- package/dist/core/output.js +7 -99
- package/dist/core/pagination.js +1 -88
- package/dist/core/plugin-swap-lock.js +1 -31
- package/dist/core/pool-credential-store.js +1 -116
- package/dist/core/predicate.js +1 -191
- package/dist/core/preview-registry.js +2 -411
- package/dist/core/preview-result-path.js +1 -26
- package/dist/core/profiles/default-binding.js +1 -24
- package/dist/core/profiles/deletion-reservation.js +1 -42
- package/dist/core/profiles/env-store.js +2 -162
- package/dist/core/profiles/fuzzy-match.js +1 -92
- package/dist/core/profiles/manifest.js +1 -574
- package/dist/core/profiles/select.js +35 -741
- package/dist/core/profiles/state-block.js +3 -17
- package/dist/core/provider-error-recognition.js +1 -74
- package/dist/core/provider-failure.js +1 -86
- package/dist/core/provider-management.js +1 -22
- package/dist/core/remote-canvas-target.js +1 -30
- package/dist/core/render.js +18 -138
- package/dist/core/resolver.js +1 -111
- package/dist/core/review/birth.js +1 -52
- package/dist/core/review/comments.js +5 -279
- package/dist/core/review/companion.js +1 -215
- package/dist/core/review/document.js +2 -138
- package/dist/core/review/project.js +1 -36
- package/dist/core/review/realize.js +1 -71
- package/dist/core/review/remap.js +4 -141
- package/dist/core/review/signal.js +1 -12
- package/dist/core/review/stage.js +1 -184
- package/dist/core/review/store.js +1 -168
- package/dist/core/review/types.js +1 -23
- package/dist/core/runtime/advertised-command-invocation.js +1 -233
- package/dist/core/runtime/auth-reload.js +1 -67
- package/dist/core/runtime/banner.js +1 -51
- package/dist/core/runtime/bearings-render.js +18 -250
- package/dist/core/runtime/bearings.js +7 -194
- package/dist/core/runtime/bin-contributions.js +2 -186
- package/dist/core/runtime/boot-root.js +1 -107
- package/dist/core/runtime/branded-host.js +2 -264
- package/dist/core/runtime/broker/auth-reload.js +1 -157
- package/dist/core/runtime/broker/client-registry.js +1 -179
- package/dist/core/runtime/broker/daemon-ops.js +1 -88
- package/dist/core/runtime/broker/engine-drive.js +1 -354
- package/dist/core/runtime/broker/engine-routing.js +1 -211
- package/dist/core/runtime/broker/event-projection.js +1 -193
- package/dist/core/runtime/broker/extension-abort.js +1 -36
- package/dist/core/runtime/broker/fault-retry.js +1 -588
- package/dist/core/runtime/broker/frame-client.js +1 -132
- package/dist/core/runtime/broker/frame-dispatch.js +1 -183
- package/dist/core/runtime/broker/frame-engine-control.js +1 -231
- package/dist/core/runtime/broker/frame-memory-refs.js +1 -41
- package/dist/core/runtime/broker/frame-model-query.js +1 -69
- package/dist/core/runtime/broker/frame-read.js +1 -116
- package/dist/core/runtime/broker/frame-replies.js +1 -64
- package/dist/core/runtime/broker/frame-session.js +4 -203
- package/dist/core/runtime/broker/held-deferred-inbox.js +1 -13
- package/dist/core/runtime/broker/inbox.js +13 -163
- package/dist/core/runtime/broker/node-named.js +1 -27
- package/dist/core/runtime/broker/read-ops.js +1 -171
- package/dist/core/runtime/broker/rebind.js +1 -318
- package/dist/core/runtime/broker/tool-groups.js +1 -246
- package/dist/core/runtime/broker/turn-admission.js +1 -31
- package/dist/core/runtime/broker/turn-ignition.js +1 -84
- package/dist/core/runtime/broker-cli.js +3 -81
- package/dist/core/runtime/broker-extension-render.js +5 -135
- package/dist/core/runtime/broker-inventory.js +1 -116
- package/dist/core/runtime/broker-persona-guidance.js +4 -154
- package/dist/core/runtime/broker-protocol.js +3 -152
- package/dist/core/runtime/broker-request.js +1 -85
- package/dist/core/runtime/broker-sdk.js +1 -129
- package/dist/core/runtime/broker.js +1 -1214
- package/dist/core/runtime/canvas-extensions.js +1 -96
- package/dist/core/runtime/chat-inventory-rows.js +1 -105
- package/dist/core/runtime/close.js +1 -265
- package/dist/core/runtime/command-expansion.js +9 -104
- package/dist/core/runtime/command-surface.js +1 -117
- package/dist/core/runtime/connectivity.js +1 -73
- package/dist/core/runtime/deliver-live.js +1 -88
- package/dist/core/runtime/fault-recovery.js +1 -83
- package/dist/core/runtime/fault.js +1 -17
- package/dist/core/runtime/fleet.js +1 -58
- package/dist/core/runtime/front-door-env.js +1 -16
- package/dist/core/runtime/front-door.js +7 -183
- package/dist/core/runtime/headless-pi.js +1 -161
- package/dist/core/runtime/host.js +1 -457
- package/dist/core/runtime/interactive-deliver.js +1 -51
- package/dist/core/runtime/invocation.js +0 -10
- package/dist/core/runtime/kickoff.js +30 -327
- package/dist/core/runtime/launch-config-worker.js +1 -12
- package/dist/core/runtime/launch-prompt.js +4 -13
- package/dist/core/runtime/launch-target.js +1 -55
- package/dist/core/runtime/launch.js +1 -483
- package/dist/core/runtime/lifecycle.js +2 -213
- package/dist/core/runtime/managed-provider-cooling.js +1 -62
- package/dist/core/runtime/memory.js +1 -17
- package/dist/core/runtime/model-registry.js +1 -13
- package/dist/core/runtime/model-selection.js +1 -135
- package/dist/core/runtime/model-swap.js +1 -86
- package/dist/core/runtime/naming.js +14 -298
- package/dist/core/runtime/nerd-font.js +2 -127
- package/dist/core/runtime/node-read.js +2 -386
- package/dist/core/runtime/nodes.js +1 -331
- package/dist/core/runtime/outcome-document.js +1 -97
- package/dist/core/runtime/package-health.js +4 -99
- package/dist/core/runtime/persona.js +2 -55
- package/dist/core/runtime/pi-cli.js +1 -65
- package/dist/core/runtime/pi-vendored.js +1 -66
- package/dist/core/runtime/placement-tmux.js +1 -81
- package/dist/core/runtime/placement.js +1 -386
- package/dist/core/runtime/promote.js +1 -174
- package/dist/core/runtime/prospective-inventory-cli.js +3 -61
- package/dist/core/runtime/prospective-inventory.js +2 -88
- package/dist/core/runtime/recap.js +27 -103
- package/dist/core/runtime/recycle.js +1 -190
- package/dist/core/runtime/reopen.js +1 -138
- package/dist/core/runtime/reset.js +1 -245
- package/dist/core/runtime/resume-root.js +10 -290
- package/dist/core/runtime/revive-all.js +1 -107
- package/dist/core/runtime/revive.js +4 -544
- package/dist/core/runtime/roadmap.js +4 -38
- package/dist/core/runtime/session-branch.js +1 -46
- package/dist/core/runtime/session-cycles.js +1 -110
- package/dist/core/runtime/session-list-cache.js +1 -406
- package/dist/core/runtime/session-visibility.js +1 -99
- package/dist/core/runtime/shell-expansion.js +9 -100
- package/dist/core/runtime/situational-context.js +2 -67
- package/dist/core/runtime/situational-live.js +1 -41
- package/dist/core/runtime/spawn-env.js +1 -255
- package/dist/core/runtime/spawn.js +3 -577
- package/dist/core/runtime/stamp/channel.js +1 -76
- package/dist/core/runtime/stamp/protocol.js +1 -113
- package/dist/core/runtime/stop-guard.js +7 -116
- package/dist/core/runtime/stop-signals.js +1 -46
- package/dist/core/runtime/stream-watchdog.js +1 -134
- package/dist/core/runtime/structured-output.js +4 -156
- package/dist/core/runtime/surface-bg.js +1 -85
- package/dist/core/runtime/tmux-bindings.js +4 -730
- package/dist/core/runtime/tmux-chrome.js +1 -5
- package/dist/core/runtime/tmux-driver.js +7 -637
- package/dist/core/runtime/tool-group-summary.js +6 -85
- package/dist/core/runtime/turn-visibility.js +1 -31
- package/dist/core/runtime/view-socket.js +1 -83
- package/dist/core/runtime/warm-pool.js +1 -395
- package/dist/core/scope.js +1 -254
- package/dist/core/scoped-state/db.js +1 -135
- package/dist/core/scoped-state/migrate.js +3 -181
- package/dist/core/scoped-state/paths.js +1 -27
- package/dist/core/scoped-state/profiles.js +1 -62
- package/dist/core/scoped-state/providers.js +1 -8
- package/dist/core/scoped-state/schema.js +3 -16
- package/dist/core/scoped-state/settings.js +1 -82
- package/dist/core/secrets.js +2 -55
- package/dist/core/self-update.js +1 -71
- package/dist/core/session-model/session-state.js +1 -180
- package/dist/core/shell-segments.js +4 -169
- package/dist/core/spawn.js +1 -26
- package/dist/core/stdout-errors.js +1 -14
- package/dist/core/subscription-state.js +3 -193
- package/dist/core/substrate/frontmatter-validation.js +1 -105
- package/dist/core/substrate/gate-explain.js +1 -424
- package/dist/core/substrate/gate.js +1 -26
- package/dist/core/substrate/index.js +1 -30
- package/dist/core/substrate/injected-store.js +1 -249
- package/dist/core/substrate/listings.js +1 -115
- package/dist/core/substrate/on-read-node.js +1 -36
- package/dist/core/substrate/on-read.js +9 -315
- package/dist/core/substrate/plan.js +1 -266
- package/dist/core/substrate/render-node.js +1 -30
- package/dist/core/substrate/render.js +65 -689
- package/dist/core/substrate/schema.js +1 -186
- package/dist/core/substrate/session-cache.js +1 -83
- package/dist/core/substrate/subject-fields.js +1 -35
- package/dist/core/substrate/subject.js +1 -47
- package/dist/core/substrate/surface-match.js +1 -242
- package/dist/core/termrender/code-doc.js +5 -92
- package/dist/core/termrender/display.js +2 -56
- package/dist/core/termrender/termrender.js +14 -719
- package/dist/core/termrender/version.js +1 -1
- package/dist/core/timing.js +2 -94
- package/dist/core/tui/draw.js +2 -378
- package/dist/core/tui/fuzzy.js +1 -38
- package/dist/core/tui/markdown.js +3 -407
- package/dist/core/tui/page-host.js +1 -74
- package/dist/core/tui/panel.js +1 -137
- package/dist/core/tui/terminal.js +2 -100
- package/dist/core/user-settings.js +1 -454
- package/dist/core/wake.js +1 -296
- package/dist/core/worktree-close.js +6 -228
- package/dist/core/worktree-containment.js +3 -48
- package/dist/core/worktree-landing.js +4 -56
- package/dist/core/worktree-mutation-async.js +10 -280
- package/dist/core/worktree-quarantine.js +1 -54
- package/dist/core/worktree-sweep.js +6 -453
- package/dist/core/worktree.js +18 -899
- package/dist/daemon/api/bridge.js +8 -418
- package/dist/daemon/api/handlers/attach.js +1 -65
- package/dist/daemon/api/handlers/bash-jobs.js +2 -91
- package/dist/daemon/api/handlers/broker-ops.js +1 -447
- package/dist/daemon/api/handlers/broker-recovery.js +1 -251
- package/dist/daemon/api/handlers/canvas.js +6 -490
- package/dist/daemon/api/handlers/chat-inventory.js +1 -25
- package/dist/daemon/api/handlers/crons.js +1 -373
- package/dist/daemon/api/handlers/daemon.js +1 -76
- package/dist/daemon/api/handlers/feedback-comments.js +3 -199
- package/dist/daemon/api/handlers/files.js +1 -63
- package/dist/daemon/api/handlers/focus.js +1 -92
- package/dist/daemon/api/handlers/health.js +1 -76
- package/dist/daemon/api/handlers/human-requests.js +1 -379
- package/dist/daemon/api/handlers/human.js +1 -3
- package/dist/daemon/api/handlers/inbox-page.js +1 -89
- package/dist/daemon/api/handlers/inbox.js +1 -301
- package/dist/daemon/api/handlers/memory.js +1 -50
- package/dist/daemon/api/handlers/messages.js +2 -506
- package/dist/daemon/api/handlers/model-config.js +1 -44
- package/dist/daemon/api/handlers/modelauth.js +1 -165
- package/dist/daemon/api/handlers/node-outcomes.js +1 -181
- package/dist/daemon/api/handlers/nodes.js +1 -939
- package/dist/daemon/api/handlers/profiles.js +1 -140
- package/dist/daemon/api/handlers/prospective-chat-inventory.js +1 -59
- package/dist/daemon/api/handlers/reports.js +16 -332
- package/dist/daemon/api/handlers/review-comments.js +1 -465
- package/dist/daemon/api/handlers/reviews.js +1 -200
- package/dist/daemon/api/handlers/subscriptions.js +1 -53
- package/dist/daemon/api/handlers/validate.js +1 -58
- package/dist/daemon/api/handlers/worktree.js +1 -39
- package/dist/daemon/api/map.js +2 -735
- package/dist/daemon/api/router.js +1 -190
- package/dist/daemon/api/server.js +11 -408
- package/dist/daemon/boot-migrations.js +1 -31
- package/dist/daemon/companion-retire.js +1 -34
- package/dist/daemon/control.js +1 -22
- package/dist/daemon/cron/armed-context.js +1 -100
- package/dist/daemon/cron/capture.js +2 -45
- package/dist/daemon/cron/disposition.js +1 -55
- package/dist/daemon/cron/escalation.js +3 -124
- package/dist/daemon/cron/held.js +1 -20
- package/dist/daemon/cron/lease-recovery.js +1 -119
- package/dist/daemon/cron/live-runs.js +1 -23
- package/dist/daemon/cron/passes.js +1 -58
- package/dist/daemon/cron/settle.js +1 -61
- package/dist/daemon/cron/sinks.js +2 -59
- package/dist/daemon/cron-run.js +1 -405
- package/dist/daemon/crtrd-cli.js +1 -23
- package/dist/daemon/crtrd.js +8 -854
- package/dist/daemon/delivery/run-delivery.js +1 -164
- package/dist/daemon/fleet.js +17 -475
- package/dist/daemon/human/finish.js +10 -179
- package/dist/daemon/human/settle.js +1 -89
- package/dist/daemon/human/sweep.js +1 -66
- package/dist/daemon/manage.js +2 -595
- package/dist/daemon/messaging/node-message.js +1 -99
- package/dist/daemon/park-activity.js +1 -30
- package/dist/daemon/park-pending.js +1 -52
- package/dist/daemon/pidfile.js +1 -37
- package/dist/daemon/profile-delete.js +1 -306
- package/dist/daemon/reconcilers/bash-deadline.js +1 -80
- package/dist/daemon/reconcilers/broker-supervision.js +4 -761
- package/dist/daemon/reconcilers/controller-death.js +1 -14
- package/dist/daemon/reconcilers/cron-lane.js +1 -29
- package/dist/daemon/reconcilers/delivery-lane.js +1 -130
- package/dist/daemon/reconcilers/live-obligation.js +1 -87
- package/dist/daemon/reconcilers/managed-worktree-sweep.js +1 -202
- package/dist/daemon/reconcilers/node-deadline.js +1 -82
- package/dist/daemon/reconcilers/node-lifecycle/freeze-lane.js +1 -172
- package/dist/daemon/reconcilers/node-lifecycle/respawn-policy.js +1 -59
- package/dist/daemon/reconcilers/node-lifecycle/terminating.js +1 -12
- package/dist/daemon/reconcilers/node-lifecycle/tick.js +1 -146
- package/dist/daemon/reconcilers/node-lifecycle/wants-execution.js +1 -11
- package/dist/daemon/reconcilers/pending-review-submit.js +1 -36
- package/dist/daemon/reconcilers/storage-maintenance.js +1 -207
- package/dist/daemon/review/comment-notify.js +2 -109
- package/dist/daemon/review/companion.js +1 -29
- package/dist/daemon/review/deliver.js +3 -8
- package/dist/daemon/review/finish.js +1 -122
- package/dist/daemon/review/sweep.js +1 -18
- package/dist/daemon/startup-policy.js +1 -1
- package/dist/daemon/supervise-cadence.js +1 -6
- package/dist/hook-authoring.js +5 -447
- package/dist/hook-process.js +1 -34
- package/dist/index.js +1 -52
- package/dist/migrations/001-surfaces-frontmatter.js +1 -161
- package/dist/migrations/002-profile-project-memory.js +1 -72
- package/dist/migrations/003-repository-root-memory-identity/front-door.js +11 -231
- package/dist/migrations/003-repository-root-memory-identity/index.js +5 -513
- package/dist/migrations/003-repository-root-memory-identity/references.js +5 -469
- package/dist/migrations/003-repository-root-memory-identity/repository-facts.js +3 -349
- package/dist/migrations/activation.js +2 -89
- package/dist/migrations/convergent.js +2 -82
- package/dist/migrations/corpus.js +3 -483
- package/dist/migrations/frontmatter-splice.js +8 -176
- package/dist/migrations/profile-manifests.js +2 -70
- package/dist/migrations/registry.js +1 -42
- package/dist/migrations/runner.js +1 -85
- package/dist/migrations/types.js +0 -24
- package/dist/pi-extensions/broker-local.js +2 -106
- package/dist/pi-extensions/canvas-bash-valve.js +7 -461
- package/dist/pi-extensions/canvas-context-intro.js +2 -113
- package/dist/pi-extensions/canvas-doc-substrate.js +9 -178
- package/dist/pi-extensions/canvas-goal-capture.js +1 -83
- package/dist/pi-extensions/canvas-inbox-watcher.js +1 -1010
- package/dist/pi-extensions/canvas-passive-context.js +14 -203
- package/dist/pi-extensions/canvas-preview-result.js +2 -72
- package/dist/pi-extensions/canvas-prompt-scrub.js +2 -54
- package/dist/pi-extensions/canvas-recap.js +11 -405
- package/dist/pi-extensions/canvas-review-boundary.js +3 -63
- package/dist/pi-extensions/canvas-stamp.js +2 -77
- package/dist/pi-extensions/canvas-stophook.js +1 -643
- package/dist/pi-extensions/canvas-structured-output.js +13 -35
- package/dist/pi-extensions/canvas-tool-guide.js +9 -78
- package/dist/pi-extensions/envelope-merge.js +8 -29
- package/dist/prompts/review.js +20 -42
- package/dist/shared/birth-announcement.js +1 -25
- package/dist/shared/crtr-version.js +1 -18
- package/dist/shared/env.js +1 -214
- package/dist/shared/generated-context.js +11 -226
- package/dist/shared/predicates.js +1 -4
- package/dist/shared/shell-quote.js +1 -5
- package/dist/shared/tool-groups.js +1 -64
- package/dist/shared/working-activity.js +1 -27
- package/dist/suppress-experimental-warnings.js +1 -15
- package/dist/types.js +1 -185
- package/docs/public-api.md +10 -9
- package/package.json +5 -4
- package/runtime.lock.json +5 -5
- package/dist/api/__tests__/integration/client.test.d.ts +0 -1
- package/dist/api/__tests__/integration/client.test.js +0 -163
- package/dist/builtin-pi-packages/pi-crtr-extensions/__tests__/insights-active-init.test.ts +0 -98
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/__tests__/crtr-commands.test.ts +0 -93
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/__tests__/integration/provider-rotation.test.ts +0 -2530
- package/dist/clients/__tests__/helpers/human-daemon.d.ts +0 -11
- package/dist/clients/__tests__/helpers/human-daemon.js +0 -60
- package/dist/clients/attach/__tests__/attach-remote-readonly.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/attach-remote-readonly.test.js +0 -97
- package/dist/clients/attach/__tests__/bash-call-width.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/bash-call-width.test.js +0 -38
- package/dist/clients/attach/__tests__/chat-view-snapshot-ordering.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/chat-view-snapshot-ordering.test.js +0 -175
- package/dist/clients/attach/__tests__/completion-frecency.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/completion-frecency.test.js +0 -35
- package/dist/clients/attach/__tests__/context-message.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/context-message.test.js +0 -130
- package/dist/clients/attach/__tests__/crtr-output.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/crtr-output.test.js +0 -68
- package/dist/clients/attach/__tests__/diagram.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/diagram.test.js +0 -42
- package/dist/clients/attach/__tests__/edit-diff.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/edit-diff.test.js +0 -31
- package/dist/clients/attach/__tests__/frame-selection.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/frame-selection.test.js +0 -84
- package/dist/clients/attach/__tests__/group-activity.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/group-activity.test.js +0 -165
- package/dist/clients/attach/__tests__/oauth-dialog-lifecycle.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/oauth-dialog-lifecycle.test.js +0 -83
- package/dist/clients/attach/__tests__/pane-tag-successor.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/pane-tag-successor.test.js +0 -56
- package/dist/clients/attach/__tests__/profile-files.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/profile-files.test.js +0 -21
- package/dist/clients/attach/__tests__/prompt-preview.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/prompt-preview.test.js +0 -21
- package/dist/clients/attach/__tests__/ref-autocomplete.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/ref-autocomplete.test.js +0 -64
- package/dist/clients/attach/__tests__/titled-editor-paste.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/titled-editor-paste.test.js +0 -114
- package/dist/clients/attach/__tests__/titled-editor-preview.test.d.ts +0 -1
- package/dist/clients/attach/__tests__/titled-editor-preview.test.js +0 -83
- package/dist/clients/inbox/__tests__/integration/inbox-controller.test.d.ts +0 -1
- package/dist/clients/inbox/__tests__/integration/inbox-controller.test.js +0 -81
- package/dist/clients/inbox/__tests__/integration/mount-panel.test.d.ts +0 -1
- package/dist/clients/inbox/__tests__/integration/mount-panel.test.js +0 -135
- package/dist/clients/inbox/__tests__/integration/stale-row-activation.test.d.ts +0 -1
- package/dist/clients/inbox/__tests__/integration/stale-row-activation.test.js +0 -66
- package/dist/clients/inbox/review/__tests__/editor-roundtrip.test.d.ts +0 -1
- package/dist/clients/inbox/review/__tests__/editor-roundtrip.test.js +0 -35
- package/dist/clients/inbox/review/__tests__/review-core.test.d.ts +0 -1
- package/dist/clients/inbox/review/__tests__/review-core.test.js +0 -52
- package/dist/clients/inbox/review/__tests__/teardown-notice.test.d.ts +0 -1
- package/dist/clients/inbox/review/__tests__/teardown-notice.test.js +0 -100
- package/dist/commands/__tests__/api-client-cold-start-diagnostic.test.d.ts +0 -1
- package/dist/commands/__tests__/api-client-cold-start-diagnostic.test.js +0 -69
- package/dist/commands/__tests__/human.test.d.ts +0 -1
- package/dist/commands/__tests__/human.test.js +0 -172
- package/dist/commands/__tests__/integration/dashboard-snapshot.test.d.ts +0 -1
- package/dist/commands/__tests__/integration/dashboard-snapshot.test.js +0 -237
- package/dist/commands/__tests__/integration/migrate.test.d.ts +0 -1
- package/dist/commands/__tests__/integration/migrate.test.js +0 -1330
- package/dist/commands/__tests__/node-message.test.d.ts +0 -1
- package/dist/commands/__tests__/node-message.test.js +0 -112
- package/dist/commands/__tests__/node-new.test.d.ts +0 -1
- package/dist/commands/__tests__/node-new.test.js +0 -58
- package/dist/commands/__tests__/revive-now-gate.test.d.ts +0 -1
- package/dist/commands/__tests__/revive-now-gate.test.js +0 -62
- package/dist/commands/__tests__/seam/daemon-status.test.d.ts +0 -1
- package/dist/commands/__tests__/seam/daemon-status.test.js +0 -29
- package/dist/commands/__tests__/surface-reload-target.test.d.ts +0 -1
- package/dist/commands/__tests__/surface-reload-target.test.js +0 -21
- package/dist/commands/memory/__tests__/command-selector-and-mutation-guards.test.d.ts +0 -1
- package/dist/commands/memory/__tests__/command-selector-and-mutation-guards.test.js +0 -379
- package/dist/commands/memory/__tests__/memory-list-and-lint-ignore.test.d.ts +0 -1
- package/dist/commands/memory/__tests__/memory-list-and-lint-ignore.test.js +0 -124
- package/dist/commands/memory/__tests__/repository-root-lint.test.d.ts +0 -1
- package/dist/commands/memory/__tests__/repository-root-lint.test.js +0 -148
- package/dist/commands/sys/__tests__/config-model-ladders.test.d.ts +0 -1
- package/dist/commands/sys/__tests__/config-model-ladders.test.js +0 -114
- package/dist/commands/sys/__tests__/setup-core.test.d.ts +0 -1
- package/dist/commands/sys/__tests__/setup-core.test.js +0 -45
- package/dist/commands/sys/__tests__/sync-project-guidance.test.d.ts +0 -1
- package/dist/commands/sys/__tests__/sync-project-guidance.test.js +0 -244
- package/dist/core/__tests__/bash-guard.test.d.ts +0 -1
- package/dist/core/__tests__/bash-guard.test.js +0 -190
- package/dist/core/__tests__/boot-fault-attempt.test.d.ts +0 -1
- package/dist/core/__tests__/boot-fault-attempt.test.js +0 -105
- package/dist/core/__tests__/boot.test.d.ts +0 -1
- package/dist/core/__tests__/boot.test.js +0 -274
- package/dist/core/__tests__/branded-host-concurrency.test.d.ts +0 -1
- package/dist/core/__tests__/branded-host-concurrency.test.js +0 -72
- package/dist/core/__tests__/broker-extension-canvas-db-boundary.test.d.ts +0 -1
- package/dist/core/__tests__/broker-extension-canvas-db-boundary.test.js +0 -75
- package/dist/core/__tests__/broker-launch-candidates.test.d.ts +0 -1
- package/dist/core/__tests__/broker-launch-candidates.test.js +0 -311
- package/dist/core/__tests__/broker-preflight.test.d.ts +0 -1
- package/dist/core/__tests__/broker-preflight.test.js +0 -95
- package/dist/core/__tests__/broker-stream-watchdog-floor.test.d.ts +0 -1
- package/dist/core/__tests__/broker-stream-watchdog-floor.test.js +0 -82
- package/dist/core/__tests__/broker-turn-admission.test.d.ts +0 -1
- package/dist/core/__tests__/broker-turn-admission.test.js +0 -44
- package/dist/core/__tests__/canvas-db-boundary.test.d.ts +0 -1
- package/dist/core/__tests__/canvas-db-boundary.test.js +0 -46
- package/dist/core/__tests__/canvas-inbox-watcher-hold.test.d.ts +0 -1
- package/dist/core/__tests__/canvas-inbox-watcher-hold.test.js +0 -710
- package/dist/core/__tests__/canvas-inbox-watcher-naming.test.d.ts +0 -1
- package/dist/core/__tests__/canvas-inbox-watcher-naming.test.js +0 -310
- package/dist/core/__tests__/canvas-inbox-watcher.test.d.ts +0 -1
- package/dist/core/__tests__/canvas-inbox-watcher.test.js +0 -397
- package/dist/core/__tests__/canvas.test.d.ts +0 -1
- package/dist/core/__tests__/canvas.test.js +0 -138
- package/dist/core/__tests__/child-death-wake.test.d.ts +0 -1
- package/dist/core/__tests__/child-death-wake.test.js +0 -153
- package/dist/core/__tests__/cli-help-contract.test.d.ts +0 -1
- package/dist/core/__tests__/cli-help-contract.test.js +0 -152
- package/dist/core/__tests__/close.test.d.ts +0 -1
- package/dist/core/__tests__/close.test.js +0 -284
- package/dist/core/__tests__/collectible.test.d.ts +0 -1
- package/dist/core/__tests__/collectible.test.js +0 -89
- package/dist/core/__tests__/config-change-delta.test.d.ts +0 -1
- package/dist/core/__tests__/config-change-delta.test.js +0 -108
- package/dist/core/__tests__/context-intro.test.d.ts +0 -1
- package/dist/core/__tests__/context-intro.test.js +0 -123
- package/dist/core/__tests__/cron-armed-context-failure.test.d.ts +0 -1
- package/dist/core/__tests__/cron-armed-context-failure.test.js +0 -150
- package/dist/core/__tests__/cron-held-settlement.test.d.ts +0 -1
- package/dist/core/__tests__/cron-held-settlement.test.js +0 -240
- package/dist/core/__tests__/cron-node-sink-parked-root.test.d.ts +0 -1
- package/dist/core/__tests__/cron-node-sink-parked-root.test.js +0 -166
- package/dist/core/__tests__/cron-self-cancel-delivery.test.d.ts +0 -1
- package/dist/core/__tests__/cron-self-cancel-delivery.test.js +0 -84
- package/dist/core/__tests__/cron-timeout-descendants.test.d.ts +0 -1
- package/dist/core/__tests__/cron-timeout-descendants.test.js +0 -114
- package/dist/core/__tests__/daemon-boot.test.d.ts +0 -1
- package/dist/core/__tests__/daemon-boot.test.js +0 -422
- package/dist/core/__tests__/daemon-wedge.test.d.ts +0 -1
- package/dist/core/__tests__/daemon-wedge.test.js +0 -106
- package/dist/core/__tests__/dead-node-policy-table.test.d.ts +0 -1
- package/dist/core/__tests__/dead-node-policy-table.test.js +0 -77
- package/dist/core/__tests__/events-contract.test.d.ts +0 -1
- package/dist/core/__tests__/events-contract.test.js +0 -76
- package/dist/core/__tests__/extension-abort.test.d.ts +0 -1
- package/dist/core/__tests__/extension-abort.test.js +0 -21
- package/dist/core/__tests__/fault-classifier.test.d.ts +0 -1
- package/dist/core/__tests__/fault-classifier.test.js +0 -138
- package/dist/core/__tests__/fixtures/api-server-host.d.ts +0 -1
- package/dist/core/__tests__/fixtures/api-server-host.js +0 -47
- package/dist/core/__tests__/fixtures/c3-custom-provider-ext.d.ts +0 -2
- package/dist/core/__tests__/fixtures/c3-custom-provider-ext.js +0 -34
- package/dist/core/__tests__/fixtures/c5-command-boundary-ext.d.ts +0 -2
- package/dist/core/__tests__/fixtures/c5-command-boundary-ext.js +0 -32
- package/dist/core/__tests__/fixtures/fake-engine.d.ts +0 -347
- package/dist/core/__tests__/fixtures/fake-engine.js +0 -1509
- package/dist/core/__tests__/fixtures/fake-pi-host.d.ts +0 -2
- package/dist/core/__tests__/fixtures/fake-pi-host.js +0 -311
- package/dist/core/__tests__/fixtures/memory-slash-live-probe.d.ts +0 -1
- package/dist/core/__tests__/fixtures/memory-slash-live-probe.js +0 -75
- package/dist/core/__tests__/fixtures/metadata-migration-race.d.ts +0 -1
- package/dist/core/__tests__/fixtures/metadata-migration-race.js +0 -49
- package/dist/core/__tests__/focuses.test.d.ts +0 -1
- package/dist/core/__tests__/focuses.test.js +0 -113
- package/dist/core/__tests__/fs-utils.test.d.ts +0 -1
- package/dist/core/__tests__/fs-utils.test.js +0 -50
- package/dist/core/__tests__/helpers/broker-clients.d.ts +0 -43
- package/dist/core/__tests__/helpers/broker-clients.js +0 -174
- package/dist/core/__tests__/helpers/fleet.d.ts +0 -12
- package/dist/core/__tests__/helpers/fleet.js +0 -50
- package/dist/core/__tests__/helpers/harness.d.ts +0 -124
- package/dist/core/__tests__/helpers/harness.js +0 -806
- package/dist/core/__tests__/helpers/viewer-panes.d.ts +0 -12
- package/dist/core/__tests__/helpers/viewer-panes.js +0 -133
- package/dist/core/__tests__/history-inbox.test.d.ts +0 -1
- package/dist/core/__tests__/history-inbox.test.js +0 -121
- package/dist/core/__tests__/human-action-delivery.test.d.ts +0 -1
- package/dist/core/__tests__/human-action-delivery.test.js +0 -162
- package/dist/core/__tests__/human-actions.test.d.ts +0 -1
- package/dist/core/__tests__/human-actions.test.js +0 -120
- package/dist/core/__tests__/inline-memory-refs.test.d.ts +0 -1
- package/dist/core/__tests__/inline-memory-refs.test.js +0 -225
- package/dist/core/__tests__/integration/broker-fork-seam.test.d.ts +0 -1
- package/dist/core/__tests__/integration/broker-fork-seam.test.js +0 -193
- package/dist/core/__tests__/integration/broker-sdk-wiring.test.d.ts +0 -1
- package/dist/core/__tests__/integration/broker-sdk-wiring.test.js +0 -750
- package/dist/core/__tests__/integration/broker-snapshot-history.test.d.ts +0 -1
- package/dist/core/__tests__/integration/broker-snapshot-history.test.js +0 -288
- package/dist/core/__tests__/integration/broker-wedge-supervision.test.d.ts +0 -1
- package/dist/core/__tests__/integration/broker-wedge-supervision.test.js +0 -103
- package/dist/core/__tests__/integration/command-plugins.test.d.ts +0 -1
- package/dist/core/__tests__/integration/command-plugins.test.js +0 -1200
- package/dist/core/__tests__/integration/deferred-no-wake.test.d.ts +0 -1
- package/dist/core/__tests__/integration/deferred-no-wake.test.js +0 -610
- package/dist/core/__tests__/integration/flagship-lifecycle.test.d.ts +0 -1
- package/dist/core/__tests__/integration/flagship-lifecycle.test.js +0 -264
- package/dist/core/__tests__/integration/fresh-home-commands.test.d.ts +0 -1
- package/dist/core/__tests__/integration/fresh-home-commands.test.js +0 -49
- package/dist/core/__tests__/integration/git-optional-locks.test.d.ts +0 -1
- package/dist/core/__tests__/integration/git-optional-locks.test.js +0 -81
- package/dist/core/__tests__/integration/host-teardown-process-group.test.d.ts +0 -1
- package/dist/core/__tests__/integration/host-teardown-process-group.test.js +0 -480
- package/dist/core/__tests__/integration/lifecycle-hooks.test.d.ts +0 -1
- package/dist/core/__tests__/integration/lifecycle-hooks.test.js +0 -498
- package/dist/core/__tests__/integration/live-mutation-verbs.test.d.ts +0 -1
- package/dist/core/__tests__/integration/live-mutation-verbs.test.js +0 -180
- package/dist/core/__tests__/integration/live-mutation.test.d.ts +0 -1
- package/dist/core/__tests__/integration/live-mutation.test.js +0 -173
- package/dist/core/__tests__/integration/plugin-revalidate.test.d.ts +0 -1
- package/dist/core/__tests__/integration/plugin-revalidate.test.js +0 -359
- package/dist/core/__tests__/integration/profile-pause.test.d.ts +0 -1
- package/dist/core/__tests__/integration/profile-pause.test.js +0 -115
- package/dist/core/__tests__/integration/refresh-stall-recycle.test.d.ts +0 -1
- package/dist/core/__tests__/integration/refresh-stall-recycle.test.js +0 -151
- package/dist/core/__tests__/integration/revive.test.d.ts +0 -1
- package/dist/core/__tests__/integration/revive.test.js +0 -615
- package/dist/core/__tests__/integration/spawn-root.test.d.ts +0 -1
- package/dist/core/__tests__/integration/spawn-root.test.js +0 -536
- package/dist/core/__tests__/integration/subscription-delivery.test.d.ts +0 -1
- package/dist/core/__tests__/integration/subscription-delivery.test.js +0 -132
- package/dist/core/__tests__/integration/tmux-surface.test.d.ts +0 -1
- package/dist/core/__tests__/integration/tmux-surface.test.js +0 -330
- package/dist/core/__tests__/integration/worktree-land.test.d.ts +0 -1
- package/dist/core/__tests__/integration/worktree-land.test.js +0 -607
- package/dist/core/__tests__/integration/worktree-reap.test.d.ts +0 -1
- package/dist/core/__tests__/integration/worktree-reap.test.js +0 -842
- package/dist/core/__tests__/kickoff.test.d.ts +0 -1
- package/dist/core/__tests__/kickoff.test.js +0 -196
- package/dist/core/__tests__/lifecycle-terminal-reasons.test.d.ts +0 -1
- package/dist/core/__tests__/lifecycle-terminal-reasons.test.js +0 -62
- package/dist/core/__tests__/lifecycle.test.d.ts +0 -1
- package/dist/core/__tests__/lifecycle.test.js +0 -176
- package/dist/core/__tests__/live-lifecycle-prompt.test.d.ts +0 -1
- package/dist/core/__tests__/live-lifecycle-prompt.test.js +0 -63
- package/dist/core/__tests__/memory-resolver-precedence.test.d.ts +0 -1
- package/dist/core/__tests__/memory-resolver-precedence.test.js +0 -228
- package/dist/core/__tests__/migration.test.d.ts +0 -1
- package/dist/core/__tests__/migration.test.js +0 -946
- package/dist/core/__tests__/model-pin-durability.test.d.ts +0 -1
- package/dist/core/__tests__/model-pin-durability.test.js +0 -195
- package/dist/core/__tests__/model-routes-config.test.d.ts +0 -1
- package/dist/core/__tests__/model-routes-config.test.js +0 -150
- package/dist/core/__tests__/nested-store-discovery.test.d.ts +0 -1
- package/dist/core/__tests__/nested-store-discovery.test.js +0 -89
- package/dist/core/__tests__/node-outcome.test.d.ts +0 -1
- package/dist/core/__tests__/node-outcome.test.js +0 -246
- package/dist/core/__tests__/on-read-crouter-home-fence.test.d.ts +0 -1
- package/dist/core/__tests__/on-read-crouter-home-fence.test.js +0 -66
- package/dist/core/__tests__/on-read-dedup-resume.test.d.ts +0 -1
- package/dist/core/__tests__/on-read-dedup-resume.test.js +0 -132
- package/dist/core/__tests__/on-read-nested-store.test.d.ts +0 -1
- package/dist/core/__tests__/on-read-nested-store.test.js +0 -135
- package/dist/core/__tests__/parse-argv-stdin-secret.test.d.ts +0 -1
- package/dist/core/__tests__/parse-argv-stdin-secret.test.js +0 -68
- package/dist/core/__tests__/passive-subscription.test.d.ts +0 -1
- package/dist/core/__tests__/passive-subscription.test.js +0 -120
- package/dist/core/__tests__/pid-identity-match.test.d.ts +0 -1
- package/dist/core/__tests__/pid-identity-match.test.js +0 -145
- package/dist/core/__tests__/pid-zombie.test.d.ts +0 -1
- package/dist/core/__tests__/pid-zombie.test.js +0 -42
- package/dist/core/__tests__/plugin-kinds.test.d.ts +0 -1
- package/dist/core/__tests__/plugin-kinds.test.js +0 -182
- package/dist/core/__tests__/plugin-link-symlinked-scope-root.test.d.ts +0 -1
- package/dist/core/__tests__/plugin-link-symlinked-scope-root.test.js +0 -43
- package/dist/core/__tests__/plugin-page-components.test.d.ts +0 -1
- package/dist/core/__tests__/plugin-page-components.test.js +0 -159
- package/dist/core/__tests__/preview-mirror-cap.test.d.ts +0 -1
- package/dist/core/__tests__/preview-mirror-cap.test.js +0 -53
- package/dist/core/__tests__/preview-registry-sync.test.d.ts +0 -1
- package/dist/core/__tests__/preview-registry-sync.test.js +0 -107
- package/dist/core/__tests__/profile-project-memory-delivery.test.d.ts +0 -1
- package/dist/core/__tests__/profile-project-memory-delivery.test.js +0 -644
- package/dist/core/__tests__/prospective-inventory-capability-parity.test.d.ts +0 -1
- package/dist/core/__tests__/prospective-inventory-capability-parity.test.js +0 -91
- package/dist/core/__tests__/prune.test.d.ts +0 -1
- package/dist/core/__tests__/prune.test.js +0 -243
- package/dist/core/__tests__/push-final-guard.test.d.ts +0 -1
- package/dist/core/__tests__/push-final-guard.test.js +0 -191
- package/dist/core/__tests__/relaunch-root.test.d.ts +0 -1
- package/dist/core/__tests__/relaunch-root.test.js +0 -249
- package/dist/core/__tests__/remote-canvas-target.test.d.ts +0 -1
- package/dist/core/__tests__/remote-canvas-target.test.js +0 -93
- package/dist/core/__tests__/repository-association.test.d.ts +0 -1
- package/dist/core/__tests__/repository-association.test.js +0 -153
- package/dist/core/__tests__/repository-root-identity.test.d.ts +0 -1
- package/dist/core/__tests__/repository-root-identity.test.js +0 -223
- package/dist/core/__tests__/respawn-throttle.test.d.ts +0 -1
- package/dist/core/__tests__/respawn-throttle.test.js +0 -20
- package/dist/core/__tests__/review-model-floor.test.d.ts +0 -1
- package/dist/core/__tests__/review-model-floor.test.js +0 -83
- package/dist/core/__tests__/revive-all.test.d.ts +0 -1
- package/dist/core/__tests__/revive-all.test.js +0 -157
- package/dist/core/__tests__/revive-capacity.test.d.ts +0 -1
- package/dist/core/__tests__/revive-capacity.test.js +0 -184
- package/dist/core/__tests__/revive-parked-fresh.test.d.ts +0 -1
- package/dist/core/__tests__/revive-parked-fresh.test.js +0 -176
- package/dist/core/__tests__/scope-crouter-home-fence.test.d.ts +0 -1
- package/dist/core/__tests__/scope-crouter-home-fence.test.js +0 -55
- package/dist/core/__tests__/seam/broker-attach-multiclient.test.d.ts +0 -1
- package/dist/core/__tests__/seam/broker-attach-multiclient.test.js +0 -262
- package/dist/core/__tests__/seam/broker-attach-stream.test.d.ts +0 -1
- package/dist/core/__tests__/seam/broker-attach-stream.test.js +0 -176
- package/dist/core/__tests__/seam/broker-cap-freeze.test.d.ts +0 -1
- package/dist/core/__tests__/seam/broker-cap-freeze.test.js +0 -155
- package/dist/core/__tests__/seam/broker-crash-teardown.test.d.ts +0 -1
- package/dist/core/__tests__/seam/broker-crash-teardown.test.js +0 -131
- package/dist/core/__tests__/seam/broker-pane-resolution.test.d.ts +0 -1
- package/dist/core/__tests__/seam/broker-pane-resolution.test.js +0 -204
- package/dist/core/__tests__/seam/broker-provider-retry.test.d.ts +0 -1
- package/dist/core/__tests__/seam/broker-provider-retry.test.js +0 -686
- package/dist/core/__tests__/seam/broker-startup-diagnostics.test.d.ts +0 -1
- package/dist/core/__tests__/seam/broker-startup-diagnostics.test.js +0 -82
- package/dist/core/__tests__/seam/broker-whip-interrupt.test.d.ts +0 -1
- package/dist/core/__tests__/seam/broker-whip-interrupt.test.js +0 -50
- package/dist/core/__tests__/seam/deadline-wake-delivery.test.d.ts +0 -1
- package/dist/core/__tests__/seam/deadline-wake-delivery.test.js +0 -138
- package/dist/core/__tests__/seam/dormancy-release.test.d.ts +0 -1
- package/dist/core/__tests__/seam/dormancy-release.test.js +0 -516
- package/dist/core/__tests__/seam/held-deferred-human-prompt.test.d.ts +0 -1
- package/dist/core/__tests__/seam/held-deferred-human-prompt.test.js +0 -65
- package/dist/core/__tests__/seam/inbox-reference-guidance.test.d.ts +0 -1
- package/dist/core/__tests__/seam/inbox-reference-guidance.test.js +0 -84
- package/dist/core/__tests__/seam/memory-slash-node-relative-inventory.test.d.ts +0 -1
- package/dist/core/__tests__/seam/memory-slash-node-relative-inventory.test.js +0 -160
- package/dist/core/__tests__/seam/node-outcome-delivery.test.d.ts +0 -1
- package/dist/core/__tests__/seam/node-outcome-delivery.test.js +0 -177
- package/dist/core/__tests__/seam/prospective-inventory-stdout.test.d.ts +0 -1
- package/dist/core/__tests__/seam/prospective-inventory-stdout.test.js +0 -31
- package/dist/core/__tests__/seam/reopen-invalidated-worktree.test.d.ts +0 -1
- package/dist/core/__tests__/seam/reopen-invalidated-worktree.test.js +0 -60
- package/dist/core/__tests__/seam/self-close-teardown.test.d.ts +0 -1
- package/dist/core/__tests__/seam/self-close-teardown.test.js +0 -49
- package/dist/core/__tests__/seam/yield-refresh-transaction.test.d.ts +0 -1
- package/dist/core/__tests__/seam/yield-refresh-transaction.test.js +0 -100
- package/dist/core/__tests__/secrets.test.d.ts +0 -1
- package/dist/core/__tests__/secrets.test.js +0 -49
- package/dist/core/__tests__/self-update.test.d.ts +0 -1
- package/dist/core/__tests__/self-update.test.js +0 -46
- package/dist/core/__tests__/session-branch.test.d.ts +0 -1
- package/dist/core/__tests__/session-branch.test.js +0 -61
- package/dist/core/__tests__/session-cycles.test.d.ts +0 -1
- package/dist/core/__tests__/session-cycles.test.js +0 -133
- package/dist/core/__tests__/session-model.test.d.ts +0 -1
- package/dist/core/__tests__/session-model.test.js +0 -111
- package/dist/core/__tests__/spawn-worktree-id-conflict.test.d.ts +0 -1
- package/dist/core/__tests__/spawn-worktree-id-conflict.test.js +0 -71
- package/dist/core/__tests__/stdin-body-no-discard.test.d.ts +0 -1
- package/dist/core/__tests__/stdin-body-no-discard.test.js +0 -33
- package/dist/core/__tests__/stdout-errors.test.d.ts +0 -1
- package/dist/core/__tests__/stdout-errors.test.js +0 -16
- package/dist/core/__tests__/stop-guard.test.d.ts +0 -1
- package/dist/core/__tests__/stop-guard.test.js +0 -237
- package/dist/core/__tests__/stream-watchdog.test.d.ts +0 -1
- package/dist/core/__tests__/stream-watchdog.test.js +0 -154
- package/dist/core/__tests__/subscription-pool-credential-guard.test.d.ts +0 -1
- package/dist/core/__tests__/subscription-pool-credential-guard.test.js +0 -95
- package/dist/core/__tests__/tmux-driver-boundary.test.d.ts +0 -1
- package/dist/core/__tests__/tmux-driver-boundary.test.js +0 -50
- package/dist/core/__tests__/warm-claim-preference-snapshot.test.d.ts +0 -1
- package/dist/core/__tests__/warm-claim-preference-snapshot.test.js +0 -54
- package/dist/core/__tests__/worktree-landing.test.d.ts +0 -1
- package/dist/core/__tests__/worktree-landing.test.js +0 -11
- package/dist/core/__tests__/yield-ensures-daemon.test.d.ts +0 -1
- package/dist/core/__tests__/yield-ensures-daemon.test.js +0 -55
- package/dist/core/broker-client/__tests__/transport-relay.test.d.ts +0 -1
- package/dist/core/broker-client/__tests__/transport-relay.test.js +0 -214
- package/dist/core/broker-client/__tests__/transport-socket.test.d.ts +0 -1
- package/dist/core/broker-client/__tests__/transport-socket.test.js +0 -73
- package/dist/core/canvas/__tests__/attention.test.d.ts +0 -1
- package/dist/core/canvas/__tests__/attention.test.js +0 -83
- package/dist/core/canvas/__tests__/history-transcript.test.d.ts +0 -1
- package/dist/core/canvas/__tests__/history-transcript.test.js +0 -102
- package/dist/core/canvas/__tests__/remote-canvas-source.test.d.ts +0 -1
- package/dist/core/canvas/__tests__/remote-canvas-source.test.js +0 -328
- package/dist/core/canvas/__tests__/remote-transport.test.d.ts +0 -1
- package/dist/core/canvas/__tests__/remote-transport.test.js +0 -97
- package/dist/core/canvas/__tests__/render-remote.test.d.ts +0 -1
- package/dist/core/canvas/__tests__/render-remote.test.js +0 -243
- package/dist/core/canvas/__tests__/session-window.test.d.ts +0 -1
- package/dist/core/canvas/__tests__/session-window.test.js +0 -70
- package/dist/core/feed/__tests__/inbox-migrate.test.d.ts +0 -1
- package/dist/core/feed/__tests__/inbox-migrate.test.js +0 -49
- package/dist/core/human/__tests__/page-catalog.test.d.ts +0 -1
- package/dist/core/human/__tests__/page-catalog.test.js +0 -20
- package/dist/core/human/__tests__/page-html-markdown.test.d.ts +0 -1
- package/dist/core/human/__tests__/page-html-markdown.test.js +0 -48
- package/dist/core/human/__tests__/page.test.d.ts +0 -1
- package/dist/core/human/__tests__/page.test.js +0 -92
- package/dist/core/keybindings/__tests__/resolve.test.d.ts +0 -1
- package/dist/core/keybindings/__tests__/resolve.test.js +0 -171
- package/dist/core/profiles/__tests__/env-store.test.d.ts +0 -1
- package/dist/core/profiles/__tests__/env-store.test.js +0 -99
- package/dist/core/profiles/__tests__/fuzzy-match.test.d.ts +0 -1
- package/dist/core/profiles/__tests__/fuzzy-match.test.js +0 -51
- package/dist/core/profiles/__tests__/root-profile.test.d.ts +0 -1
- package/dist/core/profiles/__tests__/root-profile.test.js +0 -59
- package/dist/core/review/__tests__/capture-origin.test.d.ts +0 -1
- package/dist/core/review/__tests__/capture-origin.test.js +0 -150
- package/dist/core/review/__tests__/comments.test.d.ts +0 -1
- package/dist/core/review/__tests__/comments.test.js +0 -116
- package/dist/core/review/__tests__/remap.test.d.ts +0 -1
- package/dist/core/review/__tests__/remap.test.js +0 -177
- package/dist/core/review/__tests__/stage-identity.test.d.ts +0 -1
- package/dist/core/review/__tests__/stage-identity.test.js +0 -150
- package/dist/core/runtime/__tests__/engine-route.test.d.ts +0 -1
- package/dist/core/runtime/__tests__/engine-route.test.js +0 -36
- package/dist/core/runtime/__tests__/install-id-cache-scoping.test.d.ts +0 -1
- package/dist/core/runtime/__tests__/install-id-cache-scoping.test.js +0 -45
- package/dist/core/runtime/__tests__/node-env.test.d.ts +0 -1
- package/dist/core/runtime/__tests__/node-env.test.js +0 -73
- package/dist/core/runtime/__tests__/spawn-env.test.d.ts +0 -1
- package/dist/core/runtime/__tests__/spawn-env.test.js +0 -259
- package/dist/core/substrate/__tests__/surface-match-command.test.d.ts +0 -1
- package/dist/core/substrate/__tests__/surface-match-command.test.js +0 -89
- package/dist/core/substrate/__tests__/surface-match-memory-read.test.d.ts +0 -1
- package/dist/core/substrate/__tests__/surface-match-memory-read.test.js +0 -28
- package/dist/core/substrate/__tests__/surface-match-pre-command.test.d.ts +0 -1
- package/dist/core/substrate/__tests__/surface-match-pre-command.test.js +0 -92
- package/dist/daemon/__tests__/autostart-storm.test.d.ts +0 -1
- package/dist/daemon/__tests__/autostart-storm.test.js +0 -128
- package/dist/daemon/__tests__/broker-ownership.test.d.ts +0 -1
- package/dist/daemon/__tests__/broker-ownership.test.js +0 -25
- package/dist/daemon/__tests__/daemon-ownership.test.d.ts +0 -1
- package/dist/daemon/__tests__/daemon-ownership.test.js +0 -27
- package/dist/daemon/__tests__/helpers/source-daemon.d.ts +0 -30
- package/dist/daemon/__tests__/helpers/source-daemon.js +0 -176
- package/dist/daemon/__tests__/integration/api-startup-readiness.test.d.ts +0 -1
- package/dist/daemon/__tests__/integration/api-startup-readiness.test.js +0 -83
- package/dist/daemon/__tests__/integration/migration-startup.test.d.ts +0 -1
- package/dist/daemon/__tests__/integration/migration-startup.test.js +0 -127
- package/dist/daemon/__tests__/node-deadline-lane.test.d.ts +0 -1
- package/dist/daemon/__tests__/node-deadline-lane.test.js +0 -77
- package/dist/daemon/__tests__/node-outcome-birth-invariants.test.d.ts +0 -1
- package/dist/daemon/__tests__/node-outcome-birth-invariants.test.js +0 -146
- package/dist/daemon/__tests__/node-outcome-delivery.test.d.ts +0 -1
- package/dist/daemon/__tests__/node-outcome-delivery.test.js +0 -116
- package/dist/daemon/__tests__/reconciler-signature.test.d.ts +0 -1
- package/dist/daemon/__tests__/reconciler-signature.test.js +0 -37
- package/dist/daemon/__tests__/subtree-filter-freshness.test.d.ts +0 -1
- package/dist/daemon/__tests__/subtree-filter-freshness.test.js +0 -63
- package/dist/daemon/__tests__/thaw-order.test.d.ts +0 -1
- package/dist/daemon/__tests__/thaw-order.test.js +0 -55
- package/dist/daemon/api/__tests__/bridge-heartbeat.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/bridge-heartbeat.test.js +0 -58
- package/dist/daemon/api/__tests__/broker-settle-park.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/broker-settle-park.test.js +0 -175
- package/dist/daemon/api/__tests__/canvas-snapshot-fields.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/canvas-snapshot-fields.test.js +0 -216
- package/dist/daemon/api/__tests__/error-seam.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/error-seam.test.js +0 -83
- package/dist/daemon/api/__tests__/model-config.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/model-config.test.js +0 -73
- package/dist/daemon/api/__tests__/node-create-description.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/node-create-description.test.js +0 -127
- package/dist/daemon/api/__tests__/node-model-validation.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/node-model-validation.test.js +0 -183
- package/dist/daemon/api/__tests__/nodes-activity-query.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/nodes-activity-query.test.js +0 -99
- package/dist/daemon/api/__tests__/profile-launch-gates.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/profile-launch-gates.test.js +0 -172
- package/dist/daemon/api/__tests__/profile-metadata-route.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/profile-metadata-route.test.js +0 -95
- package/dist/daemon/api/__tests__/reopen-delivery.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/reopen-delivery.test.js +0 -260
- package/dist/daemon/api/__tests__/seam/api-server.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/seam/api-server.test.js +0 -442
- package/dist/daemon/api/__tests__/seam/b10-attach-modelauth.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/seam/b10-attach-modelauth.test.js +0 -310
- package/dist/daemon/api/__tests__/seam/leaf-api-parity.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/seam/leaf-api-parity.test.js +0 -351
- package/dist/daemon/api/__tests__/seam/node-outcome-api.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/seam/node-outcome-api.test.js +0 -159
- package/dist/daemon/api/__tests__/seam/profile-delete.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/seam/profile-delete.test.js +0 -372
- package/dist/daemon/api/__tests__/submit-result.test.d.ts +0 -1
- package/dist/daemon/api/__tests__/submit-result.test.js +0 -215
- package/dist/migrations/__tests__/activation-concurrency.test.d.ts +0 -1
- package/dist/migrations/__tests__/activation-concurrency.test.js +0 -146
- package/dist/migrations/__tests__/activation.test.d.ts +0 -1
- package/dist/migrations/__tests__/activation.test.js +0 -152
- package/dist/migrations/__tests__/deletion-and-root-declaration.test.d.ts +0 -1
- package/dist/migrations/__tests__/deletion-and-root-declaration.test.js +0 -149
- package/dist/pi-extensions/__tests__/canvas-bash-valve.test.d.ts +0 -1
- package/dist/pi-extensions/__tests__/canvas-bash-valve.test.js +0 -86
- package/dist/pi-extensions/__tests__/canvas-context-intro.test.d.ts +0 -1
- package/dist/pi-extensions/__tests__/canvas-context-intro.test.js +0 -364
- package/dist/pi-extensions/__tests__/canvas-goal-capture-envelope.test.d.ts +0 -1
- package/dist/pi-extensions/__tests__/canvas-goal-capture-envelope.test.js +0 -106
- package/dist/pi-extensions/__tests__/canvas-recap.test.d.ts +0 -1
- package/dist/pi-extensions/__tests__/canvas-recap.test.js +0 -62
- package/dist/pi-extensions/__tests__/canvas-stophook-agentend.test.d.ts +0 -1
- package/dist/pi-extensions/__tests__/canvas-stophook-agentend.test.js +0 -432
- package/dist/pi-extensions/__tests__/canvas-stophook-context-nudge.test.d.ts +0 -1
- package/dist/pi-extensions/__tests__/canvas-stophook-context-nudge.test.js +0 -152
- package/dist/pi-extensions/__tests__/canvas-structured-output.test.d.ts +0 -1
- package/dist/pi-extensions/__tests__/canvas-structured-output.test.js +0 -88
- package/dist/pi-extensions/__tests__/canvas-tool-guide.test.d.ts +0 -1
- package/dist/pi-extensions/__tests__/canvas-tool-guide.test.js +0 -96
- package/dist/pi-extensions/__tests__/integration/canvas-bash-valve.test.d.ts +0 -1
- package/dist/pi-extensions/__tests__/integration/canvas-bash-valve.test.js +0 -133
- package/dist/pi-extensions/__tests__/pre-command-gate.test.d.ts +0 -1
- package/dist/pi-extensions/__tests__/pre-command-gate.test.js +0 -232
- package/dist/shared/__tests__/env-boundary.test.d.ts +0 -1
- package/dist/shared/__tests__/env-boundary.test.js +0 -95
- package/dist/shared/__tests__/generated-context-grammar.test.d.ts +0 -1
- package/dist/shared/__tests__/generated-context-grammar.test.js +0 -80
- package/docs/compat/hearth-crtr-v1.md +0 -179
- package/docs/compat/hearth-crtr-v2.md +0 -177
- package/docs/compat/hearth-crtr-v3.md +0 -176
- package/docs/compat/hearth-crtr-v4.md +0 -182
- package/docs/compat/hearth-crtr-v5.md +0 -169
|
@@ -1,1214 +1 @@
|
|
|
1
|
-
// broker.ts — the headless node broker (design §4, §5).
|
|
2
|
-
//
|
|
3
|
-
// One broker process per node — the SOLE host. It hosts ONE pi engine IN-PROCESS
|
|
4
|
-
// via the SDK (createAgentSession), is the SOLE writer of the node's session
|
|
5
|
-
// `.jsonl`, listens on `nodeDir(id)/view.sock`, fans the single engine event
|
|
6
|
-
// stream out to N viewers, serializes the drive commands of EVERY writable
|
|
7
|
-
// viewer through one frame loop, and fans blocking extension dialogs out to all
|
|
8
|
-
// of them (first answer wins). The engine has no terminal of its own; a
|
|
9
|
-
// tmux pane (or web tab) is only a viewer of this socket. It
|
|
10
|
-
// runs one turn-cycle and, when the engine settles (the stophook calls
|
|
11
|
-
// ctx.shutdown(), or the engine goes idle), disposes the engine and exits 0 —
|
|
12
|
-
// the daemon then routes revival per the intent the bound stophook set.
|
|
13
|
-
//
|
|
14
|
-
// Engine resolution flows through broker-sdk.ts (`loadBrokerEngine`) so the T11
|
|
15
|
-
// `CRTR_BROKER_ENGINE` test seam can swap a fake engine in. The resource loader
|
|
16
|
-
// + model registry are real SDK construction helpers (NOT part of the swappable
|
|
17
|
-
// engine seam — the fake engine receives the real, extension-loaded loader so
|
|
18
|
-
// the real canvas-stophook fires session_start).
|
|
19
|
-
import { envModelIntent, envNodeCwd, envNodeId, envProfileId } from '../../shared/env.js';
|
|
20
|
-
import { createServer } from 'node:net';
|
|
21
|
-
import { existsSync, readFileSync, unlinkSync } from 'node:fs';
|
|
22
|
-
import { join } from 'node:path';
|
|
23
|
-
import { randomUUID } from 'node:crypto';
|
|
24
|
-
import { mark } from '../timing.js';
|
|
25
|
-
import { getAgentDir, initTheme, ModelRegistry, ModelRuntime, } from '@earendil-works/pi-coding-agent';
|
|
26
|
-
import { nodeDir, viewSocketPath } from '../canvas/paths.js';
|
|
27
|
-
import { bindBrokerEventSource } from '../events/source.js';
|
|
28
|
-
import { emitEvent } from '../events/emit.js';
|
|
29
|
-
import { operationIdContext } from '../events/operation-id.js';
|
|
30
|
-
import { findMissingPackagePaths } from './package-health.js';
|
|
31
|
-
import { FRONT_DOOR_ENV } from './front-door.js';
|
|
32
|
-
import { CANVAS_EXTENSIONS, piInvocationToSdkConfig, } from './launch.js';
|
|
33
|
-
import { assertEngineVersion, loadBrokerEngine } from './broker-sdk.js';
|
|
34
|
-
import { resolveBundledPiPackageDir } from './pi-cli.js';
|
|
35
|
-
import { captureSessionChatCapabilities } from './command-surface.js';
|
|
36
|
-
import { PoolCredentialStore } from '../pool-credential-store.js';
|
|
37
|
-
import { mutateBrokerFault, recordBrokerTurn } from './broker/daemon-ops.js';
|
|
38
|
-
import { modelRequestFromConfig, selectInitialModelRoute, unregisteredConcreteModel } from '../model-routes.js';
|
|
39
|
-
import { KNOWN_STREAM_WAIT_UI } from './stream-watchdog.js';
|
|
40
|
-
import { probeOnline as probeOnlineReal } from './connectivity.js';
|
|
41
|
-
import { CRTR_CYCLE_CUSTOM_TYPE, cycleAwareMessages } from './session-cycles.js';
|
|
42
|
-
import { projectTranscript } from './session-visibility.js';
|
|
43
|
-
import { currentTurnVisibility } from './turn-visibility.js';
|
|
44
|
-
import { isUnknownModel } from './model-selection.js';
|
|
45
|
-
import { BrokerClientRegistry } from './broker/client-registry.js';
|
|
46
|
-
import { ToolGroupTracker } from './broker/tool-groups.js';
|
|
47
|
-
import { onNodeNamed } from './broker/node-named.js';
|
|
48
|
-
import { FaultRetry } from './broker/fault-retry.js';
|
|
49
|
-
import { createTurnAdmissionGate } from './broker/turn-admission.js';
|
|
50
|
-
import { BROKER_IDLE_TURN_START } from './broker/held-deferred-inbox.js';
|
|
51
|
-
import { EventProjection } from './broker/event-projection.js';
|
|
52
|
-
import { createFrameDispatchContext, handleFrame, } from './broker/frame-dispatch.js';
|
|
53
|
-
import { hydratePersistedAdvertisedCommandMessages, installAdvertisedCommandInvocationContract, } from './advertised-command-invocation.js';
|
|
54
|
-
import { RebindDriver } from './broker/rebind.js';
|
|
55
|
-
import { decodeKickoffOrigin, KICKOFF_ORIGIN_ENV } from './stamp/protocol.js';
|
|
56
|
-
import { announceMessageOrigin } from './stamp/channel.js';
|
|
57
|
-
import { brokerExtensionState, commitBrokerModel } from './broker/daemon-ops.js';
|
|
58
|
-
import { FrameOverflowError, normalizeSnapshotTail, } from './broker-protocol.js';
|
|
59
|
-
/** A review companion may only navigate or fork within a branch whose ancestry
|
|
60
|
-
* has crossed its durable transcript boundary. The broker sends this typed local
|
|
61
|
-
* failure as a dedicated error frame without invoking pi's tree mutation. */
|
|
62
|
-
export { ReviewBoundaryNavigationError, REVIEW_BOUNDARY_NAVIGATION_CODE } from './broker/frame-replies.js';
|
|
63
|
-
/**
|
|
64
|
-
* pi 0.82 made `ModelRuntime` the canonical model/auth surface and demoted
|
|
65
|
-
* `ModelRegistry` to the synchronous facade over it (`find`/`getAll`/
|
|
66
|
-
* `getAvailable`/`hasConfiguredAuth` off the runtime's snapshot). The broker's
|
|
67
|
-
* model policy is synchronous throughout, so every read goes through this
|
|
68
|
-
* facade; it is a thin wrapper over the LIVE runtime, so constructing one per
|
|
69
|
-
* call reads current state rather than a captured view.
|
|
70
|
-
*/
|
|
71
|
-
function registryOf(services) {
|
|
72
|
-
return new ModelRegistry(services.modelRuntime);
|
|
73
|
-
}
|
|
74
|
-
/** The auth.json/models.json pair backing one agent dir's model runtime. */
|
|
75
|
-
function modelRuntimePaths(agentDir) {
|
|
76
|
-
return { authPath: join(agentDir, 'auth.json'), modelsPath: join(agentDir, 'models.json') };
|
|
77
|
-
}
|
|
78
|
-
function formatModelSpec(model, thinkingLevel) {
|
|
79
|
-
if (model === null || model === undefined || isUnknownModel(model))
|
|
80
|
-
return null;
|
|
81
|
-
const suffix = thinkingLevel !== undefined && thinkingLevel !== '' && thinkingLevel !== 'off' ? `:${thinkingLevel}` : '';
|
|
82
|
-
return `${model.provider}/${model.id}${suffix}`;
|
|
83
|
-
}
|
|
84
|
-
/** The ask-time fork recipe requires an explicit thinking level: `:off` is a
|
|
85
|
-
* real captured choice, not an omitted default that a future runtime may infer
|
|
86
|
-
* differently. */
|
|
87
|
-
function formatExactModelSpec(model, thinkingLevel) {
|
|
88
|
-
const base = formatModelSpec(model, undefined);
|
|
89
|
-
return base === null ? null : `${base}:${thinkingLevel === undefined || thinkingLevel === '' ? 'off' : thinkingLevel}`;
|
|
90
|
-
}
|
|
91
|
-
// Tunables (backpressure / dialog anti-deadlock)
|
|
92
|
-
/** Broker-side default dialog timeout (anti-deadlock). When an extension
|
|
93
|
-
* dialog is forwarded to every writable client, the broker ALWAYS arms a timeout
|
|
94
|
-
* (this default, or a shorter per-dialog `opts.timeout` if the extension passed
|
|
95
|
-
* one) so unanswered dialogs — including ones whose writable viewers all detach
|
|
96
|
-
* — can never hang the agent turn forever. On fire it resolves to the SAFE default
|
|
97
|
-
* (deny for confirm; cancel/undefined for select/input/editor). */
|
|
98
|
-
const DEFAULT_DIALOG_TIMEOUT_MS = 120_000; // 120 s
|
|
99
|
-
// M3 (scout mq5thyli): the active engine session, exposed so broker-cli's FATAL
|
|
100
|
-
// handlers (uncaughtException / unhandledRejection / the runBroker reject) can
|
|
101
|
-
// dispose it before process.exit. The bash tool spawns children `detached` (own
|
|
102
|
-
// pgid); only session.dispose() (→ abortBash / agent.abort → killProcessTree)
|
|
103
|
-
// reaps them. The graceful exit path already disposes; without this the crash
|
|
104
|
-
// path would `process.exit(1)` and ORPHAN every in-flight bash subprocess.
|
|
105
|
-
let activeSession = null;
|
|
106
|
-
/** Dispose the live engine session if one exists (idempotent). Called by
|
|
107
|
-
* broker-cli's fatal handlers before exit so a crash never orphans detached
|
|
108
|
-
* bash children. No-op before the session is built or after a clean dispose. */
|
|
109
|
-
export function disposeActiveSession() {
|
|
110
|
-
const s = activeSession;
|
|
111
|
-
activeSession = null;
|
|
112
|
-
if (s !== null) {
|
|
113
|
-
try {
|
|
114
|
-
s.dispose();
|
|
115
|
-
}
|
|
116
|
-
catch {
|
|
117
|
-
/* dispose must not block the fatal exit */
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
// runBroker — the broker process body (plan T4 steps 1–6)
|
|
122
|
-
export async function runBroker(nodeId, startupAt = process.hrtime.bigint(), startupTs = new Date().toISOString()) {
|
|
123
|
-
// The canonical broker event source (job/log.jsonl) is bound before any other
|
|
124
|
-
// work in this function — no path/env/state setup may precede it, and the
|
|
125
|
-
// binder independently validates nodeId before constructing that path.
|
|
126
|
-
bindBrokerEventSource(nodeId);
|
|
127
|
-
// One low-volume, node-correlated boot trace. It deliberately carries only
|
|
128
|
-
// timing and runtime identity — never prompts, commands, tokens, or secrets.
|
|
129
|
-
// broker-cli captures startupAt/startupTs before dynamically loading this
|
|
130
|
-
// module, so module_loaded's elapsed value includes the cold broker import
|
|
131
|
-
// graph, and cli_entry carries the exact process-spawn wall-clock time.
|
|
132
|
-
operationIdContext.fresh(() => {
|
|
133
|
-
emitEvent({
|
|
134
|
-
level: 'info',
|
|
135
|
-
event: 'broker.startup.cli_entry',
|
|
136
|
-
ts: startupTs,
|
|
137
|
-
duration_ms: 0,
|
|
138
|
-
fields: { runtime_version: process.version, engine_version: null, model: null },
|
|
139
|
-
});
|
|
140
|
-
emitEvent({
|
|
141
|
-
level: 'info',
|
|
142
|
-
event: 'broker.startup.module_loaded',
|
|
143
|
-
duration_ms: Number(process.hrtime.bigint() - startupAt) / 1_000_000,
|
|
144
|
-
fields: { runtime_version: process.version, engine_version: null, model: null },
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
// Structured, duplicate-suppressed startup milestones reached only once the
|
|
148
|
-
// engine is streaming a turn. `engineVersion` is populated below once
|
|
149
|
-
// assertEngineVersion resolves it; the milestones fire well after that.
|
|
150
|
-
const markedStartupEvents = new Set();
|
|
151
|
-
let engineVersion = null;
|
|
152
|
-
const emitStartupMilestone = (event, model = null) => {
|
|
153
|
-
if (markedStartupEvents.has(event))
|
|
154
|
-
return;
|
|
155
|
-
markedStartupEvents.add(event);
|
|
156
|
-
// Under CRTR_TIMING the same milestone also lands on the cross-process
|
|
157
|
-
// front-door timeline (stderr → this broker's broker.log), so it can be
|
|
158
|
-
// read next to the cli/viewer markers instead of only in the job log.
|
|
159
|
-
mark(event, { duration_ms: Number(process.hrtime.bigint() - startupAt) / 1_000_000 });
|
|
160
|
-
emitEvent({
|
|
161
|
-
level: 'info',
|
|
162
|
-
event,
|
|
163
|
-
duration_ms: Number(process.hrtime.bigint() - startupAt) / 1_000_000,
|
|
164
|
-
fields: { runtime_version: process.version, engine_version: engineVersion, model },
|
|
165
|
-
});
|
|
166
|
-
};
|
|
167
|
-
// Defensive: any `crtr` child the engine/extensions spawn must inherit the
|
|
168
|
-
// front-door recursion guard (see
|
|
169
|
-
// src/core/runtime/.crouter/memory/INDEX.md). The host also sets this;
|
|
170
|
-
// setting it here keeps the broker self-sufficient.
|
|
171
|
-
process.env[FRONT_DOOR_ENV] = '1';
|
|
172
|
-
// A successful in-turn crtr command stamps this process id into its stop
|
|
173
|
-
// signal, so a crash-revived broker cannot consume a prior broker's outcome.
|
|
174
|
-
process.env['CRTR_BROKER_PID'] = String(process.pid);
|
|
175
|
-
// The broker is PANELESS and detached, but a broker spawned by a tmux-resident
|
|
176
|
-
// parent inherits the parent's TMUX_PANE/TMUX in its env (the launcher spawns
|
|
177
|
-
// with {...process.env}). Left in place, every `crtr` command the engine runs
|
|
178
|
-
// (bash tool, goal-capture naming, a child spawn) would resolve `currentTmux()`
|
|
179
|
-
// to the PARENT's pane/session and act there — e.g. open viewers beside, or
|
|
180
|
-
// close, the parent's pane. Strip both so this broker's children see no tmux
|
|
181
|
-
// context and take their paneless path.
|
|
182
|
-
delete process.env['TMUX_PANE'];
|
|
183
|
-
delete process.env['TMUX'];
|
|
184
|
-
// 1. Version tripwire + load the launch recipe the host serialized.
|
|
185
|
-
const engine = await loadBrokerEngine();
|
|
186
|
-
assertEngineVersion(engine.VERSION);
|
|
187
|
-
engineVersion = engine.VERSION;
|
|
188
|
-
// M4 / M6 (scout mq5thyli) — DELIBERATELY SKIPPED on the 0.78.1 pin. Both
|
|
189
|
-
// `configureHttpDispatcher` (M4: proxy support + the undici decompression fix)
|
|
190
|
-
// and `runMigrations` (M6: config/auth migration for a box where the pi CLI
|
|
191
|
-
// never ran) are CLI-only helpers that the pinned SDK does NOT re-export: the
|
|
192
|
-
// package's `exports` map is `.`-only, neither symbol is in `dist/index.d.ts`,
|
|
193
|
-
// a deep import (`.../dist/core/http-dispatcher.js`) is blocked with
|
|
194
|
-
// ERR_PACKAGE_PATH_NOT_EXPORTED, and the only exports-map entries are `.` and
|
|
195
|
-
// `./hooks` (neither carries these symbols). Per the "verify export; skip-with-
|
|
196
|
-
// note if absent" directive we do not vendor or reach around the export wall.
|
|
197
|
-
// Revisit when the SDK pin bumps to a version that re-exports them publicly.
|
|
198
|
-
const dir = nodeDir(nodeId);
|
|
199
|
-
const launchFile = join(dir, 'broker-launch.json');
|
|
200
|
-
const inv = JSON.parse(readFileSync(launchFile, 'utf8'));
|
|
201
|
-
const cfg = piInvocationToSdkConfig(inv); // also merges inv.env
|
|
202
|
-
if (cfg.modelExact === true)
|
|
203
|
-
process.env['CRTR_MODEL_EXACT'] = '1';
|
|
204
|
-
else
|
|
205
|
-
delete process.env['CRTR_MODEL_EXACT'];
|
|
206
|
-
// 2–4. Build the engine session via the SERVICES path (C3) — see
|
|
207
|
-
// buildBrokerSession below. Register it so the FATAL exit path (M3) can
|
|
208
|
-
// dispose it and reap detached bash children.
|
|
209
|
-
// `session` + `services` are MUTABLE holders (session-rebind): when the
|
|
210
|
-
// controller drives new_session/switch_session/fork, the AgentSessionRuntime
|
|
211
|
-
// tears down the old session and builds the next one, then runs our rebind
|
|
212
|
-
// callback which reassigns these. Every closure below (buildSnapshot,
|
|
213
|
-
// driveEngine, handleFrame, disposeAndExit) reads through them, so they all
|
|
214
|
-
// follow the live session automatically. `runtime` is undefined for an engine
|
|
215
|
-
// that does not expose the replacement API (the fake-engine fixture).
|
|
216
|
-
// eslint-disable-next-line prefer-const
|
|
217
|
-
let { session, services, resuming, runtime } = await buildBrokerSession(engine, cfg);
|
|
218
|
-
// Review identity is immutable for the broker's lifetime. Snapshot producers
|
|
219
|
-
// close over this one construction-time classification rather than re-reading
|
|
220
|
-
// canvas metadata for every welcome or session replacement. The BOUND review
|
|
221
|
-
// id (not a mere boolean) is what selects this companion's own boundary
|
|
222
|
-
// marker — a fork of another companion inherits that companion's earlier
|
|
223
|
-
// marker, and slicing at any marker would reveal its transcript.
|
|
224
|
-
const boundaryReviewId = (await brokerExtensionState(nodeId)).node.review_binding?.review_id;
|
|
225
|
-
// M3: name the boot session as the process-fatal disposal target immediately —
|
|
226
|
-
// enqueueRebind reassigns this on every later replacement, but without this
|
|
227
|
-
// initial assignment `activeSession` stays null (and disposeActiveSession() a
|
|
228
|
-
// no-op) for every exit that happens before the FIRST session replacement,
|
|
229
|
-
// which is the common case.
|
|
230
|
-
activeSession = session;
|
|
231
|
-
const retryProbe = probeOnlineReal;
|
|
232
|
-
// Initialize pi's process-global theme. The pi binary does this at boot
|
|
233
|
-
// (main.js: initTheme(settingsManager.getTheme(), appMode === 'interactive')),
|
|
234
|
-
// but the SDK convenience path the broker uses does NOT. Without it, ANY
|
|
235
|
-
// extension hook that reads `ctx.ui.theme` throws "Theme not initialized" —
|
|
236
|
-
// and the extension runner SILENTLY swallows that throw and discards the
|
|
237
|
-
// hook's returned payload. The visible symptom was the OAuth billing adapter's
|
|
238
|
-
// before_provider_request handler throwing, so its injected Claude-Code billing
|
|
239
|
-
// header was dropped and subscription turns 400'd ("draws from extra usage").
|
|
240
|
-
// headless ⇒ no file watcher (false). Idempotent global; call once at boot.
|
|
241
|
-
// Always replace an inherited PI_PACKAGE_DIR: a viewer launched from a pnpm
|
|
242
|
-
// path may pass its `.pnpm` package copy down to the daemon/broker, but that
|
|
243
|
-
// copy can omit the JSON theme assets. The broker must use crouter's actual
|
|
244
|
-
// bundled package root, exactly like its incidental pi subprocesses.
|
|
245
|
-
try {
|
|
246
|
-
process.env['PI_PACKAGE_DIR'] = resolveBundledPiPackageDir();
|
|
247
|
-
initTheme(services.settingsManager.getTheme(), false);
|
|
248
|
-
}
|
|
249
|
-
catch (err) {
|
|
250
|
-
emitEvent({
|
|
251
|
-
level: 'error',
|
|
252
|
-
event: 'broker.theme.initialization_failed',
|
|
253
|
-
error: err,
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
// Diagnose stale local-path pi packages without persisting the human-facing
|
|
257
|
-
// formatter's prose. The front door retains that actionable presentation.
|
|
258
|
-
try {
|
|
259
|
-
for (const missing of findMissingPackagePaths(getAgentDir())) {
|
|
260
|
-
emitEvent({
|
|
261
|
-
level: 'warn',
|
|
262
|
-
event: 'broker.startup.warning',
|
|
263
|
-
fields: {
|
|
264
|
-
stage: 'package_health',
|
|
265
|
-
source: missing.source,
|
|
266
|
-
resolved_path: missing.resolved,
|
|
267
|
-
},
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
catch {
|
|
272
|
-
/* best-effort */
|
|
273
|
-
}
|
|
274
|
-
// N3: the node's display name is re-applied by the rebind lane below so it
|
|
275
|
-
// survives a session replacement (new_session/switch_session/fork), not only at
|
|
276
|
-
// boot.
|
|
277
|
-
// Socket fan-out, dialogs, and transcript tool groups
|
|
278
|
-
const sockPath = viewSocketPath(nodeId);
|
|
279
|
-
const registry = new BrokerClientRegistry(nodeId);
|
|
280
|
-
const pendingDialogs = new Map();
|
|
281
|
-
const toolGroups = new ToolGroupTracker(nodeId, (frame) => registry.broadcast(frame));
|
|
282
|
-
// The naming extension commits the node's generated name a few seconds into
|
|
283
|
-
// its first turn and hands it here (broker/node-named.ts). Every attached
|
|
284
|
-
// client learns it on the pipe it already holds instead of re-reading the node
|
|
285
|
-
// on some later, unrelated trigger.
|
|
286
|
-
onNodeNamed((notice) => registry.broadcast({ type: 'node_named', ...notice }));
|
|
287
|
-
let disposed = false;
|
|
288
|
-
let disposePending = false;
|
|
289
|
-
let server;
|
|
290
|
-
let uiContext;
|
|
291
|
-
let rebind;
|
|
292
|
-
let faultRetry;
|
|
293
|
-
let projection;
|
|
294
|
-
let notifyTurnAccepted = () => { };
|
|
295
|
-
let resetFrameState = () => { };
|
|
296
|
-
rebind = new RebindDriver({
|
|
297
|
-
nodeId, cfg, session, services, runtime, registry, toolGroups,
|
|
298
|
-
uiContext: () => uiContext,
|
|
299
|
-
faultRetry: () => faultRetry,
|
|
300
|
-
projection: () => projection,
|
|
301
|
-
setActiveSession: (candidate) => { activeSession = candidate; },
|
|
302
|
-
disposeAndExit: (reason, status) => disposeAndExit(reason, status),
|
|
303
|
-
onSessionRebind: () => {
|
|
304
|
-
resetFrameState();
|
|
305
|
-
},
|
|
306
|
-
reWelcomeAll: () => reWelcomeAll(),
|
|
307
|
-
});
|
|
308
|
-
// Pi's model controls mutate only the live engine. Commit the concrete model
|
|
309
|
-
// and thinking choice through crtrd before acknowledging or broadcasting it,
|
|
310
|
-
// so the daemon remains the only durable canvas owner.
|
|
311
|
-
const persistModelChoice = async (pinnedOverride, userSelected = false) => {
|
|
312
|
-
const liveSession = rebind.session();
|
|
313
|
-
const spec = formatModelSpec(liveSession.model, liveSession.thinkingLevel);
|
|
314
|
-
if (spec === null)
|
|
315
|
-
return null;
|
|
316
|
-
const result = await commitBrokerModel(nodeId, { spec, pinnedOverride, userSelected });
|
|
317
|
-
if (userSelected) {
|
|
318
|
-
delete process.env['CRTR_MODEL_INTENT'];
|
|
319
|
-
process.env['CRTR_MODEL_EXACT'] = '1';
|
|
320
|
-
cfg.model = result.modelOverride;
|
|
321
|
-
cfg.modelExact = true;
|
|
322
|
-
}
|
|
323
|
-
return result.modelOverride;
|
|
324
|
-
};
|
|
325
|
-
// Pi emits no AgentSessionEvent for a model switch, so after a successful
|
|
326
|
-
// set_model/cycle_model the broker announces it itself. A durable change is
|
|
327
|
-
// broadcast only after crtrd returns the committed override.
|
|
328
|
-
const broadcastModelChanged = async (persist = true, pinnedOverride, userSelected = false) => {
|
|
329
|
-
const liveSession = rebind.session();
|
|
330
|
-
const liveSpec = formatModelSpec(liveSession.model, liveSession.thinkingLevel);
|
|
331
|
-
const spec = persist ? await persistModelChoice(pinnedOverride, userSelected) : liveSpec;
|
|
332
|
-
registry.broadcast({ type: 'model_changed', model: isUnknownModel(liveSession.model) ? undefined : liveSession.model, spec });
|
|
333
|
-
};
|
|
334
|
-
const turnAdmission = createTurnAdmissionGate();
|
|
335
|
-
// The inbox watcher is Jiti-loaded and cannot import this native module's
|
|
336
|
-
// gate. Its idle delivery therefore calls this narrow process-global bridge:
|
|
337
|
-
// acquire admission first, then re-read the live session before prompt() so
|
|
338
|
-
// a viewer turn that won the race is joined rather than double-started.
|
|
339
|
-
const startIdleInboxTurn = (text) => {
|
|
340
|
-
void turnAdmission.admit((release) => {
|
|
341
|
-
const liveSession = rebind.session();
|
|
342
|
-
return liveSession
|
|
343
|
-
.prompt(text, {
|
|
344
|
-
preflightResult: release,
|
|
345
|
-
...(liveSession.isStreaming ? { streamingBehavior: 'steer' } : {}),
|
|
346
|
-
})
|
|
347
|
-
.catch((error) => {
|
|
348
|
-
emitEvent({ level: 'error', event: 'broker.inbox.idle_prompt_failed', error });
|
|
349
|
-
});
|
|
350
|
-
});
|
|
351
|
-
};
|
|
352
|
-
globalThis[BROKER_IDLE_TURN_START] = startIdleInboxTurn;
|
|
353
|
-
faultRetry = new FaultRetry({
|
|
354
|
-
nodeId,
|
|
355
|
-
cfg,
|
|
356
|
-
retryProbe,
|
|
357
|
-
currentSession: () => rebind.session(),
|
|
358
|
-
currentServices: () => rebind.services(),
|
|
359
|
-
installedGeneration: () => rebind.installedGeneration(),
|
|
360
|
-
registryOf,
|
|
361
|
-
formatModelSpec,
|
|
362
|
-
broadcastModelChanged,
|
|
363
|
-
turnAdmission,
|
|
364
|
-
});
|
|
365
|
-
projection = new EventProjection({
|
|
366
|
-
registry,
|
|
367
|
-
faultRetry,
|
|
368
|
-
installedGeneration: () => rebind.installedGeneration(),
|
|
369
|
-
currentSession: () => rebind.session(),
|
|
370
|
-
notifyTurnAccepted: () => notifyTurnAccepted(),
|
|
371
|
-
emitStartupMilestone,
|
|
372
|
-
formatModelSpec,
|
|
373
|
-
});
|
|
374
|
-
const buildSnapshot = (client) => {
|
|
375
|
-
const liveSession = rebind.session();
|
|
376
|
-
const identified = snapshotMessages(liveSession, boundaryReviewId);
|
|
377
|
-
const tail = normalizeSnapshotTail(client.snapshotTail);
|
|
378
|
-
// A tail is only usable with stable ids, which let its recipient page back
|
|
379
|
-
// to the omitted history.
|
|
380
|
-
const retained = identified === undefined || tail === undefined ? identified : identified.slice(-tail);
|
|
381
|
-
const messages = retained?.map(({ message }) => message)
|
|
382
|
-
?? liveSession.sessionManager.buildSessionContext().messages;
|
|
383
|
-
const fullToolGroupSummaries = toolGroups.summaries();
|
|
384
|
-
const retainedToolCallIds = retained !== undefined && tail !== undefined ? toolCallIds(messages) : undefined;
|
|
385
|
-
const toolGroupSummaries = retainedToolCallIds === undefined
|
|
386
|
-
? fullToolGroupSummaries
|
|
387
|
-
: Object.fromEntries(Object.entries(fullToolGroupSummaries).filter(([id]) => retainedToolCallIds.has(id)));
|
|
388
|
-
return ({
|
|
389
|
-
messages,
|
|
390
|
-
...(retained === undefined ? {} : { messageIds: retained.map(({ id }) => id) }),
|
|
391
|
-
messageVisibility: retained?.map(({ visibility }) => visibility)
|
|
392
|
-
?? messages.map(() => 'visible'),
|
|
393
|
-
turnVisibility: currentTurnVisibility(),
|
|
394
|
-
stats: liveSession.getSessionStats(),
|
|
395
|
-
// pi's `get_state` (rpc-mode.js), field for field, from the same getters.
|
|
396
|
-
// The ONE divergence: a model-less session (undefined OR the SDK
|
|
397
|
-
// unknown-stub) reports no model, matching broadcastModelChanged — never a
|
|
398
|
-
// fictitious `unknown` selection.
|
|
399
|
-
state: {
|
|
400
|
-
model: isUnknownModel(liveSession.model) ? undefined : liveSession.model,
|
|
401
|
-
thinkingLevel: liveSession.thinkingLevel,
|
|
402
|
-
isStreaming: liveSession.isStreaming,
|
|
403
|
-
isCompacting: liveSession.isCompacting,
|
|
404
|
-
steeringMode: liveSession.steeringMode,
|
|
405
|
-
followUpMode: liveSession.followUpMode,
|
|
406
|
-
sessionFile: liveSession.sessionFile,
|
|
407
|
-
sessionId: liveSession.sessionId,
|
|
408
|
-
sessionName: liveSession.sessionName,
|
|
409
|
-
autoCompactionEnabled: liveSession.autoCompactionEnabled,
|
|
410
|
-
messageCount: liveSession.messages.length,
|
|
411
|
-
pendingMessageCount: liveSession.pendingMessageCount,
|
|
412
|
-
},
|
|
413
|
-
// Broker-owned levels (see BrokerSnapshot.display). Copied out so a later
|
|
414
|
-
// mutation of the retained maps cannot alias a frame already serialized.
|
|
415
|
-
display: {
|
|
416
|
-
...registry.displaySnapshot(),
|
|
417
|
-
},
|
|
418
|
-
toolGroupSummaries,
|
|
419
|
-
workingActivity: projection.currentWorkingActivity(),
|
|
420
|
-
// The UNRUN queue's texts, read non-destructively (`clearQueue()` would
|
|
421
|
-
// consume them). Same two arrays a live `queue_update` carries, so a client
|
|
422
|
-
// that attaches mid-queue lands on the state its next `queue_update` would
|
|
423
|
-
// have produced.
|
|
424
|
-
queued: {
|
|
425
|
-
steering: [...liveSession.getSteeringMessages()],
|
|
426
|
-
followUp: [...liveSession.getFollowUpMessages()],
|
|
427
|
-
},
|
|
428
|
-
});
|
|
429
|
-
};
|
|
430
|
-
// Send a client its catch-up snapshot. welcome.pending_dialog carries a single
|
|
431
|
-
// still-in-flight dialog to a WRITABLE client attaching mid-dialog; an observer
|
|
432
|
-
// can never answer one, so observers get null. The pendingDialogs map is
|
|
433
|
-
// insertion-ordered — the first entry is the canonical one carried here; any
|
|
434
|
-
// extras are replayed explicitly by the caller (rare: concurrent dialogs).
|
|
435
|
-
const sendWelcome = (client) => {
|
|
436
|
-
const first = client.role === 'controller' ? pendingDialogs.values().next().value : undefined;
|
|
437
|
-
registry.sendFrame(client, {
|
|
438
|
-
type: 'welcome',
|
|
439
|
-
snapshot: buildSnapshot(client),
|
|
440
|
-
role: client.role,
|
|
441
|
-
pending_dialog: first !== undefined ? first.request : null,
|
|
442
|
-
agentDir: getAgentDir(),
|
|
443
|
-
}, true);
|
|
444
|
-
// No display_* replay: the retained extension state rides IN the snapshot
|
|
445
|
-
// (`snapshot.display`), so catch-up is one atomic frame. A viewer attaching
|
|
446
|
-
// after an idle brief was painted still sees it on first paint, and there is
|
|
447
|
-
// no window between `welcome` and the replay where chrome renders blank.
|
|
448
|
-
};
|
|
449
|
-
// Attach-mid-dialog replay: a dialog raised before this client attached is
|
|
450
|
-
// still pending (a peer detaching never cancels one — see makeBrokerUiContext),
|
|
451
|
-
// so a writable client joining afterwards is handed every in-flight dialog and
|
|
452
|
-
// becomes a full peer in the race to answer it. `welcome.pending_dialog` already
|
|
453
|
-
// carried the FIRST entry, so this replays only the extras.
|
|
454
|
-
const replayExtraPendingDialogsTo = (client) => {
|
|
455
|
-
const pend = [...pendingDialogs.values()];
|
|
456
|
-
for (let i = 1; i < pend.length; i++)
|
|
457
|
-
registry.sendFrame(client, pend[i].request);
|
|
458
|
-
};
|
|
459
|
-
// After a session-replacing op (new_session/switch_session/fork) the engine's
|
|
460
|
-
// entire message history changed, so every attached viewer must rebuild from a
|
|
461
|
-
// fresh snapshot of the NEW session.
|
|
462
|
-
const reWelcomeAll = () => {
|
|
463
|
-
registry.forEachHelloed(sendWelcome);
|
|
464
|
-
};
|
|
465
|
-
// The single exit helper: dispose the engine, close + unlink the
|
|
466
|
-
// socket, exit 0. Idempotent — every trigger converges here.
|
|
467
|
-
const completeExit = (status) => {
|
|
468
|
-
if (disposed)
|
|
469
|
-
return;
|
|
470
|
-
disposed = true;
|
|
471
|
-
// Daemon teardown cannot wait for a recap's 45-second model timeout. Preserve
|
|
472
|
-
// exactly the newest already-capped input so the successor broker can finish
|
|
473
|
-
// it, persist the normal summary, and remove the handoff record.
|
|
474
|
-
toolGroups.persistPendingSummary();
|
|
475
|
-
projection.dispose();
|
|
476
|
-
// disposeActiveSession atomically clears the process-global pointer before
|
|
477
|
-
// disposing — whichever engine session (committed or an in-flight rebind
|
|
478
|
-
// candidate) it currently names, matching broker-cli's fatal-handler primitive.
|
|
479
|
-
disposeActiveSession();
|
|
480
|
-
try {
|
|
481
|
-
server?.close();
|
|
482
|
-
}
|
|
483
|
-
catch {
|
|
484
|
-
/* ignore */
|
|
485
|
-
}
|
|
486
|
-
// Destroy every viewer socket without waiting for close events.
|
|
487
|
-
registry.dispose();
|
|
488
|
-
try {
|
|
489
|
-
if (existsSync(sockPath))
|
|
490
|
-
unlinkSync(sockPath);
|
|
491
|
-
}
|
|
492
|
-
catch {
|
|
493
|
-
/* ignore */
|
|
494
|
-
}
|
|
495
|
-
// A clean exit never leaves a stale presence claim behind.
|
|
496
|
-
registry.clearAttachState();
|
|
497
|
-
process.exit(status);
|
|
498
|
-
};
|
|
499
|
-
const disposeAndExit = (reason, status = 0) => {
|
|
500
|
-
if (disposed)
|
|
501
|
-
return;
|
|
502
|
-
const graceful = reason === 'shutdown-hook' || reason === 'shutdown-after-settle';
|
|
503
|
-
// A graceful shutdown (yield, dormancy, daemon restart) is the final
|
|
504
|
-
// boundary of the conversation's last tool group. Group state lives only in
|
|
505
|
-
// this process, so a group left open here is unsummarizable forever and its
|
|
506
|
-
// calls render raw in every future view of the transcript. Close it now —
|
|
507
|
-
// generateSettledToolGroup registers its task synchronously, so the wait
|
|
508
|
-
// below covers the summary it launches. Any pending tool arguments are
|
|
509
|
-
// included without inventing a result; the visible abort remains outside
|
|
510
|
-
// the recap and Ctrl+O retains every underlying call row.
|
|
511
|
-
if (graceful)
|
|
512
|
-
toolGroups.finishOpenToolGroup(true);
|
|
513
|
-
// A normal terminal shutdown follows a visible boundary that may have just
|
|
514
|
-
// launched a capped (45s) headless summary. Keep the broker and its child
|
|
515
|
-
// alive until those already-started tasks persist/broadcast, rather than
|
|
516
|
-
// process.exit() orphaning pi and losing the sidecar. Abrupt failures and
|
|
517
|
-
// signals retain their existing immediate teardown behavior.
|
|
518
|
-
if (graceful && toolGroups.hasSummaryTasks()) {
|
|
519
|
-
if (disposePending)
|
|
520
|
-
return;
|
|
521
|
-
disposePending = true;
|
|
522
|
-
void toolGroups.waitForSummaryTasks().finally(() => completeExit(status));
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
completeExit(status);
|
|
526
|
-
};
|
|
527
|
-
// Extension-dialog routing (C2). makeBrokerUiContext owns the dialogPromise;
|
|
528
|
-
// here we just give it the three broker-side hooks it needs: the live set of
|
|
529
|
-
// writable clients (empty = nobody can answer → noOp fallback), how to forward a
|
|
530
|
-
// dialog to one of them, and the pending-dialog registry whichever one answers
|
|
531
|
-
// first settles through. The zero-writable path NEVER hangs and NEVER waits on a
|
|
532
|
-
// per-dialog timeout (design §5.4's timeout premise is false — see
|
|
533
|
-
// makeBrokerUiContext).
|
|
534
|
-
uiContext = makeBrokerUiContext({
|
|
535
|
-
writable: () => registry.writableClients(),
|
|
536
|
-
forward: (client, request) => registry.sendFrame(client, request),
|
|
537
|
-
pending: pendingDialogs,
|
|
538
|
-
broadcast: (frame) => registry.broadcastUi(frame),
|
|
539
|
-
// A deliberate managed-provider cooldown wait is known liveness, not a wedged
|
|
540
|
-
// stream: pause the dead-stream watchdog for its duration. Only pause for a
|
|
541
|
-
// finite future deadline, and resume ONLY while the same turn is still
|
|
542
|
-
// awaiting the provider (streaming, no tool running) so a wait that outlived
|
|
543
|
-
// its turn can't rearm a stale session; otherwise fully reset.
|
|
544
|
-
onKnownStreamWait: (deadlineMs) => projection.knownStreamWait(deadlineMs),
|
|
545
|
-
});
|
|
546
|
-
// Bind the rebind driver before accepting socket frames. It owns subscription
|
|
547
|
-
// replacement and its bounded runtime-mutation admission lane.
|
|
548
|
-
rebind.setRebindSession();
|
|
549
|
-
await rebind.enqueueRebind(session, services);
|
|
550
|
-
const frameDispatch = createFrameDispatchContext({
|
|
551
|
-
nodeId, cfg, registry, toolGroups, projection, rebind, boundaryReviewId,
|
|
552
|
-
pendingDialogs, sendWelcome, replayExtraPendingDialogsTo, reWelcomeAll, disposeAndExit,
|
|
553
|
-
persistModelChoice, broadcastModelChanged, registryOf, formatModelSpec,
|
|
554
|
-
formatExactModelSpec, turnAdmission, resolveLaunchModel,
|
|
555
|
-
});
|
|
556
|
-
notifyTurnAccepted = frameDispatch.notifyTurnAccepted;
|
|
557
|
-
resetFrameState = frameDispatch.resetForSession;
|
|
558
|
-
// 4 (plan): the socket listener — unlink any stale socket first.
|
|
559
|
-
try {
|
|
560
|
-
if (existsSync(sockPath))
|
|
561
|
-
unlinkSync(sockPath);
|
|
562
|
-
}
|
|
563
|
-
catch {
|
|
564
|
-
/* a fresh listen below will surface a real problem */
|
|
565
|
-
}
|
|
566
|
-
server = createServer((socket) => {
|
|
567
|
-
const client = registry.create(socket);
|
|
568
|
-
socket.on('data', (chunk) => {
|
|
569
|
-
let frames;
|
|
570
|
-
try {
|
|
571
|
-
frames = client.decoder.push(chunk);
|
|
572
|
-
}
|
|
573
|
-
catch (err) {
|
|
574
|
-
// G7: a client frame over the bounded decoder caps (FrameOverflowError) is
|
|
575
|
-
// cap-and-dropped — best-effort error frame, then destroy the peer. The
|
|
576
|
-
// broker survives. The try/catch is around push() itself (not just the
|
|
577
|
-
// per-frame loop) because push() throws BEFORE returning any frames.
|
|
578
|
-
if (err instanceof FrameOverflowError) {
|
|
579
|
-
registry.sendFrame(client, { type: 'error', code: 'frame_overflow', message: err.message });
|
|
580
|
-
registry.dropClient(client, `frame overflow: ${err.message}`);
|
|
581
|
-
}
|
|
582
|
-
else {
|
|
583
|
-
registry.dropClient(client, `decoder error: ${String(err)}`);
|
|
584
|
-
}
|
|
585
|
-
return;
|
|
586
|
-
}
|
|
587
|
-
for (const raw of frames) {
|
|
588
|
-
try {
|
|
589
|
-
handleFrame(frameDispatch, client, raw);
|
|
590
|
-
}
|
|
591
|
-
catch {
|
|
592
|
-
/* one bad frame never crashes the broker */
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
});
|
|
596
|
-
const drop = () => {
|
|
597
|
-
registry.removeClient(client); // a viewer disconnected
|
|
598
|
-
// A writable client detaching does NOT cancel in-flight dialogs — they stay
|
|
599
|
-
// pending under the broker-side default timeout, so a peer that is still
|
|
600
|
-
// attached (or one that attaches next and gets the replay) can still answer.
|
|
601
|
-
// Only an answer, the timeout, or an abort resolves one.
|
|
602
|
-
};
|
|
603
|
-
socket.on('close', drop);
|
|
604
|
-
socket.on('error', () => {
|
|
605
|
-
/* close follows; drop there */
|
|
606
|
-
});
|
|
607
|
-
});
|
|
608
|
-
server.on('error', (err) => {
|
|
609
|
-
// A recursive error raised during/after disposeAndExit's own server.close()
|
|
610
|
-
// (or any other exit already in flight) must not emit a second canonical
|
|
611
|
-
// failure or dispose twice.
|
|
612
|
-
if (disposed)
|
|
613
|
-
return;
|
|
614
|
-
emitEvent({ level: 'error', event: 'broker.socket.failed', error: err });
|
|
615
|
-
disposeAndExit('socket-error', 1);
|
|
616
|
-
});
|
|
617
|
-
server.listen(sockPath, async () => {
|
|
618
|
-
// Binding view.sock is the exact inverse of a `connect ENOENT view.sock`
|
|
619
|
-
// fault, so the moment the listener accepts, any socket-absence marker a
|
|
620
|
-
// viewer/relay recorded during the revive→bind gap is provably stale. The
|
|
621
|
-
// broker owns this socket, so it clears those markers here rather than
|
|
622
|
-
// waiting for a client to reconnect — a headless node with nobody attached
|
|
623
|
-
// never gets that reconnect, which is how the stale ⚠ leaked. A genuine
|
|
624
|
-
// post-bind failure is re-recorded by the next failed client op.
|
|
625
|
-
void Promise.all([
|
|
626
|
-
mutateBrokerFault(nodeId, { op: 'clear', link: 'viewer↔broker' }),
|
|
627
|
-
mutateBrokerFault(nodeId, { op: 'clear', link: 'relay↔broker' }),
|
|
628
|
-
]).catch((error) => emitEvent({ level: 'error', event: 'broker.daemon.operation.failed', node_id: nodeId, error, fields: { operation: 'broker_socket_bound_fault_clear' } }));
|
|
629
|
-
// The listener is also the broker startup boundary: a pending or
|
|
630
|
-
// surviving-admitted provider episode is re-armed only once this
|
|
631
|
-
// replacement can accept its normal viewer/daemon traffic. Independent of
|
|
632
|
-
// the link faults cleared above — those are viewer/relay socket markers,
|
|
633
|
-
// this is the provider retry episode. An invalidated record is
|
|
634
|
-
// intentionally inert inside FaultRetry.
|
|
635
|
-
let recovery;
|
|
636
|
-
try {
|
|
637
|
-
recovery = await faultRetry.recoverOnStartup();
|
|
638
|
-
}
|
|
639
|
-
catch (error) {
|
|
640
|
-
emitEvent({ level: 'error', event: 'broker.daemon.operation.failed', node_id: nodeId, error, fields: { operation: 'recovery_startup' } });
|
|
641
|
-
disposeAndExit('recovery-startup-failed', 1);
|
|
642
|
-
return;
|
|
643
|
-
}
|
|
644
|
-
// A launch prompt delivers only after the listener is accepting, so a
|
|
645
|
-
// root-spawn readiness proof and prompt admission share one boundary. This
|
|
646
|
-
// includes the one continuation carried by a clean runtime-abort resume.
|
|
647
|
-
// A model-less tier-3 boot (session.model === undefined) leaves the prompt
|
|
648
|
-
// pending in kickoffPending; drivePendingKickoff is a no-op until the
|
|
649
|
-
// reload_auth re-drive resolves a model, at which point it fires. For the
|
|
650
|
-
// common model-present path this fires immediately — unchanged behavior.
|
|
651
|
-
//
|
|
652
|
-
// recoverOnStartup returning 'retry-armed' means a resuming, non-cycling
|
|
653
|
-
// replacement is re-driving a provider-fault recovery card instead — this
|
|
654
|
-
// can never discard a birth mandate, a wake card, or a revive kickoff,
|
|
655
|
-
// because every kickoff-composing branch other than the runtime-restart-abort
|
|
656
|
-
// continuation is either !hasSessionPath or newCycle, both of which
|
|
657
|
-
// recoverOnStartup already refuses outright by returning 'none' before an
|
|
658
|
-
// episode can even be considered. So the only prompt this suppression can
|
|
659
|
-
// ever suppress is that one continuation, and only when the episode proves
|
|
660
|
-
// the resume made no progress past its anchor.
|
|
661
|
-
if (recovery !== 'retry-armed' && cfg.firstPrompt !== undefined && cfg.firstPrompt !== '') {
|
|
662
|
-
// The spawner recorded who authored this kickoff (a birth mandate, a
|
|
663
|
-
// cron wake, a revive card); announce it against the exact text so the
|
|
664
|
-
// stamp writer claims it on the message pi persists.
|
|
665
|
-
const kickoffOrigin = decodeKickoffOrigin(process.env[KICKOFF_ORIGIN_ENV]);
|
|
666
|
-
if (kickoffOrigin !== null)
|
|
667
|
-
announceMessageOrigin(cfg.firstPrompt, kickoffOrigin);
|
|
668
|
-
frameDispatch.kickoff(cfg.firstPrompt);
|
|
669
|
-
}
|
|
670
|
-
});
|
|
671
|
-
// Initialize presence to the truthful zero state at boot — this also
|
|
672
|
-
// overwrites a stale attach.json a crashed prior incarnation left behind.
|
|
673
|
-
registry.persistAttachState();
|
|
674
|
-
// Record teardown-aborted only after Pi persists the aborted turn.
|
|
675
|
-
// Timeout or rejection leaves the SQL interrupted-turn evidence intact.
|
|
676
|
-
const ABORT_BEFORE_EXIT_MS = 2_500;
|
|
677
|
-
let signalExitInFlight = false;
|
|
678
|
-
const abortAndExit = async (reason) => {
|
|
679
|
-
if (disposed || signalExitInFlight)
|
|
680
|
-
return;
|
|
681
|
-
signalExitInFlight = true;
|
|
682
|
-
const busy = rebind.isAgentRunActive() || rebind.session().isStreaming || frameDispatch.pendingPromptDispatches() > 0;
|
|
683
|
-
if (busy) {
|
|
684
|
-
const deadline = Date.now() + ABORT_BEFORE_EXIT_MS;
|
|
685
|
-
// prompt() has a real async pre-turn window where abort() silently no-ops.
|
|
686
|
-
// Wait only within the daemon's fixed teardown budget for it to become
|
|
687
|
-
// abortable. A still-pending setup is deliberately marked dirty below so
|
|
688
|
-
// recovery starts a cycle instead of silently losing the prompt on resume.
|
|
689
|
-
while (frameDispatch.pendingPromptDispatches() > 0 && !rebind.session().isStreaming && Date.now() < deadline) {
|
|
690
|
-
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
691
|
-
}
|
|
692
|
-
if (rebind.session().isStreaming) {
|
|
693
|
-
const remaining = deadline - Date.now();
|
|
694
|
-
if (remaining > 0) {
|
|
695
|
-
let timer;
|
|
696
|
-
try {
|
|
697
|
-
const settled = await Promise.race([
|
|
698
|
-
rebind.session().abort().then(() => true, () => false),
|
|
699
|
-
new Promise((resolve) => { timer = setTimeout(() => resolve(false), remaining); }),
|
|
700
|
-
]);
|
|
701
|
-
if (settled)
|
|
702
|
-
await recordBrokerTurn(nodeId, { event: 'closed', end_reason: 'teardown-aborted' });
|
|
703
|
-
}
|
|
704
|
-
finally {
|
|
705
|
-
if (timer !== undefined)
|
|
706
|
-
clearTimeout(timer);
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
else if (frameDispatch.pendingPromptDispatches() > 0 || rebind.isAgentRunActive()) {
|
|
711
|
-
// The engine never reached an abortable persisted turn in the budget.
|
|
712
|
-
// Preserve the dirty interrupted-turn witness so recovery resumes the
|
|
713
|
-
// saved transcript and explicitly re-drives the stopped work.
|
|
714
|
-
await recordBrokerTurn(nodeId, { event: 'interrupted' });
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
disposeAndExit(reason);
|
|
718
|
-
};
|
|
719
|
-
process.on('SIGTERM', () => { void abortAndExit('SIGTERM'); });
|
|
720
|
-
process.on('SIGINT', () => { void abortAndExit('SIGINT'); });
|
|
721
|
-
}
|
|
722
|
-
// snapshotMessages — the catch-up snapshot's ordered message history.
|
|
723
|
-
//
|
|
724
|
-
// The broker is the SOLE writer of the node's session `.jsonl`, so the session
|
|
725
|
-
// manager's persisted tree (`buildSessionContext`) is the canonical, complete,
|
|
726
|
-
// ordered history — byte-identical to what a dormant reader (crouter-web's static
|
|
727
|
-
// normalizer) reconstructs from the same file. We serve THAT, NOT the agent's
|
|
728
|
-
// live `session.messages` (`agent.state.messages`), because pi's recovery paths
|
|
729
|
-
// mutate the live array away from the persisted history: auto-retry, context-
|
|
730
|
-
// overflow recovery, and compaction each SLICE the errored/superseded assistant
|
|
731
|
-
// message out of `state.messages` while DELIBERATELY keeping it on disk ("keep in
|
|
732
|
-
// session for history", agent-session.js). So `session.messages` can OMIT — or, via
|
|
733
|
-
// branch/compaction reshaping, reorder — a turn the `.jsonl` still holds. Pre-
|
|
734
|
-
// close that drift is invisible (the live stream and the live array agree); after
|
|
735
|
-
// a revive the welcome snapshot built from the reloaded array would diverge from
|
|
736
|
-
// the on-disk history a dormant viewer just saw. Reconstructing from the session
|
|
737
|
-
// manager makes the live snapshot == the persisted history (single source of
|
|
738
|
-
// truth); the relayed live stream then continues from there.
|
|
739
|
-
//
|
|
740
|
-
// `AgentSession.sessionManager` is a public readonly field of the real pi SDK; the
|
|
741
|
-
// fake-engine test fixture mirrors the same `sessionManager.buildSessionContext()`
|
|
742
|
-
// surface (plus, where present, the tree accessors `cycleAwareMessages` reads).
|
|
743
|
-
// A refresh-yielded node keeps every prior cycle in the SAME `.jsonl` as sibling
|
|
744
|
-
// branches (session-cycles.ts) — `cycleAwareMessages` replays them ahead of the
|
|
745
|
-
// live cycle's context so the welcome snapshot renders one continuous
|
|
746
|
-
// conversation instead of just the post-yield window; single-cycle sessions and
|
|
747
|
-
// the fake-engine fixture (no tree accessors) fall through to plain
|
|
748
|
-
// `buildSessionContext().messages` unchanged.
|
|
749
|
-
function toolCallIds(messages) {
|
|
750
|
-
const ids = new Set();
|
|
751
|
-
for (const message of messages) {
|
|
752
|
-
if (message.role !== 'assistant' || !Array.isArray(message.content))
|
|
753
|
-
continue;
|
|
754
|
-
for (const part of message.content) {
|
|
755
|
-
if (part !== null && typeof part === 'object' && part.type === 'toolCall' && typeof part.id === 'string')
|
|
756
|
-
ids.add(part.id);
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
return ids;
|
|
760
|
-
}
|
|
761
|
-
export function snapshotMessages(session, boundaryReviewId) {
|
|
762
|
-
// Cast: the real SDK's `SessionEntry.data` is `unknown` (untyped custom-entry
|
|
763
|
-
// payload), narrower than `CycleSessionManagerLike`'s structural read of the
|
|
764
|
-
// `crtr-cycle` marker's `{cycle, fromLeaf}` shape — the fields we read off it
|
|
765
|
-
// are ones ONLY this module's own `appendCustomEntry` call (above) ever writes.
|
|
766
|
-
const manager = session.sessionManager;
|
|
767
|
-
const messages = cycleAwareMessages(manager);
|
|
768
|
-
if (messages !== undefined) {
|
|
769
|
-
hydratePersistedAdvertisedCommandMessages(messages.map(({ message }) => message));
|
|
770
|
-
}
|
|
771
|
-
return messages === undefined
|
|
772
|
-
? undefined
|
|
773
|
-
: projectTranscript(messages, {
|
|
774
|
-
boundaryReviewId,
|
|
775
|
-
sessionEntries: manager.getEntries?.(),
|
|
776
|
-
});
|
|
777
|
-
}
|
|
778
|
-
// resolveLaunchModel — the SOLE launch model-selection policy, module-scoped
|
|
779
|
-
// so both buildForManager (initial boot, inside buildBrokerSession below) and
|
|
780
|
-
// the reload_auth re-drive (inside runBroker, a DIFFERENT function scope) can
|
|
781
|
-
// invoke the identical decision against a live `services`/`cfg` without
|
|
782
|
-
// re-running session/service creation. Returns undefined when NO candidate is
|
|
783
|
-
// viable at all (tier 3) — this is NOT a fault; the caller decides what to do
|
|
784
|
-
// with it (construct a model-less session at boot, or leave a running session
|
|
785
|
-
// alone on a failed re-drive attempt).
|
|
786
|
-
function currentBrokerNodeId() {
|
|
787
|
-
const nodeId = envNodeId();
|
|
788
|
-
if (nodeId === undefined || nodeId === '')
|
|
789
|
-
throw new Error('broker launch is missing CRTR_NODE_ID');
|
|
790
|
-
return nodeId;
|
|
791
|
-
}
|
|
792
|
-
async function resolveLaunchModel(services, cfg) {
|
|
793
|
-
const routeRequest = modelRequestFromConfig(cfg.model, envModelIntent(), cfg.modelExact === true);
|
|
794
|
-
if (routeRequest === undefined)
|
|
795
|
-
return undefined;
|
|
796
|
-
const registry = registryOf(services);
|
|
797
|
-
const routeOptions = {
|
|
798
|
-
cwd: envNodeCwd() ?? cfg.cwd,
|
|
799
|
-
profileId: envProfileId(),
|
|
800
|
-
};
|
|
801
|
-
const unknown = unregisteredConcreteModel(routeRequest, registry, routeOptions);
|
|
802
|
-
if (unknown !== undefined) {
|
|
803
|
-
await mutateBrokerFault(currentBrokerNodeId(), { op: 'record', input: { link: 'crtr→pi', op: 'model resolution at launch', kind: 'model-not-found', retry: { disposition: 'fatal' }, message: `model '${unknown.request.spec}' is not registered in the serving model registry` } });
|
|
804
|
-
throw new Error(`[broker] FATAL: model '${unknown.request.spec}' is not registered in the serving model registry`);
|
|
805
|
-
}
|
|
806
|
-
const selection = selectInitialModelRoute(routeRequest, registry, routeOptions);
|
|
807
|
-
const selected = selection.selected;
|
|
808
|
-
if (selected !== undefined) {
|
|
809
|
-
const candidate = selected.candidate;
|
|
810
|
-
if ((candidate.rank ?? 0) > 0)
|
|
811
|
-
emitEvent({ level: 'warn', event: 'broker.model.launch_fallback', fields: { requested: cfg.model, selected: `${candidate.providerId}/${candidate.modelId}`, route_id: candidate.routeId, credential_source: candidate.credentialSource, rank: candidate.rank } });
|
|
812
|
-
return { model: selected.model, thinkingLevel: candidate.thinkingLevel };
|
|
813
|
-
}
|
|
814
|
-
if (cfg.modelExact === true) {
|
|
815
|
-
const rejection = selection.rejected.map(({ candidate, reason }) => `'${candidate.providerId}/${candidate.modelId}' ${reason}`).join('; ');
|
|
816
|
-
await mutateBrokerFault(currentBrokerNodeId(), { op: 'record', input: { link: 'crtr→pi', op: 'model resolution at launch', kind: 'model-not-found', retry: { disposition: 'fatal' }, message: `exact-consult model '${cfg.model}' is unavailable — refusing to substitute (${rejection})` } });
|
|
817
|
-
throw new Error(`[broker] FATAL: exact-consult model '${cfg.model}' is unavailable`);
|
|
818
|
-
}
|
|
819
|
-
emitEvent({ level: 'warn', event: 'broker.model.none_viable', fields: { rejected_candidates: selection.rejected.slice(0, 16).map(({ candidate, reason }) => ({ provider: candidate.providerId, model: candidate.modelId, reason, route_id: candidate.routeId, credential_source: candidate.credentialSource })), rejected_candidates_omitted: Math.max(0, selection.rejected.length - 16) } });
|
|
820
|
-
return undefined;
|
|
821
|
-
}
|
|
822
|
-
/**
|
|
823
|
-
* Wrap a live ModelRuntime so a model-less `createAgentSessionFromServices`
|
|
824
|
-
* call can't have the SDK's own `findInitialModel` silently pick a model
|
|
825
|
-
* behind crouter's launch policy. Every model-list read the SDK performs during
|
|
826
|
-
* construction must be intercepted:
|
|
827
|
-
* - `getModel()` — findInitialModel step 3 (settingsManager's durable
|
|
828
|
-
* `defaultProvider`/`defaultModel`, persisted into a GLOBAL settings.json by
|
|
829
|
-
* every `session.setModel()` call the broker itself already makes, so this
|
|
830
|
-
* is a live bypass on any machine that has ever picked a model, not a
|
|
831
|
-
* theoretical corner case) and the resume path's model restore.
|
|
832
|
-
* - `getAvailableSnapshot()` — findInitialModel step 4 and
|
|
833
|
-
* restoreModelFromSession's fallback both take the registry default off this
|
|
834
|
-
* SYNCHRONOUS snapshot (model-resolver.js:511/556).
|
|
835
|
-
* - `getAvailable()` — the async refresh-and-list sibling, masked alongside it
|
|
836
|
-
* so no construction-time list read can reach the real registry through
|
|
837
|
-
* either accessor.
|
|
838
|
-
* Masking any one of them alone leaves the others wide open. Everything else
|
|
839
|
-
* (`getModels`, `hasConfiguredAuth`, `refresh`, …) passes through untouched via
|
|
840
|
-
* `Reflect.get`. Used ONLY
|
|
841
|
-
* for the one model-less construction call; the `services` returned to every
|
|
842
|
-
* other caller (reload_auth, hasConfiguredAuth checks, …) keeps the REAL
|
|
843
|
-
* unwrapped registry.
|
|
844
|
-
*
|
|
845
|
-
* CONSTRUCTION-ONLY MASK: the SDK stores `options.services.modelRuntime` as the
|
|
846
|
-
* session's private `_modelRuntime` for its ENTIRE lifetime and never replaces
|
|
847
|
-
* it (agent-session-services.js:104-119, sdk.js:253). A permanent mask would
|
|
848
|
-
* leave list_models (the available list→[]), cycle_model, and provider-rotation
|
|
849
|
-
* fallback (getModel()→undefined) broken forever for any model-less-booted node,
|
|
850
|
-
* even after a later /login selects a model. Model selection can only happen
|
|
851
|
-
* DURING construction, so this proxy self-heals: it masks while `masked`, then
|
|
852
|
-
* `reveal()` (called immediately after createAgentSessionFromServices returns)
|
|
853
|
-
* flips the SAME retained proxy to a transparent passthrough forever after.
|
|
854
|
-
*/
|
|
855
|
-
function modelLessRegistry(real) {
|
|
856
|
-
let masked = true;
|
|
857
|
-
const runtime = new Proxy(real, {
|
|
858
|
-
get(target, prop, receiver) {
|
|
859
|
-
// `getAvailableSnapshot` is the sync list findInitialModel reads; its
|
|
860
|
-
// async sibling `getAvailable` refreshes first and returns the same set.
|
|
861
|
-
if (masked && prop === 'getAvailableSnapshot')
|
|
862
|
-
return () => [];
|
|
863
|
-
if (masked && prop === 'getAvailable')
|
|
864
|
-
return async () => [];
|
|
865
|
-
if (masked && prop === 'getModel')
|
|
866
|
-
return () => undefined;
|
|
867
|
-
return Reflect.get(target, prop, receiver);
|
|
868
|
-
},
|
|
869
|
-
});
|
|
870
|
-
return { runtime, reveal: () => { masked = false; } };
|
|
871
|
-
}
|
|
872
|
-
// buildBrokerSession (plan T4 steps 2–4) — turn the launch recipe into a live
|
|
873
|
-
// engine session via the pi SDK SERVICES path. Exported so the C3/C4 real-SDK
|
|
874
|
-
// regression tests can drive the EXACT production wiring (not the mock).
|
|
875
|
-
export async function buildBrokerSession(engine, cfg) {
|
|
876
|
-
// 2. Build cwd-bound runtime services via the SERVICES path (C3) — NOT plain
|
|
877
|
-
// createAgentSession. createAgentSessionServices builds + reloads the
|
|
878
|
-
// resource loader (the `-e` canvas extensions + --append-system-prompt) and
|
|
879
|
-
// REGISTERS extension-provided model providers into the ModelRegistry (it is
|
|
880
|
-
// also where extension flag values would be applied — the broker recipe
|
|
881
|
-
// carries none today). Plain createAgentSession does NEITHER, so a node whose
|
|
882
|
-
// model comes from a custom-provider extension would get NO model. Mirrors pi
|
|
883
|
-
// main.js (createAgentSessionServices → …FromServices).
|
|
884
|
-
//
|
|
885
|
-
// T3 session-rebind: services + model + session creation is factored into
|
|
886
|
-
// `buildForManager` so it can serve BOTH the initial boot AND the
|
|
887
|
-
// AgentSessionRuntime factory it is reused as below (new_session/
|
|
888
|
-
// switch_session/fork rebuild the session by re-invoking it for a new
|
|
889
|
-
// SessionManager). Mirrors pi main.js's `createRuntime`.
|
|
890
|
-
const agentDir = getAgentDir();
|
|
891
|
-
const buildForManager = async (o) => {
|
|
892
|
-
// pi 0.82 owns credentials through an app-supplied CredentialStore. Hand it
|
|
893
|
-
// crouter's, which serves managed providers straight from the subscription
|
|
894
|
-
// pool and everything else from auth.json — both read fresh under their lock
|
|
895
|
-
// on every call, because the rotation extension, `/provider-sub`, and the
|
|
896
|
-
// daemon's login fan all write out of band mid-session and pi's own default
|
|
897
|
-
// store would serve a cached view with no reload seam.
|
|
898
|
-
const { authPath, modelsPath } = modelRuntimePaths(o.agentDir);
|
|
899
|
-
const modelRuntime = await ModelRuntime.create({
|
|
900
|
-
credentials: new PoolCredentialStore(authPath),
|
|
901
|
-
modelsPath,
|
|
902
|
-
});
|
|
903
|
-
const services = await engine.createAgentSessionServices({
|
|
904
|
-
cwd: o.cwd,
|
|
905
|
-
agentDir: o.agentDir,
|
|
906
|
-
modelRuntime,
|
|
907
|
-
resourceLoaderOptions: {
|
|
908
|
-
additionalExtensionPaths: cfg.extensionPaths,
|
|
909
|
-
appendSystemPrompt: cfg.appendSystemPromptPath !== undefined ? [cfg.appendSystemPromptPath] : undefined,
|
|
910
|
-
// Suppress pi's <project_context> AGENTS.md/CLAUDE.md injection in the
|
|
911
|
-
// system prompt. crouter imports either source into the project's root
|
|
912
|
-
// memory INDEX and surfaces that front door in first-message context;
|
|
913
|
-
// pi's file-based loader is not a second guidance path.
|
|
914
|
-
noContextFiles: true,
|
|
915
|
-
},
|
|
916
|
-
});
|
|
917
|
-
const extensionResult = services.resourceLoader.getExtensions();
|
|
918
|
-
// buildBrokerSession also supports standalone SDK consumers (for example a
|
|
919
|
-
// custom-provider extension test) that are not canvas nodes. Production
|
|
920
|
-
// canvas invocations always carry the full mandatory set after preflight;
|
|
921
|
-
// once any canvas hook is requested, require every one to load.
|
|
922
|
-
if (cfg.extensionPaths.some((path) => CANVAS_EXTENSIONS.includes(path))) {
|
|
923
|
-
const loadedPaths = new Set(extensionResult.extensions.map((extension) => extension.path));
|
|
924
|
-
const missingHooks = CANVAS_EXTENSIONS.filter((path) => !loadedPaths.has(path));
|
|
925
|
-
if (missingHooks.length > 0) {
|
|
926
|
-
const errors = extensionResult.errors
|
|
927
|
-
.filter((error) => CANVAS_EXTENSIONS.includes(error.path))
|
|
928
|
-
.map((error) => `${error.path}: ${error.error}`)
|
|
929
|
-
.join('; ');
|
|
930
|
-
throw new Error(`[broker] FATAL: mandatory canvas extensions failed to load: ${missingHooks.join(', ')}${errors === '' ? '' : ` (${errors})`}`);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
// 3. Resolve one viable model — resolveLaunchModel (module-scoped above) is
|
|
934
|
-
// the SOLE launch selection policy, shared with the reload_auth re-drive so
|
|
935
|
-
// a later /login re-runs the identical decision against this same `services`.
|
|
936
|
-
const resolved = await resolveLaunchModel(services, cfg);
|
|
937
|
-
// Tier 3: no viable candidate at all. Do NOT fault — construct a live
|
|
938
|
-
// model-less session so the socket/listener still comes up and the user can
|
|
939
|
-
// /login; suppress the SDK's own findInitialModel auto-selection
|
|
940
|
-
// (modelLessRegistry) so a stale global settings.json default or an
|
|
941
|
-
// available-but-policy-rejected model can't sneak in behind crouter's back.
|
|
942
|
-
const model = resolved?.model;
|
|
943
|
-
const thinkingLevel = resolved?.thinkingLevel;
|
|
944
|
-
const modelLess = resolved === undefined ? modelLessRegistry(services.modelRuntime) : undefined;
|
|
945
|
-
const constructionServices = modelLess !== undefined
|
|
946
|
-
? { ...services, modelRuntime: modelLess.runtime }
|
|
947
|
-
: services;
|
|
948
|
-
const created = await engine.createAgentSessionFromServices({
|
|
949
|
-
services: constructionServices,
|
|
950
|
-
sessionManager: o.sessionManager,
|
|
951
|
-
model,
|
|
952
|
-
thinkingLevel,
|
|
953
|
-
tools: cfg.tools,
|
|
954
|
-
sessionStartEvent: o.sessionStartEvent,
|
|
955
|
-
});
|
|
956
|
-
installAdvertisedCommandInvocationContract(created.session);
|
|
957
|
-
// The resource loader has completed its initial load, but extensions have
|
|
958
|
-
// not received session_start yet. Freeze the Gateway capability boundary.
|
|
959
|
-
captureSessionChatCapabilities(created.session);
|
|
960
|
-
// CONSTRUCTION-ONLY MASK — see modelLessRegistry: reveal now that model
|
|
961
|
-
// selection (construction-time only) is done, so a later /login re-drive's
|
|
962
|
-
// list_models/cycle_model/provider-rotation see the real registry.
|
|
963
|
-
modelLess?.reveal();
|
|
964
|
-
return { ...created, services };
|
|
965
|
-
};
|
|
966
|
-
// 4. Select the SessionManager: FORK (spawn-time --fork), OPEN (resume), or
|
|
967
|
-
// CREATE (fresh). The broker is the sole writer of the resulting .jsonl.
|
|
968
|
-
const resumePath = cfg.resumeSessionPath;
|
|
969
|
-
const forking = cfg.forkFrom !== undefined && cfg.forkFrom !== '';
|
|
970
|
-
if (!forking &&
|
|
971
|
-
(resumePath === undefined || resumePath === '') &&
|
|
972
|
-
cfg.resumeSessionId !== undefined &&
|
|
973
|
-
cfg.resumeSessionId !== '') {
|
|
974
|
-
// SessionManager.open() takes a FILE path — it only path-normalizes; it does
|
|
975
|
-
// NOT resolve a bare uuid to its .jsonl the way pi's CLI does (via
|
|
976
|
-
// SessionManager.list). A bare-id-only resume would open a nonexistent
|
|
977
|
-
// <cwd>/<uuid> and silently start an EMPTY session. Fail loud: revive always
|
|
978
|
-
// passes the .jsonl path, so a bare id means an old node that never captured
|
|
979
|
-
// pi_session_file — mis-resuming it silently is worse than a crash.
|
|
980
|
-
throw new Error(`[broker] resume requires a session .jsonl PATH; got only a bare id ` +
|
|
981
|
-
`'${cfg.resumeSessionId}' (pi_session_file was never captured for this node)`);
|
|
982
|
-
}
|
|
983
|
-
// A fork is a fresh spawn (resuming=false) so its kickoff firstPrompt fires: a
|
|
984
|
-
// `node new --fork-from <id>` gives the new node the source's full history AND a
|
|
985
|
-
// new task to start on. An ordinary resume supplies no prompt, but a
|
|
986
|
-
// broker-certified runtime-abort resume deliberately carries a continuation.
|
|
987
|
-
//
|
|
988
|
-
// A refresh-yield CYCLES instead: `cfg.newCycle` (the `--crtr-new-cycle` token)
|
|
989
|
-
// marks a revive that reuses this SAME `.jsonl` rather than resuming it — the
|
|
990
|
-
// session manager opens the file, then resets the leaf and roots a `crtr-cycle`
|
|
991
|
-
// marker entry (data: `{cycle, fromLeaf}`) as the new cycle's ROOT before the
|
|
992
|
-
// session is built. Custom entries never enter LLM context, so the freshly
|
|
993
|
-
// rooted branch is exactly as clean as a brand-new session; `cycleAwareMessages`
|
|
994
|
-
// (session-cycles.ts) is the display-side counterpart that replays every prior
|
|
995
|
-
// cycle for snapshot rendering. cycling ⇒ resuming=false, so the kickoff
|
|
996
|
-
// firstPrompt fires below just like a true fresh launch.
|
|
997
|
-
const hasSessionPath = !forking && resumePath !== undefined && resumePath !== '';
|
|
998
|
-
const cycling = hasSessionPath && cfg.newCycle === true;
|
|
999
|
-
const resuming = hasSessionPath && !cycling;
|
|
1000
|
-
let sessionManager;
|
|
1001
|
-
if (forking) {
|
|
1002
|
-
// Spawn-time fork via pi's REAL fork seam, SessionManager.forkFrom — the exact
|
|
1003
|
-
// method pi's own `--fork` CLI flag uses (main.js forkSessionOrExit). It writes
|
|
1004
|
-
// a NEW session file with a NEW id and a `parentSession` header pointing at the
|
|
1005
|
-
// source, then copies the source's history into it. NOT a naïve `.jsonl` copy
|
|
1006
|
-
// (which would collide session ids and drop the fork metadata), and NOT
|
|
1007
|
-
// runtime.fork() (which forks an entry WITHIN an already-loaded session — there
|
|
1008
|
-
// is no current session to fork at boot). The caller (spawn.ts resolveForkSource)
|
|
1009
|
-
// resolves cfg.forkFrom to an absolute source .jsonl before launch, so a bad ref
|
|
1010
|
-
// fails loudly here (forkFrom throws on an empty/invalid/header-less source).
|
|
1011
|
-
sessionManager = engine.SessionManager.forkFrom(cfg.forkFrom, cfg.cwd);
|
|
1012
|
-
}
|
|
1013
|
-
else if (resuming || cycling) {
|
|
1014
|
-
sessionManager = engine.SessionManager.open(resumePath);
|
|
1015
|
-
if (cycling) {
|
|
1016
|
-
const fromLeaf = sessionManager.getLeafId();
|
|
1017
|
-
sessionManager.resetLeaf();
|
|
1018
|
-
sessionManager.appendCustomEntry(CRTR_CYCLE_CUSTOM_TYPE, {
|
|
1019
|
-
cycle: Number(process.env['CRTR_CYCLES']),
|
|
1020
|
-
fromLeaf,
|
|
1021
|
-
});
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
else {
|
|
1025
|
-
sessionManager = engine.SessionManager.create(cfg.cwd);
|
|
1026
|
-
}
|
|
1027
|
-
// When the engine exposes the replacement API (real SDK), wrap the builder in an
|
|
1028
|
-
// AgentSessionRuntime so new_session/switch_session/fork work; the runtime
|
|
1029
|
-
// re-invokes `buildForManager` for each new SessionManager. The fake-engine
|
|
1030
|
-
// fixture omits it — fall back to a single direct build (those three ops then
|
|
1031
|
-
// reply error{engine_error}).
|
|
1032
|
-
if (engine.createAgentSessionRuntime !== undefined) {
|
|
1033
|
-
const factory = async (o) => {
|
|
1034
|
-
const r = await buildForManager({
|
|
1035
|
-
cwd: o.cwd,
|
|
1036
|
-
agentDir: o.agentDir,
|
|
1037
|
-
sessionManager: o.sessionManager,
|
|
1038
|
-
sessionStartEvent: o.sessionStartEvent,
|
|
1039
|
-
});
|
|
1040
|
-
return { ...r, diagnostics: r.services.diagnostics ?? [] };
|
|
1041
|
-
};
|
|
1042
|
-
const runtime = await engine.createAgentSessionRuntime(factory, {
|
|
1043
|
-
cwd: cfg.cwd,
|
|
1044
|
-
agentDir,
|
|
1045
|
-
sessionManager,
|
|
1046
|
-
});
|
|
1047
|
-
return { session: runtime.session, services: runtime.services, resuming, runtime };
|
|
1048
|
-
}
|
|
1049
|
-
const r = await buildForManager({ cwd: cfg.cwd, agentDir, sessionManager });
|
|
1050
|
-
return { session: r.session, services: r.services, resuming, runtime: undefined };
|
|
1051
|
-
}
|
|
1052
|
-
export function makeBrokerUiContext(deps) {
|
|
1053
|
-
// The dialog router. C2 (scout mq5thyli): the design §5.4 premise — that an
|
|
1054
|
-
// unattended dialog auto-resolves on its OWN timeout — is FALSE. `timeout` is
|
|
1055
|
-
// OPTIONAL on dialog opts, editor() takes none, and almost no real extension
|
|
1056
|
-
// passes one (permission-gate / confirm-destructive / plan-mode / subagent all
|
|
1057
|
-
// omit it). A timeout-reliant unattended node therefore deadlocks the agent
|
|
1058
|
-
// turn FOREVER. So with NO WRITABLE client attached we fall back to the SDK's
|
|
1059
|
-
// noOp UI behavior — resolve to the default (deny / cancel / undefined)
|
|
1060
|
-
// IMMEDIATELY, never arming a timer, never waiting. With one or more, the dialog
|
|
1061
|
-
// is fanned out to all of them under a broker-side timeout+abort, so viewers
|
|
1062
|
-
// that attach but never answer cannot hang the turn either.
|
|
1063
|
-
const dialogPromise = (defaultValue, request, parse, opts) => {
|
|
1064
|
-
if (opts?.signal?.aborted)
|
|
1065
|
-
return Promise.resolve(defaultValue);
|
|
1066
|
-
// Snapshot the writable set ONCE, at raise time — the fan-out targets and the
|
|
1067
|
-
// zero-answerer decision must agree.
|
|
1068
|
-
const targets = deps.writable();
|
|
1069
|
-
// C2 (Wave-0, KEEP): nobody can answer at raise time → noOp, resolved at once.
|
|
1070
|
-
// No timer, no wait, no deadlock.
|
|
1071
|
-
if (targets.length === 0)
|
|
1072
|
-
return Promise.resolve(defaultValue);
|
|
1073
|
-
// At least one writable client: register the dialog FIRST (so a client that
|
|
1074
|
-
// attaches mid-dialog gets it replayed and joins the race), fan it out to every
|
|
1075
|
-
// target, and ALWAYS arm a broker-side timeout (C2 anti-deadlock): viewers that
|
|
1076
|
-
// never answer — or all detach — can never hang the turn. Honor a shorter
|
|
1077
|
-
// per-dialog timeout if the extension passed one; otherwise the broker default.
|
|
1078
|
-
// On fire it resolves to the SAFE default (deny/cancel/undefined). A detach
|
|
1079
|
-
// does NOT cancel this — only an answer, the timeout, or an abort.
|
|
1080
|
-
//
|
|
1081
|
-
// EVERY settlement path runs the same `cleanup` (drop the entry, so a later
|
|
1082
|
-
// answer for this id is a no-op) and then broadcasts `extension_ui_dismiss`
|
|
1083
|
-
// keyed to this id, so all peers close their copy of exactly this dialog and
|
|
1084
|
-
// nothing else.
|
|
1085
|
-
return new Promise((resolve) => {
|
|
1086
|
-
let timer;
|
|
1087
|
-
const cleanup = () => {
|
|
1088
|
-
if (timer !== undefined)
|
|
1089
|
-
clearTimeout(timer);
|
|
1090
|
-
opts?.signal?.removeEventListener('abort', onAbort);
|
|
1091
|
-
deps.pending.delete(request.id);
|
|
1092
|
-
};
|
|
1093
|
-
const onAbort = () => {
|
|
1094
|
-
cleanup();
|
|
1095
|
-
// The extension aborted this request out-of-band (e.g. an OAuth loopback
|
|
1096
|
-
// callback won the race against a still-open manual-paste dialog). Tell
|
|
1097
|
-
// every peer to tear down THIS overlay by id — an unanswered dialog whose
|
|
1098
|
-
// broker entry we just dropped would otherwise linger onscreen with nothing
|
|
1099
|
-
// left to answer it. Keyed to request.id so only the abandoned dialog is
|
|
1100
|
-
// dismissed, never an unrelated one.
|
|
1101
|
-
deps.broadcast({ type: 'extension_ui_dismiss', id: request.id });
|
|
1102
|
-
resolve(defaultValue);
|
|
1103
|
-
};
|
|
1104
|
-
opts?.signal?.addEventListener('abort', onAbort, { once: true });
|
|
1105
|
-
// N1: honor the extension's EXPLICIT per-dialog timeout if it passed one
|
|
1106
|
-
// (longer or shorter than the broker default is fine — both are bounded);
|
|
1107
|
-
// otherwise fall back to the broker default. The broker never RELIES on the
|
|
1108
|
-
// extension having passed one (C2).
|
|
1109
|
-
const ms = opts?.timeout !== undefined ? opts.timeout : DEFAULT_DIALOG_TIMEOUT_MS;
|
|
1110
|
-
timer = setTimeout(() => {
|
|
1111
|
-
cleanup();
|
|
1112
|
-
// Same correlated teardown as onAbort: the broker resolved this dialog on
|
|
1113
|
-
// its own timeout, so every peer's overlay (none of which has an
|
|
1114
|
-
// independent timer) must be dismissed by id or it lingers forever.
|
|
1115
|
-
deps.broadcast({ type: 'extension_ui_dismiss', id: request.id });
|
|
1116
|
-
resolve(defaultValue);
|
|
1117
|
-
}, ms);
|
|
1118
|
-
if (typeof timer.unref === 'function')
|
|
1119
|
-
timer.unref();
|
|
1120
|
-
deps.pending.set(request.id, {
|
|
1121
|
-
request,
|
|
1122
|
-
resolve: (r) => {
|
|
1123
|
-
cleanup();
|
|
1124
|
-
// The first answer settled it; tell every OTHER client that was fanned
|
|
1125
|
-
// this dialog (and the answerer, for whom it is an idempotent no-op) to
|
|
1126
|
-
// close its copy. Without this, peers would sit on an overlay whose
|
|
1127
|
-
// answer can never arrive.
|
|
1128
|
-
deps.broadcast({ type: 'extension_ui_dismiss', id: request.id });
|
|
1129
|
-
resolve(parse(r));
|
|
1130
|
-
},
|
|
1131
|
-
});
|
|
1132
|
-
for (const target of targets)
|
|
1133
|
-
deps.forward(target, request);
|
|
1134
|
-
});
|
|
1135
|
-
};
|
|
1136
|
-
const noop = () => { };
|
|
1137
|
-
const ctx = {
|
|
1138
|
-
// The broker-owned known-stream-wait control (see BrokerDialogDeps): a
|
|
1139
|
-
// deliberate provider cooldown is KNOWN liveness, so the provider extension
|
|
1140
|
-
// reaches this through the stable symbol to pause the dead-stream watchdog for
|
|
1141
|
-
// the wait's duration. A no-op when the host supplied none.
|
|
1142
|
-
[KNOWN_STREAM_WAIT_UI]: deps.onKnownStreamWait ?? ((_deadlineMs) => () => { }),
|
|
1143
|
-
// pi's ExtensionUIContext exposes `theme`; package extensions (e.g. the OAuth
|
|
1144
|
-
// billing adapter's status rendering) read it from ANY lifecycle hook. The
|
|
1145
|
-
// SDK's noOpUIContext returns the process-global theme proxy here; we mirror
|
|
1146
|
-
// that by reading the same global symbol (populated by initTheme() at broker
|
|
1147
|
-
// boot — see runBroker). Without this property `ctx.ui.theme` is undefined and
|
|
1148
|
-
// the hook throws, which the runner silently swallows while dropping the hook's
|
|
1149
|
-
// returned payload (the OAuth 400 root cause).
|
|
1150
|
-
get theme() {
|
|
1151
|
-
const t = globalThis[Symbol.for('@earendil-works/pi-coding-agent:theme')];
|
|
1152
|
-
if (t === undefined || t === null) {
|
|
1153
|
-
throw new Error('Theme not initialized. Call initTheme() first.');
|
|
1154
|
-
}
|
|
1155
|
-
return t;
|
|
1156
|
-
},
|
|
1157
|
-
select: (title, options, opts) => dialogPromise(undefined, { type: 'extension_ui_request', id: randomUUID(), method: 'select', title, options, timeout: opts?.timeout }, (r) => ('cancelled' in r && r.cancelled ? undefined : 'value' in r ? r.value : undefined), opts),
|
|
1158
|
-
confirm: (title, message, opts) => dialogPromise(false, { type: 'extension_ui_request', id: randomUUID(), method: 'confirm', title, message, timeout: opts?.timeout }, (r) => ('cancelled' in r && r.cancelled ? false : 'confirmed' in r ? r.confirmed : false), opts),
|
|
1159
|
-
input: (title, placeholder, opts) => dialogPromise(undefined, { type: 'extension_ui_request', id: randomUUID(), method: 'input', title, placeholder, timeout: opts?.timeout }, (r) => ('cancelled' in r && r.cancelled ? undefined : 'value' in r ? r.value : undefined), opts),
|
|
1160
|
-
editor: (title, prefill) => dialogPromise(undefined, { type: 'extension_ui_request', id: randomUUID(), method: 'editor', title, prefill }, (r) => ('cancelled' in r && r.cancelled ? undefined : 'value' in r ? r.value : undefined)),
|
|
1161
|
-
// Non-blocking extension-UI relay: broadcast these to all viewers instead of
|
|
1162
|
-
// dropping them, in pi's OWN `extension_ui_request` envelope (rpc-mode.js
|
|
1163
|
-
// emits these three identically). The viewer owns the slots that render them,
|
|
1164
|
-
// and the broker retains their last value for the welcome snapshot. The other
|
|
1165
|
-
// non-blocking methods stay inert.
|
|
1166
|
-
setStatus: (key, text) => deps.broadcast({
|
|
1167
|
-
type: 'extension_ui_request',
|
|
1168
|
-
id: randomUUID(),
|
|
1169
|
-
method: 'setStatus',
|
|
1170
|
-
statusKey: key,
|
|
1171
|
-
statusText: text,
|
|
1172
|
-
}),
|
|
1173
|
-
setWidget: (key, content, options) => {
|
|
1174
|
-
// setWidget's component-factory overload cannot be serialized over the
|
|
1175
|
-
// socket (R1 caveat) — drop it and relay only the string[] form, exactly as
|
|
1176
|
-
// pi's own RPC setWidget carries only `widgetLines`.
|
|
1177
|
-
if (typeof content === 'function')
|
|
1178
|
-
return;
|
|
1179
|
-
deps.broadcast({
|
|
1180
|
-
type: 'extension_ui_request',
|
|
1181
|
-
id: randomUUID(),
|
|
1182
|
-
method: 'setWidget',
|
|
1183
|
-
widgetKey: key,
|
|
1184
|
-
widgetLines: content,
|
|
1185
|
-
widgetPlacement: options?.placement,
|
|
1186
|
-
});
|
|
1187
|
-
},
|
|
1188
|
-
setTitle: (title) => deps.broadcast({ type: 'extension_ui_request', id: randomUUID(), method: 'setTitle', title }),
|
|
1189
|
-
notify: (message, type) => {
|
|
1190
|
-
const notifyType = type === 'warn' ? 'warning' : type;
|
|
1191
|
-
deps.broadcast({ type: 'extension_ui_request', id: randomUUID(), method: 'notify', message, notifyType });
|
|
1192
|
-
},
|
|
1193
|
-
onTerminalInput: () => noop,
|
|
1194
|
-
setWorkingMessage: noop,
|
|
1195
|
-
setWorkingVisible: noop,
|
|
1196
|
-
setWorkingIndicator: noop,
|
|
1197
|
-
setHiddenThinkingLabel: noop,
|
|
1198
|
-
setFooter: noop,
|
|
1199
|
-
setHeader: noop,
|
|
1200
|
-
custom: () => Promise.resolve(undefined),
|
|
1201
|
-
pasteToEditor: noop,
|
|
1202
|
-
setEditorText: noop,
|
|
1203
|
-
getEditorText: () => '',
|
|
1204
|
-
addAutocompleteProvider: noop,
|
|
1205
|
-
setEditorComponent: noop,
|
|
1206
|
-
getEditorComponent: () => undefined,
|
|
1207
|
-
getAllThemes: () => [],
|
|
1208
|
-
getTheme: () => undefined,
|
|
1209
|
-
setTheme: noop,
|
|
1210
|
-
getToolsExpanded: () => false,
|
|
1211
|
-
setToolsExpanded: noop,
|
|
1212
|
-
};
|
|
1213
|
-
return ctx;
|
|
1214
|
-
}
|
|
1
|
+
var ve=Object.defineProperty;var e=(t,n)=>ve(t,"name",{value:n,configurable:!0});import{envModelIntent as he,envNodeCwd as _e,envNodeId as we,envProfileId as ye}from"../../shared/env.js";import{createServer as Se}from"node:net";import{existsSync as se,readFileSync as be,unlinkSync as ae}from"node:fs";import{join as K}from"node:path";import{randomUUID as M}from"node:crypto";import{mark as Ee}from"../timing.js";import{getAgentDir as V,initTheme as Te,ModelRegistry as ke,ModelRuntime as Re}from"@earendil-works/pi-coding-agent";import{nodeDir as xe,viewSocketPath as Ce}from"../canvas/paths.js";import{bindBrokerEventSource as Ae}from"../events/source.js";import{emitEvent as E}from"../events/emit.js";import{operationIdContext as Me}from"../events/operation-id.js";import{findMissingPackagePaths as Pe}from"./package-health.js";import{FRONT_DOOR_ENV as Ie}from"./front-door.js";import{CANVAS_EXTENSIONS as X,piInvocationToSdkConfig as Oe}from"./launch.js";import{assertEngineVersion as De,loadBrokerEngine as Fe}from"./broker-sdk.js";import{resolveBundledPiPackageDir as Ne}from"./pi-cli.js";import{captureSessionChatCapabilities as Le}from"./command-surface.js";import{PoolCredentialStore as $e}from"../pool-credential-store.js";import{mutateBrokerFault as U,recordBrokerTurn as de}from"./broker/daemon-ops.js";import{modelRequestFromConfig as je,selectInitialModelRoute as Be,unregisteredConcreteModel as Ge}from"../model-routes.js";import{KNOWN_STREAM_WAIT_UI as Ue}from"./stream-watchdog.js";import{probeOnline as We}from"./connectivity.js";import{CRTR_CYCLE_CUSTOM_TYPE as qe,cycleAwareMessages as Ke}from"./session-cycles.js";import{projectTranscript as Ve}from"./session-visibility.js";import{currentTurnVisibility as Xe}from"./turn-visibility.js";import{isUnknownModel as H}from"./model-selection.js";import{BrokerClientRegistry as He}from"./broker/client-registry.js";import{ToolGroupTracker as Ye}from"./broker/tool-groups.js";import{onNodeNamed as ze}from"./broker/node-named.js";import{FaultRetry as Je}from"./broker/fault-retry.js";import{createTurnAdmissionGate as Qe}from"./broker/turn-admission.js";import{BROKER_IDLE_TURN_START as Ze}from"./broker/held-deferred-inbox.js";import{EventProjection as et}from"./broker/event-projection.js";import{createFrameDispatchContext as tt,handleFrame as nt}from"./broker/frame-dispatch.js";import{hydratePersistedAdvertisedCommandMessages as ot,installAdvertisedCommandInvocationContract as rt}from"./advertised-command-invocation.js";import{RebindDriver as it}from"./broker/rebind.js";import{decodeKickoffOrigin as st,KICKOFF_ORIGIN_ENV as at}from"./stamp/protocol.js";import{announceMessageOrigin as dt}from"./stamp/channel.js";import{brokerExtensionState as lt,commitBrokerModel as ct}from"./broker/daemon-ops.js";import{FrameOverflowError as mt,normalizeSnapshotTail as ut}from"./broker-protocol.js";import{ReviewBoundaryNavigationError as fn,REVIEW_BOUNDARY_NAVIGATION_CODE as pn}from"./broker/frame-replies.js";function Y(t){return new ke(t.modelRuntime)}e(Y,"registryOf");function ft(t){return{authPath:K(t,"auth.json"),modelsPath:K(t,"models.json")}}e(ft,"modelRuntimePaths");function L(t,n){if(t==null||H(t))return null;const s=n!==void 0&&n!==""&&n!=="off"?`:${n}`:"";return`${t.provider}/${t.id}${s}`}e(L,"formatModelSpec");function pt(t,n){const s=L(t,void 0);return s===null?null:`${s}:${n===void 0||n===""?"off":n}`}e(pt,"formatExactModelSpec");const gt=12e4;let W=null;function vt(){const t=W;if(W=null,t!==null)try{t.dispose()}catch{}}e(vt,"disposeActiveSession");async function cn(t,n=process.hrtime.bigint(),s=new Date().toISOString()){Ae(t),Me.fresh(()=>{E({level:"info",event:"broker.startup.cli_entry",ts:s,duration_ms:0,fields:{runtime_version:process.version,engine_version:null,model:null}}),E({level:"info",event:"broker.startup.module_loaded",duration_ms:Number(process.hrtime.bigint()-n)/1e6,fields:{runtime_version:process.version,engine_version:null,model:null}})});const p=new Set;let i=null;const a=e((o,r=null)=>{p.has(o)||(p.add(o),Ee(o,{duration_ms:Number(process.hrtime.bigint()-n)/1e6}),E({level:"info",event:o,duration_ms:Number(process.hrtime.bigint()-n)/1e6,fields:{runtime_version:process.version,engine_version:i,model:r}}))},"emitStartupMilestone");process.env[Ie]="1",process.env.CRTR_BROKER_PID=String(process.pid),delete process.env.TMUX_PANE,delete process.env.TMUX;const d=await Fe();De(d.VERSION),i=d.VERSION;const l=xe(t),m=K(l,"broker-launch.json"),h=JSON.parse(be(m,"utf8")),g=Oe(h);g.modelExact===!0?process.env.CRTR_MODEL_EXACT="1":delete process.env.CRTR_MODEL_EXACT;let{session:_,services:S,resuming:k,runtime:T}=await yt(d,g);const R=(await lt(t)).node.review_binding?.review_id;W=_;const B=We;try{process.env.PI_PACKAGE_DIR=Ne(),Te(S.settingsManager.getTheme(),!1)}catch(o){E({level:"error",event:"broker.theme.initialization_failed",error:o})}try{for(const o of Pe(V()))E({level:"warn",event:"broker.startup.warning",fields:{stage:"package_health",source:o.source,resolved_path:o.resolved}})}catch{}const x=Ce(t),u=new He(t),D=new Map,b=new Ye(t,o=>u.broadcast(o));ze(o=>u.broadcast({type:"node_named",...o}));let P=!1,F=!1,A,$,c,C,N,z=e(()=>{},"notifyTurnAccepted"),J=e(()=>{},"resetFrameState");c=new it({nodeId:t,cfg:g,session:_,services:S,runtime:T,registry:u,toolGroups:b,uiContext:e(()=>$,"uiContext"),faultRetry:e(()=>C,"faultRetry"),projection:e(()=>N,"projection"),setActiveSession:e(o=>{W=o},"setActiveSession"),disposeAndExit:e((o,r)=>j(o,r),"disposeAndExit"),onSessionRebind:e(()=>{J()},"onSessionRebind"),reWelcomeAll:e(()=>te(),"reWelcomeAll")});const Q=e(async(o,r=!1)=>{const f=c.session(),v=L(f.model,f.thinkingLevel);if(v===null)return null;const w=await ct(t,{spec:v,pinnedOverride:o,userSelected:r});return r&&(delete process.env.CRTR_MODEL_INTENT,process.env.CRTR_MODEL_EXACT="1",g.model=w.modelOverride,g.modelExact=!0),w.modelOverride},"persistModelChoice"),Z=e(async(o=!0,r,f=!1)=>{const v=c.session(),w=L(v.model,v.thinkingLevel),y=o?await Q(r,f):w;u.broadcast({type:"model_changed",model:H(v.model)?void 0:v.model,spec:y})},"broadcastModelChanged"),q=Qe(),me=e(o=>{q.admit(r=>{const f=c.session();return f.prompt(o,{preflightResult:r,...f.isStreaming?{streamingBehavior:"steer"}:{}}).catch(v=>{E({level:"error",event:"broker.inbox.idle_prompt_failed",error:v})})})},"startIdleInboxTurn");globalThis[Ze]=me,C=new Je({nodeId:t,cfg:g,retryProbe:B,currentSession:e(()=>c.session(),"currentSession"),currentServices:e(()=>c.services(),"currentServices"),installedGeneration:e(()=>c.installedGeneration(),"installedGeneration"),registryOf:Y,formatModelSpec:L,broadcastModelChanged:Z,turnAdmission:q}),N=new et({registry:u,faultRetry:C,installedGeneration:e(()=>c.installedGeneration(),"installedGeneration"),currentSession:e(()=>c.session(),"currentSession"),notifyTurnAccepted:e(()=>z(),"notifyTurnAccepted"),emitStartupMilestone:a,formatModelSpec:L});const ue=e(o=>{const r=c.session(),f=_t(r,R),v=ut(o.snapshotTail),w=f===void 0||v===void 0?f:f.slice(-v),y=w?.map(({message:O})=>O)??r.sessionManager.buildSessionContext().messages,G=b.summaries(),ie=w!==void 0&&v!==void 0?ht(y):void 0,ge=ie===void 0?G:Object.fromEntries(Object.entries(G).filter(([O])=>ie.has(O)));return{messages:y,...w===void 0?{}:{messageIds:w.map(({id:O})=>O)},messageVisibility:w?.map(({visibility:O})=>O)??y.map(()=>"visible"),turnVisibility:Xe(),stats:r.getSessionStats(),state:{model:H(r.model)?void 0:r.model,thinkingLevel:r.thinkingLevel,isStreaming:r.isStreaming,isCompacting:r.isCompacting,steeringMode:r.steeringMode,followUpMode:r.followUpMode,sessionFile:r.sessionFile,sessionId:r.sessionId,sessionName:r.sessionName,autoCompactionEnabled:r.autoCompactionEnabled,messageCount:r.messages.length,pendingMessageCount:r.pendingMessageCount},display:{...u.displaySnapshot()},toolGroupSummaries:ge,workingActivity:N.currentWorkingActivity(),queued:{steering:[...r.getSteeringMessages()],followUp:[...r.getFollowUpMessages()]}}},"buildSnapshot"),ee=e(o=>{const r=o.role==="controller"?D.values().next().value:void 0;u.sendFrame(o,{type:"welcome",snapshot:ue(o),role:o.role,pending_dialog:r!==void 0?r.request:null,agentDir:V()},!0)},"sendWelcome"),fe=e(o=>{const r=[...D.values()];for(let f=1;f<r.length;f++)u.sendFrame(o,r[f].request)},"replayExtraPendingDialogsTo"),te=e(()=>{u.forEachHelloed(ee)},"reWelcomeAll"),ne=e(o=>{if(!P){P=!0,b.persistPendingSummary(),N.dispose(),vt();try{A?.close()}catch{}u.dispose();try{se(x)&&ae(x)}catch{}u.clearAttachState(),process.exit(o)}},"completeExit"),j=e((o,r=0)=>{if(P)return;const f=o==="shutdown-hook"||o==="shutdown-after-settle";if(f&&b.finishOpenToolGroup(!0),f&&b.hasSummaryTasks()){if(F)return;F=!0,b.waitForSummaryTasks().finally(()=>ne(r));return}ne(r)},"disposeAndExit");$=St({writable:e(()=>u.writableClients(),"writable"),forward:e((o,r)=>u.sendFrame(o,r),"forward"),pending:D,broadcast:e(o=>u.broadcastUi(o),"broadcast"),onKnownStreamWait:e(o=>N.knownStreamWait(o),"onKnownStreamWait")}),c.setRebindSession(),await c.enqueueRebind(_,S);const I=tt({nodeId:t,cfg:g,registry:u,toolGroups:b,projection:N,rebind:c,boundaryReviewId:R,pendingDialogs:D,sendWelcome:ee,replayExtraPendingDialogsTo:fe,reWelcomeAll:te,disposeAndExit:j,persistModelChoice:Q,broadcastModelChanged:Z,registryOf:Y,formatModelSpec:L,formatExactModelSpec:pt,turnAdmission:q,resolveLaunchModel:ce});z=I.notifyTurnAccepted,J=I.resetForSession;try{se(x)&&ae(x)}catch{}A=Se(o=>{const r=u.create(o);o.on("data",v=>{let w;try{w=r.decoder.push(v)}catch(y){y instanceof mt?(u.sendFrame(r,{type:"error",code:"frame_overflow",message:y.message}),u.dropClient(r,`frame overflow: ${y.message}`)):u.dropClient(r,`decoder error: ${String(y)}`);return}for(const y of w)try{nt(I,r,y)}catch{}});const f=e(()=>{u.removeClient(r)},"drop");o.on("close",f),o.on("error",()=>{})}),A.on("error",o=>{P||(E({level:"error",event:"broker.socket.failed",error:o}),j("socket-error",1))}),A.listen(x,async()=>{Promise.all([U(t,{op:"clear",link:"viewer\u2194broker"}),U(t,{op:"clear",link:"relay\u2194broker"})]).catch(r=>E({level:"error",event:"broker.daemon.operation.failed",node_id:t,error:r,fields:{operation:"broker_socket_bound_fault_clear"}}));let o;try{o=await C.recoverOnStartup()}catch(r){E({level:"error",event:"broker.daemon.operation.failed",node_id:t,error:r,fields:{operation:"recovery_startup"}}),j("recovery-startup-failed",1);return}if(o!=="retry-armed"&&g.firstPrompt!==void 0&&g.firstPrompt!==""){const r=st(process.env[at]);r!==null&&dt(g.firstPrompt,r),I.kickoff(g.firstPrompt)}}),u.persistAttachState();const pe=2500;let oe=!1;const re=e(async o=>{if(P||oe)return;if(oe=!0,c.isAgentRunActive()||c.session().isStreaming||I.pendingPromptDispatches()>0){const f=Date.now()+pe;for(;I.pendingPromptDispatches()>0&&!c.session().isStreaming&&Date.now()<f;)await new Promise(v=>setTimeout(v,25));if(c.session().isStreaming){const v=f-Date.now();if(v>0){let w;try{await Promise.race([c.session().abort().then(()=>!0,()=>!1),new Promise(G=>{w=setTimeout(()=>G(!1),v)})])&&await de(t,{event:"closed",end_reason:"teardown-aborted"})}finally{w!==void 0&&clearTimeout(w)}}}else(I.pendingPromptDispatches()>0||c.isAgentRunActive())&&await de(t,{event:"interrupted"})}j(o)},"abortAndExit");process.on("SIGTERM",()=>{re("SIGTERM")}),process.on("SIGINT",()=>{re("SIGINT")})}e(cn,"runBroker");function ht(t){const n=new Set;for(const s of t)if(!(s.role!=="assistant"||!Array.isArray(s.content)))for(const p of s.content)p!==null&&typeof p=="object"&&p.type==="toolCall"&&typeof p.id=="string"&&n.add(p.id);return n}e(ht,"toolCallIds");function _t(t,n){const s=t.sessionManager,p=Ke(s);return p!==void 0&&ot(p.map(({message:i})=>i)),p===void 0?void 0:Ve(p,{boundaryReviewId:n,sessionEntries:s.getEntries?.()})}e(_t,"snapshotMessages");function le(){const t=we();if(t===void 0||t==="")throw new Error("broker launch is missing CRTR_NODE_ID");return t}e(le,"currentBrokerNodeId");async function ce(t,n){const s=je(n.model,he(),n.modelExact===!0);if(s===void 0)return;const p=Y(t),i={cwd:_e()??n.cwd,profileId:ye()},a=Ge(s,p,i);if(a!==void 0)throw await U(le(),{op:"record",input:{link:"crtr\u2192pi",op:"model resolution at launch",kind:"model-not-found",retry:{disposition:"fatal"},message:`model '${a.request.spec}' is not registered in the serving model registry`}}),new Error(`[broker] FATAL: model '${a.request.spec}' is not registered in the serving model registry`);const d=Be(s,p,i),l=d.selected;if(l!==void 0){const m=l.candidate;return(m.rank??0)>0&&E({level:"warn",event:"broker.model.launch_fallback",fields:{requested:n.model,selected:`${m.providerId}/${m.modelId}`,route_id:m.routeId,credential_source:m.credentialSource,rank:m.rank}}),{model:l.model,thinkingLevel:m.thinkingLevel}}if(n.modelExact===!0){const m=d.rejected.map(({candidate:h,reason:g})=>`'${h.providerId}/${h.modelId}' ${g}`).join("; ");throw await U(le(),{op:"record",input:{link:"crtr\u2192pi",op:"model resolution at launch",kind:"model-not-found",retry:{disposition:"fatal"},message:`exact-consult model '${n.model}' is unavailable \u2014 refusing to substitute (${m})`}}),new Error(`[broker] FATAL: exact-consult model '${n.model}' is unavailable`)}E({level:"warn",event:"broker.model.none_viable",fields:{rejected_candidates:d.rejected.slice(0,16).map(({candidate:m,reason:h})=>({provider:m.providerId,model:m.modelId,reason:h,route_id:m.routeId,credential_source:m.credentialSource})),rejected_candidates_omitted:Math.max(0,d.rejected.length-16)}})}e(ce,"resolveLaunchModel");function wt(t){let n=!0;return{runtime:new Proxy(t,{get(p,i,a){return n&&i==="getAvailableSnapshot"?()=>[]:n&&i==="getAvailable"?async()=>[]:n&&i==="getModel"?()=>{}:Reflect.get(p,i,a)}}),reveal:e(()=>{n=!1},"reveal")}}e(wt,"modelLessRegistry");async function yt(t,n){const s=V(),p=e(async _=>{const{authPath:S,modelsPath:k}=ft(_.agentDir),T=await Re.create({credentials:new $e(S),modelsPath:k}),R=await t.createAgentSessionServices({cwd:_.cwd,agentDir:_.agentDir,modelRuntime:T,resourceLoaderOptions:{additionalExtensionPaths:n.extensionPaths,appendSystemPrompt:n.appendSystemPromptPath!==void 0?[n.appendSystemPromptPath]:void 0,noContextFiles:!0}}),B=R.resourceLoader.getExtensions();if(n.extensionPaths.some(A=>X.includes(A))){const A=new Set(B.extensions.map(c=>c.path)),$=X.filter(c=>!A.has(c));if($.length>0){const c=B.errors.filter(C=>X.includes(C.path)).map(C=>`${C.path}: ${C.error}`).join("; ");throw new Error(`[broker] FATAL: mandatory canvas extensions failed to load: ${$.join(", ")}${c===""?"":` (${c})`}`)}}const x=await ce(R,n),u=x?.model,D=x?.thinkingLevel,b=x===void 0?wt(R.modelRuntime):void 0,P=b!==void 0?{...R,modelRuntime:b.runtime}:R,F=await t.createAgentSessionFromServices({services:P,sessionManager:_.sessionManager,model:u,thinkingLevel:D,tools:n.tools,sessionStartEvent:_.sessionStartEvent});return rt(F.session),Le(F.session),b?.reveal(),{...F,services:R}},"buildForManager"),i=n.resumeSessionPath,a=n.forkFrom!==void 0&&n.forkFrom!=="";if(!a&&(i===void 0||i==="")&&n.resumeSessionId!==void 0&&n.resumeSessionId!=="")throw new Error(`[broker] resume requires a session .jsonl PATH; got only a bare id '${n.resumeSessionId}' (pi_session_file was never captured for this node)`);const d=!a&&i!==void 0&&i!=="",l=d&&n.newCycle===!0,m=d&&!l;let h;if(a)h=t.SessionManager.forkFrom(n.forkFrom,n.cwd);else if(m||l){if(h=t.SessionManager.open(i),l){const _=h.getLeafId();h.resetLeaf(),h.appendCustomEntry(qe,{cycle:Number(process.env.CRTR_CYCLES),fromLeaf:_})}}else h=t.SessionManager.create(n.cwd);if(t.createAgentSessionRuntime!==void 0){const _=e(async k=>{const T=await p({cwd:k.cwd,agentDir:k.agentDir,sessionManager:k.sessionManager,sessionStartEvent:k.sessionStartEvent});return{...T,diagnostics:T.services.diagnostics??[]}},"factory"),S=await t.createAgentSessionRuntime(_,{cwd:n.cwd,agentDir:s,sessionManager:h});return{session:S.session,services:S.services,resuming:m,runtime:S}}const g=await p({cwd:n.cwd,agentDir:s,sessionManager:h});return{session:g.session,services:g.services,resuming:m,runtime:void 0}}e(yt,"buildBrokerSession");function St(t){const n=e((i,a,d,l)=>{if(l?.signal?.aborted)return Promise.resolve(i);const m=t.writable();return m.length===0?Promise.resolve(i):new Promise(h=>{let g;const _=e(()=>{g!==void 0&&clearTimeout(g),l?.signal?.removeEventListener("abort",S),t.pending.delete(a.id)},"cleanup"),S=e(()=>{_(),t.broadcast({type:"extension_ui_dismiss",id:a.id}),h(i)},"onAbort");l?.signal?.addEventListener("abort",S,{once:!0});const k=l?.timeout!==void 0?l.timeout:gt;g=setTimeout(()=>{_(),t.broadcast({type:"extension_ui_dismiss",id:a.id}),h(i)},k),typeof g.unref=="function"&&g.unref(),t.pending.set(a.id,{request:a,resolve:e(T=>{_(),t.broadcast({type:"extension_ui_dismiss",id:a.id}),h(d(T))},"resolve")});for(const T of m)t.forward(T,a)})},"dialogPromise"),s=e(()=>{},"noop");return{[Ue]:t.onKnownStreamWait??(i=>()=>{}),get theme(){const i=globalThis[Symbol.for("@earendil-works/pi-coding-agent:theme")];if(i==null)throw new Error("Theme not initialized. Call initTheme() first.");return i},select:e((i,a,d)=>n(void 0,{type:"extension_ui_request",id:M(),method:"select",title:i,options:a,timeout:d?.timeout},l=>"cancelled"in l&&l.cancelled?void 0:"value"in l?l.value:void 0,d),"select"),confirm:e((i,a,d)=>n(!1,{type:"extension_ui_request",id:M(),method:"confirm",title:i,message:a,timeout:d?.timeout},l=>"cancelled"in l&&l.cancelled?!1:"confirmed"in l?l.confirmed:!1,d),"confirm"),input:e((i,a,d)=>n(void 0,{type:"extension_ui_request",id:M(),method:"input",title:i,placeholder:a,timeout:d?.timeout},l=>"cancelled"in l&&l.cancelled?void 0:"value"in l?l.value:void 0,d),"input"),editor:e((i,a)=>n(void 0,{type:"extension_ui_request",id:M(),method:"editor",title:i,prefill:a},d=>"cancelled"in d&&d.cancelled?void 0:"value"in d?d.value:void 0),"editor"),setStatus:e((i,a)=>t.broadcast({type:"extension_ui_request",id:M(),method:"setStatus",statusKey:i,statusText:a}),"setStatus"),setWidget:e((i,a,d)=>{typeof a!="function"&&t.broadcast({type:"extension_ui_request",id:M(),method:"setWidget",widgetKey:i,widgetLines:a,widgetPlacement:d?.placement})},"setWidget"),setTitle:e(i=>t.broadcast({type:"extension_ui_request",id:M(),method:"setTitle",title:i}),"setTitle"),notify:e((i,a)=>{const d=a==="warn"?"warning":a;t.broadcast({type:"extension_ui_request",id:M(),method:"notify",message:i,notifyType:d})},"notify"),onTerminalInput:e(()=>s,"onTerminalInput"),setWorkingMessage:s,setWorkingVisible:s,setWorkingIndicator:s,setHiddenThinkingLabel:s,setFooter:s,setHeader:s,custom:e(()=>Promise.resolve(void 0),"custom"),pasteToEditor:s,setEditorText:s,getEditorText:e(()=>"","getEditorText"),addAutocompleteProvider:s,setEditorComponent:s,getEditorComponent:e(()=>{},"getEditorComponent"),getAllThemes:e(()=>[],"getAllThemes"),getTheme:e(()=>{},"getTheme"),setTheme:s,getToolsExpanded:e(()=>!1,"getToolsExpanded"),setToolsExpanded:s}}e(St,"makeBrokerUiContext");export{pn as REVIEW_BOUNDARY_NAVIGATION_CODE,fn as ReviewBoundaryNavigationError,yt as buildBrokerSession,vt as disposeActiveSession,St as makeBrokerUiContext,cn as runBroker,_t as snapshotMessages};
|