operon-agents 0.1.0-alpha.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.
Files changed (71) hide show
  1. package/LICENSE +55 -0
  2. package/README.md +18 -0
  3. package/dist/app-server/client.d.ts +80 -0
  4. package/dist/app-server/client.js +187 -0
  5. package/dist/app-server/codec.d.ts +52 -0
  6. package/dist/app-server/codec.js +252 -0
  7. package/dist/app-server/index.d.ts +22 -0
  8. package/dist/app-server/index.js +22 -0
  9. package/dist/app-server/main.d.ts +3 -0
  10. package/dist/app-server/main.js +85 -0
  11. package/dist/app-server/protocol.d.ts +217 -0
  12. package/dist/app-server/protocol.js +100 -0
  13. package/dist/app-server/server.d.ts +51 -0
  14. package/dist/app-server/server.js +274 -0
  15. package/dist/core.d.ts +12 -0
  16. package/dist/core.js +12 -0
  17. package/dist/cron/clock.d.ts +11 -0
  18. package/dist/cron/clock.js +19 -0
  19. package/dist/cron/cron-expr.d.ts +15 -0
  20. package/dist/cron/cron-expr.js +267 -0
  21. package/dist/cron/extension.d.ts +25 -0
  22. package/dist/cron/extension.js +141 -0
  23. package/dist/cron/index.d.ts +20 -0
  24. package/dist/cron/index.js +11 -0
  25. package/dist/cron/jitter.d.ts +18 -0
  26. package/dist/cron/jitter.js +46 -0
  27. package/dist/cron/manager.d.ts +55 -0
  28. package/dist/cron/manager.js +123 -0
  29. package/dist/cron/persist.d.ts +10 -0
  30. package/dist/cron/persist.js +22 -0
  31. package/dist/cron/scheduler.d.ts +25 -0
  32. package/dist/cron/scheduler.js +192 -0
  33. package/dist/cron/session-store.d.ts +14 -0
  34. package/dist/cron/session-store.js +50 -0
  35. package/dist/cron/time-format.d.ts +2 -0
  36. package/dist/cron/time-format.js +12 -0
  37. package/dist/cron/tools.d.ts +7 -0
  38. package/dist/cron/tools.js +161 -0
  39. package/dist/cron/types.d.ts +9 -0
  40. package/dist/cron/types.js +2 -0
  41. package/dist/extensions/index.d.ts +23 -0
  42. package/dist/extensions/index.js +41 -0
  43. package/dist/extensions/loader.d.ts +121 -0
  44. package/dist/extensions/loader.js +285 -0
  45. package/dist/extensions/manager.d.ts +103 -0
  46. package/dist/extensions/manager.js +190 -0
  47. package/dist/extensions/runtime.d.ts +188 -0
  48. package/dist/extensions/runtime.js +1127 -0
  49. package/dist/extensions/services.d.ts +85 -0
  50. package/dist/extensions/services.js +265 -0
  51. package/dist/extensions/types.d.ts +594 -0
  52. package/dist/extensions/types.js +2 -0
  53. package/dist/harness.d.ts +746 -0
  54. package/dist/harness.js +1483 -0
  55. package/dist/index.d.ts +24 -0
  56. package/dist/index.js +29 -0
  57. package/dist/internal.d.ts +9 -0
  58. package/dist/internal.js +9 -0
  59. package/dist/llm.d.ts +2 -0
  60. package/dist/llm.js +2 -0
  61. package/dist/local.d.ts +24 -0
  62. package/dist/local.js +58 -0
  63. package/dist/mcp.d.ts +2 -0
  64. package/dist/mcp.js +2 -0
  65. package/dist/protocol.d.ts +2 -0
  66. package/dist/protocol.js +2 -0
  67. package/dist/tools.d.ts +2 -0
  68. package/dist/tools.js +2 -0
  69. package/dist/tracing.d.ts +2 -0
  70. package/dist/tracing.js +2 -0
  71. package/package.json +78 -0
@@ -0,0 +1,24 @@
1
+ /**
2
+ * `operon-agents` — the batteries-included public API (Mode 2).
3
+ *
4
+ * import { createHarness } from "operon-agents"
5
+ *
6
+ * The headline is the Harness facade + deployment presets. The whole (curated) core engine
7
+ * is re-exported here for convenience — `operon-agents-core` defines its own public surface,
8
+ * so this dump is already clean: engine plumbing (the turn/step loop, store migration/blob
9
+ * machinery, capability assembly, …) is NOT here — it lives on `operon-agents/internal`
10
+ * (≡ `operon-agents-core/internal`) for advanced embedders.
11
+ *
12
+ * For the low-level "assemble it yourself" path, import from `operon-agents/core`.
13
+ */
14
+ export * from "./harness.ts";
15
+ export * from "./extensions/index.ts";
16
+ export * from "./cron/index.ts";
17
+ export * from "./local.ts";
18
+ export * from "operon-agents-core";
19
+ export * as llm from "operon-agents-core/llm";
20
+ export * as mcp from "operon-agents-core/mcp";
21
+ export * as protocol from "operon-agents-core/protocol";
22
+ export * as tools from "operon-agents-core/tools";
23
+ export * as tracing from "operon-agents-core/tracing";
24
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * `operon-agents` — the batteries-included public API (Mode 2).
3
+ *
4
+ * import { createHarness } from "operon-agents"
5
+ *
6
+ * The headline is the Harness facade + deployment presets. The whole (curated) core engine
7
+ * is re-exported here for convenience — `operon-agents-core` defines its own public surface,
8
+ * so this dump is already clean: engine plumbing (the turn/step loop, store migration/blob
9
+ * machinery, capability assembly, …) is NOT here — it lives on `operon-agents/internal`
10
+ * (≡ `operon-agents-core/internal`) for advanced embedders.
11
+ *
12
+ * For the low-level "assemble it yourself" path, import from `operon-agents/core`.
13
+ */
14
+ export * from "./harness.js";
15
+ // Extensions are a harness concept: they need the session/provider reach only this layer has.
16
+ // Core supplies the primitives they are built on (Capability / LoopHooks / ToolFilter / Injector).
17
+ export * from "./extensions/index.js";
18
+ export * from "./cron/index.js";
19
+ // Deployment composition roots: local vs server injection presets (Invariant 7 — no engine "mode").
20
+ export * from "./local.js";
21
+ // The curated core engine, re-exported for convenience; `operon-agents/core` is the dedicated
22
+ // primitives entrypoint.
23
+ export * from "operon-agents-core";
24
+ export * as llm from "operon-agents-core/llm";
25
+ export * as mcp from "operon-agents-core/mcp";
26
+ export * as protocol from "operon-agents-core/protocol";
27
+ export * as tools from "operon-agents-core/tools";
28
+ export * as tracing from "operon-agents-core/tracing";
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * `operon-agents/internal` — low-level engine plumbing (re-exports `operon-agents-core/internal`).
3
+ *
4
+ * NOT part of the stable public API. The turn/step loop, retry, tool scheduling,
5
+ * store blob/migration/index machinery, capability assembly, and file-op / shell-rule helpers.
6
+ * No stability guarantees — prefer the main `operon-agents` surface.
7
+ */
8
+ export * from "operon-agents-core/internal";
9
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * `operon-agents/internal` — low-level engine plumbing (re-exports `operon-agents-core/internal`).
3
+ *
4
+ * NOT part of the stable public API. The turn/step loop, retry, tool scheduling,
5
+ * store blob/migration/index machinery, capability assembly, and file-op / shell-rule helpers.
6
+ * No stability guarantees — prefer the main `operon-agents` surface.
7
+ */
8
+ export * from "operon-agents-core/internal";
9
+ //# sourceMappingURL=internal.js.map
package/dist/llm.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "operon-agents-core/llm";
2
+ //# sourceMappingURL=llm.d.ts.map
package/dist/llm.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "operon-agents-core/llm";
2
+ //# sourceMappingURL=llm.js.map
@@ -0,0 +1,24 @@
1
+ import { type HookDef, type McpServerConfig, type PluginManager } from "operon-agents-core";
2
+ import { type CreateSessionOptions, type Harness, type HarnessOptions, type HarnessSession } from "./harness.ts";
3
+ export interface LocalDeploymentOptions<TContext = unknown> extends HarnessOptions<TContext> {
4
+ /**
5
+ * App home root — sessions (`<homeDir>/sessions`), MCP creds, logs, and disk-discovered agent
6
+ * profiles all live under it. Defaults to `~/.agents`. (`homeDir` is a local-deployment concept;
7
+ * the harness itself only knows `repository`.)
8
+ */
9
+ readonly homeDir?: string;
10
+ /** Workspace MCP servers to expose. */
11
+ readonly mcpServers?: Record<string, McpServerConfig>;
12
+ /** Installed-plugin manager, if any. */
13
+ readonly pluginManager?: PluginManager;
14
+ /** Shell hooks from config (`config.hooks`), projected as HookDefs. */
15
+ readonly hooks?: readonly HookDef[];
16
+ /** Discover agent profiles from disk (`<homeDir>/agents` + `<cwd>/.agents/agents`). Default true. */
17
+ readonly loadDiskProfiles?: boolean;
18
+ }
19
+ /** Build `HarnessOptions` wired for a local, single-machine deployment. */
20
+ export declare function localHarnessOptions<TContext>(options: LocalDeploymentOptions<TContext>): Promise<HarnessOptions<TContext>>;
21
+ export declare function createLocalHarness<TContext = unknown>(options: LocalDeploymentOptions<TContext>): Promise<Harness<TContext>>;
22
+ /** Convenience: a local harness with one session opened and ready to `prompt()`. */
23
+ export declare function createLocalSession<TContext = unknown>(options: LocalDeploymentOptions<TContext>, session?: CreateSessionOptions<TContext>): Promise<HarnessSession<TContext>>;
24
+ //# sourceMappingURL=local.d.ts.map
package/dist/local.js ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The local composition root — every convention a single-machine, single-operator app runs on,
3
+ * bundled in one place: disk sessions under `<homeDir>/sessions`, the local machine, a rotating
4
+ * file log, file-backed MCP credentials, disk-discovered agent profiles, and the cron extension.
5
+ *
6
+ * There is deliberately no server counterpart. A hosted deployment injects its own repository,
7
+ * machine, logger and credential store, and those choices belong to the host — a preset that
8
+ * bundled them saved three lines while forcing one `McpOAuthService` (and therefore one
9
+ * credential store, which has no tenant dimension) to be shared across every session in the
10
+ * process. Servers call `createHarness` directly; see `examples/managed-agents`.
11
+ *
12
+ * There is still no "mode" inside the engine (Architecture Invariant 7): this file only picks
13
+ * backends, and returns a plain `Harness` nothing downstream can distinguish.
14
+ */
15
+ import { homedir } from "node:os";
16
+ import { cronExtension } from "./cron/index.js";
17
+ import { join } from "node:path";
18
+ import { DiskSessionRepository, McpOAuthService, RotatingFileSink, loadAgentProfiles, resolveGlobalLogPath, sinkLogger, } from "operon-agents-core";
19
+ import { createHarness, defaultCapabilities, } from "./harness.js";
20
+ /** Build `HarnessOptions` wired for a local, single-machine deployment. */
21
+ export async function localHarnessOptions(options) {
22
+ const homeDir = options.homeDir ?? join(homedir(), ".agents");
23
+ // MCP OAuth credentials on local disk (0600) — the local default backend (`<homeDir>/credentials/mcp`).
24
+ const oauthService = new McpOAuthService({ homeDir });
25
+ // Diagnostics roll on disk under <homeDir>/logs.
26
+ const logger = options.logger ?? sinkLogger(new RotatingFileSink({ path: resolveGlobalLogPath({ homeDir }) }));
27
+ // Agent profiles come from disk here; the server preset supplies them externally instead.
28
+ const extraSubagentProfiles = options.extraSubagentProfiles ??
29
+ ((options.loadDiskProfiles ?? true)
30
+ ? await loadAgentProfiles({ homeDir, cwd: options.workDir ?? process.cwd() })
31
+ : undefined);
32
+ return {
33
+ ...options,
34
+ // Disk sessions under <homeDir>/sessions; an injected repository still wins. The machine defaults to local.
35
+ repository: options.repository ?? new DiskSessionRepository(homeDir),
36
+ logger,
37
+ ...(extraSubagentProfiles !== undefined ? { extraSubagentProfiles } : {}),
38
+ capabilities: options.capabilities ??
39
+ (() => defaultCapabilities({
40
+ ...(options.maxContextTokens !== undefined ? { maxContextTokens: options.maxContextTokens } : {}),
41
+ ...(options.mcpServers !== undefined ? { mcpServers: options.mcpServers } : {}),
42
+ ...(options.pluginManager !== undefined ? { pluginManager: options.pluginManager } : {}),
43
+ ...(options.hooks !== undefined ? { hooks: options.hooks } : {}),
44
+ oauthService,
45
+ })),
46
+ // Cron rides the extension channel now: LOCAL deployments attach it, the server profile
47
+ // simply doesn't — Invariant 7 ("cron is local-only") is structural, not an option to pass.
48
+ extensions: [cronExtension(), ...(options.extensions ?? [])],
49
+ };
50
+ }
51
+ export async function createLocalHarness(options) {
52
+ return createHarness(await localHarnessOptions(options));
53
+ }
54
+ /** Convenience: a local harness with one session opened and ready to `prompt()`. */
55
+ export async function createLocalSession(options, session = {}) {
56
+ return (await createLocalHarness(options)).createSession(session);
57
+ }
58
+ //# sourceMappingURL=local.js.map
package/dist/mcp.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "operon-agents-core/mcp";
2
+ //# sourceMappingURL=mcp.d.ts.map
package/dist/mcp.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "operon-agents-core/mcp";
2
+ //# sourceMappingURL=mcp.js.map
@@ -0,0 +1,2 @@
1
+ export * from "operon-agents-core/protocol";
2
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from "operon-agents-core/protocol";
2
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1,2 @@
1
+ export * from "operon-agents-core/tools";
2
+ //# sourceMappingURL=tools.d.ts.map
package/dist/tools.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "operon-agents-core/tools";
2
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1,2 @@
1
+ export * from "operon-agents-core/tracing";
2
+ //# sourceMappingURL=tracing.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from "operon-agents-core/tracing";
2
+ //# sourceMappingURL=tracing.js.map
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "operon-agents",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "Public SDK entrypoint for building agents.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/nickqiaoo/operon-agents.git",
10
+ "directory": "packages/agents"
11
+ },
12
+ "homepage": "https://github.com/nickqiaoo/operon-agents/tree/main/packages/agents#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/nickqiaoo/operon-agents/issues"
15
+ },
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "bin": {
19
+ "operon-app-server": "./dist/app-server/main.js"
20
+ },
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js"
25
+ },
26
+ "./app-server": {
27
+ "types": "./dist/app-server/index.d.ts",
28
+ "import": "./dist/app-server/index.js"
29
+ },
30
+ "./core": {
31
+ "types": "./dist/core.d.ts",
32
+ "import": "./dist/core.js"
33
+ },
34
+ "./internal": {
35
+ "types": "./dist/internal.d.ts",
36
+ "import": "./dist/internal.js"
37
+ },
38
+ "./llm": {
39
+ "types": "./dist/llm.d.ts",
40
+ "import": "./dist/llm.js"
41
+ },
42
+ "./mcp": {
43
+ "types": "./dist/mcp.d.ts",
44
+ "import": "./dist/mcp.js"
45
+ },
46
+ "./protocol": {
47
+ "types": "./dist/protocol.d.ts",
48
+ "import": "./dist/protocol.js"
49
+ },
50
+ "./tools": {
51
+ "types": "./dist/tools.d.ts",
52
+ "import": "./dist/tools.js"
53
+ },
54
+ "./tracing": {
55
+ "types": "./dist/tracing.d.ts",
56
+ "import": "./dist/tracing.js"
57
+ },
58
+ "./package.json": "./package.json"
59
+ },
60
+ "files": [
61
+ "dist",
62
+ "!dist/**/*.map",
63
+ "README.md"
64
+ ],
65
+ "dependencies": {
66
+ "zod": "^4.4.3",
67
+ "operon-agents-core": "0.1.0-alpha.0"
68
+ },
69
+ "devDependencies": {
70
+ "@earendil-works/pi-ai": "0.84.1"
71
+ },
72
+ "scripts": {
73
+ "clean": "rm -rf dist *.tsbuildinfo",
74
+ "build": "pnpm --filter operon-agents-core build && tsc -p tsconfig.build.json",
75
+ "typecheck": "tsc --noEmit -p tsconfig.json",
76
+ "test": "for f in test/e2e*.ts; do echo \"\\n▶ $f\"; node --experimental-strip-types --no-warnings \"$f\" || exit 1; done"
77
+ }
78
+ }