@nylorun/runtime 0.1.2-beta → 0.2.1-beta

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/dist/config.d.ts CHANGED
@@ -1,10 +1,13 @@
1
- import type { RuntimeAgent } from "./contracts.js";
2
- import type { RuntimePersistence } from "./adapters/journal.js";
1
+ import type { RuntimeModelAdapter } from "./contracts.js";
2
+ import type { RuntimeDurability } from "./adapters/journal.js";
3
3
  import type { RuntimeMedia } from "./adapters/media.js";
4
4
  export interface RuntimeConfig {
5
- readonly agents: readonly RuntimeAgent[];
6
- readonly persistence?: RuntimePersistence;
5
+ readonly onModelCall?: RuntimeModelAdapter;
6
+ readonly observer?: {
7
+ (event: {
8
+ readonly type: string;
9
+ }): void | Promise<void>;
10
+ };
11
+ readonly durability?: RuntimeDurability;
7
12
  readonly media?: RuntimeMedia;
8
- readonly origins?: readonly string[];
9
13
  }
10
- export declare function defineRuntime(config: RuntimeConfig): RuntimeConfig;
package/dist/config.js CHANGED
@@ -1,15 +1 @@
1
- export function defineRuntime(config) {
2
- if (!config || !Array.isArray(config.agents))
3
- throw new Error("Runtime config must declare an agents array.");
4
- for (const agent of config.agents) {
5
- if (!agent ||
6
- typeof agent.run !== "function" ||
7
- typeof agent.id !== "string" ||
8
- !agent.manifest)
9
- throw new Error("Every registered agent must satisfy RuntimeAgent.");
10
- }
11
- return Object.freeze({
12
- ...config,
13
- agents: Object.freeze([...config.agents]),
14
- });
15
- }
1
+ export {};
@@ -57,9 +57,19 @@ export interface RuntimeSession {
57
57
  readonly completed: Promise<RuntimeCompletion>;
58
58
  };
59
59
  stream(): AsyncIterable<RuntimeEvent>;
60
- observe(listener: (event: RuntimeEvent) => void | Promise<void>): () => void;
61
60
  stop(reason?: string): Promise<void>;
62
61
  }
62
+ export interface RuntimeRunOptions {
63
+ readonly id?: string;
64
+ readonly userId?: string;
65
+ readonly context?: JsonObject;
66
+ readonly onModelCall: RuntimeModelAdapter;
67
+ readonly observer?: {
68
+ (event: {
69
+ readonly type: string;
70
+ }): void | Promise<void>;
71
+ };
72
+ }
63
73
  export interface RuntimeAgent {
64
74
  readonly id: string;
65
75
  readonly name: string;
@@ -67,11 +77,7 @@ export interface RuntimeAgent {
67
77
  readonly id: string;
68
78
  readonly name: string;
69
79
  };
70
- run(options?: {
71
- readonly id?: string;
72
- readonly userId?: string;
73
- readonly context?: JsonObject;
74
- }): RuntimeSession;
80
+ run(options: RuntimeRunOptions): RuntimeSession;
75
81
  close?(): Promise<void>;
76
82
  }
77
83
  export type PromptContentPart = Exclude<UserContentPart, {
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export { defineRuntime } from "./config.js";
2
1
  export type { RuntimeConfig } from "./config.js";
3
2
  export type * from "./contracts.js";
4
- export { createRuntime } from "./server/host.js";
5
- export { piModel } from "./model/pi-model.js";
6
- export type { PiModelOptions } from "./model/pi-model.js";
3
+ export { Runtime, serveAgents, type AgentRouterOptions, type RuntimeActor, type ServeAgentsOptions, } from "./server/host.js";
7
4
  export { localJsonl, memoryHistory, JsonlJournal } from "./adapters/journal.js";
8
- export type { RuntimePersistence, CanonicalEvent, SessionSummary, } from "./adapters/journal.js";
5
+ export type { RuntimeDurability, CanonicalEvent, SessionSummary, } from "./adapters/journal.js";
6
+ export { jsonlObserver } from "./adapters/observe.js";
9
7
  export { localMedia, MediaStore, IMAGE_MEDIA_TYPES, MAX_IMAGE_BYTES, decodeImageBase64, validateImageBytes, } from "./adapters/media.js";
10
8
  export type { RuntimeMedia, MediaAsset, MediaReference, } from "./adapters/media.js";
9
+ export { piModel } from "./model/pi-model.js";
10
+ export type { PiModelOptions } from "./model/pi-model.js";
11
11
  export { projectAsset } from "./assets.js";
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export { defineRuntime } from "./config.js";
2
- export { createRuntime } from "./server/host.js";
3
- export { piModel } from "./model/pi-model.js";
1
+ export { Runtime, serveAgents, } from "./server/host.js";
4
2
  export { localJsonl, memoryHistory, JsonlJournal } from "./adapters/journal.js";
3
+ export { jsonlObserver } from "./adapters/observe.js";
5
4
  export { localMedia, MediaStore, IMAGE_MEDIA_TYPES, MAX_IMAGE_BYTES, decodeImageBase64, validateImageBytes, } from "./adapters/media.js";
5
+ export { piModel } from "./model/pi-model.js";
6
6
  export { projectAsset } from "./assets.js";
@@ -1,6 +1,8 @@
1
- import type { RuntimeEvent } from "../contracts.js";
2
1
  /** Optional diagnostic enrichment; engines need not emit model diagnostics. */
3
- export declare function observedPayload(event: RuntimeEvent): Record<string, unknown>;
2
+ export declare function observedPayload(event: {
3
+ readonly type: string;
4
+ readonly attributes?: unknown;
5
+ }): Record<string, unknown>;
4
6
  export declare function modelRequestDigests(value: unknown): {
5
7
  prompt: string;
6
8
  tools: string;
@@ -1,14 +1,27 @@
1
- import { Hono } from "hono";
1
+ import { Hono, type Context } from "hono";
2
+ import type { JsonValue, RuntimeAgent } from "../contracts.js";
2
3
  import type { RuntimeConfig } from "../config.js";
3
- export declare function createRuntime(options: RuntimeConfig): Promise<Readonly<{
4
- app: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
5
- hasSession: (agentId: string, sessionId: string) => boolean;
4
+ export type RuntimeActor = Readonly<{
5
+ id: string;
6
+ context?: Record<string, JsonValue>;
7
+ }>;
8
+ export type AgentRouterOptions = Readonly<{
9
+ /** Public URL prefix of this router, matching the Hono mount path. */
10
+ basePath?: string;
11
+ getActor?: (context: Context) => RuntimeActor | undefined | Promise<RuntimeActor | undefined>;
12
+ getRequestMetadata?: (context: Context) => Record<string, JsonValue> | undefined | Promise<Record<string, JsonValue> | undefined>;
13
+ }>;
14
+ export type ServeAgentsOptions = AgentRouterOptions & {
15
+ readonly agents: readonly RuntimeAgent[];
16
+ readonly runtime: Runtime;
17
+ };
18
+ declare const kServe: unique symbol;
19
+ export declare class Runtime {
20
+ #private;
21
+ constructor(options?: RuntimeConfig);
6
22
  close: () => Promise<void>;
7
- }>>;
8
- /** Host headers a loopback bind answers to, on the port actually in use. */
9
- export declare function loopbackHosts(port: number): readonly string[];
10
- /**
11
- * Decide whether a request's Host header is served. Entries are exact
12
- * `host:port` values or bare host names that accept any port; `*` accepts all.
13
- */
14
- export declare function allowedHost(header: string | undefined, allowed: readonly string[]): boolean;
23
+ [kServe](options: Omit<ServeAgentsOptions, "runtime">): Hono;
24
+ }
25
+ /** Create the Hono protocol mount for a runtime. Applications may close it during graceful shutdown. */
26
+ export declare function serveAgents(options: ServeAgentsOptions): any;
27
+ export {};