@voltro/ai 0.1.0
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/CHANGELOG.md +52 -0
- package/LICENSE +57 -0
- package/README.md +26 -0
- package/SECURITY.md +56 -0
- package/THIRD-PARTY-NOTICES.md +929 -0
- package/dist/agent.d.ts +101 -0
- package/dist/agent.js +2 -0
- package/dist/agentDescriptor-DCd4F9zj.js +45 -0
- package/dist/events.d.ts +122 -0
- package/dist/events.js +54 -0
- package/dist/index.d.ts +1996 -0
- package/dist/index.js +1263 -0
- package/dist/provider-BOC5wBxx.js +294 -0
- package/dist/test.d.ts +125 -0
- package/dist/test.js +40 -0
- package/package.json +64 -0
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ActionProcedureDescriptor } from '@voltro/protocol';
|
|
2
|
+
import { QueryProcedureDescriptor } from '@voltro/protocol';
|
|
3
|
+
import { Schema } from 'effect';
|
|
4
|
+
|
|
5
|
+
declare const AGENT_DESCRIPTOR_BRAND: "@voltro/ai/AgentDescriptor";
|
|
6
|
+
|
|
7
|
+
declare const AGENT_DESCRIPTOR_SYMBOL: unique symbol;
|
|
8
|
+
|
|
9
|
+
export declare interface AgentDescriptor<S extends Schema.Schema.Any = DefaultAgentInputSchema> {
|
|
10
|
+
readonly [AGENT_DESCRIPTOR_SYMBOL]: true;
|
|
11
|
+
readonly _brand: typeof AGENT_DESCRIPTOR_BRAND;
|
|
12
|
+
/** Wire id → rpc tags `<name>.send` / `<name>.messages`. */
|
|
13
|
+
readonly name: string;
|
|
14
|
+
/** Input schema (default `{ prompt: string }`). The send route's wire input
|
|
15
|
+
* extends this with `{ threadId, order }`. */
|
|
16
|
+
readonly input?: S;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The decoded input an agent's executor sees, derived from its schema. */
|
|
20
|
+
export declare type AgentInput<S extends Schema.Schema.Any> = Schema.Schema.Type<S>;
|
|
21
|
+
|
|
22
|
+
/** The agent's input schema (default `{ prompt: string }`). */
|
|
23
|
+
export declare const agentInputSchema: (desc: AnyAgentDescriptor) => Schema.Schema.Any;
|
|
24
|
+
|
|
25
|
+
export declare const agentMessageSchema: Schema.Struct<{
|
|
26
|
+
id: typeof Schema.String;
|
|
27
|
+
threadId: typeof Schema.String;
|
|
28
|
+
role: typeof Schema.String;
|
|
29
|
+
content: typeof Schema.String;
|
|
30
|
+
streaming: typeof Schema.Boolean;
|
|
31
|
+
order: typeof Schema.Number;
|
|
32
|
+
stepOrder: typeof Schema.Number;
|
|
33
|
+
parts: Schema.Array$<Schema.TypeLiteral<{
|
|
34
|
+
type: typeof Schema.String;
|
|
35
|
+
}, readonly [{
|
|
36
|
+
readonly key: typeof Schema.String;
|
|
37
|
+
readonly value: typeof Schema.Unknown;
|
|
38
|
+
}]>>;
|
|
39
|
+
}>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The two browser-safe route descriptors synthesized for an agent. The SAME
|
|
43
|
+
* source the runtime synthesis (`agentSynthesis.ts`) and codegen both consume,
|
|
44
|
+
* so "what the server serves" and "what the client is typed for" can't drift.
|
|
45
|
+
*/
|
|
46
|
+
export declare const agentRouteDescriptors: (desc: AnyAgentDescriptor) => {
|
|
47
|
+
send: ActionProcedureDescriptor<`${string}.send`, Schema.Schema.Any, Schema.Struct<{
|
|
48
|
+
text: typeof Schema.String;
|
|
49
|
+
}>, typeof Schema.Never>;
|
|
50
|
+
messages: QueryProcedureDescriptor<`${string}.messages`, Schema.Struct<{
|
|
51
|
+
threadId: typeof Schema.String;
|
|
52
|
+
}>, Schema.Array$<Schema.Struct<{
|
|
53
|
+
id: typeof Schema.String;
|
|
54
|
+
threadId: typeof Schema.String;
|
|
55
|
+
role: typeof Schema.String;
|
|
56
|
+
content: typeof Schema.String;
|
|
57
|
+
streaming: typeof Schema.Boolean;
|
|
58
|
+
order: typeof Schema.Number;
|
|
59
|
+
stepOrder: typeof Schema.Number;
|
|
60
|
+
parts: Schema.Array$<Schema.TypeLiteral<{
|
|
61
|
+
type: typeof Schema.String;
|
|
62
|
+
}, readonly [{
|
|
63
|
+
readonly key: typeof Schema.String;
|
|
64
|
+
readonly value: typeof Schema.Unknown;
|
|
65
|
+
}]>>;
|
|
66
|
+
}>>, typeof Schema.Never>;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/** A descriptor of any input shape — for the type-erased runtime helpers. */
|
|
70
|
+
export declare type AnyAgentDescriptor = AgentDescriptor<Schema.Schema.Any>;
|
|
71
|
+
|
|
72
|
+
declare const DEFAULT_INPUT: Schema.Struct<{
|
|
73
|
+
prompt: typeof Schema.String;
|
|
74
|
+
}>;
|
|
75
|
+
|
|
76
|
+
/** Default input schema type when `input` is omitted (`{ prompt: string }`). */
|
|
77
|
+
export declare type DefaultAgentInputSchema = typeof DEFAULT_INPUT;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Declare an agent's browser-safe wire contract: its `name` and `input`
|
|
81
|
+
* schema. The decoded input type is inferred from the schema (like
|
|
82
|
+
* `defineQuery`). Behaviour (system prompt, tools, model + key, maxSteps) lives
|
|
83
|
+
* in the paired `*.agent.server.tsx` via `defineAgentExecutor`.
|
|
84
|
+
*
|
|
85
|
+
* ```ts
|
|
86
|
+
* // support.agent.tsx (browser-safe descriptor)
|
|
87
|
+
* export const support = defineAgent({
|
|
88
|
+
* name: 'support',
|
|
89
|
+
* input: Schema.Struct({ prompt: Schema.String, locale: Schema.optional(Schema.String) }),
|
|
90
|
+
* })
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare const defineAgent: <S extends Schema.Schema.Any = DefaultAgentInputSchema>(config: {
|
|
94
|
+
readonly name: string;
|
|
95
|
+
readonly input?: S;
|
|
96
|
+
}) => AgentDescriptor<S>;
|
|
97
|
+
|
|
98
|
+
/** Discovery predicate for `*.agent.tsx` exports. */
|
|
99
|
+
export declare const isAgentDescriptor: (x: unknown) => x is AnyAgentDescriptor;
|
|
100
|
+
|
|
101
|
+
export { }
|
package/dist/agent.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Schema as e } from "effect";
|
|
2
|
+
import { defineAction as t, defineQuery as n } from "@voltro/protocol";
|
|
3
|
+
//#region src/agentConstants.ts
|
|
4
|
+
var r = "agent_threads", i = "agent_messages", a = e.Struct({ prompt: e.String }), o = "@voltro/ai/AgentDescriptor", s = Symbol.for("@voltro/ai/AgentDescriptor"), c = (e) => ({
|
|
5
|
+
[s]: !0,
|
|
6
|
+
_brand: o,
|
|
7
|
+
name: e.name,
|
|
8
|
+
...e.input === void 0 ? {} : { input: e.input }
|
|
9
|
+
}), l = (e) => typeof e == "object" && !!e && e._brand === o, u = (e) => e.input ?? a, d = e.Struct({ type: e.String }, {
|
|
10
|
+
key: e.String,
|
|
11
|
+
value: e.Unknown
|
|
12
|
+
}), f = e.Struct({
|
|
13
|
+
id: e.String,
|
|
14
|
+
threadId: e.String,
|
|
15
|
+
role: e.String,
|
|
16
|
+
content: e.String,
|
|
17
|
+
streaming: e.Boolean,
|
|
18
|
+
order: e.Number,
|
|
19
|
+
stepOrder: e.Number,
|
|
20
|
+
parts: e.Array(d)
|
|
21
|
+
}), p = (t) => {
|
|
22
|
+
let n = u(t), r = e.Struct({
|
|
23
|
+
threadId: e.String,
|
|
24
|
+
order: e.Number
|
|
25
|
+
});
|
|
26
|
+
try {
|
|
27
|
+
return e.extend(n, r);
|
|
28
|
+
} catch {
|
|
29
|
+
return r;
|
|
30
|
+
}
|
|
31
|
+
}, m = (r) => ({
|
|
32
|
+
send: t({
|
|
33
|
+
name: `${r.name}.send`,
|
|
34
|
+
input: p(r),
|
|
35
|
+
output: e.Struct({ text: e.String })
|
|
36
|
+
}),
|
|
37
|
+
messages: n({
|
|
38
|
+
name: `${r.name}.messages`,
|
|
39
|
+
input: e.Struct({ threadId: e.String }),
|
|
40
|
+
output: e.Array(f),
|
|
41
|
+
source: i
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
//#endregion
|
|
45
|
+
export { l as a, c as i, f as n, i as o, m as r, r as s, u as t };
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
|
|
3
|
+
/** Error taxonomy. `retryable` on the event drives client/agent retry. */
|
|
4
|
+
export declare const AgentErrorCode: Schema.Literal<["provider", "tool", "timeout", "cancelled", "decode", "internal"]>;
|
|
5
|
+
|
|
6
|
+
export declare type AgentErrorCode = typeof AgentErrorCode.Type;
|
|
7
|
+
|
|
8
|
+
export declare const AgentEvent: Schema.Union<[Schema.Struct<{
|
|
9
|
+
_tag: Schema.Literal<["token"]>;
|
|
10
|
+
text: typeof Schema.String;
|
|
11
|
+
}>, Schema.Struct<{
|
|
12
|
+
_tag: Schema.Literal<["reasoning"]>;
|
|
13
|
+
text: typeof Schema.String;
|
|
14
|
+
}>, Schema.Struct<{
|
|
15
|
+
_tag: Schema.Literal<["toolCall"]>;
|
|
16
|
+
id: typeof Schema.String;
|
|
17
|
+
name: typeof Schema.String;
|
|
18
|
+
input: typeof Schema.Unknown;
|
|
19
|
+
}>, Schema.Struct<{
|
|
20
|
+
_tag: Schema.Literal<["toolResult"]>;
|
|
21
|
+
id: typeof Schema.String;
|
|
22
|
+
name: typeof Schema.String;
|
|
23
|
+
output: Schema.optional<typeof Schema.Unknown>;
|
|
24
|
+
error: Schema.optional<typeof Schema.String>;
|
|
25
|
+
}>, Schema.Struct<{
|
|
26
|
+
_tag: Schema.Literal<["source"]>;
|
|
27
|
+
sourceType: Schema.Literal<["url", "document"]>;
|
|
28
|
+
id: typeof Schema.String;
|
|
29
|
+
url: Schema.optional<typeof Schema.String>;
|
|
30
|
+
title: Schema.optional<typeof Schema.String>;
|
|
31
|
+
mediaType: Schema.optional<typeof Schema.String>;
|
|
32
|
+
filename: Schema.optional<typeof Schema.String>;
|
|
33
|
+
}>, Schema.Struct<{
|
|
34
|
+
_tag: Schema.Literal<["file"]>;
|
|
35
|
+
mediaType: typeof Schema.String;
|
|
36
|
+
data: typeof Schema.String;
|
|
37
|
+
}>, Schema.Struct<{
|
|
38
|
+
_tag: Schema.Literal<["message"]>;
|
|
39
|
+
role: typeof Schema.String;
|
|
40
|
+
content: typeof Schema.String;
|
|
41
|
+
}>, Schema.Struct<{
|
|
42
|
+
_tag: Schema.Literal<["error"]>;
|
|
43
|
+
code: Schema.Literal<["provider", "tool", "timeout", "cancelled", "decode", "internal"]>;
|
|
44
|
+
message: typeof Schema.String;
|
|
45
|
+
retryable: typeof Schema.Boolean;
|
|
46
|
+
}>, Schema.Struct<{
|
|
47
|
+
_tag: Schema.Literal<["done"]>;
|
|
48
|
+
finishReason: typeof Schema.String;
|
|
49
|
+
usage: Schema.Struct<{
|
|
50
|
+
inputTokens: Schema.optional<typeof Schema.Number>;
|
|
51
|
+
outputTokens: Schema.optional<typeof Schema.Number>;
|
|
52
|
+
totalTokens: Schema.optional<typeof Schema.Number>;
|
|
53
|
+
}>;
|
|
54
|
+
}>]>;
|
|
55
|
+
|
|
56
|
+
export declare type AgentEvent = typeof AgentEvent.Type;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* One persisted event of a RESUMABLE stream: an `AgentEvent` plus its monotonic
|
|
60
|
+
* 1-based position. `seq` is the resume cursor — a client that has rendered up
|
|
61
|
+
* to `seq=N` reconnects with `fromSeq: N` and gets `N+1…` replayed, then live.
|
|
62
|
+
*
|
|
63
|
+
* This is the WIRE element for a resumable `defineStream` (`element: SeqEvent`).
|
|
64
|
+
* It lives here — next to `AgentEvent`, with ZERO server imports — so a
|
|
65
|
+
* browser-loaded stream descriptor can reference the Schema without dragging
|
|
66
|
+
* the server-only resumable-stream store graph (`@voltro/database`) into the
|
|
67
|
+
* client bundle.
|
|
68
|
+
*/
|
|
69
|
+
export declare const SeqEvent: Schema.Struct<{
|
|
70
|
+
seq: typeof Schema.Number;
|
|
71
|
+
event: Schema.Union<[Schema.Struct<{
|
|
72
|
+
_tag: Schema.Literal<["token"]>;
|
|
73
|
+
text: typeof Schema.String;
|
|
74
|
+
}>, Schema.Struct<{
|
|
75
|
+
_tag: Schema.Literal<["reasoning"]>;
|
|
76
|
+
text: typeof Schema.String;
|
|
77
|
+
}>, Schema.Struct<{
|
|
78
|
+
_tag: Schema.Literal<["toolCall"]>;
|
|
79
|
+
id: typeof Schema.String;
|
|
80
|
+
name: typeof Schema.String;
|
|
81
|
+
input: typeof Schema.Unknown;
|
|
82
|
+
}>, Schema.Struct<{
|
|
83
|
+
_tag: Schema.Literal<["toolResult"]>;
|
|
84
|
+
id: typeof Schema.String;
|
|
85
|
+
name: typeof Schema.String;
|
|
86
|
+
output: Schema.optional<typeof Schema.Unknown>;
|
|
87
|
+
error: Schema.optional<typeof Schema.String>;
|
|
88
|
+
}>, Schema.Struct<{
|
|
89
|
+
_tag: Schema.Literal<["source"]>;
|
|
90
|
+
sourceType: Schema.Literal<["url", "document"]>;
|
|
91
|
+
id: typeof Schema.String;
|
|
92
|
+
url: Schema.optional<typeof Schema.String>;
|
|
93
|
+
title: Schema.optional<typeof Schema.String>;
|
|
94
|
+
mediaType: Schema.optional<typeof Schema.String>;
|
|
95
|
+
filename: Schema.optional<typeof Schema.String>;
|
|
96
|
+
}>, Schema.Struct<{
|
|
97
|
+
_tag: Schema.Literal<["file"]>;
|
|
98
|
+
mediaType: typeof Schema.String;
|
|
99
|
+
data: typeof Schema.String;
|
|
100
|
+
}>, Schema.Struct<{
|
|
101
|
+
_tag: Schema.Literal<["message"]>;
|
|
102
|
+
role: typeof Schema.String;
|
|
103
|
+
content: typeof Schema.String;
|
|
104
|
+
}>, Schema.Struct<{
|
|
105
|
+
_tag: Schema.Literal<["error"]>;
|
|
106
|
+
code: Schema.Literal<["provider", "tool", "timeout", "cancelled", "decode", "internal"]>;
|
|
107
|
+
message: typeof Schema.String;
|
|
108
|
+
retryable: typeof Schema.Boolean;
|
|
109
|
+
}>, Schema.Struct<{
|
|
110
|
+
_tag: Schema.Literal<["done"]>;
|
|
111
|
+
finishReason: typeof Schema.String;
|
|
112
|
+
usage: Schema.Struct<{
|
|
113
|
+
inputTokens: Schema.optional<typeof Schema.Number>;
|
|
114
|
+
outputTokens: Schema.optional<typeof Schema.Number>;
|
|
115
|
+
totalTokens: Schema.optional<typeof Schema.Number>;
|
|
116
|
+
}>;
|
|
117
|
+
}>]>;
|
|
118
|
+
}>;
|
|
119
|
+
|
|
120
|
+
export declare type SeqEvent = typeof SeqEvent.Type;
|
|
121
|
+
|
|
122
|
+
export { }
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Schema as e } from "effect";
|
|
2
|
+
//#region src/agentEvent.ts
|
|
3
|
+
var t = e.Literal("provider", "tool", "timeout", "cancelled", "decode", "internal"), n = e.Struct({
|
|
4
|
+
inputTokens: e.optional(e.Number),
|
|
5
|
+
outputTokens: e.optional(e.Number),
|
|
6
|
+
totalTokens: e.optional(e.Number)
|
|
7
|
+
}), r = e.Union(e.Struct({
|
|
8
|
+
_tag: e.Literal("token"),
|
|
9
|
+
text: e.String
|
|
10
|
+
}), e.Struct({
|
|
11
|
+
_tag: e.Literal("reasoning"),
|
|
12
|
+
text: e.String
|
|
13
|
+
}), e.Struct({
|
|
14
|
+
_tag: e.Literal("toolCall"),
|
|
15
|
+
id: e.String,
|
|
16
|
+
name: e.String,
|
|
17
|
+
input: e.Unknown
|
|
18
|
+
}), e.Struct({
|
|
19
|
+
_tag: e.Literal("toolResult"),
|
|
20
|
+
id: e.String,
|
|
21
|
+
name: e.String,
|
|
22
|
+
output: e.optional(e.Unknown),
|
|
23
|
+
error: e.optional(e.String)
|
|
24
|
+
}), e.Struct({
|
|
25
|
+
_tag: e.Literal("source"),
|
|
26
|
+
sourceType: e.Literal("url", "document"),
|
|
27
|
+
id: e.String,
|
|
28
|
+
url: e.optional(e.String),
|
|
29
|
+
title: e.optional(e.String),
|
|
30
|
+
mediaType: e.optional(e.String),
|
|
31
|
+
filename: e.optional(e.String)
|
|
32
|
+
}), e.Struct({
|
|
33
|
+
_tag: e.Literal("file"),
|
|
34
|
+
mediaType: e.String,
|
|
35
|
+
data: e.String
|
|
36
|
+
}), e.Struct({
|
|
37
|
+
_tag: e.Literal("message"),
|
|
38
|
+
role: e.String,
|
|
39
|
+
content: e.String
|
|
40
|
+
}), e.Struct({
|
|
41
|
+
_tag: e.Literal("error"),
|
|
42
|
+
code: t,
|
|
43
|
+
message: e.String,
|
|
44
|
+
retryable: e.Boolean
|
|
45
|
+
}), e.Struct({
|
|
46
|
+
_tag: e.Literal("done"),
|
|
47
|
+
finishReason: e.String,
|
|
48
|
+
usage: n
|
|
49
|
+
})), i = e.Struct({
|
|
50
|
+
seq: e.Number,
|
|
51
|
+
event: r
|
|
52
|
+
});
|
|
53
|
+
//#endregion
|
|
54
|
+
export { t as AgentErrorCode, r as AgentEvent, i as SeqEvent };
|