@beeuni/sdk 0.1.0 → 0.3.0
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 +53 -92
- package/dist/beeuni.esm.min.js +36 -34
- package/dist/beeuni.global.js +36 -34
- package/dist/browser/cache/idb-sync-cache.js +15 -5
- package/dist/browser/session-sync/server-transcript-mirror.d.ts +7 -1
- package/dist/browser/session-sync/server-transcript-mirror.js +30 -24
- package/dist/browser/session-sync/session-sync-registry.d.ts +3 -1
- package/dist/browser/session-sync/session-sync-registry.js +48 -3
- package/dist/browser/stores/sync-store/keep-unchanged.d.ts +4 -0
- package/dist/browser/stores/sync-store/keep-unchanged.js +34 -0
- package/dist/browser/stores/sync-store.d.ts +7 -0
- package/dist/browser/stores/sync-store.js +122 -35
- package/dist/core/attachments/prompt-attachments.d.ts +4 -0
- package/dist/core/attachments/prompt-attachments.js +34 -0
- package/dist/core/capture/rules.d.ts +17 -0
- package/dist/core/capture/rules.js +27 -0
- package/dist/core/client/beeuni.d.ts +99 -34
- package/dist/core/client/beeuni.js +5 -11
- package/dist/core/client/capture.d.ts +105 -0
- package/dist/core/client/capture.js +48 -0
- package/dist/core/client/facade-catalog.d.ts +0 -4
- package/dist/core/client/facade-catalog.js +1 -5
- package/dist/core/client/facade-identity.d.ts +1 -0
- package/dist/core/client/facade-identity.js +1 -0
- package/dist/core/client/project-access-resources.d.ts +3 -1
- package/dist/core/client/project-access-resources.js +1 -1
- package/dist/core/client/project-connections.d.ts +2 -2
- package/dist/core/client/project-connections.js +2 -2
- package/dist/core/client/project-operations-admin.d.ts +4 -4
- package/dist/core/client/project-operations-review.d.ts +2 -3
- package/dist/core/client/project-operations-review.js +1 -0
- package/dist/core/client/project-operations-workspace.d.ts +4 -4
- package/dist/core/client/project-operations-workspace.js +1 -1
- package/dist/core/client/project-operations.d.ts +9 -19
- package/dist/core/client/project-operations.js +2 -6
- package/dist/core/client/project-platform-security.d.ts +1 -1
- package/dist/core/client/project-platform-settings.d.ts +1 -1
- package/dist/core/client/session-context.d.ts +2 -0
- package/dist/core/client/session-handle.d.ts +13 -0
- package/dist/core/client/session-lifecycle-resources.d.ts +11 -0
- package/dist/core/client/session-lifecycle-resources.js +4 -0
- package/dist/core/client/session-lifecycle-security.d.ts +2 -0
- package/dist/core/client/session-lifecycle-security.js +1 -0
- package/dist/core/client/session-readiness.d.ts +2 -0
- package/dist/core/client/session-readiness.js +20 -1
- package/dist/core/http/api-client.d.ts +1 -7
- package/dist/core/http/api-client.js +2 -37
- package/dist/core/http/auth.d.ts +2 -4
- package/dist/core/http/auth.js +2 -8
- package/dist/core/http/config.d.ts +2 -0
- package/dist/core/http/response-error.js +26 -11
- package/dist/core/http/transport.js +6 -1
- package/dist/core/models/composer-model.d.ts +14 -0
- package/dist/core/models/composer-model.js +21 -1
- package/dist/core/rest/platform-client/capture.d.ts +363 -0
- package/dist/core/rest/platform-client/capture.js +116 -0
- package/dist/core/rest/platform-client/client-policy.d.ts +8 -0
- package/dist/core/rest/platform-client/client-policy.js +30 -0
- package/dist/core/rest/platform-client/index.d.ts +4 -4
- package/dist/core/rest/platform-client/index.js +4 -4
- package/dist/core/rest/platform-client/lifecycle.js +18 -12
- package/dist/core/rest/platform-client/shared.d.ts +5 -0
- package/dist/core/rest/platform-client/shared.js +18 -0
- package/dist/core/rest/platform-client/types.d.ts +1 -1
- package/dist/core/rest/projects-client/account-secret-resources.d.ts +2 -1
- package/dist/core/rest/projects-client/accounts.d.ts +34 -0
- package/dist/core/rest/projects-client/accounts.js +10 -0
- package/dist/core/rest/projects-client/admin-providers.d.ts +0 -61
- package/dist/core/rest/projects-client/admin-providers.js +0 -6
- package/dist/core/rest/projects-client/agent-config.d.ts +3 -0
- package/dist/core/rest/projects-client/apps-fleet.d.ts +5 -1
- package/dist/core/rest/projects-client/apps-fleet.js +2 -2
- package/dist/core/rest/projects-client/apps.d.ts +11 -1
- package/dist/core/rest/projects-client/change-requests.d.ts +2 -0
- package/dist/core/rest/projects-client/change-requests.js +2 -0
- package/dist/core/rest/projects-client/connectors.d.ts +13 -55
- package/dist/core/rest/projects-client/connectors.js +5 -29
- package/dist/core/rest/projects-client/files.d.ts +3 -0
- package/dist/core/rest/projects-client/files.js +4 -0
- package/dist/core/rest/projects-client/gateway.d.ts +5 -0
- package/dist/core/rest/projects-client/git-backend.d.ts +1 -10
- package/dist/core/rest/projects-client/git-backend.js +0 -10
- package/dist/core/rest/projects-client/iam-actions.d.ts +76 -0
- package/dist/core/rest/projects-client/iam-actions.js +101 -0
- package/dist/core/rest/projects-client/iam-sso.d.ts +0 -10
- package/dist/core/rest/projects-client/iam-sso.js +0 -3
- package/dist/core/rest/projects-client/iam.d.ts +1 -0
- package/dist/core/rest/projects-client/iam.js +1 -0
- package/dist/core/rest/projects-client/index.d.ts +1 -4
- package/dist/core/rest/projects-client/index.js +1 -4
- package/dist/core/rest/projects-client/notifications.d.ts +1 -1
- package/dist/core/rest/projects-client/notifications.js +4 -0
- package/dist/core/rest/projects-client/projects.d.ts +4 -2
- package/dist/core/rest/projects-client/projects.js +4 -2
- package/dist/core/rest/projects-client/review-items.d.ts +2 -0
- package/dist/core/rest/projects-client/review-items.js +4 -0
- package/dist/core/rest/projects-client/review.d.ts +17 -3
- package/dist/core/rest/projects-client/review.js +11 -0
- package/dist/core/rest/projects-client/sandbox.d.ts +8 -9
- package/dist/core/rest/projects-client/secrets.d.ts +3 -0
- package/dist/core/rest/projects-client/session-attachments.js +14 -1
- package/dist/core/rest/projects-client/session-sandbox.d.ts +1 -1
- package/dist/core/rest/projects-client/sessions.d.ts +31 -4
- package/dist/core/rest/projects-client/sessions.js +34 -4
- package/dist/core/runtime/runtime-rest-client.js +1 -1
- package/dist/core/runtime/runtime-types.d.ts +1 -0
- package/dist/core/session/control-stream.d.ts +1 -0
- package/dist/core/session/control-stream.js +18 -1
- package/dist/core/session/open-bundle.d.ts +4 -4
- package/dist/core/session/open-bundle.js +29 -46
- package/dist/core/session/turn-end-watch.d.ts +47 -0
- package/dist/core/session/turn-end-watch.js +141 -0
- package/dist/core/session-log/guard.d.ts +6 -0
- package/dist/core/session-log/guard.js +109 -0
- package/dist/core/session-log/index.d.ts +7 -0
- package/dist/core/session-log/index.js +5 -0
- package/dist/core/session-log/saved-log.d.ts +10 -0
- package/dist/core/session-log/saved-log.js +25 -0
- package/dist/core/session-log/source.d.ts +25 -0
- package/dist/core/session-log/source.js +30 -0
- package/dist/core/session-log/store.d.ts +21 -0
- package/dist/core/session-log/store.js +126 -0
- package/dist/core/session-log/tool-call.d.ts +11 -0
- package/dist/core/session-log/tool-call.js +65 -0
- package/dist/core/session-log/turns/blocks.d.ts +60 -0
- package/dist/core/session-log/turns/blocks.js +124 -0
- package/dist/core/session-log/turns/history.d.ts +32 -0
- package/dist/core/session-log/turns/history.js +99 -0
- package/dist/core/session-log/turns/index.d.ts +4 -0
- package/dist/core/session-log/turns/index.js +4 -0
- package/dist/core/session-log/turns/metrics.d.ts +21 -0
- package/dist/core/session-log/turns/metrics.js +29 -0
- package/dist/core/session-log/turns/turn.d.ts +55 -0
- package/dist/core/session-log/turns/turn.js +279 -0
- package/dist/core/session-log/turns/v1-parts.d.ts +8 -0
- package/dist/core/session-log/turns/v1-parts.js +43 -0
- package/dist/core/session-log/types.d.ts +264 -0
- package/dist/core/session-log/types.js +6 -0
- package/dist/core/session-log/v1-view.d.ts +13 -0
- package/dist/core/session-log/v1-view.js +215 -0
- package/dist/core/session-log/v1.d.ts +31 -0
- package/dist/core/session-log/v1.js +473 -0
- package/dist/core/session-sync/copy-store-types.d.ts +19 -0
- package/dist/core/session-sync/copy-store-types.js +1 -0
- package/dist/core/session-sync/saved-copy-store.js +25 -4
- package/dist/core/session-sync/saved-transcript.d.ts +15 -1
- package/dist/core/session-sync/saved-transcript.js +55 -0
- package/dist/core/session-sync/session-sync-controller.js +3 -0
- package/dist/core/stream/event-stream.js +2 -2
- package/dist/core/turns/classify.d.ts +2 -1
- package/dist/core/turns/classify.js +7 -3
- package/dist/core/turns/edit-blocks.d.ts +1 -0
- package/dist/core/turns/edit-blocks.js +15 -0
- package/dist/core/turns/parts.d.ts +3 -2
- package/dist/core/turns/parts.js +4 -2
- package/dist/core/turns/segments/burst-summary.d.ts +1 -0
- package/dist/core/turns/segments/burst-summary.js +24 -0
- package/dist/core/turns/segments/group-steps.d.ts +4 -3
- package/dist/core/turns/segments/group-steps.js +9 -6
- package/dist/core/turns/segments/index.d.ts +1 -0
- package/dist/core/turns/segments/index.js +1 -0
- package/dist/core/turns/segments/narration.d.ts +5 -4
- package/dist/core/turns/segments/narration.js +12 -3
- package/dist/core/turns/segments/session-activity-groups.d.ts +2 -1
- package/dist/core/turns/segments/session-activity-groups.js +3 -1
- package/dist/core/turns/segments/step-label.d.ts +2 -1
- package/dist/core/turns/segments/step-label.js +3 -1
- package/dist/core/turns/segments/work-split.d.ts +10 -0
- package/dist/core/turns/segments/work-split.js +40 -0
- package/dist/core/turns/segments/working-turn.d.ts +4 -2
- package/dist/core/turns/segments/working-turn.js +9 -8
- package/dist/core/turns/state.d.ts +2 -7
- package/dist/core/turns/state.js +28 -134
- package/dist/core/turns/tool-kind.d.ts +1 -1
- package/dist/core/turns/tool-kind.js +3 -2
- package/dist/core/turns/tool-registry.js +1 -0
- package/dist/core/turns/tools/tool-meta.d.ts +3 -2
- package/dist/core/turns/tools/tool-meta.js +5 -2
- package/dist/core/turns/tools/tool-outcome.d.ts +2 -1
- package/dist/core/turns/tools/tool-outcome.js +3 -1
- package/dist/core/turns/types.d.ts +1 -1
- package/dist/core/turns/view-model.js +1 -13
- package/dist/core/warm-session-pool.d.ts +29 -0
- package/dist/core/warm-session-pool.js +127 -0
- package/dist/genui/catalog.d.ts +28 -0
- package/dist/genui/catalog.js +396 -0
- package/dist/genui/expansion.d.ts +3 -0
- package/dist/genui/expansion.js +295 -0
- package/dist/genui/fence-entry.d.ts +2 -0
- package/dist/genui/fence-entry.js +1 -0
- package/dist/genui/fence.d.ts +21 -0
- package/dist/genui/fence.js +138 -0
- package/dist/genui/index.d.ts +6 -0
- package/dist/genui/index.js +6 -0
- package/dist/genui/markdown.d.ts +12 -0
- package/dist/genui/markdown.js +104 -0
- package/dist/genui/parse.d.ts +6 -0
- package/dist/genui/parse.js +75 -0
- package/dist/genui/prompt.d.ts +2 -0
- package/dist/genui/prompt.js +206 -0
- package/dist/genui/react/default-components.d.ts +2 -0
- package/dist/genui/react/default-components.js +72 -0
- package/dist/genui/react/default-components.test.d.ts +1 -0
- package/dist/genui/react/default-components.test.js +94 -0
- package/dist/genui/react/genui-block-disabled.test.d.ts +1 -0
- package/dist/genui/react/genui-block-disabled.test.js +50 -0
- package/dist/genui/react/genui-block.d.ts +28 -0
- package/dist/genui/react/genui-block.js +91 -0
- package/dist/genui/react/genui-block.test.d.ts +1 -0
- package/dist/genui/react/genui-block.test.js +205 -0
- package/dist/genui/react/index.d.ts +2 -0
- package/dist/genui/react/index.js +2 -0
- package/dist/genui/share.d.ts +5 -0
- package/dist/genui/share.js +30 -0
- package/dist/genui/test-fixtures.d.ts +2 -0
- package/dist/genui/test-fixtures.js +16 -0
- package/dist/genui/types.d.ts +29 -0
- package/dist/genui/types.js +1 -0
- package/dist/genui/urls.d.ts +1 -0
- package/dist/genui/urls.js +18 -0
- package/dist/genui/validate.d.ts +9 -0
- package/dist/genui/validate.js +116 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/internal/connector-catalog.d.ts +48 -0
- package/dist/internal/connector-catalog.js +27 -0
- package/dist/internal/host-configuration.d.ts +22 -0
- package/dist/internal/host-configuration.js +28 -0
- package/dist/internal/platform-admin-react.d.ts +12 -0
- package/dist/internal/platform-admin-react.js +13 -0
- package/dist/internal/platform-admin.d.ts +9 -0
- package/dist/internal/platform-admin.js +9 -0
- package/dist/platform/ui.d.ts +8 -2
- package/dist/platform/ui.js +19 -4
- package/dist/react/chat/use-chat-turns.d.ts +1 -1
- package/dist/react/human-presence.d.ts +9 -0
- package/dist/react/human-presence.js +12 -0
- package/dist/react/index.d.ts +4 -13
- package/dist/react/index.js +4 -13
- package/dist/react/opencode.d.ts +1 -0
- package/dist/react/opencode.js +1 -0
- package/dist/react/query-contracts.d.ts +6 -0
- package/dist/react/query-contracts.js +6 -0
- package/dist/react/query-keys.d.ts +17 -2
- package/dist/react/query-keys.js +24 -2
- package/dist/react/reset-identity-state.js +2 -0
- package/dist/react/session-cache-write.d.ts +1 -0
- package/dist/react/session-cache-write.js +20 -0
- package/dist/react/session-transcript-subscription.js +3 -1
- package/dist/react/sign-in-with-beeuni.d.ts +6 -6
- package/dist/react/turn-end-handoff.d.ts +13 -0
- package/dist/react/turn-end-handoff.js +101 -0
- package/dist/react/use-admin-providers.d.ts +3 -6
- package/dist/react/use-admin-providers.js +1 -11
- package/dist/react/use-capture.d.ts +47 -0
- package/dist/react/use-capture.js +173 -0
- package/dist/react/use-feature-flag.js +1 -0
- package/dist/react/use-opencode-events/handle-event.d.ts +1 -0
- package/dist/react/use-opencode-events/handle-event.js +5 -0
- package/dist/react/use-opencode-events/handle-interaction-event.js +8 -3
- package/dist/react/use-opencode-events/handle-session-event.js +13 -8
- package/dist/react/use-opencode-events/handler-context.d.ts +1 -0
- package/dist/react/use-opencode-events/helpers.d.ts +1 -0
- package/dist/react/use-opencode-events/helpers.js +11 -1
- package/dist/react/use-opencode-events/index.js +1 -0
- package/dist/react/use-opencode-local.d.ts +5 -1
- package/dist/react/use-opencode-local.js +15 -2
- package/dist/react/use-opencode-sessions/commands.d.ts +11 -1
- package/dist/react/use-opencode-sessions/commands.js +21 -1
- package/dist/react/use-opencode-sessions/permissions.js +28 -1
- package/dist/react/use-project-sessions.d.ts +1 -1
- package/dist/react/use-project-sessions.js +6 -5
- package/dist/react/use-prompt-attachments.js +1 -0
- package/dist/react/use-review-summary.d.ts +13 -0
- package/dist/react/use-review-summary.js +32 -0
- package/dist/react/use-runtime-reconnect.js +1 -1
- package/dist/react/use-session-list-state.d.ts +6 -0
- package/dist/react/use-session-list-state.js +33 -0
- package/dist/react/use-session-log.d.ts +16 -0
- package/dist/react/use-session-log.js +143 -0
- package/dist/react/use-session-messages.d.ts +2 -1
- package/dist/react/use-session-messages.js +15 -14
- package/dist/react/use-session-stream.js +12 -1
- package/dist/react/use-session-sync.d.ts +2 -2
- package/dist/react/use-session-sync.js +10 -8
- package/dist/react/use-session-transcript-history.js +2 -12
- package/dist/react/use-session-working.d.ts +2 -0
- package/dist/react/use-session-working.js +10 -0
- package/dist/react/use-session.d.ts +6 -0
- package/dist/react/use-session.js +88 -6
- package/package.json +62 -8
package/README.md
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
# @beeuni/sdk
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
and the package depends on no harness SDK. (The no-raw-`backendApi`/`authenticatedFetch` rule
|
|
8
|
-
below is the target state, not yet fully true of apps/web — see Rules of the
|
|
9
|
-
road.)
|
|
3
|
+
Connect your product to Beeuni Computer as an agent backend. One typed client
|
|
4
|
+
manages projects, sessions, tools, files, and live agent responses from web,
|
|
5
|
+
mobile, or server applications. The SDK includes typed transcripts
|
|
6
|
+
(`beeuni.transcript.v1`) and optional React hooks.
|
|
10
7
|
|
|
11
8
|
> Philosophy: **one Beeuni token, one client, every action a method.** Keys never
|
|
12
9
|
> leave the server; mutations own their side-effects there; the host states intent.
|
|
@@ -84,7 +81,7 @@ One connector as a handle: `run` returns the output itself and throws
|
|
|
84
81
|
`upstreamStatus`, `retryAfterSeconds`) or `ConnectorApprovalPendingError`;
|
|
85
82
|
`paginate` follows a cursor and throws `ConnectorPageLimitError` (with
|
|
86
83
|
`nextArgs`) past `maxPages`; `useConnectorQuery` (`@beeuni/sdk/react`) caches a
|
|
87
|
-
read. Guide:
|
|
84
|
+
read. Guide: [Connectors](https://beeuni.ai/docs/connect/connectors#typed-calls-from-code); runnable: `examples/13-connectors-as-code.ts`.
|
|
88
85
|
|
|
89
86
|
```ts
|
|
90
87
|
const linear = beeuni.project(projectId).connector('linear');
|
|
@@ -94,8 +91,8 @@ await linear.accounts();
|
|
|
94
91
|
```
|
|
95
92
|
|
|
96
93
|
An action outside the file accepts any object and returns `output: unknown`.
|
|
97
|
-
|
|
98
|
-
`
|
|
94
|
+
For connectors without a declared output schema, `output` stays `unknown`.
|
|
95
|
+
`ConnectorArgs<'linear', 'list_issues'>` and
|
|
99
96
|
`ConnectorResult<'linear', 'list_issues'>` name the same types.
|
|
100
97
|
|
|
101
98
|
#### Choose which account a call runs as
|
|
@@ -127,10 +124,7 @@ Nothing connected yet? Start a hosted authorization and say who the new account
|
|
|
127
124
|
belongs to:
|
|
128
125
|
|
|
129
126
|
```ts
|
|
130
|
-
await project.
|
|
131
|
-
await project.connectors.pipedream.connect('gmail', { owner: 'project' }); // shared
|
|
132
|
-
|
|
133
|
-
// Or hand a human a link instead of authorizing inline:
|
|
127
|
+
await project.setupLinks.requestConnector({ slug: 'gmail', owner: 'me' }); // my own
|
|
134
128
|
await project.setupLinks.requestConnector({ slug: 'gmail', owner: 'project' });
|
|
135
129
|
```
|
|
136
130
|
|
|
@@ -154,7 +148,7 @@ The browser path needs the App's viewer scope set to `api`
|
|
|
154
148
|
`403 insufficient_scope`. A service account answers `403` until a person
|
|
155
149
|
grants it a project role (`beeuni access grant --service-account <id> --role
|
|
156
150
|
member --project <id>`). Never put a provider API key in an App or a Convex
|
|
157
|
-
deployment when a connector exists. Guide:
|
|
151
|
+
deployment when a connector exists. Guide: [Connectors](https://beeuni.ai/docs/connect/connectors).
|
|
158
152
|
|
|
159
153
|
### Upload prompt attachments before Send
|
|
160
154
|
|
|
@@ -216,12 +210,19 @@ cannot retry: `retry` throws, and the item error carries code
|
|
|
216
210
|
resolves at once. It deletes unbound storage best-effort and never rejects; a
|
|
217
211
|
failed or refused DELETE leaves the object to the 24-hour expiry.
|
|
218
212
|
`abort(localId)` cancels unfinished work. `dispose()` aborts listed work and
|
|
219
|
-
deletes its uploads best-effort: no send holds them
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
213
|
+
deletes its uploads best-effort: no send holds them. Call it on non-React
|
|
214
|
+
cleanup; the hook handles unmount and project changes. Unused uploads expire
|
|
215
|
+
after 24 hours.
|
|
216
|
+
|
|
217
|
+
A draft may keep a finished upload, so a reload or another composer brings the
|
|
218
|
+
file back. Store its metadata (`item.attachment`: `attachment_id`, `filename`,
|
|
219
|
+
`mime`, `size`, `expires_at`) and call `forget(ids)` before `dispose()`, so the
|
|
220
|
+
upload is not deleted. Later, `restore([{ attachment, file? }])` lists it again
|
|
221
|
+
as `ready` with no request, and returns its new id (`undefined` for an expired or
|
|
222
|
+
invalid one). Send uses it like any ready upload. The server binds an attachment
|
|
223
|
+
only for its own account, project and person, so the id grants nothing to
|
|
224
|
+
anyone else. Never persist a File, a blob URL, or a signed URL: an unfinished
|
|
225
|
+
upload cannot be kept.
|
|
225
226
|
|
|
226
227
|
For non-composer uploads, call `beeuni.project(projectId).attachments.upload(file,
|
|
227
228
|
{ signal, onProgress, onUpload, resume })`. The server selects the transport in the
|
|
@@ -312,10 +313,7 @@ import { createBeeuni } from "@beeuni/sdk";
|
|
|
312
313
|
|
|
313
314
|
const beeuni = createBeeuni({
|
|
314
315
|
backendUrl: "https://api.beeuni.ai/v1",
|
|
315
|
-
getToken: () =>
|
|
316
|
-
supabase.auth
|
|
317
|
-
.getSession()
|
|
318
|
-
.then((s) => s.data.session?.access_token ?? null),
|
|
316
|
+
getToken: async () => beeuniToken,
|
|
319
317
|
});
|
|
320
318
|
|
|
321
319
|
// Projects
|
|
@@ -373,7 +371,7 @@ const warm = await beeuni.project(pid).sessions.ensureWarm(); // ordinary sessio
|
|
|
373
371
|
|
|
374
372
|
// Sessions (id-bound handle)
|
|
375
373
|
const s = beeuni.session(pid, sid);
|
|
376
|
-
const cost = await s.cost(); // reads finalized
|
|
374
|
+
const cost = await s.cost(); // reads finalized charges without starting the session
|
|
377
375
|
await s.send("Build me a widget"); // provisions/resumes if needed, then prompts
|
|
378
376
|
await s.rewind(userMessageId); // stages a reversible rollback on this session
|
|
379
377
|
await s.restoreRewind(); // restores the removed path before the next prompt
|
|
@@ -480,7 +478,7 @@ In React, `useSessionMessageAuthors(projectId, sessionId, messageCount)` reads t
|
|
|
480
478
|
### Which model answered a turn
|
|
481
479
|
|
|
482
480
|
`beeuni.session(projectId, sessionId).modelUsage()` (or `getSessionModelUsage`) returns
|
|
483
|
-
`{ latest, billed_cost, turns }`
|
|
481
|
+
`{ latest, billed_cost, turns }` for the session. `latest` is
|
|
484
482
|
`{ served_model, fallback_from, at }` for the newest answered request: `served_model` is the model
|
|
485
483
|
that answered, and `fallback_from` is the routed model when a fallback model answered in its place.
|
|
486
484
|
`turns` maps the runtime message id of each prompt to `{ served_models, fallback_from, billed_cost }`.
|
|
@@ -494,9 +492,7 @@ A transcript message carries only the model its turn asked for. In React,
|
|
|
494
492
|
transcript and events from both. The hook owns messages, rewind and restore,
|
|
495
493
|
cancellation, commands, permissions, and questions. Hosts do not construct
|
|
496
494
|
runtime routes. A feature one harness lacks is a capability: gate its control
|
|
497
|
-
with `runtimeSupports(health?.capabilities, 'session.rewind')`.
|
|
498
|
-
`session.subagents` only, so rewind, compaction, slash commands, the todo list
|
|
499
|
-
and the runtime config document stay hidden or empty on a pi session.
|
|
495
|
+
with `runtimeSupports(health?.capabilities, 'session.rewind')`.
|
|
500
496
|
|
|
501
497
|
Every session saves its transcript at the end of each turn. `useSession` reads saved
|
|
502
498
|
messages from the platform database while `/start` continues. It uses the
|
|
@@ -567,19 +563,18 @@ exhaustive — see `API-MAP.md` for the full per-domain surface:
|
|
|
567
563
|
| `beeuni.accounts` | list · get · create · members · invites · `secretResources.{list,create,rotate,delete,grant,revoke,setAccess}` · `tokens.{list,create,revoke}` (account-scoped CLI PATs, `beeuni_pat_…`) · `audit.{log,export,webhooks.*}` (filterable project/session reconstruction log) · `branding.{get,update,uploadAsset,removeAsset,reset}` (Enterprise organization branding: logo / icon / favicon, light + dark, product name) (+ more: `updateName`, `leave`, `invite`, `removeMember`, `updateMemberRole`) |
|
|
568
564
|
| `beeuni.billing` | entitlement/usage reads: `accountState` · `accountStateMinimal` · `transactions` · `transactionsSummary` · `creditBreakdown` · `usageHistory` · `usageRollup` · `sessionCosts.{list,get}` · `tierConfigurations` — plus a curated mutation surface: `subscription.{createPortalSession,cancel,reactivate,cancelScheduledChange,prorationPreview}` · `credits.{purchase,autoTopupSettings,configureAutoTopup}`. `checkout.{createSession,confirmSession}` and `subscription.scheduleDowngrade` are deprecated: they reject with `ENDPOINT_RETIRED` |
|
|
569
565
|
| `beeuni.marketplace` | public marketplace catalog browse + sources (not project-scoped): `items` · `item` · `itemFile` · `marketplaces` · `featured` · `sources.{list,add,remove}` — distinct from the install-scoped `project(id).marketplace` |
|
|
570
|
-
| `beeuni.github` | account-scoped GitHub App installs and
|
|
571
|
-
| `beeuni.gitBackend` | the instance git backend ("Beeuni managed", one per deployment, never an account connection): `get()` → `{configured, kind: 'app'|'pat'|null, owner}` (any authenticated user) · `repositories({search?, limit?})` (instance operator only; 403 otherwise) |
|
|
566
|
+
| `beeuni.github` | account-scoped GitHub App installs and repository linking: `getInstallation` · `listInstallations` · `listLinkableInstallations` · `listRepositories` · `listRepositoryBranches` · `linkInstallation` · `saveInstallation` · `deleteInstallation` · `linkRepository` · `replaceProjectRepository` (changes an existing project's repository with an expected old URL and repository-scoped authorization) |
|
|
572
567
|
| `beeuni.notifications` | the caller's notifications, across accounts: `list({ limit?, before? })` (inbox page + `unread_count`) · `markRead({ ids } \| { all: true } \| { sessionId })` · `preferences` · `updatePreferences({ kinds })` (push and email per kind) · `webPushPublicKey` · `registerWebPushSubscription` · `unregisterWebPushSubscription` · `registerDeviceToken` · `unregisterDeviceToken` (native Expo push). Muting one session is `session(pid, sid).setWatch(false)`. Hooks: `useNotificationInbox`, `useNotificationPreferences`, `useSessionWatch`. Inbox rows, Web Push, email, and session watch are served only for projects with the `notification_center` flag on, off by default; with it off, the session creator's phone still gets the push |
|
|
573
568
|
| `beeuni.validateToken()` | pasted-API-key validation helper — `GET /accounts/me`, never throws, resolves `{valid, identity?, error?}` |
|
|
574
569
|
| `beeuni.connectors` | Connector data plane for an agent-minted session token: `catalog` · `tools` · `search` · `describe` · `call` (`{ account }`) · `accounts` · `uploadAttachment` |
|
|
575
570
|
| `beeuni.project(id)` | id-bound handle: `.apps` (stable App URLs, access, artifacts, deployments, logs, rollback, start/stop, machines (`machines.list/start/stop/restart/destroy`, `scale`, `exec`), volumes (`volumes.list/create/update/destroy/snapshots/snapshot/restore/fork`), and `token`) · `.secrets` · `.access` · `.connectors` (data plane + configuration + Connections) · `.policies` · `.triggers` (cron / webhook / monitor / event; `.eventTypes({ connector })` lists a connector's app events) · `.files` · `.git` · `.changeRequests` (incl. `requestChanges`) · `.sessions` · `.tokens` (project-scoped CLI PATs — the `BEEUNI_TOKEN` shape) · `.marketplace` / `.registry` (install/update/remove catalog items) · `.setupLinks.{requestSecret,requestConnector}` (agent-minted secret-entry / connector links) · `.validateManifest` · `.gitToken` · `.setDefaultAgent(name)` · `.session(sid)` (+ more namespaces: `.review`, `.approvals`, `.gateway` (incl. `.routing` and `.playground`), `.channels`, `.modelDefaults`, `.sandbox`) |
|
|
576
571
|
| `beeuni.session(pid, sid)` | id-bound handle: lifecycle (`get`/`update`/`delete`/`start`/`restart`/`stop`/`reloadConfig`/`reloadConfigStream`/`setSharing`/`participants`/`watch`/`setWatch`/`presence`/`previews`/`commit`/`publicShares`/`ensureReady`) · `providerSecretPool.{list,get,set}` · finalized `cost()` · `send`/`abort`/`rewind`/`restoreRewind`/`setModel`/`setAgent` · `transcript()` · `.files` · runtime URL helpers (`health`/`previewUrl`/`proxyUrl`) · runtime REST escape hatches: `stream()` and the deprecated `.runtime` |
|
|
577
|
-
| `beeuni.runtime()` | the runtime REST client for the active
|
|
572
|
+
| `beeuni.runtime()` | the runtime REST client for the active computer; use a session-scoped handle in multi-tenant code |
|
|
578
573
|
|
|
579
574
|
Runnable, self-contained scripts for the highest-value flows live in
|
|
580
575
|
[`examples/`](./examples): list projects with a PAT, send + stream, the
|
|
581
|
-
multi-tenant server-wrapper pattern, headless transcript rendering,
|
|
582
|
-
|
|
576
|
+
multi-tenant server-wrapper pattern, headless transcript rendering, finalized
|
|
577
|
+
session usage, and session files + project secrets. Each file's
|
|
583
578
|
header comment states the env vars and the exact `bun run examples/….ts`
|
|
584
579
|
invocation.
|
|
585
580
|
|
|
@@ -594,7 +589,7 @@ await beeuni.project(projectId).sessions.create({
|
|
|
594
589
|
```
|
|
595
590
|
|
|
596
591
|
Do not put credentials in this map. For a white-label/backend wrapper, create an
|
|
597
|
-
|
|
592
|
+
connection managed by your application, store its credential through the dedicated
|
|
598
593
|
credential endpoint, and pass only the non-secret connection id at session create:
|
|
599
594
|
|
|
600
595
|
```ts
|
|
@@ -625,27 +620,17 @@ await project.sessions.create({
|
|
|
625
620
|
});
|
|
626
621
|
```
|
|
627
622
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
token:
|
|
623
|
+
Each logged-in member can request authorization for their own account.
|
|
624
|
+
Beeuni derives ownership from the bearer token:
|
|
631
625
|
|
|
632
626
|
```ts
|
|
633
|
-
|
|
634
|
-
connector_alias: "gmail",
|
|
635
|
-
label: "My Gmail",
|
|
636
|
-
});
|
|
637
|
-
await project.connectors.connections.pipedreamConnect(connection.connection_id);
|
|
638
|
-
// Complete OAuth, then:
|
|
639
|
-
await project.connectors.connections.pipedreamFinalize(connection.connection_id);
|
|
640
|
-
await project.sessions.create({
|
|
641
|
-
connector_bindings: { gmail: { connection_id: connection.connection_id } },
|
|
642
|
-
});
|
|
627
|
+
await project.setupLinks.requestConnector({ slug: 'gmail', owner: 'me' });
|
|
643
628
|
```
|
|
644
629
|
|
|
645
630
|
Member connections are owner-only even for project managers, and sessions using
|
|
646
631
|
one must remain private. A service account — an agent or a trigger — never
|
|
647
632
|
reaches a member connection, only the shared project one. Project defaults
|
|
648
|
-
remain shared; external/agent/subject connections
|
|
633
|
+
remain shared; your application manages external/agent/subject connections. Every connection is project/connector scoped
|
|
649
634
|
and resolved on every Connector request, so revocation takes effect without a
|
|
650
635
|
restart. Credentials are encrypted server-side and are never returned, placed
|
|
651
636
|
in `BEEUNI_SESSION_CONTEXT`, or injected into the sandbox environment. Raw env
|
|
@@ -670,7 +655,7 @@ handle.close();
|
|
|
670
655
|
|
|
671
656
|
`session.stream()` emits the runtime's events (`message.updated`,
|
|
672
657
|
`message.part.updated`, `session.status`, `permission.*`, `question.*`, …),
|
|
673
|
-
|
|
658
|
+
Use `useSession()` in React.
|
|
674
659
|
|
|
675
660
|
Events arrive in batches, 16 ms apart. Consecutive `message.part.delta` events
|
|
676
661
|
for one part field in a batch arrive as one event: `properties.delta` is their
|
|
@@ -727,17 +712,14 @@ app.use(async (req, res, next) => {
|
|
|
727
712
|
});
|
|
728
713
|
```
|
|
729
714
|
|
|
730
|
-
A runnable version of the pattern is `examples/03-server-wrapper.ts
|
|
731
|
-
full production-shaped reference (per-user project isolation, route policy,
|
|
732
|
-
rate limiting, cost markup for re-billing) is `apps/whitelabel-demo` in wrapper
|
|
733
|
-
mode — see its README.
|
|
715
|
+
A runnable version of the pattern is `examples/03-server-wrapper.ts`.
|
|
734
716
|
|
|
735
717
|
## Rendering chat (the headless chat kit)
|
|
736
718
|
|
|
737
719
|
Everything needed to render an agent transcript without adopting any Beeuni
|
|
738
720
|
UI: `classifyPart`/`classifyTurn` (framework-free, from the root entry)
|
|
739
721
|
normalize all twelve part types of the Beeuni transcript format
|
|
740
|
-
(`beeuni.transcript.v1
|
|
722
|
+
(`beeuni.transcript.v1`) (text, reasoning, tool, file,
|
|
741
723
|
subtask, patch, snapshot, agent, retry, compaction, step, + a forward-compat
|
|
742
724
|
`unknown`) into a typed `ClassifiedPart`, and normalize a failed assistant
|
|
743
725
|
turn's `info.error` into a `{ name, message }` `TurnError` — so "assistant
|
|
@@ -807,6 +789,8 @@ the root import — offers the same agents and models and sends the same pick.
|
|
|
807
789
|
| `modelInDefaultView(model, { search, isStoreVisible, selected })` | → whether the empty-search picker shows the model |
|
|
808
790
|
| `resolveModelDefault(modelDefaults, agentName)` | `/model-defaults` → agent → project → account → platform default |
|
|
809
791
|
| `resolveComposerModel({ models, picks, serverDefault, globalDefault, agentModel, configModel, recent, providers })` | → `{ model, explicit, fallback }` |
|
|
792
|
+
| `sessionModelCandidates({ session, lastPromptModel, gatewayEnabled })` | session row + last prompt's model → the models the session already runs, most trusted first: a chosen pin (`explicit`, `repointed`), the last prompt's model, a default pin. Put them in `picks` after this composer's own pick for the session |
|
|
793
|
+
| `latestPromptModel(messages)` | transcript → the model of the newest user message that records one |
|
|
810
794
|
|
|
811
795
|
The root barrel reads catalog helpers from `@beeuni/llm-catalog/lite`, which
|
|
812
796
|
never includes the ~7.6 MB models.dev snapshot, so a bundler that does not
|
|
@@ -833,8 +817,7 @@ the root barrel; `@beeuni/sdk/react` re-exports them too). They're real classes:
|
|
|
833
817
|
member (`.runtime`, `.previewUrl()`, `.proxyUrl()`) was touched before
|
|
834
818
|
`ensureReady()` resolved this session's own sandbox.
|
|
835
819
|
|
|
836
|
-
|
|
837
|
-
through to your own client for re-billing, instead of leaking a Beeuni error:
|
|
820
|
+
Catch a 402 and pass the usage payload to your own client:
|
|
838
821
|
|
|
839
822
|
```ts
|
|
840
823
|
import { ApiError, HeadlessAuthError, BillingError } from "@beeuni/sdk";
|
|
@@ -875,25 +858,15 @@ provider, resolved model, HTTP status, code, and bounded message.
|
|
|
875
858
|
|
|
876
859
|
## Entry points
|
|
877
860
|
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
cannot; `wire-message-id` exists so a server can load one module, not the barrel.
|
|
881
|
-
That is the whole map — learn it once.
|
|
861
|
+
Use the root entry point for the framework-free client. Choose the React
|
|
862
|
+
or server entry point when your integration needs those adapters.
|
|
882
863
|
|
|
883
864
|
| import | when you use it | why it is separate |
|
|
884
865
|
| --- | --- | --- |
|
|
885
866
|
| `@beeuni/sdk` | **almost always.** `createBeeuni`, `configureBeeuni`, the REST surface, `files`, session URLs + health (`runtimeSupports` reads a runtime's `capabilities`), `classifyPart`/`classifyTurn`/`toolViewModel`/`toToolView`/`toolKind`, `openEventStream`, `narrowChatEvent`, the message queue, the error classes, and every domain type | — |
|
|
886
867
|
| `@beeuni/sdk/react` | hooks and providers: `useSession`, every `useRuntime*` (each pre-W4 `useOpenCode*` name is a deprecated alias), `useChatTurns`/`renderParts`, the domain hooks | `react` is an **optional peer dependency**. Putting these at the root would force React on a CLI, a worker, or a React Native host |
|
|
887
868
|
| `@beeuni/sdk/server` | `runWithBeeuni`, `createScopedBeeuni`, `getScopedConfig` — per-request config isolation in a Node/Bun backend | imports `node:async_hooks`. Never let it into a browser bundle |
|
|
888
|
-
| `@beeuni/sdk/wire-message-id` | `mintWireMessageId`, `mintWireMessageIdAbove`, `newestWireIdClock`, `wireIdClock`, `wireIdClockDelta`, `maxWireIdClock`, `isWireIdAheadOf` — the
|
|
889
|
-
| `@beeuni/sdk/internal/*` | nothing, in host code | apps/web's zustand stores. Browser-only, **outside semver**, and not on the `window.Beeuni` global. Implementation detail that is regrettably visible |
|
|
890
|
-
|
|
891
|
-
The root really is canonical, and that is a test rather than a promise:
|
|
892
|
-
`src/root-canonical.test.ts` asserts that every name exported by every other
|
|
893
|
-
isomorphic subpath is also exported from `@beeuni/sdk`. The only names it
|
|
894
|
-
permits to be missing are the browser-only stores above — `zustand` is a
|
|
895
|
-
forbidden import in the root's `isomorphic-core` tier, so they cannot live
|
|
896
|
-
there.
|
|
869
|
+
| `@beeuni/sdk/wire-message-id` | `mintWireMessageId`, `mintWireMessageIdAbove`, `newestWireIdClock`, `wireIdClock`, `wireIdClockDelta`, `maxWireIdClock`, `isWireIdAheadOf` — the message-id clock | the root exports the same names. A server that mints ids loads this one import-free module instead of the whole barrel |
|
|
897
870
|
|
|
898
871
|
```ts
|
|
899
872
|
import { createBeeuni, classifyTurn, listFiles, openEventStream } from '@beeuni/sdk';
|
|
@@ -902,16 +875,8 @@ import { useSession } from '@beeuni/sdk/react';
|
|
|
902
875
|
|
|
903
876
|
### Legacy aliases — do not use in new code
|
|
904
877
|
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
`/projects-client`, `/platform-client`, `/opencode-client`, `/opencode-errors`,
|
|
908
|
-
`/event-stream`, `/feature-flags`, `/fresh-sessions`, `/instance-routes`,
|
|
909
|
-
`/message-queue`, and the un-prefixed store aliases.
|
|
910
|
-
|
|
911
|
-
Every one of them is a one-line `export *` re-export under `src/deprecated/`,
|
|
912
|
-
kept alive only so an existing `npm install` does not break. **They add nothing
|
|
913
|
-
the root does not already export.** They are removed at the next major; new
|
|
914
|
-
code imports the root.
|
|
878
|
+
Legacy subpath aliases remain available for existing integrations.
|
|
879
|
+
Use the root entry point in new code.
|
|
915
880
|
|
|
916
881
|
## Configuration
|
|
917
882
|
|
|
@@ -960,20 +925,16 @@ Its only platform code for the session runtime is the event transport
|
|
|
960
925
|
|
|
961
926
|
## Rules of the road
|
|
962
927
|
|
|
963
|
-
-
|
|
928
|
+
- Import transcript and runtime types from
|
|
964
929
|
`@beeuni/sdk`, and reach the runtime through the session verbs. `session.runtime`
|
|
965
930
|
(the raw REST compatibility client) is deprecated.
|
|
966
|
-
|
|
967
|
-
- **No raw `backendApi` / `authenticatedFetch` in host code.** Use the facade or a
|
|
968
|
-
subpath module. (Aspirational: apps/web still calls `backendApi` via its
|
|
969
|
-
`@/lib/api-client` re-export in ~30 files and keeps a parallel
|
|
970
|
-
`authenticatedFetch` in `apps/web/src/lib/auth-token.ts` — migration pending.)
|
|
931
|
+
- Use the facade or a subpath module for API calls.
|
|
971
932
|
- **React data** comes from `@beeuni/sdk/react` hooks; **imperative actions** from
|
|
972
933
|
the `createBeeuni` facade.
|
|
973
934
|
|
|
974
935
|
## Auth
|
|
975
936
|
|
|
976
|
-
`Authorization: Bearer <token>` — a
|
|
937
|
+
`Authorization: Bearer <token>` — a user session token, a Beeuni PAT
|
|
977
938
|
(`beeuni_pat_…`) for server-side / automation use, or an OAuth access token
|
|
978
939
|
(`beeuni_oat_…`) minted by "Sign in with Beeuni" — supplied via `getToken`.
|
|
979
940
|
|
|
@@ -1065,7 +1026,7 @@ const asUser = createBeeuni({ backendUrl, getToken: session.getToken });
|
|
|
1065
1026
|
|
|
1066
1027
|
Also `signUp`, `sendMagicLink` + `verifyOtp`, `signInWithProvider` +
|
|
1067
1028
|
`exchangeCode` (PKCE), `resetPassword`, `updatePassword`, `user`, `signOut` —
|
|
1068
|
-
all `/v1/auth
|
|
1029
|
+
all `/v1/auth/*`. Guide: `/docs/sdk/auth`.
|
|
1069
1030
|
|
|
1070
1031
|
## Tests
|
|
1071
1032
|
|
|
@@ -1129,9 +1090,9 @@ caller has no personal resource.
|
|
|
1129
1090
|
|
|
1130
1091
|
### ChatGPT subscription usage
|
|
1131
1092
|
|
|
1132
|
-
`
|
|
1133
|
-
|
|
1134
|
-
|
|
1093
|
+
`session.modelUsage()` reports the LLM credits billed to your Beeuni account.
|
|
1094
|
+
Use `getTurnTokens` to read transcript token counts independently of billing.
|
|
1095
|
+
Mixed sessions retain paid API costs; OpenAI API
|
|
1135
1096
|
models remain billable. Subscription coverage does not include sandbox compute.
|
|
1136
1097
|
|
|
1137
1098
|
### Durable prompt placement
|