@valon-technologies/gestalt 0.0.1-alpha.37 → 0.0.1-alpha.38
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/package.json +1 -1
- package/src/agent-access.ts +14 -16
- package/src/agent-conversions.ts +2 -0
- package/src/agent.ts +1 -38
- package/src/api.ts +0 -3
- package/src/app-access.ts +7 -52
- package/src/index.ts +0 -1
- package/src/internal/gen/v1/agent_pb.ts +1 -136
- package/src/internal/gen/v1/app_pb.ts +27 -134
- package/src/internal/gen/v1/workflow_pb.ts +1 -76
- package/src/runtime.ts +6 -9
- package/src/workflow-access.ts +19 -24
- package/src/workflow.ts +10 -31
- package/src/invocation-context.ts +0 -28
package/package.json
CHANGED
package/src/agent-access.ts
CHANGED
|
@@ -48,7 +48,6 @@ import {
|
|
|
48
48
|
ENV_HOST_SERVICE_SOCKET,
|
|
49
49
|
ENV_HOST_SERVICE_TOKEN,
|
|
50
50
|
} from "./host-service.ts";
|
|
51
|
-
import { hostInvocationContext } from "./invocation-context.ts";
|
|
52
51
|
|
|
53
52
|
export interface AgentWorkspaceGitCheckout {
|
|
54
53
|
url?: string | undefined;
|
|
@@ -168,12 +167,11 @@ export interface Agent {
|
|
|
168
167
|
*/
|
|
169
168
|
class AgentImpl implements Agent {
|
|
170
169
|
private readonly client: Client<typeof AgentProviderService>;
|
|
171
|
-
private readonly
|
|
170
|
+
private readonly context: Request["__requestContext"];
|
|
172
171
|
|
|
173
172
|
constructor(request: Request);
|
|
174
|
-
constructor(
|
|
175
|
-
|
|
176
|
-
this.invocationContext = hostInvocationContext(requestOrToken);
|
|
173
|
+
constructor(request: Request) {
|
|
174
|
+
this.context = request.__requestContext;
|
|
177
175
|
|
|
178
176
|
const target = process.env[ENV_HOST_SERVICE_SOCKET]?.trim();
|
|
179
177
|
if (!target) {
|
|
@@ -200,7 +198,7 @@ class AgentImpl implements Agent {
|
|
|
200
198
|
clientRef: request.clientRef ?? "",
|
|
201
199
|
metadata: optionalStruct(request.metadata),
|
|
202
200
|
idempotencyKey: request.idempotencyKey ?? "",
|
|
203
|
-
|
|
201
|
+
context: this.context,
|
|
204
202
|
workspace: workspaceToProto(request.workspace),
|
|
205
203
|
}),
|
|
206
204
|
);
|
|
@@ -211,7 +209,7 @@ class AgentImpl implements Agent {
|
|
|
211
209
|
return agentSessionFromProto(
|
|
212
210
|
await this.client.getSession({
|
|
213
211
|
sessionId: request.sessionId,
|
|
214
|
-
|
|
212
|
+
context: this.context,
|
|
215
213
|
}),
|
|
216
214
|
);
|
|
217
215
|
}
|
|
@@ -222,7 +220,7 @@ class AgentImpl implements Agent {
|
|
|
222
220
|
): Promise<AgentSession[]> {
|
|
223
221
|
const response = await this.client.listSessions({
|
|
224
222
|
providerName: request.providerName ?? "",
|
|
225
|
-
|
|
223
|
+
context: this.context,
|
|
226
224
|
state: request.state ?? AgentSessionState.UNSPECIFIED,
|
|
227
225
|
limit: request.limit ?? 0,
|
|
228
226
|
summaryOnly: request.summaryOnly ?? false,
|
|
@@ -240,7 +238,7 @@ class AgentImpl implements Agent {
|
|
|
240
238
|
clientRef: request.clientRef ?? "",
|
|
241
239
|
state: request.state ?? AgentSessionState.UNSPECIFIED,
|
|
242
240
|
metadata: optionalStruct(request.metadata),
|
|
243
|
-
|
|
241
|
+
context: this.context,
|
|
244
242
|
}),
|
|
245
243
|
);
|
|
246
244
|
}
|
|
@@ -261,7 +259,7 @@ class AgentImpl implements Agent {
|
|
|
261
259
|
output: agentOutputToProto(request.output),
|
|
262
260
|
metadata: optionalStruct(request.metadata),
|
|
263
261
|
idempotencyKey: request.idempotencyKey ?? "",
|
|
264
|
-
|
|
262
|
+
context: this.context,
|
|
265
263
|
modelOptions: optionalStruct(request.modelOptions),
|
|
266
264
|
timeoutSeconds,
|
|
267
265
|
}),
|
|
@@ -273,7 +271,7 @@ class AgentImpl implements Agent {
|
|
|
273
271
|
return agentTurnFromProto(
|
|
274
272
|
await this.client.getTurn({
|
|
275
273
|
turnId: request.turnId,
|
|
276
|
-
|
|
274
|
+
context: this.context,
|
|
277
275
|
}),
|
|
278
276
|
);
|
|
279
277
|
}
|
|
@@ -282,7 +280,7 @@ class AgentImpl implements Agent {
|
|
|
282
280
|
async listTurns(request: AgentListTurns): Promise<AgentTurn[]> {
|
|
283
281
|
const response = await this.client.listTurns({
|
|
284
282
|
sessionId: request.sessionId,
|
|
285
|
-
|
|
283
|
+
context: this.context,
|
|
286
284
|
status: request.status ?? AgentExecutionStatus.UNSPECIFIED,
|
|
287
285
|
limit: request.limit ?? 0,
|
|
288
286
|
summaryOnly: request.summaryOnly ?? false,
|
|
@@ -296,7 +294,7 @@ class AgentImpl implements Agent {
|
|
|
296
294
|
await this.client.cancelTurn({
|
|
297
295
|
turnId: request.turnId,
|
|
298
296
|
reason: request.reason ?? "",
|
|
299
|
-
|
|
297
|
+
context: this.context,
|
|
300
298
|
}),
|
|
301
299
|
);
|
|
302
300
|
}
|
|
@@ -309,7 +307,7 @@ class AgentImpl implements Agent {
|
|
|
309
307
|
turnId: request.turnId,
|
|
310
308
|
afterSeq: BigInt(request.afterSeq ?? 0),
|
|
311
309
|
limit: request.limit ?? 0,
|
|
312
|
-
|
|
310
|
+
context: this.context,
|
|
313
311
|
});
|
|
314
312
|
return response.events.map(agentTurnEventFromProto);
|
|
315
313
|
}
|
|
@@ -320,7 +318,7 @@ class AgentImpl implements Agent {
|
|
|
320
318
|
): Promise<AgentInteraction[]> {
|
|
321
319
|
const response = await this.client.listInteractions({
|
|
322
320
|
turnId: request.turnId,
|
|
323
|
-
|
|
321
|
+
context: this.context,
|
|
324
322
|
});
|
|
325
323
|
return response.interactions.map(agentInteractionFromProto);
|
|
326
324
|
}
|
|
@@ -334,7 +332,7 @@ class AgentImpl implements Agent {
|
|
|
334
332
|
turnId: request.turnId,
|
|
335
333
|
interactionId: request.interactionId,
|
|
336
334
|
resolution: optionalStruct(request.resolution),
|
|
337
|
-
|
|
335
|
+
context: this.context,
|
|
338
336
|
}),
|
|
339
337
|
);
|
|
340
338
|
}
|
package/src/agent-conversions.ts
CHANGED
|
@@ -273,6 +273,7 @@ export function agentToolRefFromProto(ref: ProtoAgentToolRef): AgentToolRef {
|
|
|
273
273
|
instance: ref.instance,
|
|
274
274
|
title: ref.title,
|
|
275
275
|
description: ref.description,
|
|
276
|
+
credentialMode: ref.credentialMode,
|
|
276
277
|
system: ref.system,
|
|
277
278
|
runAs: agentRunAsSubjectFromProto(ref.runAs),
|
|
278
279
|
};
|
|
@@ -286,6 +287,7 @@ export function agentToolRefToProto(ref: AgentToolRef): ProtoAgentToolRef {
|
|
|
286
287
|
instance: ref.instance ?? "",
|
|
287
288
|
title: ref.title ?? "",
|
|
288
289
|
description: ref.description ?? "",
|
|
290
|
+
credentialMode: ref.credentialMode ?? "",
|
|
289
291
|
system: ref.system ?? "",
|
|
290
292
|
runAs: agentRunAsSubjectToProto(ref.runAs),
|
|
291
293
|
});
|
package/src/agent.ts
CHANGED
|
@@ -208,6 +208,7 @@ export interface AgentToolRef {
|
|
|
208
208
|
instance?: string | undefined;
|
|
209
209
|
title?: string | undefined;
|
|
210
210
|
description?: string | undefined;
|
|
211
|
+
credentialMode?: string | undefined;
|
|
211
212
|
system?: string | undefined;
|
|
212
213
|
runAs?: SubjectInput | undefined;
|
|
213
214
|
}
|
|
@@ -277,7 +278,6 @@ export interface CreateAgentProviderSessionRequest {
|
|
|
277
278
|
metadata?: JsonObjectInput | undefined;
|
|
278
279
|
createdBySubjectId?: string | undefined;
|
|
279
280
|
subject?: Subject | undefined;
|
|
280
|
-
invocationToken: string;
|
|
281
281
|
context?: ProtoRequestContext | undefined;
|
|
282
282
|
sessionStart?: AgentSessionStartConfig | undefined;
|
|
283
283
|
preparedWorkspace?: AgentPreparedWorkspace | undefined;
|
|
@@ -286,14 +286,12 @@ export interface CreateAgentProviderSessionRequest {
|
|
|
286
286
|
export interface GetAgentProviderSessionRequest {
|
|
287
287
|
sessionId: string;
|
|
288
288
|
subject?: Subject | undefined;
|
|
289
|
-
invocationToken: string;
|
|
290
289
|
context?: ProtoRequestContext | undefined;
|
|
291
290
|
}
|
|
292
291
|
|
|
293
292
|
export interface ListAgentProviderSessionsRequest {
|
|
294
293
|
providerName?: string | undefined;
|
|
295
294
|
subject?: Subject | undefined;
|
|
296
|
-
invocationToken: string;
|
|
297
295
|
context?: ProtoRequestContext | undefined;
|
|
298
296
|
sessionIds: readonly string[];
|
|
299
297
|
state: AgentSessionState;
|
|
@@ -311,7 +309,6 @@ export interface UpdateAgentProviderSessionRequest {
|
|
|
311
309
|
state: AgentSessionState;
|
|
312
310
|
metadata?: JsonObjectInput | undefined;
|
|
313
311
|
subject?: Subject | undefined;
|
|
314
|
-
invocationToken: string;
|
|
315
312
|
context?: ProtoRequestContext | undefined;
|
|
316
313
|
}
|
|
317
314
|
|
|
@@ -370,8 +367,6 @@ export interface CreateAgentProviderTurnRequest {
|
|
|
370
367
|
toolSource: AgentToolSourceMode;
|
|
371
368
|
subject?: Subject | undefined;
|
|
372
369
|
modelOptions?: JsonObjectInput | undefined;
|
|
373
|
-
runGrant: string;
|
|
374
|
-
invocationToken: string;
|
|
375
370
|
context?: ProtoRequestContext | undefined;
|
|
376
371
|
timeoutSeconds: number;
|
|
377
372
|
}
|
|
@@ -390,14 +385,12 @@ export type AgentOutput =
|
|
|
390
385
|
export interface GetAgentProviderTurnRequest {
|
|
391
386
|
turnId: string;
|
|
392
387
|
subject?: Subject | undefined;
|
|
393
|
-
invocationToken: string;
|
|
394
388
|
context?: ProtoRequestContext | undefined;
|
|
395
389
|
}
|
|
396
390
|
|
|
397
391
|
export interface ListAgentProviderTurnsRequest {
|
|
398
392
|
sessionId: string;
|
|
399
393
|
subject?: Subject | undefined;
|
|
400
|
-
invocationToken: string;
|
|
401
394
|
context?: ProtoRequestContext | undefined;
|
|
402
395
|
turnIds: readonly string[];
|
|
403
396
|
status: AgentExecutionStatus;
|
|
@@ -413,7 +406,6 @@ export interface CancelAgentProviderTurnRequest {
|
|
|
413
406
|
turnId: string;
|
|
414
407
|
reason: string;
|
|
415
408
|
subject?: Subject | undefined;
|
|
416
|
-
invocationToken: string;
|
|
417
409
|
context?: ProtoRequestContext | undefined;
|
|
418
410
|
}
|
|
419
411
|
|
|
@@ -434,7 +426,6 @@ export interface ListAgentProviderTurnEventsRequest {
|
|
|
434
426
|
afterSeq: bigint;
|
|
435
427
|
limit: number;
|
|
436
428
|
subject?: Subject | undefined;
|
|
437
|
-
invocationToken: string;
|
|
438
429
|
context?: ProtoRequestContext | undefined;
|
|
439
430
|
}
|
|
440
431
|
|
|
@@ -459,14 +450,12 @@ export interface AgentInteraction {
|
|
|
459
450
|
export interface GetAgentProviderInteractionRequest {
|
|
460
451
|
interactionId: string;
|
|
461
452
|
subject?: Subject | undefined;
|
|
462
|
-
invocationToken: string;
|
|
463
453
|
context?: ProtoRequestContext | undefined;
|
|
464
454
|
}
|
|
465
455
|
|
|
466
456
|
export interface ListAgentProviderInteractionsRequest {
|
|
467
457
|
turnId: string;
|
|
468
458
|
subject?: Subject | undefined;
|
|
469
|
-
invocationToken: string;
|
|
470
459
|
context?: ProtoRequestContext | undefined;
|
|
471
460
|
}
|
|
472
461
|
|
|
@@ -479,7 +468,6 @@ export interface ResolveAgentProviderInteractionRequest {
|
|
|
479
468
|
interactionId: string;
|
|
480
469
|
resolution?: JsonObjectInput | undefined;
|
|
481
470
|
subject?: Subject | undefined;
|
|
482
|
-
invocationToken: string;
|
|
483
471
|
context?: ProtoRequestContext | undefined;
|
|
484
472
|
}
|
|
485
473
|
|
|
@@ -492,7 +480,6 @@ export interface ExecuteAgentToolRequest {
|
|
|
492
480
|
toolId: string;
|
|
493
481
|
arguments?: JsonObjectInput | undefined;
|
|
494
482
|
idempotencyKey?: string | undefined;
|
|
495
|
-
runGrant?: string | undefined;
|
|
496
483
|
context?: ProtoRequestContext | undefined;
|
|
497
484
|
}
|
|
498
485
|
|
|
@@ -527,7 +514,6 @@ export interface ListAgentToolsRequest {
|
|
|
527
514
|
pageSize?: number | undefined;
|
|
528
515
|
pageToken?: string | undefined;
|
|
529
516
|
query?: string | undefined;
|
|
530
|
-
runGrant?: string | undefined;
|
|
531
517
|
context?: ProtoRequestContext | undefined;
|
|
532
518
|
}
|
|
533
519
|
|
|
@@ -541,7 +527,6 @@ export interface ResolveAgentConnectionRequest {
|
|
|
541
527
|
turnId: string;
|
|
542
528
|
connection: string;
|
|
543
529
|
instance?: string | undefined;
|
|
544
|
-
runGrant?: string | undefined;
|
|
545
530
|
context?: ProtoRequestContext | undefined;
|
|
546
531
|
}
|
|
547
532
|
|
|
@@ -561,7 +546,6 @@ export interface AgentHostListToolsInput {
|
|
|
561
546
|
pageSize?: number | undefined;
|
|
562
547
|
pageToken?: string | undefined;
|
|
563
548
|
query?: string | undefined;
|
|
564
|
-
runGrant?: string | undefined;
|
|
565
549
|
context?: ProtoRequestContext | undefined;
|
|
566
550
|
}
|
|
567
551
|
|
|
@@ -573,7 +557,6 @@ export interface AgentHostExecuteToolInput {
|
|
|
573
557
|
toolId: string;
|
|
574
558
|
arguments?: JsonObjectInput | undefined;
|
|
575
559
|
idempotencyKey?: string | undefined;
|
|
576
|
-
runGrant?: string | undefined;
|
|
577
560
|
context?: ProtoRequestContext | undefined;
|
|
578
561
|
}
|
|
579
562
|
|
|
@@ -583,7 +566,6 @@ export interface AgentHostResolveConnectionInput {
|
|
|
583
566
|
turnId: string;
|
|
584
567
|
connection: string;
|
|
585
568
|
instance?: string | undefined;
|
|
586
|
-
runGrant?: string | undefined;
|
|
587
569
|
context?: ProtoRequestContext | undefined;
|
|
588
570
|
}
|
|
589
571
|
|
|
@@ -832,7 +814,6 @@ function createAgentProviderSessionRequestFromProto(
|
|
|
832
814
|
metadata: optionalObjectFromStruct(request.metadata),
|
|
833
815
|
createdBySubjectId: request.createdBySubjectId ?? "",
|
|
834
816
|
subject: agentRequestSubjectFromProto(request),
|
|
835
|
-
invocationToken: request.invocationToken,
|
|
836
817
|
context: request.context,
|
|
837
818
|
sessionStart: request.sessionStart === undefined ? undefined : {
|
|
838
819
|
hooks: request.sessionStart.hooks.map((hook) => ({
|
|
@@ -861,7 +842,6 @@ function getAgentProviderSessionRequestFromProto(
|
|
|
861
842
|
return {
|
|
862
843
|
sessionId: request.sessionId,
|
|
863
844
|
subject: agentRequestSubjectFromProto(request),
|
|
864
|
-
invocationToken: request.invocationToken,
|
|
865
845
|
context: request.context,
|
|
866
846
|
};
|
|
867
847
|
}
|
|
@@ -872,7 +852,6 @@ function listAgentProviderSessionsRequestFromProto(
|
|
|
872
852
|
return {
|
|
873
853
|
providerName: request.providerName,
|
|
874
854
|
subject: agentRequestSubjectFromProto(request),
|
|
875
|
-
invocationToken: request.invocationToken,
|
|
876
855
|
context: request.context,
|
|
877
856
|
sessionIds: [...request.sessionIds],
|
|
878
857
|
state: request.state as AgentSessionState,
|
|
@@ -890,7 +869,6 @@ function updateAgentProviderSessionRequestFromProto(
|
|
|
890
869
|
state: request.state as AgentSessionState,
|
|
891
870
|
metadata: optionalObjectFromStruct(request.metadata),
|
|
892
871
|
subject: agentRequestSubjectFromProto(request),
|
|
893
|
-
invocationToken: request.invocationToken,
|
|
894
872
|
context: request.context,
|
|
895
873
|
};
|
|
896
874
|
}
|
|
@@ -928,8 +906,6 @@ function createAgentProviderTurnRequestFromProto(
|
|
|
928
906
|
toolSource: request.toolSource as AgentToolSourceMode,
|
|
929
907
|
subject: agentRequestSubjectFromProto(request),
|
|
930
908
|
modelOptions: optionalObjectFromStruct(request.modelOptions),
|
|
931
|
-
runGrant: request.runGrant,
|
|
932
|
-
invocationToken: request.invocationToken,
|
|
933
909
|
context: request.context,
|
|
934
910
|
timeoutSeconds: request.timeoutSeconds,
|
|
935
911
|
};
|
|
@@ -941,7 +917,6 @@ function getAgentProviderTurnRequestFromProto(
|
|
|
941
917
|
return {
|
|
942
918
|
turnId: request.turnId,
|
|
943
919
|
subject: agentRequestSubjectFromProto(request),
|
|
944
|
-
invocationToken: request.invocationToken,
|
|
945
920
|
context: request.context,
|
|
946
921
|
};
|
|
947
922
|
}
|
|
@@ -952,7 +927,6 @@ function listAgentProviderTurnsRequestFromProto(
|
|
|
952
927
|
return {
|
|
953
928
|
sessionId: request.sessionId,
|
|
954
929
|
subject: agentRequestSubjectFromProto(request),
|
|
955
|
-
invocationToken: request.invocationToken,
|
|
956
930
|
context: request.context,
|
|
957
931
|
turnIds: [...request.turnIds],
|
|
958
932
|
status: request.status as AgentExecutionStatus,
|
|
@@ -968,7 +942,6 @@ function cancelAgentProviderTurnRequestFromProto(
|
|
|
968
942
|
turnId: request.turnId,
|
|
969
943
|
reason: request.reason,
|
|
970
944
|
subject: agentRequestSubjectFromProto(request),
|
|
971
|
-
invocationToken: request.invocationToken,
|
|
972
945
|
context: request.context,
|
|
973
946
|
};
|
|
974
947
|
}
|
|
@@ -981,7 +954,6 @@ function listAgentProviderTurnEventsRequestFromProto(
|
|
|
981
954
|
afterSeq: request.afterSeq,
|
|
982
955
|
limit: request.limit,
|
|
983
956
|
subject: agentRequestSubjectFromProto(request),
|
|
984
|
-
invocationToken: request.invocationToken,
|
|
985
957
|
context: request.context,
|
|
986
958
|
};
|
|
987
959
|
}
|
|
@@ -992,7 +964,6 @@ function getAgentProviderInteractionRequestFromProto(
|
|
|
992
964
|
return {
|
|
993
965
|
interactionId: request.interactionId,
|
|
994
966
|
subject: agentRequestSubjectFromProto(request),
|
|
995
|
-
invocationToken: request.invocationToken,
|
|
996
967
|
context: request.context,
|
|
997
968
|
};
|
|
998
969
|
}
|
|
@@ -1003,7 +974,6 @@ function listAgentProviderInteractionsRequestFromProto(
|
|
|
1003
974
|
return {
|
|
1004
975
|
turnId: request.turnId,
|
|
1005
976
|
subject: agentRequestSubjectFromProto(request),
|
|
1006
|
-
invocationToken: request.invocationToken,
|
|
1007
977
|
context: request.context,
|
|
1008
978
|
};
|
|
1009
979
|
}
|
|
@@ -1016,7 +986,6 @@ function resolveAgentProviderInteractionRequestFromProto(
|
|
|
1016
986
|
interactionId: request.interactionId,
|
|
1017
987
|
resolution: optionalObjectFromStruct(request.resolution),
|
|
1018
988
|
subject: agentRequestSubjectFromProto(request),
|
|
1019
|
-
invocationToken: request.invocationToken,
|
|
1020
989
|
context: request.context,
|
|
1021
990
|
};
|
|
1022
991
|
}
|
|
@@ -1164,7 +1133,6 @@ function executeToolRequestToProto(
|
|
|
1164
1133
|
toolId: request.toolId,
|
|
1165
1134
|
arguments: optionalStruct(request.arguments),
|
|
1166
1135
|
idempotencyKey: request.idempotencyKey ?? "",
|
|
1167
|
-
runGrant: request.runGrant ?? "",
|
|
1168
1136
|
context: request.context,
|
|
1169
1137
|
});
|
|
1170
1138
|
}
|
|
@@ -1185,7 +1153,6 @@ function listToolsRequestToProto(request: ListAgentToolsRequest): ProtoListAgent
|
|
|
1185
1153
|
pageSize: request.pageSize ?? 0,
|
|
1186
1154
|
pageToken: request.pageToken ?? "",
|
|
1187
1155
|
query: request.query ?? "",
|
|
1188
|
-
runGrant: request.runGrant ?? "",
|
|
1189
1156
|
context: request.context,
|
|
1190
1157
|
});
|
|
1191
1158
|
}
|
|
@@ -1227,7 +1194,6 @@ function resolveConnectionRequestToProto(
|
|
|
1227
1194
|
turnId: request.turnId,
|
|
1228
1195
|
connection: request.connection,
|
|
1229
1196
|
instance: request.instance ?? "",
|
|
1230
|
-
runGrant: request.runGrant ?? "",
|
|
1231
1197
|
context: request.context,
|
|
1232
1198
|
});
|
|
1233
1199
|
}
|
|
@@ -1299,7 +1265,6 @@ class AgentHostImpl implements AgentHost {
|
|
|
1299
1265
|
toolId: input.toolId,
|
|
1300
1266
|
arguments: input.arguments,
|
|
1301
1267
|
idempotencyKey: input.idempotencyKey ?? "",
|
|
1302
|
-
runGrant: input.runGrant ?? "",
|
|
1303
1268
|
context: input.context,
|
|
1304
1269
|
},
|
|
1305
1270
|
);
|
|
@@ -1325,7 +1290,6 @@ class AgentHostImpl implements AgentHost {
|
|
|
1325
1290
|
pageSize: input.pageSize ?? 0,
|
|
1326
1291
|
pageToken: input.pageToken ?? "",
|
|
1327
1292
|
query: input.query ?? "",
|
|
1328
|
-
runGrant: input.runGrant ?? "",
|
|
1329
1293
|
context: input.context,
|
|
1330
1294
|
},
|
|
1331
1295
|
);
|
|
@@ -1350,7 +1314,6 @@ class AgentHostImpl implements AgentHost {
|
|
|
1350
1314
|
turnId: input.turnId,
|
|
1351
1315
|
connection: input.connection,
|
|
1352
1316
|
instance: input.instance ?? "",
|
|
1353
|
-
runGrant: input.runGrant ?? "",
|
|
1354
1317
|
context: input.context,
|
|
1355
1318
|
},
|
|
1356
1319
|
);
|
package/src/api.ts
CHANGED
|
@@ -74,7 +74,6 @@ export interface Request {
|
|
|
74
74
|
workflow: Record<string, unknown>;
|
|
75
75
|
toolRefs: AgentToolRef[];
|
|
76
76
|
toolRefsSet: boolean;
|
|
77
|
-
invocationToken: string;
|
|
78
77
|
__requestContext?: ProtoRequestContext | undefined;
|
|
79
78
|
}
|
|
80
79
|
|
|
@@ -168,7 +167,6 @@ export function request(
|
|
|
168
167
|
credential: Partial<Credential> = {},
|
|
169
168
|
access: Partial<Access> = {},
|
|
170
169
|
workflow: Record<string, unknown> = {},
|
|
171
|
-
invocationToken = "",
|
|
172
170
|
idempotencyKey = "",
|
|
173
171
|
host: Partial<Host> = {},
|
|
174
172
|
agentSubject: Partial<Subject> = {},
|
|
@@ -222,7 +220,6 @@ export function request(
|
|
|
222
220
|
host: {
|
|
223
221
|
publicBaseUrl: host.publicBaseUrl ?? "",
|
|
224
222
|
},
|
|
225
|
-
invocationToken,
|
|
226
223
|
__requestContext: requestContext,
|
|
227
224
|
idempotencyKey: idempotencyKey.trim(),
|
|
228
225
|
};
|
package/src/app-access.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
structFromObject,
|
|
9
9
|
type JsonObjectInput,
|
|
10
10
|
} from "./protocol.ts";
|
|
11
|
-
import { hostInvocationContext } from "./invocation-context.ts";
|
|
12
11
|
import {
|
|
13
12
|
createHostServiceGrpcTransport,
|
|
14
13
|
hostServiceMetadataInterceptors,
|
|
@@ -28,18 +27,6 @@ export interface AppInvokeOptions {
|
|
|
28
27
|
credentialMode?: ConnectionMode;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
/** Grant included when exchanging an invocation token for a child token. */
|
|
32
|
-
export interface AppInvocationGrant {
|
|
33
|
-
/** App name that the child token may invoke. */
|
|
34
|
-
app: string;
|
|
35
|
-
/** Specific operation ids allowed by the child token. */
|
|
36
|
-
operations?: string[];
|
|
37
|
-
/** Surface names allowed by the child token. */
|
|
38
|
-
surfaces?: string[];
|
|
39
|
-
/** Whether the child token may invoke every operation on the app. */
|
|
40
|
-
allOperations?: boolean;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
30
|
/** Options for invoking an app GraphQL surface. */
|
|
44
31
|
export interface AppGraphQLInvokeOptions
|
|
45
32
|
extends Pick<AppInvokeOptions, "connection" | "instance" | "idempotencyKey"> {
|
|
@@ -60,27 +47,21 @@ export interface App {
|
|
|
60
47
|
document: string,
|
|
61
48
|
options?: AppGraphQLInvokeOptions,
|
|
62
49
|
): Promise<OperationResult>;
|
|
63
|
-
exchangeInvocationToken(options?: {
|
|
64
|
-
grants?: AppInvocationGrant[];
|
|
65
|
-
ttlSeconds?: number;
|
|
66
|
-
}): Promise<string>;
|
|
67
50
|
}
|
|
68
51
|
|
|
69
52
|
/**
|
|
70
53
|
* Transport-backed implementation for invoking sibling app operations.
|
|
71
54
|
*
|
|
72
|
-
* The constructor accepts
|
|
73
|
-
*
|
|
74
|
-
* when available.
|
|
55
|
+
* The constructor accepts a Gestalt request and forwards its host request
|
|
56
|
+
* context to every operation and GraphQL request.
|
|
75
57
|
*/
|
|
76
58
|
class AppImpl implements App {
|
|
77
59
|
private readonly client: Client<typeof AppService>;
|
|
78
|
-
private readonly
|
|
60
|
+
private readonly request: Request;
|
|
79
61
|
|
|
80
62
|
constructor(request: Request);
|
|
81
|
-
constructor(
|
|
82
|
-
|
|
83
|
-
this.invocationContext = hostInvocationContext(requestOrToken);
|
|
63
|
+
constructor(request: Request) {
|
|
64
|
+
this.request = request;
|
|
84
65
|
|
|
85
66
|
const { target, token } = requireHostServiceTarget("app");
|
|
86
67
|
const transport = createHostServiceGrpcTransport(
|
|
@@ -98,7 +79,6 @@ class AppImpl implements App {
|
|
|
98
79
|
options?: AppInvokeOptions,
|
|
99
80
|
): Promise<OperationResult> {
|
|
100
81
|
const response = await this.client.invoke({
|
|
101
|
-
...this.invocationContext,
|
|
102
82
|
app,
|
|
103
83
|
operation,
|
|
104
84
|
params: structFromObject(params),
|
|
@@ -106,6 +86,7 @@ class AppImpl implements App {
|
|
|
106
86
|
instance: options?.instance ?? "",
|
|
107
87
|
idempotencyKey: options?.idempotencyKey?.trim() ?? "",
|
|
108
88
|
credentialMode: options?.credentialMode?.trim() ?? "",
|
|
89
|
+
context: this.request.__requestContext,
|
|
109
90
|
});
|
|
110
91
|
return {
|
|
111
92
|
status: response.status,
|
|
@@ -126,8 +107,6 @@ class AppImpl implements App {
|
|
|
126
107
|
}
|
|
127
108
|
|
|
128
109
|
const response = await this.client.invokeGraphQL({
|
|
129
|
-
invocationToken: this.invocationContext.invocationToken,
|
|
130
|
-
context: this.invocationContext.context,
|
|
131
110
|
app,
|
|
132
111
|
document: trimmedDocument,
|
|
133
112
|
...(options?.variables !== undefined
|
|
@@ -136,6 +115,7 @@ class AppImpl implements App {
|
|
|
136
115
|
connection: options?.connection ?? "",
|
|
137
116
|
instance: options?.instance ?? "",
|
|
138
117
|
idempotencyKey: options?.idempotencyKey?.trim() ?? "",
|
|
118
|
+
context: this.request.__requestContext,
|
|
139
119
|
});
|
|
140
120
|
return {
|
|
141
121
|
status: response.status,
|
|
@@ -144,31 +124,6 @@ class AppImpl implements App {
|
|
|
144
124
|
};
|
|
145
125
|
}
|
|
146
126
|
|
|
147
|
-
/** Exchanges this invocation token for a narrower child token. */
|
|
148
|
-
async exchangeInvocationToken(options?: {
|
|
149
|
-
/** Grants to attach to the child token. */
|
|
150
|
-
grants?: AppInvocationGrant[];
|
|
151
|
-
/** Requested child-token time-to-live in seconds. */
|
|
152
|
-
ttlSeconds?: number;
|
|
153
|
-
}): Promise<string> {
|
|
154
|
-
const response = await this.client.exchangeInvocationToken({
|
|
155
|
-
parentInvocationToken: this.invocationContext.invocationToken,
|
|
156
|
-
grants: (options?.grants ?? [])
|
|
157
|
-
.map((grant) => ({
|
|
158
|
-
app: grant.app.trim(),
|
|
159
|
-
operations: (grant.operations ?? [])
|
|
160
|
-
.map((operation) => operation.trim())
|
|
161
|
-
.filter(Boolean),
|
|
162
|
-
surfaces: (grant.surfaces ?? [])
|
|
163
|
-
.map((surface) => surface.trim().toLowerCase())
|
|
164
|
-
.filter(Boolean),
|
|
165
|
-
allOperations: grant.allOperations ?? false,
|
|
166
|
-
}))
|
|
167
|
-
.filter((grant) => grant.app.length > 0),
|
|
168
|
-
ttlSeconds: BigInt(Math.max(0, options?.ttlSeconds ?? 0)),
|
|
169
|
-
});
|
|
170
|
-
return response.invocationToken;
|
|
171
|
-
}
|
|
172
127
|
}
|
|
173
128
|
|
|
174
129
|
export const App = AppImpl;
|