flavor-code 1.2.18 → 1.3.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.
@@ -0,0 +1,233 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
3
+
4
+ // src/plugins/plugin-worker-entry.ts
5
+ import { readFile, realpath } from "fs/promises";
6
+ import { isAbsolute, relative, resolve, sep } from "path";
7
+ import { fileURLToPath, pathToFileURL } from "url";
8
+ import { createContext, runInContext, SourceTextModule } from "vm";
9
+ import { parentPort, workerData } from "worker_threads";
10
+ var MAX_MODULE_BYTES = 2 * 1024 * 1024;
11
+ var CONTRIBUTION_NAME_SOURCE = "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$";
12
+ var data = workerData;
13
+ var port = parentPort;
14
+ if (port === null) throw new Error("Plugin sandbox requires a parent port");
15
+ var activationKeepAlive = setInterval(() => void 0, 1e3);
16
+ function send(message) {
17
+ port.postMessage(message);
18
+ }
19
+ function errorMessage(error) {
20
+ return error instanceof Error ? error.message : String(error);
21
+ }
22
+ function assertContained(root, candidate) {
23
+ const delta = relative(root, candidate);
24
+ if (delta === ".." || delta.startsWith(`..${sep}`) || isAbsolute(delta)) throw new Error("Plugin module import escapes the plugin root");
25
+ }
26
+ var SANDBOX_BOOTSTRAP = `(() => {
27
+ "use strict";
28
+ const stores = { command: new Map(), tool: new Map(), hook: new Map(), skillRoot: new Map(), modelAdapter: new Map() };
29
+ let deactivate;
30
+ let accepting = true;
31
+ const signal = Object.freeze({ aborted: false, reason: undefined, addEventListener() {}, removeEventListener() {}, throwIfAborted() {} });
32
+ const cloneJson = (value) => value === undefined ? undefined : JSON.parse(JSON.stringify(value));
33
+ const deepFreeze = (value) => {
34
+ if (!value || typeof value !== "object" || Object.isFrozen(value)) return value;
35
+ for (const child of Object.values(value)) deepFreeze(child);
36
+ return Object.freeze(value);
37
+ };
38
+ const config = deepFreeze(JSON.parse(globalThis.__flavorConfigJson));
39
+ delete globalThis.__flavorConfigJson;
40
+ const namePattern = new RegExp(${JSON.stringify(CONTRIBUTION_NAME_SOURCE)});
41
+ const name = (value) => {
42
+ const result = String(value);
43
+ if (!namePattern.test(result)) throw new Error("Invalid contribution name: " + result);
44
+ return result;
45
+ };
46
+ const register = (kind, rawName, value, metadata) => {
47
+ if (!accepting) throw new Error("Plugin registrations are closed after activation");
48
+ const contributionName = name(rawName);
49
+ if (stores[kind].has(contributionName)) throw new Error("Duplicate " + kind + " contribution: " + contributionName);
50
+ stores[kind].set(contributionName, { value, metadata });
51
+ let active = true;
52
+ return Object.freeze(function disposeRegistration() {
53
+ if (!active) return;
54
+ active = false;
55
+ stores[kind].delete(contributionName);
56
+ });
57
+ };
58
+ const context = Object.freeze({
59
+ signal,
60
+ config,
61
+ logger: Object.freeze({ debug() {}, info() {}, warn() {}, error() {} }),
62
+ services: Object.freeze({ filesystem: Object.freeze({
63
+ async readFile() { throw new Error("Filesystem read is not available in sandbox"); },
64
+ async writeFile() { throw new Error("Filesystem write is not available in sandbox"); },
65
+ }) }),
66
+ registerCommand(rawName, handler, description) {
67
+ if (typeof handler !== "function") throw new Error("Sandbox command handler must be a function");
68
+ return register("command", rawName, handler, { description: typeof description === "string" ? description : undefined });
69
+ },
70
+ registerTool(rawName, tool) {
71
+ if (!tool || typeof tool !== "object" || typeof tool.execute !== "function") throw new Error("Sandbox tool must provide execute(input, signal, context)");
72
+ return register("tool", rawName, tool, {
73
+ toolName: typeof tool.name === "string" ? tool.name : String(rawName),
74
+ description: typeof tool.description === "string" ? tool.description : "Plugin tool " + String(rawName),
75
+ modelInputSchema: cloneJson(tool.modelInputSchema), readOnly: tool.readOnly === true,
76
+ });
77
+ },
78
+ registerHook(rawName, handler, options) {
79
+ if (typeof handler !== "function") throw new Error("Sandbox hook handler must be a function");
80
+ return register("hook", rawName, handler, { options: cloneJson(options) });
81
+ },
82
+ registerSkillRoot(rawName, root) {
83
+ if (typeof root !== "string") throw new Error("Sandbox skill root must be a string");
84
+ return register("skillRoot", rawName, root, { root });
85
+ },
86
+ registerModelAdapter(rawName, adapter) {
87
+ if (!adapter || typeof adapter.stream !== "function") throw new Error("Sandbox model adapter must provide stream(request)");
88
+ return register("modelAdapter", rawName, adapter, {});
89
+ },
90
+ });
91
+ const describe = () => ({
92
+ commands: [...stores.command].map(([entryName, entry]) => ({ name: entryName, ...entry.metadata })),
93
+ tools: [...stores.tool].map(([entryName, entry]) => ({ name: entryName, ...entry.metadata })),
94
+ hooks: [...stores.hook].map(([entryName, entry]) => ({ name: entryName, ...entry.metadata })),
95
+ skillRoots: [...stores.skillRoot].map(([entryName, entry]) => ({ name: entryName, ...entry.metadata })),
96
+ modelAdapters: [...stores.modelAdapter].map(([entryName]) => ({ name: entryName })),
97
+ });
98
+ const invoke = async (kind, entryName, args) => {
99
+ const entry = stores[kind]?.get(entryName);
100
+ if (!entry) throw new Error("Unknown sandbox contribution: " + kind + ":" + entryName);
101
+ if (kind === "command") return entry.value(args[0], Object.freeze({ ...(args[1] || {}), signal }));
102
+ if (kind === "tool") return entry.value.execute(args[0], signal, args[1]);
103
+ if (kind === "hook") return entry.value(args[0], signal);
104
+ if (kind === "modelAdapter") {
105
+ const events = [];
106
+ for await (const event of entry.value.stream(args[0])) events.push(event);
107
+ return events;
108
+ }
109
+ throw new Error("Unsupported sandbox invocation kind: " + kind);
110
+ };
111
+ globalThis.__flavorSandbox = Object.freeze({
112
+ async activate(fn) {
113
+ const result = await fn(context);
114
+ if (result !== undefined && typeof result !== "function") throw new Error("Plugin activate result must be a disposer or undefined");
115
+ deactivate = result;
116
+ accepting = false;
117
+ return JSON.stringify(describe());
118
+ },
119
+ async invokeJson(kind, entryName, argsJson) {
120
+ try { return JSON.stringify({ ok: true, value: await invoke(kind, entryName, JSON.parse(argsJson)) }); }
121
+ catch (error) { return JSON.stringify({ ok: false, error: error instanceof Error ? error.message : String(error) }); }
122
+ },
123
+ async shutdown() { if (deactivate) await deactivate(); deactivate = undefined; },
124
+ });
125
+ })();`;
126
+ async function loadPlugin(pluginRoot, entryPath) {
127
+ const context = createContext(/* @__PURE__ */ Object.create(null), {
128
+ name: `flavor-plugin:${data.pluginName}`,
129
+ codeGeneration: { strings: false, wasm: false }
130
+ });
131
+ context.__flavorConfigJson = data.configJson;
132
+ runInContext(SANDBOX_BOOTSTRAP, context, { timeout: 1e3 });
133
+ const modules = /* @__PURE__ */ new Map();
134
+ const getModule = async (input) => {
135
+ const physical = await realpath(input);
136
+ assertContained(pluginRoot, physical);
137
+ const existing = modules.get(physical);
138
+ if (existing !== void 0) return existing;
139
+ const source = await readFile(physical, "utf8");
140
+ if (Buffer.byteLength(source) > MAX_MODULE_BYTES) throw new Error(`Plugin module exceeds ${MAX_MODULE_BYTES} bytes`);
141
+ const module = new SourceTextModule(source, {
142
+ context,
143
+ identifier: pathToFileURL(physical).href,
144
+ initializeImportMeta(meta) {
145
+ meta.url = pathToFileURL(physical).href;
146
+ },
147
+ importModuleDynamically: async (specifier, referencingModule) => {
148
+ const imported = await resolveModule(specifier, referencingModule);
149
+ if (imported.status === "unlinked") await imported.link(linker);
150
+ if (imported.status === "linked") await imported.evaluate();
151
+ return imported;
152
+ }
153
+ });
154
+ modules.set(physical, module);
155
+ return module;
156
+ };
157
+ const resolveModule = async (specifier, referencingModule) => {
158
+ if (!specifier.startsWith("./") && !specifier.startsWith("../")) throw new Error(`Sandbox blocks external module import: ${specifier}`);
159
+ return getModule(resolve(fileURLToPath(referencingModule.identifier), "..", specifier));
160
+ };
161
+ const linker = (specifier, referencingModule) => resolveModule(specifier, referencingModule);
162
+ const entry = await getModule(entryPath);
163
+ await entry.link(linker);
164
+ await entry.evaluate();
165
+ const activate = entry.namespace.activate;
166
+ if (typeof activate !== "function") throw new Error("Plugin entry must export activate(context)");
167
+ context.__flavorActivate = activate;
168
+ const contributionsJson = await runInContext(
169
+ "globalThis.__flavorSandbox.activate(globalThis.__flavorActivate)",
170
+ context
171
+ );
172
+ return { context, contributions: JSON.parse(contributionsJson) };
173
+ }
174
+ async function main() {
175
+ const pluginRoot = await realpath(data.pluginRoot);
176
+ assertContained(pluginRoot, await realpath(data.entryPath));
177
+ const loaded = await loadPlugin(pluginRoot, data.entryPath);
178
+ const { contributions } = loaded;
179
+ const result = {
180
+ ok: true,
181
+ name: data.pluginName,
182
+ version: data.pluginVersion,
183
+ registeredTools: contributions.tools.map(({ name }) => name),
184
+ registeredCommands: contributions.commands.map(({ name }) => name),
185
+ registeredHooks: contributions.hooks.map(({ name }) => name),
186
+ registeredSkillRoots: contributions.skillRoots.map(({ name }) => name),
187
+ registeredModelAdapters: contributions.modelAdapters.map(({ name }) => name),
188
+ contributions
189
+ };
190
+ send({ type: "ready", result });
191
+ port.on("message", (raw) => {
192
+ void handleMessage(raw, loaded.context);
193
+ });
194
+ clearInterval(activationKeepAlive);
195
+ }
196
+ async function handleMessage(raw, context) {
197
+ if (typeof raw !== "object" || raw === null || !("type" in raw)) {
198
+ send({ type: "fatal", error: "Invalid sandbox parent message" });
199
+ return;
200
+ }
201
+ const message = raw;
202
+ if (message.type === "shutdown") {
203
+ try {
204
+ await runInContext("globalThis.__flavorSandbox.shutdown()", context);
205
+ send({ type: "disposed" });
206
+ } catch (error) {
207
+ send({ type: "fatal", error: `Plugin sandbox shutdown failed: ${errorMessage(error)}` });
208
+ }
209
+ return;
210
+ }
211
+ if (message.type !== "invoke" || !Number.isSafeInteger(message.id) || typeof message.name !== "string" || typeof message.argsJson !== "string" || !["command", "tool", "hook", "modelAdapter"].includes(message.kind)) {
212
+ send({ type: "fatal", error: "Invalid sandbox invocation message" });
213
+ return;
214
+ }
215
+ context.__flavorKind = message.kind;
216
+ context.__flavorName = message.name;
217
+ context.__flavorArgs = message.argsJson;
218
+ try {
219
+ const responseJson = await runInContext(
220
+ "globalThis.__flavorSandbox.invokeJson(globalThis.__flavorKind, globalThis.__flavorName, globalThis.__flavorArgs)",
221
+ context
222
+ );
223
+ const response = JSON.parse(responseJson);
224
+ if (response.ok) send({ type: "response", id: message.id, ok: true, valueJson: response.value === void 0 ? "null" : JSON.stringify(response.value) });
225
+ else send({ type: "response", id: message.id, ok: false, error: response.error ?? "Sandbox invocation failed" });
226
+ } catch (error) {
227
+ send({ type: "response", id: message.id, ok: false, error: errorMessage(error) });
228
+ }
229
+ }
230
+ main().catch((error) => {
231
+ clearInterval(activationKeepAlive);
232
+ send({ type: "fatal", error: errorMessage(error) });
233
+ });
@@ -1,8 +1,7 @@
1
1
  import type { LoadedPlugin, PluginDiagnostic, PluginHostOptions } from "./types.js";
2
2
  /**
3
- * Hosts trusted in-process plugins behind a narrow host API. Plugin roots must remain immutable
4
- * during activation. Concurrent malicious mutation is outside the MVP trust model because plugin
5
- * code already has Node.js authority; this is explicitly not a process sandbox.
3
+ * Hosts plugins behind a narrow host API. The default backend loads trusted plugins in-process;
4
+ * sandbox mode uses an isolated Worker/vm realm and RPC-backed contributions.
6
5
  */
7
6
  export declare class PluginHost {
8
7
  #private;
@@ -0,0 +1,72 @@
1
+ export type SandboxContributionKind = "command" | "tool" | "hook" | "modelAdapter";
2
+ export interface SandboxCommandRegistration {
3
+ name: string;
4
+ description?: string;
5
+ }
6
+ export interface SandboxToolRegistration {
7
+ name: string;
8
+ toolName: string;
9
+ description: string;
10
+ modelInputSchema?: Record<string, unknown>;
11
+ readOnly?: boolean;
12
+ }
13
+ export interface SandboxHookRegistration {
14
+ name: string;
15
+ options?: {
16
+ timeoutMs?: number;
17
+ failurePolicy?: "error" | "allow" | "deny" | "ask";
18
+ };
19
+ }
20
+ export interface SandboxSkillRootRegistration {
21
+ name: string;
22
+ root: string;
23
+ }
24
+ export interface SandboxPluginContributions {
25
+ commands: SandboxCommandRegistration[];
26
+ tools: SandboxToolRegistration[];
27
+ hooks: SandboxHookRegistration[];
28
+ skillRoots: SandboxSkillRootRegistration[];
29
+ modelAdapters: {
30
+ name: string;
31
+ }[];
32
+ }
33
+ export interface SandboxedPluginResult {
34
+ ok: boolean;
35
+ name: string;
36
+ version: string;
37
+ registeredTools: string[];
38
+ registeredCommands: string[];
39
+ registeredHooks: string[];
40
+ registeredSkillRoots: string[];
41
+ registeredModelAdapters: string[];
42
+ contributions: SandboxPluginContributions;
43
+ error?: string;
44
+ }
45
+ export type SandboxParentMessage = {
46
+ type: "invoke";
47
+ id: number;
48
+ kind: SandboxContributionKind;
49
+ name: string;
50
+ argsJson: string;
51
+ } | {
52
+ type: "shutdown";
53
+ };
54
+ export type SandboxWorkerMessage = {
55
+ type: "ready";
56
+ result: SandboxedPluginResult;
57
+ } | {
58
+ type: "response";
59
+ id: number;
60
+ ok: true;
61
+ valueJson: string;
62
+ } | {
63
+ type: "response";
64
+ id: number;
65
+ ok: false;
66
+ error: string;
67
+ } | {
68
+ type: "disposed";
69
+ } | {
70
+ type: "fatal";
71
+ error: string;
72
+ };
@@ -10,6 +10,9 @@ export declare const PluginManifestSchema: z.ZodObject<{
10
10
  permissions: z.ZodArray<z.ZodEnum<{
11
11
  "filesystem:read": "filesystem:read";
12
12
  "filesystem:write": "filesystem:write";
13
+ network: "network";
14
+ process: "process";
15
+ "runtime:in-process": "runtime:in-process";
13
16
  }>>;
14
17
  contributes: z.ZodObject<{
15
18
  commands: z.ZodArray<z.ZodObject<{
@@ -74,8 +77,9 @@ export interface PluginCommandContext {
74
77
  }
75
78
  export type PluginCommandHandler = (args: readonly string[], context: PluginCommandContext) => unknown | Promise<unknown>;
76
79
  /**
77
- * A deliberately narrow registration surface. Plugins run in-process and are trusted in the
78
- * MVP: this API mediates host-provided capabilities, but it is not a Node.js process sandbox.
80
+ * A deliberately narrow registration surface. Production runs plugins in an
81
+ * isolated Worker/vm realm by default. Hosts that explicitly opt into legacy
82
+ * in-process activation must treat the plugin as fully trusted Node.js code.
79
83
  */
80
84
  export interface PluginContext {
81
85
  readonly signal: AbortSignal;
@@ -107,6 +111,18 @@ export interface LoadedPlugin {
107
111
  readonly version: string;
108
112
  readonly source: PluginSource;
109
113
  readonly root: string;
114
+ readonly fingerprint: string;
115
+ readonly sandboxed: boolean;
116
+ readonly permissions: readonly PluginPermission[];
117
+ }
118
+ export interface PluginTrustRequest {
119
+ readonly name: string;
120
+ readonly version: string;
121
+ readonly source: PluginSource;
122
+ readonly root: string;
123
+ readonly fingerprint: string;
124
+ readonly sandboxed: boolean;
125
+ readonly permissions: readonly PluginPermission[];
110
126
  }
111
127
  export interface PluginRegistrationCallbacks {
112
128
  command(name: string, command: PluginCommandHandler, description?: string): PluginDisposer;
@@ -134,4 +150,11 @@ export interface PluginHostOptions {
134
150
  emitLifecycle?: (type: "PluginLoad" | "PluginUnload", plugin: LoadedPlugin) => void | Promise<void>;
135
151
  activationTimeoutMs?: number;
136
152
  unloadTimeoutMs?: number;
153
+ /** When true, plugin modules run in an isolated Worker/vm realm. Only relative
154
+ * modules inside the plugin root and RPC-backed contribution calls are available. */
155
+ sandbox?: boolean;
156
+ /** Trust gate evaluated against the content fingerprint before activation. */
157
+ authorizePlugin?: (request: PluginTrustRequest) => boolean | Promise<boolean>;
158
+ /** Legacy in-process execution requires both a manifest capability and trust approval. */
159
+ requireInProcessTrust?: boolean;
137
160
  }
@@ -0,0 +1,19 @@
1
+ import type { SandboxedPluginResult, SandboxContributionKind } from "./sandbox-protocol.js";
2
+ export type { SandboxedPluginResult } from "./sandbox-protocol.js";
3
+ export interface PluginWorkerOptions {
4
+ entryPath: string;
5
+ pluginRoot?: string;
6
+ pluginName: string;
7
+ pluginVersion: string;
8
+ config?: unknown;
9
+ activationTimeoutMs?: number;
10
+ invocationTimeoutMs?: number;
11
+ maxOldSpaceMb?: number;
12
+ }
13
+ export interface SandboxedPluginSession {
14
+ readonly result: SandboxedPluginResult;
15
+ invoke<T>(kind: SandboxContributionKind, name: string, args: readonly unknown[]): Promise<T>;
16
+ dispose(): Promise<void>;
17
+ }
18
+ export declare function startPluginSandbox(options: PluginWorkerOptions): Promise<SandboxedPluginSession>;
19
+ export declare function runPluginInSandbox(options: PluginWorkerOptions): Promise<SandboxedPluginResult>;
@@ -37,6 +37,9 @@ export interface ProductionRuntimeOptions {
37
37
  shutdownStepTimeoutMs?: number;
38
38
  /** Additional tools provided by embedders (e.g. desktop-only D2C tools). */
39
39
  extraTools?: readonly ToolDefinition<unknown>[];
40
+ /** Compatibility seam for explicitly trusted legacy plugins. Product
41
+ * runtimes default to Worker/vm isolation. */
42
+ pluginSandbox?: boolean;
40
43
  /** Explicitly opt into CLI-local collaboration. Omit for print/RPC/eval callers. */
41
44
  collaboration?: {
42
45
  instanceId: string;
package/dist/sdk/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  FlavorRpcServer,
5
5
  TraceRecordSchema,
6
6
  TraceRecorder
7
- } from "../chunk-JB57IX2A.js";
7
+ } from "../chunk-IX65GYUF.js";
8
8
  import {
9
9
  AgentMessageQueue,
10
10
  DockerExecutionEnvironment,
@@ -13,7 +13,7 @@ import {
13
13
  WorkspaceCheckpointStore,
14
14
  buildDockerInvocation,
15
15
  createProductionRuntime
16
- } from "../chunk-STZQ3Y3P.js";
16
+ } from "../chunk-KL4UHJ2Q.js";
17
17
  import "../chunk-IG4Z23CL.js";
18
18
  import "../chunk-RQTYHUMK.js";
19
19
  import "../chunk-S32JRDZK.js";
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { type TranscriptState } from "../ui/transcript.js";
3
3
  import type { ModelContent } from "../models/types.js";
4
- export declare const SESSION_VERSION: 3;
4
+ export declare const SESSION_VERSION: 4;
5
5
  export declare const DEFAULT_MAX_SESSION_BYTES: number;
6
6
  export declare const SessionDocumentSchema: z.ZodObject<{
7
7
  sessionId: z.ZodString;
@@ -93,12 +93,31 @@ export declare const SessionDocumentSchema: z.ZodObject<{
93
93
  finalizedAt: z.ZodOptional<z.ZodString>;
94
94
  transcriptHash: z.ZodOptional<z.ZodString>;
95
95
  }, z.core.$strict>>;
96
- version: z.ZodLiteral<3>;
96
+ version: z.ZodLiteral<4>;
97
97
  conversation: z.ZodObject<{
98
98
  compact: z.ZodOptional<z.ZodObject<{
99
99
  summary: z.ZodString;
100
100
  compactedAt: z.ZodString;
101
101
  }, z.core.$strict>>;
102
+ epoch: z.ZodOptional<z.ZodObject<{
103
+ version: z.ZodLiteral<1>;
104
+ id: z.ZodString;
105
+ startedAt: z.ZodString;
106
+ stableMessages: z.ZodArray<z.ZodObject<{
107
+ role: z.ZodLiteral<"system">;
108
+ content: z.ZodString;
109
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
110
+ }, z.core.$strict>>;
111
+ sources: z.ZodRecord<z.ZodString, z.ZodString>;
112
+ stableSourceHash: z.ZodString;
113
+ }, z.core.$strict>>;
114
+ visibilityLog: z.ZodOptional<z.ZodArray<z.ZodObject<{
115
+ id: z.ZodString;
116
+ role: z.ZodLiteral<"system">;
117
+ content: z.ZodString;
118
+ admittedAt: z.ZodString;
119
+ scope: z.ZodLiteral<"run">;
120
+ }, z.core.$strict>>>;
102
121
  messages: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
103
122
  toolCallId: z.ZodOptional<z.ZodString>;
104
123
  toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -108,6 +127,15 @@ export declare const SessionDocumentSchema: z.ZodObject<{
108
127
  }, z.core.$strict>>>;
109
128
  role: z.ZodLiteral<"user">;
110
129
  content: z.ZodType<ModelContent, unknown, z.core.$ZodTypeInternals<ModelContent, unknown>>;
130
+ }, z.core.$strict>, z.ZodObject<{
131
+ toolCallId: z.ZodOptional<z.ZodString>;
132
+ toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
133
+ id: z.ZodString;
134
+ name: z.ZodString;
135
+ input: z.ZodUnknown;
136
+ }, z.core.$strict>>>;
137
+ role: z.ZodLiteral<"system">;
138
+ content: z.ZodString;
111
139
  }, z.core.$strict>, z.ZodObject<{
112
140
  toolCallId: z.ZodOptional<z.ZodString>;
113
141
  toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Expand the portable argument placeholders used by Claude-style Agent Skills.
3
+ * Flavor still passes the original argument text as the user prompt; expansion
4
+ * makes the skill body itself equivalent across hosts and is especially useful
5
+ * when one skill loads another through the Skill tool.
6
+ */
7
+ export declare function expandSkillArguments(body: string, argumentsText: string): string;
8
+ export declare function splitSkillArguments(input: string): string[];
@@ -1,9 +1,14 @@
1
1
  import { z } from "zod";
2
2
  import type { ToolDefinition } from "../tools/types.js";
3
3
  import type { SkillRegistry } from "./registry.js";
4
+ declare const SkillInput: z.ZodObject<{
5
+ skill: z.ZodString;
6
+ arguments: z.ZodOptional<z.ZodString>;
7
+ }, z.core.$strict>;
4
8
  declare const SkillResourceInput: z.ZodObject<{
5
9
  skill: z.ZodString;
6
10
  reference: z.ZodString;
7
11
  }, z.core.$strict>;
12
+ export declare function createSkillTool(registry: SkillRegistry): ToolDefinition<z.infer<typeof SkillInput>>;
8
13
  export declare function createSkillResourceTool(registry: SkillRegistry): ToolDefinition<z.infer<typeof SkillResourceInput>>;
9
14
  export {};
@@ -20,6 +20,11 @@ export interface ToolRuntimeOptions {
20
20
  /** Inline tool-result content budgets. */
21
21
  outputLimits?: Partial<ToolOutputLimits>;
22
22
  afterSuccess?(tool: string, paths: readonly string[], input: unknown, output: unknown, context: ToolContext): Promise<readonly string[]>;
23
+ journal?: {
24
+ start(tool: string, input: unknown, retrySafe: boolean): string;
25
+ complete(id: string, result: ToolResult): void;
26
+ interrupt(id: string, reason: string): void;
27
+ };
23
28
  }
24
29
  export interface ToolOutputLimits {
25
30
  perToolChars: number;
@@ -91,6 +91,9 @@ export interface ToolDefinition<T, O = unknown> {
91
91
  modelStrict?: boolean;
92
92
  /** Declared read-only: allowed without approval, same as Read/Glob/Grep (including plan mode). */
93
93
  readOnly?: boolean;
94
+ /** Explicitly safe to retry after an interrupted process. Defaults to false;
95
+ * read-only tools are treated as retry-safe by the durable harness. */
96
+ retrySafe?: boolean;
94
97
  paths(input: T): string[];
95
98
  /**
96
99
  * Optional short human-readable parameter summary, rendered dimmed next to the tool name.
@@ -101,6 +101,7 @@ export interface SessionServices {
101
101
  subagentModel(): string;
102
102
  llmServiceName?(): string | undefined;
103
103
  permissionMode(): PermissionMode;
104
+ addContext?(content: string): void | Promise<void>;
104
105
  run(prompt: string, signal: AbortSignal, options?: {
105
106
  getSteeringMessages(): readonly string[];
106
107
  initialUserMessage?: Extract<ModelMessage, {
@@ -155,6 +156,17 @@ export interface SessionServices {
155
156
  login(): Promise<string>;
156
157
  logout(): Promise<string>;
157
158
  pals?: PalSessionServices;
159
+ durableQueue?: {
160
+ recover(): readonly {
161
+ id: string;
162
+ kind: "steer" | "followUp";
163
+ payload: unknown;
164
+ }[];
165
+ admit(kind: "steer" | "followUp", payload: unknown): string;
166
+ claim(id: string): void;
167
+ ack(id: string): void;
168
+ release(id: string, reason: string): void;
169
+ };
158
170
  }
159
171
  export interface MultimodalSessionInput {
160
172
  text: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flavor-code",
3
- "version": "1.2.18",
3
+ "version": "1.3.0",
4
4
  "author": "YachuanWzh",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -44,7 +44,8 @@
44
44
  "desktop:start": "npm run build && electron .",
45
45
  "desktop:pack": "npm run build && electron-builder --win --dir",
46
46
  "desktop:dist": "npm run build && electron-builder --win nsis",
47
- "test": "vitest run",
47
+ "test": "vitest run",
48
+ "test:reliability": "vitest run tests/harness/journal.test.ts tests/context/manager.test.ts tests/session/store.test.ts tests/permissions/policy.test.ts tests/goal/classifier.test.ts tests/goal/orchestrator.test.ts",
48
49
  "test:watch": "vitest",
49
50
  "test:desktop:e2e": "npm run build:desktop && node tests/desktop/electron-app.e2e.mjs",
50
51
  "typecheck": "tsc --noEmit",
@@ -56,9 +57,10 @@
56
57
  "appId": "dev.flavorcode.desktop",
57
58
  "productName": "Flavor Code",
58
59
  "asar": true,
59
- "asarUnpack": [
60
- "dist/desktop/pixel-worker.js"
61
- ],
60
+ "asarUnpack": [
61
+ "dist/desktop/pixel-worker.js",
62
+ "dist/desktop/plugin-worker-entry.js"
63
+ ],
62
64
  "icon": "assets/icon",
63
65
  "directories": {
64
66
  "output": "release"