@executor-js/config 0.0.2 → 0.2.1

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/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- export { ExecutorFileConfig, SourceConfig, OpenApiSourceConfig, GraphqlSourceConfig, McpRemoteSourceConfig, McpStdioSourceConfig, McpAuthConfig, SecretMetadata, ConfigHeaderValue, SECRET_REF_PREFIX, } from "./schema";
1
+ export { ExecutorFileConfig, PluginConfig, SourceConfig, OpenApiSourceConfig, GraphqlSourceConfig, McpRemoteSourceConfig, McpStdioSourceConfig, McpAuthConfig, SecretMetadata, ConfigHeaderValue, SECRET_REF_PREFIX, } from "./schema";
2
2
  export { loadConfig, ConfigParseError } from "./load";
3
+ export { loadPluginsFromJsonc } from "./load-plugins";
4
+ export type { LoadPluginsFromJsoncOptions } from "./load-plugins";
3
5
  export { addSourceToConfig, removeSourceFromConfig, writeConfig, addSecretToConfig, removeSecretFromConfig, } from "./write";
4
6
  export type { ConfigFileSink, ConfigFileSinkOptions } from "./sink";
5
- export { makeFileConfigSink, headerToConfigValue, headersToConfigValues, } from "./sink";
7
+ export { makeFileConfigSink, headerToConfigValue, headersToConfigValues } from "./sink";
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAEtD,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,WAAW,EACX,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,WAAW,EACX,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC"}
package/dist/index.js CHANGED
@@ -72,9 +72,14 @@ var SecretMetadata = Schema.Struct({
72
72
  provider: Schema.optional(Schema.String),
73
73
  purpose: Schema.optional(Schema.String)
74
74
  });
75
+ var PluginConfig = Schema.Struct({
76
+ package: Schema.String,
77
+ options: Schema.optional(Schema.Record(Schema.String, Schema.Unknown))
78
+ });
75
79
  var ExecutorFileConfig = Schema.Struct({
76
80
  $schema: Schema.optional(Schema.String),
77
81
  name: Schema.optional(Schema.String),
82
+ plugins: Schema.optional(Schema.Array(PluginConfig)),
78
83
  sources: Schema.optional(Schema.Array(SourceConfig)),
79
84
  secrets: Schema.optional(Schema.Record(Schema.String, SecretMetadata))
80
85
  });
@@ -83,36 +88,129 @@ var ExecutorFileConfig = Schema.Struct({
83
88
  import { Effect, Schema as Schema2 } from "effect";
84
89
  import { FileSystem } from "effect";
85
90
  import * as jsonc from "jsonc-parser";
86
- var ConfigParseError = class {
87
- constructor(path, message) {
88
- this.path = path;
89
- this.message = message;
91
+ var ConfigParseError = class extends Schema2.TaggedErrorClass()(
92
+ "ConfigParseError",
93
+ {
94
+ path: Schema2.String,
95
+ message: Schema2.String
90
96
  }
91
- path;
92
- message;
93
- _tag = "ConfigParseError";
97
+ ) {
94
98
  };
95
99
  var loadConfig = (path) => Effect.gen(function* () {
96
- const fs = yield* FileSystem.FileSystem;
97
- const exists = yield* fs.exists(path);
100
+ const fs2 = yield* FileSystem.FileSystem;
101
+ const exists = yield* fs2.exists(path);
98
102
  if (!exists) return null;
99
- const raw = yield* fs.readFileString(path);
103
+ const raw = yield* fs2.readFileString(path);
100
104
  const errors = [];
101
105
  const parsed = jsonc.parse(raw, errors);
102
106
  if (errors.length > 0) {
103
107
  const msg = errors.map((e) => `offset ${e.offset}: ${jsonc.printParseErrorCode(e.error)}`).join("; ");
104
- return yield* Effect.fail(new ConfigParseError(path, msg));
108
+ return yield* new ConfigParseError({ path, message: msg });
105
109
  }
106
110
  const decoded = yield* Schema2.decodeUnknownEffect(ExecutorFileConfig)(parsed).pipe(
107
- Effect.mapError((e) => new ConfigParseError(path, String(e)))
111
+ Effect.mapError(
112
+ (error) => new ConfigParseError({
113
+ path,
114
+ message: error.issue.toString()
115
+ })
116
+ )
108
117
  );
109
118
  return decoded;
110
119
  });
111
120
 
121
+ // src/load-plugins.ts
122
+ import { createRequire } from "module";
123
+ import { dirname, isAbsolute, resolve as resolvePath } from "path";
124
+ import { pathToFileURL } from "url";
125
+ import * as fs from "fs";
126
+ import * as jsonc2 from "jsonc-parser";
127
+ import { Effect as Effect2, Schema as Schema3 } from "effect";
128
+ var LoadPluginsError = class extends Schema3.TaggedErrorClass()(
129
+ "LoadPluginsError",
130
+ {
131
+ message: Schema3.String,
132
+ cause: Schema3.optional(Schema3.Unknown)
133
+ }
134
+ ) {
135
+ };
136
+ var loadPluginsFromJsonc = async (options) => Effect2.runPromise(loadPluginsFromJsoncEffect(options));
137
+ var loadPluginsFromJsoncEffect = (options) => Effect2.gen(function* () {
138
+ const { path, deps } = options;
139
+ if (!fs.existsSync(path)) return null;
140
+ const raw = fs.readFileSync(path, "utf8");
141
+ const errors = [];
142
+ const parsed = jsonc2.parse(raw, errors);
143
+ if (errors.length > 0) {
144
+ const msg = errors.map((e) => `offset ${e.offset}: ${jsonc2.printParseErrorCode(e.error)}`).join("; ");
145
+ return yield* new LoadPluginsError({
146
+ message: `[load-plugins] failed to parse ${path}: ${msg}`
147
+ });
148
+ }
149
+ const config = yield* Schema3.decodeUnknownEffect(ExecutorFileConfig)(parsed).pipe(
150
+ Effect2.mapError(
151
+ (error) => new LoadPluginsError({
152
+ message: `[load-plugins] failed to decode ${path}: ${error.issue.toString()}`,
153
+ cause: error
154
+ })
155
+ )
156
+ );
157
+ const entries = config.plugins ?? null;
158
+ if (!entries || entries.length === 0) return null;
159
+ const { createJiti } = yield* Effect2.tryPromise({
160
+ try: () => import("jiti"),
161
+ catch: (cause) => new LoadPluginsError({
162
+ message: `[load-plugins] failed to import jiti.`,
163
+ cause
164
+ })
165
+ });
166
+ const jiti = createJiti(pathToFileURL(path).href, {
167
+ interopDefault: true,
168
+ moduleCache: false
169
+ });
170
+ const fromDir = dirname(path);
171
+ const require2 = createRequire(isAbsolute(path) ? path : resolvePath(fromDir, "_anchor.js"));
172
+ const loaded = [];
173
+ for (const entry of entries) {
174
+ const serverEntry = `${entry.package}/server`;
175
+ const resolved = yield* Effect2.try({
176
+ try: () => require2.resolve(serverEntry),
177
+ catch: (cause) => new LoadPluginsError({
178
+ message: `[load-plugins] cannot resolve "${serverEntry}" from ${fromDir}. Is "${entry.package}" installed and does it export "./server"?`,
179
+ cause
180
+ })
181
+ });
182
+ const mod = yield* Effect2.tryPromise({
183
+ try: () => jiti.import(resolved),
184
+ catch: (cause) => new LoadPluginsError({
185
+ message: `[load-plugins] failed to import "${serverEntry}" from ${resolved}.`,
186
+ cause
187
+ })
188
+ });
189
+ const factory = typeof mod === "function" ? mod : mod.default ?? null;
190
+ if (!factory || typeof factory !== "function") {
191
+ return yield* new LoadPluginsError({
192
+ message: `[load-plugins] "${serverEntry}" did not export a default definePlugin(...) factory.`
193
+ });
194
+ }
195
+ const merged = { ...deps ?? {}, ...entry.options ?? {} };
196
+ loaded.push(factory(merged));
197
+ }
198
+ return loaded;
199
+ });
200
+
112
201
  // src/write.ts
113
- import { Effect as Effect2 } from "effect";
202
+ import { Effect as Effect3 } from "effect";
114
203
  import { FileSystem as FileSystem2 } from "effect";
115
- import * as jsonc2 from "jsonc-parser";
204
+ import * as jsonc3 from "jsonc-parser";
205
+ var ConfigWriteError = class {
206
+ constructor(path, cause) {
207
+ this.path = path;
208
+ this.cause = cause;
209
+ }
210
+ path;
211
+ cause;
212
+ _tag = "ConfigWriteError";
213
+ };
116
214
  var FORMATTING = {
117
215
  tabSize: 2,
118
216
  insertSpaces: true,
@@ -122,98 +220,98 @@ var DEFAULT_CONFIG = `{
122
220
  "sources": []
123
221
  }
124
222
  `;
125
- var readOrCreate = (fs, path) => Effect2.gen(function* () {
126
- const exists = yield* fs.exists(path);
127
- if (exists) return yield* fs.readFileString(path);
128
- yield* fs.writeFileString(path, DEFAULT_CONFIG);
223
+ var readOrCreate = (fs2, path) => Effect3.gen(function* () {
224
+ const exists = yield* fs2.exists(path);
225
+ if (exists) return yield* fs2.readFileString(path);
226
+ yield* fs2.writeFileString(path, DEFAULT_CONFIG);
129
227
  return DEFAULT_CONFIG;
130
228
  });
131
- var addSourceToConfig = (path, source) => Effect2.gen(function* () {
132
- const fs = yield* FileSystem2.FileSystem;
133
- let text = yield* readOrCreate(fs, path);
134
- let tree = jsonc2.parseTree(text);
135
- let sourcesNode = tree ? jsonc2.findNodeAtLocation(tree, ["sources"]) : void 0;
229
+ var addSourceToConfig = (path, source) => Effect3.gen(function* () {
230
+ const fs2 = yield* FileSystem2.FileSystem;
231
+ let text = yield* readOrCreate(fs2, path);
232
+ let tree = jsonc3.parseTree(text);
233
+ let sourcesNode = tree ? jsonc3.findNodeAtLocation(tree, ["sources"]) : void 0;
136
234
  if (!sourcesNode) {
137
- const edits = jsonc2.modify(text, ["sources"], [source], {
235
+ const edits = jsonc3.modify(text, ["sources"], [source], {
138
236
  formattingOptions: FORMATTING
139
237
  });
140
- text = jsonc2.applyEdits(text, edits);
238
+ text = jsonc3.applyEdits(text, edits);
141
239
  } else {
142
240
  const ns = "namespace" in source ? source.namespace : void 0;
143
241
  if (ns && sourcesNode.children) {
144
242
  for (let i = sourcesNode.children.length - 1; i >= 0; i--) {
145
243
  const child = sourcesNode.children[i];
146
- const nsNode = jsonc2.findNodeAtLocation(child, ["namespace"]);
147
- if (nsNode && jsonc2.getNodeValue(nsNode) === ns) {
148
- const edits2 = jsonc2.modify(text, ["sources", i], void 0, {
244
+ const nsNode = jsonc3.findNodeAtLocation(child, ["namespace"]);
245
+ if (nsNode && jsonc3.getNodeValue(nsNode) === ns) {
246
+ const edits2 = jsonc3.modify(text, ["sources", i], void 0, {
149
247
  formattingOptions: FORMATTING
150
248
  });
151
- text = jsonc2.applyEdits(text, edits2);
249
+ text = jsonc3.applyEdits(text, edits2);
152
250
  }
153
251
  }
154
- tree = jsonc2.parseTree(text);
155
- sourcesNode = tree ? jsonc2.findNodeAtLocation(tree, ["sources"]) : void 0;
252
+ tree = jsonc3.parseTree(text);
253
+ sourcesNode = tree ? jsonc3.findNodeAtLocation(tree, ["sources"]) : void 0;
156
254
  }
157
255
  const count = sourcesNode?.children?.length ?? 0;
158
- const edits = jsonc2.modify(text, ["sources", count], source, {
256
+ const edits = jsonc3.modify(text, ["sources", count], source, {
159
257
  formattingOptions: FORMATTING
160
258
  });
161
- text = jsonc2.applyEdits(text, edits);
259
+ text = jsonc3.applyEdits(text, edits);
162
260
  }
163
- yield* fs.writeFileString(path, text);
261
+ yield* fs2.writeFileString(path, text);
164
262
  });
165
- var removeSourceFromConfig = (path, namespace) => Effect2.gen(function* () {
166
- const fs = yield* FileSystem2.FileSystem;
167
- const exists = yield* fs.exists(path);
263
+ var removeSourceFromConfig = (path, namespace) => Effect3.gen(function* () {
264
+ const fs2 = yield* FileSystem2.FileSystem;
265
+ const exists = yield* fs2.exists(path);
168
266
  if (!exists) return;
169
- let text = yield* fs.readFileString(path);
170
- const tree = jsonc2.parseTree(text);
267
+ let text = yield* fs2.readFileString(path);
268
+ const tree = jsonc3.parseTree(text);
171
269
  if (!tree) return;
172
- const sourcesNode = jsonc2.findNodeAtLocation(tree, ["sources"]);
270
+ const sourcesNode = jsonc3.findNodeAtLocation(tree, ["sources"]);
173
271
  if (!sourcesNode?.children) return;
174
272
  for (let i = sourcesNode.children.length - 1; i >= 0; i--) {
175
273
  const child = sourcesNode.children[i];
176
- const nsNode = jsonc2.findNodeAtLocation(child, ["namespace"]);
177
- if (nsNode && jsonc2.getNodeValue(nsNode) === namespace) {
178
- const edits = jsonc2.modify(text, ["sources", i], void 0, {
274
+ const nsNode = jsonc3.findNodeAtLocation(child, ["namespace"]);
275
+ if (nsNode && jsonc3.getNodeValue(nsNode) === namespace) {
276
+ const edits = jsonc3.modify(text, ["sources", i], void 0, {
179
277
  formattingOptions: FORMATTING
180
278
  });
181
- text = jsonc2.applyEdits(text, edits);
279
+ text = jsonc3.applyEdits(text, edits);
182
280
  }
183
281
  }
184
- yield* fs.writeFileString(path, text);
282
+ yield* fs2.writeFileString(path, text);
185
283
  });
186
- var writeConfig = (path, config) => Effect2.gen(function* () {
187
- const fs = yield* FileSystem2.FileSystem;
188
- const text = yield* Effect2.try({
284
+ var writeConfig = (path, config) => Effect3.gen(function* () {
285
+ const fs2 = yield* FileSystem2.FileSystem;
286
+ const text = yield* Effect3.try({
189
287
  try: () => JSON.stringify(config, null, 2) + "\n",
190
- catch: (cause) => cause
191
- }).pipe(Effect2.orDie);
192
- yield* fs.writeFileString(path, text);
288
+ catch: (cause) => new ConfigWriteError(path, cause)
289
+ });
290
+ yield* fs2.writeFileString(path, text);
193
291
  });
194
- var addSecretToConfig = (path, secretId, metadata) => Effect2.gen(function* () {
195
- const fs = yield* FileSystem2.FileSystem;
196
- let text = yield* readOrCreate(fs, path);
197
- const edits = jsonc2.modify(text, ["secrets", secretId], metadata, {
292
+ var addSecretToConfig = (path, secretId, metadata) => Effect3.gen(function* () {
293
+ const fs2 = yield* FileSystem2.FileSystem;
294
+ let text = yield* readOrCreate(fs2, path);
295
+ const edits = jsonc3.modify(text, ["secrets", secretId], metadata, {
198
296
  formattingOptions: FORMATTING
199
297
  });
200
- text = jsonc2.applyEdits(text, edits);
201
- yield* fs.writeFileString(path, text);
298
+ text = jsonc3.applyEdits(text, edits);
299
+ yield* fs2.writeFileString(path, text);
202
300
  });
203
- var removeSecretFromConfig = (path, secretId) => Effect2.gen(function* () {
204
- const fs = yield* FileSystem2.FileSystem;
205
- const exists = yield* fs.exists(path);
301
+ var removeSecretFromConfig = (path, secretId) => Effect3.gen(function* () {
302
+ const fs2 = yield* FileSystem2.FileSystem;
303
+ const exists = yield* fs2.exists(path);
206
304
  if (!exists) return;
207
- let text = yield* fs.readFileString(path);
208
- const edits = jsonc2.modify(text, ["secrets", secretId], void 0, {
305
+ let text = yield* fs2.readFileString(path);
306
+ const edits = jsonc3.modify(text, ["secrets", secretId], void 0, {
209
307
  formattingOptions: FORMATTING
210
308
  });
211
- text = jsonc2.applyEdits(text, edits);
212
- yield* fs.writeFileString(path, text);
309
+ text = jsonc3.applyEdits(text, edits);
310
+ yield* fs2.writeFileString(path, text);
213
311
  });
214
312
 
215
313
  // src/sink.ts
216
- import { Effect as Effect3 } from "effect";
314
+ import { Effect as Effect4 } from "effect";
217
315
  var headerToConfigValue = (value) => {
218
316
  if (typeof value === "string") return value;
219
317
  const ref = `${SECRET_REF_PREFIX}${value.secretId}`;
@@ -226,19 +324,18 @@ var headersToConfigValues = (headers) => {
226
324
  return out;
227
325
  };
228
326
  var defaultOnError = (op, err) => {
229
- const msg = err instanceof Error ? err.message : String(err);
230
- console.warn(`[config-sink] ${op} failed: ${msg}`);
327
+ console.warn(`[config-sink] ${op} failed`, err);
231
328
  };
232
329
  var makeFileConfigSink = (options) => {
233
330
  const { path, fsLayer, onError = defaultOnError } = options;
234
331
  return {
235
332
  upsertSource: (source) => addSourceToConfig(path, source).pipe(
236
- Effect3.provide(fsLayer),
237
- Effect3.catch((err) => Effect3.sync(() => onError("upsert", err)))
333
+ Effect4.provide(fsLayer),
334
+ Effect4.catch((err) => Effect4.sync(() => onError("upsert", err)))
238
335
  ),
239
336
  removeSource: (namespace) => removeSourceFromConfig(path, namespace).pipe(
240
- Effect3.provide(fsLayer),
241
- Effect3.catch((err) => Effect3.sync(() => onError("remove", err)))
337
+ Effect4.provide(fsLayer),
338
+ Effect4.catch((err) => Effect4.sync(() => onError("remove", err)))
242
339
  )
243
340
  };
244
341
  };
@@ -251,6 +348,7 @@ export {
251
348
  McpRemoteSourceConfig,
252
349
  McpStdioSourceConfig,
253
350
  OpenApiSourceConfig,
351
+ PluginConfig,
254
352
  SECRET_REF_PREFIX,
255
353
  SecretMetadata,
256
354
  SourceConfig,
@@ -259,6 +357,7 @@ export {
259
357
  headerToConfigValue,
260
358
  headersToConfigValues,
261
359
  loadConfig,
360
+ loadPluginsFromJsonc,
262
361
  makeFileConfigSink,
263
362
  removeSecretFromConfig,
264
363
  removeSourceFromConfig,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/schema.ts","../src/load.ts","../src/write.ts","../src/sink.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\n// ---------------------------------------------------------------------------\n// Header values\n//\n// Three forms:\n// \"static-value\" — literal string\n// \"secret-public-ref:my-token\" — secret reference (no prefix)\n// { value: \"secret-public-ref:x\", prefix } — secret reference with prefix\n// ---------------------------------------------------------------------------\n\nexport const SECRET_REF_PREFIX = \"secret-public-ref:\";\n\nexport const ConfigHeaderValue = Schema.Union([\n Schema.String,\n Schema.Struct({\n value: Schema.String,\n prefix: Schema.optional(Schema.String),\n }),\n]);\nexport type ConfigHeaderValue = typeof ConfigHeaderValue.Type;\n\nconst ConfigHeaders = Schema.Record(Schema.String, ConfigHeaderValue);\n\n// ---------------------------------------------------------------------------\n// Source configs — discriminated union on \"kind\"\n// ---------------------------------------------------------------------------\n\nexport const OpenApiSourceConfig = Schema.Struct({\n kind: Schema.Literal(\"openapi\"),\n spec: Schema.String,\n baseUrl: Schema.optional(Schema.String),\n namespace: Schema.optional(Schema.String),\n headers: Schema.optional(ConfigHeaders),\n});\nexport type OpenApiSourceConfig = typeof OpenApiSourceConfig.Type;\n\nexport const GraphqlSourceConfig = Schema.Struct({\n kind: Schema.Literal(\"graphql\"),\n endpoint: Schema.String,\n introspectionJson: Schema.optional(Schema.NullOr(Schema.String)),\n namespace: Schema.optional(Schema.String),\n headers: Schema.optional(ConfigHeaders),\n});\nexport type GraphqlSourceConfig = typeof GraphqlSourceConfig.Type;\n\nconst StringMap = Schema.Record(Schema.String, Schema.String);\n\nexport const McpAuthConfig = Schema.Union([\n Schema.Struct({ kind: Schema.Literal(\"none\") }),\n Schema.Struct({\n kind: Schema.Literal(\"header\"),\n headerName: Schema.String,\n secret: Schema.String,\n prefix: Schema.optional(Schema.String),\n }),\n Schema.Struct({\n kind: Schema.Literal(\"oauth2\"),\n /** Stable id of the SDK Connection holding access + refresh token\n * material. Scope shadowing means the same id resolves per-user\n * via the executor's innermost-wins lookup. */\n connectionId: Schema.String,\n }),\n]);\nexport type McpAuthConfig = typeof McpAuthConfig.Type;\n\nexport const McpRemoteSourceConfig = Schema.Struct({\n kind: Schema.Literal(\"mcp\"),\n transport: Schema.Literal(\"remote\"),\n name: Schema.String,\n endpoint: Schema.String,\n remoteTransport: Schema.optional(Schema.Literals([\"streamable-http\", \"sse\", \"auto\"])),\n namespace: Schema.optional(Schema.String),\n queryParams: Schema.optional(StringMap),\n headers: Schema.optional(StringMap),\n auth: Schema.optional(McpAuthConfig),\n});\nexport type McpRemoteSourceConfig = typeof McpRemoteSourceConfig.Type;\n\nexport const McpStdioSourceConfig = Schema.Struct({\n kind: Schema.Literal(\"mcp\"),\n transport: Schema.Literal(\"stdio\"),\n name: Schema.String,\n command: Schema.String,\n args: Schema.optional(Schema.Array(Schema.String)),\n env: Schema.optional(StringMap),\n cwd: Schema.optional(Schema.String),\n namespace: Schema.optional(Schema.String),\n});\nexport type McpStdioSourceConfig = typeof McpStdioSourceConfig.Type;\n\nexport const SourceConfig = Schema.Union([\n OpenApiSourceConfig,\n GraphqlSourceConfig,\n McpRemoteSourceConfig,\n McpStdioSourceConfig,\n]);\nexport type SourceConfig = typeof SourceConfig.Type;\n\n// ---------------------------------------------------------------------------\n// Secret metadata\n// ---------------------------------------------------------------------------\n\nexport const SecretMetadata = Schema.Struct({\n name: Schema.String,\n provider: Schema.optional(Schema.String),\n purpose: Schema.optional(Schema.String),\n});\nexport type SecretMetadata = typeof SecretMetadata.Type;\n\n// ---------------------------------------------------------------------------\n// Top-level config\n// ---------------------------------------------------------------------------\n\nexport const ExecutorFileConfig = Schema.Struct({\n $schema: Schema.optional(Schema.String),\n name: Schema.optional(Schema.String),\n sources: Schema.optional(Schema.Array(SourceConfig)),\n secrets: Schema.optional(Schema.Record(Schema.String, SecretMetadata)),\n});\nexport type ExecutorFileConfig = typeof ExecutorFileConfig.Type;\n","import { Effect, Schema } from \"effect\";\nimport { FileSystem } from \"effect\";\nimport type { PlatformError } from \"effect/PlatformError\";\nimport * as jsonc from \"jsonc-parser\";\nimport { ExecutorFileConfig } from \"./schema\";\n\nexport class ConfigParseError {\n readonly _tag = \"ConfigParseError\";\n constructor(\n readonly path: string,\n readonly message: string,\n ) {}\n}\n\n/**\n * Load and validate an executor config file.\n * Returns null if the file doesn't exist.\n */\nexport const loadConfig = (\n path: string,\n): Effect.Effect<\n ExecutorFileConfig | null,\n ConfigParseError | PlatformError,\n FileSystem.FileSystem\n> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n\n const exists = yield* fs.exists(path);\n if (!exists) return null;\n\n const raw = yield* fs.readFileString(path);\n\n const errors: jsonc.ParseError[] = [];\n const parsed = jsonc.parse(raw, errors);\n\n if (errors.length > 0) {\n const msg = errors\n .map((e) => `offset ${e.offset}: ${jsonc.printParseErrorCode(e.error)}`)\n .join(\"; \");\n return yield* Effect.fail(new ConfigParseError(path, msg));\n }\n\n const decoded = yield* Schema.decodeUnknownEffect(ExecutorFileConfig)(parsed).pipe(\n Effect.mapError((e) => new ConfigParseError(path, String(e))),\n );\n\n return decoded;\n });\n","import { Effect } from \"effect\";\nimport { FileSystem } from \"effect\";\nimport type { PlatformError } from \"effect/PlatformError\";\nimport * as jsonc from \"jsonc-parser\";\nimport type { SourceConfig, ExecutorFileConfig } from \"./schema\";\n\nconst FORMATTING: jsonc.FormattingOptions = {\n tabSize: 2,\n insertSpaces: true,\n eol: \"\\n\",\n};\n\nconst DEFAULT_CONFIG = `{\n \"sources\": []\n}\n`;\n\n/** Read the raw JSONC text from a config file, or create a default one. */\nconst readOrCreate = (\n fs: FileSystem.FileSystem,\n path: string,\n): Effect.Effect<string, PlatformError> =>\n Effect.gen(function* () {\n const exists = yield* fs.exists(path);\n if (exists) return yield* fs.readFileString(path);\n yield* fs.writeFileString(path, DEFAULT_CONFIG);\n return DEFAULT_CONFIG;\n });\n\n/**\n * Add a source entry to the config file. Creates the file if it doesn't exist.\n * Preserves existing comments and formatting.\n */\nexport const addSourceToConfig = (\n path: string,\n source: SourceConfig,\n): Effect.Effect<void, PlatformError, FileSystem.FileSystem> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n let text = yield* readOrCreate(fs, path);\n\n // Ensure \"sources\" array exists\n let tree = jsonc.parseTree(text);\n let sourcesNode = tree ? jsonc.findNodeAtLocation(tree, [\"sources\"]) : undefined;\n\n if (!sourcesNode) {\n const edits = jsonc.modify(text, [\"sources\"], [source], {\n formattingOptions: FORMATTING,\n });\n text = jsonc.applyEdits(text, edits);\n } else {\n // Remove existing entry with same namespace (if any) to avoid duplicates\n const ns = \"namespace\" in source ? source.namespace : undefined;\n if (ns && sourcesNode.children) {\n for (let i = sourcesNode.children.length - 1; i >= 0; i--) {\n const child = sourcesNode.children[i]!;\n const nsNode = jsonc.findNodeAtLocation(child, [\"namespace\"]);\n if (nsNode && jsonc.getNodeValue(nsNode) === ns) {\n const edits = jsonc.modify(text, [\"sources\", i], undefined, {\n formattingOptions: FORMATTING,\n });\n text = jsonc.applyEdits(text, edits);\n }\n }\n // Re-parse after removals\n tree = jsonc.parseTree(text);\n sourcesNode = tree ? jsonc.findNodeAtLocation(tree, [\"sources\"]) : undefined;\n }\n\n const count = sourcesNode?.children?.length ?? 0;\n const edits = jsonc.modify(text, [\"sources\", count], source, {\n formattingOptions: FORMATTING,\n });\n text = jsonc.applyEdits(text, edits);\n }\n\n yield* fs.writeFileString(path, text);\n });\n\n/**\n * Remove a source from the config file by namespace.\n */\nexport const removeSourceFromConfig = (\n path: string,\n namespace: string,\n): Effect.Effect<void, PlatformError, FileSystem.FileSystem> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n\n const exists = yield* fs.exists(path);\n if (!exists) return;\n\n let text = yield* fs.readFileString(path);\n const tree = jsonc.parseTree(text);\n if (!tree) return;\n\n const sourcesNode = jsonc.findNodeAtLocation(tree, [\"sources\"]);\n if (!sourcesNode?.children) return;\n\n // Walk backwards so indices stay valid after each removal\n for (let i = sourcesNode.children.length - 1; i >= 0; i--) {\n const child = sourcesNode.children[i]!;\n const nsNode = jsonc.findNodeAtLocation(child, [\"namespace\"]);\n if (nsNode && jsonc.getNodeValue(nsNode) === namespace) {\n const edits = jsonc.modify(text, [\"sources\", i], undefined, {\n formattingOptions: FORMATTING,\n });\n text = jsonc.applyEdits(text, edits);\n }\n }\n\n yield* fs.writeFileString(path, text);\n });\n\n/**\n * Write a full config object to a file.\n */\nexport const writeConfig = (\n path: string,\n config: ExecutorFileConfig,\n): Effect.Effect<void, PlatformError, FileSystem.FileSystem> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const text = yield* Effect.try({\n try: () => JSON.stringify(config, null, 2) + \"\\n\",\n catch: (cause) => cause,\n }).pipe(Effect.orDie);\n yield* fs.writeFileString(path, text);\n });\n\n/**\n * Add secret metadata to the config file.\n */\nexport const addSecretToConfig = (\n path: string,\n secretId: string,\n metadata: { name: string; provider?: string; purpose?: string },\n): Effect.Effect<void, PlatformError, FileSystem.FileSystem> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n let text = yield* readOrCreate(fs, path);\n\n const edits = jsonc.modify(text, [\"secrets\", secretId], metadata, {\n formattingOptions: FORMATTING,\n });\n text = jsonc.applyEdits(text, edits);\n\n yield* fs.writeFileString(path, text);\n });\n\n/**\n * Remove secret metadata from the config file.\n */\nexport const removeSecretFromConfig = (\n path: string,\n secretId: string,\n): Effect.Effect<void, PlatformError, FileSystem.FileSystem> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n\n const exists = yield* fs.exists(path);\n if (!exists) return;\n\n let text = yield* fs.readFileString(path);\n const edits = jsonc.modify(text, [\"secrets\", secretId], undefined, {\n formattingOptions: FORMATTING,\n });\n text = jsonc.applyEdits(text, edits);\n\n yield* fs.writeFileString(path, text);\n });\n","// ---------------------------------------------------------------------------\n// ConfigFileSink — best-effort write-back of source changes to executor.jsonc.\n//\n// Plugins (openapi, graphql, mcp) call `sink.upsertSource` after their DB\n// writes so the committable file stays in sync with runtime state. Errors\n// are logged and swallowed — a failed file write must never fail a DB\n// mutation, and the next successful mutation (or a boot-time sync) will\n// eventually reconcile.\n//\n// The FileSystem layer is injected so library code here doesn't pick a\n// platform binding. The host app provides NodeFileSystem (or BunFileSystem).\n// ---------------------------------------------------------------------------\n\nimport { Effect } from \"effect\";\nimport type { Layer } from \"effect\";\nimport type { FileSystem } from \"effect\";\n\nimport { SECRET_REF_PREFIX, type ConfigHeaderValue, type SourceConfig } from \"./schema\";\nimport { addSourceToConfig, removeSourceFromConfig } from \"./write\";\n\n// Translate a plugin-side header value (`{ secretId, prefix? }` for secret\n// refs) into the config file's `secret-public-ref:<id>` string form.\ntype PluginHeaderValue = string | { secretId: string; prefix?: string };\n\nexport const headerToConfigValue = (\n value: PluginHeaderValue,\n): ConfigHeaderValue => {\n if (typeof value === \"string\") return value;\n const ref = `${SECRET_REF_PREFIX}${value.secretId}`;\n return value.prefix ? { value: ref, prefix: value.prefix } : ref;\n};\n\nexport const headersToConfigValues = (\n headers: Record<string, PluginHeaderValue> | undefined,\n): Record<string, ConfigHeaderValue> | undefined => {\n if (!headers) return undefined;\n const out: Record<string, ConfigHeaderValue> = {};\n for (const [k, v] of Object.entries(headers)) out[k] = headerToConfigValue(v);\n return out;\n};\n\nexport interface ConfigFileSink {\n readonly upsertSource: (source: SourceConfig) => Effect.Effect<void>;\n readonly removeSource: (namespace: string) => Effect.Effect<void>;\n}\n\nexport interface ConfigFileSinkOptions {\n readonly path: string;\n readonly fsLayer: Layer.Layer<FileSystem.FileSystem>;\n /** Called when a file operation fails. Defaults to console.warn. */\n readonly onError?: (op: \"upsert\" | \"remove\", err: unknown) => void;\n}\n\nconst defaultOnError = (op: \"upsert\" | \"remove\", err: unknown): void => {\n const msg = err instanceof Error ? err.message : String(err);\n console.warn(`[config-sink] ${op} failed: ${msg}`);\n};\n\nexport const makeFileConfigSink = (\n options: ConfigFileSinkOptions,\n): ConfigFileSink => {\n const { path, fsLayer, onError = defaultOnError } = options;\n\n return {\n upsertSource: (source) =>\n addSourceToConfig(path, source).pipe(\n Effect.provide(fsLayer),\n Effect.catch((err: unknown) => Effect.sync(() => onError(\"upsert\", err))),\n ),\n\n removeSource: (namespace) =>\n removeSourceFromConfig(path, namespace).pipe(\n Effect.provide(fsLayer),\n Effect.catch((err: unknown) => Effect.sync(() => onError(\"remove\", err))),\n ),\n };\n};\n"],"mappings":";AAAA,SAAS,cA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MAAM,CAAC,QAAiBA,QAAO,KAAK,MAAM,QAAQ,UAAU,GAAG,CAAC,CAAC;AAAA,IAC1E;AAAA,IAEF,cAAc,CAAC,cACb,uBAAuB,MAAM,SAAS,EAAE;AAAA,MACtCA,QAAO,QAAQ,OAAO;AAAA,MACtBA,QAAO,MAAM,CAAC,QAAiBA,QAAO,KAAK,MAAM,QAAQ,UAAU,GAAG,CAAC,CAAC;AAAA,IAC1E;AAAA,EACJ;AACF;","names":["Schema","Schema","Effect","FileSystem","jsonc","edits","Effect","Effect"]}
1
+ {"version":3,"sources":["../src/schema.ts","../src/load.ts","../src/load-plugins.ts","../src/write.ts","../src/sink.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\n// ---------------------------------------------------------------------------\n// Header values\n//\n// Three forms:\n// \"static-value\" — literal string\n// \"secret-public-ref:my-token\" — secret reference (no prefix)\n// { value: \"secret-public-ref:x\", prefix } — secret reference with prefix\n// ---------------------------------------------------------------------------\n\nexport const SECRET_REF_PREFIX = \"secret-public-ref:\";\n\nexport const ConfigHeaderValue = Schema.Union([\n Schema.String,\n Schema.Struct({\n value: Schema.String,\n prefix: Schema.optional(Schema.String),\n }),\n]);\nexport type ConfigHeaderValue = typeof ConfigHeaderValue.Type;\n\nconst ConfigHeaders = Schema.Record(Schema.String, ConfigHeaderValue);\n\n// ---------------------------------------------------------------------------\n// Source configs — discriminated union on \"kind\"\n// ---------------------------------------------------------------------------\n\nexport const OpenApiSourceConfig = Schema.Struct({\n kind: Schema.Literal(\"openapi\"),\n spec: Schema.String,\n baseUrl: Schema.optional(Schema.String),\n namespace: Schema.optional(Schema.String),\n headers: Schema.optional(ConfigHeaders),\n});\nexport type OpenApiSourceConfig = typeof OpenApiSourceConfig.Type;\n\nexport const GraphqlSourceConfig = Schema.Struct({\n kind: Schema.Literal(\"graphql\"),\n endpoint: Schema.String,\n introspectionJson: Schema.optional(Schema.NullOr(Schema.String)),\n namespace: Schema.optional(Schema.String),\n headers: Schema.optional(ConfigHeaders),\n});\nexport type GraphqlSourceConfig = typeof GraphqlSourceConfig.Type;\n\nconst StringMap = Schema.Record(Schema.String, Schema.String);\n\nexport const McpAuthConfig = Schema.Union([\n Schema.Struct({ kind: Schema.Literal(\"none\") }),\n Schema.Struct({\n kind: Schema.Literal(\"header\"),\n headerName: Schema.String,\n secret: Schema.String,\n prefix: Schema.optional(Schema.String),\n }),\n Schema.Struct({\n kind: Schema.Literal(\"oauth2\"),\n /** Stable id of the SDK Connection holding access + refresh token\n * material. Scope shadowing means the same id resolves per-user\n * via the executor's innermost-wins lookup. */\n connectionId: Schema.String,\n }),\n]);\nexport type McpAuthConfig = typeof McpAuthConfig.Type;\n\nexport const McpRemoteSourceConfig = Schema.Struct({\n kind: Schema.Literal(\"mcp\"),\n transport: Schema.Literal(\"remote\"),\n name: Schema.String,\n endpoint: Schema.String,\n remoteTransport: Schema.optional(Schema.Literals([\"streamable-http\", \"sse\", \"auto\"])),\n namespace: Schema.optional(Schema.String),\n queryParams: Schema.optional(StringMap),\n headers: Schema.optional(StringMap),\n auth: Schema.optional(McpAuthConfig),\n});\nexport type McpRemoteSourceConfig = typeof McpRemoteSourceConfig.Type;\n\nexport const McpStdioSourceConfig = Schema.Struct({\n kind: Schema.Literal(\"mcp\"),\n transport: Schema.Literal(\"stdio\"),\n name: Schema.String,\n command: Schema.String,\n args: Schema.optional(Schema.Array(Schema.String)),\n env: Schema.optional(StringMap),\n cwd: Schema.optional(Schema.String),\n namespace: Schema.optional(Schema.String),\n});\nexport type McpStdioSourceConfig = typeof McpStdioSourceConfig.Type;\n\nexport const SourceConfig = Schema.Union([\n OpenApiSourceConfig,\n GraphqlSourceConfig,\n McpRemoteSourceConfig,\n McpStdioSourceConfig,\n]);\nexport type SourceConfig = typeof SourceConfig.Type;\n\n// ---------------------------------------------------------------------------\n// Secret metadata\n// ---------------------------------------------------------------------------\n\nexport const SecretMetadata = Schema.Struct({\n name: Schema.String,\n provider: Schema.optional(Schema.String),\n purpose: Schema.optional(Schema.String),\n});\nexport type SecretMetadata = typeof SecretMetadata.Type;\n\n// ---------------------------------------------------------------------------\n// Plugin manifest\n//\n// `plugins` is the install list. Each entry is a published npm package\n// that exports a `definePlugin(...)` factory under `./server`. The host\n// loads each at boot via jiti and calls the factory with merged\n// `options` plus host-injected deps (`configFile`, etc.). This is the\n// dynamic sibling of the static `executor.config.ts` plugin tuple — when\n// `plugins` is set, the host uses it; otherwise it falls back to the\n// statically-typed config.\n// ---------------------------------------------------------------------------\n\nexport const PluginConfig = Schema.Struct({\n package: Schema.String,\n options: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),\n});\nexport type PluginConfig = typeof PluginConfig.Type;\n\n// ---------------------------------------------------------------------------\n// Top-level config\n// ---------------------------------------------------------------------------\n\nexport const ExecutorFileConfig = Schema.Struct({\n $schema: Schema.optional(Schema.String),\n name: Schema.optional(Schema.String),\n plugins: Schema.optional(Schema.Array(PluginConfig)),\n sources: Schema.optional(Schema.Array(SourceConfig)),\n secrets: Schema.optional(Schema.Record(Schema.String, SecretMetadata)),\n});\nexport type ExecutorFileConfig = typeof ExecutorFileConfig.Type;\n","import { Effect, Schema } from \"effect\";\nimport { FileSystem } from \"effect\";\nimport type { PlatformError } from \"effect/PlatformError\";\nimport * as jsonc from \"jsonc-parser\";\nimport { ExecutorFileConfig } from \"./schema\";\n\nexport class ConfigParseError extends Schema.TaggedErrorClass<ConfigParseError>()(\n \"ConfigParseError\",\n {\n path: Schema.String,\n message: Schema.String,\n },\n) {}\n\n/**\n * Load and validate an executor config file.\n * Returns null if the file doesn't exist.\n */\nexport const loadConfig = (\n path: string,\n): Effect.Effect<\n ExecutorFileConfig | null,\n ConfigParseError | PlatformError,\n FileSystem.FileSystem\n> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n\n const exists = yield* fs.exists(path);\n if (!exists) return null;\n\n const raw = yield* fs.readFileString(path);\n\n const errors: jsonc.ParseError[] = [];\n const parsed = jsonc.parse(raw, errors);\n\n if (errors.length > 0) {\n const msg = errors\n .map((e) => `offset ${e.offset}: ${jsonc.printParseErrorCode(e.error)}`)\n .join(\"; \");\n return yield* new ConfigParseError({ path, message: msg });\n }\n\n const decoded = yield* Schema.decodeUnknownEffect(ExecutorFileConfig)(parsed).pipe(\n Effect.mapError(\n (error) =>\n new ConfigParseError({\n path,\n message: error.issue.toString(),\n }),\n ),\n );\n\n return decoded;\n });\n","// ---------------------------------------------------------------------------\n// loadPluginsFromJsonc — runtime plugin loader.\n//\n// Reads `executor.jsonc#plugins`, dynamically imports each package's\n// `./server` entry via jiti (so workspace TS sources work in dev and\n// published `dist/*.js` works after install), and calls the exported\n// `definePlugin(...)` factory with merged `options` plus host-injected\n// deps. Returns the resulting `Plugin[]` ready to hand to\n// `composePluginApi` / `createExecutor`.\n//\n// jiti is used instead of bare `import()` because:\n// - workspace plugins under monorepo dev expose `.ts` source via the\n// `bun` export condition; Node's loader can't read those directly,\n// jiti transpiles on the fly.\n// - in a published environment the package's `default` condition\n// points at `dist/*.js`, which jiti loads as a normal ESM module.\n//\n// The convention is: every plugin package exports a `./server` subpath\n// whose default export is a `ConfiguredPlugin` (the result of\n// `definePlugin(...)`). Calling that with `{ ...options, ...deps }`\n// returns a concrete `Plugin`.\n// ---------------------------------------------------------------------------\n\nimport { createRequire } from \"node:module\";\nimport { dirname, isAbsolute, resolve as resolvePath } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport * as fs from \"node:fs\";\nimport * as jsonc from \"jsonc-parser\";\nimport { Effect, Schema } from \"effect\";\n\nimport type { AnyPlugin } from \"@executor-js/sdk\";\n\n// Plugins are invoked dynamically by name — exact author types are\n// unknown at the call site, so the loader treats every factory as\n// `(options?: unknown) => AnyPlugin`. The plugin author's types still\n// hold inside the plugin's own module; we just don't propagate them\n// across the runtime boundary.\ntype LooseConfiguredPlugin = (options?: Record<string, unknown>) => AnyPlugin;\n\nimport { ExecutorFileConfig } from \"./schema\";\n\nexport class LoadPluginsError extends Schema.TaggedErrorClass<LoadPluginsError>()(\n \"LoadPluginsError\",\n {\n message: Schema.String,\n cause: Schema.optional(Schema.Unknown),\n },\n) {}\n\nexport interface LoadPluginsFromJsoncOptions {\n /** Absolute path to `executor.jsonc` (or compatible). */\n readonly path: string;\n /**\n * Host-injected deps merged into each plugin's options. Common keys:\n * `configFile` (the `ConfigFileSink`), env-derived credentials, etc.\n * Plugins ignore deps they don't accept — `definePlugin` strips\n * unknown keys before forwarding to the author factory.\n */\n readonly deps?: Readonly<Record<string, unknown>>;\n}\n\n/**\n * Returns the plugins listed in jsonc, or `null` if the file is missing\n * or has no `plugins` array. The host treats `null` as \"fall back to\n * the static `executor.config.ts` factory.\"\n */\nexport const loadPluginsFromJsonc = async (\n options: LoadPluginsFromJsoncOptions,\n): Promise<readonly AnyPlugin[] | null> => Effect.runPromise(loadPluginsFromJsoncEffect(options));\n\nconst loadPluginsFromJsoncEffect = (\n options: LoadPluginsFromJsoncOptions,\n): Effect.Effect<readonly AnyPlugin[] | null, LoadPluginsError> =>\n Effect.gen(function* () {\n const { path, deps } = options;\n if (!fs.existsSync(path)) return null;\n\n const raw = fs.readFileSync(path, \"utf8\");\n const errors: jsonc.ParseError[] = [];\n const parsed = jsonc.parse(raw, errors);\n if (errors.length > 0) {\n const msg = errors\n .map((e) => `offset ${e.offset}: ${jsonc.printParseErrorCode(e.error)}`)\n .join(\"; \");\n return yield* new LoadPluginsError({\n message: `[load-plugins] failed to parse ${path}: ${msg}`,\n });\n }\n\n const config = yield* Schema.decodeUnknownEffect(ExecutorFileConfig)(parsed).pipe(\n Effect.mapError(\n (error) =>\n new LoadPluginsError({\n message: `[load-plugins] failed to decode ${path}: ${error.issue.toString()}`,\n cause: error,\n }),\n ),\n );\n\n const entries = config.plugins ?? null;\n if (!entries || entries.length === 0) return null;\n\n // jiti is created once per call; `moduleCache: false` ensures a\n // restart picks up freshly-installed packages without process restart\n // (relevant when the dev server kicks a reload after `executor plugin\n // install`).\n const { createJiti } = yield* Effect.tryPromise({\n try: () => import(\"jiti\"),\n catch: (cause) =>\n new LoadPluginsError({\n message: `[load-plugins] failed to import jiti.`,\n cause,\n }),\n });\n const jiti = createJiti(pathToFileURL(path).href, {\n interopDefault: true,\n moduleCache: false,\n });\n\n const fromDir = dirname(path);\n // require.resolve is anchored to the jsonc's directory so plugin\n // packages resolve from the host app's `node_modules` regardless of\n // CWD.\n const require = createRequire(isAbsolute(path) ? path : resolvePath(fromDir, \"_anchor.js\"));\n\n const loaded: AnyPlugin[] = [];\n for (const entry of entries) {\n const serverEntry = `${entry.package}/server`;\n const resolved = yield* Effect.try({\n try: () => require.resolve(serverEntry),\n catch: (cause) =>\n new LoadPluginsError({\n message:\n `[load-plugins] cannot resolve \"${serverEntry}\" from ${fromDir}. ` +\n `Is \"${entry.package}\" installed and does it export \"./server\"?`,\n cause,\n }),\n });\n const mod = (yield* Effect.tryPromise({\n try: () => jiti.import(resolved),\n catch: (cause) =>\n new LoadPluginsError({\n message: `[load-plugins] failed to import \"${serverEntry}\" from ${resolved}.`,\n cause,\n }),\n })) as { default?: LooseConfiguredPlugin } | LooseConfiguredPlugin;\n const factory = (\n typeof mod === \"function\" ? mod : (mod.default ?? null)\n ) as LooseConfiguredPlugin | null;\n if (!factory || typeof factory !== \"function\") {\n return yield* new LoadPluginsError({\n message:\n `[load-plugins] \"${serverEntry}\" did not export a default ` +\n `definePlugin(...) factory.`,\n });\n }\n const merged = { ...(deps ?? {}), ...(entry.options ?? {}) };\n loaded.push(factory(merged));\n }\n\n return loaded;\n });\n","import { Effect } from \"effect\";\nimport { FileSystem } from \"effect\";\nimport type { PlatformError } from \"effect/PlatformError\";\nimport * as jsonc from \"jsonc-parser\";\nimport type { SourceConfig, ExecutorFileConfig } from \"./schema\";\n\nexport class ConfigWriteError {\n readonly _tag = \"ConfigWriteError\";\n constructor(\n readonly path: string,\n readonly cause: unknown,\n ) {}\n}\n\nconst FORMATTING: jsonc.FormattingOptions = {\n tabSize: 2,\n insertSpaces: true,\n eol: \"\\n\",\n};\n\nconst DEFAULT_CONFIG = `{\n \"sources\": []\n}\n`;\n\n/** Read the raw JSONC text from a config file, or create a default one. */\nconst readOrCreate = (\n fs: FileSystem.FileSystem,\n path: string,\n): Effect.Effect<string, PlatformError> =>\n Effect.gen(function* () {\n const exists = yield* fs.exists(path);\n if (exists) return yield* fs.readFileString(path);\n yield* fs.writeFileString(path, DEFAULT_CONFIG);\n return DEFAULT_CONFIG;\n });\n\n/**\n * Add a source entry to the config file. Creates the file if it doesn't exist.\n * Preserves existing comments and formatting.\n */\nexport const addSourceToConfig = (\n path: string,\n source: SourceConfig,\n): Effect.Effect<void, PlatformError, FileSystem.FileSystem> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n let text = yield* readOrCreate(fs, path);\n\n // Ensure \"sources\" array exists\n let tree = jsonc.parseTree(text);\n let sourcesNode = tree ? jsonc.findNodeAtLocation(tree, [\"sources\"]) : undefined;\n\n if (!sourcesNode) {\n const edits = jsonc.modify(text, [\"sources\"], [source], {\n formattingOptions: FORMATTING,\n });\n text = jsonc.applyEdits(text, edits);\n } else {\n // Remove existing entry with same namespace (if any) to avoid duplicates\n const ns = \"namespace\" in source ? source.namespace : undefined;\n if (ns && sourcesNode.children) {\n for (let i = sourcesNode.children.length - 1; i >= 0; i--) {\n const child = sourcesNode.children[i]!;\n const nsNode = jsonc.findNodeAtLocation(child, [\"namespace\"]);\n if (nsNode && jsonc.getNodeValue(nsNode) === ns) {\n const edits = jsonc.modify(text, [\"sources\", i], undefined, {\n formattingOptions: FORMATTING,\n });\n text = jsonc.applyEdits(text, edits);\n }\n }\n // Re-parse after removals\n tree = jsonc.parseTree(text);\n sourcesNode = tree ? jsonc.findNodeAtLocation(tree, [\"sources\"]) : undefined;\n }\n\n const count = sourcesNode?.children?.length ?? 0;\n const edits = jsonc.modify(text, [\"sources\", count], source, {\n formattingOptions: FORMATTING,\n });\n text = jsonc.applyEdits(text, edits);\n }\n\n yield* fs.writeFileString(path, text);\n });\n\n/**\n * Remove a source from the config file by namespace.\n */\nexport const removeSourceFromConfig = (\n path: string,\n namespace: string,\n): Effect.Effect<void, PlatformError, FileSystem.FileSystem> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n\n const exists = yield* fs.exists(path);\n if (!exists) return;\n\n let text = yield* fs.readFileString(path);\n const tree = jsonc.parseTree(text);\n if (!tree) return;\n\n const sourcesNode = jsonc.findNodeAtLocation(tree, [\"sources\"]);\n if (!sourcesNode?.children) return;\n\n // Walk backwards so indices stay valid after each removal\n for (let i = sourcesNode.children.length - 1; i >= 0; i--) {\n const child = sourcesNode.children[i]!;\n const nsNode = jsonc.findNodeAtLocation(child, [\"namespace\"]);\n if (nsNode && jsonc.getNodeValue(nsNode) === namespace) {\n const edits = jsonc.modify(text, [\"sources\", i], undefined, {\n formattingOptions: FORMATTING,\n });\n text = jsonc.applyEdits(text, edits);\n }\n }\n\n yield* fs.writeFileString(path, text);\n });\n\n/**\n * Write a full config object to a file.\n */\nexport const writeConfig = (\n path: string,\n config: ExecutorFileConfig,\n): Effect.Effect<void, ConfigWriteError | PlatformError, FileSystem.FileSystem> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const text = yield* Effect.try({\n try: () => JSON.stringify(config, null, 2) + \"\\n\",\n catch: (cause) => new ConfigWriteError(path, cause),\n });\n yield* fs.writeFileString(path, text);\n });\n\n/**\n * Add secret metadata to the config file.\n */\nexport const addSecretToConfig = (\n path: string,\n secretId: string,\n metadata: { name: string; provider?: string; purpose?: string },\n): Effect.Effect<void, PlatformError, FileSystem.FileSystem> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n let text = yield* readOrCreate(fs, path);\n\n const edits = jsonc.modify(text, [\"secrets\", secretId], metadata, {\n formattingOptions: FORMATTING,\n });\n text = jsonc.applyEdits(text, edits);\n\n yield* fs.writeFileString(path, text);\n });\n\n/**\n * Remove secret metadata from the config file.\n */\nexport const removeSecretFromConfig = (\n path: string,\n secretId: string,\n): Effect.Effect<void, PlatformError, FileSystem.FileSystem> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n\n const exists = yield* fs.exists(path);\n if (!exists) return;\n\n let text = yield* fs.readFileString(path);\n const edits = jsonc.modify(text, [\"secrets\", secretId], undefined, {\n formattingOptions: FORMATTING,\n });\n text = jsonc.applyEdits(text, edits);\n\n yield* fs.writeFileString(path, text);\n });\n","// ---------------------------------------------------------------------------\n// ConfigFileSink — best-effort write-back of source changes to executor.jsonc.\n//\n// Plugins (openapi, graphql, mcp) call `sink.upsertSource` after their DB\n// writes so the committable file stays in sync with runtime state. Errors\n// are logged and swallowed — a failed file write must never fail a DB\n// mutation, and the next successful mutation (or a boot-time sync) will\n// eventually reconcile.\n//\n// The FileSystem layer is injected so library code here doesn't pick a\n// platform binding. The host app provides NodeFileSystem (or BunFileSystem).\n// ---------------------------------------------------------------------------\n\nimport { Effect } from \"effect\";\nimport type { Layer } from \"effect\";\nimport type { FileSystem } from \"effect\";\n\nimport { SECRET_REF_PREFIX, type ConfigHeaderValue, type SourceConfig } from \"./schema\";\nimport { addSourceToConfig, removeSourceFromConfig } from \"./write\";\n\n// Translate a plugin-side header value (`{ secretId, prefix? }` for secret\n// refs) into the config file's `secret-public-ref:<id>` string form.\ntype PluginHeaderValue = string | { secretId: string; prefix?: string };\n\nexport const headerToConfigValue = (value: PluginHeaderValue): ConfigHeaderValue => {\n if (typeof value === \"string\") return value;\n const ref = `${SECRET_REF_PREFIX}${value.secretId}`;\n return value.prefix ? { value: ref, prefix: value.prefix } : ref;\n};\n\nexport const headersToConfigValues = (\n headers: Record<string, PluginHeaderValue> | undefined,\n): Record<string, ConfigHeaderValue> | undefined => {\n if (!headers) return undefined;\n const out: Record<string, ConfigHeaderValue> = {};\n for (const [k, v] of Object.entries(headers)) out[k] = headerToConfigValue(v);\n return out;\n};\n\nexport interface ConfigFileSink {\n readonly upsertSource: (source: SourceConfig) => Effect.Effect<void>;\n readonly removeSource: (namespace: string) => Effect.Effect<void>;\n}\n\nexport interface ConfigFileSinkOptions {\n readonly path: string;\n readonly fsLayer: Layer.Layer<FileSystem.FileSystem>;\n /** Called when a file operation fails. Defaults to console.warn. */\n readonly onError?: (op: \"upsert\" | \"remove\", err: unknown) => void;\n}\n\nconst defaultOnError = (op: \"upsert\" | \"remove\", err: unknown): void => {\n console.warn(`[config-sink] ${op} failed`, err);\n};\n\nexport const makeFileConfigSink = (options: ConfigFileSinkOptions): ConfigFileSink => {\n const { path, fsLayer, onError = defaultOnError } = options;\n\n return {\n upsertSource: (source) =>\n addSourceToConfig(path, source).pipe(\n Effect.provide(fsLayer),\n Effect.catch((err: unknown) => Effect.sync(() => onError(\"upsert\", err))),\n ),\n\n removeSource: (namespace) =>\n removeSourceFromConfig(path, namespace).pipe(\n Effect.provide(fsLayer),\n Effect.catch((err: unknown) => Effect.sync(() => onError(\"remove\", err))),\n ),\n };\n};\n"],"mappings":";AAAA,SAAS,cAAc;AAWhB,IAAM,oBAAoB;AAE1B,IAAM,oBAAoB,OAAO,MAAM;AAAA,EAC5C,OAAO;AAAA,EACP,OAAO,OAAO;AAAA,IACZ,OAAO,OAAO;AAAA,IACd,QAAQ,OAAO,SAAS,OAAO,MAAM;AAAA,EACvC,CAAC;AACH,CAAC;AAGD,IAAM,gBAAgB,OAAO,OAAO,OAAO,QAAQ,iBAAiB;AAM7D,IAAM,sBAAsB,OAAO,OAAO;AAAA,EAC/C,MAAM,OAAO,QAAQ,SAAS;AAAA,EAC9B,MAAM,OAAO;AAAA,EACb,SAAS,OAAO,SAAS,OAAO,MAAM;AAAA,EACtC,WAAW,OAAO,SAAS,OAAO,MAAM;AAAA,EACxC,SAAS,OAAO,SAAS,aAAa;AACxC,CAAC;AAGM,IAAM,sBAAsB,OAAO,OAAO;AAAA,EAC/C,MAAM,OAAO,QAAQ,SAAS;AAAA,EAC9B,UAAU,OAAO;AAAA,EACjB,mBAAmB,OAAO,SAAS,OAAO,OAAO,OAAO,MAAM,CAAC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,IAC1E;AAAA,EACJ;AACF;","names":["Schema","Schema","fs","jsonc","Effect","Schema","Schema","Effect","require","Effect","FileSystem","jsonc","fs","edits","Effect","Effect"]}
@@ -0,0 +1,27 @@
1
+ import { Schema } from "effect";
2
+ import type { AnyPlugin } from "@executor-js/sdk";
3
+ declare const LoadPluginsError_base: Schema.Class<LoadPluginsError, Schema.TaggedStruct<"LoadPluginsError", {
4
+ readonly message: Schema.String;
5
+ readonly cause: Schema.optional<Schema.Unknown>;
6
+ }>, import("effect/Cause").YieldableError>;
7
+ export declare class LoadPluginsError extends LoadPluginsError_base {
8
+ }
9
+ export interface LoadPluginsFromJsoncOptions {
10
+ /** Absolute path to `executor.jsonc` (or compatible). */
11
+ readonly path: string;
12
+ /**
13
+ * Host-injected deps merged into each plugin's options. Common keys:
14
+ * `configFile` (the `ConfigFileSink`), env-derived credentials, etc.
15
+ * Plugins ignore deps they don't accept — `definePlugin` strips
16
+ * unknown keys before forwarding to the author factory.
17
+ */
18
+ readonly deps?: Readonly<Record<string, unknown>>;
19
+ }
20
+ /**
21
+ * Returns the plugins listed in jsonc, or `null` if the file is missing
22
+ * or has no `plugins` array. The host treats `null` as "fall back to
23
+ * the static `executor.config.ts` factory."
24
+ */
25
+ export declare const loadPluginsFromJsonc: (options: LoadPluginsFromJsoncOptions) => Promise<readonly AnyPlugin[] | null>;
26
+ export {};
27
+ //# sourceMappingURL=load-plugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-plugins.d.ts","sourceRoot":"","sources":["../src/load-plugins.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;;;;;AAWlD,qBAAa,gBAAiB,SAAQ,qBAMrC;CAAG;AAEJ,MAAM,WAAW,2BAA2B;IAC1C,yDAAyD;IACzD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACnD;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,2BAA2B,KACnC,OAAO,CAAC,SAAS,SAAS,EAAE,GAAG,IAAI,CAA2D,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=load-plugins.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-plugins.test.d.ts","sourceRoot":"","sources":["../src/load-plugins.test.ts"],"names":[],"mappings":""}
package/dist/load.d.ts CHANGED
@@ -1,16 +1,17 @@
1
- import { Effect } from "effect";
1
+ import { Effect, Schema } from "effect";
2
2
  import { FileSystem } from "effect";
3
3
  import type { PlatformError } from "effect/PlatformError";
4
4
  import { ExecutorFileConfig } from "./schema";
5
- export declare class ConfigParseError {
6
- readonly path: string;
7
- readonly message: string;
8
- readonly _tag = "ConfigParseError";
9
- constructor(path: string, message: string);
5
+ declare const ConfigParseError_base: Schema.Class<ConfigParseError, Schema.TaggedStruct<"ConfigParseError", {
6
+ readonly path: Schema.String;
7
+ readonly message: Schema.String;
8
+ }>, import("effect/Cause").YieldableError>;
9
+ export declare class ConfigParseError extends ConfigParseError_base {
10
10
  }
11
11
  /**
12
12
  * Load and validate an executor config file.
13
13
  * Returns null if the file doesn't exist.
14
14
  */
15
15
  export declare const loadConfig: (path: string) => Effect.Effect<ExecutorFileConfig | null, ConfigParseError | PlatformError, FileSystem.FileSystem>;
16
+ export {};
16
17
  //# sourceMappingURL=load.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,qBAAa,gBAAgB;IAGzB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM;IAH1B,QAAQ,CAAC,IAAI,sBAAsB;gBAExB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM;CAE3B;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,GACrB,MAAM,MAAM,KACX,MAAM,CAAC,MAAM,CACd,kBAAkB,GAAG,IAAI,EACzB,gBAAgB,GAAG,aAAa,EAChC,UAAU,CAAC,UAAU,CAyBnB,CAAC"}
1
+ {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;;;;;AAE9C,qBAAa,gBAAiB,SAAQ,qBAMrC;CAAG;AAEJ;;;GAGG;AACH,eAAO,MAAM,UAAU,GACrB,MAAM,MAAM,KACX,MAAM,CAAC,MAAM,CACd,kBAAkB,GAAG,IAAI,EACzB,gBAAgB,GAAG,aAAa,EAChC,UAAU,CAAC,UAAU,CA+BnB,CAAC"}
package/dist/schema.d.ts CHANGED
@@ -136,9 +136,18 @@ export declare const SecretMetadata: Schema.Struct<{
136
136
  readonly purpose: Schema.optional<Schema.String>;
137
137
  }>;
138
138
  export type SecretMetadata = typeof SecretMetadata.Type;
139
+ export declare const PluginConfig: Schema.Struct<{
140
+ readonly package: Schema.String;
141
+ readonly options: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
142
+ }>;
143
+ export type PluginConfig = typeof PluginConfig.Type;
139
144
  export declare const ExecutorFileConfig: Schema.Struct<{
140
145
  readonly $schema: Schema.optional<Schema.String>;
141
146
  readonly name: Schema.optional<Schema.String>;
147
+ readonly plugins: Schema.optional<Schema.$Array<Schema.Struct<{
148
+ readonly package: Schema.String;
149
+ readonly options: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
150
+ }>>>;
142
151
  readonly sources: Schema.optional<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
143
152
  readonly kind: Schema.Literal<"openapi">;
144
153
  readonly spec: Schema.String;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAWhC,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AAEtD,eAAO,MAAM,iBAAiB;;;IAM5B,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAC;AAQ9D,eAAO,MAAM,mBAAmB;;;;;;;;;EAM9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAC,IAAI,CAAC;AAElE,eAAO,MAAM,mBAAmB;;;;;;;;;EAM9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAC,IAAI,CAAC;AAIlE,eAAO,MAAM,aAAa;;;;;;;;;IAUtB;;oDAEgD;;IAGlD,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAC;AAEtD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;QAR9B;;wDAEgD;;;EAgBlD,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,OAAO,qBAAqB,CAAC,IAAI,CAAC;AAEtE,eAAO,MAAM,oBAAoB;;;;;;;;;EAS/B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAC,IAAI,CAAC;AAEpE,eAAO,MAAM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AAM,EAAE,iBAAiB,CAAC,GAAG,SAAS,KACrD,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAKtC,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACrE,QAAQ,CAAC,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CACnE;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACrD,oEAAoE;IACpE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,GAAG,QAAQ,EAAE,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;CACpE;AAMD,eAAO,MAAM,kBAAkB,GAAI,SAAS,qBAAqB,KAAG,cAgBnE,CAAC"}
package/dist/write.d.ts CHANGED
@@ -2,6 +2,12 @@ import { Effect } from "effect";
2
2
  import { FileSystem } from "effect";
3
3
  import type { PlatformError } from "effect/PlatformError";
4
4
  import type { SourceConfig, ExecutorFileConfig } from "./schema";
5
+ export declare class ConfigWriteError {
6
+ readonly path: string;
7
+ readonly cause: unknown;
8
+ readonly _tag = "ConfigWriteError";
9
+ constructor(path: string, cause: unknown);
10
+ }
5
11
  /**
6
12
  * Add a source entry to the config file. Creates the file if it doesn't exist.
7
13
  * Preserves existing comments and formatting.
@@ -14,7 +20,7 @@ export declare const removeSourceFromConfig: (path: string, namespace: string) =
14
20
  /**
15
21
  * Write a full config object to a file.
16
22
  */
17
- export declare const writeConfig: (path: string, config: ExecutorFileConfig) => Effect.Effect<void, PlatformError, FileSystem.FileSystem>;
23
+ export declare const writeConfig: (path: string, config: ExecutorFileConfig) => Effect.Effect<void, ConfigWriteError | PlatformError, FileSystem.FileSystem>;
18
24
  /**
19
25
  * Add secret metadata to the config file.
20
26
  */
@@ -1 +1 @@
1
- {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAyBjE;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,EACZ,QAAQ,YAAY,KACnB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,CAAC,UAAU,CAyCvD,CAAC;AAEL;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,MAAM,MAAM,EACZ,WAAW,MAAM,KAChB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,CAAC,UAAU,CA2BvD,CAAC;AAEL;;GAEG;AACH,eAAO,MAAM,WAAW,GACtB,MAAM,MAAM,EACZ,QAAQ,kBAAkB,KACzB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,CAAC,UAAU,CAQvD,CAAC;AAEL;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,UAAU;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,KAC9D,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,CAAC,UAAU,CAWvD,CAAC;AAEL;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,MAAM,MAAM,EACZ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M,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,KAC9D,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,CAAC,UAAU,CAWvD,CAAC;AAEL;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,MAAM,MAAM,EACZ,UAAU,MAAM,KACf,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,CAAC,UAAU,CAcvD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@executor-js/config",
3
- "version": "0.0.2",
3
+ "version": "0.2.1",
4
4
  "homepage": "https://github.com/RhysSullivan/executor/tree/main/packages/core/config",
5
5
  "bugs": {
6
6
  "url": "https://github.com/RhysSullivan/executor/issues"
@@ -33,8 +33,9 @@
33
33
  "typecheck:slow": "tsc --noEmit"
34
34
  },
35
35
  "dependencies": {
36
- "@executor-js/sdk": "0.0.2",
36
+ "@executor-js/sdk": "0.2.1",
37
37
  "effect": "4.0.0-beta.59",
38
+ "jiti": "^2.6.1",
38
39
  "jsonc-parser": "^3.3.1"
39
40
  },
40
41
  "devDependencies": {