@codeworksh/plugin 0.2.1 → 0.3.0-dev.20261019193730

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/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { t as section_d_exports } from "./plugin/section.mjs";
2
2
  import { g as tool_d_exports } from "./tool-_ajVYIY5.mjs";
3
- import { t as plugin_d_exports } from "./plugin-BHF7bHpt.mjs";
3
+ import { t as plugin_d_exports } from "./plugin-BagjovWc.mjs";
4
4
  export { plugin_d_exports as Plugin, section_d_exports as Section, tool_d_exports as Tool };
@@ -144,12 +144,16 @@ declare const SandboxNotFoundError_base: Schema.Class<SandboxNotFoundError, Sche
144
144
  * Lifecycle errors are confined to the control plane. Once a mount succeeds,
145
145
  * consumers continue to see only FileSystemError and ShellError.
146
146
  */
147
- declare class SandboxNotFoundError extends SandboxNotFoundError_base {}
147
+ declare class SandboxNotFoundError extends SandboxNotFoundError_base {
148
+ get message(): string;
149
+ }
148
150
  declare const SandboxDriverNotRegisteredError_base: Schema.Class<SandboxDriverNotRegisteredError, Schema.TaggedStruct<"SandboxDriverNotRegisteredError", {
149
151
  readonly driver: Schema.String;
150
152
  readonly registered: Schema.optional<Schema.$Array<Schema.String>>;
151
153
  }>, import("effect/Cause").YieldableError>;
152
- declare class SandboxDriverNotRegisteredError extends SandboxDriverNotRegisteredError_base {}
154
+ declare class SandboxDriverNotRegisteredError extends SandboxDriverNotRegisteredError_base {
155
+ get message(): string;
156
+ }
153
157
  declare const SandboxDriverRegistrationError_base: Schema.Class<SandboxDriverRegistrationError, Schema.TaggedStruct<"SandboxDriverRegistrationError", {
154
158
  readonly driver: Schema.String;
155
159
  readonly reason: Schema.String;
@@ -187,7 +191,9 @@ declare const SandboxRemovedError_base: Schema.Class<SandboxRemovedError, Schema
187
191
  };
188
192
  readonly removedAt: Schema.optional<Schema.DateTimeUtc>;
189
193
  }>, import("effect/Cause").YieldableError>;
190
- declare class SandboxRemovedError extends SandboxRemovedError_base {}
194
+ declare class SandboxRemovedError extends SandboxRemovedError_base {
195
+ get message(): string;
196
+ }
191
197
  declare const SandboxUnavailError_base: Schema.Class<SandboxUnavailError, Schema.TaggedStruct<"SandboxUnavailError", {
192
198
  readonly id: Schema.brand<Schema.String, "SandboxInstance.ID"> & {
193
199
  local: string & import("effect/Brand").Brand<"SandboxInstance.ID">;
@@ -195,7 +201,9 @@ declare const SandboxUnavailError_base: Schema.Class<SandboxUnavailError, Schema
195
201
  };
196
202
  readonly reason: Schema.String;
197
203
  }>, import("effect/Cause").YieldableError>;
198
- declare class SandboxUnavailError extends SandboxUnavailError_base {}
204
+ declare class SandboxUnavailError extends SandboxUnavailError_base {
205
+ get message(): string;
206
+ }
199
207
  declare const SandboxUnsupportedError_base: Schema.Class<SandboxUnsupportedError, Schema.TaggedStruct<"SandboxUnsupportedError", {
200
208
  readonly id: Schema.optional<Schema.brand<Schema.String, "SandboxInstance.ID"> & {
201
209
  local: string & import("effect/Brand").Brand<"SandboxInstance.ID">;
@@ -230,7 +238,9 @@ declare const SandboxProviderError_base: Schema.Class<SandboxProviderError, Sche
230
238
  * a non-enumerable symbol by {@link providerError}, so Effect's default
231
239
  * formatting and JSON serialization cannot expose credentials nested in it.
232
240
  */
233
- declare class SandboxProviderError extends SandboxProviderError_base {}
241
+ declare class SandboxProviderError extends SandboxProviderError_base {
242
+ get message(): string;
243
+ }
234
244
  declare const providerErrorCause: (error: SandboxProviderError) => unknown;
235
245
  declare const providerErrorIsNotFound: (error: SandboxProviderError) => boolean;
236
246
  type Redactor = (value: string) => string;
@@ -537,4 +547,4 @@ declare const remote: (input: {
537
547
  }) => Identity;
538
548
  //#endregion
539
549
  export { SandboxRegisterError as $, RuntimeConfigBase as A, SandboxBusyError as B, Module as C, mountable as Ct, Provisioned as D, Observed as E, driver as F, SandboxDriverNotRegisteredError as G, SandboxDestroyError as H, driver_d_exports as I, SandboxMustBeStoppedError as J, SandboxDriverRegistrationError as K, erase as L, Source as M, apiVersion as N, Registered as O, defineModule as P, SandboxRefreshError as Q, withSource as R, Driver as S, isMountable as St, Name as T, toField as Tt, SandboxDriverLoadError as U, SandboxCreateError as V, SandboxDriverLoadPhase as W, SandboxProviderError as X, SandboxNotFoundError as Y, SandboxReadError as Z, withMutation as _, Status as _t, Layer$1 as a, SandboxWakeError as at, Capabilities as b, fromField as bt, Shell as c, providerError as ct, identityLayer as d, sanitizeError as dt, SandboxRemovedError as et, io_d_exports as f, ID as ft, virtual as g, PersistedError as gt, resolveMountCwd as h, Ownership as ht, Identity as i, SandboxUnsupportedError as it, RuntimeInput as j, Registration as k, host as l, providerErrorCause as lt, remote as m, Kind as mt, DEFAULT_SPILL_PATH as n, SandboxTransitionConflictError as nt, Mutation as o, errors_d_exports as ot, mount as p, Info as pt, SandboxMountError as q, FileSystem as r, SandboxUnavailError as rt, Provides as s, makeRedactor as st, Current as t, SandboxStopError as tt, hostLayer as u, providerErrorIsNotFound as ut, AbsolutePath as v, Usage as vt, ModuleDefinition as w, toColumn as wt, Definition as x, instance_d_exports as xt, ApiVersion as y, fromColumn as yt, Redactor as z };
540
- //# sourceMappingURL=io-nhvNKC33.d.mts.map
550
+ //# sourceMappingURL=io-Br9WZTsG.d.mts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeworksh/plugin",
3
- "version": "0.2.1",
3
+ "version": "0.3.0-dev.20261019193730",
4
4
  "description": "SDK for building CodeWork plugins — the plugin, tool, and sandbox contracts shared with @codeworksh/harness.",
5
5
  "keywords": [
6
6
  "agent",
@@ -168,7 +168,7 @@
168
168
  "uuidv7": "^1.2.1"
169
169
  },
170
170
  "peerDependencies": {
171
- "@codeworksh/aikit": "^0.11.0",
172
- "effect": "4.0.1"
171
+ "@codeworksh/aikit": "0.12.0-dev.20261019193730",
172
+ "effect": "4.0.5"
173
173
  }
174
174
  }
@@ -1,8 +1,8 @@
1
1
  import { i as Definition, o as Payload, r as Data, s as PublishOptions } from "./event-COPs5rMu.mjs";
2
2
  import { n as SessionID } from "./ids-CHjmAdTc.mjs";
3
3
  import { o as Service, r as Info } from "./location-Q39els63.mjs";
4
- import { f as io_d_exports, i as Identity, s as Provides } from "./io-nhvNKC33.mjs";
5
- import { i as Info$1 } from "./settings-47Mzxhl0.mjs";
4
+ import { f as io_d_exports, i as Identity, s as Provides } from "./io-Br9WZTsG.mjs";
5
+ import { i as Info$1 } from "./settings-DGYWREuu.mjs";
6
6
  import { t as section_d_exports } from "./plugin/section.mjs";
7
7
  import { n as prompt_d_exports, t as PromptRegistry } from "./prompt-DWaA5ZXj.mjs";
8
8
  import { d as ToolRegistry, p as tool_d_exports } from "./tool-D4_I_rzy.mjs";
@@ -155,4 +155,4 @@ declare namespace plugin_d_exports {
155
155
  }
156
156
  //#endregion
157
157
  export { PluginRegistry as _, define as a, PluginOptions as c, PluginSpec as d, Config as f, SharedPluginContext as g, PromptResolver as h, PluginKind as i, PluginPatch as l, Paths as m, Mount as n, domains as o, Events as p, Plugin as r, rank as s, plugin_d_exports as t, PluginRef as u };
158
- //# sourceMappingURL=plugin-BHF7bHpt.d.mts.map
158
+ //# sourceMappingURL=plugin-BagjovWc.d.mts.map
package/plugin.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as section_d_exports } from "./plugin/section.mjs";
2
2
  import { n as prompt_d_exports } from "./prompt-DWaA5ZXj.mjs";
3
3
  import { p as tool_d_exports } from "./tool-D4_I_rzy.mjs";
4
- import { _ as PluginRegistry, a as define, c as PluginOptions, d as PluginSpec, f as Config, g as SharedPluginContext, h as PromptResolver, i as PluginKind, l as PluginPatch, m as Paths, n as Mount, o as domains, p as Events, r as Plugin, s as rank, u as PluginRef } from "./plugin-BHF7bHpt.mjs";
4
+ import { _ as PluginRegistry, a as define, c as PluginOptions, d as PluginSpec, f as Config, g as SharedPluginContext, h as PromptResolver, i as PluginKind, l as PluginPatch, m as Paths, n as Mount, o as domains, p as Events, r as Plugin, s as rank, u as PluginRef } from "./plugin-BagjovWc.mjs";
5
5
  export { type Config, type Events, type Mount, type Paths, type Plugin, type PluginKind, type PluginOptions, type PluginPatch, type PluginRef, type PluginRegistry, type PluginSpec, prompt_d_exports as Prompt, type PromptResolver, section_d_exports as Section, type SharedPluginContext, tool_d_exports as Tool, define, domains, rank };
@@ -1,2 +1,2 @@
1
- import { A as RuntimeConfigBase, C as Module, D as Provisioned, E as Observed, F as driver, I as driver_d_exports, L as erase, M as Source, N as apiVersion, O as Registered, P as defineModule, R as withSource, S as Driver, T as Name, b as Capabilities, j as RuntimeInput, k as Registration, v as AbsolutePath, w as ModuleDefinition, x as Definition, y as ApiVersion } from "../io-nhvNKC33.mjs";
1
+ import { A as RuntimeConfigBase, C as Module, D as Provisioned, E as Observed, F as driver, I as driver_d_exports, L as erase, M as Source, N as apiVersion, O as Registered, P as defineModule, R as withSource, S as Driver, T as Name, b as Capabilities, j as RuntimeInput, k as Registration, v as AbsolutePath, w as ModuleDefinition, x as Definition, y as ApiVersion } from "../io-Br9WZTsG.mjs";
2
2
  export { AbsolutePath, ApiVersion, Capabilities, Definition, Driver, Module, ModuleDefinition, Name, Observed, Provisioned, Registered, Registration, RuntimeConfigBase, RuntimeInput, driver_d_exports as SandboxDriver, Source, apiVersion, driver, erase, defineModule as module, withSource };
@@ -1,2 +1,2 @@
1
- import { $ as SandboxRegisterError, B as SandboxBusyError, G as SandboxDriverNotRegisteredError, H as SandboxDestroyError, J as SandboxMustBeStoppedError, K as SandboxDriverRegistrationError, Q as SandboxRefreshError, U as SandboxDriverLoadError, V as SandboxCreateError, W as SandboxDriverLoadPhase, X as SandboxProviderError, Y as SandboxNotFoundError, Z as SandboxReadError, at as SandboxWakeError, ct as providerError, dt as sanitizeError, et as SandboxRemovedError, it as SandboxUnsupportedError, lt as providerErrorCause, nt as SandboxTransitionConflictError, ot as errors_d_exports, q as SandboxMountError, rt as SandboxUnavailError, st as makeRedactor, tt as SandboxStopError, ut as providerErrorIsNotFound, z as Redactor } from "../io-nhvNKC33.mjs";
1
+ import { $ as SandboxRegisterError, B as SandboxBusyError, G as SandboxDriverNotRegisteredError, H as SandboxDestroyError, J as SandboxMustBeStoppedError, K as SandboxDriverRegistrationError, Q as SandboxRefreshError, U as SandboxDriverLoadError, V as SandboxCreateError, W as SandboxDriverLoadPhase, X as SandboxProviderError, Y as SandboxNotFoundError, Z as SandboxReadError, at as SandboxWakeError, ct as providerError, dt as sanitizeError, et as SandboxRemovedError, it as SandboxUnsupportedError, lt as providerErrorCause, nt as SandboxTransitionConflictError, ot as errors_d_exports, q as SandboxMountError, rt as SandboxUnavailError, st as makeRedactor, tt as SandboxStopError, ut as providerErrorIsNotFound, z as Redactor } from "../io-Br9WZTsG.mjs";
2
2
  export { Redactor, SandboxBusyError, SandboxCreateError, SandboxDestroyError, SandboxDriverLoadError, SandboxDriverLoadPhase, SandboxDriverNotRegisteredError, SandboxDriverRegistrationError, errors_d_exports as SandboxError, SandboxMountError, SandboxMustBeStoppedError, SandboxNotFoundError, SandboxProviderError, SandboxReadError, SandboxRefreshError, SandboxRegisterError, SandboxRemovedError, SandboxStopError, SandboxTransitionConflictError, SandboxUnavailError, SandboxUnsupportedError, SandboxWakeError, makeRedactor, providerError, providerErrorCause, providerErrorIsNotFound, sanitizeError };
@@ -26,11 +26,19 @@ var errors_exports = /* @__PURE__ */ __exportAll({
26
26
  * Lifecycle errors are confined to the control plane. Once a mount succeeds,
27
27
  * consumers continue to see only FileSystemError and ShellError.
28
28
  */
29
- var SandboxNotFoundError = class extends Schema.TaggedError()("SandboxNotFoundError", { id: ID }) {};
29
+ var SandboxNotFoundError = class extends Schema.TaggedError()("SandboxNotFoundError", { id: ID }) {
30
+ get message() {
31
+ return `Sandbox ${this.id} does not exist.`;
32
+ }
33
+ };
30
34
  var SandboxDriverNotRegisteredError = class extends Schema.TaggedError()("SandboxDriverNotRegisteredError", {
31
35
  driver: Schema.String,
32
36
  registered: Schema.optional(Schema.Array(Schema.String))
33
- }) {};
37
+ }) {
38
+ get message() {
39
+ return `No sandbox driver named "${this.driver}" is registered.`;
40
+ }
41
+ };
34
42
  var SandboxDriverRegistrationError = class extends Schema.TaggedError()("SandboxDriverRegistrationError", {
35
43
  driver: Schema.String,
36
44
  reason: Schema.String
@@ -61,11 +69,19 @@ var SandboxMustBeStoppedError = class extends Schema.TaggedError()("SandboxMustB
61
69
  var SandboxRemovedError = class extends Schema.TaggedError()("SandboxRemovedError", {
62
70
  id: ID,
63
71
  removedAt: Schema.optional(Schema.DateTimeUtc)
64
- }) {};
72
+ }) {
73
+ get message() {
74
+ return `Sandbox ${this.id} was removed.`;
75
+ }
76
+ };
65
77
  var SandboxUnavailError = class extends Schema.TaggedError()("SandboxUnavailError", {
66
78
  id: ID,
67
79
  reason: Schema.String
68
- }) {};
80
+ }) {
81
+ get message() {
82
+ return `Sandbox ${this.id} is unavailable: ${this.reason}`;
83
+ }
84
+ };
69
85
  var SandboxUnsupportedError = class extends Schema.TaggedError()("SandboxUnsupportedError", {
70
86
  id: Schema.optional(ID),
71
87
  driver: Schema.String,
@@ -87,7 +103,11 @@ var SandboxProviderError = class extends Schema.TaggedError()("SandboxProviderEr
87
103
  driver: Schema.String,
88
104
  operation: Schema.String,
89
105
  sanitized: PersistedError
90
- }) {};
106
+ }) {
107
+ get message() {
108
+ return `The ${this.driver} sandbox failed to ${this.operation}: ${this.sanitized.message}`;
109
+ }
110
+ };
91
111
  const rawCause = Symbol("@codework/sandbox/provider/error/raw/cause");
92
112
  const missingResource = Symbol("@codework/sandbox/provider/error/missing/resource");
93
113
  const providerErrorCause = (error) => error[rawCause];
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":["SandboxInstance.ID","SandboxInstance.Status","SandboxInstance.PersistedError"],"sources":["../../../src/sandbox/errors.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport { SandboxInstance } from \"./instance.ts\";\n\n/**\n * Lifecycle errors are confined to the control plane. Once a mount succeeds,\n * consumers continue to see only FileSystemError and ShellError.\n */\nexport class SandboxNotFoundError extends Schema.TaggedError<SandboxNotFoundError>()(\"SandboxNotFoundError\", {\n\tid: SandboxInstance.ID,\n}) {}\n\nexport class SandboxDriverNotRegisteredError extends Schema.TaggedError<SandboxDriverNotRegisteredError>()(\n\t\"SandboxDriverNotRegisteredError\",\n\t{\n\t\tdriver: Schema.String,\n\t\tregistered: Schema.optional(Schema.Array(Schema.String)),\n\t},\n) {}\n\nexport class SandboxDriverRegistrationError extends Schema.TaggedError<SandboxDriverRegistrationError>()(\n\t\"SandboxDriverRegistrationError\",\n\t{\n\t\tdriver: Schema.String,\n\t\treason: Schema.String,\n\t},\n) {}\n\nexport const SandboxDriverLoadPhase = Schema.Literals([\n\t\"resolve\",\n\t\"import\",\n\t\"module\",\n\t\"api-version\",\n\t\"options\",\n\t\"factory\",\n\t\"registration\",\n]);\nexport type SandboxDriverLoadPhase = typeof SandboxDriverLoadPhase.Type;\n\nexport class SandboxDriverLoadError extends Schema.TaggedError<SandboxDriverLoadError>()(\"SandboxDriverLoadError\", {\n\tspecifier: Schema.String,\n\tphase: SandboxDriverLoadPhase,\n\tdriver: Schema.optional(Schema.String),\n\treason: Schema.String,\n}) {}\n\nexport class SandboxBusyError extends Schema.TaggedError<SandboxBusyError>()(\"SandboxBusyError\", {\n\tid: SandboxInstance.ID,\n\trefCount: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n}) {}\n\nexport class SandboxMustBeStoppedError extends Schema.TaggedError<SandboxMustBeStoppedError>()(\n\t\"SandboxMustBeStoppedError\",\n\t{\n\t\tid: SandboxInstance.ID,\n\t\tstatus: SandboxInstance.Status,\n\t},\n) {}\n\nexport class SandboxRemovedError extends Schema.TaggedError<SandboxRemovedError>()(\"SandboxRemovedError\", {\n\tid: SandboxInstance.ID,\n\tremovedAt: Schema.optional(Schema.DateTimeUtc),\n}) {}\n\nexport class SandboxUnavailError extends Schema.TaggedError<SandboxUnavailError>()(\"SandboxUnavailError\", {\n\tid: SandboxInstance.ID,\n\treason: Schema.String,\n}) {}\n\nexport class SandboxUnsupportedError extends Schema.TaggedError<SandboxUnsupportedError>()(\"SandboxUnsupportedError\", {\n\tid: Schema.optional(SandboxInstance.ID),\n\tdriver: Schema.String,\n\toperation: Schema.String,\n}) {}\n\nexport class SandboxTransitionConflictError extends Schema.TaggedError<SandboxTransitionConflictError>()(\n\t\"SandboxTransitionConflictError\",\n\t{\n\t\tid: SandboxInstance.ID,\n\t\texpected: Schema.Array(SandboxInstance.Status),\n\t\tactual: SandboxInstance.Status,\n\t},\n) {}\n\n/**\n * A lifecycle failure safe to serialize, persist, or log.\n *\n * The raw SDK defect is deliberately absent from the schema. It is retained on\n * a non-enumerable symbol by {@link providerError}, so Effect's default\n * formatting and JSON serialization cannot expose credentials nested in it.\n */\nexport class SandboxProviderError extends Schema.TaggedError<SandboxProviderError>()(\"SandboxProviderError\", {\n\tdriver: Schema.String,\n\toperation: Schema.String,\n\tsanitized: SandboxInstance.PersistedError,\n}) {}\n\nconst rawCause = Symbol(\"@codework/sandbox/provider/error/raw/cause\");\nconst missingResource = Symbol(\"@codework/sandbox/provider/error/missing/resource\");\n\nexport const providerErrorCause = (error: SandboxProviderError): unknown =>\n\t(error as SandboxProviderError & { readonly [rawCause]?: unknown })[rawCause];\n\nexport const providerErrorIsNotFound = (error: SandboxProviderError): boolean =>\n\t(error as SandboxProviderError & { readonly [missingResource]?: boolean })[missingResource] === true;\n\nexport type Redactor = (value: string) => string;\n\nconst REDACTED = \"<redacted>\";\n\n/**\n * Conservative text redaction shared by every driver sanitizer.\n *\n * Disclaimer: This can really leak. Its never safe\n *\n * Configured secrets are removed exactly. Common authorization/header and URL\n * query shapes are masked as a second line of defence for values the caller did\n * not explicitly seed.\n *\n * Note: add support for diff regex as needed.\n */\nexport const makeRedactor = (secrets: Iterable<string> = []): Redactor => {\n\tconst configured = [...secrets].filter((secret) => secret.length > 0).sort((a, b) => b.length - a.length);\n\treturn (value) => {\n\t\tlet redacted = value;\n\t\tfor (const secret of configured) redacted = redacted.replaceAll(secret, REDACTED);\n\t\treturn redacted\n\t\t\t.replace(/\\b(authorization\\s*:\\s*(?:bearer|basic)\\s+)[^\\s,;]+/gi, `$1${REDACTED}`)\n\t\t\t.replace(/\\b((?:api[-_]?key|token|secret|password)\\s*[=:]\\s*)[^\\s,;&]+/gi, `$1${REDACTED}`)\n\t\t\t.replace(/([?&](?:access_token|api_key|token|secret|password)=)[^&#\\s]+/gi, `$1${REDACTED}`)\n\t\t\t.replace(/\\b(?:gh[opsu]_[A-Za-z0-9_]{20,}|github_pat_[A-Za-z0-9_]{20,})\\b/g, REDACTED);\n\t};\n};\n\nconst errorCode = (cause: unknown): string | undefined => {\n\tif (typeof cause !== \"object\" || cause === null || !(\"code\" in cause)) return undefined;\n\tconst code = cause.code;\n\treturn typeof code === \"string\" || typeof code === \"number\" ? String(code) : undefined;\n};\n\nconst errorName = (cause: unknown): string => {\n\tif (typeof cause !== \"object\" || cause === null || !(\"name\" in cause) || typeof cause.name !== \"string\")\n\t\treturn \"Error\";\n\treturn cause.name;\n};\n\nconst errorMessage = (cause: unknown): string => {\n\tif (typeof cause === \"object\" && cause !== null && \"message\" in cause && typeof cause.message === \"string\")\n\t\treturn cause.message;\n\treturn String(cause);\n};\n\nexport const sanitizeError = (cause: unknown, redact: Redactor = makeRedactor()): SandboxInstance.PersistedError => {\n\tconst code = errorCode(cause);\n\treturn {\n\t\tname: redact(errorName(cause)),\n\t\tmessage: redact(errorMessage(cause)),\n\t\t...(code === undefined ? {} : { code: redact(code) }),\n\t};\n};\n\nexport const providerError = (input: {\n\treadonly driver: string;\n\treadonly operation: string;\n\treadonly cause: unknown;\n\treadonly redact?: Redactor;\n\treadonly sanitize?: (cause: unknown, redact: Redactor) => SandboxInstance.PersistedError;\n\treadonly notFound?: boolean;\n}): SandboxProviderError => {\n\tconst redact = input.redact ?? makeRedactor();\n\tconst error = new SandboxProviderError({\n\t\tdriver: input.driver,\n\t\toperation: input.operation,\n\t\tsanitized: (input.sanitize ?? sanitizeError)(input.cause, redact),\n\t});\n\tObject.defineProperty(error, rawCause, {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\tvalue: input.cause,\n\t\twritable: false,\n\t});\n\tObject.defineProperty(error, missingResource, {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\tvalue: input.notFound === true,\n\t\twritable: false,\n\t});\n\treturn error;\n};\n\nexport type SandboxMountError =\n\t| SandboxNotFoundError\n\t| SandboxDriverNotRegisteredError\n\t| SandboxUnavailError\n\t| SandboxRemovedError\n\t| SandboxProviderError;\n\nexport type SandboxCreateError =\n\t| SandboxDriverNotRegisteredError\n\t| SandboxDriverRegistrationError\n\t| SandboxProviderError;\n\nexport type SandboxRegisterError =\n\t| SandboxDriverNotRegisteredError\n\t| SandboxDriverRegistrationError\n\t| SandboxUnsupportedError\n\t| SandboxProviderError;\n\nexport type SandboxReadError = never;\n\nexport type SandboxRefreshError =\n\t| SandboxNotFoundError\n\t| SandboxDriverNotRegisteredError\n\t| SandboxUnavailError\n\t| SandboxUnsupportedError\n\t| SandboxProviderError;\n\nexport type SandboxWakeError = SandboxRefreshError | SandboxRemovedError;\n\nexport type SandboxStopError = SandboxWakeError | SandboxBusyError | SandboxTransitionConflictError;\n\nexport type SandboxDestroyError = SandboxStopError | SandboxMustBeStoppedError;\n\nexport * as SandboxError from \"./errors.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAAC,wBAAwB,EAC5G,IAAIA,GACL,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,kCAAb,cAAqD,OAAO,YAA6C,CAAC,CACzG,mCACA;CACC,QAAQ,OAAO;CACf,YAAY,OAAO,SAAS,OAAO,MAAM,OAAO,MAAM,CAAC;AACxD,CACD,CAAC,CAAC,CAAC;AAEH,IAAa,iCAAb,cAAoD,OAAO,YAA4C,CAAC,CACvG,kCACA;CACC,QAAQ,OAAO;CACf,QAAQ,OAAO;AACh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CAC5B,OAAO;EACN,MAAM,OAAO,UAAU,KAAK,CAAC;EAC7B,SAAS,OAAO,aAAa,KAAK,CAAC;EACnC,GAAI,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,OAAO,IAAI,EAAE;CACpD;AACD;AAEA,MAAa,iBAAiB,UAOF;CAC3B,MAAM,SAAS,MAAM,UAAU,aAAa;CAC5C,MAAM,QAAQ,IAAI,qBAAqB;EACtC,QAAQ,MAAM;EACd,WAAW,MAAM;EACjB,YAAY,MAAM,YAAY,cAAA,CAAe,MAAM,OAAO,MAAM;CACjE,CAAC;CACD,OAAO,eAAe,OAAO,UAAU;EACtC,cAAc;EACd,YAAY;EACZ,OAAO,MAAM;EACb,UAAU;CACX,CAAC;CACD,OAAO,eAAe,OAAO,iBAAiB;EAC7C,cAAc;EACd,YAAY;EACZ,OAAO,MAAM,aAAa;EAC1B,UAAU;CACX,CAAC;CACD,OAAO;AACR"}
1
+ {"version":3,"file":"errors.mjs","names":["SandboxInstance.ID","SandboxInstance.Status","SandboxInstance.PersistedError"],"sources":["../../../src/sandbox/errors.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport { SandboxInstance } from \"./instance.ts\";\n\n/**\n * Lifecycle errors are confined to the control plane. Once a mount succeeds,\n * consumers continue to see only FileSystemError and ShellError.\n */\nexport class SandboxNotFoundError extends Schema.TaggedError<SandboxNotFoundError>()(\"SandboxNotFoundError\", {\n\tid: SandboxInstance.ID,\n}) {\n\toverride get message(): string {\n\t\treturn `Sandbox ${this.id} does not exist.`;\n\t}\n}\n\nexport class SandboxDriverNotRegisteredError extends Schema.TaggedError<SandboxDriverNotRegisteredError>()(\n\t\"SandboxDriverNotRegisteredError\",\n\t{\n\t\tdriver: Schema.String,\n\t\tregistered: Schema.optional(Schema.Array(Schema.String)),\n\t},\n) {\n\toverride get message(): string {\n\t\treturn `No sandbox driver named \"${this.driver}\" is registered.`;\n\t}\n}\n\nexport class SandboxDriverRegistrationError extends Schema.TaggedError<SandboxDriverRegistrationError>()(\n\t\"SandboxDriverRegistrationError\",\n\t{\n\t\tdriver: Schema.String,\n\t\treason: Schema.String,\n\t},\n) {}\n\nexport const SandboxDriverLoadPhase = Schema.Literals([\n\t\"resolve\",\n\t\"import\",\n\t\"module\",\n\t\"api-version\",\n\t\"options\",\n\t\"factory\",\n\t\"registration\",\n]);\nexport type SandboxDriverLoadPhase = typeof SandboxDriverLoadPhase.Type;\n\nexport class SandboxDriverLoadError extends Schema.TaggedError<SandboxDriverLoadError>()(\"SandboxDriverLoadError\", {\n\tspecifier: Schema.String,\n\tphase: SandboxDriverLoadPhase,\n\tdriver: Schema.optional(Schema.String),\n\treason: Schema.String,\n}) {}\n\nexport class SandboxBusyError extends Schema.TaggedError<SandboxBusyError>()(\"SandboxBusyError\", {\n\tid: SandboxInstance.ID,\n\trefCount: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n}) {}\n\nexport class SandboxMustBeStoppedError extends Schema.TaggedError<SandboxMustBeStoppedError>()(\n\t\"SandboxMustBeStoppedError\",\n\t{\n\t\tid: SandboxInstance.ID,\n\t\tstatus: SandboxInstance.Status,\n\t},\n) {}\n\nexport class SandboxRemovedError extends Schema.TaggedError<SandboxRemovedError>()(\"SandboxRemovedError\", {\n\tid: SandboxInstance.ID,\n\tremovedAt: Schema.optional(Schema.DateTimeUtc),\n}) {\n\toverride get message(): string {\n\t\treturn `Sandbox ${this.id} was removed.`;\n\t}\n}\n\nexport class SandboxUnavailError extends Schema.TaggedError<SandboxUnavailError>()(\"SandboxUnavailError\", {\n\tid: SandboxInstance.ID,\n\treason: Schema.String,\n}) {\n\toverride get message(): string {\n\t\treturn `Sandbox ${this.id} is unavailable: ${this.reason}`;\n\t}\n}\n\nexport class SandboxUnsupportedError extends Schema.TaggedError<SandboxUnsupportedError>()(\"SandboxUnsupportedError\", {\n\tid: Schema.optional(SandboxInstance.ID),\n\tdriver: Schema.String,\n\toperation: Schema.String,\n}) {}\n\nexport class SandboxTransitionConflictError extends Schema.TaggedError<SandboxTransitionConflictError>()(\n\t\"SandboxTransitionConflictError\",\n\t{\n\t\tid: SandboxInstance.ID,\n\t\texpected: Schema.Array(SandboxInstance.Status),\n\t\tactual: SandboxInstance.Status,\n\t},\n) {}\n\n/**\n * A lifecycle failure safe to serialize, persist, or log.\n *\n * The raw SDK defect is deliberately absent from the schema. It is retained on\n * a non-enumerable symbol by {@link providerError}, so Effect's default\n * formatting and JSON serialization cannot expose credentials nested in it.\n */\nexport class SandboxProviderError extends Schema.TaggedError<SandboxProviderError>()(\"SandboxProviderError\", {\n\tdriver: Schema.String,\n\toperation: Schema.String,\n\tsanitized: SandboxInstance.PersistedError,\n}) {\n\toverride get message(): string {\n\t\treturn `The ${this.driver} sandbox failed to ${this.operation}: ${this.sanitized.message}`;\n\t}\n}\n\nconst rawCause = Symbol(\"@codework/sandbox/provider/error/raw/cause\");\nconst missingResource = Symbol(\"@codework/sandbox/provider/error/missing/resource\");\n\nexport const providerErrorCause = (error: SandboxProviderError): unknown =>\n\t(error as SandboxProviderError & { readonly [rawCause]?: unknown })[rawCause];\n\nexport const providerErrorIsNotFound = (error: SandboxProviderError): boolean =>\n\t(error as SandboxProviderError & { readonly [missingResource]?: boolean })[missingResource] === true;\n\nexport type Redactor = (value: string) => string;\n\nconst REDACTED = \"<redacted>\";\n\n/**\n * Conservative text redaction shared by every driver sanitizer.\n *\n * Disclaimer: This can really leak. Its never safe\n *\n * Configured secrets are removed exactly. Common authorization/header and URL\n * query shapes are masked as a second line of defence for values the caller did\n * not explicitly seed.\n *\n * Note: add support for diff regex as needed.\n */\nexport const makeRedactor = (secrets: Iterable<string> = []): Redactor => {\n\tconst configured = [...secrets].filter((secret) => secret.length > 0).sort((a, b) => b.length - a.length);\n\treturn (value) => {\n\t\tlet redacted = value;\n\t\tfor (const secret of configured) redacted = redacted.replaceAll(secret, REDACTED);\n\t\treturn redacted\n\t\t\t.replace(/\\b(authorization\\s*:\\s*(?:bearer|basic)\\s+)[^\\s,;]+/gi, `$1${REDACTED}`)\n\t\t\t.replace(/\\b((?:api[-_]?key|token|secret|password)\\s*[=:]\\s*)[^\\s,;&]+/gi, `$1${REDACTED}`)\n\t\t\t.replace(/([?&](?:access_token|api_key|token|secret|password)=)[^&#\\s]+/gi, `$1${REDACTED}`)\n\t\t\t.replace(/\\b(?:gh[opsu]_[A-Za-z0-9_]{20,}|github_pat_[A-Za-z0-9_]{20,})\\b/g, REDACTED);\n\t};\n};\n\nconst errorCode = (cause: unknown): string | undefined => {\n\tif (typeof cause !== \"object\" || cause === null || !(\"code\" in cause)) return undefined;\n\tconst code = cause.code;\n\treturn typeof code === \"string\" || typeof code === \"number\" ? String(code) : undefined;\n};\n\nconst errorName = (cause: unknown): string => {\n\tif (typeof cause !== \"object\" || cause === null || !(\"name\" in cause) || typeof cause.name !== \"string\")\n\t\treturn \"Error\";\n\treturn cause.name;\n};\n\nconst errorMessage = (cause: unknown): string => {\n\tif (typeof cause === \"object\" && cause !== null && \"message\" in cause && typeof cause.message === \"string\")\n\t\treturn cause.message;\n\treturn String(cause);\n};\n\nexport const sanitizeError = (cause: unknown, redact: Redactor = makeRedactor()): SandboxInstance.PersistedError => {\n\tconst code = errorCode(cause);\n\treturn {\n\t\tname: redact(errorName(cause)),\n\t\tmessage: redact(errorMessage(cause)),\n\t\t...(code === undefined ? {} : { code: redact(code) }),\n\t};\n};\n\nexport const providerError = (input: {\n\treadonly driver: string;\n\treadonly operation: string;\n\treadonly cause: unknown;\n\treadonly redact?: Redactor;\n\treadonly sanitize?: (cause: unknown, redact: Redactor) => SandboxInstance.PersistedError;\n\treadonly notFound?: boolean;\n}): SandboxProviderError => {\n\tconst redact = input.redact ?? makeRedactor();\n\tconst error = new SandboxProviderError({\n\t\tdriver: input.driver,\n\t\toperation: input.operation,\n\t\tsanitized: (input.sanitize ?? sanitizeError)(input.cause, redact),\n\t});\n\tObject.defineProperty(error, rawCause, {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\tvalue: input.cause,\n\t\twritable: false,\n\t});\n\tObject.defineProperty(error, missingResource, {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\tvalue: input.notFound === true,\n\t\twritable: false,\n\t});\n\treturn error;\n};\n\nexport type SandboxMountError =\n\t| SandboxNotFoundError\n\t| SandboxDriverNotRegisteredError\n\t| SandboxUnavailError\n\t| SandboxRemovedError\n\t| SandboxProviderError;\n\nexport type SandboxCreateError =\n\t| SandboxDriverNotRegisteredError\n\t| SandboxDriverRegistrationError\n\t| SandboxProviderError;\n\nexport type SandboxRegisterError =\n\t| SandboxDriverNotRegisteredError\n\t| SandboxDriverRegistrationError\n\t| SandboxUnsupportedError\n\t| SandboxProviderError;\n\nexport type SandboxReadError = never;\n\nexport type SandboxRefreshError =\n\t| SandboxNotFoundError\n\t| SandboxDriverNotRegisteredError\n\t| SandboxUnavailError\n\t| SandboxUnsupportedError\n\t| SandboxProviderError;\n\nexport type SandboxWakeError = SandboxRefreshError | SandboxRemovedError;\n\nexport type SandboxStopError = SandboxWakeError | SandboxBusyError | SandboxTransitionConflictError;\n\nexport type SandboxDestroyError = SandboxStopError | SandboxMustBeStoppedError;\n\nexport * as SandboxError from \"./errors.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAAC,wBAAwB,EAC5G,IAAIA,GACL,CAAC,CAAC,CAAC;CACF,IAAa,UAAkB;EAC9B,OAAO,WAAW,KAAK,GAAG;CAC3B;AACD;AAEA,IAAa,kCAAb,cAAqD,OAAO,YAA6C,CAAC,CACzG,mCACA;CACC,QAAQ,OAAO;CACf,YAAY,OAAO,SAAS,OAAO,MAAM,OAAO,MAAM,CAAC;AACxD,CACD,CAAC,CAAC;CACD,IAAa,UAAkB;EAC9B,OAAO,4BAA4B,KAAK,OAAO;CAChD;AACD;AAEA,IAAa,iCAAb,cAAoD,OAAO,YAA4C,CAAC,CACvG,kCACA;CACC,QAAQ,OAAO;CACf,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ACd;AAEA,MAAM,gBAAgB,UAA2B;CAChD,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,aAAa,SAAS,OAAO,MAAM,YAAY,UACjG,OAAO,MAAM;CACd,OAAO,OAAO,KAAK;AACpB;AAEA,MAAa,iBAAiB,OAAgB,SAAmB,aAAa,MAAsC;CACnH,MAAM,OAAO,UAAU,KAAK;CAC5B,OAAO;EACN,MAAM,OAAO,UAAU,KAAK,CAAC;EAC7B,SAAS,OAAO,aAAa,KAAK,CAAC;EACnC,GAAI,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,OAAO,IAAI,EAAE;CACpD;AACD;AAEA,MAAa,iBAAiB,UAOF;CAC3B,MAAM,SAAS,MAAM,UAAU,aAAa;CAC5C,MAAM,QAAQ,IAAI,qBAAqB;EACtC,QAAQ,MAAM;EACd,WAAW,MAAM;EACjB,YAAY,MAAM,YAAY,cAAA,CAAe,MAAM,OAAO,MAAM;CACjE,CAAC;CACD,OAAO,eAAe,OAAO,UAAU;EACtC,cAAc;EACd,YAAY;EACZ,OAAO,MAAM;EACb,UAAU;CACX,CAAC;CACD,OAAO,eAAe,OAAO,iBAAiB;EAC7C,cAAc;EACd,YAAY;EACZ,OAAO,MAAM,aAAa;EAC1B,UAAU;CACX,CAAC;CACD,OAAO;AACR"}
@@ -1,2 +1,2 @@
1
- import { Ct as mountable, St as isMountable, Tt as toField, _t as Status, bt as fromField, ft as ID, gt as PersistedError, ht as Ownership, mt as Kind, pt as Info, vt as Usage, wt as toColumn, xt as instance_d_exports, yt as fromColumn } from "../io-nhvNKC33.mjs";
1
+ import { Ct as mountable, St as isMountable, Tt as toField, _t as Status, bt as fromField, ft as ID, gt as PersistedError, ht as Ownership, mt as Kind, pt as Info, vt as Usage, wt as toColumn, xt as instance_d_exports, yt as fromColumn } from "../io-Br9WZTsG.mjs";
2
2
  export { ID, Info, Kind, Ownership, PersistedError, instance_d_exports as SandboxInstance, Status, Usage, fromColumn, fromField, isMountable, mountable, toColumn, toField };
package/sandbox/io.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as withMutation, a as Layer, c as Shell, d as identityLayer, f as io_d_exports, g as virtual, h as resolveMountCwd, i as Identity, l as host, m as remote, n as DEFAULT_SPILL_PATH, o as Mutation, p as mount, r as FileSystem, s as Provides, t as Current, u as hostLayer } from "../io-nhvNKC33.mjs";
1
+ import { _ as withMutation, a as Layer, c as Shell, d as identityLayer, f as io_d_exports, g as virtual, h as resolveMountCwd, i as Identity, l as host, m as remote, n as DEFAULT_SPILL_PATH, o as Mutation, p as mount, r as FileSystem, s as Provides, t as Current, u as hostLayer } from "../io-Br9WZTsG.mjs";
2
2
  export { Current, DEFAULT_SPILL_PATH, FileSystem, Identity, Layer, Mutation, Provides, io_d_exports as SandboxIO, Shell, host, hostLayer, identityLayer, mount, remote, resolveMountCwd, virtual, withMutation };
package/sandbox.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as RuntimeConfigBase, C as Module, D as Provisioned, E as Observed, F as driver, N as apiVersion, P as defineModule, S as Driver, T as Name, X as SandboxProviderError, _ as withMutation, a as Layer, b as Capabilities, c as Shell, ct as providerError, dt as sanitizeError, i as Identity, j as RuntimeInput, k as Registration, lt as providerErrorCause, n as DEFAULT_SPILL_PATH, o as Mutation, r as FileSystem, s as Provides, st as makeRedactor, t as Current, ut as providerErrorIsNotFound, v as AbsolutePath, w as ModuleDefinition, x as Definition, xt as instance_d_exports, y as ApiVersion, z as Redactor } from "./io-nhvNKC33.mjs";
1
+ import { A as RuntimeConfigBase, C as Module, D as Provisioned, E as Observed, F as driver, N as apiVersion, P as defineModule, S as Driver, T as Name, X as SandboxProviderError, _ as withMutation, a as Layer, b as Capabilities, c as Shell, ct as providerError, dt as sanitizeError, i as Identity, j as RuntimeInput, k as Registration, lt as providerErrorCause, n as DEFAULT_SPILL_PATH, o as Mutation, r as FileSystem, s as Provides, st as makeRedactor, t as Current, ut as providerErrorIsNotFound, v as AbsolutePath, w as ModuleDefinition, x as Definition, xt as instance_d_exports, y as ApiVersion, z as Redactor } from "./io-Br9WZTsG.mjs";
2
2
  import { c as filesystem_d_exports } from "./filesystem-CuGE9poU.mjs";
3
3
  import { a as ShellError, i as Shell$1, l as quote, n as ExecResult, o as ShellOptions, r as ISandboxExe, s as fromExec, t as ExecChunk, u as quoteArgv } from "./shell-CZ6Y4lNU.mjs";
4
4
  import { SandboxResource as resource_d_exports } from "./sandbox/resource.mjs";
@@ -110,6 +110,7 @@ declare const ModelEntry: Schema.decodeTo<Schema.declare<{
110
110
  supportsOpenAIGrammarTools?: boolean;
111
111
  supportsThinkingTokenBudget?: boolean;
112
112
  forceAdaptiveThinking?: boolean;
113
+ supportsTemperature?: boolean;
113
114
  thinkingTokenBudgetField?: string;
114
115
  };
115
116
  contextWindow: number;
@@ -190,6 +191,7 @@ declare const ModelEntry: Schema.decodeTo<Schema.declare<{
190
191
  supportsOpenAIGrammarTools?: boolean;
191
192
  supportsThinkingTokenBudget?: boolean;
192
193
  forceAdaptiveThinking?: boolean;
194
+ supportsTemperature?: boolean;
193
195
  thinkingTokenBudgetField?: string;
194
196
  };
195
197
  contextWindow: number;
@@ -367,6 +369,7 @@ declare const Patch: Schema.Struct<{
367
369
  supportsOpenAIGrammarTools?: boolean;
368
370
  supportsThinkingTokenBudget?: boolean;
369
371
  forceAdaptiveThinking?: boolean;
372
+ supportsTemperature?: boolean;
370
373
  thinkingTokenBudgetField?: string;
371
374
  };
372
375
  contextWindow: number;
@@ -447,6 +450,7 @@ declare const Patch: Schema.Struct<{
447
450
  supportsOpenAIGrammarTools?: boolean;
448
451
  supportsThinkingTokenBudget?: boolean;
449
452
  forceAdaptiveThinking?: boolean;
453
+ supportsTemperature?: boolean;
450
454
  thinkingTokenBudgetField?: string;
451
455
  };
452
456
  contextWindow: number;
@@ -584,4 +588,4 @@ interface Info {
584
588
  declare const defaults: Info;
585
589
  //#endregion
586
590
  export { keyName as _, KeyReference as a, ModelProtocol as c, PluginPatch as d, Retry as f, defaults as g, ToolExecution as h, Info as i, Patch as l, ThinkingLevel as m, Declared as n, Model$1 as o, RetryPolicy as p, DeclaredModel as r, ModelEntry as s, Block as t, PluginEntry as u, requestFields as v };
587
- //# sourceMappingURL=settings-47Mzxhl0.d.mts.map
591
+ //# sourceMappingURL=settings-DGYWREuu.d.mts.map
package/settings.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as keyName, a as KeyReference, c as ModelProtocol, d as PluginPatch, f as Retry, g as defaults, h as ToolExecution, i as Info, l as Patch, m as ThinkingLevel, n as Declared, o as Model, p as RetryPolicy, r as DeclaredModel, s as ModelEntry, t as Block, u as PluginEntry, v as requestFields } from "./settings-47Mzxhl0.mjs";
1
+ import { _ as keyName, a as KeyReference, c as ModelProtocol, d as PluginPatch, f as Retry, g as defaults, h as ToolExecution, i as Info, l as Patch, m as ThinkingLevel, n as Declared, o as Model, p as RetryPolicy, r as DeclaredModel, s as ModelEntry, t as Block, u as PluginEntry, v as requestFields } from "./settings-DGYWREuu.mjs";
2
2
  export { Block, Declared, DeclaredModel, Info, KeyReference, Model, ModelEntry, ModelProtocol, Patch, PluginEntry, PluginPatch, Retry, RetryPolicy, ThinkingLevel, ToolExecution, defaults, keyName, requestFields };
package/settings.mjs CHANGED
@@ -133,7 +133,7 @@ const defaults = {
133
133
  model: {
134
134
  provider: "openai",
135
135
  id: "gpt-5.6-luna",
136
- thinkingLevel: "high",
136
+ thinkingLevel: "medium",
137
137
  toolExecution: "sequential",
138
138
  options: {
139
139
  timeoutMs: 36e5,
package/settings.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"settings.mjs","names":["AikitModel"],"sources":["../../src/settings.ts"],"sourcesContent":["import { Model as AikitModel, type Protocol } from \"@codeworksh/aikit\";\nimport { Effect, Schema, type SchemaAST, SchemaGetter, SchemaIssue } from \"effect\";\nimport { isAikitModelInfo, NonNegativeInt, validateAikitModelInfo } from \"./schema.ts\";\n\nexport const ThinkingLevel = Schema.Literals(Object.values(AikitModel.ThinkingLevelEnum));\nexport const ToolExecution = Schema.Literals([\"sequential\", \"parallel\"]);\nexport type ToolExecution = typeof ToolExecution.Type;\nconst Budgets = Schema.Record(\n\tSchema.Literals(Object.values(AikitModel.ThinkingLevelEnum).filter((level) => level !== \"off\")),\n\tSchema.optional(Schema.Finite),\n);\n\n/** Aikit does not export its request schema; keep this routing surface checked against its public types. */\nexport const requestFields = {\n\ttemperature: Schema.optional(Schema.Finite),\n\tmaxTokens: Schema.optional(Schema.Finite),\n\tcacheRetention: Schema.optional(Schema.Literals([\"none\", \"short\", \"long\"])),\n\theaders: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n\ttimeoutMs: Schema.optional(Schema.Finite),\n\tidleTimeoutMs: Schema.optional(Schema.Finite),\n\tmaxRetries: Schema.optional(Schema.Finite),\n\tmetadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),\n\tthinkingBudgets: Schema.optional(Budgets),\n\tbaseURL: Schema.optional(Schema.String),\n\tmethod: Schema.optional(Schema.Literals(Object.values(AikitModel.APIMethodEnum))),\n} satisfies Record<\n\t| Exclude<keyof Protocol.CommonOptions, \"signal\" | \"sessionId\" | \"reasoning\" | \"apiKey\" | \"onPayload\">\n\t| \"baseURL\"\n\t| \"method\",\n\tSchema.Top\n>;\n\n/**\n * An API key named, never written: `\"${NAME}\"`, read from the host process environment when the\n * model is called. Settings only ever hold the variable's name.\n */\nconst keyReference = /^\\$\\{([A-Za-z_][A-Za-z0-9_]*)\\}$/;\nconst keyReferenceError = 'apiKey must reference an environment variable, e.g. \"${OPENAI_API_KEY}\"';\nexport const KeyReference = Schema.String.check(\n\tSchema.makeFilter((value) => keyReference.test(value) || keyReferenceError),\n);\n\n/** The variable a `\"${NAME}\"` reference names. */\nexport const keyName = (reference: string): string => keyReference.exec(reference)?.[1] ?? reference;\n\nconst reserved = new Set([\n\t\"toolChoice\",\n\t\"activeTools\",\n\t\"provider\",\n\t\"id\",\n\t\"signal\",\n\t\"sessionId\",\n\t\"reasoning\",\n\t\"modelId\",\n\t\"onPayload\",\n\t\"api\",\n\t\"npm\",\n\t\"providerOptionsKey\",\n\t\"compat\",\n\t\"thinkingLevelMap\",\n]);\n\n/** The wire protocol a model speaks, which a catalog entry may have wrong for a local endpoint. */\nexport const ModelProtocol = Schema.Literals(Object.values(AikitModel.KnownProviderEnum));\n\nexport const Block = Schema.StructWithRest(\n\tSchema.Struct({\n\t\t...requestFields,\n\t\tprotocol: Schema.optional(ModelProtocol),\n\t\tthinkingLevel: Schema.optional(ThinkingLevel),\n\t\ttoolExecution: Schema.optional(ToolExecution),\n\t\tcontextWindow: Schema.optional(Schema.Finite),\n\t\t/** Which environment variable holds the key for this model: `\"${NAME}\"`. */\n\t\tapiKey: Schema.optional(KeyReference),\n\t\textras: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),\n\t}),\n\t[Schema.Record(Schema.String, Schema.Unknown)],\n).check(\n\tSchema.makeFilter(\n\t\t(value) => Object.keys(value).every((key) => !reserved.has(key)) || \"Reserved configuration key in model options\",\n\t),\n);\nexport type Block = typeof Block.Type;\n\nexport const Model = Schema.Struct({\n\tprovider: Schema.optional(Schema.String),\n\tid: Schema.optional(Schema.String),\n\tthinkingLevel: Schema.optional(ThinkingLevel),\n\ttoolExecution: Schema.optional(ToolExecution),\n\tthinkingBudgets: Schema.optional(Budgets),\n\toptions: Schema.optional(Block),\n\tproviderOptions: Schema.optional(Schema.Record(Schema.String, Schema.Record(Schema.String, Block))),\n});\nconst reasonOf = (cause: unknown): string => (cause instanceof Error ? cause.message : String(cause));\n\nconst decodeModelEntry = (value: unknown, options: SchemaAST.ParseOptions) =>\n\tEffect.try({\n\t\ttry: () => {\n\t\t\tconst entry = validateAikitModelInfo(value, \"models entry\");\n\t\t\tif (entry.provider.key !== undefined && !keyReference.test(entry.provider.key)) {\n\t\t\t\tthrow new Error(`models entry ${entry.provider.id}/${entry.id}: provider.key: ${keyReferenceError}`);\n\t\t\t}\n\t\t\treturn entry;\n\t\t},\n\t\tcatch: (cause) => new SchemaIssue.InvalidValue({ message: reasonOf(cause) }, value, options),\n\t});\n\n/**\n * A catalog entry in settings: an aikit `Model.Info`, read exactly like an entry of the generated\n * catalog. The one difference is `provider.key`, which must be a `\"${NAME}\"` reference.\n */\nexport const ModelEntry = Schema.Unknown.pipe(\n\tSchema.decodeTo(Schema.declare<AikitModel.Info>(isAikitModelInfo, { expected: \"aikit Model.Info\" }), {\n\t\tdecode: SchemaGetter.transformEffect(decodeModelEntry),\n\t\tencode: SchemaGetter.transformEffect(decodeModelEntry),\n\t}),\n);\nexport type ModelEntry = typeof ModelEntry.Type;\n\n/** A module to load: a path, a `file:` URL, or a package spec. */\nconst PluginReference = Schema.String.check(Schema.isNonEmpty());\n/**\n * Configuration for a plugin something else already selected, named by its ID (`plugin`) or by\n * its registered module string (`package`). It never loads anything: an entry naming a plugin\n * that is not in the selection is ignored.\n */\nconst config = {\n\tenabled: Schema.optional(Schema.Boolean),\n\toptions: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),\n};\nexport const PluginPatch = Schema.Union(\n\t[Schema.Struct({ plugin: PluginReference, ...config }), Schema.Struct({ package: PluginReference, ...config })],\n\t// `oneOf`, so an entry carrying both keys is a decode failure rather than one of them being\n\t// quietly dropped -- naming a plugin two ways at once says two different things.\n\t{ mode: \"oneOf\" },\n);\nexport const PluginEntry = Schema.Union([PluginReference, PluginPatch]);\nexport type PluginEntry = typeof PluginEntry.Type;\n\n/**\n * Agent-level retry of a turn whose provider request failed transiently (rate limit, overload,\n * 5xx, dropped connection). Delays double from `baseDelayMs` and stop growing at `maxDelayMs`;\n * a server that asks for a longer wait than `maxDelayMs` is not retried. `maxRetries: 0` is off.\n *\n * Separate from `model.options.maxRetries`, which retries inside the provider SDK and defaults to\n * 0 so that the two do not multiply, and so a quota error reaches the loop instead of being retried.\n */\nexport const Retry = Schema.Struct({\n\tmaxRetries: Schema.optional(NonNegativeInt),\n\tbaseDelayMs: Schema.optional(NonNegativeInt),\n\tmaxDelayMs: Schema.optional(NonNegativeInt),\n});\nexport interface RetryPolicy {\n\treadonly maxRetries: number;\n\treadonly baseDelayMs: number;\n\treadonly maxDelayMs: number;\n}\n\nexport const Patch = Schema.Struct({\n\t$schema: Schema.optional(Schema.String),\n\tplugins: Schema.optional(Schema.Array(PluginEntry)),\n\tmodel: Schema.optional(Model),\n\tmodels: Schema.optional(Schema.Array(ModelEntry)),\n\tretry: Schema.optional(Retry),\n});\nexport type Patch = typeof Patch.Type;\n\n/**\n * One plugin entry, and where it came from.\n *\n * Flattening every layer's `plugins` into one array loses the file that declared each entry, and\n * that cannot be recovered afterwards: two layers may declare the same string, so attribution is\n * genuinely gone rather than merely inconvenient. Three things need it -- anchoring a relative\n * path, naming the declaring layer in `plugin list`, and the missing-plugin diagnostic -- so the\n * loaded shape carries it from the start.\n *\n * In simple terms:\n * `written` - is what module the developer is declaring - what\n * `file` - where the module is being declared - where\n * `entry` - the resolved path of the module, relative to the `file`; especially needed for local.\n *\n * Example:\n * written: \"@acme/x@^1\"\n * entry: \"@acme/x@^1\"\n * file: \"/Users/me/.codework/settings.jsonc\"\n *\n * written: \"./plugins/mine.mjs\"\n * entry: \"/Users/me/.codework/plugins/mine.mjs\"\n * file: \"/Users/me/.codework/settings.jsonc\"\n */\nexport interface Declared {\n\t/** The entry exactly as the file spells it, which is the string a person will search for. */\n\treadonly written: PluginEntry;\n\t/** The same entry with any relative path anchored to the directory of its declaring file. */\n\treadonly entry: PluginEntry;\n\t/** The settings file that declared it. */\n\treadonly file: string;\n}\n\n/** A `models` entry, and the settings file that declared it. */\nexport interface DeclaredModel {\n\treadonly entry: AikitModel.Info;\n\treadonly file: string;\n}\n\nexport interface Info {\n\t/**\n\t * Plugin entries added to the harness selection, in order: every layer's entries, lowest\n\t * priority first, so a project's list extends the user's rather than replacing it.\n\t *\n\t * Anchored, and stripped of provenance: this is the list the loader consumes. {@link Info.declared}\n\t * is the same list with the file each entry came from.\n\t */\n\treadonly plugins: ReadonlyArray<PluginEntry>;\n\t/** {@link Info.plugins}, with the origin of each entry. Same order, same length. */\n\treadonly declared: ReadonlyArray<Declared>;\n\t/**\n\t * Catalog entries from every layer, lowest priority first. Applied over the generated catalog\n\t * in this order, so for one `provider.id` + `id` the last entry wins.\n\t */\n\treadonly models: ReadonlyArray<DeclaredModel>;\n\treadonly model: typeof Model.Type & {\n\t\treadonly provider: string;\n\t\treadonly id: string;\n\t\treadonly thinkingLevel: AikitModel.ThinkingLevel;\n\t\treadonly toolExecution: ToolExecution;\n\t};\n\treadonly retry: RetryPolicy;\n}\n\n/** Let aikit supply model-aware generation defaults. */\nexport const defaults: Info = {\n\tplugins: [],\n\tdeclared: [],\n\tmodels: [],\n\tmodel: {\n\t\tprovider: \"openai\",\n\t\tid: \"gpt-5.6-luna\",\n\t\tthinkingLevel: \"high\",\n\t\ttoolExecution: \"sequential\",\n\t\toptions: { timeoutMs: 3_600_000, idleTimeoutMs: 300_000, maxRetries: 0 },\n\t},\n\tretry: { maxRetries: 3, baseDelayMs: 2_000, maxDelayMs: 60_000 },\n};\n"],"mappings":";;;;AAIA,MAAa,gBAAgB,OAAO,SAAS,OAAO,OAAOA,QAAW,iBAAiB,CAAC;AACxF,MAAa,gBAAgB,OAAO,SAAS,CAAC,cAAc,UAAU,CAAC;AAEvE,MAAM,UAAU,OAAO,OACtB,OAAO,SAAS,OAAO,OAAOA,QAAW,iBAAiB,CAAC,CAAC,QAAQ,UAAU,UAAU,KAAK,CAAC,GAC9F,OAAO,SAAS,OAAO,MAAM,CAC9B;;AAGA,MAAa,gBAAgB;CAC5B,aAAa,OAAO,SAAS,OAAO,MAAM;CAC1C,WAAW,OAAO,SAAS,OAAO,MAAM;CACxC,gBAAgB,OAAO,SAAS,OAAO,SAAS;EAAC;EAAQ;EAAS;CAAM,CAAC,CAAC;CAC1E,SAAS,OAAO,SAAS,OAAO,OAAO,OAAO,QAAQ,OAAO,MAAM,CAAC;CACpE,WAAW,OAAO,SAAS,OAAO,MAAM;CACxC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GAG9G,EAAE,MAAM,QAAQ,CACjB;AACA,MAAa,cAAc,OAAO,MAAM,CAAC,iBAAiB,WAAW,CAAC;;;;;;;;;AAWtE,MAAa,QAAQ,OAAO,OAAO;CAClC,YAAY,OAAO,SAAS,cAAc;CAC1C,aAAa,OAAO,SAAS,cAAc;CAC3C,YAAY,OAAO,SAAS,cAAc;AAC3C,CAAC;AAOD,MAAa,QAAQ,OAAO,OAAO;CAClC,SAAS,OAAO,SAAS,OAAO,MAAM;CACtC,SAAS,OAAO,SAAS,OAAO,MAAM,WAAW,CAAC;CAClD,OAAO,OAAO,SAAS,KAAK;CAC5B,QAAQ,OAAO,SAAS,OAAO,MAAM,UAAU,CAAC;CAChD,OAAO,OAAO,SAAS,KAAK;AAC7B,CAAC;;AAmED,MAAa,WAAiB;CAC7B,SAAS,CAAC;CACV,UAAU,CAAC;CACX,QAAQ,CAAC;CACT,OAAO;EACN,UAAU;EACV,IAAI;EACJ,eAAe;EACf,eAAe;EACf,SAAS;GAAE,WAAW;GAAW,eAAe;GAAS,YAAY;EAAE;CACxE;CACA,OAAO;EAAE,YAAY;EAAG,aAAa;EAAO,YAAY;CAAO;AAChE"}
1
+ {"version":3,"file":"settings.mjs","names":["AikitModel"],"sources":["../../src/settings.ts"],"sourcesContent":["import { Model as AikitModel, type Protocol } from \"@codeworksh/aikit\";\nimport { Effect, Schema, type SchemaAST, SchemaGetter, SchemaIssue } from \"effect\";\nimport { isAikitModelInfo, NonNegativeInt, validateAikitModelInfo } from \"./schema.ts\";\n\nexport const ThinkingLevel = Schema.Literals(Object.values(AikitModel.ThinkingLevelEnum));\nexport const ToolExecution = Schema.Literals([\"sequential\", \"parallel\"]);\nexport type ToolExecution = typeof ToolExecution.Type;\nconst Budgets = Schema.Record(\n\tSchema.Literals(Object.values(AikitModel.ThinkingLevelEnum).filter((level) => level !== \"off\")),\n\tSchema.optional(Schema.Finite),\n);\n\n/** Aikit does not export its request schema; keep this routing surface checked against its public types. */\nexport const requestFields = {\n\ttemperature: Schema.optional(Schema.Finite),\n\tmaxTokens: Schema.optional(Schema.Finite),\n\tcacheRetention: Schema.optional(Schema.Literals([\"none\", \"short\", \"long\"])),\n\theaders: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n\ttimeoutMs: Schema.optional(Schema.Finite),\n\tidleTimeoutMs: Schema.optional(Schema.Finite),\n\tmaxRetries: Schema.optional(Schema.Finite),\n\tmetadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),\n\tthinkingBudgets: Schema.optional(Budgets),\n\tbaseURL: Schema.optional(Schema.String),\n\tmethod: Schema.optional(Schema.Literals(Object.values(AikitModel.APIMethodEnum))),\n} satisfies Record<\n\t| Exclude<keyof Protocol.CommonOptions, \"signal\" | \"sessionId\" | \"reasoning\" | \"apiKey\" | \"onPayload\">\n\t| \"baseURL\"\n\t| \"method\",\n\tSchema.Top\n>;\n\n/**\n * An API key named, never written: `\"${NAME}\"`, read from the host process environment when the\n * model is called. Settings only ever hold the variable's name.\n */\nconst keyReference = /^\\$\\{([A-Za-z_][A-Za-z0-9_]*)\\}$/;\nconst keyReferenceError = 'apiKey must reference an environment variable, e.g. \"${OPENAI_API_KEY}\"';\nexport const KeyReference = Schema.String.check(\n\tSchema.makeFilter((value) => keyReference.test(value) || keyReferenceError),\n);\n\n/** The variable a `\"${NAME}\"` reference names. */\nexport const keyName = (reference: string): string => keyReference.exec(reference)?.[1] ?? reference;\n\nconst reserved = new Set([\n\t\"toolChoice\",\n\t\"activeTools\",\n\t\"provider\",\n\t\"id\",\n\t\"signal\",\n\t\"sessionId\",\n\t\"reasoning\",\n\t\"modelId\",\n\t\"onPayload\",\n\t\"api\",\n\t\"npm\",\n\t\"providerOptionsKey\",\n\t\"compat\",\n\t\"thinkingLevelMap\",\n]);\n\n/** The wire protocol a model speaks, which a catalog entry may have wrong for a local endpoint. */\nexport const ModelProtocol = Schema.Literals(Object.values(AikitModel.KnownProviderEnum));\n\nexport const Block = Schema.StructWithRest(\n\tSchema.Struct({\n\t\t...requestFields,\n\t\tprotocol: Schema.optional(ModelProtocol),\n\t\tthinkingLevel: Schema.optional(ThinkingLevel),\n\t\ttoolExecution: Schema.optional(ToolExecution),\n\t\tcontextWindow: Schema.optional(Schema.Finite),\n\t\t/** Which environment variable holds the key for this model: `\"${NAME}\"`. */\n\t\tapiKey: Schema.optional(KeyReference),\n\t\textras: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),\n\t}),\n\t[Schema.Record(Schema.String, Schema.Unknown)],\n).check(\n\tSchema.makeFilter(\n\t\t(value) => Object.keys(value).every((key) => !reserved.has(key)) || \"Reserved configuration key in model options\",\n\t),\n);\nexport type Block = typeof Block.Type;\n\nexport const Model = Schema.Struct({\n\tprovider: Schema.optional(Schema.String),\n\tid: Schema.optional(Schema.String),\n\tthinkingLevel: Schema.optional(ThinkingLevel),\n\ttoolExecution: Schema.optional(ToolExecution),\n\tthinkingBudgets: Schema.optional(Budgets),\n\toptions: Schema.optional(Block),\n\tproviderOptions: Schema.optional(Schema.Record(Schema.String, Schema.Record(Schema.String, Block))),\n});\nconst reasonOf = (cause: unknown): string => (cause instanceof Error ? cause.message : String(cause));\n\nconst decodeModelEntry = (value: unknown, options: SchemaAST.ParseOptions) =>\n\tEffect.try({\n\t\ttry: () => {\n\t\t\tconst entry = validateAikitModelInfo(value, \"models entry\");\n\t\t\tif (entry.provider.key !== undefined && !keyReference.test(entry.provider.key)) {\n\t\t\t\tthrow new Error(`models entry ${entry.provider.id}/${entry.id}: provider.key: ${keyReferenceError}`);\n\t\t\t}\n\t\t\treturn entry;\n\t\t},\n\t\tcatch: (cause) => new SchemaIssue.InvalidValue({ message: reasonOf(cause) }, value, options),\n\t});\n\n/**\n * A catalog entry in settings: an aikit `Model.Info`, read exactly like an entry of the generated\n * catalog. The one difference is `provider.key`, which must be a `\"${NAME}\"` reference.\n */\nexport const ModelEntry = Schema.Unknown.pipe(\n\tSchema.decodeTo(Schema.declare<AikitModel.Info>(isAikitModelInfo, { expected: \"aikit Model.Info\" }), {\n\t\tdecode: SchemaGetter.transformEffect(decodeModelEntry),\n\t\tencode: SchemaGetter.transformEffect(decodeModelEntry),\n\t}),\n);\nexport type ModelEntry = typeof ModelEntry.Type;\n\n/** A module to load: a path, a `file:` URL, or a package spec. */\nconst PluginReference = Schema.String.check(Schema.isNonEmpty());\n/**\n * Configuration for a plugin something else already selected, named by its ID (`plugin`) or by\n * its registered module string (`package`). It never loads anything: an entry naming a plugin\n * that is not in the selection is ignored.\n */\nconst config = {\n\tenabled: Schema.optional(Schema.Boolean),\n\toptions: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),\n};\nexport const PluginPatch = Schema.Union(\n\t[Schema.Struct({ plugin: PluginReference, ...config }), Schema.Struct({ package: PluginReference, ...config })],\n\t// `oneOf`, so an entry carrying both keys is a decode failure rather than one of them being\n\t// quietly dropped -- naming a plugin two ways at once says two different things.\n\t{ mode: \"oneOf\" },\n);\nexport const PluginEntry = Schema.Union([PluginReference, PluginPatch]);\nexport type PluginEntry = typeof PluginEntry.Type;\n\n/**\n * Agent-level retry of a turn whose provider request failed transiently (rate limit, overload,\n * 5xx, dropped connection). Delays double from `baseDelayMs` and stop growing at `maxDelayMs`;\n * a server that asks for a longer wait than `maxDelayMs` is not retried. `maxRetries: 0` is off.\n *\n * Separate from `model.options.maxRetries`, which retries inside the provider SDK and defaults to\n * 0 so that the two do not multiply, and so a quota error reaches the loop instead of being retried.\n */\nexport const Retry = Schema.Struct({\n\tmaxRetries: Schema.optional(NonNegativeInt),\n\tbaseDelayMs: Schema.optional(NonNegativeInt),\n\tmaxDelayMs: Schema.optional(NonNegativeInt),\n});\nexport interface RetryPolicy {\n\treadonly maxRetries: number;\n\treadonly baseDelayMs: number;\n\treadonly maxDelayMs: number;\n}\n\nexport const Patch = Schema.Struct({\n\t$schema: Schema.optional(Schema.String),\n\tplugins: Schema.optional(Schema.Array(PluginEntry)),\n\tmodel: Schema.optional(Model),\n\tmodels: Schema.optional(Schema.Array(ModelEntry)),\n\tretry: Schema.optional(Retry),\n});\nexport type Patch = typeof Patch.Type;\n\n/**\n * One plugin entry, and where it came from.\n *\n * Flattening every layer's `plugins` into one array loses the file that declared each entry, and\n * that cannot be recovered afterwards: two layers may declare the same string, so attribution is\n * genuinely gone rather than merely inconvenient. Three things need it -- anchoring a relative\n * path, naming the declaring layer in `plugin list`, and the missing-plugin diagnostic -- so the\n * loaded shape carries it from the start.\n *\n * In simple terms:\n * `written` - is what module the developer is declaring - what\n * `file` - where the module is being declared - where\n * `entry` - the resolved path of the module, relative to the `file`; especially needed for local.\n *\n * Example:\n * written: \"@acme/x@^1\"\n * entry: \"@acme/x@^1\"\n * file: \"/Users/me/.codework/settings.jsonc\"\n *\n * written: \"./plugins/mine.mjs\"\n * entry: \"/Users/me/.codework/plugins/mine.mjs\"\n * file: \"/Users/me/.codework/settings.jsonc\"\n */\nexport interface Declared {\n\t/** The entry exactly as the file spells it, which is the string a person will search for. */\n\treadonly written: PluginEntry;\n\t/** The same entry with any relative path anchored to the directory of its declaring file. */\n\treadonly entry: PluginEntry;\n\t/** The settings file that declared it. */\n\treadonly file: string;\n}\n\n/** A `models` entry, and the settings file that declared it. */\nexport interface DeclaredModel {\n\treadonly entry: AikitModel.Info;\n\treadonly file: string;\n}\n\nexport interface Info {\n\t/**\n\t * Plugin entries added to the harness selection, in order: every layer's entries, lowest\n\t * priority first, so a project's list extends the user's rather than replacing it.\n\t *\n\t * Anchored, and stripped of provenance: this is the list the loader consumes. {@link Info.declared}\n\t * is the same list with the file each entry came from.\n\t */\n\treadonly plugins: ReadonlyArray<PluginEntry>;\n\t/** {@link Info.plugins}, with the origin of each entry. Same order, same length. */\n\treadonly declared: ReadonlyArray<Declared>;\n\t/**\n\t * Catalog entries from every layer, lowest priority first. Applied over the generated catalog\n\t * in this order, so for one `provider.id` + `id` the last entry wins.\n\t */\n\treadonly models: ReadonlyArray<DeclaredModel>;\n\treadonly model: typeof Model.Type & {\n\t\treadonly provider: string;\n\t\treadonly id: string;\n\t\treadonly thinkingLevel: AikitModel.ThinkingLevel;\n\t\treadonly toolExecution: ToolExecution;\n\t};\n\treadonly retry: RetryPolicy;\n}\n\n/** Let aikit supply model-aware generation defaults. */\nexport const defaults: Info = {\n\tplugins: [],\n\tdeclared: [],\n\tmodels: [],\n\tmodel: {\n\t\tprovider: \"openai\",\n\t\tid: \"gpt-5.6-luna\",\n\t\tthinkingLevel: \"medium\",\n\t\ttoolExecution: \"sequential\",\n\t\toptions: { timeoutMs: 3_600_000, idleTimeoutMs: 300_000, maxRetries: 0 },\n\t},\n\tretry: { maxRetries: 3, baseDelayMs: 2_000, maxDelayMs: 60_000 },\n};\n"],"mappings":";;;;AAIA,MAAa,gBAAgB,OAAO,SAAS,OAAO,OAAOA,QAAW,iBAAiB,CAAC;AACxF,MAAa,gBAAgB,OAAO,SAAS,CAAC,cAAc,UAAU,CAAC;AAEvE,MAAM,UAAU,OAAO,OACtB,OAAO,SAAS,OAAO,OAAOA,QAAW,iBAAiB,CAAC,CAAC,QAAQ,UAAU,UAAU,KAAK,CAAC,GAC9F,OAAO,SAAS,OAAO,MAAM,CAC9B;;AAGA,MAAa,gBAAgB;CAC5B,aAAa,OAAO,SAAS,OAAO,MAAM;CAC1C,WAAW,OAAO,SAAS,OAAO,MAAM;CACxC,gBAAgB,OAAO,SAAS,OAAO,SAAS;EAAC;EAAQ;EAAS;CAAM,CAAC,CAAC;CAC1E,SAAS,OAAO,SAAS,OAAO,OAAO,OAAO,QAAQ,OAAO,MAAM,CAAC;CACpE,WAAW,OAAO,SAAS,OAAO,MAAM;CACxC,eAAe,OAAO,SAAS,OAAO,MAAM;CAC5C,YAAY,OAAO,SAAS,OAAO,MAAM;CACzC,UAAU,OAAO,SAAS,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,CAAC;CACtE,iBAAiB,OAAO,SAAS,OAAO;CACxC,SAAS,OAAO,SAAS,OAAO,MAAM;CACtC,QAAQ,OAAO,SAAS,OAAO,SAAS,OAAO,OAAO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