@valon-technologies/gestalt 0.0.1-alpha.12 → 0.0.1-alpha.14
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 +1 -1
- package/gen/google/rpc/status_pb.ts +76 -0
- package/gen/v1/agent_pb.ts +2412 -0
- package/gen/v1/authentication_pb.ts +1 -1
- package/gen/v1/authorization_pb.ts +28 -28
- package/gen/v1/cache_pb.ts +4 -4
- package/gen/v1/datastore_pb.ts +467 -12
- package/gen/v1/external_credential_pb.ts +274 -0
- package/gen/v1/plugin_pb.ts +64 -42
- package/gen/v1/pluginruntime_pb.ts +632 -0
- package/gen/v1/runtime_pb.ts +46 -3
- package/gen/v1/s3_pb.ts +120 -20
- package/gen/v1/secrets_pb.ts +1 -1
- package/gen/v1/workflow_pb.ts +849 -97
- package/package.json +5 -3
- package/src/agent-manager.ts +247 -0
- package/src/agent.ts +645 -0
- package/src/api.ts +4 -1
- package/src/authorization.ts +88 -18
- package/src/index.ts +134 -16
- package/src/indexeddb.ts +481 -1
- package/src/invoker.ts +3 -0
- package/src/plugin.ts +81 -181
- package/src/pluginruntime.ts +220 -0
- package/src/provider-kind.ts +12 -0
- package/src/provider.ts +28 -1
- package/src/runtime-log-host.ts +244 -0
- package/src/runtime.ts +194 -67
- package/src/s3.ts +170 -38
- package/src/telemetry.ts +429 -0
- package/src/workflow-manager.ts +78 -9
- package/src/manifest-metadata.ts +0 -106
package/src/authorization.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { connect } from "node:net";
|
|
2
2
|
|
|
3
3
|
import type { MessageInitShape } from "@bufbuild/protobuf";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
createClient,
|
|
6
|
+
type Client,
|
|
7
|
+
type Interceptor,
|
|
8
|
+
} from "@connectrpc/connect";
|
|
5
9
|
import { createGrpcTransport } from "@connectrpc/connect-node";
|
|
6
10
|
|
|
7
11
|
import {
|
|
@@ -20,10 +24,14 @@ import {
|
|
|
20
24
|
} from "../gen/v1/authorization_pb.ts";
|
|
21
25
|
|
|
22
26
|
/**
|
|
23
|
-
* Environment variable containing the Unix socket path for the
|
|
24
|
-
* authorization client exposed to plugins.
|
|
27
|
+
* Environment variable containing the Unix socket path or relay target for the
|
|
28
|
+
* read-only host authorization client exposed to plugins.
|
|
25
29
|
*/
|
|
26
30
|
export const ENV_AUTHORIZATION_SOCKET = "GESTALT_AUTHORIZATION_SOCKET";
|
|
31
|
+
export const ENV_AUTHORIZATION_SOCKET_TOKEN =
|
|
32
|
+
`${ENV_AUTHORIZATION_SOCKET}_TOKEN`;
|
|
33
|
+
const AUTHORIZATION_RELAY_TOKEN_HEADER =
|
|
34
|
+
"x-gestalt-host-service-relay-token";
|
|
27
35
|
|
|
28
36
|
export type AuthorizationEvaluateInput = MessageInitShape<
|
|
29
37
|
typeof AccessEvaluationRequestSchema
|
|
@@ -49,10 +57,12 @@ export type AuthorizationActionSearchMessage = ActionSearchResponse;
|
|
|
49
57
|
export type AuthorizationReadRelationshipsMessage = ReadRelationshipsResponse;
|
|
50
58
|
|
|
51
59
|
const sharedAuthorizationTransport: {
|
|
52
|
-
|
|
60
|
+
target: string;
|
|
61
|
+
token: string;
|
|
53
62
|
client: AuthorizationClient | undefined;
|
|
54
63
|
} = {
|
|
55
|
-
|
|
64
|
+
target: "",
|
|
65
|
+
token: "",
|
|
56
66
|
client: undefined,
|
|
57
67
|
};
|
|
58
68
|
|
|
@@ -62,13 +72,21 @@ const sharedAuthorizationTransport: {
|
|
|
62
72
|
export class AuthorizationClient {
|
|
63
73
|
private readonly client: Client<typeof AuthorizationProviderService>;
|
|
64
74
|
|
|
65
|
-
constructor(
|
|
66
|
-
const
|
|
75
|
+
constructor(socketTarget?: string, relayToken = process.env[ENV_AUTHORIZATION_SOCKET_TOKEN]?.trim() ?? "") {
|
|
76
|
+
const resolvedTarget = resolveAuthorizationSocketTarget(socketTarget);
|
|
77
|
+
const transportOptions = authorizationTransportOptions(resolvedTarget);
|
|
67
78
|
const transport = createGrpcTransport({
|
|
68
|
-
|
|
69
|
-
nodeOptions
|
|
70
|
-
|
|
71
|
-
|
|
79
|
+
...transportOptions,
|
|
80
|
+
...(transportOptions.nodeOptions
|
|
81
|
+
? {
|
|
82
|
+
nodeOptions: {
|
|
83
|
+
createConnection: () => connect(transportOptions.nodeOptions!.path),
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
: {}),
|
|
87
|
+
interceptors: relayToken
|
|
88
|
+
? [authorizationRelayTokenInterceptor(relayToken)]
|
|
89
|
+
: [],
|
|
72
90
|
});
|
|
73
91
|
this.client = createClient(AuthorizationProviderService, transport);
|
|
74
92
|
}
|
|
@@ -113,26 +131,78 @@ export class AuthorizationClient {
|
|
|
113
131
|
* client inside authored providers.
|
|
114
132
|
*/
|
|
115
133
|
export function Authorization(): AuthorizationClient {
|
|
116
|
-
const
|
|
134
|
+
const target = resolveAuthorizationSocketTarget();
|
|
135
|
+
const token = process.env[ENV_AUTHORIZATION_SOCKET_TOKEN]?.trim() ?? "";
|
|
117
136
|
if (
|
|
118
137
|
sharedAuthorizationTransport.client &&
|
|
119
|
-
sharedAuthorizationTransport.
|
|
138
|
+
sharedAuthorizationTransport.target === target &&
|
|
139
|
+
sharedAuthorizationTransport.token === token
|
|
120
140
|
) {
|
|
121
141
|
return sharedAuthorizationTransport.client;
|
|
122
142
|
}
|
|
123
143
|
|
|
124
|
-
const client = new AuthorizationClient(
|
|
125
|
-
sharedAuthorizationTransport.
|
|
144
|
+
const client = new AuthorizationClient(target, token);
|
|
145
|
+
sharedAuthorizationTransport.target = target;
|
|
146
|
+
sharedAuthorizationTransport.token = token;
|
|
126
147
|
sharedAuthorizationTransport.client = client;
|
|
127
148
|
return client;
|
|
128
149
|
}
|
|
129
150
|
|
|
130
|
-
function
|
|
151
|
+
function resolveAuthorizationSocketTarget(socketPath = process.env[ENV_AUTHORIZATION_SOCKET]): string {
|
|
131
152
|
const trimmed = socketPath?.trim() ?? "";
|
|
132
153
|
if (!trimmed) {
|
|
154
|
+
throw new Error(`authorization: ${ENV_AUTHORIZATION_SOCKET} is not set`);
|
|
155
|
+
}
|
|
156
|
+
return trimmed;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function authorizationTransportOptions(rawTarget: string): {
|
|
160
|
+
baseUrl: string;
|
|
161
|
+
nodeOptions?: { path: string };
|
|
162
|
+
} {
|
|
163
|
+
const target = rawTarget.trim();
|
|
164
|
+
if (!target) {
|
|
165
|
+
throw new Error("authorization: transport target is required");
|
|
166
|
+
}
|
|
167
|
+
if (target.startsWith("tcp://")) {
|
|
168
|
+
const address = target.slice("tcp://".length).trim();
|
|
169
|
+
if (!address) {
|
|
170
|
+
throw new Error(
|
|
171
|
+
`authorization: tcp target ${JSON.stringify(rawTarget)} is missing host:port`,
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
return { baseUrl: `http://${address}` };
|
|
175
|
+
}
|
|
176
|
+
if (target.startsWith("tls://")) {
|
|
177
|
+
const address = target.slice("tls://".length).trim();
|
|
178
|
+
if (!address) {
|
|
179
|
+
throw new Error(
|
|
180
|
+
`authorization: tls target ${JSON.stringify(rawTarget)} is missing host:port`,
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
return { baseUrl: `https://${address}` };
|
|
184
|
+
}
|
|
185
|
+
if (target.startsWith("unix://")) {
|
|
186
|
+
const socketPath = target.slice("unix://".length).trim();
|
|
187
|
+
if (!socketPath) {
|
|
188
|
+
throw new Error(
|
|
189
|
+
`authorization: unix target ${JSON.stringify(rawTarget)} is missing a socket path`,
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
return { baseUrl: "http://localhost", nodeOptions: { path: socketPath } };
|
|
193
|
+
}
|
|
194
|
+
if (target.includes("://")) {
|
|
195
|
+
const parsed = new URL(target);
|
|
133
196
|
throw new Error(
|
|
134
|
-
`authorization: ${
|
|
197
|
+
`authorization: unsupported target scheme ${JSON.stringify(parsed.protocol.replace(/:$/, ""))}`,
|
|
135
198
|
);
|
|
136
199
|
}
|
|
137
|
-
return
|
|
200
|
+
return { baseUrl: "http://localhost", nodeOptions: { path: target } };
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function authorizationRelayTokenInterceptor(token: string): Interceptor {
|
|
204
|
+
return (next) => async (req) => {
|
|
205
|
+
req.header.set(AUTHORIZATION_RELAY_TOKEN_HEADER, token);
|
|
206
|
+
return next(req);
|
|
207
|
+
};
|
|
138
208
|
}
|
package/src/index.ts
CHANGED
|
@@ -32,6 +32,7 @@ export {
|
|
|
32
32
|
Authorization,
|
|
33
33
|
AuthorizationClient,
|
|
34
34
|
ENV_AUTHORIZATION_SOCKET,
|
|
35
|
+
ENV_AUTHORIZATION_SOCKET_TOKEN,
|
|
35
36
|
type AuthorizationActionSearchMessage,
|
|
36
37
|
type AuthorizationDecisionMessage,
|
|
37
38
|
type AuthorizationEvaluateInput,
|
|
@@ -76,21 +77,6 @@ export {
|
|
|
76
77
|
type CatalogParameter,
|
|
77
78
|
type CatalogSchema,
|
|
78
79
|
} from "./catalog.ts";
|
|
79
|
-
export {
|
|
80
|
-
hasPluginManifestMetadata,
|
|
81
|
-
manifestMetadataToYaml,
|
|
82
|
-
writeManifestMetadataYaml,
|
|
83
|
-
type HTTPAck,
|
|
84
|
-
type HTTPAuthScheme,
|
|
85
|
-
type HTTPBinding,
|
|
86
|
-
type HTTPIn,
|
|
87
|
-
type HTTPMediaType,
|
|
88
|
-
type HTTPRequestBody,
|
|
89
|
-
type HTTPSecretRef,
|
|
90
|
-
type HTTPSecurityScheme,
|
|
91
|
-
type HTTPSecuritySchemeType,
|
|
92
|
-
type PluginManifestMetadata,
|
|
93
|
-
} from "./manifest-metadata.ts";
|
|
94
80
|
export {
|
|
95
81
|
buildProviderBinary,
|
|
96
82
|
bunBuildCommand,
|
|
@@ -105,8 +91,25 @@ export {
|
|
|
105
91
|
type PluginInvocationGrant,
|
|
106
92
|
type PluginInvokeOptions,
|
|
107
93
|
} from "./invoker.ts";
|
|
94
|
+
export {
|
|
95
|
+
ENV_AGENT_MANAGER_SOCKET,
|
|
96
|
+
ENV_AGENT_MANAGER_SOCKET_TOKEN,
|
|
97
|
+
AgentManager,
|
|
98
|
+
type AgentManagerCancelTurnInput,
|
|
99
|
+
type AgentManagerCreateSessionInput,
|
|
100
|
+
type AgentManagerCreateTurnInput,
|
|
101
|
+
type AgentManagerGetSessionInput,
|
|
102
|
+
type AgentManagerGetTurnInput,
|
|
103
|
+
type AgentManagerListInteractionsInput,
|
|
104
|
+
type AgentManagerListSessionsInput,
|
|
105
|
+
type AgentManagerListTurnEventsInput,
|
|
106
|
+
type AgentManagerListTurnsInput,
|
|
107
|
+
type AgentManagerResolveInteractionInput,
|
|
108
|
+
type AgentManagerUpdateSessionInput,
|
|
109
|
+
} from "./agent-manager.ts";
|
|
108
110
|
export {
|
|
109
111
|
ENV_WORKFLOW_MANAGER_SOCKET,
|
|
112
|
+
ENV_WORKFLOW_MANAGER_SOCKET_TOKEN,
|
|
110
113
|
WorkflowManager,
|
|
111
114
|
type ManagedWorkflowEventTriggerMessage,
|
|
112
115
|
type ManagedWorkflowScheduleMessage,
|
|
@@ -125,6 +128,18 @@ export {
|
|
|
125
128
|
type WorkflowManagerUpdateTriggerInput,
|
|
126
129
|
type WorkflowManagerUpdateScheduleInput,
|
|
127
130
|
} from "./workflow-manager.ts";
|
|
131
|
+
export {
|
|
132
|
+
ENV_RUNTIME_LOG_HOST_SOCKET,
|
|
133
|
+
ENV_RUNTIME_LOG_HOST_SOCKET_TOKEN,
|
|
134
|
+
ENV_RUNTIME_SESSION_ID,
|
|
135
|
+
RuntimeLogHost,
|
|
136
|
+
type RuntimeLogAppendInput,
|
|
137
|
+
type RuntimeLogAppendLogsInput,
|
|
138
|
+
type RuntimeLogAppendResponseMessage,
|
|
139
|
+
type RuntimeLogStreamInput,
|
|
140
|
+
type RuntimeLogStreamName,
|
|
141
|
+
type RuntimeLogWriterOptions,
|
|
142
|
+
} from "./runtime-log-host.ts";
|
|
128
143
|
export {
|
|
129
144
|
AuthenticationProvider,
|
|
130
145
|
defineAuthenticationProvider,
|
|
@@ -155,6 +170,7 @@ export {
|
|
|
155
170
|
type SecretsProviderOptions,
|
|
156
171
|
} from "./secrets.ts";
|
|
157
172
|
export {
|
|
173
|
+
type ConnectedToken,
|
|
158
174
|
PluginProvider,
|
|
159
175
|
connectionModeToProtoValue,
|
|
160
176
|
connectionParamToProto,
|
|
@@ -165,6 +181,7 @@ export {
|
|
|
165
181
|
type ConnectionParamDefinition,
|
|
166
182
|
type OperationDefinition,
|
|
167
183
|
type OperationOptions,
|
|
184
|
+
type PostConnectHandler,
|
|
168
185
|
type PluginDefinitionOptions,
|
|
169
186
|
type SessionCatalog,
|
|
170
187
|
type SessionCatalogHandler,
|
|
@@ -179,8 +196,28 @@ export {
|
|
|
179
196
|
type ProviderKind,
|
|
180
197
|
type ProviderMetadata,
|
|
181
198
|
type RuntimeProviderOptions,
|
|
199
|
+
type StartHandler,
|
|
182
200
|
type WarningsHandler,
|
|
183
201
|
} from "./provider.ts";
|
|
202
|
+
export {
|
|
203
|
+
PluginRuntimeEgressMode,
|
|
204
|
+
PluginRuntimeHostServiceAccess,
|
|
205
|
+
PluginRuntimeProvider,
|
|
206
|
+
createPluginRuntimeProviderService,
|
|
207
|
+
definePluginRuntimeProvider,
|
|
208
|
+
isPluginRuntimeProvider,
|
|
209
|
+
type BindPluginRuntimeHostServiceRequest,
|
|
210
|
+
type GetPluginRuntimeSessionRequest,
|
|
211
|
+
type HostedPlugin,
|
|
212
|
+
type ListPluginRuntimeSessionsRequest,
|
|
213
|
+
type PluginRuntimeHostServiceBinding,
|
|
214
|
+
type PluginRuntimeProviderOptions,
|
|
215
|
+
type PluginRuntimeSession,
|
|
216
|
+
type PluginRuntimeSupport,
|
|
217
|
+
type StartHostedPluginRequest,
|
|
218
|
+
type StartPluginRuntimeSessionRequest,
|
|
219
|
+
type StopPluginRuntimeSessionRequest,
|
|
220
|
+
} from "./pluginruntime.ts";
|
|
184
221
|
export {
|
|
185
222
|
array,
|
|
186
223
|
boolean,
|
|
@@ -199,7 +236,6 @@ export {
|
|
|
199
236
|
ENV_PROVIDER_PARENT_PID,
|
|
200
237
|
ENV_PROVIDER_SOCKET,
|
|
201
238
|
ENV_WRITE_CATALOG,
|
|
202
|
-
ENV_WRITE_MANIFEST_METADATA,
|
|
203
239
|
createAuthenticationService,
|
|
204
240
|
createCacheService,
|
|
205
241
|
createSecretsService,
|
|
@@ -230,15 +266,22 @@ export {
|
|
|
230
266
|
IndexedDB,
|
|
231
267
|
ObjectStore,
|
|
232
268
|
Index,
|
|
269
|
+
Transaction,
|
|
270
|
+
TransactionObjectStore,
|
|
271
|
+
TransactionIndex,
|
|
233
272
|
Cursor,
|
|
234
273
|
CursorDirection,
|
|
235
274
|
NotFoundError,
|
|
236
275
|
AlreadyExistsError,
|
|
276
|
+
TransactionError,
|
|
237
277
|
ColumnType,
|
|
238
278
|
indexedDBSocketEnv,
|
|
239
279
|
indexedDBSocketTokenEnv,
|
|
240
280
|
type Record,
|
|
241
281
|
type KeyRange,
|
|
282
|
+
type TransactionMode,
|
|
283
|
+
type TransactionDurabilityHint,
|
|
284
|
+
type TransactionOptions,
|
|
242
285
|
type ColumnSchema,
|
|
243
286
|
type IndexSchema,
|
|
244
287
|
type ObjectStoreSchema,
|
|
@@ -255,11 +298,16 @@ export {
|
|
|
255
298
|
createS3Service,
|
|
256
299
|
defineS3Provider,
|
|
257
300
|
isS3Provider,
|
|
301
|
+
ENV_S3_SOCKET,
|
|
302
|
+
ENV_S3_SOCKET_TOKEN,
|
|
258
303
|
s3SocketEnv,
|
|
304
|
+
s3SocketTokenEnv,
|
|
259
305
|
type ByteRange,
|
|
260
306
|
type CopyOptions,
|
|
261
307
|
type ListOptions,
|
|
262
308
|
type ListPage,
|
|
309
|
+
type ObjectAccessURL,
|
|
310
|
+
type ObjectAccessURLOptions,
|
|
263
311
|
type ObjectMeta,
|
|
264
312
|
type ObjectRef,
|
|
265
313
|
type PresignOptions,
|
|
@@ -271,6 +319,59 @@ export {
|
|
|
271
319
|
type S3ProviderOptions,
|
|
272
320
|
type WriteOptions,
|
|
273
321
|
} from "./s3.ts";
|
|
322
|
+
export {
|
|
323
|
+
ENV_AGENT_HOST_SOCKET,
|
|
324
|
+
ENV_AGENT_HOST_SOCKET_TOKEN,
|
|
325
|
+
AgentHost,
|
|
326
|
+
AgentExecutionStatus,
|
|
327
|
+
AgentInteractionState,
|
|
328
|
+
AgentInteractionType,
|
|
329
|
+
AgentMessagePartType,
|
|
330
|
+
AgentProvider,
|
|
331
|
+
AgentSessionState,
|
|
332
|
+
AgentToolSourceMode,
|
|
333
|
+
createAgentProviderService,
|
|
334
|
+
defineAgentProvider,
|
|
335
|
+
isAgentProvider,
|
|
336
|
+
type AgentActor,
|
|
337
|
+
type AgentInteraction,
|
|
338
|
+
type AgentMessage,
|
|
339
|
+
type AgentMessagePart,
|
|
340
|
+
type AgentMessagePartImageRef,
|
|
341
|
+
type AgentMessagePartToolCall,
|
|
342
|
+
type AgentMessagePartToolResult,
|
|
343
|
+
type AgentProviderCapabilities,
|
|
344
|
+
type AgentProviderOptions,
|
|
345
|
+
type AgentSession,
|
|
346
|
+
type AgentToolRef,
|
|
347
|
+
type AgentTurn,
|
|
348
|
+
type AgentTurnDisplay,
|
|
349
|
+
type AgentTurnDisplayInit,
|
|
350
|
+
type AgentTurnDisplayValue,
|
|
351
|
+
type AgentTurnEvent,
|
|
352
|
+
type AgentTurnEventInit,
|
|
353
|
+
type CancelAgentProviderTurnRequest,
|
|
354
|
+
type CreateAgentProviderSessionRequest,
|
|
355
|
+
type CreateAgentProviderTurnRequest,
|
|
356
|
+
type ExecuteAgentToolRequest,
|
|
357
|
+
type ExecuteAgentToolResponse,
|
|
358
|
+
type GetAgentProviderCapabilitiesRequest,
|
|
359
|
+
type GetAgentProviderInteractionRequest,
|
|
360
|
+
type GetAgentProviderSessionRequest,
|
|
361
|
+
type GetAgentProviderTurnRequest,
|
|
362
|
+
type ListAgentToolsRequest,
|
|
363
|
+
type ListAgentToolsResponse,
|
|
364
|
+
type ListAgentProviderInteractionsRequest,
|
|
365
|
+
type ListAgentProviderSessionsRequest,
|
|
366
|
+
type ListAgentProviderTurnEventsRequest,
|
|
367
|
+
type ListAgentProviderTurnsRequest,
|
|
368
|
+
type ListedAgentTool,
|
|
369
|
+
type ResolveAgentProviderInteractionRequest,
|
|
370
|
+
type ResolvedAgentTool,
|
|
371
|
+
type SearchAgentToolsRequest,
|
|
372
|
+
type SearchAgentToolsResponse,
|
|
373
|
+
type UpdateAgentProviderSessionRequest,
|
|
374
|
+
} from "./agent.ts";
|
|
274
375
|
export {
|
|
275
376
|
ENV_WORKFLOW_HOST_SOCKET,
|
|
276
377
|
WorkflowHost,
|
|
@@ -304,3 +405,20 @@ export {
|
|
|
304
405
|
type WorkflowEvent,
|
|
305
406
|
type WorkflowProviderOptions,
|
|
306
407
|
} from "./workflow.ts";
|
|
408
|
+
export {
|
|
409
|
+
GENAI_OPERATION_CHAT,
|
|
410
|
+
GENAI_OPERATION_EXECUTE_TOOL,
|
|
411
|
+
GENAI_OPERATION_INVOKE_AGENT,
|
|
412
|
+
GENAI_PROVIDER_NAME,
|
|
413
|
+
GENAI_TOOL_TYPE_DATASTORE,
|
|
414
|
+
GENAI_TOOL_TYPE_EXTENSION,
|
|
415
|
+
GenAIOperation,
|
|
416
|
+
TELEMETRY_INSTRUMENTATION_NAME,
|
|
417
|
+
withAgentInvocation,
|
|
418
|
+
withModelOperation,
|
|
419
|
+
withToolExecution,
|
|
420
|
+
type AgentInvocationOptions,
|
|
421
|
+
type ModelOperationOptions,
|
|
422
|
+
type TokenUsage,
|
|
423
|
+
type ToolExecutionOptions,
|
|
424
|
+
} from "./telemetry.ts";
|