@valon-technologies/gestalt 0.0.1-alpha.18 → 0.0.1-alpha.19
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 +34 -12
- package/package.json +5 -3
- package/src/agent-conversions.ts +201 -0
- package/src/agent-manager.ts +272 -83
- package/src/agent.ts +1023 -224
- package/src/api.ts +42 -0
- package/src/auth.ts +3 -3
- package/src/authorization.ts +1700 -51
- package/src/cache.ts +3 -3
- package/src/catalog.ts +22 -0
- package/src/http-subject.ts +9 -2
- package/src/index.ts +191 -17
- package/src/indexeddb.ts +3 -15
- package/src/internal/gen/v1/agent_pb.ts +137 -51
- package/src/internal/gen/v1/authorization_pb.ts +505 -27
- package/src/internal/gen/v1/plugin_pb.ts +67 -21
- package/src/internal/gen/v1/pluginruntime_pb.ts +95 -6
- package/src/internal/gen/v1/workflow_pb.ts +344 -62
- package/src/invoker.ts +6 -35
- package/src/plugin.ts +12 -12
- package/src/pluginruntime.ts +337 -49
- package/src/protocol/v1.ts +19 -0
- package/src/protocol-internal.ts +19 -0
- package/src/protocol.ts +183 -0
- package/src/provider-kind.ts +7 -3
- package/src/provider.ts +21 -13
- package/src/runtime-log-host.ts +80 -52
- package/src/runtime.ts +67 -0
- package/src/s3.ts +13 -28
- package/src/secrets.ts +3 -3
- package/src/workflow-manager.ts +350 -121
- package/src/workflow.ts +2598 -389
package/README.md
CHANGED
|
@@ -9,6 +9,21 @@ The package is published as `@valon-technologies/gestalt`.
|
|
|
9
9
|
bun add @valon-technologies/gestalt@0.0.1-alpha.16
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
+
## API sections
|
|
13
|
+
|
|
14
|
+
The TypeDoc reference is organized around the provider-authoring workflow. All
|
|
15
|
+
symbols are imported from `@valon-technologies/gestalt` unless the section
|
|
16
|
+
explicitly names a submodule.
|
|
17
|
+
|
|
18
|
+
| Section | Start with | Use it for |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
| Provider authoring | `definePlugin`, `operation`, `ok` | Executable plugin providers, typed request handlers, and operation results. |
|
|
21
|
+
| Runtime schemas | `s`, `object`, `string` | Runtime validation and generated catalog metadata for operation inputs and outputs. |
|
|
22
|
+
| Provider runtimes | `defineAuthenticationProvider`, `defineCacheProvider`, `defineS3Provider`, `defineWorkflowProvider`, `defineAgentProvider` | Host-service backends implemented as TypeScript providers. |
|
|
23
|
+
| Workflow and agent models | `WorkflowProvider`, `WorkflowManager`, `AgentProvider`, `AgentManager` | Native workflow values, agent sessions, turns, messages, tools, and manager clients. |
|
|
24
|
+
| Host-service clients | `Cache`, `IndexedDB`, `S3`, `PluginInvoker`, `AuthorizationClient` | Calling sibling services exposed to a provider process by `gestaltd`. |
|
|
25
|
+
| Telemetry | `withModelOperation`, `withToolExecution`, `withAgentInvocation` | Provider-authored GenAI spans and metrics inside a running provider process. |
|
|
26
|
+
|
|
12
27
|
```ts
|
|
13
28
|
import { definePlugin, ok, operation, s } from "@valon-technologies/gestalt";
|
|
14
29
|
|
|
@@ -62,16 +77,15 @@ is omitted, the runtime looks for `provider`, then `plugin`, then the default
|
|
|
62
77
|
export.
|
|
63
78
|
|
|
64
79
|
Use `"plugin"` as the kind token for executable plugin providers. Use an object
|
|
65
|
-
target with an explicit kind for authentication,
|
|
66
|
-
|
|
80
|
+
target with an explicit kind for authentication, cache, IndexedDB, S3, secrets,
|
|
81
|
+
workflow, agent, and hosted-runtime providers.
|
|
67
82
|
|
|
68
83
|
## Public surface
|
|
69
84
|
|
|
70
85
|
The root package exports provider definition helpers:
|
|
71
86
|
|
|
72
87
|
- `definePlugin` for integration operations and session catalogs.
|
|
73
|
-
- `defineAuthenticationProvider`
|
|
74
|
-
surfaces.
|
|
88
|
+
- `defineAuthenticationProvider` for authentication surfaces.
|
|
75
89
|
- `defineCacheProvider`, `defineIndexedDBProvider`, `defineS3Provider`, and
|
|
76
90
|
`defineSecretsProvider` for host-service backends.
|
|
77
91
|
- `defineWorkflowProvider`, `defineAgentProvider`, and
|
|
@@ -81,6 +95,22 @@ The root package exports provider definition helpers:
|
|
|
81
95
|
- Host-service clients for cache, IndexedDB, S3, workflows, agents,
|
|
82
96
|
invocations, and telemetry.
|
|
83
97
|
|
|
98
|
+
`defineAgentProvider` handlers receive and return plain TypeScript objects such
|
|
99
|
+
as `CreateAgentProviderTurnRequest`, `AgentSession`, `AgentTurn`, and
|
|
100
|
+
`AgentTurnEvent`. Structured payload fields accept JSON values and timestamp
|
|
101
|
+
fields use native `Date`; the SDK runtime owns transport serialization at the
|
|
102
|
+
transport boundary. `AgentHost` includes plain-object helpers named
|
|
103
|
+
`listToolsForTurn`, `executeToolForTurn`, and `resolveConnectionForTurn`.
|
|
104
|
+
Workflow helpers such as `boundWorkflowTarget`, `workflowSignal`,
|
|
105
|
+
`boundWorkflowRun`, and `workflowExecutionReference` accept plain JSON objects
|
|
106
|
+
and native `Date` values. Copy helpers such as `boundWorkflowTargetFromTarget`
|
|
107
|
+
preserve request shape without requiring provider code to assemble transport
|
|
108
|
+
objects. Provider-facing APIs should accept native TypeScript values and keep
|
|
109
|
+
transport serialization inside SDK adapters.
|
|
110
|
+
|
|
111
|
+
The TypeScript SDK does not currently expose an authored authorization-provider
|
|
112
|
+
helper. Use the Go SDK when you need to build a custom authorization provider.
|
|
113
|
+
|
|
84
114
|
TypeScript types are not enough to describe runtime payloads. Use the schema
|
|
85
115
|
builders for every operation input and output that should appear in the
|
|
86
116
|
Gestalt catalog.
|
|
@@ -102,14 +132,6 @@ gestalt-ts-build ROOT plugin:./provider.ts#plugin OUTPUT PROVIDER_NAME GOOS GOAR
|
|
|
102
132
|
The build entrypoint compiles a standalone executable with Bun and bundles the
|
|
103
133
|
provider source into the result.
|
|
104
134
|
|
|
105
|
-
## Regenerating protobuf code
|
|
106
|
-
|
|
107
|
-
From the repo root:
|
|
108
|
-
|
|
109
|
-
```sh
|
|
110
|
-
buf generate --template sdk/proto/buf.typescript.gen.yaml sdk/proto
|
|
111
|
-
```
|
|
112
|
-
|
|
113
135
|
## API reference
|
|
114
136
|
|
|
115
137
|
The TypeDoc reference is generated from the authored public surface plus
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valon-technologies/gestalt",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.19",
|
|
4
4
|
"description": "TypeScript SDK for Gestalt executable providers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
"./build": "./src/build.ts",
|
|
13
13
|
"./runtime": "./src/runtime.ts",
|
|
14
14
|
"./schema": "./src/schema.ts",
|
|
15
|
+
"./protocol": "./src/protocol.ts",
|
|
16
|
+
"./protocol/v1": "./src/protocol/v1.ts",
|
|
15
17
|
"./test/agent-contract": "./src/test-agent-contract.ts",
|
|
16
18
|
"./telemetry": "./src/telemetry.ts",
|
|
17
19
|
"./target": "./src/target.ts"
|
|
@@ -31,8 +33,8 @@
|
|
|
31
33
|
"scripts": {
|
|
32
34
|
"build:proto": "buf generate --template ../proto/buf.typescript.gen.yaml ../proto",
|
|
33
35
|
"docs:lint": "eslint --max-warnings=0 \"src/**/*.ts\" \"docs/entrypoints/**/*.ts\"",
|
|
34
|
-
"docs:build": "typedoc --options typedoc.json --out docs/_build/html",
|
|
35
|
-
"docs:build:deploy": "
|
|
36
|
+
"docs:build": "typedoc --options typedoc.json --out \"${TYPEDOC_OUT_DIR:-docs/_build/html}\"",
|
|
37
|
+
"docs:build:deploy": "TYPEDOC_OUT_DIR=../../docs/public/api/typescript bun run docs:build",
|
|
36
38
|
"docs:check": "bun run docs:lint && bun run docs:build",
|
|
37
39
|
"typecheck": "tsc --noEmit",
|
|
38
40
|
"test": "bun test --max-concurrency 1",
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import {
|
|
2
|
+
create,
|
|
3
|
+
type MessageInitShape,
|
|
4
|
+
} from "@bufbuild/protobuf";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
AgentActorSchema,
|
|
8
|
+
AgentMessagePartSchema,
|
|
9
|
+
AgentMessagePartType as ProtoAgentMessagePartType,
|
|
10
|
+
AgentMessageSchema,
|
|
11
|
+
AgentToolRefSchema,
|
|
12
|
+
AgentTurnDisplaySchema,
|
|
13
|
+
type AgentActor as ProtoAgentActor,
|
|
14
|
+
type AgentMessage as ProtoAgentMessage,
|
|
15
|
+
type AgentMessagePart as ProtoAgentMessagePart,
|
|
16
|
+
type AgentToolRef as ProtoAgentToolRef,
|
|
17
|
+
type AgentTurnDisplay as ProtoAgentTurnDisplay,
|
|
18
|
+
} from "./internal/gen/v1/agent_pb.ts";
|
|
19
|
+
import {
|
|
20
|
+
jsonFromValue,
|
|
21
|
+
valueFromJson,
|
|
22
|
+
type JsonInput,
|
|
23
|
+
} from "./protocol.ts";
|
|
24
|
+
import {
|
|
25
|
+
optionalObjectFromStruct,
|
|
26
|
+
optionalStruct,
|
|
27
|
+
} from "./protocol-internal.ts";
|
|
28
|
+
import type {
|
|
29
|
+
AgentActor,
|
|
30
|
+
AgentMessage,
|
|
31
|
+
AgentMessagePart,
|
|
32
|
+
AgentMessagePartType,
|
|
33
|
+
AgentToolRef,
|
|
34
|
+
AgentTurnDisplay,
|
|
35
|
+
} from "./agent.ts";
|
|
36
|
+
|
|
37
|
+
export function agentTurnDisplayFromProto(
|
|
38
|
+
display?: ProtoAgentTurnDisplay | undefined,
|
|
39
|
+
): AgentTurnDisplay | undefined {
|
|
40
|
+
if (display === undefined) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
kind: display.kind,
|
|
45
|
+
phase: display.phase,
|
|
46
|
+
text: display.text,
|
|
47
|
+
label: display.label,
|
|
48
|
+
ref: display.ref,
|
|
49
|
+
parentRef: display.parentRef,
|
|
50
|
+
input: display.input === undefined ? undefined : jsonFromValue(display.input) as JsonInput,
|
|
51
|
+
output: display.output === undefined ? undefined : jsonFromValue(display.output) as JsonInput,
|
|
52
|
+
error: display.error === undefined ? undefined : jsonFromValue(display.error) as JsonInput,
|
|
53
|
+
action: display.action,
|
|
54
|
+
format: display.format,
|
|
55
|
+
language: display.language,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function agentTurnDisplayToProto(
|
|
60
|
+
display: AgentTurnDisplay | undefined,
|
|
61
|
+
): MessageInitShape<typeof AgentTurnDisplaySchema> | undefined {
|
|
62
|
+
if (!display) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
kind: display.kind ?? "",
|
|
67
|
+
phase: display.phase ?? "",
|
|
68
|
+
text: display.text ?? "",
|
|
69
|
+
label: display.label ?? "",
|
|
70
|
+
ref: display.ref ?? "",
|
|
71
|
+
parentRef: display.parentRef ?? "",
|
|
72
|
+
input: display.input === undefined ? undefined : valueFromJson(display.input),
|
|
73
|
+
output: display.output === undefined ? undefined : valueFromJson(display.output),
|
|
74
|
+
error: display.error === undefined ? undefined : valueFromJson(display.error),
|
|
75
|
+
action: display.action ?? "",
|
|
76
|
+
format: display.format ?? "",
|
|
77
|
+
language: display.language ?? "",
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function agentMessageFromProto(message: ProtoAgentMessage): AgentMessage {
|
|
82
|
+
return {
|
|
83
|
+
role: message.role,
|
|
84
|
+
text: message.text,
|
|
85
|
+
parts: message.parts.map(agentMessagePartFromProto),
|
|
86
|
+
metadata: optionalObjectFromStruct(message.metadata),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function agentMessageToProto(
|
|
91
|
+
message: AgentMessage,
|
|
92
|
+
): MessageInitShape<typeof AgentMessageSchema> {
|
|
93
|
+
return {
|
|
94
|
+
role: message.role ?? "",
|
|
95
|
+
text: message.text ?? "",
|
|
96
|
+
parts: message.parts?.map(agentMessagePartToProto) ?? [],
|
|
97
|
+
metadata: optionalStruct(message.metadata),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function agentMessagePartFromProto(
|
|
102
|
+
part: ProtoAgentMessagePart,
|
|
103
|
+
): AgentMessagePart {
|
|
104
|
+
return {
|
|
105
|
+
type: part.type as AgentMessagePartType,
|
|
106
|
+
text: part.text,
|
|
107
|
+
json: optionalObjectFromStruct(part.json),
|
|
108
|
+
toolCall: part.toolCall === undefined ? undefined : {
|
|
109
|
+
id: part.toolCall.id,
|
|
110
|
+
toolId: part.toolCall.toolId,
|
|
111
|
+
arguments: optionalObjectFromStruct(part.toolCall.arguments),
|
|
112
|
+
},
|
|
113
|
+
toolResult: part.toolResult === undefined ? undefined : {
|
|
114
|
+
toolCallId: part.toolResult.toolCallId,
|
|
115
|
+
status: part.toolResult.status,
|
|
116
|
+
content: part.toolResult.content,
|
|
117
|
+
output: optionalObjectFromStruct(part.toolResult.output),
|
|
118
|
+
},
|
|
119
|
+
imageRef: part.imageRef === undefined ? undefined : {
|
|
120
|
+
uri: part.imageRef.uri,
|
|
121
|
+
mimeType: part.imageRef.mimeType,
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function agentMessagePartToProto(
|
|
127
|
+
part: AgentMessagePart,
|
|
128
|
+
): MessageInitShape<typeof AgentMessagePartSchema> {
|
|
129
|
+
return {
|
|
130
|
+
type: part.type ?? ProtoAgentMessagePartType.UNSPECIFIED,
|
|
131
|
+
text: part.text ?? "",
|
|
132
|
+
json: optionalStruct(part.json),
|
|
133
|
+
toolCall: part.toolCall === undefined ? undefined : {
|
|
134
|
+
id: part.toolCall.id ?? "",
|
|
135
|
+
toolId: part.toolCall.toolId ?? "",
|
|
136
|
+
arguments: optionalStruct(part.toolCall.arguments),
|
|
137
|
+
},
|
|
138
|
+
toolResult: part.toolResult === undefined ? undefined : {
|
|
139
|
+
toolCallId: part.toolResult.toolCallId ?? "",
|
|
140
|
+
status: part.toolResult.status ?? 0,
|
|
141
|
+
content: part.toolResult.content ?? "",
|
|
142
|
+
output: optionalStruct(part.toolResult.output),
|
|
143
|
+
},
|
|
144
|
+
imageRef: part.imageRef === undefined ? undefined : {
|
|
145
|
+
uri: part.imageRef.uri ?? "",
|
|
146
|
+
mimeType: part.imageRef.mimeType ?? "",
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function agentActorFromProto(
|
|
152
|
+
actor?: ProtoAgentActor | undefined,
|
|
153
|
+
): AgentActor | undefined {
|
|
154
|
+
if (actor === undefined) {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
subjectId: actor.subjectId,
|
|
159
|
+
subjectKind: actor.subjectKind,
|
|
160
|
+
displayName: actor.displayName,
|
|
161
|
+
authSource: actor.authSource,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function agentActorToProto(
|
|
166
|
+
actor?: AgentActor | undefined,
|
|
167
|
+
): ProtoAgentActor | undefined {
|
|
168
|
+
if (actor === undefined) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
return create(AgentActorSchema, {
|
|
172
|
+
subjectId: actor.subjectId ?? "",
|
|
173
|
+
subjectKind: actor.subjectKind ?? "",
|
|
174
|
+
displayName: actor.displayName ?? "",
|
|
175
|
+
authSource: actor.authSource ?? "",
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function agentToolRefFromProto(ref: ProtoAgentToolRef): AgentToolRef {
|
|
180
|
+
return {
|
|
181
|
+
plugin: ref.plugin,
|
|
182
|
+
operation: ref.operation,
|
|
183
|
+
connection: ref.connection,
|
|
184
|
+
instance: ref.instance,
|
|
185
|
+
title: ref.title,
|
|
186
|
+
description: ref.description,
|
|
187
|
+
system: ref.system,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function agentToolRefToProto(ref: AgentToolRef): ProtoAgentToolRef {
|
|
192
|
+
return create(AgentToolRefSchema, {
|
|
193
|
+
plugin: ref.plugin ?? "",
|
|
194
|
+
operation: ref.operation ?? "",
|
|
195
|
+
connection: ref.connection ?? "",
|
|
196
|
+
instance: ref.instance ?? "",
|
|
197
|
+
title: ref.title ?? "",
|
|
198
|
+
description: ref.description ?? "",
|
|
199
|
+
system: ref.system ?? "",
|
|
200
|
+
});
|
|
201
|
+
}
|