veryfront 0.1.469 → 0.1.471
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/esm/deno.js +1 -1
- package/esm/src/agent/hosted-chat-execution-runtime.d.ts +35 -0
- package/esm/src/agent/hosted-chat-execution-runtime.d.ts.map +1 -1
- package/esm/src/agent/hosted-chat-execution-runtime.js +76 -8
- package/esm/src/agent/index.d.ts +2 -2
- package/esm/src/agent/index.d.ts.map +1 -1
- package/esm/src/agent/index.js +2 -2
- package/esm/src/agent/runtime-agent-definition.d.ts +11 -0
- package/esm/src/agent/runtime-agent-definition.d.ts.map +1 -1
- package/esm/src/agent/runtime-agent-definition.js +50 -0
- package/esm/src/chat/stream-watchdog.js +4 -2
- package/esm/src/server/index.d.ts +2 -1
- package/esm/src/server/index.d.ts.map +1 -1
- package/esm/src/server/index.js +3 -43
- package/esm/src/server/node-handler.d.ts +2 -0
- package/esm/src/server/node-handler.d.ts.map +1 -0
- package/esm/src/server/node-handler.js +43 -0
- package/esm/src/server/service-server.d.ts +43 -0
- package/esm/src/server/service-server.d.ts.map +1 -0
- package/esm/src/server/service-server.js +116 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
- package/src/deno.js +1 -1
- package/src/deps/esm.sh/@types/react-dom@19.2.3/client.d.ts +1 -1
- package/src/deps/esm.sh/@types/{react@19.2.14 → react@19.2.3}/global.d.ts +0 -1
- package/src/deps/esm.sh/@types/{react@19.2.14 → react@19.2.3}/index.d.ts +24 -93
- package/src/deps/esm.sh/react-dom@19.2.4/client.d.ts +1 -1
- package/src/src/agent/hosted-chat-execution-runtime.ts +134 -13
- package/src/src/agent/index.ts +6 -0
- package/src/src/agent/runtime-agent-definition.ts +77 -0
- package/src/src/chat/stream-watchdog.ts +5 -2
- package/src/src/server/index.ts +13 -41
- package/src/src/server/node-handler.ts +42 -0
- package/src/src/server/service-server.ts +187 -0
- package/src/src/utils/version-constant.ts +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type VeryfrontServiceServerFetch = (request: Request) => Response | Promise<Response>;
|
|
2
|
+
export type VeryfrontServiceServerModuleResponse = Response | null | undefined;
|
|
3
|
+
export type VeryfrontServiceServerModule = {
|
|
4
|
+
name: string;
|
|
5
|
+
handle: (request: Request) => VeryfrontServiceServerModuleResponse | Promise<VeryfrontServiceServerModuleResponse>;
|
|
6
|
+
setShuttingDown?: () => void;
|
|
7
|
+
stop?: () => void | Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
export type VeryfrontServiceServerLogger = {
|
|
10
|
+
debug?: (message: string, metadata?: Record<string, unknown>) => void;
|
|
11
|
+
info?: (message: string, metadata?: Record<string, unknown>) => void;
|
|
12
|
+
warn?: (message: string, metadata?: Record<string, unknown>) => void;
|
|
13
|
+
error?: (message: string, metadata?: Record<string, unknown>) => void;
|
|
14
|
+
};
|
|
15
|
+
export type CreateVeryfrontServerOptions = {
|
|
16
|
+
modules: readonly VeryfrontServiceServerModule[];
|
|
17
|
+
notFound?: (request: Request) => Response | Promise<Response>;
|
|
18
|
+
onError?: (error: unknown, request: Request) => Response | Promise<Response>;
|
|
19
|
+
logger?: VeryfrontServiceServerLogger;
|
|
20
|
+
};
|
|
21
|
+
export type VeryfrontServiceServerRuntime = {
|
|
22
|
+
fetch: VeryfrontServiceServerFetch;
|
|
23
|
+
setShuttingDown: () => void;
|
|
24
|
+
stop: () => Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
export type StartNodeVeryfrontServerOptions = {
|
|
27
|
+
runtime: VeryfrontServiceServerRuntime;
|
|
28
|
+
port: number;
|
|
29
|
+
bindAddress?: string;
|
|
30
|
+
logger?: VeryfrontServiceServerLogger;
|
|
31
|
+
signals?: readonly NodeJS.Signals[];
|
|
32
|
+
hardShutdownTimeoutMs?: number;
|
|
33
|
+
};
|
|
34
|
+
export type NodeVeryfrontServiceServer = {
|
|
35
|
+
server: import("node:http").Server;
|
|
36
|
+
ready: Promise<void>;
|
|
37
|
+
stop: () => Promise<void>;
|
|
38
|
+
port: number;
|
|
39
|
+
url: string;
|
|
40
|
+
};
|
|
41
|
+
export declare function createVeryfrontServer(options: CreateVeryfrontServerOptions): VeryfrontServiceServerRuntime;
|
|
42
|
+
export declare function startNodeVeryfrontServer(options: StartNodeVeryfrontServerOptions): Promise<NodeVeryfrontServiceServer>;
|
|
43
|
+
//# sourceMappingURL=service-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-server.d.ts","sourceRoot":"","sources":["../../../src/src/server/service-server.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,2BAA2B,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC7F,MAAM,MAAM,oCAAoC,GAAG,QAAQ,GAAG,IAAI,GAAG,SAAS,CAAC;AAE/E,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,CACN,OAAO,EAAE,OAAO,KACb,oCAAoC,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;IAC1F,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACtE,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACrE,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACrE,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACvE,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,OAAO,EAAE,SAAS,4BAA4B,EAAE,CAAC;IACjD,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7E,MAAM,CAAC,EAAE,4BAA4B,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,KAAK,EAAE,2BAA2B,CAAC;IACnC,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,OAAO,EAAE,6BAA6B,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,4BAA4B,CAAC;IACtC,OAAO,CAAC,EAAE,SAAS,MAAM,CAAC,OAAO,EAAE,CAAC;IACpC,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,MAAM,EAAE,OAAO,WAAW,EAAE,MAAM,CAAC;IACnC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAkBF,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,4BAA4B,GACpC,6BAA6B,CAgC/B;AAeD,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,0BAA0B,CAAC,CAkErC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import * as dntShim from "../../_dnt.shims.js";
|
|
2
|
+
import { serverLogger } from "../utils/index.js";
|
|
3
|
+
import { toNodeHandler } from "./node-handler.js";
|
|
4
|
+
function defaultNotFound() {
|
|
5
|
+
return new Response("Not Found", { status: 404 });
|
|
6
|
+
}
|
|
7
|
+
function defaultErrorResponse(error, request, logger) {
|
|
8
|
+
logger.error?.("Veryfront service request failed", {
|
|
9
|
+
url: request.url,
|
|
10
|
+
error: error instanceof Error ? error.message : String(error),
|
|
11
|
+
});
|
|
12
|
+
return new Response("Internal Server Error", { status: 500 });
|
|
13
|
+
}
|
|
14
|
+
export function createVeryfrontServer(options) {
|
|
15
|
+
const logger = options.logger ?? serverLogger.component("service-server");
|
|
16
|
+
const notFound = options.notFound ?? defaultNotFound;
|
|
17
|
+
const onError = options.onError ??
|
|
18
|
+
((error, request) => defaultErrorResponse(error, request, logger));
|
|
19
|
+
return {
|
|
20
|
+
fetch: async (request) => {
|
|
21
|
+
try {
|
|
22
|
+
for (const module of options.modules) {
|
|
23
|
+
const response = await module.handle(request);
|
|
24
|
+
if (response) {
|
|
25
|
+
return response;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return await notFound(request);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
return await onError(error, request);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
setShuttingDown: () => {
|
|
35
|
+
for (const module of options.modules) {
|
|
36
|
+
module.setShuttingDown?.();
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
stop: async () => {
|
|
40
|
+
for (const module of options.modules) {
|
|
41
|
+
await module.stop?.();
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function closeNodeServer(server) {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
server.close((error) => {
|
|
49
|
+
if (error) {
|
|
50
|
+
reject(error);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
resolve();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export async function startNodeVeryfrontServer(options) {
|
|
58
|
+
const { createServer } = await import("node:http");
|
|
59
|
+
const logger = options.logger ?? serverLogger.component("service-server");
|
|
60
|
+
const bindAddress = options.bindAddress ?? "0.0.0.0";
|
|
61
|
+
const hardShutdownTimeoutMs = options.hardShutdownTimeoutMs ?? 20_000;
|
|
62
|
+
const server = createServer(toNodeHandler(options.runtime.fetch));
|
|
63
|
+
let shutdownStarted = false;
|
|
64
|
+
const stop = async () => {
|
|
65
|
+
if (shutdownStarted) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
shutdownStarted = true;
|
|
69
|
+
options.runtime.setShuttingDown();
|
|
70
|
+
await closeNodeServer(server);
|
|
71
|
+
await options.runtime.stop();
|
|
72
|
+
};
|
|
73
|
+
const ready = new Promise((resolve, reject) => {
|
|
74
|
+
server.once("error", reject);
|
|
75
|
+
server.listen(options.port, bindAddress, () => {
|
|
76
|
+
server.off("error", reject);
|
|
77
|
+
logger.info?.("Veryfront service server listening", {
|
|
78
|
+
port: options.port,
|
|
79
|
+
bindAddress,
|
|
80
|
+
});
|
|
81
|
+
resolve();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
for (const signal of options.signals ?? ["SIGTERM"]) {
|
|
85
|
+
process.on(signal, () => {
|
|
86
|
+
if (shutdownStarted) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
logger.info?.("Veryfront service server received shutdown signal", { signal });
|
|
90
|
+
const hardTimeout = dntShim.setTimeout(() => {
|
|
91
|
+
logger.error?.("Veryfront service server graceful shutdown timed out", { signal });
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}, hardShutdownTimeoutMs);
|
|
94
|
+
void stop()
|
|
95
|
+
.then(() => {
|
|
96
|
+
clearTimeout(hardTimeout);
|
|
97
|
+
process.exit(0);
|
|
98
|
+
})
|
|
99
|
+
.catch((error) => {
|
|
100
|
+
clearTimeout(hardTimeout);
|
|
101
|
+
logger.error?.("Veryfront service server shutdown failed", {
|
|
102
|
+
signal,
|
|
103
|
+
error: error instanceof Error ? error.message : String(error),
|
|
104
|
+
});
|
|
105
|
+
process.exit(1);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
server,
|
|
111
|
+
ready,
|
|
112
|
+
stop,
|
|
113
|
+
port: options.port,
|
|
114
|
+
url: `http://${bindAddress}:${options.port}`,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.471";
|
|
2
2
|
//# sourceMappingURL=version-constant.d.ts.map
|
package/package.json
CHANGED
package/src/deno.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
// See https://github.com/facebook/react/blob/main/packages/react-dom/client.js to see how the exports are declared,
|
|
6
6
|
|
|
7
|
-
import React = require("https://esm.sh/@types/react@19.2.
|
|
7
|
+
import React = require("https://esm.sh/@types/react@19.2.3/index.d.ts");
|
|
8
8
|
|
|
9
9
|
export {};
|
|
10
10
|
|
|
@@ -18,7 +18,6 @@ interface KeyboardEvent extends Event {}
|
|
|
18
18
|
interface MouseEvent extends Event {}
|
|
19
19
|
interface TouchEvent extends Event {}
|
|
20
20
|
interface PointerEvent extends Event {}
|
|
21
|
-
interface SubmitEvent extends Event {}
|
|
22
21
|
interface ToggleEvent extends Event {}
|
|
23
22
|
interface TransitionEvent extends Event {}
|
|
24
23
|
interface UIEvent extends Event {}
|
|
@@ -16,7 +16,6 @@ type NativeKeyboardEvent = KeyboardEvent;
|
|
|
16
16
|
type NativeMouseEvent = MouseEvent;
|
|
17
17
|
type NativeTouchEvent = TouchEvent;
|
|
18
18
|
type NativePointerEvent = PointerEvent;
|
|
19
|
-
type NativeSubmitEvent = SubmitEvent;
|
|
20
19
|
type NativeToggleEvent = ToggleEvent;
|
|
21
20
|
type NativeTransitionEvent = TransitionEvent;
|
|
22
21
|
type NativeUIEvent = UIEvent;
|
|
@@ -226,20 +225,12 @@ declare namespace React {
|
|
|
226
225
|
|
|
227
226
|
type ComponentState = any;
|
|
228
227
|
|
|
229
|
-
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES {}
|
|
230
|
-
|
|
231
228
|
/**
|
|
232
229
|
* A value which uniquely identifies a node among items in an array.
|
|
233
230
|
*
|
|
234
231
|
* @see {@link https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key React Docs}
|
|
235
232
|
*/
|
|
236
|
-
type Key =
|
|
237
|
-
| string
|
|
238
|
-
| number
|
|
239
|
-
| bigint
|
|
240
|
-
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES[
|
|
241
|
-
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES
|
|
242
|
-
];
|
|
233
|
+
type Key = string | number | bigint;
|
|
243
234
|
|
|
244
235
|
/**
|
|
245
236
|
* @internal The props any component can receive.
|
|
@@ -1893,7 +1884,7 @@ declare namespace React {
|
|
|
1893
1884
|
*
|
|
1894
1885
|
* @param callback A synchronous, void callback that will execute as a single, complete React commit.
|
|
1895
1886
|
*
|
|
1896
|
-
* @see
|
|
1887
|
+
* @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
|
|
1897
1888
|
*/
|
|
1898
1889
|
// NOTES
|
|
1899
1890
|
// - the order of these signatures matters - typescript will check the signatures in source order.
|
|
@@ -1935,31 +1926,7 @@ declare namespace React {
|
|
|
1935
1926
|
reducer: (state: State, action: Action) => State,
|
|
1936
1927
|
): [State, (action: Action) => void];
|
|
1937
1928
|
|
|
1938
|
-
|
|
1939
|
-
status?: void;
|
|
1940
|
-
}
|
|
1941
|
-
|
|
1942
|
-
export interface PendingReactPromise<T> extends PromiseLike<T> {
|
|
1943
|
-
status: "pending";
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
|
-
export interface FulfilledReactPromise<T> extends PromiseLike<T> {
|
|
1947
|
-
status: "fulfilled";
|
|
1948
|
-
value: T;
|
|
1949
|
-
}
|
|
1950
|
-
|
|
1951
|
-
export interface RejectedReactPromise<T> extends PromiseLike<T> {
|
|
1952
|
-
status: "rejected";
|
|
1953
|
-
reason: unknown;
|
|
1954
|
-
}
|
|
1955
|
-
|
|
1956
|
-
export type ReactPromise<T> =
|
|
1957
|
-
| UntrackedReactPromise<T>
|
|
1958
|
-
| PendingReactPromise<T>
|
|
1959
|
-
| FulfilledReactPromise<T>
|
|
1960
|
-
| RejectedReactPromise<T>;
|
|
1961
|
-
|
|
1962
|
-
export type Usable<T> = ReactPromise<T> | Context<T>;
|
|
1929
|
+
export type Usable<T> = PromiseLike<T> | Context<T>;
|
|
1963
1930
|
|
|
1964
1931
|
export function use<T>(usable: Usable<T>): T;
|
|
1965
1932
|
|
|
@@ -2074,28 +2041,15 @@ declare namespace React {
|
|
|
2074
2041
|
target: EventTarget & Target;
|
|
2075
2042
|
}
|
|
2076
2043
|
|
|
2077
|
-
/**
|
|
2078
|
-
* @deprecated FormEvent doesn't actually exist.
|
|
2079
|
-
* You probably meant to use {@link ChangeEvent}, {@link InputEvent}, {@link SubmitEvent}, or just {@link SyntheticEvent} instead
|
|
2080
|
-
* depending on the event type.
|
|
2081
|
-
*/
|
|
2082
2044
|
interface FormEvent<T = Element> extends SyntheticEvent<T> {
|
|
2083
2045
|
}
|
|
2084
2046
|
|
|
2085
2047
|
interface InvalidEvent<T = Element> extends SyntheticEvent<T> {
|
|
2048
|
+
target: EventTarget & T;
|
|
2086
2049
|
}
|
|
2087
2050
|
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
* Only for form elements we know their target type because form events can't
|
|
2091
|
-
* be nested.
|
|
2092
|
-
* This type exists purely to narrow `target` for form elements. It doesn't
|
|
2093
|
-
* reflect a DOM event. Change events are just fired as standard {@link SyntheticEvent}.
|
|
2094
|
-
*/
|
|
2095
|
-
interface ChangeEvent<CurrentTarget = Element, Target = Element> extends SyntheticEvent<CurrentTarget> {
|
|
2096
|
-
// TODO: This is wrong for change event handlers on arbitrary. Should
|
|
2097
|
-
// be EventTarget & Target, but kept for backward compatibility until React 20.
|
|
2098
|
-
target: EventTarget & CurrentTarget;
|
|
2051
|
+
interface ChangeEvent<T = Element> extends SyntheticEvent<T> {
|
|
2052
|
+
target: EventTarget & T;
|
|
2099
2053
|
}
|
|
2100
2054
|
|
|
2101
2055
|
interface InputEvent<T = Element> extends SyntheticEvent<T, NativeInputEvent> {
|
|
@@ -2165,13 +2119,6 @@ declare namespace React {
|
|
|
2165
2119
|
shiftKey: boolean;
|
|
2166
2120
|
}
|
|
2167
2121
|
|
|
2168
|
-
interface SubmitEvent<T = Element> extends SyntheticEvent<T, NativeSubmitEvent> {
|
|
2169
|
-
// `submitter` is available in react@canary
|
|
2170
|
-
// submitter: HTMLElement | null;
|
|
2171
|
-
// SubmitEvents are always targetted at HTMLFormElements.
|
|
2172
|
-
target: EventTarget & HTMLFormElement;
|
|
2173
|
-
}
|
|
2174
|
-
|
|
2175
2122
|
interface TouchEvent<T = Element> extends UIEvent<T, NativeTouchEvent> {
|
|
2176
2123
|
altKey: boolean;
|
|
2177
2124
|
changedTouches: TouchList;
|
|
@@ -2227,19 +2174,11 @@ declare namespace React {
|
|
|
2227
2174
|
type CompositionEventHandler<T = Element> = EventHandler<CompositionEvent<T>>;
|
|
2228
2175
|
type DragEventHandler<T = Element> = EventHandler<DragEvent<T>>;
|
|
2229
2176
|
type FocusEventHandler<T = Element> = EventHandler<FocusEvent<T>>;
|
|
2230
|
-
/**
|
|
2231
|
-
* @deprecated FormEventHandler doesn't actually exist.
|
|
2232
|
-
* You probably meant to use {@link ChangeEventHandler}, {@link InputEventHandler}, {@link SubmitEventHandler}, or just {@link EventHandler} instead
|
|
2233
|
-
* depending on the event type.
|
|
2234
|
-
*/
|
|
2235
2177
|
type FormEventHandler<T = Element> = EventHandler<FormEvent<T>>;
|
|
2236
|
-
type ChangeEventHandler<
|
|
2237
|
-
ChangeEvent<CurrentTarget, Target>
|
|
2238
|
-
>;
|
|
2178
|
+
type ChangeEventHandler<T = Element> = EventHandler<ChangeEvent<T>>;
|
|
2239
2179
|
type InputEventHandler<T = Element> = EventHandler<InputEvent<T>>;
|
|
2240
2180
|
type KeyboardEventHandler<T = Element> = EventHandler<KeyboardEvent<T>>;
|
|
2241
2181
|
type MouseEventHandler<T = Element> = EventHandler<MouseEvent<T>>;
|
|
2242
|
-
type SubmitEventHandler<T = Element> = EventHandler<SubmitEvent<T>>;
|
|
2243
2182
|
type TouchEventHandler<T = Element> = EventHandler<TouchEvent<T>>;
|
|
2244
2183
|
type PointerEventHandler<T = Element> = EventHandler<PointerEvent<T>>;
|
|
2245
2184
|
type UIEventHandler<T = Element> = EventHandler<UIEvent<T>>;
|
|
@@ -2293,19 +2232,19 @@ declare namespace React {
|
|
|
2293
2232
|
onBlur?: FocusEventHandler<T> | undefined;
|
|
2294
2233
|
onBlurCapture?: FocusEventHandler<T> | undefined;
|
|
2295
2234
|
|
|
2296
|
-
//
|
|
2297
|
-
onChange?:
|
|
2298
|
-
onChangeCapture?:
|
|
2235
|
+
// Form Events
|
|
2236
|
+
onChange?: FormEventHandler<T> | undefined;
|
|
2237
|
+
onChangeCapture?: FormEventHandler<T> | undefined;
|
|
2299
2238
|
onBeforeInput?: InputEventHandler<T> | undefined;
|
|
2300
|
-
onBeforeInputCapture?:
|
|
2301
|
-
onInput?:
|
|
2302
|
-
onInputCapture?:
|
|
2303
|
-
onReset?:
|
|
2304
|
-
onResetCapture?:
|
|
2305
|
-
onSubmit?:
|
|
2306
|
-
onSubmitCapture?:
|
|
2307
|
-
onInvalid?:
|
|
2308
|
-
onInvalidCapture?:
|
|
2239
|
+
onBeforeInputCapture?: FormEventHandler<T> | undefined;
|
|
2240
|
+
onInput?: FormEventHandler<T> | undefined;
|
|
2241
|
+
onInputCapture?: FormEventHandler<T> | undefined;
|
|
2242
|
+
onReset?: FormEventHandler<T> | undefined;
|
|
2243
|
+
onResetCapture?: FormEventHandler<T> | undefined;
|
|
2244
|
+
onSubmit?: FormEventHandler<T> | undefined;
|
|
2245
|
+
onSubmitCapture?: FormEventHandler<T> | undefined;
|
|
2246
|
+
onInvalid?: FormEventHandler<T> | undefined;
|
|
2247
|
+
onInvalidCapture?: FormEventHandler<T> | undefined;
|
|
2309
2248
|
|
|
2310
2249
|
// Image Events
|
|
2311
2250
|
onLoad?: ReactEventHandler<T> | undefined;
|
|
@@ -2849,7 +2788,7 @@ declare namespace React {
|
|
|
2849
2788
|
|
|
2850
2789
|
// Living Standard
|
|
2851
2790
|
/**
|
|
2852
|
-
* @see
|
|
2791
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert
|
|
2853
2792
|
*/
|
|
2854
2793
|
inert?: boolean | undefined;
|
|
2855
2794
|
/**
|
|
@@ -3312,9 +3251,7 @@ declare namespace React {
|
|
|
3312
3251
|
value?: string | readonly string[] | number | undefined;
|
|
3313
3252
|
width?: number | string | undefined;
|
|
3314
3253
|
|
|
3315
|
-
|
|
3316
|
-
// so we know the target will be a HTMLInputElement.
|
|
3317
|
-
onChange?: ChangeEventHandler<T, HTMLInputElement> | undefined;
|
|
3254
|
+
onChange?: ChangeEventHandler<T> | undefined;
|
|
3318
3255
|
}
|
|
3319
3256
|
|
|
3320
3257
|
interface KeygenHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
@@ -3479,9 +3416,7 @@ declare namespace React {
|
|
|
3479
3416
|
required?: boolean | undefined;
|
|
3480
3417
|
size?: number | undefined;
|
|
3481
3418
|
value?: string | readonly string[] | number | undefined;
|
|
3482
|
-
|
|
3483
|
-
// so we know the target will be a HTMLSelectElement.
|
|
3484
|
-
onChange?: ChangeEventHandler<T, HTMLSelectElement> | undefined;
|
|
3419
|
+
onChange?: ChangeEventHandler<T> | undefined;
|
|
3485
3420
|
}
|
|
3486
3421
|
|
|
3487
3422
|
interface SourceHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
@@ -3533,9 +3468,7 @@ declare namespace React {
|
|
|
3533
3468
|
value?: string | readonly string[] | number | undefined;
|
|
3534
3469
|
wrap?: string | undefined;
|
|
3535
3470
|
|
|
3536
|
-
|
|
3537
|
-
// so we know the target will be a HTMLTextAreaElement.
|
|
3538
|
-
onChange?: ChangeEventHandler<T, HTMLTextAreaElement> | undefined;
|
|
3471
|
+
onChange?: ChangeEventHandler<T> | undefined;
|
|
3539
3472
|
}
|
|
3540
3473
|
|
|
3541
3474
|
interface TdHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
@@ -3607,9 +3540,6 @@ declare namespace React {
|
|
|
3607
3540
|
method?: string | undefined;
|
|
3608
3541
|
min?: number | string | undefined;
|
|
3609
3542
|
name?: string | undefined;
|
|
3610
|
-
nonce?: string | undefined;
|
|
3611
|
-
part?: string | undefined;
|
|
3612
|
-
slot?: string | undefined;
|
|
3613
3543
|
style?: CSSProperties | undefined;
|
|
3614
3544
|
target?: string | undefined;
|
|
3615
3545
|
type?: string | undefined;
|
|
@@ -4127,6 +4057,7 @@ declare namespace React {
|
|
|
4127
4057
|
* Captures which component contained the exception, and its ancestors.
|
|
4128
4058
|
*/
|
|
4129
4059
|
componentStack?: string | null;
|
|
4060
|
+
digest?: string | null;
|
|
4130
4061
|
}
|
|
4131
4062
|
|
|
4132
4063
|
// Keep in sync with JSX namespace in ./jsx-runtime.d.ts and ./jsx-dev-runtime.d.ts
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
// See https://github.com/facebook/react/blob/main/packages/react-dom/client.js to see how the exports are declared,
|
|
6
6
|
|
|
7
|
-
import React = require("https://esm.sh/@types/react@19.2.
|
|
7
|
+
import React = require("https://esm.sh/@types/react@19.2.3/index.d.ts");
|
|
8
8
|
|
|
9
9
|
export {};
|
|
10
10
|
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import * as dntShim from "../../_dnt.shims.js";
|
|
2
1
|
import {
|
|
3
2
|
buildChatStreamChunkMessageMetadata,
|
|
4
3
|
extractChatMessageMetadata,
|
|
5
4
|
} from "../chat/chat-ui-message-helpers.js";
|
|
6
5
|
import { getLastStreamStep } from "../chat/final-step-fallback.js";
|
|
7
6
|
import type { ChatUiMessage, ChatUiMessageChunk, MessageMetadata } from "../chat/types.js";
|
|
7
|
+
import type { HostedConversationRootRunContext } from "./conversation-root-run-lifecycle.js";
|
|
8
|
+
import {
|
|
9
|
+
createHostedAgentRunSpanController,
|
|
10
|
+
createHostedRootRunLifecycleRuntimeAdapter,
|
|
11
|
+
type CreateHostedRootRunLifecycleRuntimeAdapterInput,
|
|
12
|
+
type HostedAgentRunSpanController,
|
|
13
|
+
type HostedAgentRunTracer,
|
|
14
|
+
} from "./hosted-agent-run-lifecycle.js";
|
|
8
15
|
import {
|
|
9
16
|
buildDetachedFallbackChunks,
|
|
10
17
|
buildDetachedFallbackMessageState,
|
|
@@ -112,6 +119,44 @@ export interface CreateHostedChatExecutionRuntimeInput {
|
|
|
112
119
|
incompleteToolCallsPartErrorText?: string;
|
|
113
120
|
}
|
|
114
121
|
|
|
122
|
+
export interface CreateBootstrappedHostedChatExecutionRuntimeInput {
|
|
123
|
+
authToken: string;
|
|
124
|
+
apiUrl: string;
|
|
125
|
+
agent: HostedChatRuntimeAgent;
|
|
126
|
+
agentId: string;
|
|
127
|
+
modelId: string;
|
|
128
|
+
cleanup: () => Promise<void>;
|
|
129
|
+
messages: ChatUiMessage[];
|
|
130
|
+
finalMessages: HostedChatRuntimeStreamInput["messages"];
|
|
131
|
+
conversationId?: string;
|
|
132
|
+
projectId: string | null;
|
|
133
|
+
userId: string;
|
|
134
|
+
rootRunContext: HostedConversationRootRunContext;
|
|
135
|
+
abortSignal: AbortSignal;
|
|
136
|
+
responseMessageId?: string;
|
|
137
|
+
upstreamParentConversationId?: string;
|
|
138
|
+
upstreamParentRunId?: string;
|
|
139
|
+
spawnedFromToolCallId?: string;
|
|
140
|
+
tracer: HostedAgentRunTracer;
|
|
141
|
+
resolveProvider: (modelId: string) => string;
|
|
142
|
+
traceStream?: CreateHostedChatExecutionRuntimeBootstrapInput["traceStream"];
|
|
143
|
+
logger?: HostedChatExecutionRuntimeLogger;
|
|
144
|
+
spanName?: string;
|
|
145
|
+
terminalErrorCode?: string;
|
|
146
|
+
incompleteToolCallsPartErrorText?: string;
|
|
147
|
+
createRootStreamWatchdog?: CreateHostedChatExecutionRuntimeBootstrapInput[
|
|
148
|
+
"createRootStreamWatchdog"
|
|
149
|
+
];
|
|
150
|
+
createTerminalAdapter?: CreateHostedRootRunLifecycleRuntimeAdapterInput[
|
|
151
|
+
"createTerminalAdapter"
|
|
152
|
+
];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface BootstrappedHostedChatExecutionRuntime {
|
|
156
|
+
agentRunSpan: HostedAgentRunSpanController;
|
|
157
|
+
execution: HostedChatExecutionRuntime;
|
|
158
|
+
}
|
|
159
|
+
|
|
115
160
|
type SharedFinalizationHooks = Pick<
|
|
116
161
|
FinalizeHostedResponseOptions<ChatUiMessage, ChatUiMessageChunk<MessageMetadata>>,
|
|
117
162
|
| "resolveEmptyTerminalError"
|
|
@@ -157,10 +202,7 @@ function createHostedChatExecutionCleanup(cleanup: () => Promise<void>): () => P
|
|
|
157
202
|
}
|
|
158
203
|
|
|
159
204
|
function createDefaultHostedChatExecutionRootStreamWatchdog(): HostedChatExecutionRootStreamWatchdog {
|
|
160
|
-
return createChatStreamWatchdog(
|
|
161
|
-
setTimeoutFn: dntShim.dntGlobalThis["setTimeout"],
|
|
162
|
-
clearTimeoutFn: globalThis["clearTimeout"],
|
|
163
|
-
});
|
|
205
|
+
return createChatStreamWatchdog();
|
|
164
206
|
}
|
|
165
207
|
|
|
166
208
|
function traceHostedChatRuntimeStream<T>(
|
|
@@ -188,14 +230,20 @@ export async function createHostedChatExecutionRuntimeBootstrap(
|
|
|
188
230
|
: createDefaultHostedChatExecutionRootStreamWatchdog();
|
|
189
231
|
const streamAbortSignal = AbortSignal.any([input.abortSignal, rootStreamWatchdog.signal]);
|
|
190
232
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
(
|
|
194
|
-
input.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
233
|
+
let streamResult: HostedChatRuntimeStreamResult;
|
|
234
|
+
try {
|
|
235
|
+
streamResult = await traceHostedChatRuntimeStream(
|
|
236
|
+
input.traceStream,
|
|
237
|
+
() =>
|
|
238
|
+
input.agent.stream({
|
|
239
|
+
messages: input.finalMessages,
|
|
240
|
+
abortSignal: streamAbortSignal,
|
|
241
|
+
}),
|
|
242
|
+
);
|
|
243
|
+
} catch (error) {
|
|
244
|
+
rootStreamWatchdog.dispose();
|
|
245
|
+
throw error;
|
|
246
|
+
}
|
|
199
247
|
|
|
200
248
|
return {
|
|
201
249
|
cleanup,
|
|
@@ -209,6 +257,79 @@ export async function createHostedChatExecutionRuntimeBootstrap(
|
|
|
209
257
|
};
|
|
210
258
|
}
|
|
211
259
|
|
|
260
|
+
async function createBootstrappedHostedChatRuntime(
|
|
261
|
+
input: CreateBootstrappedHostedChatExecutionRuntimeInput,
|
|
262
|
+
agentRunSpan: HostedAgentRunSpanController,
|
|
263
|
+
): Promise<HostedChatExecutionRuntime> {
|
|
264
|
+
const lifecycleAdapter = createHostedRootRunLifecycleRuntimeAdapter({
|
|
265
|
+
authToken: input.authToken,
|
|
266
|
+
apiUrl: input.apiUrl,
|
|
267
|
+
modelId: input.modelId,
|
|
268
|
+
durableRootRun: input.rootRunContext.durableRootRun,
|
|
269
|
+
durableRunMirror: input.rootRunContext.durableRunMirror,
|
|
270
|
+
agentRunSpan,
|
|
271
|
+
resolveProvider: input.resolveProvider,
|
|
272
|
+
...(input.createTerminalAdapter ? { createTerminalAdapter: input.createTerminalAdapter } : {}),
|
|
273
|
+
});
|
|
274
|
+
const bootstrap = await createHostedChatExecutionRuntimeBootstrap({
|
|
275
|
+
agent: input.agent,
|
|
276
|
+
cleanup: input.cleanup,
|
|
277
|
+
lifecycleAdapter,
|
|
278
|
+
finalMessages: input.finalMessages,
|
|
279
|
+
conversationId: input.conversationId,
|
|
280
|
+
abortSignal: input.abortSignal,
|
|
281
|
+
traceStream: input.traceStream,
|
|
282
|
+
...(input.createRootStreamWatchdog
|
|
283
|
+
? { createRootStreamWatchdog: input.createRootStreamWatchdog }
|
|
284
|
+
: {}),
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
return createHostedChatExecutionRuntime({
|
|
288
|
+
agentId: input.agentId,
|
|
289
|
+
modelId: input.modelId,
|
|
290
|
+
originalMessages: input.messages,
|
|
291
|
+
responseMessageId: input.responseMessageId,
|
|
292
|
+
runContext: agentRunSpan,
|
|
293
|
+
abortSignal: input.abortSignal,
|
|
294
|
+
bootstrap,
|
|
295
|
+
logger: input.logger,
|
|
296
|
+
incompleteToolCallsPartErrorText: input.incompleteToolCallsPartErrorText,
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export async function createBootstrappedHostedChatExecutionRuntime(
|
|
301
|
+
input: CreateBootstrappedHostedChatExecutionRuntimeInput,
|
|
302
|
+
): Promise<BootstrappedHostedChatExecutionRuntime> {
|
|
303
|
+
const agentRunSpan = createHostedAgentRunSpanController({
|
|
304
|
+
tracer: input.tracer,
|
|
305
|
+
spanName: input.spanName,
|
|
306
|
+
operationName: "chat",
|
|
307
|
+
conversationId: input.conversationId,
|
|
308
|
+
projectId: input.projectId,
|
|
309
|
+
userId: input.userId,
|
|
310
|
+
agentId: input.agentId,
|
|
311
|
+
rootRun: input.rootRunContext.durableRootRun,
|
|
312
|
+
upstreamParentConversationId: input.upstreamParentConversationId,
|
|
313
|
+
upstreamParentRunId: input.upstreamParentRunId,
|
|
314
|
+
spawnedFromToolCallId: input.spawnedFromToolCallId,
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
try {
|
|
318
|
+
const execution = await agentRunSpan.withContext(() =>
|
|
319
|
+
createBootstrappedHostedChatRuntime(input, agentRunSpan)
|
|
320
|
+
);
|
|
321
|
+
return { agentRunSpan, execution };
|
|
322
|
+
} catch (error) {
|
|
323
|
+
agentRunSpan.finalize({
|
|
324
|
+
status: "failed",
|
|
325
|
+
modelId: input.modelId,
|
|
326
|
+
terminalErrorCode: input.terminalErrorCode ?? "STREAM_ERROR",
|
|
327
|
+
terminalErrorMessage: error instanceof Error ? error.message : String(error),
|
|
328
|
+
});
|
|
329
|
+
throw error;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
212
333
|
export function createHostedChatStreamFinalizationHooks(input: {
|
|
213
334
|
lifecycleAdapter: HostedChatExecutionLifecycleAdapter;
|
|
214
335
|
cleanup: () => Promise<void>;
|
package/src/src/agent/index.ts
CHANGED
|
@@ -174,6 +174,9 @@ export {
|
|
|
174
174
|
} from "./hosted-child-fork-tool-sources.js";
|
|
175
175
|
|
|
176
176
|
export {
|
|
177
|
+
createRuntimeAgentSystemMessages,
|
|
178
|
+
type CreateRuntimeAgentSystemMessagesInput,
|
|
179
|
+
DEFAULT_RUNTIME_AGENT_CONTEXT_MARKER,
|
|
177
180
|
parseRuntimeAgentMarkdownDefinition,
|
|
178
181
|
type ParseRuntimeAgentMarkdownDefinitionInput,
|
|
179
182
|
parseRuntimeAgentMarkdownDefinitionInputSchema,
|
|
@@ -1022,7 +1025,10 @@ export {
|
|
|
1022
1025
|
type FinalizedMessageState,
|
|
1023
1026
|
} from "./hosted-finalized-message.js";
|
|
1024
1027
|
export {
|
|
1028
|
+
type BootstrappedHostedChatExecutionRuntime,
|
|
1025
1029
|
cleanupAfterHostedChatExecutionFinalization,
|
|
1030
|
+
createBootstrappedHostedChatExecutionRuntime,
|
|
1031
|
+
type CreateBootstrappedHostedChatExecutionRuntimeInput,
|
|
1026
1032
|
createHostedChatExecutionRuntime,
|
|
1027
1033
|
createHostedChatExecutionRuntimeBootstrap,
|
|
1028
1034
|
type CreateHostedChatExecutionRuntimeBootstrapInput,
|