operon-agents 0.1.0-alpha.28 → 0.1.0-alpha.29

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/harness.d.ts CHANGED
@@ -7,9 +7,9 @@
7
7
  * control plane (goals, plan mode, compaction, skills, plugins, …) delegated to
8
8
  * the core `Session`.
9
9
  *
10
- * It is a pure composition of core primitives — no new engine behavior. For the
11
- * low-level "assemble it yourself / stateless server" path, import from
12
- * `operon-agents/core` instead.
10
+ * It is a pure composition of core primitives — no new engine behavior. The low-level
11
+ * primitives for the "assemble it yourself / stateless server" path are exported from
12
+ * `operon-agents` too.
13
13
  */
14
14
  import { type EventPublicationMode, type TelemetryService, type AgentEventListener, type AgentInput, SessionProjection, type SessionSnapshot, type SnapshotOptions, type DirectoryEntry, type ProjectionObservation, type ProjectionListener, type ApprovalRequest, type ApprovalResponse, type Capability, type InterruptAnswer, type ChatModel, ListenerSink, type PermissionManagerOptions, type PermissionMode, type PendingRunInterrupt, type QuestionRequest, type QuestionResult, type Responder, type RunHandle, type RunResult, type SessionHandle, type SessionSummary, type ListSessionsFilter, type OpenSessionOptions, type DeleteSessionOptions, type ThinkingLevel, type Tool, type SteerMessage, type SteerOptions, type SteerOrigin, type SteerReceipt, Agent, Runner, Session, McpOAuthService, SkillRegistry, type HookDef, type McpServerConfig, type McpTransportKind, type McpCredentialProvider, type PluginManager, type ApprovalRequestOptions, type Environment, type EnvironmentFactory, type SessionRepository, type ResolvedAgentProfile, type SubagentProvider } from "operon-agents-core";
15
15
  import type { SkillsService, CompactionService, BackgroundManager, McpServersHandle, GoalStore, PlanMode, Logger, ModelRuntime, TracingProcessor } from "operon-agents-core";
package/dist/harness.js CHANGED
@@ -7,9 +7,9 @@
7
7
  * control plane (goals, plan mode, compaction, skills, plugins, …) delegated to
8
8
  * the core `Session`.
9
9
  *
10
- * It is a pure composition of core primitives — no new engine behavior. For the
11
- * low-level "assemble it yourself / stateless server" path, import from
12
- * `operon-agents/core` instead.
10
+ * It is a pure composition of core primitives — no new engine behavior. The low-level
11
+ * primitives for the "assemble it yourself / stateless server" path are exported from
12
+ * `operon-agents` too.
13
13
  */
14
14
  import { readSessionTails, SessionProjection, ListenerSink, recoverOrphanedTurns, Agent, buildAgentFromProfile, INTERRUPTION_STATE_KEY, flattenPendingInterrupts, parseInterruptionState, Runner, Session, emptyUsage, isGuardrailTripwireError, askUserQuestionTool, backgroundCapability, compactionCapability, filesystemTools, goalCapability, LocalEnvironment, McpOAuthService, MemorySessionRepository, SessionRepositoryNotFoundError, planCapability, skillsCapability, SkillRegistry, mcpServersCapability, pluginsCapability, userHooksCapability, taskCapability, workflowCapability, DEFAULT_AGENT_PROFILES, DEFAULT_AGENT_PROFILE_NAME, DEFAULT_SUBAGENT_NAMES, profileSubagentProvider, DEFAULT_ADDRESS, envLogger, noopLogger, } from "operon-agents-core";
15
15
  import { mkdirSync } from "node:fs";
package/dist/index.d.ts CHANGED
@@ -9,7 +9,8 @@
9
9
  * machinery, capability assembly, …) is NOT here — it lives on `operon-agents/internal`
10
10
  * (≡ `operon-agents-core/internal`) for advanced embedders.
11
11
  *
12
- * For the low-level "assemble it yourself" path, import from `operon-agents/core`.
12
+ * This is the only entry point for applications. `operon-agents-core` is for the framework's own
13
+ * packages, and everything its root exports is public here.
13
14
  */
14
15
  export * from "./harness.ts";
15
16
  export * from "./extensions/index.ts";
package/dist/index.js CHANGED
@@ -9,7 +9,8 @@
9
9
  * machinery, capability assembly, …) is NOT here — it lives on `operon-agents/internal`
10
10
  * (≡ `operon-agents-core/internal`) for advanced embedders.
11
11
  *
12
- * For the low-level "assemble it yourself" path, import from `operon-agents/core`.
12
+ * This is the only entry point for applications. `operon-agents-core` is for the framework's own
13
+ * packages, and everything its root exports is public here.
13
14
  */
14
15
  export * from "./harness.js";
15
16
  // Extensions are a harness concept: they need the session/provider reach only this layer has.
@@ -22,8 +23,7 @@ export * from "./providers.js";
22
23
  export * from "./local.js";
23
24
  // Per-directory MCP sharing for hosts that open many sessions in one folder (a desktop app).
24
25
  export * from "./workspace-mcp.js";
25
- // The curated core engine, re-exported for convenience; `operon-agents/core` is the dedicated
26
- // primitives entrypoint.
26
+ // The curated core engine, including the low-level primitives for assembling an agent by hand.
27
27
  export * from "operon-agents-core";
28
28
  export * as llm from "operon-agents-core/llm";
29
29
  export * as mcp from "operon-agents-core/mcp";
@@ -35,7 +35,8 @@
35
35
  * ```
36
36
  */
37
37
  import { z } from "zod";
38
- import { type Api, type ModelRuntime } from "operon-agents-core";
38
+ import { DecisionModel, type Api, type ChatModel, type Model, type ModelRuntime } from "operon-agents-core";
39
+ import type { Provider } from "@earendil-works/pi-ai";
39
40
  /** The wire dialects a configured endpoint can speak. Almost everything speaks the first. */
40
41
  export declare const PROVIDER_APIS: readonly ["openai-completions", "openai-responses", "anthropic-messages"];
41
42
  export type ProviderApi = (typeof PROVIDER_APIS)[number];
@@ -119,7 +120,34 @@ export declare function parseModelsResponse(body: unknown): readonly string[];
119
120
  * Turn one config entry into a provider the engine can stream through. Its model list starts at
120
121
  * whatever the config declared and is replaced by the endpoint's on the first refresh.
121
122
  */
122
- export declare function providerFromConfig(providerId: string, entry: ProviderEntry): import("@earendil-works/pi-ai").Provider<Api>;
123
+ export declare function providerFromConfig(providerId: string, entry: ProviderEntry): Provider<Api>;
124
+ /**
125
+ * One model, named by a host that already knows which it wants.
126
+ *
127
+ * The picked fields are pi's own. `baseUrl` is used exactly as given; without it, pi's catalog says
128
+ * where each model lives. The others describe a model the catalog lacks: a catalogued one keeps its own.
129
+ */
130
+ export interface ChatModelConfig extends Readonly<Partial<Pick<Model<Api>, "baseUrl" | "contextWindow" | "maxTokens" | "input" | "reasoning">>> {
131
+ /** pi's provider id to use its catalog; any other name needs `api` and `baseUrl`. */
132
+ readonly provider: string;
133
+ readonly model: string;
134
+ readonly apiKey?: string;
135
+ /** Marks a custom endpoint, built with `createProvider`. Only the dialects it can load. */
136
+ readonly api?: ProviderApi;
137
+ }
138
+ /** Build the `ChatModel` a host picked: from pi's catalog, or from `api` and `baseUrl` for a custom endpoint. */
139
+ export declare function resolveChatModel(config: ChatModelConfig): ChatModel;
140
+ export interface DecisionModelConfig {
141
+ /** pi's provider id: decision models only exist in its catalog. */
142
+ readonly provider: string;
143
+ readonly model: string;
144
+ readonly apiKey: string;
145
+ }
146
+ /**
147
+ * The decision model a config names, or undefined when it is an LLM. An id catalogued as both
148
+ * (OpenAI's `gpt-6-luna`) counts as an LLM, and an id the catalog doesn't know can only be one.
149
+ */
150
+ export declare function resolveDecisionModel(config: DecisionModelConfig): Promise<DecisionModel | undefined>;
123
151
  export interface ModelRuntimeFromConfigOptions {
124
152
  readonly homeDir: string;
125
153
  /**
package/dist/providers.js CHANGED
@@ -38,7 +38,7 @@ import { readFile } from "node:fs/promises";
38
38
  import { join } from "node:path";
39
39
  import { parse as parseToml } from "smol-toml";
40
40
  import { z } from "zod";
41
- import { createModelRuntime, createProvider, lazyApi, } from "operon-agents-core";
41
+ import { DecisionModel, createModelRuntime, createProvider, defineModel, lazyApi, } from "operon-agents-core";
42
42
  /** The wire dialects a configured endpoint can speak. Almost everything speaks the first. */
43
43
  export const PROVIDER_APIS = ["openai-completions", "openai-responses", "anthropic-messages"];
44
44
  const ModelOverrideSchema = z.object({
@@ -226,6 +226,74 @@ function dialectStreams(api) {
226
226
  return lazyApi(() => import("@earendil-works/pi-ai/api/openai-completions"));
227
227
  }
228
228
  }
229
+ /** An id newer than a catalog provider's list runs on the API of that provider's default endpoint. */
230
+ function modelNewerThanCatalog(provider, config) {
231
+ const models = provider.getModels();
232
+ const template = models.find((model) => model.baseUrl === provider.baseUrl) ?? models[0];
233
+ if (template === undefined)
234
+ throw new Error(`Provider "${provider.id}" lists no models to run "${config.model}" like.`);
235
+ return {
236
+ id: config.model,
237
+ name: config.model,
238
+ api: template.api,
239
+ provider: provider.id,
240
+ baseUrl: template.baseUrl,
241
+ reasoning: config.reasoning ?? false,
242
+ input: [...(config.input ?? ["text"])],
243
+ cost: NO_COST,
244
+ contextWindow: config.contextWindow ?? 128_000,
245
+ maxTokens: config.maxTokens ?? 8_192,
246
+ };
247
+ }
248
+ function catalogChatModel(config) {
249
+ const runtime = createModelRuntime();
250
+ const provider = runtime.models.getProvider(config.provider);
251
+ if (provider === undefined) {
252
+ throw new Error(`Provider "${config.provider}" is not in pi's catalog. Set \`api\` and \`baseUrl\` for a custom endpoint.`);
253
+ }
254
+ const descriptor = runtime.models.getModel(config.provider, config.model) ?? modelNewerThanCatalog(provider, config);
255
+ return defineModel({
256
+ runtime,
257
+ descriptor: config.baseUrl === undefined ? descriptor : { ...descriptor, baseUrl: config.baseUrl },
258
+ ...(config.apiKey !== undefined ? { apiKey: config.apiKey } : {}),
259
+ });
260
+ }
261
+ function customChatModel(config, api) {
262
+ if (config.baseUrl === undefined)
263
+ throw new Error(`Custom provider "${config.provider}" needs a \`baseUrl\`.`);
264
+ const entry = ProviderEntrySchema.parse({
265
+ base_url: config.baseUrl,
266
+ api,
267
+ api_key: config.apiKey,
268
+ fetch_models: false,
269
+ context_window: config.contextWindow,
270
+ max_output_tokens: config.maxTokens,
271
+ reasoning: config.reasoning,
272
+ vision: config.input?.includes("image"),
273
+ models: { [config.model]: {} },
274
+ });
275
+ const runtime = createModelRuntime({ builtins: false });
276
+ runtime.models.setProvider(providerFromConfig(config.provider, entry));
277
+ return defineModel({ runtime, descriptor: modelFrom(config.provider, entry, config.model) });
278
+ }
279
+ /** Build the `ChatModel` a host picked: from pi's catalog, or from `api` and `baseUrl` for a custom endpoint. */
280
+ export function resolveChatModel(config) {
281
+ return config.api === undefined ? catalogChatModel(config) : customChatModel(config, config.api);
282
+ }
283
+ /**
284
+ * The decision model a config names, or undefined when it is an LLM. An id catalogued as both
285
+ * (OpenAI's `gpt-6-luna`) counts as an LLM, and an id the catalog doesn't know can only be one.
286
+ */
287
+ export async function resolveDecisionModel(config) {
288
+ const runtime = createModelRuntime();
289
+ if (runtime.models.getModel(config.provider, config.model) !== undefined)
290
+ return undefined;
291
+ const descriptor = runtime.models.getModelOfType("classifier", config.provider, config.model);
292
+ if (descriptor === undefined)
293
+ return undefined;
294
+ await runtime.credentials.modify(config.provider, async () => ({ type: "api_key", key: config.apiKey }));
295
+ return new DecisionModel({ runtime, descriptor });
296
+ }
229
297
  /**
230
298
  * One model runtime carrying the engine's built-in providers plus everything in
231
299
  * `<homeDir>/providers.toml`, with each configured endpoint asked what it serves.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "operon-agents",
3
- "version": "0.1.0-alpha.28",
3
+ "version": "0.1.0-alpha.29",
4
4
  "description": "Public SDK entrypoint for building agents.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -30,10 +30,6 @@
30
30
  "types": "./dist/app-server/index.d.ts",
31
31
  "import": "./dist/app-server/index.js"
32
32
  },
33
- "./core": {
34
- "types": "./dist/core.d.ts",
35
- "import": "./dist/core.js"
36
- },
37
33
  "./internal": {
38
34
  "types": "./dist/internal.d.ts",
39
35
  "import": "./dist/internal.js"
@@ -74,7 +70,7 @@
74
70
  "zod": "^4.4.3",
75
71
  "smol-toml": "^1.6.1",
76
72
  "@earendil-works/pi-ai": "1.5.0",
77
- "operon-agents-core": "0.1.0-alpha.28"
73
+ "operon-agents-core": "0.1.0-alpha.29"
78
74
  },
79
75
  "devDependencies": {
80
76
  "@earendil-works/pi-ai": "1.5.0"
package/dist/core.d.ts DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * Mode 1 — low-level primitives (the engine, assemble-it-yourself).
3
- *
4
- * `import { Runner, defineAgent, defineModel } from 'operon-agents/core'`
5
- *
6
- * Everything the core engine exposes: Runner / Session / Agent / capabilities /
7
- * environments / tools. Pass no environment and omit file tools to run a stateless,
8
- * no-filesystem agent (a `NullEnvironment` refuses any stray I/O). For the
9
- * batteries-included facade, import from `operon-agents` instead.
10
- */
11
- export * from "operon-agents-core";
12
- //# sourceMappingURL=core.d.ts.map
package/dist/core.js DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * Mode 1 — low-level primitives (the engine, assemble-it-yourself).
3
- *
4
- * `import { Runner, defineAgent, defineModel } from 'operon-agents/core'`
5
- *
6
- * Everything the core engine exposes: Runner / Session / Agent / capabilities /
7
- * environments / tools. Pass no environment and omit file tools to run a stateless,
8
- * no-filesystem agent (a `NullEnvironment` refuses any stray I/O). For the
9
- * batteries-included facade, import from `operon-agents` instead.
10
- */
11
- export * from "operon-agents-core";
12
- //# sourceMappingURL=core.js.map