@fragno-dev/pi-fragment 0.0.1 → 0.0.3
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 +39 -3
- package/dist/browser/client/react.d.ts +44 -36
- package/dist/browser/client/react.d.ts.map +1 -1
- package/dist/browser/client/react.js +105 -22
- package/dist/browser/client/react.js.map +1 -1
- package/dist/browser/client/solid.d.ts +42 -36
- package/dist/browser/client/solid.d.ts.map +1 -1
- package/dist/browser/client/solid.js +27 -13
- package/dist/browser/client/solid.js.map +1 -1
- package/dist/browser/client/svelte.d.ts +42 -36
- package/dist/browser/client/svelte.d.ts.map +1 -1
- package/dist/browser/client/svelte.js +14 -6
- package/dist/browser/client/svelte.js.map +1 -1
- package/dist/browser/client/vanilla.d.ts +99 -39
- package/dist/browser/client/vanilla.d.ts.map +1 -1
- package/dist/browser/client/vanilla.js +151 -3
- package/dist/browser/client/vanilla.js.map +1 -1
- package/dist/browser/client/vue.d.ts +54 -38
- package/dist/browser/client/vue.d.ts.map +1 -1
- package/dist/browser/client/vue.js +25 -17
- package/dist/browser/client/vue.js.map +1 -1
- package/dist/browser/{factory-DKoO_lRA.js → clients-BscY_HVe.js} +1051 -799
- package/dist/browser/clients-BscY_HVe.js.map +1 -0
- package/dist/browser/index.d.ts +3 -776
- package/dist/browser/index.js +801 -2
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/routes-CpL_YGWK.d.ts +1560 -0
- package/dist/browser/routes-CpL_YGWK.d.ts.map +1 -0
- package/dist/cli/mod.d.ts.map +1 -1
- package/dist/cli/mod.js +245 -7
- package/dist/cli/mod.js.map +1 -1
- package/dist/node/{pi → client}/clients.d.ts +46 -36
- package/dist/node/client/clients.d.ts.map +1 -0
- package/dist/node/client/clients.js +54 -0
- package/dist/node/client/clients.js.map +1 -0
- package/dist/node/client/session-controller.d.ts +31 -0
- package/dist/node/client/session-controller.d.ts.map +1 -0
- package/dist/node/client/session-controller.js +33 -0
- package/dist/node/client/session-controller.js.map +1 -0
- package/dist/node/client/session-store.d.ts +71 -0
- package/dist/node/client/session-store.d.ts.map +1 -0
- package/dist/node/client/session-store.js +637 -0
- package/dist/node/client/session-store.js.map +1 -0
- package/dist/node/debug-log.d.ts +9 -0
- package/dist/node/debug-log.d.ts.map +1 -0
- package/dist/node/debug-log.js +58 -0
- package/dist/node/debug-log.js.map +1 -0
- package/dist/node/index.d.ts +5 -4
- package/dist/node/index.js +5 -3
- package/dist/node/pi/definition.d.ts +1 -1
- package/dist/node/pi/definition.d.ts.map +1 -1
- package/dist/node/pi/dsl.d.ts +5 -2
- package/dist/node/pi/dsl.d.ts.map +1 -1
- package/dist/node/pi/dsl.js +22 -3
- package/dist/node/pi/dsl.js.map +1 -1
- package/dist/node/pi/factory.d.ts +37 -34
- package/dist/node/pi/factory.d.ts.map +1 -1
- package/dist/node/pi/factory.js.map +1 -1
- package/dist/node/pi/mappers.js +0 -1
- package/dist/node/pi/mappers.js.map +1 -1
- package/dist/node/pi/route-schemas.js +42 -10
- package/dist/node/pi/route-schemas.js.map +1 -1
- package/dist/node/pi/types.d.ts +155 -7
- package/dist/node/pi/types.d.ts.map +1 -1
- package/dist/node/pi/types.js +6 -0
- package/dist/node/pi/types.js.map +1 -0
- package/dist/node/pi/workflow/active-session.d.ts +2 -0
- package/dist/node/pi/workflow/active-session.js +107 -0
- package/dist/node/pi/workflow/active-session.js.map +1 -0
- package/dist/node/pi/workflow/agent-runner.d.ts +13 -0
- package/dist/node/pi/workflow/agent-runner.d.ts.map +1 -0
- package/dist/node/pi/workflow/agent-runner.js +228 -0
- package/dist/node/pi/workflow/agent-runner.js.map +1 -0
- package/dist/node/pi/workflow/tool-journal.js +157 -0
- package/dist/node/pi/workflow/tool-journal.js.map +1 -0
- package/dist/node/pi/workflow/workflow.d.ts +29 -0
- package/dist/node/pi/workflow/workflow.d.ts.map +1 -0
- package/dist/node/pi/workflow/workflow.js +219 -0
- package/dist/node/pi/workflow/workflow.js.map +1 -0
- package/dist/node/routes.d.ts +38 -35
- package/dist/node/routes.d.ts.map +1 -1
- package/dist/node/routes.js +203 -132
- package/dist/node/routes.js.map +1 -1
- package/dist/node/schema.js +1 -1
- package/dist/node/schema.js.map +1 -1
- package/package.json +30 -29
- package/dist/browser/client-Bk-J98pf.d.ts +0 -679
- package/dist/browser/client-Bk-J98pf.d.ts.map +0 -1
- package/dist/browser/factory-DKoO_lRA.js.map +0 -1
- package/dist/browser/index.d.ts.map +0 -1
- package/dist/node/pi/clients.d.ts.map +0 -1
- package/dist/node/pi/clients.js +0 -18
- package/dist/node/pi/clients.js.map +0 -1
- package/dist/node/pi/workflow.d.ts +0 -31
- package/dist/node/pi/workflow.d.ts.map +0 -1
- package/dist/node/pi/workflow.js +0 -242
- package/dist/node/pi/workflow.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,1560 @@
|
|
|
1
|
+
import { MapStore, ReadableAtom, Store } from "nanostores";
|
|
2
|
+
import * as _fragno_dev_core0 from "@fragno-dev/core";
|
|
3
|
+
import * as zod from "zod";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import * as _fragno_dev_workflows0 from "@fragno-dev/workflows";
|
|
6
|
+
import { InstanceStatus, WorkflowsFragmentServices, WorkflowsHistoryStep } from "@fragno-dev/workflows";
|
|
7
|
+
import * as _fragno_dev_db_schema0 from "@fragno-dev/db/schema";
|
|
8
|
+
import * as _mariozechner_pi_agent_core0 from "@mariozechner/pi-agent-core";
|
|
9
|
+
import { AgentEvent, AgentMessage, AgentOptions, AgentTool, StreamFn, ThinkingLevel } from "@mariozechner/pi-agent-core";
|
|
10
|
+
import * as zod_v4_core0 from "zod/v4/core";
|
|
11
|
+
import * as _standard_schema_spec0 from "@standard-schema/spec";
|
|
12
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
13
|
+
import * as _fragno_dev_db0 from "@fragno-dev/db";
|
|
14
|
+
import { FragnoPublicConfigWithDatabase, TxResult } from "@fragno-dev/db";
|
|
15
|
+
import { Api, ImageContent, Model, TextContent } from "@mariozechner/pi-ai";
|
|
16
|
+
import * as _fragno_dev_db_fragment_definition_builder0 from "@fragno-dev/db/fragment-definition-builder";
|
|
17
|
+
|
|
18
|
+
//#region ../fragno/dist/api/internal/path.d.ts
|
|
19
|
+
//#region src/api/internal/path.d.ts
|
|
20
|
+
type SplitPath<T extends string> = T extends `${infer First}/${infer Rest}` ? First extends "" ? SplitPath<Rest> : [First, ...SplitPath<Rest>] : T extends "" ? [] : [T];
|
|
21
|
+
type ExtractParam<T extends string> = T extends `:${infer Name}` ? Name : T extends `**:${infer Name}` ? Name : T extends "**" ? "**" : never;
|
|
22
|
+
type ExtractParamsFromSegments<T extends readonly string[]> = T extends readonly [infer First, ...infer Rest] ? First extends string ? Rest extends readonly string[] ? ExtractParam<First> | ExtractParamsFromSegments<Rest> : ExtractParam<First> : never : never;
|
|
23
|
+
/**
|
|
24
|
+
* Type helper to extract path parameters from a const string path
|
|
25
|
+
*
|
|
26
|
+
* Supports:
|
|
27
|
+
* - Regular paths: "/path" -> never
|
|
28
|
+
* - Named parameters: "/path/:name" -> "name"
|
|
29
|
+
* - Wildcard paths: "/path/foo/**" -> "**"
|
|
30
|
+
* - Named wildcard paths: "/path/foo/**:name" -> "name"
|
|
31
|
+
* - String (narrows): string -> never
|
|
32
|
+
*/
|
|
33
|
+
type ExtractPathParams<T extends string, ValueType = string> = ExtractParamsFromSegments<SplitPath<T>> extends never ? Record<string, never> : Record<ExtractParamsFromSegments<SplitPath<T>>, ValueType>;
|
|
34
|
+
/**
|
|
35
|
+
* Same as @see ExtractPathParams, but returns `Record<string, ValueType>` when a string is
|
|
36
|
+
* passed in.
|
|
37
|
+
*/
|
|
38
|
+
type ExtractPathParamsOrWiden<T extends string, ValueType = string> = string extends T ? Record<string, ValueType> : ExtractPathParams<T, ValueType>;
|
|
39
|
+
/**
|
|
40
|
+
* Same as @see ExtractPathParamsOrWiden, but returns `undefined` when no path parameters in the
|
|
41
|
+
* const.
|
|
42
|
+
*/
|
|
43
|
+
type MaybeExtractPathParamsOrWiden<T extends string, ValueType = string> = HasPathParams<T> extends true ? ExtractPathParamsOrWiden<T, ValueType> : undefined;
|
|
44
|
+
type ExtractPathParamNames<T extends string> = ExtractParamsFromSegments<SplitPath<T>>;
|
|
45
|
+
type HasPathParams<T extends string> = ExtractPathParamNames<T> extends never ? false : true;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a query parameters type where the specified keys are hints (optional)
|
|
48
|
+
* and additional string keys are also allowed.
|
|
49
|
+
*
|
|
50
|
+
* This allows for flexible query parameter typing where:
|
|
51
|
+
* - All hinted parameters are optional
|
|
52
|
+
* - Additional parameters beyond the hints are allowed
|
|
53
|
+
* - Values can be of any specified type (defaults to string)
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* type MyQuery = QueryParamsHint<"page" | "limit", string>;
|
|
58
|
+
* // Allows: { page?: string, limit?: string, [key: string]: string }
|
|
59
|
+
*
|
|
60
|
+
* const query1: MyQuery = {}; // Valid - no params required
|
|
61
|
+
* const query2: MyQuery = { page: "1" }; // Valid - hinted param
|
|
62
|
+
* const query3: MyQuery = { page: "1", sort: "asc" }; // Valid - additional param
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
type QueryParamsHint<TQueryParameters extends string, ValueType = string> = Partial<Record<TQueryParameters, ValueType>> & Record<string, ValueType | undefined>; //#endregion
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region ../fragno/dist/util/types-util.d.ts
|
|
68
|
+
//#region src/util/types-util.d.ts
|
|
69
|
+
type InferOr<T, U> = T extends NonNullable<StandardSchemaV1> ? StandardSchemaV1.InferOutput<T> : T extends undefined ? U : U;
|
|
70
|
+
type InferOrUnknown<T> = InferOr<T, unknown>; //#endregion
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region ../fragno/dist/http/http-status.d.ts
|
|
73
|
+
//#region src/http/http-status.d.ts
|
|
74
|
+
/**
|
|
75
|
+
* @module
|
|
76
|
+
* HTTP Status utility.
|
|
77
|
+
*
|
|
78
|
+
* Modified from honojs/hono
|
|
79
|
+
* Original source: https://github.com/honojs/hono/blob/0e3db674ad3f40be215a55a18062dd8e387ce525/src/utils/http-status.ts
|
|
80
|
+
* License: MIT
|
|
81
|
+
* Date obtained: August 28 2025
|
|
82
|
+
* Copyright (c) 2021-present Yusuke Wada and Hono contributors
|
|
83
|
+
*
|
|
84
|
+
*/
|
|
85
|
+
type InfoStatusCode = 100 | 101 | 102 | 103;
|
|
86
|
+
type SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;
|
|
87
|
+
type DeprecatedStatusCode = 305 | 306;
|
|
88
|
+
type RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;
|
|
89
|
+
type ClientErrorStatusCode = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451;
|
|
90
|
+
type ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
|
|
91
|
+
/**
|
|
92
|
+
* If you want to use an unofficial status, use `UnofficialStatusCode`.
|
|
93
|
+
*/
|
|
94
|
+
type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode;
|
|
95
|
+
type ContentlessStatusCode = 101 | 204 | 205 | 304; //#endregion
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region ../fragno/dist/client/client-error.d.ts
|
|
98
|
+
//#region src/client/client-error.d.ts
|
|
99
|
+
type FragnoErrorOptions = {
|
|
100
|
+
cause?: Error | unknown;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Base error class for all Fragno client errors.
|
|
104
|
+
*/
|
|
105
|
+
declare abstract class FragnoClientError<TCode extends string = string> extends Error {
|
|
106
|
+
#private;
|
|
107
|
+
constructor(message: string, code: TCode, options?: FragnoErrorOptions);
|
|
108
|
+
get code(): TCode | (string & {});
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region ../fragno/dist/api/mutable-request-state.d.ts
|
|
112
|
+
//#region src/api/mutable-request-state.d.ts
|
|
113
|
+
/**
|
|
114
|
+
* Holds mutable request state that can be modified by middleware and consumed by handlers.
|
|
115
|
+
*
|
|
116
|
+
* This class provides a structural way for middleware to modify request data:
|
|
117
|
+
* - Path parameters can be modified
|
|
118
|
+
* - Query/search parameters can be modified
|
|
119
|
+
* - Request body can be overridden
|
|
120
|
+
* - Request headers can be modified
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* // In middleware
|
|
125
|
+
* const state = new MutableRequestState({
|
|
126
|
+
* pathParams: { id: "123" },
|
|
127
|
+
* searchParams: new URLSearchParams("?role=user"),
|
|
128
|
+
* body: { name: "John" },
|
|
129
|
+
* headers: new Headers()
|
|
130
|
+
* });
|
|
131
|
+
*
|
|
132
|
+
* // Modify query parameters
|
|
133
|
+
* state.searchParams.set("role", "admin");
|
|
134
|
+
*
|
|
135
|
+
* // Override body
|
|
136
|
+
* state.setBody({ name: "Jane" });
|
|
137
|
+
*
|
|
138
|
+
* // Modify headers
|
|
139
|
+
* state.headers.set("X-Custom", "value");
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
declare class MutableRequestState {
|
|
143
|
+
#private;
|
|
144
|
+
constructor(config: {
|
|
145
|
+
pathParams: Record<string, string>;
|
|
146
|
+
searchParams: URLSearchParams;
|
|
147
|
+
body: RequestBodyType;
|
|
148
|
+
headers: Headers;
|
|
149
|
+
});
|
|
150
|
+
/**
|
|
151
|
+
* Path parameters extracted from the route.
|
|
152
|
+
* Can be modified directly (e.g., `state.pathParams.id = "456"`).
|
|
153
|
+
*/
|
|
154
|
+
get pathParams(): Record<string, string>;
|
|
155
|
+
/**
|
|
156
|
+
* URLSearchParams for query parameters.
|
|
157
|
+
* Can be modified using URLSearchParams API (e.g., `state.searchParams.set("key", "value")`).
|
|
158
|
+
*/
|
|
159
|
+
get searchParams(): URLSearchParams;
|
|
160
|
+
/**
|
|
161
|
+
* Request headers.
|
|
162
|
+
* Can be modified using Headers API (e.g., `state.headers.set("X-Custom", "value")`).
|
|
163
|
+
*/
|
|
164
|
+
get headers(): Headers;
|
|
165
|
+
/**
|
|
166
|
+
* Get the current body value.
|
|
167
|
+
* Returns the override if set, otherwise the initial body.
|
|
168
|
+
*/
|
|
169
|
+
get body(): RequestBodyType;
|
|
170
|
+
/**
|
|
171
|
+
* Override the request body.
|
|
172
|
+
* This allows middleware to replace the body that will be seen by the handler.
|
|
173
|
+
*
|
|
174
|
+
* @param body - The new body value
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* // In middleware
|
|
179
|
+
* state.setBody({ modifiedField: "new value" });
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
setBody(body: RequestBodyType): void;
|
|
183
|
+
/**
|
|
184
|
+
* Check if the body has been overridden by middleware.
|
|
185
|
+
*/
|
|
186
|
+
get hasBodyOverride(): boolean;
|
|
187
|
+
} //#endregion
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region ../fragno/dist/api/request-input-context.d.ts
|
|
190
|
+
//#region src/api/request-input-context.d.ts
|
|
191
|
+
type RequestBodyType = unknown | FormData | Blob | ReadableStream<Uint8Array> | null | undefined;
|
|
192
|
+
declare class RequestInputContext<TPath extends string = string, TInputSchema extends StandardSchemaV1 | undefined = undefined> {
|
|
193
|
+
#private;
|
|
194
|
+
constructor(config: {
|
|
195
|
+
path: TPath;
|
|
196
|
+
method: string;
|
|
197
|
+
pathParams: ExtractPathParams<TPath>;
|
|
198
|
+
searchParams: URLSearchParams;
|
|
199
|
+
parsedBody: RequestBodyType;
|
|
200
|
+
rawBody?: string;
|
|
201
|
+
headers: Headers;
|
|
202
|
+
request?: Request;
|
|
203
|
+
inputSchema?: TInputSchema;
|
|
204
|
+
shouldValidateInput?: boolean;
|
|
205
|
+
});
|
|
206
|
+
/**
|
|
207
|
+
* Create a RequestContext from a Request object for server-side handling
|
|
208
|
+
*/
|
|
209
|
+
static fromRequest<TPath extends string, TInputSchema extends StandardSchemaV1 | undefined = undefined>(config: {
|
|
210
|
+
request: Request;
|
|
211
|
+
method: string;
|
|
212
|
+
path: TPath;
|
|
213
|
+
pathParams: ExtractPathParams<TPath>;
|
|
214
|
+
inputSchema?: TInputSchema;
|
|
215
|
+
shouldValidateInput?: boolean;
|
|
216
|
+
state: MutableRequestState;
|
|
217
|
+
rawBody?: string;
|
|
218
|
+
}): Promise<RequestInputContext<TPath, TInputSchema>>;
|
|
219
|
+
/**
|
|
220
|
+
* Create a RequestContext for server-side rendering contexts (no Request object)
|
|
221
|
+
*/
|
|
222
|
+
static fromSSRContext<TPath extends string, TInputSchema extends StandardSchemaV1 | undefined = undefined>(config: {
|
|
223
|
+
method: "GET";
|
|
224
|
+
path: TPath;
|
|
225
|
+
pathParams: ExtractPathParams<TPath>;
|
|
226
|
+
searchParams?: URLSearchParams;
|
|
227
|
+
headers?: Headers;
|
|
228
|
+
} | {
|
|
229
|
+
method: Exclude<HTTPMethod, "GET">;
|
|
230
|
+
path: TPath;
|
|
231
|
+
pathParams: ExtractPathParams<TPath>;
|
|
232
|
+
searchParams?: URLSearchParams;
|
|
233
|
+
headers?: Headers;
|
|
234
|
+
body: RequestBodyType;
|
|
235
|
+
inputSchema?: TInputSchema;
|
|
236
|
+
}): RequestInputContext<TPath, TInputSchema>;
|
|
237
|
+
/**
|
|
238
|
+
* The HTTP method as string (e.g., `GET`, `POST`)
|
|
239
|
+
*/
|
|
240
|
+
get method(): string;
|
|
241
|
+
/**
|
|
242
|
+
* The matched route path (e.g., `/users/:id`)
|
|
243
|
+
* @remarks `string`
|
|
244
|
+
*/
|
|
245
|
+
get path(): TPath;
|
|
246
|
+
/**
|
|
247
|
+
* Extracted path parameters as object (e.g., `{ id: '123' }`)
|
|
248
|
+
* @remarks `Record<string, string>`
|
|
249
|
+
*/
|
|
250
|
+
get pathParams(): ExtractPathParams<TPath>;
|
|
251
|
+
/**
|
|
252
|
+
* [URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) object for query parameters
|
|
253
|
+
* @remarks `URLSearchParams`
|
|
254
|
+
*/
|
|
255
|
+
get query(): URLSearchParams;
|
|
256
|
+
/**
|
|
257
|
+
* [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) object for request headers
|
|
258
|
+
* @remarks `Headers`
|
|
259
|
+
*/
|
|
260
|
+
get headers(): Headers;
|
|
261
|
+
get rawBody(): string | undefined;
|
|
262
|
+
/**
|
|
263
|
+
* Access the request body as FormData.
|
|
264
|
+
*
|
|
265
|
+
* Use this method when handling file uploads or multipart form submissions.
|
|
266
|
+
* The request must have been sent with Content-Type: multipart/form-data.
|
|
267
|
+
*
|
|
268
|
+
* @throws Error if the request body is not FormData
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```typescript
|
|
272
|
+
* defineRoute({
|
|
273
|
+
* method: "POST",
|
|
274
|
+
* path: "/upload",
|
|
275
|
+
* async handler(ctx, res) {
|
|
276
|
+
* const formData = ctx.formData();
|
|
277
|
+
* const file = formData.get("file") as File;
|
|
278
|
+
* const description = formData.get("description") as string;
|
|
279
|
+
* // ... process file
|
|
280
|
+
* }
|
|
281
|
+
* });
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
formData(): FormData;
|
|
285
|
+
/**
|
|
286
|
+
* Check if the request body is FormData.
|
|
287
|
+
*
|
|
288
|
+
* Useful for routes that accept both JSON and FormData payloads.
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* ```typescript
|
|
292
|
+
* defineRoute({
|
|
293
|
+
* method: "POST",
|
|
294
|
+
* path: "/upload",
|
|
295
|
+
* async handler(ctx, res) {
|
|
296
|
+
* if (ctx.isFormData()) {
|
|
297
|
+
* const formData = ctx.formData();
|
|
298
|
+
* // handle file upload
|
|
299
|
+
* } else {
|
|
300
|
+
* const json = await ctx.input.valid();
|
|
301
|
+
* // handle JSON payload
|
|
302
|
+
* }
|
|
303
|
+
* }
|
|
304
|
+
* });
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
isFormData(): boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Access the request body as a ReadableStream (application/octet-stream).
|
|
310
|
+
*
|
|
311
|
+
* @throws Error if the request body is not a ReadableStream
|
|
312
|
+
*/
|
|
313
|
+
bodyStream(): ReadableStream<Uint8Array>;
|
|
314
|
+
/**
|
|
315
|
+
* Check if the request body is a ReadableStream.
|
|
316
|
+
*/
|
|
317
|
+
isBodyStream(): boolean;
|
|
318
|
+
/**
|
|
319
|
+
* Input validation context (only if inputSchema is defined)
|
|
320
|
+
* @remarks `InputContext`
|
|
321
|
+
*/
|
|
322
|
+
get input(): TInputSchema extends undefined ? undefined : {
|
|
323
|
+
schema: TInputSchema;
|
|
324
|
+
valid: () => Promise<TInputSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TInputSchema> : unknown>;
|
|
325
|
+
};
|
|
326
|
+
} //#endregion
|
|
327
|
+
//#endregion
|
|
328
|
+
//#region ../fragno/dist/api/internal/response-stream.d.ts
|
|
329
|
+
//#region src/api/internal/response-stream.d.ts
|
|
330
|
+
/**
|
|
331
|
+
* @module
|
|
332
|
+
* Stream utility.
|
|
333
|
+
*
|
|
334
|
+
* Modified from honojs/hono
|
|
335
|
+
* Original source: https://github.com/honojs/hono/blob/0e3db674ad3f40be215a55a18062dd8e387ce525/src/utils/stream.ts
|
|
336
|
+
* License: MIT
|
|
337
|
+
* Date obtained: August 28 2025
|
|
338
|
+
* Copyright (c) 2021-present Yusuke Wada and Hono contributors
|
|
339
|
+
*/
|
|
340
|
+
type Error$1<Message extends string> = {
|
|
341
|
+
__errorMessage: Message;
|
|
342
|
+
};
|
|
343
|
+
declare class ResponseStream<TArray> {
|
|
344
|
+
#private;
|
|
345
|
+
/**
|
|
346
|
+
* Whether the stream has been aborted.
|
|
347
|
+
*/
|
|
348
|
+
get aborted(): boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Whether the stream has been closed normally.
|
|
351
|
+
*/
|
|
352
|
+
get closed(): boolean;
|
|
353
|
+
/**
|
|
354
|
+
* The readable stream that the response is piped to.
|
|
355
|
+
*/
|
|
356
|
+
get responseReadable(): ReadableStream;
|
|
357
|
+
constructor(writable: WritableStream, readable: ReadableStream);
|
|
358
|
+
writeRaw(input: Uint8Array | string): Promise<void>;
|
|
359
|
+
write(input: TArray extends (infer U)[] ? U : Error$1<"To use a streaming response, outputSchema must be an array.">): Promise<void>;
|
|
360
|
+
sleep(ms: number): Promise<unknown>;
|
|
361
|
+
close(): Promise<void>;
|
|
362
|
+
onAbort(listener: () => void | Promise<void>): void;
|
|
363
|
+
/**
|
|
364
|
+
* Abort the stream.
|
|
365
|
+
* You can call this method when stream is aborted by external event.
|
|
366
|
+
*/
|
|
367
|
+
abort(): void;
|
|
368
|
+
} //#endregion
|
|
369
|
+
//#endregion
|
|
370
|
+
//#region ../fragno/dist/api/request-output-context.d.ts
|
|
371
|
+
//#region src/api/request-output-context.d.ts
|
|
372
|
+
interface ResponseInit<T extends StatusCode = StatusCode> {
|
|
373
|
+
headers?: HeadersInit;
|
|
374
|
+
status?: T;
|
|
375
|
+
statusText?: string;
|
|
376
|
+
}
|
|
377
|
+
declare abstract class OutputContext<const TOutput, const TErrorCode extends string> {
|
|
378
|
+
/**
|
|
379
|
+
* Creates an error response.
|
|
380
|
+
*
|
|
381
|
+
* Shortcut for `throw new FragnoApiError(...)`
|
|
382
|
+
*/
|
|
383
|
+
error: ({
|
|
384
|
+
message,
|
|
385
|
+
code
|
|
386
|
+
}: {
|
|
387
|
+
message: string;
|
|
388
|
+
code: TErrorCode;
|
|
389
|
+
}, initOrStatus?: ResponseInit | StatusCode, headers?: HeadersInit) => Response;
|
|
390
|
+
empty: (initOrStatus?: ResponseInit<ContentlessStatusCode> | ContentlessStatusCode, headers?: HeadersInit) => Response;
|
|
391
|
+
json: (object: TOutput, initOrStatus?: ResponseInit | StatusCode, headers?: HeadersInit) => Response;
|
|
392
|
+
jsonStream: (cb: (stream: ResponseStream<TOutput>) => void | Promise<void>, {
|
|
393
|
+
onError,
|
|
394
|
+
headers
|
|
395
|
+
}?: {
|
|
396
|
+
onError?: (error: Error, stream: ResponseStream<TOutput>) => void | Promise<void>;
|
|
397
|
+
headers?: HeadersInit;
|
|
398
|
+
}) => Response;
|
|
399
|
+
}
|
|
400
|
+
declare class RequestOutputContext<const TOutputSchema extends StandardSchemaV1 | undefined = undefined, const TErrorCode extends string = string> extends OutputContext<InferOrUnknown<TOutputSchema>, TErrorCode> {
|
|
401
|
+
#private;
|
|
402
|
+
constructor(outputSchema?: TOutputSchema);
|
|
403
|
+
} //#endregion
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region ../fragno/dist/api/api.d.ts
|
|
406
|
+
//#region src/api/api.d.ts
|
|
407
|
+
type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
|
|
408
|
+
type NonGetHTTPMethod = Exclude<HTTPMethod, "GET">;
|
|
409
|
+
interface RequestThisContext {}
|
|
410
|
+
/**
|
|
411
|
+
* Content types that can be accepted by a route.
|
|
412
|
+
*
|
|
413
|
+
* - `"application/json"` (default): JSON request body, validated against inputSchema
|
|
414
|
+
* - `"multipart/form-data"`: FormData request body (file uploads), no schema validation
|
|
415
|
+
*/
|
|
416
|
+
type RouteContentType = "application/json" | "multipart/form-data" | "application/octet-stream";
|
|
417
|
+
interface FragnoRouteConfig<TMethod extends HTTPMethod, TPath extends string, TInputSchema extends StandardSchemaV1 | undefined, TOutputSchema extends StandardSchemaV1 | undefined, TErrorCode extends string = string, TQueryParameters extends string = string, TThisContext extends RequestThisContext = RequestThisContext> {
|
|
418
|
+
method: TMethod;
|
|
419
|
+
path: TPath;
|
|
420
|
+
/**
|
|
421
|
+
* The expected content type for this route's request body.
|
|
422
|
+
*
|
|
423
|
+
* - `"application/json"` (default): Expects JSON body, will be validated against inputSchema
|
|
424
|
+
* - `"multipart/form-data"`: Expects FormData body (for file uploads), use `ctx.formData()` in handler
|
|
425
|
+
*
|
|
426
|
+
* The server will reject requests with mismatched Content-Type headers.
|
|
427
|
+
*
|
|
428
|
+
* @default "application/json"
|
|
429
|
+
*/
|
|
430
|
+
contentType?: RouteContentType;
|
|
431
|
+
inputSchema?: TInputSchema;
|
|
432
|
+
outputSchema?: TOutputSchema;
|
|
433
|
+
errorCodes?: readonly TErrorCode[];
|
|
434
|
+
queryParameters?: readonly TQueryParameters[];
|
|
435
|
+
handler(this: TThisContext, inputCtx: RequestInputContext<TPath, TInputSchema>, outputCtx: RequestOutputContext<TOutputSchema, TErrorCode>): Promise<Response>;
|
|
436
|
+
}
|
|
437
|
+
//#endregion
|
|
438
|
+
//#region ../fragno/dist/api/shared-types.d.ts
|
|
439
|
+
/**
|
|
440
|
+
* Configuration for custom fetch behavior in client-side fragments.
|
|
441
|
+
*/
|
|
442
|
+
type FetcherConfig = {
|
|
443
|
+
type: "options";
|
|
444
|
+
options: RequestInit;
|
|
445
|
+
} | {
|
|
446
|
+
type: "function";
|
|
447
|
+
fetcher: typeof fetch;
|
|
448
|
+
};
|
|
449
|
+
/**
|
|
450
|
+
* Public configuration for Fragno fragments on the client side.
|
|
451
|
+
*/
|
|
452
|
+
interface FragnoPublicClientConfig {
|
|
453
|
+
mountRoute?: string;
|
|
454
|
+
baseUrl?: string;
|
|
455
|
+
fetcherConfig?: FetcherConfig;
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Shared configuration for fragment routes.
|
|
459
|
+
*/
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region ../../node_modules/.pnpm/@nanostores+query@0.3.4_nanostores@1.2.0/node_modules/@nanostores/query/dist/factory.d.ts
|
|
462
|
+
type Key = string;
|
|
463
|
+
type FetcherValue<T = any, E = Error> = {
|
|
464
|
+
data?: T;
|
|
465
|
+
error?: E;
|
|
466
|
+
loading: boolean;
|
|
467
|
+
promise?: Promise<T>;
|
|
468
|
+
};
|
|
469
|
+
type LazyFetchValue<T = any, E = any> = {
|
|
470
|
+
data: T;
|
|
471
|
+
} | {
|
|
472
|
+
error: E;
|
|
473
|
+
};
|
|
474
|
+
type FetcherStore<T = any, E = any> = MapStore<FetcherValue<T, E>> & {
|
|
475
|
+
_: Symbol;
|
|
476
|
+
key?: Key;
|
|
477
|
+
invalidate: (...args: any[]) => void;
|
|
478
|
+
revalidate: (...args: any[]) => void;
|
|
479
|
+
mutate: (data?: T) => void;
|
|
480
|
+
fetch: () => Promise<LazyFetchValue<T, E>>;
|
|
481
|
+
};
|
|
482
|
+
type MutateCb<Data, Result = unknown> = Data extends void ? () => Promise<Result> : (data: Data) => Promise<Result>;
|
|
483
|
+
type MutatorStore<Data = void, Result = unknown, E = Error> = MapStore<{
|
|
484
|
+
mutate: MutateCb<Data, Result>;
|
|
485
|
+
data?: Result;
|
|
486
|
+
loading?: boolean;
|
|
487
|
+
error?: E;
|
|
488
|
+
}> & {
|
|
489
|
+
mutate: MutateCb<Data, Result>;
|
|
490
|
+
};
|
|
491
|
+
//#endregion
|
|
492
|
+
//#region ../fragno/dist/client/client.d.ts
|
|
493
|
+
//#region src/client/client.d.ts
|
|
494
|
+
/**
|
|
495
|
+
* Symbols used to identify hook types
|
|
496
|
+
*/
|
|
497
|
+
declare const GET_HOOK_SYMBOL: unique symbol;
|
|
498
|
+
declare const MUTATOR_HOOK_SYMBOL: unique symbol;
|
|
499
|
+
declare const STORE_SYMBOL: unique symbol;
|
|
500
|
+
/**
|
|
501
|
+
* @internal
|
|
502
|
+
*/
|
|
503
|
+
type FragnoStoreFactoryData<T extends object, TArgs extends unknown[] = []> = {
|
|
504
|
+
factory: (...args: TArgs) => T;
|
|
505
|
+
[STORE_SYMBOL]: true;
|
|
506
|
+
};
|
|
507
|
+
type FragnoClientHookData<TMethod$1 extends HTTPMethod, TPath$1 extends string, TOutputSchema$1 extends StandardSchemaV1, TErrorCode$1 extends string, TQueryParameters$1 extends string> = {
|
|
508
|
+
route: FragnoRouteConfig<TMethod$1, TPath$1, StandardSchemaV1 | undefined, TOutputSchema$1, TErrorCode$1, TQueryParameters$1>;
|
|
509
|
+
query(args?: {
|
|
510
|
+
path?: MaybeExtractPathParamsOrWiden<TPath$1, string>;
|
|
511
|
+
query?: Record<TQueryParameters$1, string | undefined>;
|
|
512
|
+
}): Promise<StandardSchemaV1.InferOutput<TOutputSchema$1>>;
|
|
513
|
+
store(args?: {
|
|
514
|
+
path?: MaybeExtractPathParamsOrWiden<TPath$1, string | ReadableAtom<string>>;
|
|
515
|
+
query?: Record<TQueryParameters$1, string | undefined | ReadableAtom<string | undefined>>;
|
|
516
|
+
}): FetcherStore<StandardSchemaV1.InferOutput<TOutputSchema$1>, FragnoClientError<TErrorCode$1>>;
|
|
517
|
+
[GET_HOOK_SYMBOL]: true;
|
|
518
|
+
} & {
|
|
519
|
+
readonly _outputSchema?: TOutputSchema$1;
|
|
520
|
+
};
|
|
521
|
+
type FragnoClientMutatorData<TMethod$1 extends NonGetHTTPMethod, TPath$1 extends string, TInputSchema$1 extends StandardSchemaV1 | undefined, TOutputSchema$1 extends StandardSchemaV1 | undefined, TErrorCode$1 extends string, TQueryParameters$1 extends string> = {
|
|
522
|
+
route: FragnoRouteConfig<TMethod$1, TPath$1, TInputSchema$1, TOutputSchema$1, TErrorCode$1, TQueryParameters$1>;
|
|
523
|
+
mutateQuery(args?: {
|
|
524
|
+
body?: InferOr<TInputSchema$1, undefined>;
|
|
525
|
+
path?: MaybeExtractPathParamsOrWiden<TPath$1, string>;
|
|
526
|
+
query?: Record<TQueryParameters$1, string | undefined>;
|
|
527
|
+
}): Promise<InferOr<TOutputSchema$1, undefined>>;
|
|
528
|
+
mutatorStore: MutatorStore<{
|
|
529
|
+
body?: InferOr<TInputSchema$1, undefined>;
|
|
530
|
+
path?: MaybeExtractPathParamsOrWiden<TPath$1, string | ReadableAtom<string>>;
|
|
531
|
+
query?: Record<TQueryParameters$1, string | undefined | ReadableAtom<string | undefined>>;
|
|
532
|
+
}, InferOr<TOutputSchema$1, undefined>, FragnoClientError<TErrorCode$1>>;
|
|
533
|
+
[MUTATOR_HOOK_SYMBOL]: true;
|
|
534
|
+
} & {
|
|
535
|
+
readonly _inputSchema?: TInputSchema$1;
|
|
536
|
+
readonly _outputSchema?: TOutputSchema$1;
|
|
537
|
+
};
|
|
538
|
+
/**
|
|
539
|
+
* @internal
|
|
540
|
+
*/
|
|
541
|
+
//#endregion
|
|
542
|
+
//#region src/debug-log.d.ts
|
|
543
|
+
type PiLogLevel = "off" | "error" | "warn" | "info" | "debug";
|
|
544
|
+
type PiLoggerConfig = {
|
|
545
|
+
enabled?: boolean;
|
|
546
|
+
level?: PiLogLevel;
|
|
547
|
+
};
|
|
548
|
+
//#endregion
|
|
549
|
+
//#region src/pi/constants.d.ts
|
|
550
|
+
declare const SESSION_STATUSES: readonly ["active", "paused", "errored", "terminated", "complete", "waiting"];
|
|
551
|
+
declare const STEERING_MODES: readonly ["all", "one-at-a-time"];
|
|
552
|
+
declare const THINKING_LEVELS: readonly ["off", "minimal", "low", "medium", "high", "xhigh"];
|
|
553
|
+
type PiSessionStatus = (typeof SESSION_STATUSES)[number];
|
|
554
|
+
type PiSteeringMode = (typeof STEERING_MODES)[number];
|
|
555
|
+
//#endregion
|
|
556
|
+
//#region src/pi/workflow/agent-runner.d.ts
|
|
557
|
+
type AgentLoopParams = {
|
|
558
|
+
sessionId: string;
|
|
559
|
+
agentName: string;
|
|
560
|
+
systemPrompt?: string;
|
|
561
|
+
initialMessages?: AgentMessage[];
|
|
562
|
+
};
|
|
563
|
+
//#endregion
|
|
564
|
+
//#region src/pi/workflow/workflow.d.ts
|
|
565
|
+
declare const PI_WORKFLOW_NAME = "agent-loop-workflow";
|
|
566
|
+
type WorkflowsOptions = {
|
|
567
|
+
agents: PiAgentRegistry;
|
|
568
|
+
tools: PiToolRegistry;
|
|
569
|
+
toolSideEffectReducers?: PiToolSideEffectReducerRegistry;
|
|
570
|
+
logging?: PiFragmentConfig["logging"];
|
|
571
|
+
};
|
|
572
|
+
declare const createPiAgentLoopWorkflow: (options: WorkflowsOptions) => _fragno_dev_workflows0.WorkflowDefinition<AgentLoopParams, {
|
|
573
|
+
messages: AgentMessage[];
|
|
574
|
+
}, z.ZodType<AgentLoopParams, unknown, z.core.$ZodTypeInternals<AgentLoopParams, unknown>>, undefined, PiAgentLoopState, "agent-loop-workflow">;
|
|
575
|
+
type PiWorkflowsRegistry = {
|
|
576
|
+
agentLoop: ReturnType<typeof createPiAgentLoopWorkflow>;
|
|
577
|
+
};
|
|
578
|
+
declare const createPiWorkflows: (options: WorkflowsOptions) => {
|
|
579
|
+
agentLoop: _fragno_dev_workflows0.WorkflowDefinition<AgentLoopParams, {
|
|
580
|
+
messages: AgentMessage[];
|
|
581
|
+
}, z.ZodType<AgentLoopParams, unknown, z.core.$ZodTypeInternals<AgentLoopParams, unknown>>, undefined, PiAgentLoopState, "agent-loop-workflow">;
|
|
582
|
+
};
|
|
583
|
+
//#endregion
|
|
584
|
+
//#region src/pi/types.d.ts
|
|
585
|
+
type WorkflowsService = WorkflowsFragmentServices<PiWorkflowsRegistry>;
|
|
586
|
+
type PiSession = {
|
|
587
|
+
id: string;
|
|
588
|
+
name: string | null;
|
|
589
|
+
status: PiSessionStatus;
|
|
590
|
+
agent: string;
|
|
591
|
+
steeringMode: PiSteeringMode;
|
|
592
|
+
metadata: unknown;
|
|
593
|
+
tags: string[];
|
|
594
|
+
createdAt: Date;
|
|
595
|
+
updatedAt: Date;
|
|
596
|
+
};
|
|
597
|
+
type PiTurnSummary = {
|
|
598
|
+
turn: number;
|
|
599
|
+
assistant: AgentMessage | null;
|
|
600
|
+
summary: string | null;
|
|
601
|
+
};
|
|
602
|
+
type PiSessionDetailEvent = {
|
|
603
|
+
id: string;
|
|
604
|
+
type: string;
|
|
605
|
+
payload: unknown | null;
|
|
606
|
+
createdAt: Date;
|
|
607
|
+
deliveredAt: Date | null;
|
|
608
|
+
consumedByStepKey: string | null;
|
|
609
|
+
runNumber?: number | null;
|
|
610
|
+
};
|
|
611
|
+
type PiAgentLoopPhase = "waiting-for-user" | "running-agent" | "complete";
|
|
612
|
+
type PiActiveSessionStreamItem = AgentEvent;
|
|
613
|
+
type PiActiveSessionSettledStatus = "waiting-for-user" | "complete" | "errored";
|
|
614
|
+
type PiActiveSessionUpdate = {
|
|
615
|
+
type: "event";
|
|
616
|
+
turn: number;
|
|
617
|
+
event: PiActiveSessionStreamItem;
|
|
618
|
+
} | {
|
|
619
|
+
type: "settled";
|
|
620
|
+
turn: number;
|
|
621
|
+
status: PiActiveSessionSettledStatus;
|
|
622
|
+
};
|
|
623
|
+
type PiActiveSessionSubscriber = (update: PiActiveSessionUpdate) => void;
|
|
624
|
+
type PiActiveSessionReplayBufferEntry = {
|
|
625
|
+
turn: number;
|
|
626
|
+
updates: PiActiveSessionUpdate[];
|
|
627
|
+
};
|
|
628
|
+
type PiActiveSessionReplayBuffer = PiActiveSessionReplayBufferEntry[];
|
|
629
|
+
type PiActiveSessionState = {
|
|
630
|
+
subscribe: (listener: PiActiveSessionSubscriber) => () => void;
|
|
631
|
+
publishEvent: (turn: number, event: PiActiveSessionStreamItem) => void;
|
|
632
|
+
settleTurn: (turn: number, status: PiActiveSessionSettledStatus) => void;
|
|
633
|
+
replayTurn: (turn: number) => PiActiveSessionUpdate[];
|
|
634
|
+
exportReplayBuffer: () => PiActiveSessionReplayBuffer;
|
|
635
|
+
importReplayBuffer: (buffer: PiActiveSessionReplayBuffer) => void;
|
|
636
|
+
listenerCount: () => number;
|
|
637
|
+
};
|
|
638
|
+
type PiAgentLoopWaitingFor = {
|
|
639
|
+
type: "user_message";
|
|
640
|
+
turn: number;
|
|
641
|
+
stepKey: string;
|
|
642
|
+
timeoutMs: number | null;
|
|
643
|
+
} | {
|
|
644
|
+
type: "assistant";
|
|
645
|
+
turn: number;
|
|
646
|
+
stepKey: string;
|
|
647
|
+
} | null;
|
|
648
|
+
type PiAgentLoopSerializableState = {
|
|
649
|
+
messages: AgentMessage[];
|
|
650
|
+
events: PiSessionDetailEvent[];
|
|
651
|
+
trace: AgentEvent[];
|
|
652
|
+
summaries: PiTurnSummary[];
|
|
653
|
+
turn: number;
|
|
654
|
+
phase: PiAgentLoopPhase;
|
|
655
|
+
waitingFor: PiAgentLoopWaitingFor;
|
|
656
|
+
};
|
|
657
|
+
type PiAgentLoopPersistedState = PiAgentLoopSerializableState & {
|
|
658
|
+
activeSessionUpdatesByTurn: PiActiveSessionReplayBuffer;
|
|
659
|
+
};
|
|
660
|
+
type PiSessionWorkflowStatus = {
|
|
661
|
+
status: PiSessionStatus;
|
|
662
|
+
error?: {
|
|
663
|
+
name: string;
|
|
664
|
+
message: string;
|
|
665
|
+
};
|
|
666
|
+
output?: unknown;
|
|
667
|
+
};
|
|
668
|
+
type PiSessionDetail = PiSession & {
|
|
669
|
+
workflow: PiSessionWorkflowStatus;
|
|
670
|
+
messages: AgentMessage[];
|
|
671
|
+
events: PiSessionDetailEvent[];
|
|
672
|
+
trace: AgentEvent[];
|
|
673
|
+
summaries: PiTurnSummary[];
|
|
674
|
+
turn: number;
|
|
675
|
+
phase: PiAgentLoopPhase;
|
|
676
|
+
waitingFor: PiAgentLoopWaitingFor;
|
|
677
|
+
};
|
|
678
|
+
type PiAgentLoopState = PiAgentLoopPersistedState & {
|
|
679
|
+
activeSession?: PiActiveSessionState;
|
|
680
|
+
};
|
|
681
|
+
type PiWorkflowsInstanceStatus = InstanceStatus;
|
|
682
|
+
type PiWorkflowHistoryStep = WorkflowsHistoryStep;
|
|
683
|
+
type PiWorkflowsService = Pick<WorkflowsService, "createInstance" | "getInstanceStatus" | "getLiveInstanceState" | "restoreInstanceState" | "sendEvent"> & {
|
|
684
|
+
getInstanceStatusBatch?: (workflowName: string, instanceIds: string[]) => TxResult<PiWorkflowsInstanceStatus[], PiWorkflowsInstanceStatus[]>;
|
|
685
|
+
};
|
|
686
|
+
type PiAgentDefinition = {
|
|
687
|
+
name: string;
|
|
688
|
+
systemPrompt: string;
|
|
689
|
+
model: Model<Api>;
|
|
690
|
+
thinkingLevel?: ThinkingLevel;
|
|
691
|
+
tools?: string[];
|
|
692
|
+
toolConfig?: unknown;
|
|
693
|
+
maxTraceEvents?: number;
|
|
694
|
+
streamFn?: StreamFn;
|
|
695
|
+
convertToLlm?: AgentOptions["convertToLlm"];
|
|
696
|
+
transformContext?: AgentOptions["transformContext"];
|
|
697
|
+
getApiKey?: AgentOptions["getApiKey"];
|
|
698
|
+
thinkingBudgets?: AgentOptions["thinkingBudgets"];
|
|
699
|
+
maxRetryDelayMs?: AgentOptions["maxRetryDelayMs"];
|
|
700
|
+
onEvent?: (event: AgentEvent, ctx: {
|
|
701
|
+
sessionId: string;
|
|
702
|
+
turnId: string;
|
|
703
|
+
}) => void;
|
|
704
|
+
};
|
|
705
|
+
type PiAgentRegistry = Record<string, PiAgentDefinition>;
|
|
706
|
+
declare const PI_TOOL_JOURNAL_VERSION: 1;
|
|
707
|
+
type PiToolJournalVersion = typeof PI_TOOL_JOURNAL_VERSION;
|
|
708
|
+
type PiToolCallStableKey = string;
|
|
709
|
+
type PiPersistedToolResult = {
|
|
710
|
+
content: Array<TextContent | ImageContent>;
|
|
711
|
+
details: unknown;
|
|
712
|
+
};
|
|
713
|
+
type PiPersistedToolCallSource = "executed" | "replay";
|
|
714
|
+
type PiPersistedToolCallV1 = {
|
|
715
|
+
version: PiToolJournalVersion;
|
|
716
|
+
key: PiToolCallStableKey;
|
|
717
|
+
sessionId: string;
|
|
718
|
+
turnId: string;
|
|
719
|
+
toolCallId: string;
|
|
720
|
+
toolName: string;
|
|
721
|
+
args: Record<string, unknown>;
|
|
722
|
+
result: PiPersistedToolResult;
|
|
723
|
+
isError: boolean;
|
|
724
|
+
source: PiPersistedToolCallSource;
|
|
725
|
+
capturedAt: number;
|
|
726
|
+
seq: number;
|
|
727
|
+
};
|
|
728
|
+
type PiActiveSessionSystemMessage = {
|
|
729
|
+
layer: "system";
|
|
730
|
+
type: "snapshot";
|
|
731
|
+
turn: number;
|
|
732
|
+
phase: PiAgentLoopPhase;
|
|
733
|
+
waitingFor: PiAgentLoopWaitingFor;
|
|
734
|
+
replayCount: number;
|
|
735
|
+
} | {
|
|
736
|
+
layer: "system";
|
|
737
|
+
type: "settled";
|
|
738
|
+
turn: number;
|
|
739
|
+
status: PiActiveSessionSettledStatus;
|
|
740
|
+
} | {
|
|
741
|
+
layer: "system";
|
|
742
|
+
type: "inactive";
|
|
743
|
+
reason: "session-complete" | "session-idle";
|
|
744
|
+
turn: number;
|
|
745
|
+
phase: PiAgentLoopPhase;
|
|
746
|
+
waitingFor: PiAgentLoopWaitingFor;
|
|
747
|
+
};
|
|
748
|
+
type PiActiveSessionProtocolMessage = PiActiveSessionSystemMessage | {
|
|
749
|
+
layer: "pi";
|
|
750
|
+
type: "event";
|
|
751
|
+
turn: number;
|
|
752
|
+
source: "replay" | "live";
|
|
753
|
+
event: PiActiveSessionStreamItem;
|
|
754
|
+
};
|
|
755
|
+
type PiPersistedToolCall = PiPersistedToolCallV1;
|
|
756
|
+
type PiToolReplayCache = Map<PiToolCallStableKey, PiPersistedToolCall>;
|
|
757
|
+
type PiToolSideEffectReducerContext = {
|
|
758
|
+
key: PiToolCallStableKey;
|
|
759
|
+
sessionId: string;
|
|
760
|
+
turnId: string;
|
|
761
|
+
};
|
|
762
|
+
type PiToolSideEffectReducer = (state: unknown, entry: PiPersistedToolCall, ctx: PiToolSideEffectReducerContext) => unknown;
|
|
763
|
+
type PiToolSideEffectReducerRegistry = Record<string, PiToolSideEffectReducer>;
|
|
764
|
+
type PiToolReplayContext = {
|
|
765
|
+
cache: PiToolReplayCache;
|
|
766
|
+
journal: PiPersistedToolCall[];
|
|
767
|
+
sideEffects: Record<string, unknown>;
|
|
768
|
+
};
|
|
769
|
+
type PiToolFactoryContext = {
|
|
770
|
+
session: PiSession;
|
|
771
|
+
turnId: string;
|
|
772
|
+
toolConfig: unknown;
|
|
773
|
+
messages: AgentMessage[];
|
|
774
|
+
replay: PiToolReplayContext;
|
|
775
|
+
};
|
|
776
|
+
type PiToolFactory = AgentTool | ((ctx: PiToolFactoryContext) => AgentTool | Promise<AgentTool>);
|
|
777
|
+
type PiToolRegistry = Record<string, PiToolFactory>;
|
|
778
|
+
interface PiFragmentConfig {
|
|
779
|
+
agents: PiAgentRegistry;
|
|
780
|
+
tools: PiToolRegistry;
|
|
781
|
+
defaultSteeringMode?: PiSteeringMode;
|
|
782
|
+
toolSideEffectReducers?: PiToolSideEffectReducerRegistry;
|
|
783
|
+
/**
|
|
784
|
+
* Optional logging config for internal pi-fragment diagnostics.
|
|
785
|
+
*/
|
|
786
|
+
logging?: PiLoggerConfig;
|
|
787
|
+
}
|
|
788
|
+
//#endregion
|
|
789
|
+
//#region src/client/session-store.d.ts
|
|
790
|
+
type QueryStoreValue<T> = {
|
|
791
|
+
loading: boolean;
|
|
792
|
+
data?: T;
|
|
793
|
+
error?: {
|
|
794
|
+
message?: string;
|
|
795
|
+
};
|
|
796
|
+
};
|
|
797
|
+
type QueryStore<T> = ReadableAtom<QueryStoreValue<T>> & {
|
|
798
|
+
revalidate: () => void;
|
|
799
|
+
};
|
|
800
|
+
type PiLiveToolExecution = {
|
|
801
|
+
toolCallId: string;
|
|
802
|
+
toolName: string;
|
|
803
|
+
args: unknown;
|
|
804
|
+
partialResult: unknown | null;
|
|
805
|
+
};
|
|
806
|
+
type PiSessionConnectionState = "idle" | "connecting" | "listening" | "reconnecting" | "error";
|
|
807
|
+
type PiSessionStoreState = {
|
|
808
|
+
loading: boolean;
|
|
809
|
+
session: PiSessionDetail | null;
|
|
810
|
+
messages: AgentMessage[];
|
|
811
|
+
traceEvents: AgentEvent[];
|
|
812
|
+
runningTools: PiLiveToolExecution[];
|
|
813
|
+
connection: PiSessionConnectionState;
|
|
814
|
+
statusText: string | null;
|
|
815
|
+
readyForInput: boolean;
|
|
816
|
+
sending: boolean;
|
|
817
|
+
error: string | null;
|
|
818
|
+
sendError: string | null;
|
|
819
|
+
};
|
|
820
|
+
type CreatePiSessionStoreArgs = {
|
|
821
|
+
sessionId: string;
|
|
822
|
+
initialData?: PiSessionDetail | null;
|
|
823
|
+
};
|
|
824
|
+
type PiSessionStoreController = {
|
|
825
|
+
store: ReadableAtom<PiSessionStoreState>;
|
|
826
|
+
sendMessage: (input: {
|
|
827
|
+
text: string;
|
|
828
|
+
done?: boolean;
|
|
829
|
+
steeringMode?: "all" | "one-at-a-time";
|
|
830
|
+
}) => boolean;
|
|
831
|
+
refetch: () => void;
|
|
832
|
+
deactivate: () => void;
|
|
833
|
+
destroy: () => void;
|
|
834
|
+
};
|
|
835
|
+
type CreatePiSessionStoreDependencies = {
|
|
836
|
+
createDetailStore: (sessionId: string) => QueryStore<PiSessionDetail>;
|
|
837
|
+
sendMessage: (options: {
|
|
838
|
+
sessionId: string;
|
|
839
|
+
text: string;
|
|
840
|
+
done?: boolean;
|
|
841
|
+
steeringMode?: "all" | "one-at-a-time";
|
|
842
|
+
}) => Promise<{
|
|
843
|
+
status: PiSessionStatus;
|
|
844
|
+
}>;
|
|
845
|
+
buildActiveUrl: (sessionId: string) => string;
|
|
846
|
+
fetcher: typeof fetch;
|
|
847
|
+
defaultOptions?: RequestInit;
|
|
848
|
+
enableActiveStream?: boolean;
|
|
849
|
+
activeLogger?: (event: string, details?: Record<string, unknown>) => void;
|
|
850
|
+
};
|
|
851
|
+
declare function createPiSessionStore(deps: CreatePiSessionStoreDependencies, args: CreatePiSessionStoreArgs): PiSessionStoreController;
|
|
852
|
+
//#endregion
|
|
853
|
+
//#region src/client/session-controller.d.ts
|
|
854
|
+
type PiSessionStoreHookArgs = {
|
|
855
|
+
path: {
|
|
856
|
+
sessionId: string;
|
|
857
|
+
};
|
|
858
|
+
initialData?: PiSessionDetail | null;
|
|
859
|
+
};
|
|
860
|
+
type PiSessionStoreView = {
|
|
861
|
+
loading: ReadableAtom<PiSessionStoreState["loading"]>;
|
|
862
|
+
session: ReadableAtom<PiSessionStoreState["session"]>;
|
|
863
|
+
messages: ReadableAtom<AgentMessage[]>;
|
|
864
|
+
traceEvents: ReadableAtom<AgentEvent[]>;
|
|
865
|
+
runningTools: ReadableAtom<PiSessionStoreState["runningTools"]>;
|
|
866
|
+
connection: ReadableAtom<PiSessionStoreState["connection"]>;
|
|
867
|
+
statusText: ReadableAtom<PiSessionStoreState["statusText"]>;
|
|
868
|
+
readyForInput: ReadableAtom<PiSessionStoreState["readyForInput"]>;
|
|
869
|
+
sending: ReadableAtom<PiSessionStoreState["sending"]>;
|
|
870
|
+
error: ReadableAtom<PiSessionStoreState["error"]>;
|
|
871
|
+
sendError: ReadableAtom<PiSessionStoreState["sendError"]>;
|
|
872
|
+
sendMessage: PiSessionStoreController["sendMessage"];
|
|
873
|
+
refetch: PiSessionStoreController["refetch"];
|
|
874
|
+
[Symbol.dispose]: () => void;
|
|
875
|
+
};
|
|
876
|
+
//#endregion
|
|
877
|
+
//#region src/client/clients.d.ts
|
|
878
|
+
type PiFragmentClientConfig = FragnoPublicClientConfig & {
|
|
879
|
+
debugActiveSession?: boolean;
|
|
880
|
+
};
|
|
881
|
+
declare function createPiFragmentClients(fragnoConfig: PiFragmentClientConfig): {
|
|
882
|
+
useSessions: FragnoClientHookData<"GET", "/sessions", zod.ZodArray<zod.ZodObject<{
|
|
883
|
+
id: zod.ZodString;
|
|
884
|
+
name: zod.ZodNullable<zod.ZodString>;
|
|
885
|
+
status: zod.ZodEnum<{
|
|
886
|
+
active: "active";
|
|
887
|
+
paused: "paused";
|
|
888
|
+
errored: "errored";
|
|
889
|
+
terminated: "terminated";
|
|
890
|
+
complete: "complete";
|
|
891
|
+
waiting: "waiting";
|
|
892
|
+
}>;
|
|
893
|
+
agent: zod.ZodString;
|
|
894
|
+
steeringMode: zod.ZodEnum<{
|
|
895
|
+
all: "all";
|
|
896
|
+
"one-at-a-time": "one-at-a-time";
|
|
897
|
+
}>;
|
|
898
|
+
metadata: zod.ZodNullable<zod.ZodAny>;
|
|
899
|
+
tags: zod.ZodArray<zod.ZodString>;
|
|
900
|
+
createdAt: zod.ZodDate;
|
|
901
|
+
updatedAt: zod.ZodDate;
|
|
902
|
+
}, zod_v4_core0.$strip>>, string, "limit">;
|
|
903
|
+
useSessionDetail: FragnoClientHookData<"GET", "/sessions/:sessionId", zod.ZodObject<{
|
|
904
|
+
id: zod.ZodString;
|
|
905
|
+
name: zod.ZodNullable<zod.ZodString>;
|
|
906
|
+
status: zod.ZodEnum<{
|
|
907
|
+
active: "active";
|
|
908
|
+
paused: "paused";
|
|
909
|
+
errored: "errored";
|
|
910
|
+
terminated: "terminated";
|
|
911
|
+
complete: "complete";
|
|
912
|
+
waiting: "waiting";
|
|
913
|
+
}>;
|
|
914
|
+
agent: zod.ZodString;
|
|
915
|
+
steeringMode: zod.ZodEnum<{
|
|
916
|
+
all: "all";
|
|
917
|
+
"one-at-a-time": "one-at-a-time";
|
|
918
|
+
}>;
|
|
919
|
+
metadata: zod.ZodNullable<zod.ZodAny>;
|
|
920
|
+
tags: zod.ZodArray<zod.ZodString>;
|
|
921
|
+
createdAt: zod.ZodDate;
|
|
922
|
+
updatedAt: zod.ZodDate;
|
|
923
|
+
workflow: zod.ZodObject<{
|
|
924
|
+
status: zod.ZodEnum<{
|
|
925
|
+
active: "active";
|
|
926
|
+
paused: "paused";
|
|
927
|
+
errored: "errored";
|
|
928
|
+
terminated: "terminated";
|
|
929
|
+
complete: "complete";
|
|
930
|
+
waiting: "waiting";
|
|
931
|
+
}>;
|
|
932
|
+
error: zod.ZodOptional<zod.ZodObject<{
|
|
933
|
+
name: zod.ZodString;
|
|
934
|
+
message: zod.ZodString;
|
|
935
|
+
}, zod_v4_core0.$strip>>;
|
|
936
|
+
output: zod.ZodOptional<zod.ZodAny>;
|
|
937
|
+
}, zod_v4_core0.$strip>;
|
|
938
|
+
messages: zod.ZodArray<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
939
|
+
role: zod.ZodLiteral<"user">;
|
|
940
|
+
content: zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
941
|
+
type: zod.ZodLiteral<"text">;
|
|
942
|
+
text: zod.ZodString;
|
|
943
|
+
textSignature: zod.ZodOptional<zod.ZodString>;
|
|
944
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
945
|
+
type: zod.ZodLiteral<"image">;
|
|
946
|
+
data: zod.ZodString;
|
|
947
|
+
mimeType: zod.ZodString;
|
|
948
|
+
}, zod_v4_core0.$strip>]>>]>;
|
|
949
|
+
timestamp: zod.ZodNumber;
|
|
950
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
951
|
+
role: zod.ZodLiteral<"assistant">;
|
|
952
|
+
content: zod.ZodArray<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
953
|
+
type: zod.ZodLiteral<"text">;
|
|
954
|
+
text: zod.ZodString;
|
|
955
|
+
textSignature: zod.ZodOptional<zod.ZodString>;
|
|
956
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
957
|
+
type: zod.ZodLiteral<"thinking">;
|
|
958
|
+
thinking: zod.ZodString;
|
|
959
|
+
thinkingSignature: zod.ZodOptional<zod.ZodString>;
|
|
960
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
961
|
+
type: zod.ZodLiteral<"toolCall">;
|
|
962
|
+
id: zod.ZodString;
|
|
963
|
+
name: zod.ZodString;
|
|
964
|
+
arguments: zod.ZodRecord<zod.ZodString, zod.ZodUnknown>;
|
|
965
|
+
thoughtSignature: zod.ZodOptional<zod.ZodString>;
|
|
966
|
+
}, zod_v4_core0.$strip>]>>;
|
|
967
|
+
api: zod.ZodString;
|
|
968
|
+
provider: zod.ZodString;
|
|
969
|
+
model: zod.ZodString;
|
|
970
|
+
usage: zod.ZodObject<{
|
|
971
|
+
input: zod.ZodNumber;
|
|
972
|
+
output: zod.ZodNumber;
|
|
973
|
+
cacheRead: zod.ZodNumber;
|
|
974
|
+
cacheWrite: zod.ZodNumber;
|
|
975
|
+
totalTokens: zod.ZodNumber;
|
|
976
|
+
cost: zod.ZodObject<{
|
|
977
|
+
input: zod.ZodNumber;
|
|
978
|
+
output: zod.ZodNumber;
|
|
979
|
+
cacheRead: zod.ZodNumber;
|
|
980
|
+
cacheWrite: zod.ZodNumber;
|
|
981
|
+
total: zod.ZodNumber;
|
|
982
|
+
}, zod_v4_core0.$strip>;
|
|
983
|
+
}, zod_v4_core0.$strip>;
|
|
984
|
+
stopReason: zod.ZodEnum<{
|
|
985
|
+
length: "length";
|
|
986
|
+
error: "error";
|
|
987
|
+
stop: "stop";
|
|
988
|
+
toolUse: "toolUse";
|
|
989
|
+
aborted: "aborted";
|
|
990
|
+
}>;
|
|
991
|
+
errorMessage: zod.ZodOptional<zod.ZodString>;
|
|
992
|
+
timestamp: zod.ZodNumber;
|
|
993
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
994
|
+
role: zod.ZodLiteral<"toolResult">;
|
|
995
|
+
toolCallId: zod.ZodString;
|
|
996
|
+
toolName: zod.ZodString;
|
|
997
|
+
content: zod.ZodArray<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
998
|
+
type: zod.ZodLiteral<"text">;
|
|
999
|
+
text: zod.ZodString;
|
|
1000
|
+
textSignature: zod.ZodOptional<zod.ZodString>;
|
|
1001
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
1002
|
+
type: zod.ZodLiteral<"image">;
|
|
1003
|
+
data: zod.ZodString;
|
|
1004
|
+
mimeType: zod.ZodString;
|
|
1005
|
+
}, zod_v4_core0.$strip>]>>;
|
|
1006
|
+
details: zod.ZodOptional<zod.ZodUnknown>;
|
|
1007
|
+
isError: zod.ZodBoolean;
|
|
1008
|
+
timestamp: zod.ZodNumber;
|
|
1009
|
+
}, zod_v4_core0.$strip>]>>;
|
|
1010
|
+
events: zod.ZodArray<zod.ZodObject<{
|
|
1011
|
+
id: zod.ZodString;
|
|
1012
|
+
runNumber: zod.ZodOptional<zod.ZodNullable<zod.ZodNumber>>;
|
|
1013
|
+
type: zod.ZodString;
|
|
1014
|
+
payload: zod.ZodNullable<zod.ZodUnknown>;
|
|
1015
|
+
createdAt: zod.ZodDate;
|
|
1016
|
+
deliveredAt: zod.ZodNullable<zod.ZodDate>;
|
|
1017
|
+
consumedByStepKey: zod.ZodNullable<zod.ZodString>;
|
|
1018
|
+
}, zod_v4_core0.$strip>>;
|
|
1019
|
+
trace: zod.ZodArray<zod.ZodType<_mariozechner_pi_agent_core0.AgentEvent, unknown, zod_v4_core0.$ZodTypeInternals<_mariozechner_pi_agent_core0.AgentEvent, unknown>>>;
|
|
1020
|
+
turn: zod.ZodNumber;
|
|
1021
|
+
phase: zod.ZodEnum<{
|
|
1022
|
+
complete: "complete";
|
|
1023
|
+
"waiting-for-user": "waiting-for-user";
|
|
1024
|
+
"running-agent": "running-agent";
|
|
1025
|
+
}>;
|
|
1026
|
+
waitingFor: zod.ZodNullable<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
1027
|
+
type: zod.ZodLiteral<"user_message">;
|
|
1028
|
+
turn: zod.ZodNumber;
|
|
1029
|
+
stepKey: zod.ZodString;
|
|
1030
|
+
timeoutMs: zod.ZodNullable<zod.ZodNumber>;
|
|
1031
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
1032
|
+
type: zod.ZodLiteral<"assistant">;
|
|
1033
|
+
turn: zod.ZodNumber;
|
|
1034
|
+
stepKey: zod.ZodString;
|
|
1035
|
+
}, zod_v4_core0.$strip>]>>;
|
|
1036
|
+
summaries: zod.ZodArray<zod.ZodObject<{
|
|
1037
|
+
turn: zod.ZodNumber;
|
|
1038
|
+
assistant: zod.ZodNullable<zod.ZodAny>;
|
|
1039
|
+
summary: zod.ZodNullable<zod.ZodString>;
|
|
1040
|
+
}, zod_v4_core0.$strip>>;
|
|
1041
|
+
}, zod_v4_core0.$strip>, "SESSION_NOT_FOUND" | "WORKFLOW_INSTANCE_MISSING", "events" | "trace" | "summaries">;
|
|
1042
|
+
useSession: FragnoStoreFactoryData<PiSessionStoreView, [args: PiSessionStoreHookArgs]>;
|
|
1043
|
+
useCreateSession: FragnoClientMutatorData<NonGetHTTPMethod, "/sessions", _standard_schema_spec0.StandardSchemaV1<unknown, unknown> | zod.ZodObject<{
|
|
1044
|
+
agent: zod.ZodString;
|
|
1045
|
+
name: zod.ZodOptional<zod.ZodString>;
|
|
1046
|
+
systemMessage: zod.ZodOptional<zod.ZodString>;
|
|
1047
|
+
metadata: zod.ZodOptional<zod.ZodAny>;
|
|
1048
|
+
tags: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
|
|
1049
|
+
steeringMode: zod.ZodOptional<zod.ZodEnum<{
|
|
1050
|
+
all: "all";
|
|
1051
|
+
"one-at-a-time": "one-at-a-time";
|
|
1052
|
+
}>>;
|
|
1053
|
+
}, zod_v4_core0.$strip> | undefined, zod.ZodObject<{
|
|
1054
|
+
id: zod.ZodString;
|
|
1055
|
+
name: zod.ZodNullable<zod.ZodString>;
|
|
1056
|
+
status: zod.ZodEnum<{
|
|
1057
|
+
active: "active";
|
|
1058
|
+
paused: "paused";
|
|
1059
|
+
errored: "errored";
|
|
1060
|
+
terminated: "terminated";
|
|
1061
|
+
complete: "complete";
|
|
1062
|
+
waiting: "waiting";
|
|
1063
|
+
}>;
|
|
1064
|
+
agent: zod.ZodString;
|
|
1065
|
+
steeringMode: zod.ZodEnum<{
|
|
1066
|
+
all: "all";
|
|
1067
|
+
"one-at-a-time": "one-at-a-time";
|
|
1068
|
+
}>;
|
|
1069
|
+
metadata: zod.ZodNullable<zod.ZodAny>;
|
|
1070
|
+
tags: zod.ZodArray<zod.ZodString>;
|
|
1071
|
+
createdAt: zod.ZodDate;
|
|
1072
|
+
updatedAt: zod.ZodDate;
|
|
1073
|
+
}, zod_v4_core0.$strip> | zod.ZodArray<zod.ZodObject<{
|
|
1074
|
+
id: zod.ZodString;
|
|
1075
|
+
name: zod.ZodNullable<zod.ZodString>;
|
|
1076
|
+
status: zod.ZodEnum<{
|
|
1077
|
+
active: "active";
|
|
1078
|
+
paused: "paused";
|
|
1079
|
+
errored: "errored";
|
|
1080
|
+
terminated: "terminated";
|
|
1081
|
+
complete: "complete";
|
|
1082
|
+
waiting: "waiting";
|
|
1083
|
+
}>;
|
|
1084
|
+
agent: zod.ZodString;
|
|
1085
|
+
steeringMode: zod.ZodEnum<{
|
|
1086
|
+
all: "all";
|
|
1087
|
+
"one-at-a-time": "one-at-a-time";
|
|
1088
|
+
}>;
|
|
1089
|
+
metadata: zod.ZodNullable<zod.ZodAny>;
|
|
1090
|
+
tags: zod.ZodArray<zod.ZodString>;
|
|
1091
|
+
createdAt: zod.ZodDate;
|
|
1092
|
+
updatedAt: zod.ZodDate;
|
|
1093
|
+
}, zod_v4_core0.$strip>> | undefined, string, string>;
|
|
1094
|
+
useActiveSession: FragnoClientHookData<"GET", "/sessions/:sessionId/active", zod.ZodArray<zod.ZodType<PiActiveSessionProtocolMessage, unknown, zod_v4_core0.$ZodTypeInternals<PiActiveSessionProtocolMessage, unknown>>>, "SESSION_NOT_FOUND" | "WORKFLOW_INSTANCE_MISSING", string>;
|
|
1095
|
+
useSendMessage: FragnoClientMutatorData<NonGetHTTPMethod, "/sessions/:sessionId/messages", zod.ZodObject<{
|
|
1096
|
+
text: zod.ZodString;
|
|
1097
|
+
done: zod.ZodOptional<zod.ZodBoolean>;
|
|
1098
|
+
steeringMode: zod.ZodOptional<zod.ZodEnum<{
|
|
1099
|
+
all: "all";
|
|
1100
|
+
"one-at-a-time": "one-at-a-time";
|
|
1101
|
+
}>>;
|
|
1102
|
+
}, zod_v4_core0.$strip> | undefined, zod.ZodObject<{
|
|
1103
|
+
status: zod.ZodEnum<{
|
|
1104
|
+
active: "active";
|
|
1105
|
+
paused: "paused";
|
|
1106
|
+
errored: "errored";
|
|
1107
|
+
terminated: "terminated";
|
|
1108
|
+
complete: "complete";
|
|
1109
|
+
waiting: "waiting";
|
|
1110
|
+
}>;
|
|
1111
|
+
}, zod_v4_core0.$strip> | undefined, "SESSION_NOT_FOUND" | "WORKFLOW_INSTANCE_MISSING" | "SESSION_NOT_READY", string>;
|
|
1112
|
+
};
|
|
1113
|
+
//#endregion
|
|
1114
|
+
//#region src/pi/dsl.d.ts
|
|
1115
|
+
type PiAgentDefinitionInput = Omit<PiAgentDefinition, "name"> & {
|
|
1116
|
+
name?: string;
|
|
1117
|
+
};
|
|
1118
|
+
type PiRuntime = {
|
|
1119
|
+
config: PiFragmentConfig;
|
|
1120
|
+
workflows: PiWorkflowsRegistry;
|
|
1121
|
+
};
|
|
1122
|
+
declare const defineAgent: (name: string, definition: PiAgentDefinitionInput) => PiAgentDefinition;
|
|
1123
|
+
declare const createPi: () => {
|
|
1124
|
+
agent(definition: PiAgentDefinition): /*elided*/any;
|
|
1125
|
+
agents(registry: PiAgentRegistry): /*elided*/any;
|
|
1126
|
+
tool(name: string, tool: PiToolFactory): /*elided*/any;
|
|
1127
|
+
tools(registry: PiToolRegistry): /*elided*/any;
|
|
1128
|
+
toolSideEffectReducer(toolName: string, reducer: PiToolSideEffectReducer): /*elided*/any;
|
|
1129
|
+
toolSideEffectReducers(registry: PiToolSideEffectReducerRegistry): /*elided*/any;
|
|
1130
|
+
defaultSteeringMode(mode: PiSteeringMode): /*elided*/any;
|
|
1131
|
+
logging(config: PiFragmentConfig["logging"]): /*elided*/any;
|
|
1132
|
+
build(): PiRuntime;
|
|
1133
|
+
};
|
|
1134
|
+
//#endregion
|
|
1135
|
+
//#region src/pi/definition.d.ts
|
|
1136
|
+
declare const piFragmentDefinition: _fragno_dev_core0.FragmentDefinition<PiFragmentConfig, _fragno_dev_db0.FragnoPublicConfigWithDatabase, _fragno_dev_db0.ImplicitDatabaseDependencies<_fragno_dev_db_schema0.Schema<Record<"session", _fragno_dev_db_schema0.Table<Record<"id", _fragno_dev_db_schema0.IdColumn<"varchar(128)", string | _fragno_dev_db_schema0.FragnoId | null, _fragno_dev_db_schema0.FragnoId>> & Record<"name", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"agent", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"status", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"steeringMode", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"metadata", _fragno_dev_db_schema0.Column<"json", unknown, unknown>> & Record<"tags", _fragno_dev_db_schema0.Column<"json", unknown, unknown>> & Record<"createdAt", _fragno_dev_db_schema0.Column<"timestamp", (_fragno_dev_db0.DbNow | Date) | null, Date>> & Record<"updatedAt", _fragno_dev_db_schema0.Column<"timestamp", (_fragno_dev_db0.DbNow | Date) | null, Date>>, Record<string, _fragno_dev_db_schema0.AnyRelation>, Record<string, _fragno_dev_db_schema0.Index<_fragno_dev_db_schema0.AnyColumn[], readonly string[]>> & Record<"idx_session_status", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"string", string, string>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["status"]>> & Record<"idx_session_created", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"timestamp", (_fragno_dev_db0.DbNow | Date) | null, Date>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["createdAt"]>>>>>>, {}, {}, {
|
|
1137
|
+
workflows: PiWorkflowsService;
|
|
1138
|
+
}, {}, _fragno_dev_db0.DatabaseServiceContext<_fragno_dev_db0.HooksMap>, _fragno_dev_db0.DatabaseRequestContext<_fragno_dev_db0.HooksMap>, _fragno_dev_db_fragment_definition_builder0.DatabaseRequestStorage, []>;
|
|
1139
|
+
//#endregion
|
|
1140
|
+
//#region src/pi/factory.d.ts
|
|
1141
|
+
type PiFragmentServices = {
|
|
1142
|
+
workflows: PiWorkflowsService;
|
|
1143
|
+
};
|
|
1144
|
+
declare function createPiFragment(config: PiFragmentConfig, options: FragnoPublicConfigWithDatabase, services: PiFragmentServices): _fragno_dev_core0.FragnoInstantiatedFragment<readonly [_fragno_dev_core0.FragnoRouteConfig<"POST", "/sessions", zod.ZodObject<{
|
|
1145
|
+
agent: zod.ZodString;
|
|
1146
|
+
name: zod.ZodOptional<zod.ZodString>;
|
|
1147
|
+
systemMessage: zod.ZodOptional<zod.ZodString>;
|
|
1148
|
+
metadata: zod.ZodOptional<zod.ZodAny>;
|
|
1149
|
+
tags: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
|
|
1150
|
+
steeringMode: zod.ZodOptional<zod.ZodEnum<{
|
|
1151
|
+
all: "all";
|
|
1152
|
+
"one-at-a-time": "one-at-a-time";
|
|
1153
|
+
}>>;
|
|
1154
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
1155
|
+
id: zod.ZodString;
|
|
1156
|
+
name: zod.ZodNullable<zod.ZodString>;
|
|
1157
|
+
status: zod.ZodEnum<{
|
|
1158
|
+
active: "active";
|
|
1159
|
+
paused: "paused";
|
|
1160
|
+
errored: "errored";
|
|
1161
|
+
terminated: "terminated";
|
|
1162
|
+
complete: "complete";
|
|
1163
|
+
waiting: "waiting";
|
|
1164
|
+
}>;
|
|
1165
|
+
agent: zod.ZodString;
|
|
1166
|
+
steeringMode: zod.ZodEnum<{
|
|
1167
|
+
all: "all";
|
|
1168
|
+
"one-at-a-time": "one-at-a-time";
|
|
1169
|
+
}>;
|
|
1170
|
+
metadata: zod.ZodNullable<zod.ZodAny>;
|
|
1171
|
+
tags: zod.ZodArray<zod.ZodString>;
|
|
1172
|
+
createdAt: zod.ZodDate;
|
|
1173
|
+
updatedAt: zod.ZodDate;
|
|
1174
|
+
}, zod_v4_core0.$strip>, "AGENT_NOT_FOUND" | "WORKFLOW_CREATE_FAILED", string, _fragno_dev_db0.DatabaseRequestContext<_fragno_dev_db0.HooksMap>>, _fragno_dev_core0.FragnoRouteConfig<"GET", "/sessions", _standard_schema_spec0.StandardSchemaV1<unknown, unknown> | undefined, zod.ZodArray<zod.ZodObject<{
|
|
1175
|
+
id: zod.ZodString;
|
|
1176
|
+
name: zod.ZodNullable<zod.ZodString>;
|
|
1177
|
+
status: zod.ZodEnum<{
|
|
1178
|
+
active: "active";
|
|
1179
|
+
paused: "paused";
|
|
1180
|
+
errored: "errored";
|
|
1181
|
+
terminated: "terminated";
|
|
1182
|
+
complete: "complete";
|
|
1183
|
+
waiting: "waiting";
|
|
1184
|
+
}>;
|
|
1185
|
+
agent: zod.ZodString;
|
|
1186
|
+
steeringMode: zod.ZodEnum<{
|
|
1187
|
+
all: "all";
|
|
1188
|
+
"one-at-a-time": "one-at-a-time";
|
|
1189
|
+
}>;
|
|
1190
|
+
metadata: zod.ZodNullable<zod.ZodAny>;
|
|
1191
|
+
tags: zod.ZodArray<zod.ZodString>;
|
|
1192
|
+
createdAt: zod.ZodDate;
|
|
1193
|
+
updatedAt: zod.ZodDate;
|
|
1194
|
+
}, zod_v4_core0.$strip>>, string, "limit", _fragno_dev_db0.DatabaseRequestContext<_fragno_dev_db0.HooksMap>>, _fragno_dev_core0.FragnoRouteConfig<"GET", "/sessions/:sessionId", _standard_schema_spec0.StandardSchemaV1<unknown, unknown> | undefined, zod.ZodObject<{
|
|
1195
|
+
id: zod.ZodString;
|
|
1196
|
+
name: zod.ZodNullable<zod.ZodString>;
|
|
1197
|
+
status: zod.ZodEnum<{
|
|
1198
|
+
active: "active";
|
|
1199
|
+
paused: "paused";
|
|
1200
|
+
errored: "errored";
|
|
1201
|
+
terminated: "terminated";
|
|
1202
|
+
complete: "complete";
|
|
1203
|
+
waiting: "waiting";
|
|
1204
|
+
}>;
|
|
1205
|
+
agent: zod.ZodString;
|
|
1206
|
+
steeringMode: zod.ZodEnum<{
|
|
1207
|
+
all: "all";
|
|
1208
|
+
"one-at-a-time": "one-at-a-time";
|
|
1209
|
+
}>;
|
|
1210
|
+
metadata: zod.ZodNullable<zod.ZodAny>;
|
|
1211
|
+
tags: zod.ZodArray<zod.ZodString>;
|
|
1212
|
+
createdAt: zod.ZodDate;
|
|
1213
|
+
updatedAt: zod.ZodDate;
|
|
1214
|
+
workflow: zod.ZodObject<{
|
|
1215
|
+
status: zod.ZodEnum<{
|
|
1216
|
+
active: "active";
|
|
1217
|
+
paused: "paused";
|
|
1218
|
+
errored: "errored";
|
|
1219
|
+
terminated: "terminated";
|
|
1220
|
+
complete: "complete";
|
|
1221
|
+
waiting: "waiting";
|
|
1222
|
+
}>;
|
|
1223
|
+
error: zod.ZodOptional<zod.ZodObject<{
|
|
1224
|
+
name: zod.ZodString;
|
|
1225
|
+
message: zod.ZodString;
|
|
1226
|
+
}, zod_v4_core0.$strip>>;
|
|
1227
|
+
output: zod.ZodOptional<zod.ZodAny>;
|
|
1228
|
+
}, zod_v4_core0.$strip>;
|
|
1229
|
+
messages: zod.ZodArray<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
1230
|
+
role: zod.ZodLiteral<"user">;
|
|
1231
|
+
content: zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
1232
|
+
type: zod.ZodLiteral<"text">;
|
|
1233
|
+
text: zod.ZodString;
|
|
1234
|
+
textSignature: zod.ZodOptional<zod.ZodString>;
|
|
1235
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
1236
|
+
type: zod.ZodLiteral<"image">;
|
|
1237
|
+
data: zod.ZodString;
|
|
1238
|
+
mimeType: zod.ZodString;
|
|
1239
|
+
}, zod_v4_core0.$strip>]>>]>;
|
|
1240
|
+
timestamp: zod.ZodNumber;
|
|
1241
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
1242
|
+
role: zod.ZodLiteral<"assistant">;
|
|
1243
|
+
content: zod.ZodArray<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
1244
|
+
type: zod.ZodLiteral<"text">;
|
|
1245
|
+
text: zod.ZodString;
|
|
1246
|
+
textSignature: zod.ZodOptional<zod.ZodString>;
|
|
1247
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
1248
|
+
type: zod.ZodLiteral<"thinking">;
|
|
1249
|
+
thinking: zod.ZodString;
|
|
1250
|
+
thinkingSignature: zod.ZodOptional<zod.ZodString>;
|
|
1251
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
1252
|
+
type: zod.ZodLiteral<"toolCall">;
|
|
1253
|
+
id: zod.ZodString;
|
|
1254
|
+
name: zod.ZodString;
|
|
1255
|
+
arguments: zod.ZodRecord<zod.ZodString, zod.ZodUnknown>;
|
|
1256
|
+
thoughtSignature: zod.ZodOptional<zod.ZodString>;
|
|
1257
|
+
}, zod_v4_core0.$strip>]>>;
|
|
1258
|
+
api: zod.ZodString;
|
|
1259
|
+
provider: zod.ZodString;
|
|
1260
|
+
model: zod.ZodString;
|
|
1261
|
+
usage: zod.ZodObject<{
|
|
1262
|
+
input: zod.ZodNumber;
|
|
1263
|
+
output: zod.ZodNumber;
|
|
1264
|
+
cacheRead: zod.ZodNumber;
|
|
1265
|
+
cacheWrite: zod.ZodNumber;
|
|
1266
|
+
totalTokens: zod.ZodNumber;
|
|
1267
|
+
cost: zod.ZodObject<{
|
|
1268
|
+
input: zod.ZodNumber;
|
|
1269
|
+
output: zod.ZodNumber;
|
|
1270
|
+
cacheRead: zod.ZodNumber;
|
|
1271
|
+
cacheWrite: zod.ZodNumber;
|
|
1272
|
+
total: zod.ZodNumber;
|
|
1273
|
+
}, zod_v4_core0.$strip>;
|
|
1274
|
+
}, zod_v4_core0.$strip>;
|
|
1275
|
+
stopReason: zod.ZodEnum<{
|
|
1276
|
+
length: "length";
|
|
1277
|
+
error: "error";
|
|
1278
|
+
stop: "stop";
|
|
1279
|
+
toolUse: "toolUse";
|
|
1280
|
+
aborted: "aborted";
|
|
1281
|
+
}>;
|
|
1282
|
+
errorMessage: zod.ZodOptional<zod.ZodString>;
|
|
1283
|
+
timestamp: zod.ZodNumber;
|
|
1284
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
1285
|
+
role: zod.ZodLiteral<"toolResult">;
|
|
1286
|
+
toolCallId: zod.ZodString;
|
|
1287
|
+
toolName: zod.ZodString;
|
|
1288
|
+
content: zod.ZodArray<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
1289
|
+
type: zod.ZodLiteral<"text">;
|
|
1290
|
+
text: zod.ZodString;
|
|
1291
|
+
textSignature: zod.ZodOptional<zod.ZodString>;
|
|
1292
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
1293
|
+
type: zod.ZodLiteral<"image">;
|
|
1294
|
+
data: zod.ZodString;
|
|
1295
|
+
mimeType: zod.ZodString;
|
|
1296
|
+
}, zod_v4_core0.$strip>]>>;
|
|
1297
|
+
details: zod.ZodOptional<zod.ZodUnknown>;
|
|
1298
|
+
isError: zod.ZodBoolean;
|
|
1299
|
+
timestamp: zod.ZodNumber;
|
|
1300
|
+
}, zod_v4_core0.$strip>]>>;
|
|
1301
|
+
events: zod.ZodArray<zod.ZodObject<{
|
|
1302
|
+
id: zod.ZodString;
|
|
1303
|
+
runNumber: zod.ZodOptional<zod.ZodNullable<zod.ZodNumber>>;
|
|
1304
|
+
type: zod.ZodString;
|
|
1305
|
+
payload: zod.ZodNullable<zod.ZodUnknown>;
|
|
1306
|
+
createdAt: zod.ZodDate;
|
|
1307
|
+
deliveredAt: zod.ZodNullable<zod.ZodDate>;
|
|
1308
|
+
consumedByStepKey: zod.ZodNullable<zod.ZodString>;
|
|
1309
|
+
}, zod_v4_core0.$strip>>;
|
|
1310
|
+
trace: zod.ZodArray<zod.ZodType<_mariozechner_pi_agent_core0.AgentEvent, unknown, zod_v4_core0.$ZodTypeInternals<_mariozechner_pi_agent_core0.AgentEvent, unknown>>>;
|
|
1311
|
+
turn: zod.ZodNumber;
|
|
1312
|
+
phase: zod.ZodEnum<{
|
|
1313
|
+
complete: "complete";
|
|
1314
|
+
"waiting-for-user": "waiting-for-user";
|
|
1315
|
+
"running-agent": "running-agent";
|
|
1316
|
+
}>;
|
|
1317
|
+
waitingFor: zod.ZodNullable<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
1318
|
+
type: zod.ZodLiteral<"user_message">;
|
|
1319
|
+
turn: zod.ZodNumber;
|
|
1320
|
+
stepKey: zod.ZodString;
|
|
1321
|
+
timeoutMs: zod.ZodNullable<zod.ZodNumber>;
|
|
1322
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
1323
|
+
type: zod.ZodLiteral<"assistant">;
|
|
1324
|
+
turn: zod.ZodNumber;
|
|
1325
|
+
stepKey: zod.ZodString;
|
|
1326
|
+
}, zod_v4_core0.$strip>]>>;
|
|
1327
|
+
summaries: zod.ZodArray<zod.ZodObject<{
|
|
1328
|
+
turn: zod.ZodNumber;
|
|
1329
|
+
assistant: zod.ZodNullable<zod.ZodAny>;
|
|
1330
|
+
summary: zod.ZodNullable<zod.ZodString>;
|
|
1331
|
+
}, zod_v4_core0.$strip>>;
|
|
1332
|
+
}, zod_v4_core0.$strip>, "SESSION_NOT_FOUND" | "WORKFLOW_INSTANCE_MISSING", "events" | "trace" | "summaries", _fragno_dev_db0.DatabaseRequestContext<_fragno_dev_db0.HooksMap>>, _fragno_dev_core0.FragnoRouteConfig<"GET", "/sessions/:sessionId/active", _standard_schema_spec0.StandardSchemaV1<unknown, unknown> | undefined, zod.ZodArray<zod.ZodType<PiActiveSessionProtocolMessage, unknown, zod_v4_core0.$ZodTypeInternals<PiActiveSessionProtocolMessage, unknown>>>, "SESSION_NOT_FOUND" | "WORKFLOW_INSTANCE_MISSING", string, _fragno_dev_db0.DatabaseRequestContext<_fragno_dev_db0.HooksMap>>, _fragno_dev_core0.FragnoRouteConfig<"POST", "/sessions/:sessionId/messages", zod.ZodObject<{
|
|
1333
|
+
text: zod.ZodString;
|
|
1334
|
+
done: zod.ZodOptional<zod.ZodBoolean>;
|
|
1335
|
+
steeringMode: zod.ZodOptional<zod.ZodEnum<{
|
|
1336
|
+
all: "all";
|
|
1337
|
+
"one-at-a-time": "one-at-a-time";
|
|
1338
|
+
}>>;
|
|
1339
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
1340
|
+
status: zod.ZodEnum<{
|
|
1341
|
+
active: "active";
|
|
1342
|
+
paused: "paused";
|
|
1343
|
+
errored: "errored";
|
|
1344
|
+
terminated: "terminated";
|
|
1345
|
+
complete: "complete";
|
|
1346
|
+
waiting: "waiting";
|
|
1347
|
+
}>;
|
|
1348
|
+
}, zod_v4_core0.$strip>, "SESSION_NOT_FOUND" | "WORKFLOW_INSTANCE_MISSING" | "SESSION_NOT_READY", string, _fragno_dev_db0.DatabaseRequestContext<_fragno_dev_db0.HooksMap>>], _fragno_dev_db0.ImplicitDatabaseDependencies<_fragno_dev_db_schema0.Schema<Record<"session", _fragno_dev_db_schema0.Table<Record<"id", _fragno_dev_db_schema0.IdColumn<"varchar(128)", string | _fragno_dev_db_schema0.FragnoId | null, _fragno_dev_db_schema0.FragnoId>> & Record<"name", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"agent", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"status", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"steeringMode", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"metadata", _fragno_dev_db_schema0.Column<"json", unknown, unknown>> & Record<"tags", _fragno_dev_db_schema0.Column<"json", unknown, unknown>> & Record<"createdAt", _fragno_dev_db_schema0.Column<"timestamp", (_fragno_dev_db0.DbNow | Date) | null, Date>> & Record<"updatedAt", _fragno_dev_db_schema0.Column<"timestamp", (_fragno_dev_db0.DbNow | Date) | null, Date>>, Record<string, _fragno_dev_db_schema0.AnyRelation>, Record<string, _fragno_dev_db_schema0.Index<_fragno_dev_db_schema0.AnyColumn[], readonly string[]>> & Record<"idx_session_status", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"string", string, string>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["status"]>> & Record<"idx_session_created", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"timestamp", (_fragno_dev_db0.DbNow | Date) | null, Date>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["createdAt"]>>>>>>, _fragno_dev_core0.BoundServices<{}>, _fragno_dev_db0.DatabaseServiceContext<_fragno_dev_db0.HooksMap>, _fragno_dev_db0.DatabaseRequestContext<_fragno_dev_db0.HooksMap>, _fragno_dev_db_fragment_definition_builder0.DatabaseRequestStorage, FragnoPublicConfigWithDatabase>;
|
|
1349
|
+
//#endregion
|
|
1350
|
+
//#region src/routes.d.ts
|
|
1351
|
+
declare const piRoutesFactory: _fragno_dev_core0.RouteFactory<PiFragmentConfig, _fragno_dev_db0.ImplicitDatabaseDependencies<_fragno_dev_db_schema0.Schema<Record<"session", _fragno_dev_db_schema0.Table<Record<"id", _fragno_dev_db_schema0.IdColumn<"varchar(128)", string | _fragno_dev_db_schema0.FragnoId | null, _fragno_dev_db_schema0.FragnoId>> & Record<"name", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"agent", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"status", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"steeringMode", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"metadata", _fragno_dev_db_schema0.Column<"json", unknown, unknown>> & Record<"tags", _fragno_dev_db_schema0.Column<"json", unknown, unknown>> & Record<"createdAt", _fragno_dev_db_schema0.Column<"timestamp", (_fragno_dev_db0.DbNow | Date) | null, Date>> & Record<"updatedAt", _fragno_dev_db_schema0.Column<"timestamp", (_fragno_dev_db0.DbNow | Date) | null, Date>>, Record<string, _fragno_dev_db_schema0.AnyRelation>, Record<string, _fragno_dev_db_schema0.Index<_fragno_dev_db_schema0.AnyColumn[], readonly string[]>> & Record<"idx_session_status", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"string", string, string>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["status"]>> & Record<"idx_session_created", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"timestamp", (_fragno_dev_db0.DbNow | Date) | null, Date>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["createdAt"]>>>>>>, _fragno_dev_core0.BoundServices<{}>, {
|
|
1352
|
+
workflows: PiWorkflowsService;
|
|
1353
|
+
}, readonly [_fragno_dev_core0.FragnoRouteConfig<"POST", "/sessions", z.ZodObject<{
|
|
1354
|
+
agent: z.ZodString;
|
|
1355
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1356
|
+
systemMessage: z.ZodOptional<z.ZodString>;
|
|
1357
|
+
metadata: z.ZodOptional<z.ZodAny>;
|
|
1358
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1359
|
+
steeringMode: z.ZodOptional<z.ZodEnum<{
|
|
1360
|
+
all: "all";
|
|
1361
|
+
"one-at-a-time": "one-at-a-time";
|
|
1362
|
+
}>>;
|
|
1363
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1364
|
+
id: z.ZodString;
|
|
1365
|
+
name: z.ZodNullable<z.ZodString>;
|
|
1366
|
+
status: z.ZodEnum<{
|
|
1367
|
+
active: "active";
|
|
1368
|
+
paused: "paused";
|
|
1369
|
+
errored: "errored";
|
|
1370
|
+
terminated: "terminated";
|
|
1371
|
+
complete: "complete";
|
|
1372
|
+
waiting: "waiting";
|
|
1373
|
+
}>;
|
|
1374
|
+
agent: z.ZodString;
|
|
1375
|
+
steeringMode: z.ZodEnum<{
|
|
1376
|
+
all: "all";
|
|
1377
|
+
"one-at-a-time": "one-at-a-time";
|
|
1378
|
+
}>;
|
|
1379
|
+
metadata: z.ZodNullable<z.ZodAny>;
|
|
1380
|
+
tags: z.ZodArray<z.ZodString>;
|
|
1381
|
+
createdAt: z.ZodDate;
|
|
1382
|
+
updatedAt: z.ZodDate;
|
|
1383
|
+
}, z.core.$strip>, "AGENT_NOT_FOUND" | "WORKFLOW_CREATE_FAILED", string, _fragno_dev_db0.DatabaseRequestContext<_fragno_dev_db0.HooksMap>>, _fragno_dev_core0.FragnoRouteConfig<"GET", "/sessions", _standard_schema_spec0.StandardSchemaV1<unknown, unknown> | undefined, z.ZodArray<z.ZodObject<{
|
|
1384
|
+
id: z.ZodString;
|
|
1385
|
+
name: z.ZodNullable<z.ZodString>;
|
|
1386
|
+
status: z.ZodEnum<{
|
|
1387
|
+
active: "active";
|
|
1388
|
+
paused: "paused";
|
|
1389
|
+
errored: "errored";
|
|
1390
|
+
terminated: "terminated";
|
|
1391
|
+
complete: "complete";
|
|
1392
|
+
waiting: "waiting";
|
|
1393
|
+
}>;
|
|
1394
|
+
agent: z.ZodString;
|
|
1395
|
+
steeringMode: z.ZodEnum<{
|
|
1396
|
+
all: "all";
|
|
1397
|
+
"one-at-a-time": "one-at-a-time";
|
|
1398
|
+
}>;
|
|
1399
|
+
metadata: z.ZodNullable<z.ZodAny>;
|
|
1400
|
+
tags: z.ZodArray<z.ZodString>;
|
|
1401
|
+
createdAt: z.ZodDate;
|
|
1402
|
+
updatedAt: z.ZodDate;
|
|
1403
|
+
}, z.core.$strip>>, string, "limit", _fragno_dev_db0.DatabaseRequestContext<_fragno_dev_db0.HooksMap>>, _fragno_dev_core0.FragnoRouteConfig<"GET", "/sessions/:sessionId", _standard_schema_spec0.StandardSchemaV1<unknown, unknown> | undefined, z.ZodObject<{
|
|
1404
|
+
id: z.ZodString;
|
|
1405
|
+
name: z.ZodNullable<z.ZodString>;
|
|
1406
|
+
status: z.ZodEnum<{
|
|
1407
|
+
active: "active";
|
|
1408
|
+
paused: "paused";
|
|
1409
|
+
errored: "errored";
|
|
1410
|
+
terminated: "terminated";
|
|
1411
|
+
complete: "complete";
|
|
1412
|
+
waiting: "waiting";
|
|
1413
|
+
}>;
|
|
1414
|
+
agent: z.ZodString;
|
|
1415
|
+
steeringMode: z.ZodEnum<{
|
|
1416
|
+
all: "all";
|
|
1417
|
+
"one-at-a-time": "one-at-a-time";
|
|
1418
|
+
}>;
|
|
1419
|
+
metadata: z.ZodNullable<z.ZodAny>;
|
|
1420
|
+
tags: z.ZodArray<z.ZodString>;
|
|
1421
|
+
createdAt: z.ZodDate;
|
|
1422
|
+
updatedAt: z.ZodDate;
|
|
1423
|
+
workflow: z.ZodObject<{
|
|
1424
|
+
status: z.ZodEnum<{
|
|
1425
|
+
active: "active";
|
|
1426
|
+
paused: "paused";
|
|
1427
|
+
errored: "errored";
|
|
1428
|
+
terminated: "terminated";
|
|
1429
|
+
complete: "complete";
|
|
1430
|
+
waiting: "waiting";
|
|
1431
|
+
}>;
|
|
1432
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
1433
|
+
name: z.ZodString;
|
|
1434
|
+
message: z.ZodString;
|
|
1435
|
+
}, z.core.$strip>>;
|
|
1436
|
+
output: z.ZodOptional<z.ZodAny>;
|
|
1437
|
+
}, z.core.$strip>;
|
|
1438
|
+
messages: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
1439
|
+
role: z.ZodLiteral<"user">;
|
|
1440
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
1441
|
+
type: z.ZodLiteral<"text">;
|
|
1442
|
+
text: z.ZodString;
|
|
1443
|
+
textSignature: z.ZodOptional<z.ZodString>;
|
|
1444
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1445
|
+
type: z.ZodLiteral<"image">;
|
|
1446
|
+
data: z.ZodString;
|
|
1447
|
+
mimeType: z.ZodString;
|
|
1448
|
+
}, z.core.$strip>]>>]>;
|
|
1449
|
+
timestamp: z.ZodNumber;
|
|
1450
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1451
|
+
role: z.ZodLiteral<"assistant">;
|
|
1452
|
+
content: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
1453
|
+
type: z.ZodLiteral<"text">;
|
|
1454
|
+
text: z.ZodString;
|
|
1455
|
+
textSignature: z.ZodOptional<z.ZodString>;
|
|
1456
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1457
|
+
type: z.ZodLiteral<"thinking">;
|
|
1458
|
+
thinking: z.ZodString;
|
|
1459
|
+
thinkingSignature: z.ZodOptional<z.ZodString>;
|
|
1460
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1461
|
+
type: z.ZodLiteral<"toolCall">;
|
|
1462
|
+
id: z.ZodString;
|
|
1463
|
+
name: z.ZodString;
|
|
1464
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1465
|
+
thoughtSignature: z.ZodOptional<z.ZodString>;
|
|
1466
|
+
}, z.core.$strip>]>>;
|
|
1467
|
+
api: z.ZodString;
|
|
1468
|
+
provider: z.ZodString;
|
|
1469
|
+
model: z.ZodString;
|
|
1470
|
+
usage: z.ZodObject<{
|
|
1471
|
+
input: z.ZodNumber;
|
|
1472
|
+
output: z.ZodNumber;
|
|
1473
|
+
cacheRead: z.ZodNumber;
|
|
1474
|
+
cacheWrite: z.ZodNumber;
|
|
1475
|
+
totalTokens: z.ZodNumber;
|
|
1476
|
+
cost: z.ZodObject<{
|
|
1477
|
+
input: z.ZodNumber;
|
|
1478
|
+
output: z.ZodNumber;
|
|
1479
|
+
cacheRead: z.ZodNumber;
|
|
1480
|
+
cacheWrite: z.ZodNumber;
|
|
1481
|
+
total: z.ZodNumber;
|
|
1482
|
+
}, z.core.$strip>;
|
|
1483
|
+
}, z.core.$strip>;
|
|
1484
|
+
stopReason: z.ZodEnum<{
|
|
1485
|
+
length: "length";
|
|
1486
|
+
error: "error";
|
|
1487
|
+
stop: "stop";
|
|
1488
|
+
toolUse: "toolUse";
|
|
1489
|
+
aborted: "aborted";
|
|
1490
|
+
}>;
|
|
1491
|
+
errorMessage: z.ZodOptional<z.ZodString>;
|
|
1492
|
+
timestamp: z.ZodNumber;
|
|
1493
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1494
|
+
role: z.ZodLiteral<"toolResult">;
|
|
1495
|
+
toolCallId: z.ZodString;
|
|
1496
|
+
toolName: z.ZodString;
|
|
1497
|
+
content: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
1498
|
+
type: z.ZodLiteral<"text">;
|
|
1499
|
+
text: z.ZodString;
|
|
1500
|
+
textSignature: z.ZodOptional<z.ZodString>;
|
|
1501
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1502
|
+
type: z.ZodLiteral<"image">;
|
|
1503
|
+
data: z.ZodString;
|
|
1504
|
+
mimeType: z.ZodString;
|
|
1505
|
+
}, z.core.$strip>]>>;
|
|
1506
|
+
details: z.ZodOptional<z.ZodUnknown>;
|
|
1507
|
+
isError: z.ZodBoolean;
|
|
1508
|
+
timestamp: z.ZodNumber;
|
|
1509
|
+
}, z.core.$strip>]>>;
|
|
1510
|
+
events: z.ZodArray<z.ZodObject<{
|
|
1511
|
+
id: z.ZodString;
|
|
1512
|
+
runNumber: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1513
|
+
type: z.ZodString;
|
|
1514
|
+
payload: z.ZodNullable<z.ZodUnknown>;
|
|
1515
|
+
createdAt: z.ZodDate;
|
|
1516
|
+
deliveredAt: z.ZodNullable<z.ZodDate>;
|
|
1517
|
+
consumedByStepKey: z.ZodNullable<z.ZodString>;
|
|
1518
|
+
}, z.core.$strip>>;
|
|
1519
|
+
trace: z.ZodArray<z.ZodType<_mariozechner_pi_agent_core0.AgentEvent, unknown, z.core.$ZodTypeInternals<_mariozechner_pi_agent_core0.AgentEvent, unknown>>>;
|
|
1520
|
+
turn: z.ZodNumber;
|
|
1521
|
+
phase: z.ZodEnum<{
|
|
1522
|
+
complete: "complete";
|
|
1523
|
+
"waiting-for-user": "waiting-for-user";
|
|
1524
|
+
"running-agent": "running-agent";
|
|
1525
|
+
}>;
|
|
1526
|
+
waitingFor: z.ZodNullable<z.ZodUnion<readonly [z.ZodObject<{
|
|
1527
|
+
type: z.ZodLiteral<"user_message">;
|
|
1528
|
+
turn: z.ZodNumber;
|
|
1529
|
+
stepKey: z.ZodString;
|
|
1530
|
+
timeoutMs: z.ZodNullable<z.ZodNumber>;
|
|
1531
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1532
|
+
type: z.ZodLiteral<"assistant">;
|
|
1533
|
+
turn: z.ZodNumber;
|
|
1534
|
+
stepKey: z.ZodString;
|
|
1535
|
+
}, z.core.$strip>]>>;
|
|
1536
|
+
summaries: z.ZodArray<z.ZodObject<{
|
|
1537
|
+
turn: z.ZodNumber;
|
|
1538
|
+
assistant: z.ZodNullable<z.ZodAny>;
|
|
1539
|
+
summary: z.ZodNullable<z.ZodString>;
|
|
1540
|
+
}, z.core.$strip>>;
|
|
1541
|
+
}, z.core.$strip>, "SESSION_NOT_FOUND" | "WORKFLOW_INSTANCE_MISSING", "events" | "trace" | "summaries", _fragno_dev_db0.DatabaseRequestContext<_fragno_dev_db0.HooksMap>>, _fragno_dev_core0.FragnoRouteConfig<"GET", "/sessions/:sessionId/active", _standard_schema_spec0.StandardSchemaV1<unknown, unknown> | undefined, z.ZodArray<z.ZodType<PiActiveSessionProtocolMessage, unknown, z.core.$ZodTypeInternals<PiActiveSessionProtocolMessage, unknown>>>, "SESSION_NOT_FOUND" | "WORKFLOW_INSTANCE_MISSING", string, _fragno_dev_db0.DatabaseRequestContext<_fragno_dev_db0.HooksMap>>, _fragno_dev_core0.FragnoRouteConfig<"POST", "/sessions/:sessionId/messages", z.ZodObject<{
|
|
1542
|
+
text: z.ZodString;
|
|
1543
|
+
done: z.ZodOptional<z.ZodBoolean>;
|
|
1544
|
+
steeringMode: z.ZodOptional<z.ZodEnum<{
|
|
1545
|
+
all: "all";
|
|
1546
|
+
"one-at-a-time": "one-at-a-time";
|
|
1547
|
+
}>>;
|
|
1548
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1549
|
+
status: z.ZodEnum<{
|
|
1550
|
+
active: "active";
|
|
1551
|
+
paused: "paused";
|
|
1552
|
+
errored: "errored";
|
|
1553
|
+
terminated: "terminated";
|
|
1554
|
+
complete: "complete";
|
|
1555
|
+
waiting: "waiting";
|
|
1556
|
+
}>;
|
|
1557
|
+
}, z.core.$strip>, "SESSION_NOT_FOUND" | "WORKFLOW_INSTANCE_MISSING" | "SESSION_NOT_READY", string, _fragno_dev_db0.DatabaseRequestContext<_fragno_dev_db0.HooksMap>>]>;
|
|
1558
|
+
//#endregion
|
|
1559
|
+
export { InferOr as $, PiToolFactoryContext as A, PiWorkflowsService as B, PiFragmentConfig as C, PiSession as D, PiPersistedToolResult as E, PiToolSideEffectReducerContext as F, PiSteeringMode as G, PiWorkflowsRegistry as H, PiToolSideEffectReducerRegistry as I, THINKING_LEVELS as J, SESSION_STATUSES as K, PiTurnSummary as L, PiToolReplayCache as M, PiToolReplayContext as N, PiSessionDetail as O, PiToolSideEffectReducer as P, FragnoClientError as Q, PiWorkflowHistoryStep as R, PiAgentRegistry as S, PiPersistedToolCallSource as T, createPiWorkflows as U, PI_WORKFLOW_NAME as V, PiSessionStatus as W, FetcherValue as X, FragnoStoreFactoryData as Y, NonGetHTTPMethod as Z, createPiSessionStore as _, PiRuntime as a, PiActiveSessionStreamItem as b, PiFragmentClientConfig as c, PiSessionStoreView as d, ExtractPathParamsOrWiden as et, CreatePiSessionStoreArgs as f, PiSessionStoreState as g, PiSessionStoreController as h, PiAgentDefinitionInput as i, PiToolRegistry as j, PiToolFactory as k, createPiFragmentClients as l, PiSessionConnectionState as m, createPiFragment as n, MaybeExtractPathParamsOrWiden as nt, createPi as o, PiLiveToolExecution as p, STEERING_MODES as q, piFragmentDefinition as r, QueryParamsHint as rt, defineAgent as s, piRoutesFactory as t, HasPathParams as tt, PiSessionStoreHookArgs as u, PI_TOOL_JOURNAL_VERSION as v, PiPersistedToolCall as w, PiAgentDefinition as x, PiActiveSessionProtocolMessage as y, PiWorkflowsInstanceStatus as z };
|
|
1560
|
+
//# sourceMappingURL=routes-CpL_YGWK.d.ts.map
|