@codeworksh/plugin 0.0.1-canary.11.1.g892b5fc8 → 0.0.1-canary.13.1.gbddb812f
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/README.md +13 -5
- package/{event-BixB94Zu.d.mts → event-9PbbjnHJ.d.mts} +33 -33
- package/event.d.mts +1 -1
- package/index.d.mts +3 -2
- package/index.mjs +3 -2
- package/{location-D4hAfuXF.d.mts → location-Q39els63.d.mts} +9 -14
- package/location.d.mts +2 -2
- package/location.mjs +2 -5
- package/location.mjs.map +1 -1
- package/package.json +7 -2
- package/plugin/prompt.d.mts +1 -1
- package/plugin/prompt.mjs.map +1 -1
- package/plugin/section.d.mts +27 -0
- package/plugin/section.mjs +65 -0
- package/plugin/section.mjs.map +1 -0
- package/{plugin-C5AH_5Ei.d.mts → plugin-CaG6IlD-.d.mts} +7 -6
- package/{plugin-lorpq7Oi.mjs → plugin-XaYYRsX-.mjs} +3 -1
- package/{plugin-lorpq7Oi.mjs.map → plugin-XaYYRsX-.mjs.map} +1 -1
- package/plugin.d.mts +4 -3
- package/plugin.mjs +3 -2
- package/prompt-DWaA5ZXj.d.mts +21 -0
- package/{settings-C6RxGd-M.d.mts → settings-B6-grSTA.d.mts} +26 -2
- package/settings.d.mts +2 -2
- package/settings.mjs +23 -4
- package/settings.mjs.map +1 -1
- package/prompt-BcpagjGh.d.mts +0 -10
package/README.md
CHANGED
|
@@ -52,20 +52,28 @@ for a capability such as `SandboxIO.Shell`.
|
|
|
52
52
|
## A prompt plugin
|
|
53
53
|
|
|
54
54
|
```ts
|
|
55
|
-
import { Plugin } from "@codeworksh/plugin";
|
|
55
|
+
import { Plugin, Section } from "@codeworksh/plugin";
|
|
56
|
+
|
|
57
|
+
const GithubPrRules = Section.define("github_pr_rules", { format: "list" });
|
|
56
58
|
|
|
57
59
|
export default Plugin.define({
|
|
58
60
|
id: "acme.prompt.house-style",
|
|
59
61
|
kind: "prompt",
|
|
60
62
|
setup(ctx) {
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
ctx.plugin.prompt.
|
|
63
|
+
// Merges into the one <rules> every plugin writes to.
|
|
64
|
+
ctx.plugin.prompt.sections.append(Section.Rules, "No `any`.");
|
|
65
|
+
// Opens <github_pr_rules> on first use; later appends, from any plugin, land in it.
|
|
66
|
+
ctx.plugin.prompt.sections.append(GithubPrRules, "Link the issue in every PR description.");
|
|
65
67
|
},
|
|
66
68
|
});
|
|
67
69
|
```
|
|
68
70
|
|
|
71
|
+
The harness renders the system prompt from what plugins wrote: the foundation first and untagged
|
|
72
|
+
(`ctx.plugin.prompt.foundation.set`), then `<tools>`, `<rules>`, `<addendum>`, `<project_context>`,
|
|
73
|
+
`<skills>`, `<cwd>`, and custom sections in the order they were first written. `tools` and `cwd`
|
|
74
|
+
belong to the harness. A `list` section renders its entries as deduplicated `- ` bullets; a `text`
|
|
75
|
+
section (the default) keeps them verbatim, separated by a blank line.
|
|
76
|
+
|
|
69
77
|
## `kind` decides when a plugin runs
|
|
70
78
|
|
|
71
79
|
Every `tool` plugin runs before any `prompt` plugin, whichever settings layer each came from, so a
|
|
@@ -154,14 +154,19 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
154
154
|
type: "image";
|
|
155
155
|
data: string;
|
|
156
156
|
mimeType: string;
|
|
157
|
+
} | {
|
|
158
|
+
type: "thinking";
|
|
159
|
+
thinking: string;
|
|
160
|
+
thinkingSignature?: string;
|
|
161
|
+
redacted?: boolean;
|
|
157
162
|
} | {
|
|
158
163
|
addedToolNames?: string[];
|
|
159
164
|
arguments: Record<string, any>;
|
|
160
165
|
callID: string;
|
|
161
166
|
name: string;
|
|
162
167
|
namespace?: string;
|
|
163
|
-
|
|
164
|
-
content
|
|
168
|
+
partial?: {
|
|
169
|
+
content?: ({
|
|
165
170
|
type: "text";
|
|
166
171
|
text: string;
|
|
167
172
|
textSignature?: string;
|
|
@@ -171,9 +176,8 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
171
176
|
mimeType: string;
|
|
172
177
|
})[];
|
|
173
178
|
details?: any;
|
|
174
|
-
isError: false;
|
|
175
179
|
};
|
|
176
|
-
status: "
|
|
180
|
+
status: "running";
|
|
177
181
|
thoughtSignature?: string;
|
|
178
182
|
time: {
|
|
179
183
|
start: number;
|
|
@@ -197,9 +201,9 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
197
201
|
mimeType: string;
|
|
198
202
|
})[];
|
|
199
203
|
details?: any;
|
|
200
|
-
isError:
|
|
204
|
+
isError: false;
|
|
201
205
|
};
|
|
202
|
-
status: "
|
|
206
|
+
status: "completed";
|
|
203
207
|
thoughtSignature?: string;
|
|
204
208
|
time: {
|
|
205
209
|
start: number;
|
|
@@ -225,7 +229,7 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
225
229
|
details?: any;
|
|
226
230
|
isError: true;
|
|
227
231
|
};
|
|
228
|
-
status: "
|
|
232
|
+
status: "error";
|
|
229
233
|
thoughtSignature?: string;
|
|
230
234
|
time: {
|
|
231
235
|
start: number;
|
|
@@ -251,26 +255,21 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
251
255
|
details?: any;
|
|
252
256
|
isError: true;
|
|
253
257
|
};
|
|
254
|
-
status: "
|
|
258
|
+
status: "skipped";
|
|
255
259
|
thoughtSignature?: string;
|
|
256
260
|
time: {
|
|
257
261
|
start: number;
|
|
258
262
|
end: number;
|
|
259
263
|
};
|
|
260
264
|
type: "toolCall";
|
|
261
|
-
} | {
|
|
262
|
-
type: "thinking";
|
|
263
|
-
thinking: string;
|
|
264
|
-
thinkingSignature?: string;
|
|
265
|
-
redacted?: boolean;
|
|
266
265
|
} | {
|
|
267
266
|
addedToolNames?: string[];
|
|
268
267
|
arguments: Record<string, any>;
|
|
269
268
|
callID: string;
|
|
270
269
|
name: string;
|
|
271
270
|
namespace?: string;
|
|
272
|
-
|
|
273
|
-
content
|
|
271
|
+
result: {
|
|
272
|
+
content: ({
|
|
274
273
|
type: "text";
|
|
275
274
|
text: string;
|
|
276
275
|
textSignature?: string;
|
|
@@ -280,8 +279,9 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
280
279
|
mimeType: string;
|
|
281
280
|
})[];
|
|
282
281
|
details?: any;
|
|
282
|
+
isError: true;
|
|
283
283
|
};
|
|
284
|
-
status: "
|
|
284
|
+
status: "aborted";
|
|
285
285
|
thoughtSignature?: string;
|
|
286
286
|
time: {
|
|
287
287
|
start: number;
|
|
@@ -454,14 +454,19 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
454
454
|
type: "image";
|
|
455
455
|
data: string;
|
|
456
456
|
mimeType: string;
|
|
457
|
+
} | {
|
|
458
|
+
type: "thinking";
|
|
459
|
+
thinking: string;
|
|
460
|
+
thinkingSignature?: string;
|
|
461
|
+
redacted?: boolean;
|
|
457
462
|
} | {
|
|
458
463
|
addedToolNames?: string[];
|
|
459
464
|
arguments: Record<string, any>;
|
|
460
465
|
callID: string;
|
|
461
466
|
name: string;
|
|
462
467
|
namespace?: string;
|
|
463
|
-
|
|
464
|
-
content
|
|
468
|
+
partial?: {
|
|
469
|
+
content?: ({
|
|
465
470
|
type: "text";
|
|
466
471
|
text: string;
|
|
467
472
|
textSignature?: string;
|
|
@@ -471,9 +476,8 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
471
476
|
mimeType: string;
|
|
472
477
|
})[];
|
|
473
478
|
details?: any;
|
|
474
|
-
isError: false;
|
|
475
479
|
};
|
|
476
|
-
status: "
|
|
480
|
+
status: "running";
|
|
477
481
|
thoughtSignature?: string;
|
|
478
482
|
time: {
|
|
479
483
|
start: number;
|
|
@@ -497,9 +501,9 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
497
501
|
mimeType: string;
|
|
498
502
|
})[];
|
|
499
503
|
details?: any;
|
|
500
|
-
isError:
|
|
504
|
+
isError: false;
|
|
501
505
|
};
|
|
502
|
-
status: "
|
|
506
|
+
status: "completed";
|
|
503
507
|
thoughtSignature?: string;
|
|
504
508
|
time: {
|
|
505
509
|
start: number;
|
|
@@ -525,7 +529,7 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
525
529
|
details?: any;
|
|
526
530
|
isError: true;
|
|
527
531
|
};
|
|
528
|
-
status: "
|
|
532
|
+
status: "error";
|
|
529
533
|
thoughtSignature?: string;
|
|
530
534
|
time: {
|
|
531
535
|
start: number;
|
|
@@ -551,26 +555,21 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
551
555
|
details?: any;
|
|
552
556
|
isError: true;
|
|
553
557
|
};
|
|
554
|
-
status: "
|
|
558
|
+
status: "skipped";
|
|
555
559
|
thoughtSignature?: string;
|
|
556
560
|
time: {
|
|
557
561
|
start: number;
|
|
558
562
|
end: number;
|
|
559
563
|
};
|
|
560
564
|
type: "toolCall";
|
|
561
|
-
} | {
|
|
562
|
-
type: "thinking";
|
|
563
|
-
thinking: string;
|
|
564
|
-
thinkingSignature?: string;
|
|
565
|
-
redacted?: boolean;
|
|
566
565
|
} | {
|
|
567
566
|
addedToolNames?: string[];
|
|
568
567
|
arguments: Record<string, any>;
|
|
569
568
|
callID: string;
|
|
570
569
|
name: string;
|
|
571
570
|
namespace?: string;
|
|
572
|
-
|
|
573
|
-
content
|
|
571
|
+
result: {
|
|
572
|
+
content: ({
|
|
574
573
|
type: "text";
|
|
575
574
|
text: string;
|
|
576
575
|
textSignature?: string;
|
|
@@ -580,8 +579,9 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
580
579
|
mimeType: string;
|
|
581
580
|
})[];
|
|
582
581
|
details?: any;
|
|
582
|
+
isError: true;
|
|
583
583
|
};
|
|
584
|
-
status: "
|
|
584
|
+
status: "aborted";
|
|
585
585
|
thoughtSignature?: string;
|
|
586
586
|
time: {
|
|
587
587
|
start: number;
|
|
@@ -892,4 +892,4 @@ declare function durable<const Definitions extends ReadonlyArray<Definition>>(de
|
|
|
892
892
|
declare function latest(definitions: ReadonlyArray<Definition>): ReadonlyMap<string, Definition<string, Schema.Codec<unknown, unknown, never, never>>>;
|
|
893
893
|
//#endregion
|
|
894
894
|
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 };
|
|
895
|
-
//# sourceMappingURL=event-
|
|
895
|
+
//# sourceMappingURL=event-9PbbjnHJ.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-9PbbjnHJ.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,3 +1,4 @@
|
|
|
1
|
+
import { t as section_d_exports } from "./plugin/section.mjs";
|
|
1
2
|
import { g as tool_d_exports } from "./tool-DuYBgiJf.mjs";
|
|
2
|
-
import { t as plugin_d_exports } from "./plugin-
|
|
3
|
-
export { plugin_d_exports as Plugin, tool_d_exports as Tool };
|
|
3
|
+
import { t as plugin_d_exports } from "./plugin-CaG6IlD-.mjs";
|
|
4
|
+
export { plugin_d_exports as Plugin, section_d_exports as Section, tool_d_exports as Tool };
|
package/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { t as plugin_exports } from "./plugin-
|
|
1
|
+
import { t as plugin_exports } from "./plugin-XaYYRsX-.mjs";
|
|
2
|
+
import { t as section_exports } from "./plugin/section.mjs";
|
|
2
3
|
import { t as tool_exports } from "./tool.mjs";
|
|
3
|
-
export { plugin_exports as Plugin, tool_exports as Tool };
|
|
4
|
+
export { plugin_exports as Plugin, section_exports as Section, tool_exports as Tool };
|
|
@@ -2,6 +2,12 @@ import { i as project_d_exports, n as Info$1 } from "./project-CLGsIFD-.mjs";
|
|
|
2
2
|
import { a as space_d_exports, n as Info$2 } from "./space-CR-9UxdT.mjs";
|
|
3
3
|
import { Context, Schema } from "effect";
|
|
4
4
|
//#region src/location.d.ts
|
|
5
|
+
declare const Info_base: Schema.Class<Info, Schema.Struct<{
|
|
6
|
+
/** The absolute cwd tools run in; `space.location` is the root it lives under. */
|
|
7
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
8
|
+
readonly space: typeof Info$2;
|
|
9
|
+
readonly project: typeof Info$1;
|
|
10
|
+
}>, {}>;
|
|
5
11
|
/**
|
|
6
12
|
* Where work happens: a directory inside a space.
|
|
7
13
|
*
|
|
@@ -12,7 +18,7 @@ import { Context, Schema } from "effect";
|
|
|
12
18
|
* equal to or beneath that root. Sessions sharing a space share the project;
|
|
13
19
|
* worktree relationships stay a Project concern beneath it.
|
|
14
20
|
*
|
|
15
|
-
* **Both halves come from the mount,
|
|
21
|
+
* **Both halves come from the mount, and nothing overrides them.**
|
|
16
22
|
* A Location is a directory *within* a mounted namespace — the mount has to be
|
|
17
23
|
* resolved first, the way a volume is mounted before any path on it means
|
|
18
24
|
* anything — and once it is, the namespace and the working directory are already
|
|
@@ -24,17 +30,6 @@ import { Context, Schema } from "effect";
|
|
|
24
30
|
* which belong to the harness; a plugin receives a resolved `Info` on its context and asks for
|
|
25
31
|
* {@link Service} when it needs the live one.
|
|
26
32
|
*/
|
|
27
|
-
declare const Ref: Schema.Struct<{
|
|
28
|
-
/** Defaults to the mount's cwd. Set it to work in a subdirectory of the mount. */
|
|
29
|
-
readonly directory: Schema.optional<Schema.brand<Schema.String, "AbsolutePath">>;
|
|
30
|
-
}>;
|
|
31
|
-
type Ref = typeof Ref.Type;
|
|
32
|
-
declare const Info_base: Schema.Class<Info, Schema.Struct<{
|
|
33
|
-
/** The absolute cwd tools run in; `space.location` is the root it lives under. */
|
|
34
|
-
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
35
|
-
readonly space: typeof Info$2;
|
|
36
|
-
readonly project: typeof Info$1;
|
|
37
|
-
}>, {}>;
|
|
38
33
|
declare class Info extends Info_base {}
|
|
39
34
|
interface Interface extends Info {}
|
|
40
35
|
declare const Service_base: Context.ServiceClass<Service, "@codeworksh/plugin/location/Service", Interface>;
|
|
@@ -57,5 +52,5 @@ declare const NotDirectoryError_base: Schema.Class<NotDirectoryError, Schema.Tag
|
|
|
57
52
|
declare class NotDirectoryError extends NotDirectoryError_base {}
|
|
58
53
|
type Error = DirectoryNotFoundError | NotDirectoryError;
|
|
59
54
|
//#endregion
|
|
60
|
-
export { NotDirectoryError as a, Interface as i, Error as n,
|
|
61
|
-
//# sourceMappingURL=location-
|
|
55
|
+
export { NotDirectoryError as a, Interface as i, Error as n, Service as o, Info as r, DirectoryNotFoundError as t };
|
|
56
|
+
//# sourceMappingURL=location-Q39els63.d.mts.map
|
package/location.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as NotDirectoryError, i as Interface, n as Error, o as
|
|
2
|
-
export { DirectoryNotFoundError, Error, Info, Interface, NotDirectoryError,
|
|
1
|
+
import { a as NotDirectoryError, i as Interface, n as Error, o as Service, r as Info, t as DirectoryNotFoundError } from "./location-Q39els63.mjs";
|
|
2
|
+
export { DirectoryNotFoundError, Error, Info, Interface, NotDirectoryError, Service };
|
package/location.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import { Context, Schema } from "effect";
|
|
|
14
14
|
* equal to or beneath that root. Sessions sharing a space share the project;
|
|
15
15
|
* worktree relationships stay a Project concern beneath it.
|
|
16
16
|
*
|
|
17
|
-
* **Both halves come from the mount,
|
|
17
|
+
* **Both halves come from the mount, and nothing overrides them.**
|
|
18
18
|
* A Location is a directory *within* a mounted namespace — the mount has to be
|
|
19
19
|
* resolved first, the way a volume is mounted before any path on it means
|
|
20
20
|
* anything — and once it is, the namespace and the working directory are already
|
|
@@ -26,9 +26,6 @@ import { Context, Schema } from "effect";
|
|
|
26
26
|
* which belong to the harness; a plugin receives a resolved `Info` on its context and asks for
|
|
27
27
|
* {@link Service} when it needs the live one.
|
|
28
28
|
*/
|
|
29
|
-
const Ref = Schema.Struct({
|
|
30
|
-
/** Defaults to the mount's cwd. Set it to work in a subdirectory of the mount. */
|
|
31
|
-
directory: Schema.optional(AbsolutePath) }).annotate({ identifier: "Location.Ref" });
|
|
32
29
|
var Info = class extends Schema.Class("Location.Info")({
|
|
33
30
|
/** The absolute cwd tools run in; `space.location` is the root it lives under. */
|
|
34
31
|
directory: AbsolutePath,
|
|
@@ -43,6 +40,6 @@ const Fields = {
|
|
|
43
40
|
var DirectoryNotFoundError = class extends Schema.TaggedError()("Location.DirectoryNotFoundError", Fields) {};
|
|
44
41
|
var NotDirectoryError = class extends Schema.TaggedError()("Location.NotDirectoryError", Fields) {};
|
|
45
42
|
//#endregion
|
|
46
|
-
export { DirectoryNotFoundError, Info, NotDirectoryError,
|
|
43
|
+
export { DirectoryNotFoundError, Info, NotDirectoryError, Service };
|
|
47
44
|
|
|
48
45
|
//# sourceMappingURL=location.mjs.map
|
package/location.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"location.mjs","names":["SpaceSchema.Info","ProjectSchema.Info","SandboxInstance.ID"],"sources":["../../src/location.ts"],"sourcesContent":["import { Context, Schema } from \"effect\";\nimport { ProjectSchema } from \"./project.ts\";\nimport { AbsolutePath } from \"./schema.ts\";\nimport { SandboxInstance } from \"./sandbox/instance.ts\";\nimport { SpaceSchema } from \"./space.ts\";\n\n/**\n * Where work happens: a directory inside a space.\n *\n * The pair (space, directory) is the key. A path alone does not name a place —\n * `/app/repo` on the host and `/app/repo` inside a remote sandbox are different\n * trees wearing the same spelling — so the space carries the env and the\n * root it lives under (`space.location`), and `directory` is the absolute cwd\n * equal to or beneath that root. Sessions sharing a space share the project;\n * worktree relationships stay a Project concern beneath it.\n *\n * **Both halves come from the mount,
|
|
1
|
+
{"version":3,"file":"location.mjs","names":["SpaceSchema.Info","ProjectSchema.Info","SandboxInstance.ID"],"sources":["../../src/location.ts"],"sourcesContent":["import { Context, Schema } from \"effect\";\nimport { ProjectSchema } from \"./project.ts\";\nimport { AbsolutePath } from \"./schema.ts\";\nimport { SandboxInstance } from \"./sandbox/instance.ts\";\nimport { SpaceSchema } from \"./space.ts\";\n\n/**\n * Where work happens: a directory inside a space.\n *\n * The pair (space, directory) is the key. A path alone does not name a place —\n * `/app/repo` on the host and `/app/repo` inside a remote sandbox are different\n * trees wearing the same spelling — so the space carries the env and the\n * root it lives under (`space.location`), and `directory` is the absolute cwd\n * equal to or beneath that root. Sessions sharing a space share the project;\n * worktree relationships stay a Project concern beneath it.\n *\n * **Both halves come from the mount, and nothing overrides them.**\n * A Location is a directory *within* a mounted namespace — the mount has to be\n * resolved first, the way a volume is mounted before any path on it means\n * anything — and once it is, the namespace and the working directory are already\n * in scope. Re-declaring them would be two spellings of one value, free to drift;\n * a Location pointing somewhere its own shell is not becomes unrepresentable\n * rather than merely avoided by discipline.\n *\n * Only the shape and the service tag live here. Building one needs Project, Space, Repo and Git,\n * which belong to the harness; a plugin receives a resolved `Info` on its context and asks for\n * {@link Service} when it needs the live one.\n */\nexport class Info extends Schema.Class<Info>(\"Location.Info\")({\n\t/** The absolute cwd tools run in; `space.location` is the root it lives under. */\n\tdirectory: AbsolutePath,\n\tspace: SpaceSchema.Info,\n\tproject: ProjectSchema.Info,\n}) {}\n\nexport interface Interface extends Info {}\n\nexport class Service extends Context.Service<Service, Interface>()(\"@codeworksh/plugin/location/Service\") {}\n\nconst Fields = {\n\tdirectory: AbsolutePath,\n\tsandboxInstanceId: SandboxInstance.ID,\n};\n\nexport class DirectoryNotFoundError extends Schema.TaggedError<DirectoryNotFoundError>()(\n\t\"Location.DirectoryNotFoundError\",\n\tFields,\n) {}\n\nexport class NotDirectoryError extends Schema.TaggedError<NotDirectoryError>()(\"Location.NotDirectoryError\", Fields) {}\n\nexport type Error = DirectoryNotFoundError | NotDirectoryError;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAa,OAAb,cAA0B,OAAO,MAAY,eAAe,CAAC,CAAC;;CAE7D,WAAW;CACX,OAAOA;CACP,SAASC;AACV,CAAC,CAAC,CAAC,CAAC;AAIJ,IAAa,UAAb,cAA6B,QAAQ,QAA4B,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC;AAE3G,MAAM,SAAS;CACd,WAAW;CACX,mBAAmBC;AACpB;AAEA,IAAa,yBAAb,cAA4C,OAAO,YAAoC,CAAC,CACvF,mCACA,MACD,CAAC,CAAC,CAAC;AAEH,IAAa,oBAAb,cAAuC,OAAO,YAA+B,CAAC,CAAC,8BAA8B,MAAM,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeworksh/plugin",
|
|
3
|
-
"version": "0.0.1-canary.
|
|
3
|
+
"version": "0.0.1-canary.13.1.gbddb812f",
|
|
4
4
|
"description": "SDK for building CodeWork plugins — the plugin, tool, and sandbox contracts shared with @codeworksh/harness.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -45,6 +45,11 @@
|
|
|
45
45
|
"import": "./plugin/prompt.mjs",
|
|
46
46
|
"default": "./plugin/prompt.mjs"
|
|
47
47
|
},
|
|
48
|
+
"./plugin/section": {
|
|
49
|
+
"types": "./plugin/section.d.mts",
|
|
50
|
+
"import": "./plugin/section.mjs",
|
|
51
|
+
"default": "./plugin/section.mjs"
|
|
52
|
+
},
|
|
48
53
|
"./sandbox": {
|
|
49
54
|
"types": "./sandbox.d.mts",
|
|
50
55
|
"import": "./sandbox.mjs",
|
|
@@ -163,7 +168,7 @@
|
|
|
163
168
|
"uuidv7": "^1.2.1"
|
|
164
169
|
},
|
|
165
170
|
"peerDependencies": {
|
|
166
|
-
"@codeworksh/aikit": "0.9.3-canary.
|
|
171
|
+
"@codeworksh/aikit": "0.9.3-canary.13.1.gbddb812f",
|
|
167
172
|
"effect": "4.0.0-rc.115"
|
|
168
173
|
}
|
|
169
174
|
}
|
package/plugin/prompt.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as PromptRegistry } from "../prompt-
|
|
1
|
+
import { t as PromptRegistry } from "../prompt-DWaA5ZXj.mjs";
|
|
2
2
|
export { PromptRegistry };
|
package/plugin/prompt.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.mjs","names":[],"sources":["../../../src/plugin/prompt.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"prompt.mjs","names":[],"sources":["../../../src/plugin/prompt.ts"],"sourcesContent":["import type { Section } from \"./section.ts\";\n\nexport interface PromptRegistry {\n\t/** The untagged head of the system prompt; the last `set` wins. */\n\treadonly foundation: {\n\t\treadonly set: (text: string) => void;\n\t\treadonly get: () => string | undefined;\n\t};\n\treadonly sections: {\n\t\treadonly append: (section: Section, entry: string) => void;\n\t\treadonly set: (section: Section, entries: ReadonlyArray<string>) => void;\n\t\t/** Writing a removed section again opens a new one, last in order. */\n\t\treadonly remove: (section: Section) => void;\n\t\treadonly get: (section: Section) => ReadonlyArray<string> | undefined;\n\t};\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare namespace section_d_exports {
|
|
2
|
+
export { Addendum, Format, ProjectContext, Rules, Section, Skills, builtins, define, invalid, isFormat, reserved };
|
|
3
|
+
}
|
|
4
|
+
/** `text`: entries verbatim, blank-line separated. `list`: deduplicated `- ` bullets. */
|
|
5
|
+
export type Format = "text" | "list";
|
|
6
|
+
export interface Section<Name extends string = string> {
|
|
7
|
+
readonly name: Name;
|
|
8
|
+
readonly format: Format;
|
|
9
|
+
}
|
|
10
|
+
export declare const Rules: Section<"rules">;
|
|
11
|
+
export declare const Addendum: Section<"addendum">;
|
|
12
|
+
export declare const ProjectContext: Section<"project_context">;
|
|
13
|
+
export declare const Skills: Section<"skills">;
|
|
14
|
+
/** Rendered in this order, before custom sections. */
|
|
15
|
+
export declare const builtins: ReadonlyArray<Section>;
|
|
16
|
+
/** Rendered by the harness, never by a plugin. */
|
|
17
|
+
export declare const reserved: ReadonlySet<string>;
|
|
18
|
+
/** Runtime check: a JavaScript plugin can pass anything. */
|
|
19
|
+
export declare const isFormat: (format: unknown) => format is Format;
|
|
20
|
+
export declare const invalid: (name: unknown) => string | undefined;
|
|
21
|
+
/** A custom section. Throws on a name that is malformed, reserved, or built in. */
|
|
22
|
+
export declare const define: <const Name extends string>(name: Name, options?: {
|
|
23
|
+
readonly format?: Format;
|
|
24
|
+
}) => Section<Name>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { section_d_exports as t };
|
|
27
|
+
//# sourceMappingURL=section.d.mts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
//#region src/plugin/section.ts
|
|
3
|
+
var section_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
Addendum: () => Addendum,
|
|
5
|
+
ProjectContext: () => ProjectContext,
|
|
6
|
+
Rules: () => Rules,
|
|
7
|
+
Skills: () => Skills,
|
|
8
|
+
builtins: () => builtins,
|
|
9
|
+
define: () => define,
|
|
10
|
+
invalid: () => invalid,
|
|
11
|
+
isFormat: () => isFormat,
|
|
12
|
+
reserved: () => reserved
|
|
13
|
+
});
|
|
14
|
+
const Rules = Object.freeze({
|
|
15
|
+
name: "rules",
|
|
16
|
+
format: "list"
|
|
17
|
+
});
|
|
18
|
+
const Addendum = Object.freeze({
|
|
19
|
+
name: "addendum",
|
|
20
|
+
format: "text"
|
|
21
|
+
});
|
|
22
|
+
const ProjectContext = Object.freeze({
|
|
23
|
+
name: "project_context",
|
|
24
|
+
format: "text"
|
|
25
|
+
});
|
|
26
|
+
const Skills = Object.freeze({
|
|
27
|
+
name: "skills",
|
|
28
|
+
format: "text"
|
|
29
|
+
});
|
|
30
|
+
/** Rendered in this order, before custom sections. */
|
|
31
|
+
const builtins = Object.freeze([
|
|
32
|
+
Rules,
|
|
33
|
+
Addendum,
|
|
34
|
+
ProjectContext,
|
|
35
|
+
Skills
|
|
36
|
+
]);
|
|
37
|
+
/** Rendered by the harness, never by a plugin. */
|
|
38
|
+
const reserved = /* @__PURE__ */ new Set([
|
|
39
|
+
"tools",
|
|
40
|
+
"cwd",
|
|
41
|
+
"foundation"
|
|
42
|
+
]);
|
|
43
|
+
const pattern = /^[a-z][a-z0-9_-]*$/;
|
|
44
|
+
const formats = /* @__PURE__ */ new Set(["text", "list"]);
|
|
45
|
+
/** Runtime check: a JavaScript plugin can pass anything. */
|
|
46
|
+
const isFormat = (format) => formats.has(format);
|
|
47
|
+
const invalid = (name) => {
|
|
48
|
+
if (typeof name !== "string" || !pattern.test(name)) return `prompt section name must be lowercase letters, digits, "_" or "-": ${JSON.stringify(name)}`;
|
|
49
|
+
if (reserved.has(name)) return `prompt section name is reserved: ${name}`;
|
|
50
|
+
};
|
|
51
|
+
/** A custom section. Throws on a name that is malformed, reserved, or built in. */
|
|
52
|
+
const define = (name, options) => {
|
|
53
|
+
const reason = invalid(name) ?? (builtins.some((section) => section.name === name) ? `prompt section name is built in: ${name}` : void 0);
|
|
54
|
+
if (reason !== void 0) throw new Error(reason);
|
|
55
|
+
const format = options?.format ?? "text";
|
|
56
|
+
if (!isFormat(format)) throw new Error(`prompt section format must be "text" or "list": ${JSON.stringify(format)}`);
|
|
57
|
+
return Object.freeze({
|
|
58
|
+
name,
|
|
59
|
+
format
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { Addendum, ProjectContext, Rules, Skills, builtins, define, invalid, isFormat, reserved, section_exports as t };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=section.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section.mjs","names":[],"sources":["../../../src/plugin/section.ts"],"sourcesContent":["// Sections are passed by value, never by name string, so a typo fails to compile instead of\n// quietly opening a new section.\n\n/** `text`: entries verbatim, blank-line separated. `list`: deduplicated `- ` bullets. */\nexport type Format = \"text\" | \"list\";\n\nexport interface Section<Name extends string = string> {\n\treadonly name: Name;\n\treadonly format: Format;\n}\n\nexport const Rules: Section<\"rules\"> = Object.freeze({ name: \"rules\", format: \"list\" });\nexport const Addendum: Section<\"addendum\"> = Object.freeze({ name: \"addendum\", format: \"text\" });\nexport const ProjectContext: Section<\"project_context\"> = Object.freeze({ name: \"project_context\", format: \"text\" });\nexport const Skills: Section<\"skills\"> = Object.freeze({ name: \"skills\", format: \"text\" });\n\n/** Rendered in this order, before custom sections. */\nexport const builtins: ReadonlyArray<Section> = Object.freeze([Rules, Addendum, ProjectContext, Skills]);\n\n/** Rendered by the harness, never by a plugin. */\nexport const reserved: ReadonlySet<string> = new Set([\"tools\", \"cwd\", \"foundation\"]);\n\nconst pattern = /^[a-z][a-z0-9_-]*$/;\n\nconst formats: ReadonlySet<unknown> = new Set<Format>([\"text\", \"list\"]);\n\n/** Runtime check: a JavaScript plugin can pass anything. */\nexport const isFormat = (format: unknown): format is Format => formats.has(format);\n\nexport const invalid = (name: unknown): string | undefined => {\n\tif (typeof name !== \"string\" || !pattern.test(name))\n\t\treturn `prompt section name must be lowercase letters, digits, \"_\" or \"-\": ${JSON.stringify(name)}`;\n\tif (reserved.has(name)) return `prompt section name is reserved: ${name}`;\n\treturn undefined;\n};\n\n/** A custom section. Throws on a name that is malformed, reserved, or built in. */\nexport const define = <const Name extends string>(\n\tname: Name,\n\toptions?: { readonly format?: Format },\n): Section<Name> => {\n\tconst reason =\n\t\tinvalid(name) ??\n\t\t(builtins.some((section) => section.name === name) ? `prompt section name is built in: ${name}` : undefined);\n\tif (reason !== undefined) throw new Error(reason);\n\tconst format = options?.format ?? \"text\";\n\tif (!isFormat(format)) throw new Error(`prompt section format must be \"text\" or \"list\": ${JSON.stringify(format)}`);\n\treturn Object.freeze({ name, format });\n};\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAa,QAA0B,OAAO,OAAO;CAAE,MAAM;CAAS,QAAQ;AAAO,CAAC;AACtF,MAAa,WAAgC,OAAO,OAAO;CAAE,MAAM;CAAY,QAAQ;AAAO,CAAC;AAC/F,MAAa,iBAA6C,OAAO,OAAO;CAAE,MAAM;CAAmB,QAAQ;AAAO,CAAC;AACnH,MAAa,SAA4B,OAAO,OAAO;CAAE,MAAM;CAAU,QAAQ;AAAO,CAAC;;AAGzF,MAAa,WAAmC,OAAO,OAAO;CAAC;CAAO;CAAU;CAAgB;AAAM,CAAC;;AAGvG,MAAa,2BAAgC,IAAI,IAAI;CAAC;CAAS;CAAO;AAAY,CAAC;AAEnF,MAAM,UAAU;AAEhB,MAAM,0BAAgC,IAAI,IAAY,CAAC,QAAQ,MAAM,CAAC;;AAGtE,MAAa,YAAY,WAAsC,QAAQ,IAAI,MAAM;AAEjF,MAAa,WAAW,SAAsC;CAC7D,IAAI,OAAO,SAAS,YAAY,CAAC,QAAQ,KAAK,IAAI,GACjD,OAAO,sEAAsE,KAAK,UAAU,IAAI;CACjG,IAAI,SAAS,IAAI,IAAI,GAAG,OAAO,oCAAoC;AAEpE;;AAGA,MAAa,UACZ,MACA,YACmB;CACnB,MAAM,SACL,QAAQ,IAAI,MACX,SAAS,MAAM,YAAY,QAAQ,SAAS,IAAI,IAAI,oCAAoC,SAAS,KAAA;CACnG,IAAI,WAAW,KAAA,GAAW,MAAM,IAAI,MAAM,MAAM;CAChD,MAAM,SAAS,SAAS,UAAU;CAClC,IAAI,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,mDAAmD,KAAK,UAAU,MAAM,GAAG;CAClH,OAAO,OAAO,OAAO;EAAE;EAAM;CAAO,CAAC;AACtC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
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-9PbbjnHJ.mjs";
|
|
2
2
|
import { n as SessionID } from "./ids-CHjmAdTc.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { o as Service, r as Info } from "./location-Q39els63.mjs";
|
|
4
4
|
import { a as Provides, r as Identity, u as io_d_exports } from "./io-BYs7hbiY.mjs";
|
|
5
|
-
import { i as Info$1 } from "./settings-
|
|
6
|
-
import {
|
|
5
|
+
import { i as Info$1 } from "./settings-B6-grSTA.mjs";
|
|
6
|
+
import { t as section_d_exports } from "./plugin/section.mjs";
|
|
7
|
+
import { n as prompt_d_exports, t as PromptRegistry } from "./prompt-DWaA5ZXj.mjs";
|
|
7
8
|
import { d as ToolRegistry, p as tool_d_exports } from "./tool-BoVqkYvL.mjs";
|
|
8
9
|
import { Model } from "@codeworksh/aikit";
|
|
9
10
|
import { Effect } from "effect";
|
|
@@ -133,8 +134,8 @@ interface Plugin {
|
|
|
133
134
|
}
|
|
134
135
|
declare const define: (plugin: Plugin) => Plugin;
|
|
135
136
|
declare namespace plugin_d_exports {
|
|
136
|
-
export { Config, Events, Mount, Plugin, PluginKind, PluginOptions, PluginPatch, PluginRef, PluginRegistry, PluginSpec, prompt_d_exports as Prompt, PromptResolver, SharedPluginContext, tool_d_exports as Tool, define, domains, rank };
|
|
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 };
|
|
137
138
|
}
|
|
138
139
|
//#endregion
|
|
139
140
|
export { define as a, PluginOptions as c, PluginSpec as d, Config as f, PluginRegistry as g, SharedPluginContext as h, PluginKind as i, PluginPatch as l, PromptResolver 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 };
|
|
140
|
-
//# sourceMappingURL=plugin-
|
|
141
|
+
//# sourceMappingURL=plugin-CaG6IlD-.d.mts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { t as prompt_exports } from "./plugin/prompt.mjs";
|
|
3
|
+
import { t as section_exports } from "./plugin/section.mjs";
|
|
3
4
|
import { t as tool_exports } from "./plugin/tool.mjs";
|
|
4
5
|
//#region src/plugin/plugin.ts
|
|
5
6
|
/**
|
|
@@ -30,6 +31,7 @@ const define = (plugin) => plugin;
|
|
|
30
31
|
//#region src/plugin.ts
|
|
31
32
|
var plugin_exports = /* @__PURE__ */ __exportAll({
|
|
32
33
|
Prompt: () => prompt_exports,
|
|
34
|
+
Section: () => section_exports,
|
|
33
35
|
Tool: () => tool_exports,
|
|
34
36
|
define: () => define,
|
|
35
37
|
domains: () => domains,
|
|
@@ -38,4 +40,4 @@ var plugin_exports = /* @__PURE__ */ __exportAll({
|
|
|
38
40
|
//#endregion
|
|
39
41
|
export { rank as i, define as n, domains as r, plugin_exports as t };
|
|
40
42
|
|
|
41
|
-
//# sourceMappingURL=plugin-
|
|
43
|
+
//# sourceMappingURL=plugin-XaYYRsX-.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-
|
|
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 { PluginOptions } from \"./ref.ts\";\nimport type { SharedPluginContext } from \"./context.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 * `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, 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;AA+BlD,MAAa,UAAU,WAA2B"}
|
package/plugin.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as section_d_exports } from "./plugin/section.mjs";
|
|
2
|
+
import { n as prompt_d_exports } from "./prompt-DWaA5ZXj.mjs";
|
|
2
3
|
import { p as tool_d_exports } from "./tool-BoVqkYvL.mjs";
|
|
3
|
-
import { a as define, c as PluginOptions, d as PluginSpec, f as Config, g as PluginRegistry, h as SharedPluginContext, i as PluginKind, l as PluginPatch, m as PromptResolver, n as Mount, o as domains, p as Events, r as Plugin, s as rank, u as PluginRef } from "./plugin-
|
|
4
|
-
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, type SharedPluginContext, tool_d_exports as Tool, define, domains, rank };
|
|
4
|
+
import { a as define, c as PluginOptions, d as PluginSpec, f as Config, g as PluginRegistry, h as SharedPluginContext, i as PluginKind, l as PluginPatch, m as PromptResolver, n as Mount, o as domains, p as Events, r as Plugin, s as rank, u as PluginRef } from "./plugin-CaG6IlD-.mjs";
|
|
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 };
|
package/plugin.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { i as rank, n as define, r as domains } from "./plugin-
|
|
1
|
+
import { i as rank, n as define, r as domains } from "./plugin-XaYYRsX-.mjs";
|
|
2
2
|
import { t as prompt_exports } from "./plugin/prompt.mjs";
|
|
3
|
+
import { t as section_exports } from "./plugin/section.mjs";
|
|
3
4
|
import { t as tool_exports } from "./plugin/tool.mjs";
|
|
4
|
-
export { prompt_exports as Prompt, tool_exports as Tool, define, domains, rank };
|
|
5
|
+
export { prompt_exports as Prompt, section_exports as Section, tool_exports as Tool, define, domains, rank };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Section } from "./plugin/section.mjs";
|
|
2
|
+
declare namespace prompt_d_exports {
|
|
3
|
+
export { PromptRegistry };
|
|
4
|
+
}
|
|
5
|
+
interface PromptRegistry {
|
|
6
|
+
/** The untagged head of the system prompt; the last `set` wins. */
|
|
7
|
+
readonly foundation: {
|
|
8
|
+
readonly set: (text: string) => void;
|
|
9
|
+
readonly get: () => string | undefined;
|
|
10
|
+
};
|
|
11
|
+
readonly sections: {
|
|
12
|
+
readonly append: (section: Section, entry: string) => void;
|
|
13
|
+
readonly set: (section: Section, entries: ReadonlyArray<string>) => void;
|
|
14
|
+
/** Writing a removed section again opens a new one, last in order. */
|
|
15
|
+
readonly remove: (section: Section) => void;
|
|
16
|
+
readonly get: (section: Section) => ReadonlyArray<string> | undefined;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { prompt_d_exports as n, PromptRegistry as t };
|
|
21
|
+
//# sourceMappingURL=prompt-DWaA5ZXj.d.mts.map
|
|
@@ -272,6 +272,24 @@ declare const PluginEntry: Schema.Union<readonly [Schema.String, Schema.Union<re
|
|
|
272
272
|
readonly package: Schema.String;
|
|
273
273
|
}>]>]>;
|
|
274
274
|
type PluginEntry = typeof PluginEntry.Type;
|
|
275
|
+
/**
|
|
276
|
+
* Agent-level retry of a turn whose provider request failed transiently (rate limit, overload,
|
|
277
|
+
* 5xx, dropped connection). Delays double from `baseDelayMs` and stop growing at `maxDelayMs`;
|
|
278
|
+
* a server that asks for a longer wait than `maxDelayMs` is not retried. `maxRetries: 0` is off.
|
|
279
|
+
*
|
|
280
|
+
* Separate from `model.options.maxRetries`, which retries inside the provider SDK and defaults to
|
|
281
|
+
* 0 so that the two do not multiply, and so a quota error reaches the loop instead of being retried.
|
|
282
|
+
*/
|
|
283
|
+
declare const Retry: Schema.Struct<{
|
|
284
|
+
readonly maxRetries: Schema.optional<Schema.Int>;
|
|
285
|
+
readonly baseDelayMs: Schema.optional<Schema.Int>;
|
|
286
|
+
readonly maxDelayMs: Schema.optional<Schema.Int>;
|
|
287
|
+
}>;
|
|
288
|
+
interface RetryPolicy {
|
|
289
|
+
readonly maxRetries: number;
|
|
290
|
+
readonly baseDelayMs: number;
|
|
291
|
+
readonly maxDelayMs: number;
|
|
292
|
+
}
|
|
275
293
|
declare const Patch: Schema.Struct<{
|
|
276
294
|
readonly $schema: Schema.optional<Schema.String>;
|
|
277
295
|
readonly plugins: Schema.optional<Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Union<readonly [Schema.Struct<{
|
|
@@ -489,6 +507,11 @@ declare const Patch: Schema.Struct<{
|
|
|
489
507
|
xhigh?: string | null;
|
|
490
508
|
};
|
|
491
509
|
}>, Schema.Unknown, never, never>>>;
|
|
510
|
+
readonly retry: Schema.optional<Schema.Struct<{
|
|
511
|
+
readonly maxRetries: Schema.optional<Schema.Int>;
|
|
512
|
+
readonly baseDelayMs: Schema.optional<Schema.Int>;
|
|
513
|
+
readonly maxDelayMs: Schema.optional<Schema.Int>;
|
|
514
|
+
}>>;
|
|
492
515
|
}>;
|
|
493
516
|
type Patch = typeof Patch.Type;
|
|
494
517
|
/**
|
|
@@ -549,9 +572,10 @@ interface Info {
|
|
|
549
572
|
readonly thinkingLevel: Model.ThinkingLevel;
|
|
550
573
|
readonly toolExecution: ToolExecution;
|
|
551
574
|
};
|
|
575
|
+
readonly retry: RetryPolicy;
|
|
552
576
|
}
|
|
553
577
|
/** Let aikit supply model-aware generation defaults. */
|
|
554
578
|
declare const defaults: Info;
|
|
555
579
|
//#endregion
|
|
556
|
-
export { KeyReference as a, ModelProtocol as c, PluginPatch as d,
|
|
557
|
-
//# sourceMappingURL=settings-
|
|
580
|
+
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-B6-grSTA.d.mts.map
|
package/settings.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as KeyReference, c as ModelProtocol, d as PluginPatch, f as
|
|
2
|
-
export { Block, Declared, DeclaredModel, Info, KeyReference, Model, ModelEntry, ModelProtocol, Patch, PluginEntry, PluginPatch, ThinkingLevel, ToolExecution, defaults, keyName, requestFields };
|
|
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-B6-grSTA.mjs";
|
|
2
|
+
export { Block, Declared, DeclaredModel, Info, KeyReference, Model, ModelEntry, ModelProtocol, Patch, PluginEntry, PluginPatch, Retry, RetryPolicy, ThinkingLevel, ToolExecution, defaults, keyName, requestFields };
|
package/settings.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isAikitModelInfo, validateAikitModelInfo } from "./schema.mjs";
|
|
1
|
+
import { NonNegativeInt, isAikitModelInfo, validateAikitModelInfo } from "./schema.mjs";
|
|
2
2
|
import { Model as Model$1 } from "@codeworksh/aikit";
|
|
3
3
|
import { Effect, Schema, SchemaGetter, SchemaIssue } from "effect";
|
|
4
4
|
//#region src/settings.ts
|
|
@@ -104,11 +104,25 @@ const PluginPatch = Schema.Union([Schema.Struct({
|
|
|
104
104
|
...config
|
|
105
105
|
})], { mode: "oneOf" });
|
|
106
106
|
const PluginEntry = Schema.Union([PluginReference, PluginPatch]);
|
|
107
|
+
/**
|
|
108
|
+
* Agent-level retry of a turn whose provider request failed transiently (rate limit, overload,
|
|
109
|
+
* 5xx, dropped connection). Delays double from `baseDelayMs` and stop growing at `maxDelayMs`;
|
|
110
|
+
* a server that asks for a longer wait than `maxDelayMs` is not retried. `maxRetries: 0` is off.
|
|
111
|
+
*
|
|
112
|
+
* Separate from `model.options.maxRetries`, which retries inside the provider SDK and defaults to
|
|
113
|
+
* 0 so that the two do not multiply, and so a quota error reaches the loop instead of being retried.
|
|
114
|
+
*/
|
|
115
|
+
const Retry = Schema.Struct({
|
|
116
|
+
maxRetries: Schema.optional(NonNegativeInt),
|
|
117
|
+
baseDelayMs: Schema.optional(NonNegativeInt),
|
|
118
|
+
maxDelayMs: Schema.optional(NonNegativeInt)
|
|
119
|
+
});
|
|
107
120
|
const Patch = Schema.Struct({
|
|
108
121
|
$schema: Schema.optional(Schema.String),
|
|
109
122
|
plugins: Schema.optional(Schema.Array(PluginEntry)),
|
|
110
123
|
model: Schema.optional(Model),
|
|
111
|
-
models: Schema.optional(Schema.Array(ModelEntry))
|
|
124
|
+
models: Schema.optional(Schema.Array(ModelEntry)),
|
|
125
|
+
retry: Schema.optional(Retry)
|
|
112
126
|
});
|
|
113
127
|
/** Let aikit supply model-aware generation defaults. */
|
|
114
128
|
const defaults = {
|
|
@@ -122,11 +136,16 @@ const defaults = {
|
|
|
122
136
|
toolExecution: "sequential",
|
|
123
137
|
options: {
|
|
124
138
|
timeoutMs: 36e5,
|
|
125
|
-
maxRetries:
|
|
139
|
+
maxRetries: 0
|
|
126
140
|
}
|
|
141
|
+
},
|
|
142
|
+
retry: {
|
|
143
|
+
maxRetries: 3,
|
|
144
|
+
baseDelayMs: 2e3,
|
|
145
|
+
maxDelayMs: 6e4
|
|
127
146
|
}
|
|
128
147
|
};
|
|
129
148
|
//#endregion
|
|
130
|
-
export { Block, KeyReference, Model, ModelEntry, ModelProtocol, Patch, PluginEntry, PluginPatch, ThinkingLevel, ToolExecution, defaults, keyName, requestFields };
|
|
149
|
+
export { Block, KeyReference, Model, ModelEntry, ModelProtocol, Patch, PluginEntry, PluginPatch, Retry, ThinkingLevel, ToolExecution, defaults, keyName, requestFields };
|
|
131
150
|
|
|
132
151
|
//# sourceMappingURL=settings.mjs.map
|
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, 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\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});\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}\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: 3 },\n\t},\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,OAA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,CACF;;AAIA,MAAM,kBAAkB,OAAO,OAAO,MAAM,OAAO,WAAW,CAAC;;;;;;AAM/D,MAAM,SAAS;CACd,SAAS,OAAO,SAAS,OAAO,OAAO;CACvC,SAAS,OAAO,SAAS,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,CAAC;AACtE;AACA,MAAa,cAAc,OAAO,MACjC,CAAC,OAAO,OAAO;CAAE,QAAQ;CAAiB,GAAG;AAAO,CAAC,GAAG,OAAO,OAAO;CAAE,SAAS;CAAiB,GAAG;AAAO,CAAC,CAAC,GAG9G,EAAE,MAAM,QAAQ,CACjB;AACA,MAAa,cAAc,OAAO,MAAM,CAAC,iBAAiB,WAAW,CAAC;AAGtE,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;AACjD,CAAC;;AAkED,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,YAAY;EAAE;CAChD;AACD"}
|
|
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,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,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,S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AOD,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,YAAY;EAAE;CAChD;CACA,OAAO;EAAE,YAAY;EAAG,aAAa;EAAO,YAAY;CAAO;AAChE"}
|
package/prompt-BcpagjGh.d.mts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare namespace prompt_d_exports {
|
|
2
|
-
export { PromptRegistry };
|
|
3
|
-
}
|
|
4
|
-
interface PromptRegistry {
|
|
5
|
-
readonly set: (systemPrompt: string) => void;
|
|
6
|
-
readonly get: () => string | undefined;
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
export { prompt_d_exports as n, PromptRegistry as t };
|
|
10
|
-
//# sourceMappingURL=prompt-BcpagjGh.d.mts.map
|