@codeworksh/plugin 0.3.0-canary.66.1.gf4c14646 → 0.3.0-canary.69.1.g5be1ef81
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-6sTQ_4bq.d.mts → event-C6-oCzlq.d.mts} +1 -21
- package/event.d.mts +1 -1
- package/index.d.mts +2 -2
- package/package.json +2 -2
- package/plugin/tool.d.mts +1 -1
- package/{plugin-CZHbJIzN.d.mts → plugin-ZmFbf49i.d.mts} +3 -3
- package/plugin.d.mts +2 -2
- package/tool/progress.d.mts +1 -1
- package/{tool-Bz8XyBlE.d.mts → tool-B27F3Bhp.d.mts} +2 -10
- package/{tool-B4nkpC9M.d.mts → tool-BRTCmPch.d.mts} +17 -3
- package/tool.d.mts +2 -2
- package/tool.mjs +17 -1
- package/tool.mjs.map +1 -1
|
@@ -162,7 +162,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
162
162
|
thinkingSignature?: string;
|
|
163
163
|
redacted?: boolean;
|
|
164
164
|
} | {
|
|
165
|
-
addedToolNames?: string[];
|
|
166
165
|
arguments: Record<string, any>;
|
|
167
166
|
callID: string;
|
|
168
167
|
name: string;
|
|
@@ -187,7 +186,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
187
186
|
};
|
|
188
187
|
type: "toolCall";
|
|
189
188
|
} | {
|
|
190
|
-
addedToolNames?: string[];
|
|
191
189
|
arguments: Record<string, any>;
|
|
192
190
|
callID: string;
|
|
193
191
|
name: string;
|
|
@@ -213,7 +211,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
213
211
|
};
|
|
214
212
|
type: "toolCall";
|
|
215
213
|
} | {
|
|
216
|
-
addedToolNames?: string[];
|
|
217
214
|
arguments: Record<string, any>;
|
|
218
215
|
callID: string;
|
|
219
216
|
name: string;
|
|
@@ -239,7 +236,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
239
236
|
};
|
|
240
237
|
type: "toolCall";
|
|
241
238
|
} | {
|
|
242
|
-
addedToolNames?: string[];
|
|
243
239
|
arguments: Record<string, any>;
|
|
244
240
|
callID: string;
|
|
245
241
|
name: string;
|
|
@@ -265,7 +261,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
265
261
|
};
|
|
266
262
|
type: "toolCall";
|
|
267
263
|
} | {
|
|
268
|
-
addedToolNames?: string[];
|
|
269
264
|
arguments: Record<string, any>;
|
|
270
265
|
callID: string;
|
|
271
266
|
name: string;
|
|
@@ -297,7 +292,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
297
292
|
arguments: Record<string, any>;
|
|
298
293
|
thoughtSignature?: string;
|
|
299
294
|
namespace?: string;
|
|
300
|
-
addedToolNames?: string[];
|
|
301
295
|
time: {
|
|
302
296
|
start: number;
|
|
303
297
|
end: number;
|
|
@@ -464,7 +458,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
464
458
|
thinkingSignature?: string;
|
|
465
459
|
redacted?: boolean;
|
|
466
460
|
} | {
|
|
467
|
-
addedToolNames?: string[];
|
|
468
461
|
arguments: Record<string, any>;
|
|
469
462
|
callID: string;
|
|
470
463
|
name: string;
|
|
@@ -489,7 +482,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
489
482
|
};
|
|
490
483
|
type: "toolCall";
|
|
491
484
|
} | {
|
|
492
|
-
addedToolNames?: string[];
|
|
493
485
|
arguments: Record<string, any>;
|
|
494
486
|
callID: string;
|
|
495
487
|
name: string;
|
|
@@ -515,7 +507,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
515
507
|
};
|
|
516
508
|
type: "toolCall";
|
|
517
509
|
} | {
|
|
518
|
-
addedToolNames?: string[];
|
|
519
510
|
arguments: Record<string, any>;
|
|
520
511
|
callID: string;
|
|
521
512
|
name: string;
|
|
@@ -541,7 +532,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
541
532
|
};
|
|
542
533
|
type: "toolCall";
|
|
543
534
|
} | {
|
|
544
|
-
addedToolNames?: string[];
|
|
545
535
|
arguments: Record<string, any>;
|
|
546
536
|
callID: string;
|
|
547
537
|
name: string;
|
|
@@ -567,7 +557,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
567
557
|
};
|
|
568
558
|
type: "toolCall";
|
|
569
559
|
} | {
|
|
570
|
-
addedToolNames?: string[];
|
|
571
560
|
arguments: Record<string, any>;
|
|
572
561
|
callID: string;
|
|
573
562
|
name: string;
|
|
@@ -599,7 +588,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
599
588
|
arguments: Record<string, any>;
|
|
600
589
|
thoughtSignature?: string;
|
|
601
590
|
namespace?: string;
|
|
602
|
-
addedToolNames?: string[];
|
|
603
591
|
time: {
|
|
604
592
|
start: number;
|
|
605
593
|
end: number;
|
|
@@ -613,7 +601,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
613
601
|
}>, Schema.Unknown, never, never>;
|
|
614
602
|
type AikitAssistantMessage = typeof AikitAssistantMessage.Type;
|
|
615
603
|
declare const AikitToolCallTerminalPart: Schema.decodeTo<Schema.declare<{
|
|
616
|
-
addedToolNames?: string[];
|
|
617
604
|
arguments: Record<string, any>;
|
|
618
605
|
callID: string;
|
|
619
606
|
name: string;
|
|
@@ -639,7 +626,6 @@ declare const AikitToolCallTerminalPart: Schema.decodeTo<Schema.declare<{
|
|
|
639
626
|
};
|
|
640
627
|
type: "toolCall";
|
|
641
628
|
} | {
|
|
642
|
-
addedToolNames?: string[];
|
|
643
629
|
arguments: Record<string, any>;
|
|
644
630
|
callID: string;
|
|
645
631
|
name: string;
|
|
@@ -665,7 +651,6 @@ declare const AikitToolCallTerminalPart: Schema.decodeTo<Schema.declare<{
|
|
|
665
651
|
};
|
|
666
652
|
type: "toolCall";
|
|
667
653
|
} | {
|
|
668
|
-
addedToolNames?: string[];
|
|
669
654
|
arguments: Record<string, any>;
|
|
670
655
|
callID: string;
|
|
671
656
|
name: string;
|
|
@@ -691,7 +676,6 @@ declare const AikitToolCallTerminalPart: Schema.decodeTo<Schema.declare<{
|
|
|
691
676
|
};
|
|
692
677
|
type: "toolCall";
|
|
693
678
|
} | {
|
|
694
|
-
addedToolNames?: string[];
|
|
695
679
|
arguments: Record<string, any>;
|
|
696
680
|
callID: string;
|
|
697
681
|
name: string;
|
|
@@ -717,7 +701,6 @@ declare const AikitToolCallTerminalPart: Schema.decodeTo<Schema.declare<{
|
|
|
717
701
|
};
|
|
718
702
|
type: "toolCall";
|
|
719
703
|
}, {
|
|
720
|
-
addedToolNames?: string[];
|
|
721
704
|
arguments: Record<string, any>;
|
|
722
705
|
callID: string;
|
|
723
706
|
name: string;
|
|
@@ -743,7 +726,6 @@ declare const AikitToolCallTerminalPart: Schema.decodeTo<Schema.declare<{
|
|
|
743
726
|
};
|
|
744
727
|
type: "toolCall";
|
|
745
728
|
} | {
|
|
746
|
-
addedToolNames?: string[];
|
|
747
729
|
arguments: Record<string, any>;
|
|
748
730
|
callID: string;
|
|
749
731
|
name: string;
|
|
@@ -769,7 +751,6 @@ declare const AikitToolCallTerminalPart: Schema.decodeTo<Schema.declare<{
|
|
|
769
751
|
};
|
|
770
752
|
type: "toolCall";
|
|
771
753
|
} | {
|
|
772
|
-
addedToolNames?: string[];
|
|
773
754
|
arguments: Record<string, any>;
|
|
774
755
|
callID: string;
|
|
775
756
|
name: string;
|
|
@@ -795,7 +776,6 @@ declare const AikitToolCallTerminalPart: Schema.decodeTo<Schema.declare<{
|
|
|
795
776
|
};
|
|
796
777
|
type: "toolCall";
|
|
797
778
|
} | {
|
|
798
|
-
addedToolNames?: string[];
|
|
799
779
|
arguments: Record<string, any>;
|
|
800
780
|
callID: string;
|
|
801
781
|
name: string;
|
|
@@ -896,4 +876,4 @@ declare function durable<const Definitions extends ReadonlyArray<Definition>>(de
|
|
|
896
876
|
declare function latest(definitions: ReadonlyArray<Definition>): ReadonlyMap<string, Definition<string, Schema.Codec<unknown, unknown, never, never>>>;
|
|
897
877
|
//#endregion
|
|
898
878
|
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-
|
|
879
|
+
//# sourceMappingURL=event-C6-oCzlq.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-C6-oCzlq.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
|
-
import {
|
|
3
|
-
import { t as plugin_d_exports } from "./plugin-
|
|
2
|
+
import { v as tool_d_exports } from "./tool-BRTCmPch.mjs";
|
|
3
|
+
import { t as plugin_d_exports } from "./plugin-ZmFbf49i.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.3.0-canary.
|
|
3
|
+
"version": "0.3.0-canary.69.1.g5be1ef81",
|
|
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.12.1-canary.
|
|
171
|
+
"@codeworksh/aikit": "0.12.1-canary.69.1.g5be1ef81",
|
|
172
172
|
"effect": "4.0.5"
|
|
173
173
|
}
|
|
174
174
|
}
|
package/plugin/tool.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ToolAfterResult, c as ToolBeforeResult, d as ToolRegistry, f as ToolResultContent, i as ToolAfterFn, l as ToolDefPatch, n as ToolAddOptions, o as ToolBefore, r as ToolAfter, s as ToolBeforeFn, t as HookReturn, u as ToolRegistration } from "../tool-
|
|
1
|
+
import { a as ToolAfterResult, c as ToolBeforeResult, d as ToolRegistry, f as ToolResultContent, i as ToolAfterFn, l as ToolDefPatch, n as ToolAddOptions, o as ToolBefore, r as ToolAfter, s as ToolBeforeFn, t as HookReturn, u as ToolRegistration } from "../tool-B27F3Bhp.mjs";
|
|
2
2
|
export { HookReturn, ToolAddOptions, ToolAfter, ToolAfterFn, ToolAfterResult, ToolBefore, ToolBeforeFn, ToolBeforeResult, ToolDefPatch, ToolRegistration, ToolRegistry, ToolResultContent };
|
|
@@ -1,11 +1,11 @@
|
|
|
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-C6-oCzlq.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-Br9WZTsG.mjs";
|
|
5
5
|
import { i as Info$1 } from "./settings-DGYWREuu.mjs";
|
|
6
6
|
import { t as section_d_exports } from "./plugin/section.mjs";
|
|
7
7
|
import { n as prompt_d_exports, t as PromptRegistry } from "./prompt-DWaA5ZXj.mjs";
|
|
8
|
-
import { d as ToolRegistry, p as tool_d_exports } from "./tool-
|
|
8
|
+
import { d as ToolRegistry, p as tool_d_exports } from "./tool-B27F3Bhp.mjs";
|
|
9
9
|
import { Model } from "@codeworksh/aikit";
|
|
10
10
|
import { Effect } from "effect";
|
|
11
11
|
//#region src/plugin/registry.d.ts
|
|
@@ -155,4 +155,4 @@ declare namespace plugin_d_exports {
|
|
|
155
155
|
}
|
|
156
156
|
//#endregion
|
|
157
157
|
export { PluginRegistry as _, define as a, PluginOptions as c, PluginSpec as d, Config as f, SharedPluginContext as g, PromptResolver as h, PluginKind as i, PluginPatch as l, Paths as m, Mount as n, domains as o, Events as p, Plugin as r, rank as s, plugin_d_exports as t, PluginRef as u };
|
|
158
|
-
//# sourceMappingURL=plugin-
|
|
158
|
+
//# sourceMappingURL=plugin-ZmFbf49i.d.mts.map
|
package/plugin.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as section_d_exports } from "./plugin/section.mjs";
|
|
2
2
|
import { n as prompt_d_exports } from "./prompt-DWaA5ZXj.mjs";
|
|
3
|
-
import { p as tool_d_exports } from "./tool-
|
|
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-
|
|
3
|
+
import { p as tool_d_exports } from "./tool-B27F3Bhp.mjs";
|
|
4
|
+
import { _ as PluginRegistry, a as define, c as PluginOptions, d as PluginSpec, f as Config, g as SharedPluginContext, h as PromptResolver, i as PluginKind, l as PluginPatch, m as Paths, n as Mount, o as domains, p as Events, r as Plugin, s as rank, u as PluginRef } from "./plugin-ZmFbf49i.mjs";
|
|
5
5
|
export { type Config, type Events, type Mount, type Paths, type Plugin, type PluginKind, type PluginOptions, type PluginPatch, type PluginRef, type PluginRegistry, type PluginSpec, prompt_d_exports as Prompt, type PromptResolver, section_d_exports as Section, type SharedPluginContext, tool_d_exports as Tool, define, domains, rank };
|
package/tool/progress.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as noop, S as make, b as ToolProgress, x as ToolProgressPartial, y as IToolProgress } from "../tool-BRTCmPch.mjs";
|
|
2
2
|
export { IToolProgress, ToolProgress, ToolProgressPartial, make, noop };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as RegisteredTool, i as ModelContent, t as AnyToolDef } from "./tool-
|
|
1
|
+
import { a as RegisteredTool, i as ModelContent, t as AnyToolDef } from "./tool-BRTCmPch.mjs";
|
|
2
2
|
import { Effect, Schema } from "effect";
|
|
3
3
|
declare namespace tool_d_exports {
|
|
4
4
|
export { HookReturn, ToolAddOptions, ToolAfter, ToolAfterFn, ToolAfterResult, ToolBefore, ToolBeforeFn, ToolBeforeResult, ToolDefPatch, ToolRegistration, ToolRegistry, ToolResultContent };
|
|
@@ -34,7 +34,6 @@ declare const ToolAfter: Schema.Struct<{
|
|
|
34
34
|
};
|
|
35
35
|
readonly params: Schema.Unknown;
|
|
36
36
|
readonly terminal: Schema.decodeTo<Schema.declare<{
|
|
37
|
-
addedToolNames?: string[];
|
|
38
37
|
arguments: Record<string, any>;
|
|
39
38
|
callID: string;
|
|
40
39
|
name: string;
|
|
@@ -60,7 +59,6 @@ declare const ToolAfter: Schema.Struct<{
|
|
|
60
59
|
};
|
|
61
60
|
type: "toolCall";
|
|
62
61
|
} | {
|
|
63
|
-
addedToolNames?: string[];
|
|
64
62
|
arguments: Record<string, any>;
|
|
65
63
|
callID: string;
|
|
66
64
|
name: string;
|
|
@@ -86,7 +84,6 @@ declare const ToolAfter: Schema.Struct<{
|
|
|
86
84
|
};
|
|
87
85
|
type: "toolCall";
|
|
88
86
|
} | {
|
|
89
|
-
addedToolNames?: string[];
|
|
90
87
|
arguments: Record<string, any>;
|
|
91
88
|
callID: string;
|
|
92
89
|
name: string;
|
|
@@ -112,7 +109,6 @@ declare const ToolAfter: Schema.Struct<{
|
|
|
112
109
|
};
|
|
113
110
|
type: "toolCall";
|
|
114
111
|
} | {
|
|
115
|
-
addedToolNames?: string[];
|
|
116
112
|
arguments: Record<string, any>;
|
|
117
113
|
callID: string;
|
|
118
114
|
name: string;
|
|
@@ -138,7 +134,6 @@ declare const ToolAfter: Schema.Struct<{
|
|
|
138
134
|
};
|
|
139
135
|
type: "toolCall";
|
|
140
136
|
}, {
|
|
141
|
-
addedToolNames?: string[];
|
|
142
137
|
arguments: Record<string, any>;
|
|
143
138
|
callID: string;
|
|
144
139
|
name: string;
|
|
@@ -164,7 +159,6 @@ declare const ToolAfter: Schema.Struct<{
|
|
|
164
159
|
};
|
|
165
160
|
type: "toolCall";
|
|
166
161
|
} | {
|
|
167
|
-
addedToolNames?: string[];
|
|
168
162
|
arguments: Record<string, any>;
|
|
169
163
|
callID: string;
|
|
170
164
|
name: string;
|
|
@@ -190,7 +184,6 @@ declare const ToolAfter: Schema.Struct<{
|
|
|
190
184
|
};
|
|
191
185
|
type: "toolCall";
|
|
192
186
|
} | {
|
|
193
|
-
addedToolNames?: string[];
|
|
194
187
|
arguments: Record<string, any>;
|
|
195
188
|
callID: string;
|
|
196
189
|
name: string;
|
|
@@ -216,7 +209,6 @@ declare const ToolAfter: Schema.Struct<{
|
|
|
216
209
|
};
|
|
217
210
|
type: "toolCall";
|
|
218
211
|
} | {
|
|
219
|
-
addedToolNames?: string[];
|
|
220
212
|
arguments: Record<string, any>;
|
|
221
213
|
callID: string;
|
|
222
214
|
name: string;
|
|
@@ -286,4 +278,4 @@ interface ToolRegistry {
|
|
|
286
278
|
}
|
|
287
279
|
//#endregion
|
|
288
280
|
export { ToolAfterResult as a, ToolBeforeResult as c, ToolRegistry as d, ToolResultContent as f, ToolAfterFn as i, ToolDefPatch as l, ToolAddOptions as n, ToolBefore as o, tool_d_exports as p, ToolAfter as r, ToolBeforeFn as s, HookReturn as t, ToolRegistration as u };
|
|
289
|
-
//# sourceMappingURL=tool-
|
|
281
|
+
//# sourceMappingURL=tool-B27F3Bhp.d.mts.map
|
|
@@ -26,7 +26,7 @@ declare const make$1: (report: IToolProgress["report"]) => Layer.Layer<ToolProgr
|
|
|
26
26
|
/** Drops every update — the default until the executor wires a live event sink. */
|
|
27
27
|
declare const noop: Layer.Layer<ToolProgress>;
|
|
28
28
|
declare namespace tool_d_exports {
|
|
29
|
-
export { AnyToolDef, AnyToolImpl, Handler, ModelContent, RegisteredTool, ToolCallContext, ToolDef, ToolImpl, define, implement, make, provide, register, toAikitTool, toProviderJsonSchema };
|
|
29
|
+
export { AnyToolDef, AnyToolImpl, Handler, ModelContent, RegisteredTool, ToolCallContext, ToolDef, ToolExposure, ToolImpl, declared, define, implement, make, provide, register, toAikitTool, toProviderJsonSchema };
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* The tool definition + handler model.
|
|
@@ -54,6 +54,17 @@ declare const ToolCallContext: Schema.Struct<{
|
|
|
54
54
|
readonly modelInput: Schema.optional<Schema.$Array<Schema.Literals<readonly ["text", "image"]>>>;
|
|
55
55
|
}>;
|
|
56
56
|
type ToolCallContext = typeof ToolCallContext.Type;
|
|
57
|
+
/**
|
|
58
|
+
* Where a tool is reachable. `direct` and `model` tools are declared to the model each turn;
|
|
59
|
+
* `model` ones are never callable from other tools. `codemode` and `deferred` tools stay off the
|
|
60
|
+
* wire until loaded, and `hidden` ones never reach the model.
|
|
61
|
+
*/
|
|
62
|
+
declare const ToolExposure: Schema.Literals<readonly ["direct", "model", "codemode", "deferred", "hidden"]>;
|
|
63
|
+
type ToolExposure = typeof ToolExposure.Type;
|
|
64
|
+
/** Whether a tool is declared to the model every turn. Omitted exposure means `direct`. */
|
|
65
|
+
declare const declared: (def: {
|
|
66
|
+
readonly exposure?: ToolExposure;
|
|
67
|
+
}) => boolean;
|
|
57
68
|
/**
|
|
58
69
|
* A pure tool definition. Parametrised over the *schema* instances so the
|
|
59
70
|
* decoded parameter/success/failure types can be recovered via `["Type"]`.
|
|
@@ -70,6 +81,8 @@ interface ToolDef<Name extends string = string, Params extends Schema.Top = Sche
|
|
|
70
81
|
readonly promptSnippet?: string;
|
|
71
82
|
/** Optional guideline bullets appended to the default system prompt Guidelines section when this tool is active. */
|
|
72
83
|
readonly promptGuidelines?: ReadonlyArray<string>;
|
|
84
|
+
/** Where the tool is reachable. Omit → `direct`. */
|
|
85
|
+
readonly exposure?: ToolExposure;
|
|
73
86
|
/**
|
|
74
87
|
* Repair argument shapes models commonly send before they are validated against
|
|
75
88
|
* `parameters`. Return a copy; a throw makes the arguments invalid.
|
|
@@ -109,6 +122,7 @@ interface DefineInput<Name extends string, Params extends Schema.Top, Success ex
|
|
|
109
122
|
readonly label?: string;
|
|
110
123
|
readonly promptSnippet?: string;
|
|
111
124
|
readonly promptGuidelines?: ReadonlyArray<string>;
|
|
125
|
+
readonly exposure?: ToolExposure;
|
|
112
126
|
readonly prepareArguments?: (args: unknown) => unknown;
|
|
113
127
|
readonly parameters: Params;
|
|
114
128
|
readonly constrainedSampling?: Message.Tool["constrainedSampling"];
|
|
@@ -159,5 +173,5 @@ declare const toProviderJsonSchema: (schema: Schema.Top) => Record<string, unkno
|
|
|
159
173
|
*/
|
|
160
174
|
declare const toAikitTool: (def: AnyToolDef) => Message.Tool;
|
|
161
175
|
//#endregion
|
|
162
|
-
export {
|
|
163
|
-
//# sourceMappingURL=tool-
|
|
176
|
+
export { noop as C, make$1 as S, toProviderJsonSchema as _, RegisteredTool as a, ToolProgress as b, ToolExposure as c, define as d, implement as f, toAikitTool as g, register as h, ModelContent as i, ToolImpl as l, provide as m, AnyToolImpl as n, ToolCallContext as o, make as p, Handler as r, ToolDef as s, AnyToolDef as t, declared as u, tool_d_exports as v, ToolProgressPartial as x, IToolProgress as y };
|
|
177
|
+
//# sourceMappingURL=tool-BRTCmPch.d.mts.map
|
package/tool.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as RegisteredTool, c as
|
|
2
|
-
export { AnyToolDef, AnyToolImpl, Handler, ModelContent, RegisteredTool, ToolCallContext, ToolDef, ToolImpl, define, implement, make, provide, register, toAikitTool, toProviderJsonSchema };
|
|
1
|
+
import { _ as toProviderJsonSchema, a as RegisteredTool, c as ToolExposure, d as define, f as implement, g as toAikitTool, h as register, i as ModelContent, l as ToolImpl, m as provide, n as AnyToolImpl, o as ToolCallContext, p as make, r as Handler, s as ToolDef, t as AnyToolDef, u as declared } from "./tool-BRTCmPch.mjs";
|
|
2
|
+
export { AnyToolDef, AnyToolImpl, Handler, ModelContent, RegisteredTool, ToolCallContext, ToolDef, ToolExposure, ToolImpl, declared, define, implement, make, provide, register, toAikitTool, toProviderJsonSchema };
|
package/tool.mjs
CHANGED
|
@@ -4,6 +4,8 @@ import { Effect, Schema, SchemaAST } from "effect";
|
|
|
4
4
|
//#region src/tool.ts
|
|
5
5
|
var tool_exports = /* @__PURE__ */ __exportAll({
|
|
6
6
|
ToolCallContext: () => ToolCallContext,
|
|
7
|
+
ToolExposure: () => ToolExposure,
|
|
8
|
+
declared: () => declared,
|
|
7
9
|
define: () => define,
|
|
8
10
|
implement: () => implement,
|
|
9
11
|
make: () => make,
|
|
@@ -20,6 +22,20 @@ const ToolCallContext = Schema.Struct({
|
|
|
20
22
|
/** Input modalities of the model the call answers, e.g. `["text", "image"]`. */
|
|
21
23
|
modelInput: Schema.optional(Schema.Array(Schema.Literals(["text", "image"])))
|
|
22
24
|
});
|
|
25
|
+
/**
|
|
26
|
+
* Where a tool is reachable. `direct` and `model` tools are declared to the model each turn;
|
|
27
|
+
* `model` ones are never callable from other tools. `codemode` and `deferred` tools stay off the
|
|
28
|
+
* wire until loaded, and `hidden` ones never reach the model.
|
|
29
|
+
*/
|
|
30
|
+
const ToolExposure = Schema.Literals([
|
|
31
|
+
"direct",
|
|
32
|
+
"model",
|
|
33
|
+
"codemode",
|
|
34
|
+
"deferred",
|
|
35
|
+
"hidden"
|
|
36
|
+
]);
|
|
37
|
+
/** Whether a tool is declared to the model every turn. Omitted exposure means `direct`. */
|
|
38
|
+
const declared = (def) => def.exposure === void 0 || def.exposure === "direct" || def.exposure === "model";
|
|
23
39
|
/** Define a pure tool (handler attached later via {@link implement} or a toolkit). */
|
|
24
40
|
const define = (input) => ({ ...input });
|
|
25
41
|
/** Attach a handler to an existing definition (the testable def/exec split). */
|
|
@@ -77,6 +93,6 @@ const toAikitTool = (def) => ({
|
|
|
77
93
|
...def.constrainedSampling === void 0 ? {} : { constrainedSampling: def.constrainedSampling }
|
|
78
94
|
});
|
|
79
95
|
//#endregion
|
|
80
|
-
export { ToolCallContext, define, implement, make, provide, register, tool_exports as t, toAikitTool, toProviderJsonSchema };
|
|
96
|
+
export { ToolCallContext, ToolExposure, declared, define, implement, make, provide, register, tool_exports as t, toAikitTool, toProviderJsonSchema };
|
|
81
97
|
|
|
82
98
|
//# sourceMappingURL=tool.mjs.map
|
package/tool.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.mjs","names":[],"sources":["../../src/tool.ts"],"sourcesContent":["import type { Message } from \"@codeworksh/aikit\";\nimport { Effect, type Layer, Schema, SchemaAST } from \"effect\";\nimport type { TSchema } from \"typebox\";\nimport { ToolExecutionError } from \"./tool/error.ts\";\nimport type { ToolProgress } from \"./tool/progress.ts\";\n\n/**\n * The tool definition + handler model.\n *\n * A tool definition is pure, serializable data: name, description, and Effect\n * Schema for parameters / success / failure. Execution is a separate `Handler`\n * — an `Effect` whose capability dependencies (e.g. `ToolShell`) live in its\n * requirements `R`, provided by a Layer at runtime. Separating the two is the\n * main testing win: assert on the definition as plain data, and run the handler\n * against a stub capability Layer.\n *\n * Effect Schema is the single source of truth. {@link toAikitTool} derives a\n * provider-safe JSON Schema object for the aikit wire view; the harness\n * decode/encodes arguments and results with Effect Schema natively (it does not\n * use aikit's Typebox validators).\n */\n\n/** What the model reads next turn (the `content` side of content/details). */\nexport type ModelContent = ReadonlyArray<Message.TextContent | Message.ImageContent>;\n\n/** Per-call metadata handed to a handler instead of positional args. */\nexport const ToolCallContext = Schema.Struct({\n\tcallID: Schema.String,\n\ttoolName: Schema.String,\n\trawArgs: Schema.Record(Schema.String, Schema.Unknown),\n\t/** Input modalities of the model the call answers, e.g. `[\"text\", \"image\"]`. */\n\tmodelInput: Schema.optional(Schema.Array(Schema.Literals([\"text\", \"image\"]))),\n});\nexport type ToolCallContext = typeof ToolCallContext.Type;\n\n/**\n * A pure tool definition. Parametrised over the *schema* instances so the\n * decoded parameter/success/failure types can be recovered via `[\"Type\"]`.\n */\nexport interface ToolDef<\n\tName extends string = string,\n\tParams extends Schema.Top = Schema.Top,\n\tSuccess extends Schema.Top = Schema.Top,\n\tFailure extends Schema.Top = Schema.Top,\n> {\n\treadonly name: Name;\n\treadonly description: string;\n\t/** Human-readable display label (kept from the previous `AgentTool`). */\n\treadonly label?: string;\n\t/**\n\t * A short one-line summary for compact tool listings (e.g. a system-prompt tool index),\n\t * distinct from the fuller `description`.\n\t */\n\treadonly promptSnippet?: string;\n\t/** Optional guideline bullets appended to the default system prompt Guidelines section when this tool is active. */\n\treadonly promptGuidelines?: ReadonlyArray<string>;\n\t/**\n\t * Repair argument shapes models commonly send before they are validated against\n\t * `parameters`. Return a copy; a throw makes the arguments invalid.\n\t */\n\treadonly prepareArguments?: (args: unknown) => unknown;\n\treadonly parameters: Params;\n\t/**\n\t * How the provider constrains the generated arguments. `{ type: \"json_schema\", strict: \"prefer\" }` sends\n\t * `parameters` in strict mode where the provider can express it and falls back to non-strict otherwise.\n\t */\n\treadonly constrainedSampling?: Message.Tool[\"constrainedSampling\"];\n\treadonly success: Success;\n\t/** Declared, model-visible failures (typed). Omit for tools that cannot fail expectedly. */\n\treadonly failure?: Failure;\n\t/** Render success for the model. Omit → executor falls back to JSON text. */\n\treadonly encodeContent?: (success: Success[\"Type\"]) => ModelContent;\n\t/** Render an expected failure for the model. Omit → executor falls back to JSON text. */\n\treadonly encodeFailureContent?: (failure: Failure[\"Type\"]) => ModelContent;\n\t/**\n\t * The `details` kept with a success, for UIs and programmatic consumers. Omit → the encoded\n\t * success. Set it when `encodeContent` already carries the payload, so it is not stored twice.\n\t */\n\treadonly encodeDetails?: (success: Success[\"Type\"]) => unknown;\n}\n\n/** A handler: validated params + context → typed success or typed failure. */\nexport type Handler<Params extends Schema.Top, Success extends Schema.Top, Failure extends Schema.Top, R = never> = (\n\tparams: Params[\"Type\"],\n\tctx: ToolCallContext,\n) => Effect.Effect<Success[\"Type\"], Failure[\"Type\"], R>;\n\n/** A definition paired with its handler (the unit the executor runs). */\nexport interface ToolImpl<\n\tName extends string = string,\n\tParams extends Schema.Top = Schema.Top,\n\tSuccess extends Schema.Top = Schema.Top,\n\tFailure extends Schema.Top = Schema.Top,\n\tR = never,\n> {\n\treadonly definition: ToolDef<Name, Params, Success, Failure>;\n\treadonly handler: Handler<Params, Success, Failure, R>;\n}\n\n// Heterogeneous-collection aliases. `any` for the schema generics keeps handlers\n// of differing parameter types assignable into one array (the precise generics\n// live on the authoring helpers below).\n// biome-ignore lint/suspicious/noExplicitAny: erased schema generics for storage\nexport type AnyToolDef = ToolDef<string, any, any, any>;\n// biome-ignore lint/suspicious/noExplicitAny: erased schema generics for storage\nexport type AnyToolImpl<R = never> = ToolImpl<string, any, any, any, R>;\n\ninterface DefineInput<\n\tName extends string,\n\tParams extends Schema.Top,\n\tSuccess extends Schema.Top,\n\tFailure extends Schema.Top,\n> {\n\treadonly name: Name;\n\treadonly description: string;\n\treadonly label?: string;\n\treadonly promptSnippet?: string;\n\treadonly promptGuidelines?: ReadonlyArray<string>;\n\treadonly prepareArguments?: (args: unknown) => unknown;\n\treadonly parameters: Params;\n\treadonly constrainedSampling?: Message.Tool[\"constrainedSampling\"];\n\treadonly success: Success;\n\treadonly failure?: Failure;\n\treadonly encodeContent?: (success: Success[\"Type\"]) => ModelContent;\n\treadonly encodeFailureContent?: (failure: Failure[\"Type\"]) => ModelContent;\n\treadonly encodeDetails?: (success: Success[\"Type\"]) => unknown;\n}\n\n/** Define a pure tool (handler attached later via {@link implement} or a toolkit). */\nexport const define = <\n\tName extends string,\n\tParams extends Schema.Top,\n\tSuccess extends Schema.Top,\n\tFailure extends Schema.Top = Schema.Top,\n>(\n\tinput: DefineInput<Name, Params, Success, Failure>,\n): ToolDef<Name, Params, Success, Failure> => ({\n\t...input,\n});\n\n/** Attach a handler to an existing definition (the testable def/exec split). */\nexport const implement = <\n\tName extends string,\n\tParams extends Schema.Top,\n\tSuccess extends Schema.Top,\n\tFailure extends Schema.Top,\n\tR = never,\n>(\n\tdefinition: ToolDef<Name, Params, Success, Failure>,\n\thandler: Handler<Params, Success, Failure, R>,\n): ToolImpl<Name, Params, Success, Failure, R> => ({ definition, handler });\n\n/** Sugar for the co-located case: a definition with its handler in one object. */\nexport const make = <\n\tName extends string,\n\tParams extends Schema.Top,\n\tSuccess extends Schema.Top,\n\tFailure extends Schema.Top = Schema.Top,\n\tR = never,\n>(\n\tinput: DefineInput<Name, Params, Success, Failure> & {\n\t\treadonly handler: Handler<Params, Success, Failure, R>;\n\t},\n): ToolImpl<Name, Params, Success, Failure, R> => {\n\tconst { handler, ...rest } = input;\n\treturn { definition: define(rest), handler };\n};\n\n/**\n * A tool ready to register: its capability requirements have been discharged, leaving only\n * the executor-provided {@link ToolProgress}. The registry and executor hold `RegisteredTool`s\n * and are non-generic (only `handle` is generic, over a progress sink's `RProgress`), so any\n * number of tools — built-in or\n * third-party/plugin — compose without a shared capability union\n */\nexport interface RegisteredTool {\n\treadonly definition: AnyToolDef;\n\treadonly handler: (\n\t\tparams: unknown,\n\t\tctx: ToolCallContext,\n\t) => Effect.Effect<unknown, ToolExecutionError, ToolProgress>;\n}\n\nconst toRegistered = <\n\tName extends string,\n\tParams extends Schema.Top,\n\tSuccess extends Schema.Top,\n\tFailure extends Schema.Top,\n>(\n\tdefinition: ToolDef<Name, Params, Success, Failure>,\n\thandler: Handler<Params, Success, Failure, ToolProgress>,\n): RegisteredTool => ({\n\tdefinition,\n\t// The executor decodes with `definition.parameters` before invoking this\n\t// erased handler, so restoring the authored parameter type is safe here.\n\thandler: (params, ctx) =>\n\t\thandler(params as Params[\"Type\"], ctx).pipe(\n\t\t\tEffect.mapError((cause) => new ToolExecutionError({ toolName: definition.name, cause })),\n\t\t),\n});\n\n/** Register a tool whose only requirement is the executor-provided progress service. */\nexport const register = <\n\tName extends string,\n\tParams extends Schema.Top,\n\tSuccess extends Schema.Top,\n\tFailure extends Schema.Top,\n>(\n\timpl: ToolImpl<Name, Params, Success, Failure, ToolProgress>,\n): RegisteredTool => toRegistered(impl.definition, impl.handler);\n\n/**\n * Discharge a tool's capability requirements into a {@link RegisteredTool}, erasing its `R`\n * (the executor still provides `ToolProgress`). This is the registration boundary: a\n * plugin/third-party tool provides its own fully-resolved capability Layer here, so the\n * registry never has to unify anyone's `R`.\n */\nexport const provide = <\n\tName extends string,\n\tParams extends Schema.Top,\n\tSuccess extends Schema.Top,\n\tFailure extends Schema.Top,\n\tR,\n>(\n\timpl: ToolImpl<Name, Params, Success, Failure, R | ToolProgress>,\n\tlayer: Layer.Layer<R>,\n): RegisteredTool =>\n\t// `Effect.provide` discharges `R`, leaving `ToolProgress`. TS can't simplify\n\t// `Exclude<ToolProgress, R>` for a generic `R`, so localize the cast before\n\t// crossing the registered-tool boundary.\n\ttoRegistered(impl.definition, ((params, ctx) => impl.handler(params, ctx).pipe(Effect.provide(layer))) as Handler<\n\t\tParams,\n\t\tSuccess,\n\t\tFailure,\n\t\tToolProgress\n\t>);\n\n/**\n * Derive a provider-safe JSON Schema object from an Effect Schema. This is the\n * single boundary that crosses into the provider wire; if a provider rejects a\n * construct, fix it here. Draft-07 inlines the root (no top-level `$ref`).\n */\nexport const toProviderJsonSchema = (schema: Schema.Top): Record<string, unknown> => {\n\t// Effect reads `Struct({})` as TS `{}` (any non-null) and emits `{ not: { type: \"null\" } }`;\n\t// providers require an object, so emit one shaped like a non-empty struct's.\n\tconst encoded = SchemaAST.toEncoded(schema.ast);\n\tif (\n\t\tSchemaAST.isObjects(encoded) &&\n\t\tencoded.propertySignatures.length === 0 &&\n\t\tencoded.indexSignatures.length === 0\n\t) {\n\t\treturn { type: \"object\", properties: {}, additionalProperties: true };\n\t}\n\treturn Schema.toStandardJSONSchemaV1(schema)[\"~standard\"].jsonSchema.input({ target: \"draft-07\" });\n};\n\n/**\n * Build the aikit `Message.Tool` wire view from a definition. The derived JSON\n * Schema object satisfies aikit's `parameters` slot structurally at runtime; the\n * single localized cast keeps aikit untouched (decision 3-A).\n */\nexport const toAikitTool = (def: AnyToolDef): Message.Tool => ({\n\tname: def.name,\n\tdescription: def.description,\n\tparameters: toProviderJsonSchema(def.parameters) as unknown as TSchema,\n\t...(def.constrainedSampling === undefined ? {} : { constrainedSampling: def.constrainedSampling }),\n});\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,MAAa,kBAAkB,OAAO,OAAO;CAC5C,QAAQ,OAAO;CACf,UAAU,OAAO;CACjB,SAAS,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO;;CAEpD,YAAY,OAAO,SAAS,OAAO,MAAM,OAAO,SAAS,CAAC,QAAQ,OAAO,CAAC,CAAC,CAAC;AAC7E,CAAC;;AAiGD,MAAa,UAMZ,WAC8C,EAC9C,GAAG,MACJ;;AAGA,MAAa,aAOZ,YACA,aACkD;CAAE;CAAY;AAAQ;;AAGzE,MAAa,QAOZ,UAGiD;CACjD,MAAM,EAAE,SAAS,GAAG,SAAS;CAC7B,OAAO;EAAE,YAAY,OAAO,IAAI;EAAG;CAAQ;AAC5C;AAiBA,MAAM,gBAML,YACA,aACqB;CACrB;CAGA,UAAU,QAAQ,QACjB,QAAQ,QAA0B,GAAG,CAAC,CAAC,KACtC,OAAO,UAAU,UAAU,IAAI,mBAAmB;EAAE,UAAU,WAAW;EAAM;CAAM,CAAC,CAAC,CACxF;AACF;;AAGA,MAAa,YAMZ,SACoB,aAAa,KAAK,YAAY,KAAK,OAAO;;;;;;;AAQ/D,MAAa,WAOZ,MACA,UAKA,aAAa,KAAK,cAAc,QAAQ,QAAQ,KAAK,QAAQ,QAAQ,GAAG,CAAC,CAAC,KAAK,OAAO,QAAQ,KAAK,CAAC,EAKnG;;;;;;AAOF,MAAa,wBAAwB,WAAgD;CAGpF,MAAM,UAAU,UAAU,UAAU,OAAO,GAAG;CAC9C,IACC,UAAU,UAAU,OAAO,KAC3B,QAAQ,mBAAmB,WAAW,KACtC,QAAQ,gBAAgB,WAAW,GAEnC,OAAO;EAAE,MAAM;EAAU,YAAY,CAAC;EAAG,sBAAsB;CAAK;CAErE,OAAO,OAAO,uBAAuB,MAAM,CAAC,CAAC,YAAY,CAAC,WAAW,MAAM,EAAE,QAAQ,WAAW,CAAC;AAClG;;;;;;AAOA,MAAa,eAAe,SAAmC;CAC9D,MAAM,IAAI;CACV,aAAa,IAAI;CACjB,YAAY,qBAAqB,IAAI,UAAU;CAC/C,GAAI,IAAI,wBAAwB,KAAA,IAAY,CAAC,IAAI,EAAE,qBAAqB,IAAI,oBAAoB;AACjG"}
|
|
1
|
+
{"version":3,"file":"tool.mjs","names":[],"sources":["../../src/tool.ts"],"sourcesContent":["import type { Message } from \"@codeworksh/aikit\";\nimport { Effect, type Layer, Schema, SchemaAST } from \"effect\";\nimport type { TSchema } from \"typebox\";\nimport { ToolExecutionError } from \"./tool/error.ts\";\nimport type { ToolProgress } from \"./tool/progress.ts\";\n\n/**\n * The tool definition + handler model.\n *\n * A tool definition is pure, serializable data: name, description, and Effect\n * Schema for parameters / success / failure. Execution is a separate `Handler`\n * — an `Effect` whose capability dependencies (e.g. `ToolShell`) live in its\n * requirements `R`, provided by a Layer at runtime. Separating the two is the\n * main testing win: assert on the definition as plain data, and run the handler\n * against a stub capability Layer.\n *\n * Effect Schema is the single source of truth. {@link toAikitTool} derives a\n * provider-safe JSON Schema object for the aikit wire view; the harness\n * decode/encodes arguments and results with Effect Schema natively (it does not\n * use aikit's Typebox validators).\n */\n\n/** What the model reads next turn (the `content` side of content/details). */\nexport type ModelContent = ReadonlyArray<Message.TextContent | Message.ImageContent>;\n\n/** Per-call metadata handed to a handler instead of positional args. */\nexport const ToolCallContext = Schema.Struct({\n\tcallID: Schema.String,\n\ttoolName: Schema.String,\n\trawArgs: Schema.Record(Schema.String, Schema.Unknown),\n\t/** Input modalities of the model the call answers, e.g. `[\"text\", \"image\"]`. */\n\tmodelInput: Schema.optional(Schema.Array(Schema.Literals([\"text\", \"image\"]))),\n});\nexport type ToolCallContext = typeof ToolCallContext.Type;\n\n/**\n * Where a tool is reachable. `direct` and `model` tools are declared to the model each turn;\n * `model` ones are never callable from other tools. `codemode` and `deferred` tools stay off the\n * wire until loaded, and `hidden` ones never reach the model.\n */\nexport const ToolExposure = Schema.Literals([\"direct\", \"model\", \"codemode\", \"deferred\", \"hidden\"]);\nexport type ToolExposure = typeof ToolExposure.Type;\n\n/** Whether a tool is declared to the model every turn. Omitted exposure means `direct`. */\nexport const declared = (def: { readonly exposure?: ToolExposure }): boolean =>\n\tdef.exposure === undefined || def.exposure === \"direct\" || def.exposure === \"model\";\n\n/**\n * A pure tool definition. Parametrised over the *schema* instances so the\n * decoded parameter/success/failure types can be recovered via `[\"Type\"]`.\n */\nexport interface ToolDef<\n\tName extends string = string,\n\tParams extends Schema.Top = Schema.Top,\n\tSuccess extends Schema.Top = Schema.Top,\n\tFailure extends Schema.Top = Schema.Top,\n> {\n\treadonly name: Name;\n\treadonly description: string;\n\t/** Human-readable display label (kept from the previous `AgentTool`). */\n\treadonly label?: string;\n\t/**\n\t * A short one-line summary for compact tool listings (e.g. a system-prompt tool index),\n\t * distinct from the fuller `description`.\n\t */\n\treadonly promptSnippet?: string;\n\t/** Optional guideline bullets appended to the default system prompt Guidelines section when this tool is active. */\n\treadonly promptGuidelines?: ReadonlyArray<string>;\n\t/** Where the tool is reachable. Omit → `direct`. */\n\treadonly exposure?: ToolExposure;\n\t/**\n\t * Repair argument shapes models commonly send before they are validated against\n\t * `parameters`. Return a copy; a throw makes the arguments invalid.\n\t */\n\treadonly prepareArguments?: (args: unknown) => unknown;\n\treadonly parameters: Params;\n\t/**\n\t * How the provider constrains the generated arguments. `{ type: \"json_schema\", strict: \"prefer\" }` sends\n\t * `parameters` in strict mode where the provider can express it and falls back to non-strict otherwise.\n\t */\n\treadonly constrainedSampling?: Message.Tool[\"constrainedSampling\"];\n\treadonly success: Success;\n\t/** Declared, model-visible failures (typed). Omit for tools that cannot fail expectedly. */\n\treadonly failure?: Failure;\n\t/** Render success for the model. Omit → executor falls back to JSON text. */\n\treadonly encodeContent?: (success: Success[\"Type\"]) => ModelContent;\n\t/** Render an expected failure for the model. Omit → executor falls back to JSON text. */\n\treadonly encodeFailureContent?: (failure: Failure[\"Type\"]) => ModelContent;\n\t/**\n\t * The `details` kept with a success, for UIs and programmatic consumers. Omit → the encoded\n\t * success. Set it when `encodeContent` already carries the payload, so it is not stored twice.\n\t */\n\treadonly encodeDetails?: (success: Success[\"Type\"]) => unknown;\n}\n\n/** A handler: validated params + context → typed success or typed failure. */\nexport type Handler<Params extends Schema.Top, Success extends Schema.Top, Failure extends Schema.Top, R = never> = (\n\tparams: Params[\"Type\"],\n\tctx: ToolCallContext,\n) => Effect.Effect<Success[\"Type\"], Failure[\"Type\"], R>;\n\n/** A definition paired with its handler (the unit the executor runs). */\nexport interface ToolImpl<\n\tName extends string = string,\n\tParams extends Schema.Top = Schema.Top,\n\tSuccess extends Schema.Top = Schema.Top,\n\tFailure extends Schema.Top = Schema.Top,\n\tR = never,\n> {\n\treadonly definition: ToolDef<Name, Params, Success, Failure>;\n\treadonly handler: Handler<Params, Success, Failure, R>;\n}\n\n// Heterogeneous-collection aliases. `any` for the schema generics keeps handlers\n// of differing parameter types assignable into one array (the precise generics\n// live on the authoring helpers below).\n// biome-ignore lint/suspicious/noExplicitAny: erased schema generics for storage\nexport type AnyToolDef = ToolDef<string, any, any, any>;\n// biome-ignore lint/suspicious/noExplicitAny: erased schema generics for storage\nexport type AnyToolImpl<R = never> = ToolImpl<string, any, any, any, R>;\n\ninterface DefineInput<\n\tName extends string,\n\tParams extends Schema.Top,\n\tSuccess extends Schema.Top,\n\tFailure extends Schema.Top,\n> {\n\treadonly name: Name;\n\treadonly description: string;\n\treadonly label?: string;\n\treadonly promptSnippet?: string;\n\treadonly promptGuidelines?: ReadonlyArray<string>;\n\treadonly exposure?: ToolExposure;\n\treadonly prepareArguments?: (args: unknown) => unknown;\n\treadonly parameters: Params;\n\treadonly constrainedSampling?: Message.Tool[\"constrainedSampling\"];\n\treadonly success: Success;\n\treadonly failure?: Failure;\n\treadonly encodeContent?: (success: Success[\"Type\"]) => ModelContent;\n\treadonly encodeFailureContent?: (failure: Failure[\"Type\"]) => ModelContent;\n\treadonly encodeDetails?: (success: Success[\"Type\"]) => unknown;\n}\n\n/** Define a pure tool (handler attached later via {@link implement} or a toolkit). */\nexport const define = <\n\tName extends string,\n\tParams extends Schema.Top,\n\tSuccess extends Schema.Top,\n\tFailure extends Schema.Top = Schema.Top,\n>(\n\tinput: DefineInput<Name, Params, Success, Failure>,\n): ToolDef<Name, Params, Success, Failure> => ({\n\t...input,\n});\n\n/** Attach a handler to an existing definition (the testable def/exec split). */\nexport const implement = <\n\tName extends string,\n\tParams extends Schema.Top,\n\tSuccess extends Schema.Top,\n\tFailure extends Schema.Top,\n\tR = never,\n>(\n\tdefinition: ToolDef<Name, Params, Success, Failure>,\n\thandler: Handler<Params, Success, Failure, R>,\n): ToolImpl<Name, Params, Success, Failure, R> => ({ definition, handler });\n\n/** Sugar for the co-located case: a definition with its handler in one object. */\nexport const make = <\n\tName extends string,\n\tParams extends Schema.Top,\n\tSuccess extends Schema.Top,\n\tFailure extends Schema.Top = Schema.Top,\n\tR = never,\n>(\n\tinput: DefineInput<Name, Params, Success, Failure> & {\n\t\treadonly handler: Handler<Params, Success, Failure, R>;\n\t},\n): ToolImpl<Name, Params, Success, Failure, R> => {\n\tconst { handler, ...rest } = input;\n\treturn { definition: define(rest), handler };\n};\n\n/**\n * A tool ready to register: its capability requirements have been discharged, leaving only\n * the executor-provided {@link ToolProgress}. The registry and executor hold `RegisteredTool`s\n * and are non-generic (only `handle` is generic, over a progress sink's `RProgress`), so any\n * number of tools — built-in or\n * third-party/plugin — compose without a shared capability union\n */\nexport interface RegisteredTool {\n\treadonly definition: AnyToolDef;\n\treadonly handler: (\n\t\tparams: unknown,\n\t\tctx: ToolCallContext,\n\t) => Effect.Effect<unknown, ToolExecutionError, ToolProgress>;\n}\n\nconst toRegistered = <\n\tName extends string,\n\tParams extends Schema.Top,\n\tSuccess extends Schema.Top,\n\tFailure extends Schema.Top,\n>(\n\tdefinition: ToolDef<Name, Params, Success, Failure>,\n\thandler: Handler<Params, Success, Failure, ToolProgress>,\n): RegisteredTool => ({\n\tdefinition,\n\t// The executor decodes with `definition.parameters` before invoking this\n\t// erased handler, so restoring the authored parameter type is safe here.\n\thandler: (params, ctx) =>\n\t\thandler(params as Params[\"Type\"], ctx).pipe(\n\t\t\tEffect.mapError((cause) => new ToolExecutionError({ toolName: definition.name, cause })),\n\t\t),\n});\n\n/** Register a tool whose only requirement is the executor-provided progress service. */\nexport const register = <\n\tName extends string,\n\tParams extends Schema.Top,\n\tSuccess extends Schema.Top,\n\tFailure extends Schema.Top,\n>(\n\timpl: ToolImpl<Name, Params, Success, Failure, ToolProgress>,\n): RegisteredTool => toRegistered(impl.definition, impl.handler);\n\n/**\n * Discharge a tool's capability requirements into a {@link RegisteredTool}, erasing its `R`\n * (the executor still provides `ToolProgress`). This is the registration boundary: a\n * plugin/third-party tool provides its own fully-resolved capability Layer here, so the\n * registry never has to unify anyone's `R`.\n */\nexport const provide = <\n\tName extends string,\n\tParams extends Schema.Top,\n\tSuccess extends Schema.Top,\n\tFailure extends Schema.Top,\n\tR,\n>(\n\timpl: ToolImpl<Name, Params, Success, Failure, R | ToolProgress>,\n\tlayer: Layer.Layer<R>,\n): RegisteredTool =>\n\t// `Effect.provide` discharges `R`, leaving `ToolProgress`. TS can't simplify\n\t// `Exclude<ToolProgress, R>` for a generic `R`, so localize the cast before\n\t// crossing the registered-tool boundary.\n\ttoRegistered(impl.definition, ((params, ctx) => impl.handler(params, ctx).pipe(Effect.provide(layer))) as Handler<\n\t\tParams,\n\t\tSuccess,\n\t\tFailure,\n\t\tToolProgress\n\t>);\n\n/**\n * Derive a provider-safe JSON Schema object from an Effect Schema. This is the\n * single boundary that crosses into the provider wire; if a provider rejects a\n * construct, fix it here. Draft-07 inlines the root (no top-level `$ref`).\n */\nexport const toProviderJsonSchema = (schema: Schema.Top): Record<string, unknown> => {\n\t// Effect reads `Struct({})` as TS `{}` (any non-null) and emits `{ not: { type: \"null\" } }`;\n\t// providers require an object, so emit one shaped like a non-empty struct's.\n\tconst encoded = SchemaAST.toEncoded(schema.ast);\n\tif (\n\t\tSchemaAST.isObjects(encoded) &&\n\t\tencoded.propertySignatures.length === 0 &&\n\t\tencoded.indexSignatures.length === 0\n\t) {\n\t\treturn { type: \"object\", properties: {}, additionalProperties: true };\n\t}\n\treturn Schema.toStandardJSONSchemaV1(schema)[\"~standard\"].jsonSchema.input({ target: \"draft-07\" });\n};\n\n/**\n * Build the aikit `Message.Tool` wire view from a definition. The derived JSON\n * Schema object satisfies aikit's `parameters` slot structurally at runtime; the\n * single localized cast keeps aikit untouched (decision 3-A).\n */\nexport const toAikitTool = (def: AnyToolDef): Message.Tool => ({\n\tname: def.name,\n\tdescription: def.description,\n\tparameters: toProviderJsonSchema(def.parameters) as unknown as TSchema,\n\t...(def.constrainedSampling === undefined ? {} : { constrainedSampling: def.constrainedSampling }),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AA0BA,MAAa,kBAAkB,OAAO,OAAO;CAC5C,QAAQ,OAAO;CACf,UAAU,OAAO;CACjB,SAAS,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO;;CAEpD,YAAY,OAAO,SAAS,OAAO,MAAM,OAAO,SAAS,CAAC,QAAQ,OAAO,CAAC,CAAC,CAAC;AAC7E,CAAC;;;;;;AAQD,MAAa,eAAe,OAAO,SAAS;CAAC;CAAU;CAAS;CAAY;CAAY;AAAQ,CAAC;;AAIjG,MAAa,YAAY,QACxB,IAAI,aAAa,KAAA,KAAa,IAAI,aAAa,YAAY,IAAI,aAAa;;AAmG7E,MAAa,UAMZ,WAC8C,EAC9C,GAAG,MACJ;;AAGA,MAAa,aAOZ,YACA,aACkD;CAAE;CAAY;AAAQ;;AAGzE,MAAa,QAOZ,UAGiD;CACjD,MAAM,EAAE,SAAS,GAAG,SAAS;CAC7B,OAAO;EAAE,YAAY,OAAO,IAAI;EAAG;CAAQ;AAC5C;AAiBA,MAAM,gBAML,YACA,aACqB;CACrB;CAGA,UAAU,QAAQ,QACjB,QAAQ,QAA0B,GAAG,CAAC,CAAC,KACtC,OAAO,UAAU,UAAU,IAAI,mBAAmB;EAAE,UAAU,WAAW;EAAM;CAAM,CAAC,CAAC,CACxF;AACF;;AAGA,MAAa,YAMZ,SACoB,aAAa,KAAK,YAAY,KAAK,OAAO;;;;;;;AAQ/D,MAAa,WAOZ,MACA,UAKA,aAAa,KAAK,cAAc,QAAQ,QAAQ,KAAK,QAAQ,QAAQ,GAAG,CAAC,CAAC,KAAK,OAAO,QAAQ,KAAK,CAAC,EAKnG;;;;;;AAOF,MAAa,wBAAwB,WAAgD;CAGpF,MAAM,UAAU,UAAU,UAAU,OAAO,GAAG;CAC9C,IACC,UAAU,UAAU,OAAO,KAC3B,QAAQ,mBAAmB,WAAW,KACtC,QAAQ,gBAAgB,WAAW,GAEnC,OAAO;EAAE,MAAM;EAAU,YAAY,CAAC;EAAG,sBAAsB;CAAK;CAErE,OAAO,OAAO,uBAAuB,MAAM,CAAC,CAAC,YAAY,CAAC,WAAW,MAAM,EAAE,QAAQ,WAAW,CAAC;AAClG;;;;;;AAOA,MAAa,eAAe,SAAmC;CAC9D,MAAM,IAAI;CACV,aAAa,IAAI;CACjB,YAAY,qBAAqB,IAAI,UAAU;CAC/C,GAAI,IAAI,wBAAwB,KAAA,IAAY,CAAC,IAAI,EAAE,qBAAqB,IAAI,oBAAoB;AACjG"}
|