@valon-technologies/gestalt 0.0.1-alpha.19 → 0.0.1-alpha.21
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 +4 -6
- package/package.json +1 -4
- package/src/agent-conversions.ts +69 -2
- package/src/agent-manager.ts +26 -22
- package/src/agent.ts +33 -27
- package/src/api.ts +19 -0
- package/src/authorization.ts +0 -63
- package/src/index.ts +48 -60
- package/src/indexeddb.ts +450 -46
- package/src/internal/gen/v1/agent_pb.ts +103 -162
- package/src/internal/gen/v1/authentication_pb.ts +1 -1
- package/src/internal/gen/v1/authorization_pb.ts +1 -1
- package/src/internal/gen/v1/cache_pb.ts +1 -1
- package/src/internal/gen/v1/datastore_pb.ts +1 -1
- package/src/internal/gen/v1/external_credential_pb.ts +1 -1
- package/src/internal/gen/v1/plugin_pb.ts +94 -16
- package/src/internal/gen/v1/pluginruntime_pb.ts +1 -1
- package/src/internal/gen/v1/runtime_pb.ts +1 -1
- package/src/internal/gen/v1/s3_pb.ts +1 -1
- package/src/internal/gen/v1/secrets_pb.ts +1 -1
- package/src/internal/gen/v1/workflow_pb.ts +170 -74
- package/src/plugin.ts +4 -4
- package/src/protocol.ts +4 -1
- package/src/runtime.ts +17 -4
- package/src/workflow-manager.ts +53 -57
- package/src/workflow.ts +231 -163
- package/src/protocol/v1.ts +0 -19
- package/src/test-agent-contract.ts +0 -43
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ explicitly names a submodule.
|
|
|
19
19
|
| --- | --- | --- |
|
|
20
20
|
| Provider authoring | `definePlugin`, `operation`, `ok` | Executable plugin providers, typed request handlers, and operation results. |
|
|
21
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. |
|
|
22
|
+
| Provider runtimes | `defineAuthenticationProvider`, `defineAuthorizationProvider`, `defineCacheProvider`, `defineS3Provider`, `defineWorkflowProvider`, `defineAgentProvider` | Host-service backends implemented as TypeScript providers. |
|
|
23
23
|
| Workflow and agent models | `WorkflowProvider`, `WorkflowManager`, `AgentProvider`, `AgentManager` | Native workflow values, agent sessions, turns, messages, tools, and manager clients. |
|
|
24
24
|
| Host-service clients | `Cache`, `IndexedDB`, `S3`, `PluginInvoker`, `AuthorizationClient` | Calling sibling services exposed to a provider process by `gestaltd`. |
|
|
25
25
|
| Telemetry | `withModelOperation`, `withToolExecution`, `withAgentInvocation` | Provider-authored GenAI spans and metrics inside a running provider process. |
|
|
@@ -77,8 +77,8 @@ is omitted, the runtime looks for `provider`, then `plugin`, then the default
|
|
|
77
77
|
export.
|
|
78
78
|
|
|
79
79
|
Use `"plugin"` as the kind token for executable plugin providers. Use an object
|
|
80
|
-
target with an explicit kind for authentication,
|
|
81
|
-
workflow, agent, and hosted-runtime providers.
|
|
80
|
+
target with an explicit kind for authentication, authorization, cache,
|
|
81
|
+
IndexedDB, S3, secrets, workflow, agent, and hosted-runtime providers.
|
|
82
82
|
|
|
83
83
|
## Public surface
|
|
84
84
|
|
|
@@ -86,6 +86,7 @@ The root package exports provider definition helpers:
|
|
|
86
86
|
|
|
87
87
|
- `definePlugin` for integration operations and session catalogs.
|
|
88
88
|
- `defineAuthenticationProvider` for authentication surfaces.
|
|
89
|
+
- `defineAuthorizationProvider` for custom authorization providers.
|
|
89
90
|
- `defineCacheProvider`, `defineIndexedDBProvider`, `defineS3Provider`, and
|
|
90
91
|
`defineSecretsProvider` for host-service backends.
|
|
91
92
|
- `defineWorkflowProvider`, `defineAgentProvider`, and
|
|
@@ -108,9 +109,6 @@ preserve request shape without requiring provider code to assemble transport
|
|
|
108
109
|
objects. Provider-facing APIs should accept native TypeScript values and keep
|
|
109
110
|
transport serialization inside SDK adapters.
|
|
110
111
|
|
|
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
|
-
|
|
114
112
|
TypeScript types are not enough to describe runtime payloads. Use the schema
|
|
115
113
|
builders for every operation input and output that should appear in the
|
|
116
114
|
Gestalt catalog.
|
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.21",
|
|
4
4
|
"description": "TypeScript SDK for Gestalt executable providers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -12,9 +12,6 @@
|
|
|
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",
|
|
17
|
-
"./test/agent-contract": "./src/test-agent-contract.ts",
|
|
18
15
|
"./telemetry": "./src/telemetry.ts",
|
|
19
16
|
"./target": "./src/target.ts"
|
|
20
17
|
},
|
package/src/agent-conversions.ts
CHANGED
|
@@ -8,14 +8,20 @@ import {
|
|
|
8
8
|
AgentMessagePartSchema,
|
|
9
9
|
AgentMessagePartType as ProtoAgentMessagePartType,
|
|
10
10
|
AgentMessageSchema,
|
|
11
|
-
AgentToolRefSchema,
|
|
12
11
|
AgentTurnDisplaySchema,
|
|
13
12
|
type AgentActor as ProtoAgentActor,
|
|
14
13
|
type AgentMessage as ProtoAgentMessage,
|
|
15
14
|
type AgentMessagePart as ProtoAgentMessagePart,
|
|
16
|
-
type AgentToolRef as ProtoAgentToolRef,
|
|
17
15
|
type AgentTurnDisplay as ProtoAgentTurnDisplay,
|
|
18
16
|
} from "./internal/gen/v1/agent_pb.ts";
|
|
17
|
+
import {
|
|
18
|
+
SubjectContextSchema,
|
|
19
|
+
AgentToolRefSchema,
|
|
20
|
+
ExternalIdentityContextSchema,
|
|
21
|
+
type SubjectContext as ProtoSubjectContext,
|
|
22
|
+
type AgentToolRef as ProtoAgentToolRef,
|
|
23
|
+
type ExternalIdentityContext as ProtoExternalIdentityContext,
|
|
24
|
+
} from "./internal/gen/v1/plugin_pb.ts";
|
|
19
25
|
import {
|
|
20
26
|
jsonFromValue,
|
|
21
27
|
valueFromJson,
|
|
@@ -33,6 +39,7 @@ import type {
|
|
|
33
39
|
AgentToolRef,
|
|
34
40
|
AgentTurnDisplay,
|
|
35
41
|
} from "./agent.ts";
|
|
42
|
+
import type { ExternalIdentity, Subject, SubjectInput } from "./api.ts";
|
|
36
43
|
|
|
37
44
|
export function agentTurnDisplayFromProto(
|
|
38
45
|
display?: ProtoAgentTurnDisplay | undefined,
|
|
@@ -185,6 +192,8 @@ export function agentToolRefFromProto(ref: ProtoAgentToolRef): AgentToolRef {
|
|
|
185
192
|
title: ref.title,
|
|
186
193
|
description: ref.description,
|
|
187
194
|
system: ref.system,
|
|
195
|
+
runAs: agentRunAsSubjectFromProto(ref.runAs),
|
|
196
|
+
runAsExternalIdentity: externalIdentityFromProto(ref.runAsExternalIdentity),
|
|
188
197
|
};
|
|
189
198
|
}
|
|
190
199
|
|
|
@@ -197,5 +206,63 @@ export function agentToolRefToProto(ref: AgentToolRef): ProtoAgentToolRef {
|
|
|
197
206
|
title: ref.title ?? "",
|
|
198
207
|
description: ref.description ?? "",
|
|
199
208
|
system: ref.system ?? "",
|
|
209
|
+
runAs: agentRunAsSubjectToProto(ref.runAs),
|
|
210
|
+
runAsExternalIdentity: externalIdentityToProto(ref.runAsExternalIdentity),
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function agentRunAsSubjectFromProto(
|
|
215
|
+
subject?: ProtoSubjectContext | undefined,
|
|
216
|
+
): Subject | undefined {
|
|
217
|
+
if (subject === undefined) {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
id: subject.id,
|
|
222
|
+
kind: subject.kind,
|
|
223
|
+
credentialSubjectId: subject.credentialSubjectId,
|
|
224
|
+
displayName: subject.displayName,
|
|
225
|
+
authSource: subject.authSource,
|
|
226
|
+
email: subject.email,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function agentRunAsSubjectToProto(
|
|
231
|
+
subject?: SubjectInput | undefined,
|
|
232
|
+
): ProtoSubjectContext | undefined {
|
|
233
|
+
if (subject === undefined) {
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
return create(SubjectContextSchema, {
|
|
237
|
+
id: subject.id ?? "",
|
|
238
|
+
kind: subject.kind ?? "",
|
|
239
|
+
credentialSubjectId: subject.credentialSubjectId ?? "",
|
|
240
|
+
displayName: subject.displayName ?? "",
|
|
241
|
+
authSource: subject.authSource ?? "",
|
|
242
|
+
email: subject.email ?? "",
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function externalIdentityFromProto(
|
|
247
|
+
identity?: ProtoExternalIdentityContext | undefined,
|
|
248
|
+
): ExternalIdentity | undefined {
|
|
249
|
+
if (identity === undefined) {
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
type: identity.type,
|
|
254
|
+
id: identity.id,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function externalIdentityToProto(
|
|
259
|
+
identity?: ExternalIdentity | undefined,
|
|
260
|
+
): ProtoExternalIdentityContext | undefined {
|
|
261
|
+
if (identity === undefined) {
|
|
262
|
+
return undefined;
|
|
263
|
+
}
|
|
264
|
+
return create(ExternalIdentityContextSchema, {
|
|
265
|
+
type: identity.type,
|
|
266
|
+
id: identity.id,
|
|
200
267
|
});
|
|
201
268
|
}
|
package/src/agent-manager.ts
CHANGED
|
@@ -61,7 +61,7 @@ export interface AgentManagerWorkspace {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/** Shape accepted when creating an agent session through the host manager. */
|
|
64
|
-
export interface
|
|
64
|
+
export interface AgentManagerCreateSession {
|
|
65
65
|
providerName: string;
|
|
66
66
|
model?: string | undefined;
|
|
67
67
|
clientRef?: string | undefined;
|
|
@@ -71,12 +71,12 @@ export interface AgentManagerCreateSessionInput {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/** Shape accepted when fetching an agent session through the host manager. */
|
|
74
|
-
export interface
|
|
74
|
+
export interface AgentManagerGetSession {
|
|
75
75
|
sessionId: string;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/** Shape accepted when listing agent sessions through the host manager. */
|
|
79
|
-
export interface
|
|
79
|
+
export interface AgentManagerListSessions {
|
|
80
80
|
providerName?: string | undefined;
|
|
81
81
|
state?: AgentSessionState | undefined;
|
|
82
82
|
limit?: number | undefined;
|
|
@@ -84,7 +84,7 @@ export interface AgentManagerListSessionsInput {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/** Shape accepted when updating an agent session through the host manager. */
|
|
87
|
-
export interface
|
|
87
|
+
export interface AgentManagerUpdateSession {
|
|
88
88
|
sessionId: string;
|
|
89
89
|
clientRef?: string | undefined;
|
|
90
90
|
state?: AgentSessionState | undefined;
|
|
@@ -92,25 +92,27 @@ export interface AgentManagerUpdateSessionInput {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/** Shape accepted when creating an agent turn through the host manager. */
|
|
95
|
-
export interface
|
|
95
|
+
export interface AgentManagerCreateTurn {
|
|
96
96
|
sessionId: string;
|
|
97
97
|
model?: string | undefined;
|
|
98
98
|
messages?: readonly AgentMessage[] | undefined;
|
|
99
99
|
toolRefs?: readonly AgentToolRef[] | undefined;
|
|
100
|
+
toolRefsSet?: boolean | undefined;
|
|
100
101
|
toolSource?: AgentToolSourceMode | undefined;
|
|
101
102
|
responseSchema?: JsonObjectInput | undefined;
|
|
102
103
|
metadata?: JsonObjectInput | undefined;
|
|
103
104
|
idempotencyKey?: string | undefined;
|
|
104
105
|
modelOptions?: JsonObjectInput | undefined;
|
|
106
|
+
timeoutSeconds?: number | undefined;
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
/** Shape accepted when fetching an agent turn through the host manager. */
|
|
108
|
-
export interface
|
|
110
|
+
export interface AgentManagerGetTurn {
|
|
109
111
|
turnId: string;
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
/** Shape accepted when listing agent turns through the host manager. */
|
|
113
|
-
export interface
|
|
115
|
+
export interface AgentManagerListTurns {
|
|
114
116
|
sessionId: string;
|
|
115
117
|
status?: AgentExecutionStatus | undefined;
|
|
116
118
|
limit?: number | undefined;
|
|
@@ -118,25 +120,25 @@ export interface AgentManagerListTurnsInput {
|
|
|
118
120
|
}
|
|
119
121
|
|
|
120
122
|
/** Shape accepted when cancelling an agent turn through the host manager. */
|
|
121
|
-
export interface
|
|
123
|
+
export interface AgentManagerCancelTurn {
|
|
122
124
|
turnId: string;
|
|
123
125
|
reason?: string | undefined;
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
/** Shape accepted when listing events for an agent turn. */
|
|
127
|
-
export interface
|
|
129
|
+
export interface AgentManagerListTurnEvents {
|
|
128
130
|
turnId: string;
|
|
129
131
|
afterSeq?: bigint | number | undefined;
|
|
130
132
|
limit?: number | undefined;
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
/** Shape accepted when listing agent interactions. */
|
|
134
|
-
export interface
|
|
136
|
+
export interface AgentManagerListInteractions {
|
|
135
137
|
turnId: string;
|
|
136
138
|
}
|
|
137
139
|
|
|
138
140
|
/** Shape accepted when resolving an agent interaction. */
|
|
139
|
-
export interface
|
|
141
|
+
export interface AgentManagerResolveInteraction {
|
|
140
142
|
turnId: string;
|
|
141
143
|
interactionId: string;
|
|
142
144
|
resolution?: JsonObjectInput | undefined;
|
|
@@ -175,7 +177,7 @@ export class AgentManager {
|
|
|
175
177
|
|
|
176
178
|
/** Creates an agent session. */
|
|
177
179
|
async createSession(
|
|
178
|
-
request:
|
|
180
|
+
request: AgentManagerCreateSession,
|
|
179
181
|
): Promise<AgentSession> {
|
|
180
182
|
return agentSessionFromProto(
|
|
181
183
|
await this.client.createSession({
|
|
@@ -191,7 +193,7 @@ export class AgentManager {
|
|
|
191
193
|
}
|
|
192
194
|
|
|
193
195
|
/** Fetches one agent session. */
|
|
194
|
-
async getSession(request:
|
|
196
|
+
async getSession(request: AgentManagerGetSession): Promise<AgentSession> {
|
|
195
197
|
return agentSessionFromProto(
|
|
196
198
|
await this.client.getSession({
|
|
197
199
|
sessionId: request.sessionId,
|
|
@@ -202,7 +204,7 @@ export class AgentManager {
|
|
|
202
204
|
|
|
203
205
|
/** Lists agent sessions visible to the invocation token. */
|
|
204
206
|
async listSessions(
|
|
205
|
-
request:
|
|
207
|
+
request: AgentManagerListSessions = {},
|
|
206
208
|
): Promise<AgentSession[]> {
|
|
207
209
|
const response = await this.client.listSessions({
|
|
208
210
|
providerName: request.providerName ?? "",
|
|
@@ -216,7 +218,7 @@ export class AgentManager {
|
|
|
216
218
|
|
|
217
219
|
/** Updates mutable fields on an agent session. */
|
|
218
220
|
async updateSession(
|
|
219
|
-
request:
|
|
221
|
+
request: AgentManagerUpdateSession,
|
|
220
222
|
): Promise<AgentSession> {
|
|
221
223
|
return agentSessionFromProto(
|
|
222
224
|
await this.client.updateSession({
|
|
@@ -230,25 +232,27 @@ export class AgentManager {
|
|
|
230
232
|
}
|
|
231
233
|
|
|
232
234
|
/** Creates an agent turn. */
|
|
233
|
-
async createTurn(request:
|
|
235
|
+
async createTurn(request: AgentManagerCreateTurn): Promise<AgentTurn> {
|
|
234
236
|
return agentTurnFromProto(
|
|
235
237
|
await this.client.createTurn({
|
|
236
238
|
sessionId: request.sessionId,
|
|
237
239
|
model: request.model ?? "",
|
|
238
240
|
messages: request.messages?.map(agentMessageToProto) ?? [],
|
|
239
241
|
toolRefs: request.toolRefs?.map(agentToolRefToProto) ?? [],
|
|
242
|
+
toolRefsSet: request.toolRefsSet ?? (request.toolRefs !== undefined && request.toolRefs.length > 0),
|
|
240
243
|
toolSource: request.toolSource ?? AgentToolSourceMode.UNSPECIFIED,
|
|
241
244
|
responseSchema: optionalStruct(request.responseSchema),
|
|
242
245
|
metadata: optionalStruct(request.metadata),
|
|
243
246
|
idempotencyKey: request.idempotencyKey ?? "",
|
|
244
247
|
invocationToken: this.invocationToken,
|
|
245
248
|
modelOptions: optionalStruct(request.modelOptions),
|
|
249
|
+
timeoutSeconds: request.timeoutSeconds ?? 0,
|
|
246
250
|
}),
|
|
247
251
|
);
|
|
248
252
|
}
|
|
249
253
|
|
|
250
254
|
/** Fetches one agent turn. */
|
|
251
|
-
async getTurn(request:
|
|
255
|
+
async getTurn(request: AgentManagerGetTurn): Promise<AgentTurn> {
|
|
252
256
|
return agentTurnFromProto(
|
|
253
257
|
await this.client.getTurn({
|
|
254
258
|
turnId: request.turnId,
|
|
@@ -258,7 +262,7 @@ export class AgentManager {
|
|
|
258
262
|
}
|
|
259
263
|
|
|
260
264
|
/** Lists turns for an agent session. */
|
|
261
|
-
async listTurns(request:
|
|
265
|
+
async listTurns(request: AgentManagerListTurns): Promise<AgentTurn[]> {
|
|
262
266
|
const response = await this.client.listTurns({
|
|
263
267
|
sessionId: request.sessionId,
|
|
264
268
|
invocationToken: this.invocationToken,
|
|
@@ -270,7 +274,7 @@ export class AgentManager {
|
|
|
270
274
|
}
|
|
271
275
|
|
|
272
276
|
/** Cancels an in-progress agent turn. */
|
|
273
|
-
async cancelTurn(request:
|
|
277
|
+
async cancelTurn(request: AgentManagerCancelTurn): Promise<AgentTurn> {
|
|
274
278
|
return agentTurnFromProto(
|
|
275
279
|
await this.client.cancelTurn({
|
|
276
280
|
turnId: request.turnId,
|
|
@@ -282,7 +286,7 @@ export class AgentManager {
|
|
|
282
286
|
|
|
283
287
|
/** Lists events emitted for an agent turn. */
|
|
284
288
|
async listTurnEvents(
|
|
285
|
-
request:
|
|
289
|
+
request: AgentManagerListTurnEvents,
|
|
286
290
|
): Promise<AgentTurnEvent[]> {
|
|
287
291
|
const response = await this.client.listTurnEvents({
|
|
288
292
|
turnId: request.turnId,
|
|
@@ -295,7 +299,7 @@ export class AgentManager {
|
|
|
295
299
|
|
|
296
300
|
/** Lists pending or completed agent interactions. */
|
|
297
301
|
async listInteractions(
|
|
298
|
-
request:
|
|
302
|
+
request: AgentManagerListInteractions,
|
|
299
303
|
): Promise<AgentInteraction[]> {
|
|
300
304
|
const response = await this.client.listInteractions({
|
|
301
305
|
turnId: request.turnId,
|
|
@@ -306,7 +310,7 @@ export class AgentManager {
|
|
|
306
310
|
|
|
307
311
|
/** Resolves an agent interaction with a host response. */
|
|
308
312
|
async resolveInteraction(
|
|
309
|
-
request:
|
|
313
|
+
request: AgentManagerResolveInteraction,
|
|
310
314
|
): Promise<AgentInteraction> {
|
|
311
315
|
return agentInteractionFromProto(
|
|
312
316
|
await this.client.resolveInteraction({
|
package/src/agent.ts
CHANGED
|
@@ -40,8 +40,6 @@ import {
|
|
|
40
40
|
type AgentMessagePartToolCall as ProtoAgentMessagePartToolCall,
|
|
41
41
|
type AgentMessagePartToolResult as ProtoAgentMessagePartToolResult,
|
|
42
42
|
type AgentSession as ProtoAgentSession,
|
|
43
|
-
type AgentSubjectContext as ProtoAgentSubjectContext,
|
|
44
|
-
type AgentToolRef as ProtoAgentToolRef,
|
|
45
43
|
type AgentTurn as ProtoAgentTurn,
|
|
46
44
|
type AgentTurnEvent as ProtoAgentTurnEvent,
|
|
47
45
|
type CancelAgentProviderTurnRequest as ProtoCancelAgentProviderTurnRequest,
|
|
@@ -66,7 +64,17 @@ import {
|
|
|
66
64
|
type ResolvedAgentTool as ProtoResolvedAgentTool,
|
|
67
65
|
type UpdateAgentProviderSessionRequest as ProtoUpdateAgentProviderSessionRequest,
|
|
68
66
|
} from "./internal/gen/v1/agent_pb.ts";
|
|
69
|
-
import {
|
|
67
|
+
import {
|
|
68
|
+
type SubjectContext as ProtoSubjectContext,
|
|
69
|
+
type AgentToolRef as ProtoAgentToolRef,
|
|
70
|
+
} from "./internal/gen/v1/plugin_pb.ts";
|
|
71
|
+
import {
|
|
72
|
+
errorMessage,
|
|
73
|
+
type ExternalIdentity,
|
|
74
|
+
type MaybePromise,
|
|
75
|
+
type Subject,
|
|
76
|
+
type SubjectInput,
|
|
77
|
+
} from "./api.ts";
|
|
70
78
|
import {
|
|
71
79
|
agentActorFromProto,
|
|
72
80
|
agentActorToProto,
|
|
@@ -109,6 +117,7 @@ export type AgentMessagePartType =
|
|
|
109
117
|
export const AgentToolSourceMode = {
|
|
110
118
|
UNSPECIFIED: ProtoAgentToolSourceMode.UNSPECIFIED,
|
|
111
119
|
MCP_CATALOG: ProtoAgentToolSourceMode.MCP_CATALOG,
|
|
120
|
+
NONE: ProtoAgentToolSourceMode.NONE,
|
|
112
121
|
} as const;
|
|
113
122
|
export type AgentToolSourceMode =
|
|
114
123
|
(typeof AgentToolSourceMode)[keyof typeof AgentToolSourceMode];
|
|
@@ -196,14 +205,6 @@ export interface AgentActor {
|
|
|
196
205
|
authSource?: string | undefined;
|
|
197
206
|
}
|
|
198
207
|
|
|
199
|
-
export interface AgentSubjectContext {
|
|
200
|
-
subjectId?: string | undefined;
|
|
201
|
-
subjectKind?: string | undefined;
|
|
202
|
-
credentialSubjectId?: string | undefined;
|
|
203
|
-
displayName?: string | undefined;
|
|
204
|
-
authSource?: string | undefined;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
208
|
export interface AgentToolRef {
|
|
208
209
|
plugin?: string | undefined;
|
|
209
210
|
operation?: string | undefined;
|
|
@@ -212,6 +213,8 @@ export interface AgentToolRef {
|
|
|
212
213
|
title?: string | undefined;
|
|
213
214
|
description?: string | undefined;
|
|
214
215
|
system?: string | undefined;
|
|
216
|
+
runAs?: SubjectInput | undefined;
|
|
217
|
+
runAsExternalIdentity?: ExternalIdentity | undefined;
|
|
215
218
|
}
|
|
216
219
|
|
|
217
220
|
export interface ResolvedAgentTool {
|
|
@@ -279,18 +282,18 @@ export interface CreateAgentProviderSessionRequest {
|
|
|
279
282
|
clientRef: string;
|
|
280
283
|
metadata?: JsonObjectInput | undefined;
|
|
281
284
|
createdBy?: AgentActor | undefined;
|
|
282
|
-
subject?:
|
|
285
|
+
subject?: Subject | undefined;
|
|
283
286
|
sessionStart?: AgentSessionStartConfig | undefined;
|
|
284
287
|
preparedWorkspace?: AgentPreparedWorkspace | undefined;
|
|
285
288
|
}
|
|
286
289
|
|
|
287
290
|
export interface GetAgentProviderSessionRequest {
|
|
288
291
|
sessionId: string;
|
|
289
|
-
subject?:
|
|
292
|
+
subject?: Subject | undefined;
|
|
290
293
|
}
|
|
291
294
|
|
|
292
295
|
export interface ListAgentProviderSessionsRequest {
|
|
293
|
-
subject?:
|
|
296
|
+
subject?: Subject | undefined;
|
|
294
297
|
sessionIds: readonly string[];
|
|
295
298
|
state: AgentSessionState;
|
|
296
299
|
limit: number;
|
|
@@ -306,7 +309,7 @@ export interface UpdateAgentProviderSessionRequest {
|
|
|
306
309
|
clientRef: string;
|
|
307
310
|
state: AgentSessionState;
|
|
308
311
|
metadata?: JsonObjectInput | undefined;
|
|
309
|
-
subject?:
|
|
312
|
+
subject?: Subject | undefined;
|
|
310
313
|
}
|
|
311
314
|
|
|
312
315
|
export interface AgentTurn {
|
|
@@ -354,19 +357,20 @@ export interface CreateAgentProviderTurnRequest {
|
|
|
354
357
|
executionRef: string;
|
|
355
358
|
toolRefs: readonly AgentToolRef[];
|
|
356
359
|
toolSource: AgentToolSourceMode;
|
|
357
|
-
subject?:
|
|
360
|
+
subject?: Subject | undefined;
|
|
358
361
|
modelOptions?: JsonObjectInput | undefined;
|
|
359
362
|
runGrant: string;
|
|
363
|
+
timeoutSeconds: number;
|
|
360
364
|
}
|
|
361
365
|
|
|
362
366
|
export interface GetAgentProviderTurnRequest {
|
|
363
367
|
turnId: string;
|
|
364
|
-
subject?:
|
|
368
|
+
subject?: Subject | undefined;
|
|
365
369
|
}
|
|
366
370
|
|
|
367
371
|
export interface ListAgentProviderTurnsRequest {
|
|
368
372
|
sessionId: string;
|
|
369
|
-
subject?:
|
|
373
|
+
subject?: Subject | undefined;
|
|
370
374
|
turnIds: readonly string[];
|
|
371
375
|
status: AgentExecutionStatus;
|
|
372
376
|
limit: number;
|
|
@@ -380,7 +384,7 @@ export interface ListAgentProviderTurnsResponse {
|
|
|
380
384
|
export interface CancelAgentProviderTurnRequest {
|
|
381
385
|
turnId: string;
|
|
382
386
|
reason: string;
|
|
383
|
-
subject?:
|
|
387
|
+
subject?: Subject | undefined;
|
|
384
388
|
}
|
|
385
389
|
|
|
386
390
|
export interface AgentTurnEvent {
|
|
@@ -399,7 +403,7 @@ export interface ListAgentProviderTurnEventsRequest {
|
|
|
399
403
|
turnId: string;
|
|
400
404
|
afterSeq: bigint;
|
|
401
405
|
limit: number;
|
|
402
|
-
subject?:
|
|
406
|
+
subject?: Subject | undefined;
|
|
403
407
|
}
|
|
404
408
|
|
|
405
409
|
export interface ListAgentProviderTurnEventsResponse {
|
|
@@ -422,12 +426,12 @@ export interface AgentInteraction {
|
|
|
422
426
|
|
|
423
427
|
export interface GetAgentProviderInteractionRequest {
|
|
424
428
|
interactionId: string;
|
|
425
|
-
subject?:
|
|
429
|
+
subject?: Subject | undefined;
|
|
426
430
|
}
|
|
427
431
|
|
|
428
432
|
export interface ListAgentProviderInteractionsRequest {
|
|
429
433
|
turnId: string;
|
|
430
|
-
subject?:
|
|
434
|
+
subject?: Subject | undefined;
|
|
431
435
|
}
|
|
432
436
|
|
|
433
437
|
export interface ListAgentProviderInteractionsResponse {
|
|
@@ -437,7 +441,7 @@ export interface ListAgentProviderInteractionsResponse {
|
|
|
437
441
|
export interface ResolveAgentProviderInteractionRequest {
|
|
438
442
|
interactionId: string;
|
|
439
443
|
resolution?: JsonObjectInput | undefined;
|
|
440
|
-
subject?:
|
|
444
|
+
subject?: Subject | undefined;
|
|
441
445
|
}
|
|
442
446
|
|
|
443
447
|
export interface GetAgentProviderCapabilitiesRequest {}
|
|
@@ -836,6 +840,7 @@ function createAgentProviderTurnRequestFromProto(
|
|
|
836
840
|
subject: agentSubjectFromProto(request.subject),
|
|
837
841
|
modelOptions: optionalObjectFromStruct(request.modelOptions),
|
|
838
842
|
runGrant: request.runGrant,
|
|
843
|
+
timeoutSeconds: request.timeoutSeconds,
|
|
839
844
|
};
|
|
840
845
|
}
|
|
841
846
|
|
|
@@ -1008,17 +1013,18 @@ function resolvedAgentToolFromProto(tool: ProtoResolvedAgentTool): ResolvedAgent
|
|
|
1008
1013
|
}
|
|
1009
1014
|
|
|
1010
1015
|
function agentSubjectFromProto(
|
|
1011
|
-
subject?:
|
|
1012
|
-
):
|
|
1016
|
+
subject?: ProtoSubjectContext | undefined,
|
|
1017
|
+
): Subject | undefined {
|
|
1013
1018
|
if (subject === undefined) {
|
|
1014
1019
|
return undefined;
|
|
1015
1020
|
}
|
|
1016
1021
|
return {
|
|
1017
|
-
|
|
1018
|
-
|
|
1022
|
+
id: subject.id,
|
|
1023
|
+
kind: subject.kind,
|
|
1019
1024
|
credentialSubjectId: subject.credentialSubjectId,
|
|
1020
1025
|
displayName: subject.displayName,
|
|
1021
1026
|
authSource: subject.authSource,
|
|
1027
|
+
email: subject.email,
|
|
1022
1028
|
};
|
|
1023
1029
|
}
|
|
1024
1030
|
|
package/src/api.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Common request and response types shared across authored Gestalt providers.
|
|
3
3
|
*/
|
|
4
|
+
import type { AgentToolRef } from "./agent.ts";
|
|
5
|
+
|
|
4
6
|
export interface Subject {
|
|
5
7
|
id: string;
|
|
6
8
|
kind: string;
|
|
9
|
+
credentialSubjectId: string;
|
|
7
10
|
displayName: string;
|
|
8
11
|
authSource: string;
|
|
9
12
|
email: string;
|
|
@@ -15,6 +18,7 @@ export interface Subject {
|
|
|
15
18
|
export interface SubjectInput {
|
|
16
19
|
id: string;
|
|
17
20
|
kind: string;
|
|
21
|
+
credentialSubjectId?: string | undefined;
|
|
18
22
|
displayName: string;
|
|
19
23
|
authSource: string;
|
|
20
24
|
email?: string | undefined;
|
|
@@ -70,6 +74,8 @@ export interface Request {
|
|
|
70
74
|
// Workflow callback metadata uses a JSON-style lowerCamelCase object such as
|
|
71
75
|
// runId, target.plugin.pluginName, trigger.scheduleId, and trigger.event.specVersion.
|
|
72
76
|
workflow: Record<string, unknown>;
|
|
77
|
+
toolRefs: AgentToolRef[];
|
|
78
|
+
toolRefsSet: boolean;
|
|
73
79
|
invocationToken: string;
|
|
74
80
|
}
|
|
75
81
|
|
|
@@ -141,6 +147,8 @@ export function request(
|
|
|
141
147
|
agentSubject: Partial<Subject> = {},
|
|
142
148
|
externalIdentity: Partial<ExternalIdentity> = {},
|
|
143
149
|
agentExternalIdentity: Partial<ExternalIdentity> = {},
|
|
150
|
+
toolRefs: readonly AgentToolRef[] = [],
|
|
151
|
+
toolRefsSet = false,
|
|
144
152
|
): Request {
|
|
145
153
|
return {
|
|
146
154
|
token,
|
|
@@ -150,6 +158,7 @@ export function request(
|
|
|
150
158
|
subject: {
|
|
151
159
|
id: subject.id ?? "",
|
|
152
160
|
kind: subject.kind ?? "",
|
|
161
|
+
credentialSubjectId: subject.credentialSubjectId ?? "",
|
|
153
162
|
displayName: subject.displayName ?? "",
|
|
154
163
|
authSource: subject.authSource ?? "",
|
|
155
164
|
email: subject.email ?? "",
|
|
@@ -157,6 +166,7 @@ export function request(
|
|
|
157
166
|
agentSubject: {
|
|
158
167
|
id: agentSubject.id ?? "",
|
|
159
168
|
kind: agentSubject.kind ?? "",
|
|
169
|
+
credentialSubjectId: agentSubject.credentialSubjectId ?? "",
|
|
160
170
|
displayName: agentSubject.displayName ?? "",
|
|
161
171
|
authSource: agentSubject.authSource ?? "",
|
|
162
172
|
email: agentSubject.email ?? "",
|
|
@@ -182,6 +192,15 @@ export function request(
|
|
|
182
192
|
workflow: {
|
|
183
193
|
...workflow,
|
|
184
194
|
},
|
|
195
|
+
toolRefs: toolRefs.map((ref) => ({
|
|
196
|
+
...ref,
|
|
197
|
+
runAs: ref.runAs === undefined ? undefined : { ...ref.runAs },
|
|
198
|
+
runAsExternalIdentity:
|
|
199
|
+
ref.runAsExternalIdentity === undefined
|
|
200
|
+
? undefined
|
|
201
|
+
: { ...ref.runAsExternalIdentity },
|
|
202
|
+
})),
|
|
203
|
+
toolRefsSet,
|
|
185
204
|
host: {
|
|
186
205
|
publicBaseUrl: host.publicBaseUrl ?? "",
|
|
187
206
|
},
|