@beeuni/sdk 0.1.0 → 0.2.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 +35 -83
- package/dist/beeuni.esm.min.js +35 -35
- package/dist/beeuni.global.js +35 -35
- package/dist/browser/stores/sync-store.d.ts +6 -0
- package/dist/browser/stores/sync-store.js +52 -21
- package/dist/core/client/beeuni.d.ts +7 -29
- package/dist/core/client/beeuni.js +3 -11
- package/dist/core/client/facade-catalog.d.ts +0 -4
- package/dist/core/client/facade-catalog.js +1 -5
- 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.d.ts +4 -15
- 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/http/api-client.d.ts +0 -7
- package/dist/core/http/api-client.js +1 -37
- package/dist/core/http/auth.d.ts +2 -4
- package/dist/core/http/auth.js +2 -8
- 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 +3 -4
- package/dist/core/rest/platform-client/index.js +3 -4
- package/dist/core/rest/platform-client/types.d.ts +1 -1
- package/dist/core/rest/projects-client/apps.d.ts +8 -1
- package/dist/core/rest/projects-client/connectors.d.ts +6 -55
- package/dist/core/rest/projects-client/connectors.js +2 -29
- 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-sso.d.ts +0 -10
- package/dist/core/rest/projects-client/iam-sso.js +0 -3
- 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/projects.d.ts +2 -1
- package/dist/core/rest/projects-client/projects.js +3 -0
- package/dist/core/rest/projects-client/sandbox.d.ts +8 -9
- package/dist/core/rest/projects-client/session-sandbox.d.ts +1 -1
- package/dist/core/rest/projects-client/sessions.d.ts +2 -2
- package/dist/core/session/control-stream.d.ts +1 -0
- package/dist/core/session/control-stream.js +18 -1
- 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 +3 -0
- package/dist/core/session-log/index.js +2 -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 +6 -0
- package/dist/core/session-log/tool-call.js +46 -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 +10 -0
- package/dist/core/session-log/v1-view.js +151 -0
- package/dist/core/session-log/v1.d.ts +31 -0
- package/dist/core/session-log/v1.js +466 -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/stream/event-stream.js +2 -2
- package/dist/core/turns/classify.d.ts +2 -1
- package/dist/core/turns/classify.js +3 -1
- package/dist/core/turns/parts.d.ts +3 -2
- package/dist/core/turns/parts.js +4 -2
- package/dist/core/turns/segments/index.d.ts +1 -0
- package/dist/core/turns/segments/index.js +1 -0
- 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/state.d.ts +2 -7
- package/dist/core/turns/state.js +28 -134
- package/dist/core/turns/tools/tool-meta.d.ts +2 -1
- package/dist/core/turns/tools/tool-meta.js +3 -1
- 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/warm-session-pool.d.ts +29 -0
- package/dist/core/warm-session-pool.js +127 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/internal/connector-catalog.d.ts +47 -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/react/index.d.ts +0 -13
- package/dist/react/index.js +0 -13
- package/dist/react/opencode.d.ts +1 -0
- package/dist/react/opencode.js +1 -0
- package/dist/react/query-keys.d.ts +0 -1
- package/dist/react/query-keys.js +0 -1
- package/dist/react/session-transcript-subscription.js +3 -1
- package/dist/react/sign-in-with-beeuni.d.ts +1 -1
- package/dist/react/use-admin-providers.d.ts +5 -5
- 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/index.js +1 -0
- package/dist/react/use-runtime-reconnect.js +2 -2
- package/dist/react/use-session-log.d.ts +15 -0
- package/dist/react/use-session-log.js +134 -0
- package/dist/react/use-session.js +2 -0
- package/package.json +15 -7
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.
|
|
@@ -94,7 +91,7 @@ await linear.accounts();
|
|
|
94
91
|
```
|
|
95
92
|
|
|
96
93
|
An action outside the file accepts any object and returns `output: unknown`.
|
|
97
|
-
|
|
94
|
+
Connectors without a declared output schema return
|
|
98
95
|
`output` stays `unknown`. `ConnectorArgs<'linear', 'list_issues'>` and
|
|
99
96
|
`ConnectorResult<'linear', 'list_issues'>` name the same types.
|
|
100
97
|
|
|
@@ -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
|
|
|
@@ -312,10 +306,7 @@ import { createBeeuni } from "@beeuni/sdk";
|
|
|
312
306
|
|
|
313
307
|
const beeuni = createBeeuni({
|
|
314
308
|
backendUrl: "https://api.beeuni.ai/v1",
|
|
315
|
-
getToken: () =>
|
|
316
|
-
supabase.auth
|
|
317
|
-
.getSession()
|
|
318
|
-
.then((s) => s.data.session?.access_token ?? null),
|
|
309
|
+
getToken: async () => beeuniToken,
|
|
319
310
|
});
|
|
320
311
|
|
|
321
312
|
// Projects
|
|
@@ -373,7 +364,7 @@ const warm = await beeuni.project(pid).sessions.ensureWarm(); // ordinary sessio
|
|
|
373
364
|
|
|
374
365
|
// Sessions (id-bound handle)
|
|
375
366
|
const s = beeuni.session(pid, sid);
|
|
376
|
-
const cost = await s.cost(); // reads finalized
|
|
367
|
+
const cost = await s.cost(); // reads finalized charges without starting the session
|
|
377
368
|
await s.send("Build me a widget"); // provisions/resumes if needed, then prompts
|
|
378
369
|
await s.rewind(userMessageId); // stages a reversible rollback on this session
|
|
379
370
|
await s.restoreRewind(); // restores the removed path before the next prompt
|
|
@@ -480,7 +471,7 @@ In React, `useSessionMessageAuthors(projectId, sessionId, messageCount)` reads t
|
|
|
480
471
|
### Which model answered a turn
|
|
481
472
|
|
|
482
473
|
`beeuni.session(projectId, sessionId).modelUsage()` (or `getSessionModelUsage`) returns
|
|
483
|
-
`{ latest, billed_cost, turns }`
|
|
474
|
+
`{ latest, billed_cost, turns }` for the session. `latest` is
|
|
484
475
|
`{ served_model, fallback_from, at }` for the newest answered request: `served_model` is the model
|
|
485
476
|
that answered, and `fallback_from` is the routed model when a fallback model answered in its place.
|
|
486
477
|
`turns` maps the runtime message id of each prompt to `{ served_models, fallback_from, billed_cost }`.
|
|
@@ -494,9 +485,7 @@ A transcript message carries only the model its turn asked for. In React,
|
|
|
494
485
|
transcript and events from both. The hook owns messages, rewind and restore,
|
|
495
486
|
cancellation, commands, permissions, and questions. Hosts do not construct
|
|
496
487
|
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.
|
|
488
|
+
with `runtimeSupports(health?.capabilities, 'session.rewind')`.
|
|
500
489
|
|
|
501
490
|
Every session saves its transcript at the end of each turn. `useSession` reads saved
|
|
502
491
|
messages from the platform database while `/start` continues. It uses the
|
|
@@ -567,19 +556,18 @@ exhaustive — see `API-MAP.md` for the full per-domain surface:
|
|
|
567
556
|
| `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
557
|
| `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
558
|
| `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) |
|
|
559
|
+
| `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
560
|
| `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
561
|
| `beeuni.validateToken()` | pasted-API-key validation helper — `GET /accounts/me`, never throws, resolves `{valid, identity?, error?}` |
|
|
574
562
|
| `beeuni.connectors` | Connector data plane for an agent-minted session token: `catalog` · `tools` · `search` · `describe` · `call` (`{ account }`) · `accounts` · `uploadAttachment` |
|
|
575
563
|
| `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
564
|
| `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
|
|
565
|
+
| `beeuni.runtime()` | the runtime REST client for the active computer; use a session-scoped handle in multi-tenant code |
|
|
578
566
|
|
|
579
567
|
Runnable, self-contained scripts for the highest-value flows live in
|
|
580
568
|
[`examples/`](./examples): list projects with a PAT, send + stream, the
|
|
581
|
-
multi-tenant server-wrapper pattern, headless transcript rendering,
|
|
582
|
-
|
|
569
|
+
multi-tenant server-wrapper pattern, headless transcript rendering, finalized
|
|
570
|
+
session usage, and session files + project secrets. Each file's
|
|
583
571
|
header comment states the env vars and the exact `bun run examples/….ts`
|
|
584
572
|
invocation.
|
|
585
573
|
|
|
@@ -594,7 +582,7 @@ await beeuni.project(projectId).sessions.create({
|
|
|
594
582
|
```
|
|
595
583
|
|
|
596
584
|
Do not put credentials in this map. For a white-label/backend wrapper, create an
|
|
597
|
-
|
|
585
|
+
connection managed by your application, store its credential through the dedicated
|
|
598
586
|
credential endpoint, and pass only the non-secret connection id at session create:
|
|
599
587
|
|
|
600
588
|
```ts
|
|
@@ -625,27 +613,17 @@ await project.sessions.create({
|
|
|
625
613
|
});
|
|
626
614
|
```
|
|
627
615
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
token:
|
|
616
|
+
Each logged-in member can request authorization for their own account.
|
|
617
|
+
Beeuni derives ownership from the bearer token:
|
|
631
618
|
|
|
632
619
|
```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
|
-
});
|
|
620
|
+
await project.setupLinks.requestConnector({ slug: 'gmail', owner: 'me' });
|
|
643
621
|
```
|
|
644
622
|
|
|
645
623
|
Member connections are owner-only even for project managers, and sessions using
|
|
646
624
|
one must remain private. A service account — an agent or a trigger — never
|
|
647
625
|
reaches a member connection, only the shared project one. Project defaults
|
|
648
|
-
remain shared; external/agent/subject connections
|
|
626
|
+
remain shared; your application manages external/agent/subject connections. Every connection is project/connector scoped
|
|
649
627
|
and resolved on every Connector request, so revocation takes effect without a
|
|
650
628
|
restart. Credentials are encrypted server-side and are never returned, placed
|
|
651
629
|
in `BEEUNI_SESSION_CONTEXT`, or injected into the sandbox environment. Raw env
|
|
@@ -670,7 +648,7 @@ handle.close();
|
|
|
670
648
|
|
|
671
649
|
`session.stream()` emits the runtime's events (`message.updated`,
|
|
672
650
|
`message.part.updated`, `session.status`, `permission.*`, `question.*`, …),
|
|
673
|
-
|
|
651
|
+
Use `useSession()` in React.
|
|
674
652
|
|
|
675
653
|
Events arrive in batches, 16 ms apart. Consecutive `message.part.delta` events
|
|
676
654
|
for one part field in a batch arrive as one event: `properties.delta` is their
|
|
@@ -727,17 +705,14 @@ app.use(async (req, res, next) => {
|
|
|
727
705
|
});
|
|
728
706
|
```
|
|
729
707
|
|
|
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.
|
|
708
|
+
A runnable version of the pattern is `examples/03-server-wrapper.ts`.
|
|
734
709
|
|
|
735
710
|
## Rendering chat (the headless chat kit)
|
|
736
711
|
|
|
737
712
|
Everything needed to render an agent transcript without adopting any Beeuni
|
|
738
713
|
UI: `classifyPart`/`classifyTurn` (framework-free, from the root entry)
|
|
739
714
|
normalize all twelve part types of the Beeuni transcript format
|
|
740
|
-
(`beeuni.transcript.v1
|
|
715
|
+
(`beeuni.transcript.v1`) (text, reasoning, tool, file,
|
|
741
716
|
subtask, patch, snapshot, agent, retry, compaction, step, + a forward-compat
|
|
742
717
|
`unknown`) into a typed `ClassifiedPart`, and normalize a failed assistant
|
|
743
718
|
turn's `info.error` into a `{ name, message }` `TurnError` — so "assistant
|
|
@@ -833,8 +808,7 @@ the root barrel; `@beeuni/sdk/react` re-exports them too). They're real classes:
|
|
|
833
808
|
member (`.runtime`, `.previewUrl()`, `.proxyUrl()`) was touched before
|
|
834
809
|
`ensureReady()` resolved this session's own sandbox.
|
|
835
810
|
|
|
836
|
-
|
|
837
|
-
through to your own client for re-billing, instead of leaking a Beeuni error:
|
|
811
|
+
Catch a 402 and pass the usage payload to your own client:
|
|
838
812
|
|
|
839
813
|
```ts
|
|
840
814
|
import { ApiError, HeadlessAuthError, BillingError } from "@beeuni/sdk";
|
|
@@ -875,25 +849,15 @@ provider, resolved model, HTTP status, code, and bounded message.
|
|
|
875
849
|
|
|
876
850
|
## Entry points
|
|
877
851
|
|
|
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.
|
|
852
|
+
Use the root entry point for the framework-free client. Choose the React
|
|
853
|
+
or server entry point when your integration needs those adapters.
|
|
882
854
|
|
|
883
855
|
| import | when you use it | why it is separate |
|
|
884
856
|
| --- | --- | --- |
|
|
885
857
|
| `@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
858
|
| `@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
859
|
| `@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.
|
|
860
|
+
| `@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
861
|
|
|
898
862
|
```ts
|
|
899
863
|
import { createBeeuni, classifyTurn, listFiles, openEventStream } from '@beeuni/sdk';
|
|
@@ -902,16 +866,8 @@ import { useSession } from '@beeuni/sdk/react';
|
|
|
902
866
|
|
|
903
867
|
### Legacy aliases — do not use in new code
|
|
904
868
|
|
|
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.
|
|
869
|
+
Legacy subpath aliases remain available for existing integrations.
|
|
870
|
+
Use the root entry point in new code.
|
|
915
871
|
|
|
916
872
|
## Configuration
|
|
917
873
|
|
|
@@ -960,20 +916,16 @@ Its only platform code for the session runtime is the event transport
|
|
|
960
916
|
|
|
961
917
|
## Rules of the road
|
|
962
918
|
|
|
963
|
-
-
|
|
919
|
+
- Import transcript and runtime types from
|
|
964
920
|
`@beeuni/sdk`, and reach the runtime through the session verbs. `session.runtime`
|
|
965
921
|
(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.)
|
|
922
|
+
- Use the facade or a subpath module for API calls.
|
|
971
923
|
- **React data** comes from `@beeuni/sdk/react` hooks; **imperative actions** from
|
|
972
924
|
the `createBeeuni` facade.
|
|
973
925
|
|
|
974
926
|
## Auth
|
|
975
927
|
|
|
976
|
-
`Authorization: Bearer <token>` — a
|
|
928
|
+
`Authorization: Bearer <token>` — a user session token, a Beeuni PAT
|
|
977
929
|
(`beeuni_pat_…`) for server-side / automation use, or an OAuth access token
|
|
978
930
|
(`beeuni_oat_…`) minted by "Sign in with Beeuni" — supplied via `getToken`.
|
|
979
931
|
|
|
@@ -1065,7 +1017,7 @@ const asUser = createBeeuni({ backendUrl, getToken: session.getToken });
|
|
|
1065
1017
|
|
|
1066
1018
|
Also `signUp`, `sendMagicLink` + `verifyOtp`, `signInWithProvider` +
|
|
1067
1019
|
`exchangeCode` (PKCE), `resetPassword`, `updatePassword`, `user`, `signOut` —
|
|
1068
|
-
all `/v1/auth
|
|
1020
|
+
all `/v1/auth/*`. Guide: `/docs/sdk/auth`.
|
|
1069
1021
|
|
|
1070
1022
|
## Tests
|
|
1071
1023
|
|
|
@@ -1129,9 +1081,9 @@ caller has no personal resource.
|
|
|
1129
1081
|
|
|
1130
1082
|
### ChatGPT subscription usage
|
|
1131
1083
|
|
|
1132
|
-
`
|
|
1133
|
-
|
|
1134
|
-
|
|
1084
|
+
`session.modelUsage()` reports the LLM credits billed to your Beeuni account.
|
|
1085
|
+
Use `getTurnTokens` to read transcript token counts independently of billing.
|
|
1086
|
+
Mixed sessions retain paid API costs; OpenAI API
|
|
1135
1087
|
models remain billable. Subscription coverage does not include sandbox compute.
|
|
1136
1088
|
|
|
1137
1089
|
### Durable prompt placement
|