Skip to content

Load user Pi configuration in the bundled runtime - #1080

Merged
SawyerHood merged 3 commits into
mainfrom
bb/clone-pi-dev-and-assess-integration-thr_nm27yahx34
Aug 7, 2026
Merged

SawyerHood merged 3 commits into
mainfrom
bb/clone-pi-dev-and-assess-integration-thr_nm27yahx34

Conversation

@SawyerHood

Copy link
Copy Markdown
Collaborator

Summary

  • Ship a pinned physical Pi 0.84.0 package tree.
  • Load global and project Pi settings through Pi's full service path.
  • Load configured packages, extensions, skills, prompts, themes, context, authentication, and models.
  • Include extension models in the BB model list.
  • Preserve Pi shell settings when BB adds thread environment values.
  • Test a custom extension provider, extension tool, and BB dynamic tool from an installed package.

Why

The bridge created in-memory settings and bundled Pi into one file. This bypassed the user's Pi configuration.

The single-file package also prevented extensions from sharing the host Pi modules.

Impact

Users keep their Pi settings and extensions while BB controls the Pi package version.

Users do not need an installed Pi executable.

Validation

  • pnpm exec turbo run typecheck --filter=@bb/agent-runtime --filter=@bb/host-daemon --filter=@bb/server --filter=bb-app --force
  • 810 agent runtime tests
  • 479 host daemon tests
  • 1,335 server tests
  • 48 BB application tests
  • pnpm exec turbo run smoke:tarball --filter=bb-app --force
  • A real model request through the packaged bridge with an existing Pi configuration

@SawyerHood
SawyerHood marked this pull request as ready for review August 6, 2026 15:37
@SawyerHood

Copy link
Copy Markdown
Collaborator Author

🚨 SLOP COP 🚨 · review

I am SlopCop, and I am reviewing this pull request under the review rule.

The stack contains only PR #1080: Load user Pi configuration in the bundled runtime.

I will review security, code quality, performance, architecture, duplication, and end-to-end behavior.

@SawyerHood

Copy link
Copy Markdown
Collaborator Author

🚨 SLOP COP 🚨 · review

Security phase complete.

I found one high-severity defect. BB skips the Pi project trust check in both new service paths.

An untrusted repository can run project extension code during model/list. That code can read environment secrets and use the host network.

The final review will include the exact source line and required correction.

@SawyerHood

Copy link
Copy Markdown
Collaborator Author

🚨 SLOP COP 🚨 · review

Code quality and architecture phase complete.

I confirmed the high-severity trust defect with a direct execution test.

I also found a medium-severity error-reporting defect. The bridge checks services.diagnostics but ignores resource loader errors.

The model picker and session paths also duplicate the complete Pi service setup. A shared policy helper should resolve trust and collect errors.

Focused tests, typechecks, the host build, and the bundle check passed.

@SawyerHood

Copy link
Copy Markdown
Collaborator Author

🚨 SLOP COP 🚨 · review

Performance and end-to-end phase complete.

The packaged-runtime end-to-end test passed in 1 minute 56 seconds. This change has no browser route, so a browser test does not apply.

Each thread now creates a new model runtime and repeats all Pi configuration scans. A 20-session test used about 4 MiB more heap than shared model runtimes.

Cold bridge start time increased by about 54 percent. The npm download also grew by at least 4.8 MB.

},
});

const serviceErrors = services.diagnostics.filter(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 slopcop/review — Report resource loader failures from the session path

This check also misses extension and resource loader errors. A broken project extension can silently disappear while the session continues with fewer models or tools. Use one shared Pi service helper to collect all failures for both the model and session paths. Add a test that proves the thread reports a broken extension.

// Use the full service path here too. This adds models from configured Pi
// extensions to BB's model picker. The bridge process starts in the current
// workspace, so the loader also sees that workspace's .pi configuration.
modelRuntimePromise ??= createAgentSessionServices({

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 slopcop/review — Use the requested project path for project extension models

The normal daemon model list starts this bridge in provider-maintenance-workspace. Thus, process.cwd() cannot see a project .pi directory. The smoke test starts the bridge inside a project and hides this mismatch. Pass the project path through the model-list contract, or limit the documentation to global extension models. Increment the daemon protocol version if the wire contract changes.

cwd: process.cwd(),
})
.then((services) => {
const errors = services.diagnostics.filter(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 slopcop/review — Report resource loader failures from the model-list path

services.diagnostics does not contain all extension and resource errors. A direct syntax-error test produced zero service diagnostics and one extension error. The model then disappears without a useful message. Collect resource loader and settings errors with the service diagnostics. Add a failed-extension test.

// Pi's service factory reads the global and project settings files. It also
// discovers packages, extensions, skills, prompts, themes, context files,
// auth, and custom models from the user's normal Pi directories.
const services = await createAgentSessionServices({

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 slopcop/review — Resolve project trust before this factory loads project resources

Pi 0.84 uses projectTrusted: true by default. A repository can execute .pi/extensions code with the provider process host access. Resolve the saved or global trust policy before this call. Keep unresolved projects untrusted. Add tests for rejected, saved, and unresolved trust decisions.

@SawyerHood SawyerHood left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 SLOP COP 🚨 · review

Final review complete for stack PR #1080.

I found one high-severity defect and two medium-severity defects.

  • High: The session path trusts project Pi resources by default. Repository extensions can run with host access.
  • Medium: The normal model picker runs in a maintenance directory. It cannot see project extension models.
  • Medium: Both service paths ignore resource loader failures. Broken extensions and resources can disappear without a useful error.

The model and session paths duplicate the complete Pi service setup. Use one helper for trust, diagnostics, and service creation.

The performance tests found a 54 percent cold-start increase. The npm download grew by at least 4.8 MB. These are documented tradeoffs.

The packaged-runtime end-to-end test passed. Focused tests, typechecks, the host build, and the bundle check also passed.

GitHub failed several other jobs during action downloads. Those failures did not run product code.

The GPT-5.6 review gate returned REQUEST CHANGES. I used only the comment review control, as required.

@SawyerHood
SawyerHood force-pushed the bb/clone-pi-dev-and-assess-integration-thr_nm27yahx34 branch 2 times, most recently from 2287ea9 to fae3d1f Compare August 7, 2026 14:31
@SawyerHood
SawyerHood force-pushed the bb/clone-pi-dev-and-assess-integration-thr_nm27yahx34 branch from fae3d1f to 9aebfa8 Compare August 7, 2026 14:49
@SawyerHood
SawyerHood merged commit 8d7bf61 into main Aug 7, 2026
10 checks passed
@SawyerHood
SawyerHood deleted the bb/clone-pi-dev-and-assess-integration-thr_nm27yahx34 branch August 7, 2026 14:54
SawyerHood added a commit that referenced this pull request Aug 7, 2026
## Summary

- Verify that the `primeExtensions()` port asked for in #1086 already
landed in #1080, end to end against the built bridge.
- Stop one broken Pi extension from emptying the whole model picker.
- Stop an extension model without `input` types from failing the whole
model list.

## Why

#1086 asks to port `primeExtensions()` to the production Pi bridge so
extension providers such as `commandcode` appear in the stock Pi
provider.

That port already landed in #1080 (`8d7bf6124`). The bridge builds its
model runtime through `createConfiguredPiServices()`, and Pi 0.84.0
flushes `pendingProviderRegistrations` inside
`createAgentSessionServices()`. A disposable priming session is not
necessary.

I confirmed this with the real extension from the issue, not a mock:
`[email protected]` installed from npm, driven by a real
`model/list` JSON-RPC request to the built `dist/bb-pi-bridge.mjs`. It
returns **51 CommandCode models**.

That test found two defects that still produce the exact symptom in the
issue.

### 1. A broken extension emptied the whole picker

`collectServiceErrors()` throws on any extension load error, and
`getPiModelRuntime()` passed that on, so `model/list` answered with a
JSON-RPC error. The user lost every model on the machine, built-in
providers included, because of one bad third-party extension.

Repro before this change, with a working extension and a broken one
installed together:

```
Error: Failed to load Pi extension "/tmp/pi-broken/ext/broken.ts": Cannot find module '@not-installed/nope'
```

The fix splits the service builder. `loadConfiguredPiServices()` reports
the problems, and `createConfiguredPiServices()` still throws. Model
listing writes the problems to stderr and lists what loaded. Thread
start still fails loudly, so a run never uses a partial configuration in
silence.

After, through the shipped bundle:

```
pi bridge: Failed to load Pi extension "/tmp/pi-broken/ext/broken.ts": ...
TOTAL 2
  commandcode-fake: 2
```

### 2. An extension model without `input` crashed the list

`input: [...model.input]` threw `TypeError: model.input is not
iterable`. Pi types `input` as required, but an extension registers its
models from plain JavaScript and Pi does not validate them. One
malformed model hid every other provider.

## Impact

A user with a broken or outdated Pi extension keeps a working model
picker and gets the reason on stderr, instead of an empty picker with no
explanation.

## Note on model counts

Extension models appear only when the provider has credentials. With
`COMMANDCODE_API_KEY` unset, `getAvailable()` filters CommandCode out
and the count returns to 0. That is correct Pi behavior, not a BB
defect, but it may explain part of what the reporter saw.

`HOST_DAEMON_PROTOCOL_VERSION` is unchanged: this is internal to the
bridge process and the `model/list` result shape is the same.

## Validation

- 823 `@bb/agent-runtime` tests, including 3 new regression tests
- 482 `@bb/host-daemon` tests
- `pnpm exec turbo run typecheck --filter=@bb/agent-runtime
--filter=@bb/host-daemon`
- ESLint on `packages/agent-runtime/src/pi`
- All three scenarios driven over JSON-RPC against the built
`bb-pi-bridge.mjs`, not only against source

Fixes #1086

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
amadad pushed a commit to amadad/bb that referenced this pull request Aug 14, 2026
## Summary

- Ship a pinned physical Pi 0.84.0 package tree.
- Load global and project Pi settings through Pi's full service path.
- Load configured packages, extensions, skills, prompts, themes,
context, authentication, and models.
- Include extension models in the BB model list.
- Preserve Pi shell settings when BB adds thread environment values.
- Test a custom extension provider, extension tool, and BB dynamic tool
from an installed package.

## Why

The bridge created in-memory settings and bundled Pi into one file. This
bypassed the user's Pi configuration.

The single-file package also prevented extensions from sharing the host
Pi modules.

## Impact

Users keep their Pi settings and extensions while BB controls the Pi
package version.

Users do not need an installed Pi executable.

## Validation

- `pnpm exec turbo run typecheck --filter=@bb/agent-runtime
--filter=@bb/host-daemon --filter=@bb/server --filter=bb-app --force`
- 810 agent runtime tests
- 479 host daemon tests
- 1,335 server tests
- 48 BB application tests
- `pnpm exec turbo run smoke:tarball --filter=bb-app --force`
- A real model request through the packaged bridge with an existing Pi
configuration
amadad pushed a commit to amadad/bb that referenced this pull request Aug 14, 2026
## Summary

- Verify that the `primeExtensions()` port asked for in get-bb#1086 already
landed in get-bb#1080, end to end against the built bridge.
- Stop one broken Pi extension from emptying the whole model picker.
- Stop an extension model without `input` types from failing the whole
model list.

## Why

get-bb#1086 asks to port `primeExtensions()` to the production Pi bridge so
extension providers such as `commandcode` appear in the stock Pi
provider.

That port already landed in get-bb#1080 (`8d7bf6124`). The bridge builds its
model runtime through `createConfiguredPiServices()`, and Pi 0.84.0
flushes `pendingProviderRegistrations` inside
`createAgentSessionServices()`. A disposable priming session is not
necessary.

I confirmed this with the real extension from the issue, not a mock:
`[email protected]` installed from npm, driven by a real
`model/list` JSON-RPC request to the built `dist/bb-pi-bridge.mjs`. It
returns **51 CommandCode models**.

That test found two defects that still produce the exact symptom in the
issue.

### 1. A broken extension emptied the whole picker

`collectServiceErrors()` throws on any extension load error, and
`getPiModelRuntime()` passed that on, so `model/list` answered with a
JSON-RPC error. The user lost every model on the machine, built-in
providers included, because of one bad third-party extension.

Repro before this change, with a working extension and a broken one
installed together:

```
Error: Failed to load Pi extension "/tmp/pi-broken/ext/broken.ts": Cannot find module '@not-installed/nope'
```

The fix splits the service builder. `loadConfiguredPiServices()` reports
the problems, and `createConfiguredPiServices()` still throws. Model
listing writes the problems to stderr and lists what loaded. Thread
start still fails loudly, so a run never uses a partial configuration in
silence.

After, through the shipped bundle:

```
pi bridge: Failed to load Pi extension "/tmp/pi-broken/ext/broken.ts": ...
TOTAL 2
  commandcode-fake: 2
```

### 2. An extension model without `input` crashed the list

`input: [...model.input]` threw `TypeError: model.input is not
iterable`. Pi types `input` as required, but an extension registers its
models from plain JavaScript and Pi does not validate them. One
malformed model hid every other provider.

## Impact

A user with a broken or outdated Pi extension keeps a working model
picker and gets the reason on stderr, instead of an empty picker with no
explanation.

## Note on model counts

Extension models appear only when the provider has credentials. With
`COMMANDCODE_API_KEY` unset, `getAvailable()` filters CommandCode out
and the count returns to 0. That is correct Pi behavior, not a BB
defect, but it may explain part of what the reporter saw.

`HOST_DAEMON_PROTOCOL_VERSION` is unchanged: this is internal to the
bridge process and the `model/list` result shape is the same.

## Validation

- 823 `@bb/agent-runtime` tests, including 3 new regression tests
- 482 `@bb/host-daemon` tests
- `pnpm exec turbo run typecheck --filter=@bb/agent-runtime
--filter=@bb/host-daemon`
- ESLint on `packages/agent-runtime/src/pi`
- All three scenarios driven over JSON-RPC against the built
`bb-pi-bridge.mjs`, not only against source

Fixes get-bb#1086

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant