@radheim/sdk 0.0.0-stage → 2.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +148 -3
  2. package/dist/chunks/contracts-21rejh3w.js +79 -0
  3. package/dist/chunks/contracts-4gf949th.js +14 -0
  4. package/dist/chunks/contracts-6ard325q.js +23 -0
  5. package/dist/chunks/contracts-9921d0eq.js +18 -0
  6. package/dist/chunks/contracts-9rqn6x4v.js +16 -0
  7. package/dist/chunks/contracts-9ybt1tz4.js +14 -0
  8. package/dist/chunks/contracts-d8k8mt5a.js +49 -0
  9. package/dist/chunks/contracts-f8tdk121.js +128 -0
  10. package/dist/chunks/contracts-fc2gzwgc.js +52 -0
  11. package/dist/chunks/contracts-q7txhdnb.js +25 -0
  12. package/dist/chunks/contracts-r4rmkqh9.js +44 -0
  13. package/dist/chunks/contracts-rnpbh5as.js +55 -0
  14. package/dist/chunks/contracts-v8gt2qd1.js +29 -0
  15. package/dist/contracts.d.ts +26 -0
  16. package/dist/contracts.js +58 -0
  17. package/dist/effect/index.d.ts +10 -0
  18. package/dist/effect/index.js +85 -0
  19. package/dist/effect/opencode.d.ts +55 -0
  20. package/dist/effect/opencode.js +17 -0
  21. package/dist/effect/tool.d.ts +3 -0
  22. package/dist/effect/tool.js +8 -0
  23. package/dist/effect/workerd.d.ts +34 -0
  24. package/dist/effect/workerd.js +44 -0
  25. package/dist/index.d.ts +5 -0
  26. package/dist/index.js +75 -0
  27. package/dist/internal/effect.d.ts +12 -0
  28. package/dist/internal/effect.js +14 -0
  29. package/dist/internal/fetch.d.ts +7 -0
  30. package/dist/internal/fetch.js +8 -0
  31. package/dist/internal/host.d.ts +64 -0
  32. package/dist/internal/host.js +11 -0
  33. package/dist/internal/instances.d.ts +21 -0
  34. package/dist/internal/instances.js +10 -0
  35. package/dist/internal/promise.d.ts +8 -0
  36. package/dist/internal/promise.js +12 -0
  37. package/dist/internal/workerd.d.ts +12 -0
  38. package/dist/internal/workerd.js +8 -0
  39. package/dist/logging.d.ts +14 -0
  40. package/dist/logging.js +6 -0
  41. package/dist/opencode.d.ts +31 -0
  42. package/dist/opencode.js +13 -0
  43. package/dist/tool.d.ts +3 -0
  44. package/dist/tool.js +8 -0
  45. package/dist/workerd.d.ts +51 -0
  46. package/dist/workerd.js +41 -0
  47. package/package.json +59 -4
@@ -0,0 +1,12 @@
1
+ export * as WorkerdProfile from "./workerd";
2
+ import type { Config } from "@radheim/schema/config";
3
+ import { ServerWorkerd } from "@radheim/server/workerd";
4
+ import type { EmbeddedHost } from "./host";
5
+ export type { ImageLimits, ImageResizer, ImageResizerInput, ImageResizerOutput } from "@radheim/server/workerd";
6
+ export type { Hibernation } from "@radheim/server/workerd-machine-link";
7
+ export type Configuration = Omit<typeof Config.Info.Encoded, "plugins">;
8
+ export interface Options extends Omit<ServerWorkerd.Options, "config"> {
9
+ readonly config?: Configuration;
10
+ }
11
+ /** The host profile serving `ServerWorkerd`'s routes and handler, so the SDK and the server boot workerd one way. */
12
+ export declare function make(options: Options): EmbeddedHost.Profile<ServerWorkerd.Handler>;
@@ -0,0 +1,8 @@
1
+ import {
2
+ make2,
3
+ exports_workerd
4
+ } from "../chunks/contracts-q7txhdnb.js";
5
+ export {
6
+ exports_workerd as WorkerdProfile,
7
+ make2 as make
8
+ };
@@ -0,0 +1,14 @@
1
+ import { Layer } from "effect";
2
+ export type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "fatal";
3
+ export type LogEntry = {
4
+ readonly level: LogLevel;
5
+ readonly message: string;
6
+ readonly attributes?: Readonly<Record<string, unknown>>;
7
+ readonly cause?: unknown;
8
+ };
9
+ export type LogWriter = (entry: LogEntry) => void;
10
+ export type LogOptions = {
11
+ readonly level?: LogLevel;
12
+ readonly emit: LogWriter;
13
+ };
14
+ export declare function layer(log?: LogOptions): Layer.Layer<never, never, never>;
@@ -0,0 +1,6 @@
1
+ import {
2
+ layer3
3
+ } from "./chunks/contracts-d8k8mt5a.js";
4
+ export {
5
+ layer3 as layer
6
+ };
@@ -0,0 +1,31 @@
1
+ export * as Radhe from "./opencode";
2
+ import type { RadheClient } from "@radheim/client";
3
+ import type { Plugin } from "@radheim/plugin";
4
+ import type { Session } from "@radheim/schema/session";
5
+ import type { EmbeddedHost } from "./internal/host";
6
+ export type { LogEntry, LogLevel, LogOptions, LogWriter } from "./logging";
7
+ export interface InstanceConfiguration {
8
+ readonly plugins: ReadonlyArray<Plugin.Plugin>;
9
+ }
10
+ export interface InstanceOptions {
11
+ /** Select a sharing key within the Session's current Location. Must not initialize plugins. */
12
+ readonly key: (session: typeof Session.Info.Encoded) => string;
13
+ /** Reconstruct configuration on a cache miss, including after a host restart. */
14
+ readonly configure: (key: string) => InstanceConfiguration | Promise<InstanceConfiguration>;
15
+ }
16
+ export interface CreateOptions extends Omit<EmbeddedHost.CreateOptions, "plugins" | "workspaceProviders" | "instances"> {
17
+ readonly plugins?: ReadonlyArray<Plugin.Plugin>;
18
+ readonly instances?: InstanceOptions;
19
+ }
20
+ export type Interface = Omit<RadheClient, "plugin" | "session" | "event"> & {
21
+ /** @deprecated Use `sessions`. Removed in the next minor. */
22
+ readonly session: RadheClient["session"];
23
+ /** @deprecated Use `events`. Removed in the next minor. */
24
+ readonly event: RadheClient["event"];
25
+ readonly sessions: RadheClient["session"];
26
+ readonly events: RadheClient["event"];
27
+ readonly plugin: ((plugin: Plugin.Plugin) => Promise<void>) & RadheClient["plugin"];
28
+ readonly close: () => Promise<void>;
29
+ readonly [Symbol.asyncDispose]: () => Promise<void>;
30
+ };
31
+ export declare function create(options?: CreateOptions): Promise<Interface>;
@@ -0,0 +1,13 @@
1
+ import {
2
+ create3,
3
+ exports_opencode2
4
+ } from "./chunks/contracts-9921d0eq.js";
5
+ import"./chunks/contracts-rnpbh5as.js";
6
+ import"./chunks/contracts-21rejh3w.js";
7
+ import"./chunks/contracts-fc2gzwgc.js";
8
+ import"./chunks/contracts-d8k8mt5a.js";
9
+ import"./chunks/contracts-f8tdk121.js";
10
+ export {
11
+ exports_opencode2 as Radhe,
12
+ create3 as create
13
+ };
package/dist/tool.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { RegistrationError } from "@radheim/core/tool";
2
+ export { Error } from "@radheim/schema/tool";
3
+ export type { ToolContext as Context, Info } from "@radheim/plugin/promise/tool";
package/dist/tool.js ADDED
@@ -0,0 +1,8 @@
1
+ import {
2
+ RegistrationError3,
3
+ Error3
4
+ } from "./chunks/contracts-9ybt1tz4.js";
5
+ export {
6
+ Error3 as Error,
7
+ RegistrationError3 as RegistrationError
8
+ };
@@ -0,0 +1,51 @@
1
+ export * as RadheWorkerd from "./workerd";
2
+ import { WorkerdProfile } from "./internal/workerd";
3
+ import type { LogOptions } from "./logging";
4
+ import { Radhe as Sdk } from "./opencode";
5
+ export type { Configuration, ImageLimits, ImageResizer, ImageResizerInput, ImageResizerOutput, } from "./internal/workerd";
6
+ export interface CreateOptions extends WorkerdProfile.Options {
7
+ readonly log?: LogOptions;
8
+ readonly plugins?: Sdk.CreateOptions["plugins"];
9
+ readonly instances?: Sdk.CreateOptions["instances"];
10
+ }
11
+ /**
12
+ * The Durable Object's WebSocket Hibernation methods, for an object created with `state`: forward its
13
+ * `webSocketMessage`, `webSocketClose` and `webSocketError` to these, in order and without awaiting anything first.
14
+ *
15
+ * With `state`, create at most one live instance per `ctx`, for example once inside `ctx.blockConcurrencyWhile` in the
16
+ * Durable Object's constructor: a second leaves the machine links the first holds alone.
17
+ */
18
+ export type Hibernation = WorkerdProfile.Hibernation;
19
+ export type Interface = Sdk.Interface & Hibernation & {
20
+ /**
21
+ * Serves a request from outside the Durable Object, as `ServerWorkerd.create`'s handler does: `/api/*` and the
22
+ * `/api/event` stream behind `password` and the cross-site and CORS checks, and machine-link WebSocket upgrades.
23
+ * Return it from the Durable Object's `fetch()` method.
24
+ */
25
+ readonly fetch: (request: Request) => Promise<Response>;
26
+ /** Suspends any workspaces past their idle threshold; call from the Durable Object's `alarm()` method. */
27
+ readonly alarm: () => Promise<void>;
28
+ };
29
+ /**
30
+ * Boots the embedded opencode SDK on the workerd runtime profile: the full
31
+ * application graph inside a Cloudflare Durable Object, with the database on
32
+ * the injected `DurableObjectStorage` SQLite and every intentionally-local
33
+ * service replaced or disabled (see `ServerWorkerd.replacements`).
34
+ *
35
+ * Suspended Sessions resume on boot (as on every runtime) because a Durable
36
+ * Object can be evicted mid-turn with no teardown; the write-ahead execution
37
+ * claim marks the turn and the boot-time sweep replays it.
38
+ *
39
+ * Forward the Durable Object's `fetch()` to `opencode.fetch(request)` to serve
40
+ * the HTTP API and machine links, and its `alarm()` to `opencode.alarm()` so
41
+ * idle remote workspaces suspend while the Durable Object hibernates at zero
42
+ * idle cost. Pass `state: ctx` and forward `webSocketMessage`,
43
+ * `webSocketClose` and `webSocketError` too, so idle machine links let it
44
+ * hibernate and carry on unchanged when it wakes.
45
+ *
46
+ * Returns the same typed `Sdk.Interface` as `Sdk.create` plus
47
+ * `fetch()` and `alarm()` — typed session operations plus the live
48
+ * `events.subscribe()` stream — served over an in-process fetch transport, so
49
+ * no request leaves the isolate.
50
+ */
51
+ export declare const create: (options: CreateOptions) => Promise<Interface>;
@@ -0,0 +1,41 @@
1
+ import"./chunks/contracts-d8k8mt5a.js";
2
+ import"./chunks/contracts-f8tdk121.js";
3
+ import"./chunks/contracts-fc2gzwgc.js";
4
+ import"./chunks/contracts-21rejh3w.js";
5
+ import {
6
+ createWithHost2
7
+ } from "./chunks/contracts-rnpbh5as.js";
8
+ import {
9
+ make2
10
+ } from "./chunks/contracts-q7txhdnb.js";
11
+ import {
12
+ __export
13
+ } from "./chunks/contracts-9rqn6x4v.js";
14
+
15
+ // src/workerd.ts
16
+ var exports_workerd = {};
17
+ __export(exports_workerd, {
18
+ RadheWorkerd: () => exports_workerd,
19
+ create: () => create
20
+ });
21
+ var create = async (options) => {
22
+ const created = await createWithHost2({
23
+ log: options.log,
24
+ plugins: options.plugins,
25
+ instances: options.instances
26
+ }, { profile: make2(options) });
27
+ return {
28
+ ...created.sdk,
29
+ webSocketMessage: created.host.served.webSocketMessage,
30
+ webSocketClose: created.host.served.webSocketClose,
31
+ webSocketError: created.host.served.webSocketError,
32
+ fetch: created.host.handler,
33
+ alarm: async () => {
34
+ await created.host.runtime.runPromise(created.host.workspace.suspendIdle());
35
+ }
36
+ };
37
+ };
38
+ export {
39
+ exports_workerd as RadheWorkerd,
40
+ create
41
+ };
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/package.json",
3
+ "version": "2.4.3",
2
4
  "name": "@radheim/sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/anomalyco/opencode.git",
10
+ "directory": "packages/sdk"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ },
23
+ "./effect": {
24
+ "types": "./dist/effect/index.d.ts",
25
+ "import": "./dist/effect/index.js"
26
+ },
27
+ "./workerd": {
28
+ "types": "./dist/workerd.d.ts",
29
+ "import": "./dist/workerd.js"
30
+ },
31
+ "./workerd/effect": {
32
+ "types": "./dist/effect/workerd.d.ts",
33
+ "import": "./dist/effect/workerd.js"
34
+ }
35
+ },
36
+ "scripts": {
37
+ "build": "bun run script/build.ts",
38
+ "pack": "bun run script/pack.ts",
39
+ "test": "bun run ../core/script/test.ts --timeout=5000",
40
+ "typecheck": "bun check --no-script -b",
41
+ "typecheck:tsc": "tsc -b",
42
+ "verify:package": "bun run script/verify-package.ts"
43
+ },
44
+ "dependencies": {
45
+ "@radheim/client": "2.4.3",
46
+ "@radheim/core": "2.4.3",
47
+ "@radheim/plugin": "2.4.3",
48
+ "@radheim/schema": "2.4.3",
49
+ "@radheim/server": "2.4.3",
50
+ "@radheim/util": "2.4.3",
51
+ "effect": "4.1.0"
52
+ },
53
+ "devDependencies": {
54
+ "@radheim/ai": "2.4.3",
55
+ "@radheim/httpapi-codegen": "2.4.3",
56
+ "@radheim/protocol": "2.4.3",
57
+ "@tsconfig/bun": "1.0.9",
58
+ "@types/bun": "1.4.3",
59
+ "@typescript/native": "npm:typescript@7.1.0-beta"
60
+ }
61
+ }