@codeworksh/plugin 0.1.0-canary.26.1.gaaada198 → 0.1.0-canary.29.1.g3f9ed90b
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/{event-mKxToqmh.d.mts → event-6sTQ_4bq.d.mts} +33 -33
- package/event.d.mts +1 -1
- package/index.d.mts +1 -1
- package/package.json +2 -2
- package/{plugin-DkTmu4O0.d.mts → plugin-Deb2QWIP.d.mts} +22 -5
- package/plugin-XaYYRsX-.mjs.map +1 -1
- package/plugin.d.mts +2 -2
- package/{settings-B6-grSTA.d.mts → settings-47Mzxhl0.d.mts} +7 -1
- package/settings.d.mts +1 -1
- package/settings.mjs +2 -0
- package/settings.mjs.map +1 -1
|
@@ -156,14 +156,19 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
156
156
|
type: "image";
|
|
157
157
|
data: string;
|
|
158
158
|
mimeType: string;
|
|
159
|
+
} | {
|
|
160
|
+
type: "thinking";
|
|
161
|
+
thinking: string;
|
|
162
|
+
thinkingSignature?: string;
|
|
163
|
+
redacted?: boolean;
|
|
159
164
|
} | {
|
|
160
165
|
addedToolNames?: string[];
|
|
161
166
|
arguments: Record<string, any>;
|
|
162
167
|
callID: string;
|
|
163
168
|
name: string;
|
|
164
169
|
namespace?: string;
|
|
165
|
-
|
|
166
|
-
content
|
|
170
|
+
partial?: {
|
|
171
|
+
content?: ({
|
|
167
172
|
type: "text";
|
|
168
173
|
text: string;
|
|
169
174
|
textSignature?: string;
|
|
@@ -173,9 +178,8 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
173
178
|
mimeType: string;
|
|
174
179
|
})[];
|
|
175
180
|
details?: any;
|
|
176
|
-
isError: false;
|
|
177
181
|
};
|
|
178
|
-
status: "
|
|
182
|
+
status: "running";
|
|
179
183
|
thoughtSignature?: string;
|
|
180
184
|
time: {
|
|
181
185
|
start: number;
|
|
@@ -199,9 +203,9 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
199
203
|
mimeType: string;
|
|
200
204
|
})[];
|
|
201
205
|
details?: any;
|
|
202
|
-
isError:
|
|
206
|
+
isError: false;
|
|
203
207
|
};
|
|
204
|
-
status: "
|
|
208
|
+
status: "completed";
|
|
205
209
|
thoughtSignature?: string;
|
|
206
210
|
time: {
|
|
207
211
|
start: number;
|
|
@@ -227,7 +231,7 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
227
231
|
details?: any;
|
|
228
232
|
isError: true;
|
|
229
233
|
};
|
|
230
|
-
status: "
|
|
234
|
+
status: "error";
|
|
231
235
|
thoughtSignature?: string;
|
|
232
236
|
time: {
|
|
233
237
|
start: number;
|
|
@@ -253,26 +257,21 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
253
257
|
details?: any;
|
|
254
258
|
isError: true;
|
|
255
259
|
};
|
|
256
|
-
status: "
|
|
260
|
+
status: "skipped";
|
|
257
261
|
thoughtSignature?: string;
|
|
258
262
|
time: {
|
|
259
263
|
start: number;
|
|
260
264
|
end: number;
|
|
261
265
|
};
|
|
262
266
|
type: "toolCall";
|
|
263
|
-
} | {
|
|
264
|
-
type: "thinking";
|
|
265
|
-
thinking: string;
|
|
266
|
-
thinkingSignature?: string;
|
|
267
|
-
redacted?: boolean;
|
|
268
267
|
} | {
|
|
269
268
|
addedToolNames?: string[];
|
|
270
269
|
arguments: Record<string, any>;
|
|
271
270
|
callID: string;
|
|
272
271
|
name: string;
|
|
273
272
|
namespace?: string;
|
|
274
|
-
|
|
275
|
-
content
|
|
273
|
+
result: {
|
|
274
|
+
content: ({
|
|
276
275
|
type: "text";
|
|
277
276
|
text: string;
|
|
278
277
|
textSignature?: string;
|
|
@@ -282,8 +281,9 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
282
281
|
mimeType: string;
|
|
283
282
|
})[];
|
|
284
283
|
details?: any;
|
|
284
|
+
isError: true;
|
|
285
285
|
};
|
|
286
|
-
status: "
|
|
286
|
+
status: "aborted";
|
|
287
287
|
thoughtSignature?: string;
|
|
288
288
|
time: {
|
|
289
289
|
start: number;
|
|
@@ -458,14 +458,19 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
458
458
|
type: "image";
|
|
459
459
|
data: string;
|
|
460
460
|
mimeType: string;
|
|
461
|
+
} | {
|
|
462
|
+
type: "thinking";
|
|
463
|
+
thinking: string;
|
|
464
|
+
thinkingSignature?: string;
|
|
465
|
+
redacted?: boolean;
|
|
461
466
|
} | {
|
|
462
467
|
addedToolNames?: string[];
|
|
463
468
|
arguments: Record<string, any>;
|
|
464
469
|
callID: string;
|
|
465
470
|
name: string;
|
|
466
471
|
namespace?: string;
|
|
467
|
-
|
|
468
|
-
content
|
|
472
|
+
partial?: {
|
|
473
|
+
content?: ({
|
|
469
474
|
type: "text";
|
|
470
475
|
text: string;
|
|
471
476
|
textSignature?: string;
|
|
@@ -475,9 +480,8 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
475
480
|
mimeType: string;
|
|
476
481
|
})[];
|
|
477
482
|
details?: any;
|
|
478
|
-
isError: false;
|
|
479
483
|
};
|
|
480
|
-
status: "
|
|
484
|
+
status: "running";
|
|
481
485
|
thoughtSignature?: string;
|
|
482
486
|
time: {
|
|
483
487
|
start: number;
|
|
@@ -501,9 +505,9 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
501
505
|
mimeType: string;
|
|
502
506
|
})[];
|
|
503
507
|
details?: any;
|
|
504
|
-
isError:
|
|
508
|
+
isError: false;
|
|
505
509
|
};
|
|
506
|
-
status: "
|
|
510
|
+
status: "completed";
|
|
507
511
|
thoughtSignature?: string;
|
|
508
512
|
time: {
|
|
509
513
|
start: number;
|
|
@@ -529,7 +533,7 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
529
533
|
details?: any;
|
|
530
534
|
isError: true;
|
|
531
535
|
};
|
|
532
|
-
status: "
|
|
536
|
+
status: "error";
|
|
533
537
|
thoughtSignature?: string;
|
|
534
538
|
time: {
|
|
535
539
|
start: number;
|
|
@@ -555,26 +559,21 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
555
559
|
details?: any;
|
|
556
560
|
isError: true;
|
|
557
561
|
};
|
|
558
|
-
status: "
|
|
562
|
+
status: "skipped";
|
|
559
563
|
thoughtSignature?: string;
|
|
560
564
|
time: {
|
|
561
565
|
start: number;
|
|
562
566
|
end: number;
|
|
563
567
|
};
|
|
564
568
|
type: "toolCall";
|
|
565
|
-
} | {
|
|
566
|
-
type: "thinking";
|
|
567
|
-
thinking: string;
|
|
568
|
-
thinkingSignature?: string;
|
|
569
|
-
redacted?: boolean;
|
|
570
569
|
} | {
|
|
571
570
|
addedToolNames?: string[];
|
|
572
571
|
arguments: Record<string, any>;
|
|
573
572
|
callID: string;
|
|
574
573
|
name: string;
|
|
575
574
|
namespace?: string;
|
|
576
|
-
|
|
577
|
-
content
|
|
575
|
+
result: {
|
|
576
|
+
content: ({
|
|
578
577
|
type: "text";
|
|
579
578
|
text: string;
|
|
580
579
|
textSignature?: string;
|
|
@@ -584,8 +583,9 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
584
583
|
mimeType: string;
|
|
585
584
|
})[];
|
|
586
585
|
details?: any;
|
|
586
|
+
isError: true;
|
|
587
587
|
};
|
|
588
|
-
status: "
|
|
588
|
+
status: "aborted";
|
|
589
589
|
thoughtSignature?: string;
|
|
590
590
|
time: {
|
|
591
591
|
start: number;
|
|
@@ -896,4 +896,4 @@ declare function durable<const Definitions extends ReadonlyArray<Definition>>(de
|
|
|
896
896
|
declare function latest(definitions: ReadonlyArray<Definition>): ReadonlyMap<string, Definition<string, Schema.Codec<unknown, unknown, never, never>>>;
|
|
897
897
|
//#endregion
|
|
898
898
|
export { ID as a, define as c, inventory as d, latest as f, Definition as i, durable as l, AikitToolCallTerminalPart as n, Payload as o, versionedType as p, Data as r, PublishOptions as s, AikitAssistantMessage as t, event_d_exports as u };
|
|
899
|
-
//# sourceMappingURL=event-
|
|
899
|
+
//# sourceMappingURL=event-6sTQ_4bq.d.mts.map
|
package/event.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ID, c as define, d as inventory, f as latest, i as Definition, l as durable, n as AikitToolCallTerminalPart, o as Payload, p as versionedType, r as Data, s as PublishOptions, t as AikitAssistantMessage, u as event_d_exports } from "./event-
|
|
1
|
+
import { a as ID, c as define, d as inventory, f as latest, i as Definition, l as durable, n as AikitToolCallTerminalPart, o as Payload, p as versionedType, r as Data, s as PublishOptions, t as AikitAssistantMessage, u as event_d_exports } from "./event-6sTQ_4bq.mjs";
|
|
2
2
|
export { AikitAssistantMessage, AikitToolCallTerminalPart, Data, Definition, event_d_exports as EventSchema, ID, Payload, PublishOptions, define, durable, inventory, latest, versionedType };
|
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-
|
|
3
|
+
import { t as plugin_d_exports } from "./plugin-Deb2QWIP.mjs";
|
|
4
4
|
export { plugin_d_exports as Plugin, section_d_exports as Section, tool_d_exports as Tool };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeworksh/plugin",
|
|
3
|
-
"version": "0.1.0-canary.
|
|
3
|
+
"version": "0.1.0-canary.29.1.g3f9ed90b",
|
|
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.10.0-canary.
|
|
171
|
+
"@codeworksh/aikit": "0.10.0-canary.29.1.g3f9ed90b",
|
|
172
172
|
"effect": "4.0.1"
|
|
173
173
|
}
|
|
174
174
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { i as Definition, o as Payload, r as Data, s as PublishOptions } from "./event-
|
|
1
|
+
import { i as Definition, o as Payload, r as Data, s as PublishOptions } from "./event-6sTQ_4bq.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
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-
|
|
5
|
+
import { i as Info$1 } from "./settings-47Mzxhl0.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";
|
|
@@ -37,10 +37,22 @@ interface Config {
|
|
|
37
37
|
interface Events {
|
|
38
38
|
readonly publish: <D extends Definition>(definition: D, data: Data<D>, options?: PublishOptions) => Effect.Effect<Payload<D>>;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* The harness's own directories on the host, all under its home (`--home`, `~/.codework` by
|
|
42
|
+
* default). App-level: the same for every session, and never a session's project or its sandbox.
|
|
43
|
+
*/
|
|
44
|
+
interface Paths {
|
|
45
|
+
readonly home: string;
|
|
46
|
+
readonly bin: string;
|
|
47
|
+
readonly cache: string;
|
|
48
|
+
readonly data: string;
|
|
49
|
+
readonly log: string;
|
|
50
|
+
}
|
|
40
51
|
/** One object, shared by every plugin in one exchange. */
|
|
41
52
|
interface SharedPluginContext {
|
|
42
53
|
readonly sessionId: SessionID;
|
|
43
54
|
readonly sandbox: Identity;
|
|
55
|
+
readonly paths: Paths;
|
|
44
56
|
readonly location: Info;
|
|
45
57
|
readonly settings: Info$1;
|
|
46
58
|
readonly model: Model.Info;
|
|
@@ -124,6 +136,11 @@ interface Plugin {
|
|
|
124
136
|
* `plugin.<id>.*`.
|
|
125
137
|
*/
|
|
126
138
|
readonly events?: ReadonlyArray<Definition>;
|
|
139
|
+
/**
|
|
140
|
+
* Off until a user asks for it. An `optIn` plugin is selected like any other but runs only
|
|
141
|
+
* when a settings entry turns it on: `{ "plugin": "<id>", "enabled": true }`.
|
|
142
|
+
*/
|
|
143
|
+
readonly optIn?: boolean;
|
|
127
144
|
/**
|
|
128
145
|
* `options` is this plugin's own configuration block, `{}` when its entry carried none.
|
|
129
146
|
* Unvalidated: the harness never looks inside it, so a plugin checks whatever shape it
|
|
@@ -134,8 +151,8 @@ interface Plugin {
|
|
|
134
151
|
}
|
|
135
152
|
declare const define: (plugin: Plugin) => Plugin;
|
|
136
153
|
declare namespace plugin_d_exports {
|
|
137
|
-
export { Config, Events, Mount, Plugin, PluginKind, PluginOptions, PluginPatch, PluginRef, PluginRegistry, PluginSpec, prompt_d_exports as Prompt, PromptResolver, section_d_exports as Section, SharedPluginContext, tool_d_exports as Tool, define, domains, rank };
|
|
154
|
+
export { Config, Events, Mount, Paths, Plugin, PluginKind, PluginOptions, PluginPatch, PluginRef, PluginRegistry, PluginSpec, prompt_d_exports as Prompt, PromptResolver, section_d_exports as Section, SharedPluginContext, tool_d_exports as Tool, define, domains, rank };
|
|
138
155
|
}
|
|
139
156
|
//#endregion
|
|
140
|
-
export { define as a, PluginOptions as c, PluginSpec as d, Config as f,
|
|
141
|
-
//# sourceMappingURL=plugin-
|
|
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-Deb2QWIP.d.mts.map
|
package/plugin-XaYYRsX-.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-XaYYRsX-.mjs","names":[],"sources":["../../src/plugin/plugin.ts","../../src/plugin.ts"],"sourcesContent":["import type { Effect } from \"effect\";\nimport type { Definition } from \"../event.ts\";\nimport type { Service as LocationService } from \"../location.ts\";\nimport type { SandboxIO } from \"../sandbox/io.ts\";\nimport type {
|
|
1
|
+
{"version":3,"file":"plugin-XaYYRsX-.mjs","names":[],"sources":["../../src/plugin/plugin.ts","../../src/plugin.ts"],"sourcesContent":["import type { Effect } from \"effect\";\nimport type { Definition } from \"../event.ts\";\nimport type { Service as LocationService } from \"../location.ts\";\nimport type { SandboxIO } from \"../sandbox/io.ts\";\nimport type { SharedPluginContext } from \"./context.ts\";\nimport type { PluginOptions } from \"./ref.ts\";\n\n/**\n * The domains a plugin can extend, and the order the harness runs them in.\n *\n * Order is declared, not positional. A plugin's place used to come from where its entry sat in\n * the `plugins` array, which is unknowable when the entry is written: a user's settings file and\n * a project's are edited by different people at different times, and neither can see the other's\n * order. Since a prompt plugin indexes the tools registered before it, that made a tool added\n * from settings invisible in the system prompt, with no way to fix it from a settings file.\n *\n * A plugin instead says which domain it extends, and the harness runs the domains in this order.\n * Entries within one domain keep the order they were written in, because that is where\n * composition actually happens -- a plugin patching another's tool, or appending to the prompt a\n * previous one rendered, is written next to it and deliberately after it.\n *\n * Kept as data so a later release can add a domain, or make the order configurable, without\n * touching the loader: `{ tool: 1, skill: 2, prompt: 3 }` needs no code change here.\n */\nexport const domains = { tool: 1, prompt: 2 } as const;\n\nexport type PluginKind = keyof typeof domains;\n\n/** Sort key for a plugin: its domain first, then where it was written. */\nexport const rank = (kind: PluginKind) => domains[kind];\n\nexport type Mount = SandboxIO.Provides | LocationService;\nexport interface Plugin {\n\treadonly id: string;\n\t/**\n\t * The domain this plugin extends, which decides when it runs: every `tool` plugin is set up\n\t * before any `prompt` plugin, whichever settings layer each came from, so a prompt plugin\n\t * always sees the complete tool set. Plugins within one domain run in the order they were\n\t * written.\n\t */\n\treadonly kind: PluginKind;\n\t/**\n\t * Event definitions this plugin publishes. Declared rather than registered at\n\t * runtime so they are known before the event system builds, and so a bad type\n\t * fails the boot instead of the first publish. Types must be namespaced\n\t * `plugin.<id>.*`.\n\t */\n\treadonly events?: ReadonlyArray<Definition>;\n\t/**\n\t * Off until a user asks for it. An `optIn` plugin is selected like any other but runs only\n\t * when a settings entry turns it on: `{ \"plugin\": \"<id>\", \"enabled\": true }`.\n\t */\n\treadonly optIn?: boolean;\n\t/**\n\t * `options` is this plugin's own configuration block, `{}` when its entry carried none.\n\t * Unvalidated: the harness never looks inside it, so a plugin checks whatever shape it\n\t * documents. It is a second argument rather than a context field so `ctx` stays one object\n\t * shared by every plugin in the exchange.\n\t */\n\treadonly setup: (\n\t\tctx: SharedPluginContext,\n\t\toptions: PluginOptions,\n\t) => void | Promise<void> | Effect.Effect<void, unknown, Mount>;\n}\n\nexport const define = (plugin: Plugin): Plugin => plugin;\n","/**\n * The plugin authoring surface.\n *\n * Everything a third-party plugin needs to describe itself and to write into the harness during\n * `setup`, and nothing about how the harness finds, installs or runs it. Loading, the store and\n * the `.npmrc` anchoring stay in `@codeworksh/harness`, which imports this same module — so a\n * plugin and its host agree on one set of types rather than two that happen to match.\n */\nexport type { Config, Events, Paths, PromptResolver, SharedPluginContext } from \"./plugin/context.ts\";\nexport { define, domains, type Mount, type Plugin, type PluginKind, rank } from \"./plugin/plugin.ts\";\nexport * as Prompt from \"./plugin/prompt.ts\";\nexport * as Section from \"./plugin/section.ts\";\nexport type { PluginOptions, PluginPatch, PluginRef, PluginSpec } from \"./plugin/ref.ts\";\nexport type { PluginRegistry } from \"./plugin/registry.ts\";\nexport * as Tool from \"./plugin/tool.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,UAAU;CAAE,MAAM;CAAG,QAAQ;AAAE;;AAK5C,MAAa,QAAQ,SAAqB,QAAQ;AAoClD,MAAa,UAAU,WAA2B"}
|
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 { a as define, c as PluginOptions, d as PluginSpec, f as Config, g as
|
|
5
|
-
export { type Config, type Events, type Mount, 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 };
|
|
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-Deb2QWIP.mjs";
|
|
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 };
|
|
@@ -11,6 +11,7 @@ declare const requestFields: {
|
|
|
11
11
|
cacheRetention: Schema.optional<Schema.Literals<readonly ["none", "short", "long"]>>;
|
|
12
12
|
headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
13
13
|
timeoutMs: Schema.optional<Schema.Finite>;
|
|
14
|
+
idleTimeoutMs: Schema.optional<Schema.Finite>;
|
|
14
15
|
maxRetries: Schema.optional<Schema.Finite>;
|
|
15
16
|
metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
16
17
|
thinkingBudgets: Schema.optional<Schema.$Record<Schema.Literals<("high" | "low" | "max" | "medium" | "minimal" | "xhigh")[]>, Schema.optional<Schema.Finite>>>;
|
|
@@ -28,6 +29,7 @@ declare const Block: Schema.StructWithRest<Schema.Struct<{
|
|
|
28
29
|
readonly cacheRetention: Schema.optional<Schema.Literals<readonly ["none", "short", "long"]>>;
|
|
29
30
|
readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
30
31
|
readonly timeoutMs: Schema.optional<Schema.Finite>;
|
|
32
|
+
readonly idleTimeoutMs: Schema.optional<Schema.Finite>;
|
|
31
33
|
readonly maxRetries: Schema.optional<Schema.Finite>;
|
|
32
34
|
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
33
35
|
readonly thinkingBudgets: Schema.optional<Schema.$Record<Schema.Literals<("high" | "low" | "max" | "medium" | "minimal" | "xhigh")[]>, Schema.optional<Schema.Finite>>>;
|
|
@@ -54,6 +56,7 @@ declare const Model$1: Schema.Struct<{
|
|
|
54
56
|
readonly cacheRetention: Schema.optional<Schema.Literals<readonly ["none", "short", "long"]>>;
|
|
55
57
|
readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
56
58
|
readonly timeoutMs: Schema.optional<Schema.Finite>;
|
|
59
|
+
readonly idleTimeoutMs: Schema.optional<Schema.Finite>;
|
|
57
60
|
readonly maxRetries: Schema.optional<Schema.Finite>;
|
|
58
61
|
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
59
62
|
readonly thinkingBudgets: Schema.optional<Schema.$Record<Schema.Literals<("high" | "low" | "max" | "medium" | "minimal" | "xhigh")[]>, Schema.optional<Schema.Finite>>>;
|
|
@@ -73,6 +76,7 @@ declare const Model$1: Schema.Struct<{
|
|
|
73
76
|
readonly cacheRetention: Schema.optional<Schema.Literals<readonly ["none", "short", "long"]>>;
|
|
74
77
|
readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
75
78
|
readonly timeoutMs: Schema.optional<Schema.Finite>;
|
|
79
|
+
readonly idleTimeoutMs: Schema.optional<Schema.Finite>;
|
|
76
80
|
readonly maxRetries: Schema.optional<Schema.Finite>;
|
|
77
81
|
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
78
82
|
readonly thinkingBudgets: Schema.optional<Schema.$Record<Schema.Literals<("high" | "low" | "max" | "medium" | "minimal" | "xhigh")[]>, Schema.optional<Schema.Finite>>>;
|
|
@@ -313,6 +317,7 @@ declare const Patch: Schema.Struct<{
|
|
|
313
317
|
readonly cacheRetention: Schema.optional<Schema.Literals<readonly ["none", "short", "long"]>>;
|
|
314
318
|
readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
315
319
|
readonly timeoutMs: Schema.optional<Schema.Finite>;
|
|
320
|
+
readonly idleTimeoutMs: Schema.optional<Schema.Finite>;
|
|
316
321
|
readonly maxRetries: Schema.optional<Schema.Finite>;
|
|
317
322
|
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
318
323
|
readonly thinkingBudgets: Schema.optional<Schema.$Record<Schema.Literals<("high" | "low" | "max" | "medium" | "minimal" | "xhigh")[]>, Schema.optional<Schema.Finite>>>;
|
|
@@ -332,6 +337,7 @@ declare const Patch: Schema.Struct<{
|
|
|
332
337
|
readonly cacheRetention: Schema.optional<Schema.Literals<readonly ["none", "short", "long"]>>;
|
|
333
338
|
readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
334
339
|
readonly timeoutMs: Schema.optional<Schema.Finite>;
|
|
340
|
+
readonly idleTimeoutMs: Schema.optional<Schema.Finite>;
|
|
335
341
|
readonly maxRetries: Schema.optional<Schema.Finite>;
|
|
336
342
|
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
337
343
|
readonly thinkingBudgets: Schema.optional<Schema.$Record<Schema.Literals<("high" | "low" | "max" | "medium" | "minimal" | "xhigh")[]>, Schema.optional<Schema.Finite>>>;
|
|
@@ -578,4 +584,4 @@ interface Info {
|
|
|
578
584
|
declare const defaults: Info;
|
|
579
585
|
//#endregion
|
|
580
586
|
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 };
|
|
581
|
-
//# sourceMappingURL=settings-
|
|
587
|
+
//# sourceMappingURL=settings-47Mzxhl0.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-
|
|
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";
|
|
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
|
@@ -16,6 +16,7 @@ const requestFields = {
|
|
|
16
16
|
])),
|
|
17
17
|
headers: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
18
18
|
timeoutMs: Schema.optional(Schema.Finite),
|
|
19
|
+
idleTimeoutMs: Schema.optional(Schema.Finite),
|
|
19
20
|
maxRetries: Schema.optional(Schema.Finite),
|
|
20
21
|
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
21
22
|
thinkingBudgets: Schema.optional(Budgets),
|
|
@@ -136,6 +137,7 @@ const defaults = {
|
|
|
136
137
|
toolExecution: "sequential",
|
|
137
138
|
options: {
|
|
138
139
|
timeoutMs: 36e5,
|
|
140
|
+
idleTimeoutMs: 3e5,
|
|
139
141
|
maxRetries: 0
|
|
140
142
|
}
|
|
141
143
|
},
|
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\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, 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,M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":["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,MAA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