operon-agents-core 0.1.0-alpha.2 → 0.1.0-alpha.21
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/agent/agent.d.ts +8 -7
- package/dist/agent/compose-hooks.d.ts +10 -1
- package/dist/agent/compose-hooks.js +61 -6
- package/dist/agent/concurrency.js +1 -1
- package/dist/agent/context-report.d.ts +2 -2
- package/dist/agent/durable-state.d.ts +22 -0
- package/dist/agent/durable-state.js +54 -0
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +1 -1
- package/dist/agent/instruction-context.d.ts +6 -6
- package/dist/agent/instruction-context.js +23 -23
- package/dist/agent/profile-builtins.js +1 -1
- package/dist/agent/run-support.d.ts +1 -1
- package/dist/agent/run-support.js +6 -5
- package/dist/agent/runner.d.ts +25 -22
- package/dist/agent/runner.js +217 -121
- package/dist/agent/session.d.ts +262 -156
- package/dist/agent/session.js +590 -418
- package/dist/agent/subagent-tools.js +3 -3
- package/dist/agent/subagent.js +28 -13
- package/dist/agent/toolset.d.ts +1 -0
- package/dist/agent/toolset.js +13 -7
- package/dist/agent/workflow/journal.d.ts +2 -2
- package/dist/agent/workflow/journal.js +2 -2
- package/dist/agent/workflow/manager.d.ts +1 -1
- package/dist/agent/workflow/manager.js +1 -1
- package/dist/agent/workflow/prompt.js +2 -2
- package/dist/agent/workflow/sandbox.d.ts +1 -1
- package/dist/agent/workflow/sandbox.js +1 -1
- package/dist/agent/workflow/tool.js +30 -43
- package/dist/agent/worktree.d.ts +8 -8
- package/dist/agent/worktree.js +15 -15
- package/dist/capabilities/assembler.d.ts +29 -5
- package/dist/capabilities/assembler.js +85 -9
- package/dist/capabilities/background/code-task.d.ts +43 -0
- package/dist/capabilities/background/code-task.js +75 -0
- package/dist/capabilities/background/command-task.d.ts +9 -2
- package/dist/capabilities/background/command-task.js +22 -6
- package/dist/capabilities/background/index.d.ts +6 -1
- package/dist/capabilities/background/index.js +26 -20
- package/dist/capabilities/background/manager.d.ts +57 -1
- package/dist/capabilities/background/manager.js +210 -45
- package/dist/capabilities/background/persist-disk.d.ts +1 -1
- package/dist/capabilities/background/persist-disk.js +1 -1
- package/dist/capabilities/background/persist.js +4 -2
- package/dist/capabilities/background/projections.d.ts +16 -0
- package/dist/capabilities/background/projections.js +86 -0
- package/dist/capabilities/background/stall-watchdog.d.ts +41 -0
- package/dist/capabilities/background/stall-watchdog.js +85 -0
- package/dist/capabilities/background/task.d.ts +8 -7
- package/dist/capabilities/background/tools.js +33 -7
- package/dist/capabilities/capability-data.d.ts +52 -0
- package/dist/capabilities/capability-data.js +88 -0
- package/dist/capabilities/capability-state.d.ts +2 -4
- package/dist/capabilities/capability-state.js +5 -23
- package/dist/capabilities/capability.d.ts +203 -38
- package/dist/capabilities/compaction/index.js +10 -4
- package/dist/capabilities/compaction/service.d.ts +20 -5
- package/dist/capabilities/compaction/service.js +27 -11
- package/dist/capabilities/goal/goal-store.d.ts +76 -12
- package/dist/capabilities/goal/goal-store.js +137 -53
- package/dist/capabilities/goal/index.d.ts +1 -1
- package/dist/capabilities/goal/index.js +30 -7
- package/dist/capabilities/index.d.ts +9 -6
- package/dist/capabilities/index.js +4 -3
- package/dist/capabilities/plan/index.js +22 -5
- package/dist/capabilities/plan/plan-mode.d.ts +30 -9
- package/dist/capabilities/plan/plan-mode.js +57 -32
- package/dist/capabilities/plan/tools.js +1 -1
- package/dist/capabilities/skills/flow-provider.js +3 -3
- package/dist/capabilities/skills/index.d.ts +13 -1
- package/dist/capabilities/skills/index.js +30 -21
- package/dist/capabilities/skills/parser.d.ts +2 -2
- package/dist/capabilities/skills/parser.js +3 -3
- package/dist/capabilities/skills/registry.d.ts +5 -6
- package/dist/capabilities/skills/registry.js +6 -9
- package/dist/capabilities/skills/scanner.d.ts +3 -3
- package/dist/capabilities/skills/scanner.js +14 -14
- package/dist/capabilities/skills/service.d.ts +2 -1
- package/dist/capabilities/skills/service.js +3 -3
- package/dist/capabilities/skills/skill-tool.d.ts +2 -0
- package/dist/capabilities/skills/skill-tool.js +1 -1
- package/dist/capabilities/task/index.js +2 -1
- package/dist/capabilities/task/persist-disk.d.ts +1 -1
- package/dist/capabilities/task/persist-disk.js +1 -1
- package/dist/capabilities/task/persist.js +1 -1
- package/dist/capabilities/todo/index.js +11 -6
- package/dist/capabilities/todo/injector.js +2 -1
- package/dist/capabilities/todo/todo-store.d.ts +28 -7
- package/dist/capabilities/todo/todo-store.js +44 -11
- package/dist/capabilities/todo/tools.js +8 -3
- package/dist/capabilities/tool-provider.d.ts +3 -3
- package/dist/capabilities/user-hooks/engine.d.ts +3 -3
- package/dist/capabilities/user-hooks/engine.js +7 -7
- package/dist/capabilities/user-hooks/index.js +2 -1
- package/dist/capabilities/workflow/index.d.ts +5 -3
- package/dist/capabilities/workflow/index.js +3 -2
- package/dist/commands/index.js +34 -32
- package/dist/config/index.d.ts +1 -1
- package/dist/config/provider-manager.js +0 -28
- package/dist/config/schema.d.ts +53 -4
- package/dist/config/schema.js +53 -1
- package/dist/events/events.d.ts +43 -11
- package/dist/events/events.js +1 -0
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.js +1 -1
- package/dist/events/projection.d.ts +49 -1
- package/dist/events/projection.js +144 -19
- package/dist/events/publisher.js +2 -21
- package/dist/home.d.ts +1 -1
- package/dist/home.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/internal.d.ts +5 -2
- package/dist/internal.js +5 -2
- package/dist/llm/define-model.d.ts +4 -0
- package/dist/llm/define-model.js +63 -25
- package/dist/llm/index.d.ts +1 -0
- package/dist/llm/index.js +1 -0
- package/dist/llm/model.d.ts +2 -0
- package/dist/llm/provider.d.ts +17 -0
- package/dist/llm/provider.js +14 -0
- package/dist/llm/retry.js +1 -1
- package/dist/loop/context.d.ts +21 -1
- package/dist/loop/context.js +47 -9
- package/dist/loop/events.d.ts +5 -1
- package/dist/loop/index.d.ts +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/interruption.d.ts +9 -4
- package/dist/loop/interruption.js +11 -25
- package/dist/loop/run-turn.d.ts +16 -3
- package/dist/loop/run-turn.js +13 -4
- package/dist/loop/steer.d.ts +78 -12
- package/dist/loop/steer.js +101 -38
- package/dist/loop/tool-call.d.ts +13 -2
- package/dist/loop/tool-call.js +135 -5
- package/dist/loop/turn-step.d.ts +13 -2
- package/dist/loop/turn-step.js +29 -7
- package/dist/loop/types.d.ts +6 -0
- package/dist/mcp/auth-tool.d.ts +3 -1
- package/dist/mcp/auth-tool.js +2 -2
- package/dist/mcp/capability.d.ts +13 -0
- package/dist/mcp/capability.js +36 -17
- package/dist/mcp/config-loader.d.ts +5 -5
- package/dist/mcp/config-loader.js +17 -17
- package/dist/mcp/credentials.d.ts +35 -0
- package/dist/mcp/credentials.js +2 -0
- package/dist/mcp/filter.d.ts +2 -2
- package/dist/mcp/index.d.ts +4 -3
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/manager.d.ts +108 -6
- package/dist/mcp/manager.js +262 -18
- package/dist/mcp/oauth/callback-server.d.ts +10 -1
- package/dist/mcp/oauth/callback-server.js +82 -16
- package/dist/mcp/oauth/index.d.ts +2 -2
- package/dist/mcp/oauth/provider.d.ts +18 -0
- package/dist/mcp/oauth/provider.js +31 -1
- package/dist/mcp/oauth/service.d.ts +9 -3
- package/dist/mcp/oauth/service.js +29 -4
- package/dist/mcp/sdk-transport.js +1 -1
- package/dist/mcp/server.js +1 -1
- package/dist/permission/auto-approver/prompts-data.d.ts +1 -1
- package/dist/permission/auto-approver/prompts-data.js +1 -1
- package/dist/permission/manager.d.ts +5 -3
- package/dist/permission/manager.js +7 -3
- package/dist/permission/policies.d.ts +2 -2
- package/dist/permission/policies.js +4 -4
- package/dist/plugins/fields.d.ts +14 -0
- package/dist/plugins/fields.js +30 -0
- package/dist/plugins/hooks.d.ts +2 -2
- package/dist/plugins/hooks.js +12 -12
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/manager.d.ts +8 -3
- package/dist/plugins/manager.js +18 -7
- package/dist/plugins/manifest.d.ts +2 -2
- package/dist/plugins/manifest.js +101 -91
- package/dist/plugins/marketplace.js +76 -57
- package/dist/plugins/store.d.ts +3 -3
- package/dist/plugins/store.js +6 -6
- package/dist/protocol/index.d.ts +1 -1
- package/dist/store/catalog-store.d.ts +4 -1
- package/dist/store/catalog-store.js +5 -1
- package/dist/store/checkpointing-store.d.ts +41 -0
- package/dist/store/checkpointing-store.js +86 -0
- package/dist/store/disk-store.d.ts +8 -0
- package/dist/store/disk-store.js +127 -5
- package/dist/store/index.d.ts +3 -2
- package/dist/store/index.js +2 -1
- package/dist/store/log-store.d.ts +9 -1
- package/dist/store/log-store.js +68 -4
- package/dist/store/migrate.d.ts +8 -2
- package/dist/store/migrate.js +9 -2
- package/dist/store/origin.d.ts +31 -6
- package/dist/store/origin.js +0 -14
- package/dist/store/pg.d.ts +1 -0
- package/dist/store/pg.js +37 -2
- package/dist/store/redis.d.ts +1 -0
- package/dist/store/redis.js +30 -0
- package/dist/store/repository.d.ts +13 -1
- package/dist/store/repository.js +45 -2
- package/dist/store/session-catalog.d.ts +4 -0
- package/dist/store/session-catalog.js +6 -0
- package/dist/store/storage.js +3 -0
- package/dist/store/store.d.ts +97 -34
- package/dist/store/store.js +64 -10
- package/dist/telemetry/appender.d.ts +43 -0
- package/dist/telemetry/appender.js +46 -0
- package/dist/telemetry/events.d.ts +142 -0
- package/dist/telemetry/events.js +141 -0
- package/dist/telemetry/index.d.ts +10 -0
- package/dist/telemetry/index.js +6 -0
- package/dist/telemetry/projection.d.ts +23 -0
- package/dist/telemetry/projection.js +185 -0
- package/dist/telemetry/redact.d.ts +20 -0
- package/dist/telemetry/redact.js +40 -0
- package/dist/telemetry/service.d.ts +49 -0
- package/dist/telemetry/service.js +137 -0
- package/dist/testing.d.ts +58 -0
- package/dist/testing.js +123 -0
- package/dist/tool/background.d.ts +9 -6
- package/dist/tool/background.js +7 -1
- package/dist/tool/builtin/ask-user-question.js +6 -5
- package/dist/tool/builtin/bash.d.ts +6 -0
- package/dist/tool/builtin/bash.js +79 -42
- package/dist/tool/builtin/edit.js +82 -109
- package/dist/tool/builtin/glob.js +13 -13
- package/dist/tool/builtin/grep.js +13 -13
- package/dist/tool/builtin/read.js +25 -15
- package/dist/tool/builtin/write.js +49 -33
- package/dist/tool/define.d.ts +14 -8
- package/dist/tool/define.js +8 -2
- package/dist/tool/{machine-base.d.ts → environment-base.d.ts} +37 -37
- package/dist/tool/{machine-base.js → environment-base.js} +45 -119
- package/dist/tool/{machine-local.d.ts → environment-local.d.ts} +9 -8
- package/dist/tool/{machine-local.js → environment-local.js} +60 -81
- package/dist/tool/{machine-null.d.ts → environment-null.d.ts} +9 -9
- package/dist/tool/{machine-null.js → environment-null.js} +9 -9
- package/dist/tool/{machine-ssh.d.ts → environment-ssh.d.ts} +33 -18
- package/dist/tool/{machine-ssh.js → environment-ssh.js} +118 -149
- package/dist/tool/{machine.d.ts → environment.d.ts} +53 -82
- package/dist/tool/environment.js +2 -0
- package/dist/tool/file-freshness.d.ts +33 -19
- package/dist/tool/file-freshness.js +39 -30
- package/dist/tool/filesystem-tools.d.ts +1 -1
- package/dist/tool/filesystem-tools.js +1 -1
- package/dist/tool/git-context.d.ts +2 -2
- package/dist/tool/git-context.js +8 -8
- package/dist/tool/index.d.ts +12 -12
- package/dist/tool/index.js +12 -10
- package/dist/tool/policies/path-access.d.ts +4 -4
- package/dist/tool/policies/path-access.js +12 -12
- package/dist/tool/questions.d.ts +8 -0
- package/dist/tool/search/catalog.d.ts +37 -0
- package/dist/tool/search/catalog.js +182 -0
- package/dist/tool/search/deferral.d.ts +3 -2
- package/dist/tool/search/loaded.d.ts +32 -0
- package/dist/tool/search/loaded.js +96 -0
- package/dist/tool/search/search-tool.d.ts +2 -6
- package/dist/tool/search/search-tool.js +16 -15
- package/dist/tool/shell-env.js +4 -0
- package/dist/tool/support/bash-paths.js +38 -7
- package/dist/tool/support/{machine-ops.d.ts → environment-ops.d.ts} +12 -14
- package/dist/tool/support/{machine-ops.js → environment-ops.js} +21 -2
- package/dist/tool/support/git-worktree.d.ts +3 -3
- package/dist/tool/support/git-worktree.js +6 -6
- package/dist/tool/support/rg-locator.d.ts +6 -6
- package/dist/tool/support/rg-locator.js +6 -6
- package/dist/tool/support/ripgrep-run.d.ts +5 -5
- package/dist/tool/support/ripgrep-run.js +3 -3
- package/dist/tool/support/tool-path.d.ts +3 -3
- package/dist/tool/support/tool-path.js +7 -7
- package/dist/tool/types.d.ts +54 -10
- package/dist/tool/web/fetch-url.js +1 -1
- package/dist/tool/web/web-search.js +1 -1
- package/dist/tool/workspace-spec.d.ts +3 -3
- package/dist/tool/workspace-spec.js +27 -27
- package/dist/tracing/bridge.d.ts +9 -1
- package/dist/tracing/bridge.js +307 -77
- package/dist/tracing/index.d.ts +2 -2
- package/dist/tracing/otel.d.ts +28 -1
- package/dist/tracing/otel.js +150 -38
- package/dist/tracing/processor.d.ts +22 -0
- package/dist/tracing/processor.js +2 -0
- package/dist/tracing/spans.d.ts +54 -0
- package/dist/tracing/spans.js +5 -0
- package/package.json +6 -2
- package/dist/tool/machine.js +0 -15
- package/dist/tool/search/activation.d.ts +0 -13
- package/dist/tool/search/activation.js +0 -31
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Environment } from "../index.ts";
|
|
2
2
|
import { type PluginDiagnostic, type PluginManifest } from "./types.ts";
|
|
3
3
|
export interface ParsedManifestResult {
|
|
4
4
|
readonly manifest?: PluginManifest;
|
|
5
5
|
readonly manifestPath?: string;
|
|
6
6
|
readonly diagnostics: readonly PluginDiagnostic[];
|
|
7
7
|
}
|
|
8
|
-
export declare function parseManifest(
|
|
8
|
+
export declare function parseManifest(environment: Environment, pluginRoot: string): Promise<ParsedManifestResult>;
|
|
9
9
|
//# sourceMappingURL=manifest.d.ts.map
|
package/dist/plugins/manifest.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
import { McpServerConfigSchema } from "../index.js";
|
|
3
4
|
import { loadPluginHooks } from "./hooks.js";
|
|
4
5
|
import { PLUGIN_NAME_REGEX } from "./types.js";
|
|
5
|
-
import { readTextFile } from "../tool/support/
|
|
6
|
+
import { readTextFile } from "../tool/support/environment-ops.js";
|
|
7
|
+
import { describeIssue, optionalText } from "./fields.js";
|
|
6
8
|
const PLUGIN_ROOT_MANIFEST = "agents.plugin.json";
|
|
7
9
|
const PLUGIN_DIR_MANIFEST = ".agents-plugin/plugin.json";
|
|
8
10
|
// Codex-format plugins (github.com/openai/plugins): same manifest shape, different filename, and
|
|
@@ -10,12 +12,46 @@ const PLUGIN_DIR_MANIFEST = ".agents-plugin/plugin.json";
|
|
|
10
12
|
const CODEX_DIR_MANIFEST = ".codex-plugin/plugin.json";
|
|
11
13
|
// Runtime fields we still do not execute. `hooks` is supported (see loadPluginHooks).
|
|
12
14
|
const UNSUPPORTED_RUNTIME_FIELDS = ["tools", "commands", "apps", "inject", "configFile", "bootstrap"];
|
|
13
|
-
|
|
15
|
+
const AuthorSchema = z.union([
|
|
16
|
+
z.string().transform((name) => ({ name })),
|
|
17
|
+
z.object({ name: optionalText, email: optionalText }).transform(({ name, email }) => (name === undefined && email === undefined ? undefined : { name, email })),
|
|
18
|
+
]);
|
|
19
|
+
const InterfaceSchema = z
|
|
20
|
+
.object({ displayName: optionalText, shortDescription: optionalText, longDescription: optionalText })
|
|
21
|
+
.transform((iface) => (Object.values(iface).some((v) => v !== undefined) ? iface : undefined));
|
|
22
|
+
/**
|
|
23
|
+
* The manifest as written. Fields that need the filesystem to be resolved (`skills`,
|
|
24
|
+
* `mcpServers`, `hooks`) are shape-checked here and resolved below; everything else lands in
|
|
25
|
+
* the `PluginManifest` as is. Unknown fields pass through so a newer plugin still loads.
|
|
26
|
+
*/
|
|
27
|
+
const RawManifestSchema = z.looseObject({
|
|
28
|
+
name: z.string({ error: "is required" }).refine((name) => name.trim().length > 0, "is required"),
|
|
29
|
+
version: optionalText,
|
|
30
|
+
description: optionalText,
|
|
31
|
+
keywords: z.array(z.string()).optional(),
|
|
32
|
+
homepage: optionalText,
|
|
33
|
+
license: optionalText,
|
|
34
|
+
author: AuthorSchema.optional(),
|
|
35
|
+
skills: z.union([z.string(), z.array(z.string())], { error: "must be a string or string[]" }).optional(),
|
|
36
|
+
sessionStart: z.object({ skill: z.string().refine((skill) => skill.trim().length > 0, "is required when sessionStart is present") }).optional(),
|
|
37
|
+
mcpServers: z.union([z.string(), z.record(z.string(), z.unknown())], { error: "must be an object or a path to a .mcp.json" }).optional(),
|
|
38
|
+
hooks: z.unknown().optional(),
|
|
39
|
+
interface: InterfaceSchema.optional(),
|
|
40
|
+
skillInstructions: z.string().optional(),
|
|
41
|
+
});
|
|
42
|
+
// A malformed optional field is reported and dropped, not fatal: the plugin still loads with
|
|
43
|
+
// what was valid, the way it always has. `name` and `skills` are the two a plugin cannot do
|
|
44
|
+
// without, so those stay errors.
|
|
45
|
+
const FATAL_FIELDS = new Set(["name"]);
|
|
46
|
+
const ERROR_FIELDS = new Set(["skills"]);
|
|
47
|
+
const DEFAULT_SKILLS_DIR = "skills";
|
|
48
|
+
const DEFAULT_MCP_CONFIG_FILE = ".mcp.json";
|
|
49
|
+
export async function parseManifest(environment, pluginRoot) {
|
|
14
50
|
const candidates = [PLUGIN_ROOT_MANIFEST, PLUGIN_DIR_MANIFEST, CODEX_DIR_MANIFEST];
|
|
15
51
|
let manifestPath;
|
|
16
52
|
for (const candidate of candidates) {
|
|
17
53
|
const candidatePath = path.join(pluginRoot, candidate);
|
|
18
|
-
if (await isFile(
|
|
54
|
+
if (await isFile(environment, candidatePath)) {
|
|
19
55
|
manifestPath = candidatePath;
|
|
20
56
|
break;
|
|
21
57
|
}
|
|
@@ -23,64 +59,86 @@ export async function parseManifest(machine, pluginRoot) {
|
|
|
23
59
|
if (manifestPath === undefined) {
|
|
24
60
|
return { diagnostics: [{ severity: "error", message: `No manifest at ${candidates.join(", ")}` }] };
|
|
25
61
|
}
|
|
26
|
-
let
|
|
62
|
+
let json;
|
|
27
63
|
try {
|
|
28
|
-
|
|
64
|
+
json = JSON.parse(await readTextFile(environment, manifestPath));
|
|
29
65
|
}
|
|
30
66
|
catch (error) {
|
|
31
67
|
return { manifestPath, diagnostics: [{ severity: "error", message: `Failed to parse ${manifestPath}: ${error.message}` }] };
|
|
32
68
|
}
|
|
33
|
-
if (!isObject(
|
|
69
|
+
if (!isObject(json)) {
|
|
34
70
|
return { manifestPath, diagnostics: [{ severity: "error", message: "manifest must be a JSON object" }] };
|
|
35
71
|
}
|
|
36
72
|
const diagnostics = [];
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
diagnostics.push({ severity: "error", message: '"name" is required' });
|
|
73
|
+
const raw = parseTolerant(json, diagnostics);
|
|
74
|
+
if (raw === undefined)
|
|
40
75
|
return { manifestPath, diagnostics };
|
|
41
|
-
|
|
76
|
+
const name = raw.name.trim();
|
|
42
77
|
if (!PLUGIN_NAME_REGEX.test(name)) {
|
|
43
78
|
diagnostics.push({ severity: "error", message: `"name" must match ${PLUGIN_NAME_REGEX} (got "${name}")` });
|
|
44
79
|
return { manifestPath, diagnostics };
|
|
45
80
|
}
|
|
46
|
-
|
|
47
|
-
|
|
81
|
+
// Codex convention: a manifest that doesn't name its skills / MCP file still gets the plugin's
|
|
82
|
+
// `skills/` dir and root `.mcp.json` (most curated plugins rely on this — e.g. Vercel, Slack).
|
|
83
|
+
const skillsField = raw.skills ?? ((await isDir(environment, path.join(pluginRoot, DEFAULT_SKILLS_DIR))) ? `./${DEFAULT_SKILLS_DIR}` : undefined);
|
|
84
|
+
const mcpServersField = raw.mcpServers ?? ((await isFile(environment, path.join(pluginRoot, DEFAULT_MCP_CONFIG_FILE))) ? `./${DEFAULT_MCP_CONFIG_FILE}` : undefined);
|
|
85
|
+
let skills = await resolveSkillsField(environment, pluginRoot, skillsField, diagnostics);
|
|
86
|
+
if (skillsField === undefined && (await isFile(environment, path.join(pluginRoot, "SKILL.md")))) {
|
|
48
87
|
skills = [pluginRoot];
|
|
49
88
|
}
|
|
50
89
|
for (const field of UNSUPPORTED_RUNTIME_FIELDS) {
|
|
51
90
|
if (raw[field] !== undefined)
|
|
52
91
|
diagnostics.push({ severity: "info", message: `"${field}" is present but not supported` });
|
|
53
92
|
}
|
|
54
|
-
const hooks = await loadPluginHooks(
|
|
93
|
+
const hooks = await loadPluginHooks(environment, pluginRoot, raw.hooks, diagnostics);
|
|
55
94
|
const manifest = {
|
|
56
95
|
name,
|
|
57
|
-
version:
|
|
58
|
-
description:
|
|
59
|
-
keywords:
|
|
60
|
-
homepage:
|
|
61
|
-
license:
|
|
62
|
-
author:
|
|
96
|
+
version: raw.version,
|
|
97
|
+
description: raw.description,
|
|
98
|
+
keywords: raw.keywords,
|
|
99
|
+
homepage: raw.homepage,
|
|
100
|
+
license: raw.license,
|
|
101
|
+
author: raw.author,
|
|
63
102
|
skills,
|
|
64
|
-
sessionStart:
|
|
65
|
-
mcpServers: await readMcpServers(
|
|
103
|
+
sessionStart: raw.sessionStart === undefined ? undefined : { skill: raw.sessionStart.skill.trim() },
|
|
104
|
+
mcpServers: await readMcpServers(environment, pluginRoot, mcpServersField, diagnostics),
|
|
66
105
|
...(hooks.length > 0 ? { hooks } : {}),
|
|
67
|
-
interface:
|
|
68
|
-
skillInstructions:
|
|
106
|
+
interface: raw.interface,
|
|
107
|
+
skillInstructions: raw.skillInstructions,
|
|
69
108
|
};
|
|
70
109
|
return { manifest, manifestPath, diagnostics };
|
|
71
110
|
}
|
|
72
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Validate the manifest, reporting each malformed field by name. A bad `name` ends parsing;
|
|
113
|
+
* any other bad field is dropped and the rest is parsed again, so one typo in `author` does
|
|
114
|
+
* not cost the plugin its skills.
|
|
115
|
+
*/
|
|
116
|
+
function parseTolerant(json, diagnostics) {
|
|
117
|
+
const first = RawManifestSchema.safeParse(json);
|
|
118
|
+
if (first.success)
|
|
119
|
+
return first.data;
|
|
120
|
+
const dropped = new Set();
|
|
121
|
+
for (const issue of first.error.issues) {
|
|
122
|
+
const field = String(issue.path[0] ?? "");
|
|
123
|
+
if (FATAL_FIELDS.has(field) || issue.path.length === 0) {
|
|
124
|
+
diagnostics.push({ severity: "error", message: describeIssue(issue) });
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
diagnostics.push({ severity: ERROR_FIELDS.has(field) ? "error" : "warn", message: describeIssue(issue) });
|
|
128
|
+
dropped.add(field);
|
|
129
|
+
}
|
|
130
|
+
const pruned = Object.fromEntries(Object.entries(json).filter(([key]) => !dropped.has(key)));
|
|
131
|
+
const second = RawManifestSchema.safeParse(pruned);
|
|
132
|
+
if (second.success)
|
|
133
|
+
return second.data;
|
|
134
|
+
for (const issue of second.error.issues)
|
|
135
|
+
diagnostics.push({ severity: "error", message: describeIssue(issue) });
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
async function resolveSkillsField(environment, pluginRoot, raw, diagnostics) {
|
|
73
139
|
if (raw === undefined)
|
|
74
140
|
return [];
|
|
75
|
-
const entries = [];
|
|
76
|
-
if (typeof raw === "string")
|
|
77
|
-
entries.push(raw);
|
|
78
|
-
else if (Array.isArray(raw) && raw.every((e) => typeof e === "string"))
|
|
79
|
-
entries.push(...raw);
|
|
80
|
-
else {
|
|
81
|
-
diagnostics.push({ severity: "error", message: '"skills" must be a string or string[]' });
|
|
82
|
-
return [];
|
|
83
|
-
}
|
|
141
|
+
const entries = typeof raw === "string" ? [raw] : raw;
|
|
84
142
|
const resolved = [];
|
|
85
143
|
for (const entry of entries) {
|
|
86
144
|
if (!entry.startsWith("./")) {
|
|
@@ -92,7 +150,7 @@ async function resolveSkillsField(machine, pluginRoot, raw, diagnostics) {
|
|
|
92
150
|
diagnostics.push({ severity: "error", message: `"skills" path resolves outside the plugin (${entry})` });
|
|
93
151
|
continue;
|
|
94
152
|
}
|
|
95
|
-
if (!(await isDir(
|
|
153
|
+
if (!(await isDir(environment, absolute))) {
|
|
96
154
|
diagnostics.push({ severity: "warn", message: `"skills" path is not a directory (${entry})` });
|
|
97
155
|
continue;
|
|
98
156
|
}
|
|
@@ -100,21 +158,7 @@ async function resolveSkillsField(machine, pluginRoot, raw, diagnostics) {
|
|
|
100
158
|
}
|
|
101
159
|
return resolved;
|
|
102
160
|
}
|
|
103
|
-
function
|
|
104
|
-
if (raw === undefined)
|
|
105
|
-
return undefined;
|
|
106
|
-
if (!isObject(raw)) {
|
|
107
|
-
diagnostics.push({ severity: "warn", message: '"sessionStart" must be an object' });
|
|
108
|
-
return undefined;
|
|
109
|
-
}
|
|
110
|
-
const skill = typeof raw["skill"] === "string" ? raw["skill"].trim() : "";
|
|
111
|
-
if (skill.length === 0) {
|
|
112
|
-
diagnostics.push({ severity: "warn", message: '"sessionStart.skill" is required when sessionStart is present' });
|
|
113
|
-
return undefined;
|
|
114
|
-
}
|
|
115
|
-
return { skill };
|
|
116
|
-
}
|
|
117
|
-
async function readMcpServers(machine, pluginRoot, raw, diagnostics) {
|
|
161
|
+
async function readMcpServers(environment, pluginRoot, raw, diagnostics) {
|
|
118
162
|
if (raw === undefined)
|
|
119
163
|
return undefined;
|
|
120
164
|
// Codex format: `mcpServers` is a path to a `.mcp.json` ({ "mcpServers": { … } }). Read it and
|
|
@@ -132,7 +176,7 @@ async function readMcpServers(machine, pluginRoot, raw, diagnostics) {
|
|
|
132
176
|
return undefined;
|
|
133
177
|
}
|
|
134
178
|
try {
|
|
135
|
-
const parsed = JSON.parse(await readTextFile(
|
|
179
|
+
const parsed = JSON.parse(await readTextFile(environment, absolute));
|
|
136
180
|
servers = isObject(parsed) && isObject(parsed["mcpServers"]) ? parsed["mcpServers"] : parsed;
|
|
137
181
|
}
|
|
138
182
|
catch (error) {
|
|
@@ -156,16 +200,16 @@ async function readMcpServers(machine, pluginRoot, raw, diagnostics) {
|
|
|
156
200
|
diagnostics.push({ severity: "warn", message: `Invalid MCP server "${trimmedName}": ${parsed.error.message}` });
|
|
157
201
|
continue;
|
|
158
202
|
}
|
|
159
|
-
out[trimmedName] = await normalizePluginMcpServer(
|
|
203
|
+
out[trimmedName] = await normalizePluginMcpServer(environment, pluginRoot, trimmedName, parsed.data, diagnostics);
|
|
160
204
|
}
|
|
161
205
|
return Object.keys(out).length === 0 ? undefined : out;
|
|
162
206
|
}
|
|
163
|
-
async function normalizePluginMcpServer(
|
|
207
|
+
async function normalizePluginMcpServer(environment, pluginRoot, name, config, diagnostics) {
|
|
164
208
|
// stdio `./command` resolves within the plugin root; bare names stay PATH commands.
|
|
165
209
|
if (config.transport === "stdio" && typeof config.command === "string" && config.command.startsWith("./")) {
|
|
166
210
|
const absolute = path.resolve(pluginRoot, config.command);
|
|
167
211
|
if (isWithin(absolute, pluginRoot)) {
|
|
168
|
-
if (!(await isFile(
|
|
212
|
+
if (!(await isFile(environment, absolute))) {
|
|
169
213
|
diagnostics.push({ severity: "warn", message: `"mcpServers.${name}.command" not found (${config.command})` });
|
|
170
214
|
}
|
|
171
215
|
return { ...config, command: absolute };
|
|
@@ -174,40 +218,6 @@ async function normalizePluginMcpServer(machine, pluginRoot, name, config, diagn
|
|
|
174
218
|
}
|
|
175
219
|
return config;
|
|
176
220
|
}
|
|
177
|
-
function readAuthor(raw) {
|
|
178
|
-
if (typeof raw === "string")
|
|
179
|
-
return { name: raw };
|
|
180
|
-
if (!isObject(raw))
|
|
181
|
-
return undefined;
|
|
182
|
-
const name = stringField(raw, "name");
|
|
183
|
-
const email = stringField(raw, "email");
|
|
184
|
-
if (name === undefined && email === undefined)
|
|
185
|
-
return undefined;
|
|
186
|
-
return { name, email };
|
|
187
|
-
}
|
|
188
|
-
function readInterface(raw) {
|
|
189
|
-
if (!isObject(raw))
|
|
190
|
-
return undefined;
|
|
191
|
-
const out = {
|
|
192
|
-
displayName: stringField(raw, "displayName"),
|
|
193
|
-
shortDescription: stringField(raw, "shortDescription"),
|
|
194
|
-
longDescription: stringField(raw, "longDescription"),
|
|
195
|
-
};
|
|
196
|
-
return Object.values(out).some((v) => v !== undefined) ? out : undefined;
|
|
197
|
-
}
|
|
198
|
-
function stringField(raw, key) {
|
|
199
|
-
const value = raw[key];
|
|
200
|
-
if (typeof value !== "string")
|
|
201
|
-
return undefined;
|
|
202
|
-
const trimmed = value.trim();
|
|
203
|
-
return trimmed.length === 0 ? undefined : trimmed;
|
|
204
|
-
}
|
|
205
|
-
function stringArrayField(raw, key) {
|
|
206
|
-
const value = raw[key];
|
|
207
|
-
if (!Array.isArray(value) || !value.every((e) => typeof e === "string"))
|
|
208
|
-
return undefined;
|
|
209
|
-
return value;
|
|
210
|
-
}
|
|
211
221
|
function isObject(value) {
|
|
212
222
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
213
223
|
}
|
|
@@ -215,17 +225,17 @@ function isWithin(child, parent) {
|
|
|
215
225
|
const relative = path.relative(parent, child);
|
|
216
226
|
return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
|
|
217
227
|
}
|
|
218
|
-
async function isFile(
|
|
228
|
+
async function isFile(environment, p) {
|
|
219
229
|
try {
|
|
220
|
-
return (await
|
|
230
|
+
return (await environment.fileInfo(p)).kind === "file";
|
|
221
231
|
}
|
|
222
232
|
catch {
|
|
223
233
|
return false;
|
|
224
234
|
}
|
|
225
235
|
}
|
|
226
|
-
async function isDir(
|
|
236
|
+
async function isDir(environment, p) {
|
|
227
237
|
try {
|
|
228
|
-
return (await
|
|
238
|
+
return (await environment.fileInfo(p)).kind === "dir";
|
|
229
239
|
}
|
|
230
240
|
catch {
|
|
231
241
|
return false;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
3
4
|
import { downloadZip, extractZip } from "./archive.js";
|
|
5
|
+
import { describeIssue, optionalText, optionalTextList } from "./fields.js";
|
|
4
6
|
import { codeloadZipUrl } from "./github-resolver.js";
|
|
5
7
|
import { resolveInstallSource, sanitizeSubdir } from "./source.js";
|
|
6
8
|
// Codex's marketplace index path inside a repo.
|
|
@@ -22,24 +24,48 @@ export async function materializeGithubRepo(options) {
|
|
|
22
24
|
const buffer = await downloadZip(codeloadZipUrl(options.owner, options.repo, ref));
|
|
23
25
|
return extractZip(buffer, options.destDir);
|
|
24
26
|
}
|
|
27
|
+
/** Codex source object: { source: "local"|"git-subdir"|"url", path|url, ref|sha }. */
|
|
28
|
+
const CodexSourceSchema = z.object({
|
|
29
|
+
source: optionalText,
|
|
30
|
+
path: optionalText,
|
|
31
|
+
url: optionalText,
|
|
32
|
+
ref: optionalText,
|
|
33
|
+
sha: optionalText,
|
|
34
|
+
});
|
|
35
|
+
const MarketplaceEntrySchema = z.object({
|
|
36
|
+
id: optionalText,
|
|
37
|
+
name: optionalText,
|
|
38
|
+
displayName: optionalText,
|
|
39
|
+
source: CodexSourceSchema,
|
|
40
|
+
tier: optionalText,
|
|
41
|
+
version: optionalText,
|
|
42
|
+
description: optionalText,
|
|
43
|
+
shortDescription: optionalText,
|
|
44
|
+
homepage: optionalText,
|
|
45
|
+
websiteURL: optionalText,
|
|
46
|
+
keywords: optionalTextList,
|
|
47
|
+
});
|
|
48
|
+
const MarketplaceSchema = z.object({
|
|
49
|
+
version: optionalText,
|
|
50
|
+
plugins: z.array(MarketplaceEntrySchema),
|
|
51
|
+
});
|
|
25
52
|
/** Parse + validate a marketplace registry string against a cached repo location. */
|
|
26
53
|
export function parseMarketplace(raw, location) {
|
|
27
|
-
let
|
|
54
|
+
let json;
|
|
28
55
|
try {
|
|
29
|
-
|
|
56
|
+
json = JSON.parse(raw);
|
|
30
57
|
}
|
|
31
58
|
catch (error) {
|
|
32
59
|
throw new Error(`Plugin marketplace is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
33
60
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
throw new TypeError('Plugin marketplace must contain a "plugins" array.');
|
|
61
|
+
const parsed = MarketplaceSchema.safeParse(json);
|
|
62
|
+
if (!parsed.success) {
|
|
63
|
+
throw new TypeError(`Plugin marketplace is malformed: ${parsed.error.issues.map(describeIssue).join("; ")}`);
|
|
64
|
+
}
|
|
39
65
|
return {
|
|
40
66
|
source: location.source,
|
|
41
|
-
version:
|
|
42
|
-
plugins:
|
|
67
|
+
version: parsed.data.version,
|
|
68
|
+
plugins: parsed.data.plugins.map((entry, index) => toEntry(entry, index, location)),
|
|
43
69
|
};
|
|
44
70
|
}
|
|
45
71
|
function resolveLocation(source, repoDir) {
|
|
@@ -80,33 +106,24 @@ export function parseGithubMarketplaceSource(source) {
|
|
|
80
106
|
return undefined;
|
|
81
107
|
return { owner: m[1], repo: m[2].replace(/\.git$/, ""), ...(m[3] ? { ref: m[3] } : {}) };
|
|
82
108
|
}
|
|
83
|
-
function
|
|
84
|
-
|
|
85
|
-
throw new TypeError(`Plugin marketplace entry ${index + 1} must be an object.`);
|
|
86
|
-
const id = stringField(value, "id") ?? stringField(value, "name");
|
|
109
|
+
function toEntry(value, index, location) {
|
|
110
|
+
const id = value.id ?? value.name;
|
|
87
111
|
if (id === undefined)
|
|
88
112
|
throw new Error(`Plugin marketplace entry ${index + 1} must define "id" or "name".`);
|
|
89
113
|
return {
|
|
90
114
|
id,
|
|
91
|
-
displayName:
|
|
92
|
-
source:
|
|
93
|
-
tier:
|
|
94
|
-
version:
|
|
95
|
-
description:
|
|
96
|
-
homepage:
|
|
97
|
-
keywords:
|
|
115
|
+
displayName: value.displayName ?? value.name ?? id,
|
|
116
|
+
source: resolveCodexSource(value.source, location, id),
|
|
117
|
+
tier: value.tier,
|
|
118
|
+
version: value.version,
|
|
119
|
+
description: value.description ?? value.shortDescription,
|
|
120
|
+
homepage: value.homepage ?? value.websiteURL,
|
|
121
|
+
keywords: value.keywords,
|
|
98
122
|
};
|
|
99
123
|
}
|
|
100
|
-
function resolveSource(value, location, id) {
|
|
101
|
-
const raw = value["source"];
|
|
102
|
-
if (!isRecord(raw))
|
|
103
|
-
throw new Error(`Plugin marketplace entry ${id} must define an object "source" (Codex format).`);
|
|
104
|
-
return resolveCodexSource(raw, location, id);
|
|
105
|
-
}
|
|
106
|
-
/** Codex source object: { source: "local"|"git-subdir"|"url", path|url, ref|sha }. */
|
|
107
124
|
function resolveCodexSource(obj, location, id) {
|
|
108
|
-
const kind =
|
|
109
|
-
const path =
|
|
125
|
+
const kind = obj.source;
|
|
126
|
+
const path = obj.path;
|
|
110
127
|
if (kind === "local" || (kind === undefined && path !== undefined)) {
|
|
111
128
|
if (path === undefined)
|
|
112
129
|
throw new Error(`Plugin marketplace entry ${id}: local source requires "path".`);
|
|
@@ -114,16 +131,16 @@ function resolveCodexSource(obj, location, id) {
|
|
|
114
131
|
return join(location.repoRoot, cleanSubdir(path));
|
|
115
132
|
}
|
|
116
133
|
if (kind === "git-subdir") {
|
|
117
|
-
const url =
|
|
134
|
+
const url = obj.url;
|
|
118
135
|
if (url === undefined)
|
|
119
136
|
throw new Error(`Plugin marketplace entry ${id}: git-subdir source requires "url".`);
|
|
120
|
-
const ref =
|
|
137
|
+
const ref = obj.ref ?? obj.sha ?? "HEAD";
|
|
121
138
|
const sub = path !== undefined ? cleanSubdir(path) : undefined;
|
|
122
139
|
const base = `${stripTrailingSlash(url)}/tree/${ref}`;
|
|
123
140
|
return sub !== undefined ? `${base}#path=${sub}` : base;
|
|
124
141
|
}
|
|
125
142
|
if (kind === "url") {
|
|
126
|
-
const url =
|
|
143
|
+
const url = obj.url ?? path;
|
|
127
144
|
if (url === undefined)
|
|
128
145
|
throw new Error(`Plugin marketplace entry ${id}: url source requires "url".`);
|
|
129
146
|
return url;
|
|
@@ -138,23 +155,6 @@ function cleanSubdir(p) {
|
|
|
138
155
|
function stripTrailingSlash(s) {
|
|
139
156
|
return s.replace(/\/$/, "");
|
|
140
157
|
}
|
|
141
|
-
function stringField(value, field) {
|
|
142
|
-
const raw = value[field];
|
|
143
|
-
if (typeof raw !== "string")
|
|
144
|
-
return undefined;
|
|
145
|
-
const trimmed = raw.trim();
|
|
146
|
-
return trimmed.length > 0 ? trimmed : undefined;
|
|
147
|
-
}
|
|
148
|
-
function stringArrayField(value, field) {
|
|
149
|
-
const raw = value[field];
|
|
150
|
-
if (!Array.isArray(raw))
|
|
151
|
-
return undefined;
|
|
152
|
-
const out = raw.filter((item) => typeof item === "string").map((item) => item.trim()).filter((item) => item.length > 0);
|
|
153
|
-
return out.length > 0 ? out : undefined;
|
|
154
|
-
}
|
|
155
|
-
function isRecord(value) {
|
|
156
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
157
|
-
}
|
|
158
158
|
// Manifest filenames to try, in order (Codex first, then operon). Mirrors plugins/manifest.ts.
|
|
159
159
|
const ENTRY_MANIFEST_CANDIDATES = [".codex-plugin/plugin.json", "agents.plugin.json", ".agents-plugin/plugin.json"];
|
|
160
160
|
/**
|
|
@@ -168,10 +168,10 @@ export async function loadMarketplaceEntryDetails(source) {
|
|
|
168
168
|
return null;
|
|
169
169
|
for (const candidate of ENTRY_MANIFEST_CANDIDATES) {
|
|
170
170
|
try {
|
|
171
|
-
const manifest = JSON.parse(await readFile(join(resolved.path, candidate), "utf8"));
|
|
172
|
-
if (!
|
|
171
|
+
const manifest = DetailsManifestSchema.safeParse(JSON.parse(await readFile(join(resolved.path, candidate), "utf8")));
|
|
172
|
+
if (!manifest.success)
|
|
173
173
|
continue;
|
|
174
|
-
return extractEntryDetails(manifest, resolved.path);
|
|
174
|
+
return extractEntryDetails(manifest.data, resolved.path);
|
|
175
175
|
}
|
|
176
176
|
catch {
|
|
177
177
|
// Missing/parse error for this candidate — try the next, then give up (null).
|
|
@@ -179,13 +179,32 @@ export async function loadMarketplaceEntryDetails(source) {
|
|
|
179
179
|
}
|
|
180
180
|
return null;
|
|
181
181
|
}
|
|
182
|
+
// Display metadata only: a field of the wrong type is ignored, never a reason to hide the entry.
|
|
183
|
+
const lenientText = optionalText.catch(undefined);
|
|
184
|
+
const DetailsManifestSchema = z.looseObject({
|
|
185
|
+
interface: z
|
|
186
|
+
.looseObject({
|
|
187
|
+
displayName: lenientText,
|
|
188
|
+
shortDescription: lenientText,
|
|
189
|
+
longDescription: lenientText,
|
|
190
|
+
logo: lenientText,
|
|
191
|
+
composerIcon: lenientText,
|
|
192
|
+
brandColor: lenientText,
|
|
193
|
+
})
|
|
194
|
+
.catch({}),
|
|
195
|
+
displayName: lenientText,
|
|
196
|
+
name: lenientText,
|
|
197
|
+
description: lenientText,
|
|
198
|
+
logo: lenientText,
|
|
199
|
+
icon: lenientText,
|
|
200
|
+
});
|
|
182
201
|
function extractEntryDetails(manifest, dir) {
|
|
183
202
|
// Codex puts the user-facing fields under `interface`; operon uses top-level fields.
|
|
184
|
-
const iface =
|
|
185
|
-
const displayName =
|
|
186
|
-
const description =
|
|
187
|
-
const logoRel =
|
|
188
|
-
const brandColor =
|
|
203
|
+
const iface = manifest.interface;
|
|
204
|
+
const displayName = iface.displayName ?? manifest.displayName ?? manifest.name;
|
|
205
|
+
const description = iface.shortDescription ?? iface.longDescription ?? manifest.description;
|
|
206
|
+
const logoRel = iface.logo ?? iface.composerIcon ?? manifest.logo ?? manifest.icon;
|
|
207
|
+
const brandColor = iface.brandColor;
|
|
189
208
|
let logoUrl;
|
|
190
209
|
let logoPath;
|
|
191
210
|
if (logoRel !== undefined) {
|
package/dist/plugins/store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Environment } from "../index.ts";
|
|
2
2
|
import type { PluginCapabilityState, PluginGithubMetadata, PluginSource } from "./types.ts";
|
|
3
3
|
export interface InstalledRecord {
|
|
4
4
|
readonly id: string;
|
|
@@ -15,6 +15,6 @@ export interface InstalledFile {
|
|
|
15
15
|
readonly version: 1;
|
|
16
16
|
readonly plugins: readonly InstalledRecord[];
|
|
17
17
|
}
|
|
18
|
-
export declare function readInstalled(
|
|
19
|
-
export declare function writeInstalled(
|
|
18
|
+
export declare function readInstalled(environment: Environment, homeDir: string): Promise<InstalledFile>;
|
|
19
|
+
export declare function writeInstalled(environment: Environment, homeDir: string, data: InstalledFile): Promise<void>;
|
|
20
20
|
//# sourceMappingURL=store.d.ts.map
|
package/dist/plugins/store.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { readTextFile, writeTextFile } from "../tool/support/
|
|
2
|
+
import { readTextFile, writeTextFile } from "../tool/support/environment-ops.js";
|
|
3
3
|
const EMPTY = { version: 1, plugins: [] };
|
|
4
4
|
function installedPath(homeDir) {
|
|
5
5
|
return path.join(homeDir, "plugins", "installed.json");
|
|
6
6
|
}
|
|
7
|
-
export async function readInstalled(
|
|
7
|
+
export async function readInstalled(environment, homeDir) {
|
|
8
8
|
let text;
|
|
9
9
|
try {
|
|
10
|
-
text = await readTextFile(
|
|
10
|
+
text = await readTextFile(environment, installedPath(homeDir));
|
|
11
11
|
}
|
|
12
12
|
catch {
|
|
13
13
|
return EMPTY; // missing file → empty registry
|
|
@@ -23,8 +23,8 @@ export async function readInstalled(machine, homeDir) {
|
|
|
23
23
|
throw new Error(`Failed to parse ${installedPath(homeDir)}: ${error.message}`, { cause: error });
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
export async function writeInstalled(
|
|
27
|
-
await
|
|
28
|
-
await writeTextFile(
|
|
26
|
+
export async function writeInstalled(environment, homeDir, data) {
|
|
27
|
+
await environment.mkdir(path.join(homeDir, "plugins"), { parents: true, existOk: true });
|
|
28
|
+
await writeTextFile(environment, installedPath(homeDir), JSON.stringify(data, null, 2));
|
|
29
29
|
}
|
|
30
30
|
//# sourceMappingURL=store.js.map
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Message, UserMessage, AssistantMessage, ToolResultMessage, ToolCall, TextContent, ThinkingContent, ImageContent, Usage, Context, Model, Api, KnownApi, KnownProvider, ThinkingLevel, ThinkingBudgets, ProviderHeaders, Transport, Tool as PiTool, AssistantMessageEvent, AssistantMessageEventStream, } from "@earendil-works/pi-ai";
|
|
1
|
+
export type { Message, SystemMessage, UserMessage, AssistantMessage, ToolResultMessage, ToolCall, TextContent, ThinkingContent, ImageContent, Usage, Context, Model, Api, KnownApi, KnownProvider, ThinkingLevel, ThinkingBudgets, ProviderHeaders, Transport, Tool as PiTool, AssistantMessageEvent, AssistantMessageEventStream, JsonObject, JsonValue, } from "@earendil-works/pi-ai";
|
|
2
2
|
export type { ProviderId as Provider } from "@earendil-works/pi-ai";
|
|
3
3
|
export type { ToolSchema } from "./tool-schema.ts";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Usage } from "../protocol/index.ts";
|
|
2
|
+
import { type AgentRecord, type ReadRecordPageOptions, type ReadRecordsFilter, type RecordPage, type SessionStore, type StateKey } from "./store.ts";
|
|
2
3
|
export type DurableSessionState = "idle" | "interrupted";
|
|
3
4
|
export interface SessionCatalogObserver {
|
|
4
5
|
activity(at: number, source: "log" | "state"): void | Promise<void>;
|
|
5
6
|
durableState(state: DurableSessionState, at: number): void | Promise<void>;
|
|
6
7
|
metadata?(value: unknown, at: number): void | Promise<void>;
|
|
8
|
+
/** The session's running usage moved (a root-agent turn ended; see `SessionSummary.usage`). */
|
|
9
|
+
usage?(usage: Usage, at: number): void | Promise<void>;
|
|
7
10
|
flush?(): Promise<void>;
|
|
8
11
|
}
|
|
9
12
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SESSION_USAGE_KEY, } from "./store.js";
|
|
1
2
|
/**
|
|
2
3
|
* Decorates a repository-owned store with catalog maintenance. The session KV/log remains
|
|
3
4
|
* authoritative: callbacks run only after the corresponding write succeeds, and a broken
|
|
@@ -19,7 +20,8 @@ export class CatalogSessionStore {
|
|
|
19
20
|
}
|
|
20
21
|
async appendRecord(record) {
|
|
21
22
|
const sequence = await this.inner.appendRecord(record);
|
|
22
|
-
|
|
23
|
+
const at = Date.now();
|
|
24
|
+
await this.notify(() => this.observer.activity(at, "log"));
|
|
23
25
|
return sequence;
|
|
24
26
|
}
|
|
25
27
|
readRecords(filter) {
|
|
@@ -36,6 +38,8 @@ export class CatalogSessionStore {
|
|
|
36
38
|
return this.observer.durableState("interrupted", at);
|
|
37
39
|
if (key === "meta" && this.observer.metadata !== undefined)
|
|
38
40
|
return this.observer.metadata(value, at);
|
|
41
|
+
if (key === SESSION_USAGE_KEY && this.observer.usage !== undefined)
|
|
42
|
+
return this.observer.usage(value, at);
|
|
39
43
|
return this.observer.activity(at, "state");
|
|
40
44
|
});
|
|
41
45
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type AgentRecord, type ReadRecordPageOptions, type ReadRecordsFilter, type RecordPage, type SessionStore, type StateKey, type StoredAgentRecord, type WatchRecordsOptions } from "./store.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Stamps every history checkpoint a session writes with the shard's lifecycle at that instant
|
|
4
|
+
* (`#frame`: agent, open turn, queued steers — see `FrameCheckpoint`).
|
|
5
|
+
*
|
|
6
|
+
* The stamp happens inside `appendRecord`, which a `ConversationContext` calls synchronously in
|
|
7
|
+
* the same block as the history reset — so it is of exactly the lifecycle every record before
|
|
8
|
+
* the checkpoint produced, and of nothing after it. Doing it here rather than in each context
|
|
9
|
+
* means no context, wherever it is built, can write a checkpoint without it. A record that
|
|
10
|
+
* already carries `checkpoint` passes through untouched.
|
|
11
|
+
*
|
|
12
|
+
* The lifecycle is folded here from every record that passes through: this store sits UNDER the
|
|
13
|
+
* event publisher, so the lifecycle records the publisher journals pass through it too, in
|
|
14
|
+
* exactly the order they reach the log. Session and capability state are not stamped — they are
|
|
15
|
+
* kept as current values in the store's key/value side (see `CapabilityDurableState`).
|
|
16
|
+
*/
|
|
17
|
+
export declare class CheckpointingSessionStore implements SessionStore {
|
|
18
|
+
private readonly inner;
|
|
19
|
+
/** The lifecycle side of every shard written or restored in this process, without history. */
|
|
20
|
+
private readonly frames;
|
|
21
|
+
readonly listStateKeys?: () => Promise<readonly StateKey[]>;
|
|
22
|
+
readonly watch?: (options: WatchRecordsOptions) => AsyncIterable<StoredAgentRecord>;
|
|
23
|
+
readonly flush?: () => Promise<void>;
|
|
24
|
+
readonly close?: () => Promise<void>;
|
|
25
|
+
readonly rewrite?: (address?: string) => Promise<void>;
|
|
26
|
+
readonly storageDir?: () => string | undefined;
|
|
27
|
+
constructor(inner: SessionStore, sessionId: string);
|
|
28
|
+
/**
|
|
29
|
+
* Fold a shard's records read back from the log (from its checkpoint on, or whole) into the
|
|
30
|
+
* lifecycle state, before this process writes to it again. A shard already folded here is
|
|
31
|
+
* left alone: what this process wrote is newer than anything it could read.
|
|
32
|
+
*/
|
|
33
|
+
restoreFrame(address: string, records: readonly AgentRecord[]): void;
|
|
34
|
+
appendRecord(record: AgentRecord): Promise<string>;
|
|
35
|
+
readRecords(filter?: ReadRecordsFilter): AsyncIterable<AgentRecord>;
|
|
36
|
+
readRecordPage(options: ReadRecordPageOptions): Promise<RecordPage>;
|
|
37
|
+
putState(key: StateKey, value: unknown): Promise<void>;
|
|
38
|
+
getState(key: StateKey): Promise<unknown | null>;
|
|
39
|
+
deleteState(key: StateKey): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=checkpointing-store.d.ts.map
|