@arcforge/types 2.0.59 → 2.0.63
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/package.json +1 -1
- package/src/define.ts +45 -0
package/package.json
CHANGED
package/src/define.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { AxonConfig } from "./config"
|
|
2
2
|
import type { BenchConfig, BenchDefinition } from "./bench"
|
|
3
3
|
import type { ModuleConfig, ModuleOptionSchema } from "./module"
|
|
4
|
+
import type { AxonPlugin } from "./plugin"
|
|
5
|
+
import type { AxonHandle } from "./handle"
|
|
4
6
|
|
|
5
7
|
/** Return shape produced by `defineAgent()`. */
|
|
6
8
|
export type AgentDefinition<EventMap extends Record<string, unknown> = Record<string, unknown>> = {
|
|
@@ -182,3 +184,46 @@ export function defineArgs<T extends Record<string, unknown>>(): T {
|
|
|
182
184
|
export function defineProps<T extends Record<string, unknown>>(): T {
|
|
183
185
|
return (globalThis as any).__axon_skill_props__ as T
|
|
184
186
|
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Registers a boot-time server plugin.
|
|
190
|
+
*
|
|
191
|
+
* Use this as the default export from `server/plugins/*.ts`. The callback runs
|
|
192
|
+
* once, after middleware and before routes are mounted, and receives the live
|
|
193
|
+
* `axon` handle to subscribe to hooks and wire behavior. A throwing plugin
|
|
194
|
+
* aborts boot — plugin failure is always fatal.
|
|
195
|
+
*
|
|
196
|
+
* ```ts
|
|
197
|
+
* export default defineAxonPlugin(async (axon) => {
|
|
198
|
+
* axon.hooks.on("telegram:message", async ({ text, reply }) => {
|
|
199
|
+
* const result = await axon.request({ prompt: text })
|
|
200
|
+
* await reply(result.text)
|
|
201
|
+
* })
|
|
202
|
+
* })
|
|
203
|
+
* ```
|
|
204
|
+
*
|
|
205
|
+
* @see https://axon.arclabs.it/docs/v2/agent/server
|
|
206
|
+
*/
|
|
207
|
+
export function defineAxonPlugin(fn: (axon: AxonHandle) => void | Promise<void>): AxonPlugin {
|
|
208
|
+
return { name: fn.name || "plugin", fn: () => fn((globalThis as any).axon as AxonHandle) }
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Handle returned by the test-runtime spawner `Axon()`. */
|
|
212
|
+
export type AxonTestHandle = {
|
|
213
|
+
axon: AxonHandle
|
|
214
|
+
stop: () => Promise<void>
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Boots a full Axon runtime for integration testing. Global in test files — no
|
|
219
|
+
* import needed. The runtime is torn down by calling `stop()`.
|
|
220
|
+
*
|
|
221
|
+
* ```ts
|
|
222
|
+
* const { axon, stop } = await Axon()
|
|
223
|
+
* const result = await axon.request("hello")
|
|
224
|
+
* await stop()
|
|
225
|
+
* ```
|
|
226
|
+
*
|
|
227
|
+
* @see https://axon.arclabs.it/docs/v2/agent/testing
|
|
228
|
+
*/
|
|
229
|
+
export type AxonTest = () => Promise<AxonTestHandle>
|