@valon-technologies/gestalt 0.0.1-alpha.14 → 0.0.1-alpha.17
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 +70 -80
- package/package.json +2 -2
- package/src/agent-manager.ts +33 -2
- package/src/agent.ts +20 -11
- package/src/authorization.ts +1 -1
- package/src/build.ts +2 -0
- package/src/cache.ts +12 -2
- package/src/index.ts +0 -5
- package/src/indexeddb.ts +1 -1
- package/{gen → src/internal/gen}/v1/agent_pb.ts +64 -178
- package/{gen → src/internal/gen}/v1/pluginruntime_pb.ts +15 -130
- package/{gen → src/internal/gen}/v1/workflow_pb.ts +6 -1
- package/src/invoker.ts +27 -2
- package/src/pluginruntime.ts +2 -27
- package/src/runtime-log-host.ts +28 -2
- package/src/runtime.ts +11 -9
- package/src/s3.ts +41 -6
- package/src/test-agent-contract.ts +43 -0
- package/src/workflow-manager.ts +42 -2
- package/src/workflow.ts +15 -1
- package/tsconfig.json +1 -1
- /package/{gen → src/internal/gen}/google/rpc/status_pb.ts +0 -0
- /package/{gen → src/internal/gen}/v1/authentication_pb.ts +0 -0
- /package/{gen → src/internal/gen}/v1/authorization_pb.ts +0 -0
- /package/{gen → src/internal/gen}/v1/cache_pb.ts +0 -0
- /package/{gen → src/internal/gen}/v1/datastore_pb.ts +0 -0
- /package/{gen → src/internal/gen}/v1/external_credential_pb.ts +0 -0
- /package/{gen → src/internal/gen}/v1/plugin_pb.ts +0 -0
- /package/{gen → src/internal/gen}/v1/runtime_pb.ts +0 -0
- /package/{gen → src/internal/gen}/v1/s3_pb.ts +0 -0
- /package/{gen → src/internal/gen}/v1/secrets_pb.ts +0 -0
package/src/runtime.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
1
3
|
import { rmSync, writeFileSync } from "node:fs";
|
|
2
4
|
import { createServer } from "node:http2";
|
|
3
5
|
import { dirname, resolve } from "node:path";
|
|
@@ -14,7 +16,7 @@ import { connectNodeAdapter } from "@connectrpc/connect-node";
|
|
|
14
16
|
|
|
15
17
|
import {
|
|
16
18
|
AgentProvider as AgentProviderService,
|
|
17
|
-
} from "
|
|
19
|
+
} from "./internal/gen/v1/agent_pb.ts";
|
|
18
20
|
import {
|
|
19
21
|
AuthenticationProvider as AuthenticationProviderService,
|
|
20
22
|
AuthSessionSettingsSchema,
|
|
@@ -22,7 +24,7 @@ import {
|
|
|
22
24
|
BeginLoginResponseSchema,
|
|
23
25
|
type CompleteLoginRequest as AuthCompleteLoginRequest,
|
|
24
26
|
type ValidateExternalTokenRequest,
|
|
25
|
-
} from "
|
|
27
|
+
} from "./internal/gen/v1/authentication_pb.ts";
|
|
26
28
|
import {
|
|
27
29
|
Cache as CacheService,
|
|
28
30
|
CacheDeleteManyResponseSchema,
|
|
@@ -31,12 +33,12 @@ import {
|
|
|
31
33
|
CacheGetResponseSchema,
|
|
32
34
|
CacheResultSchema,
|
|
33
35
|
CacheTouchResponseSchema,
|
|
34
|
-
} from "
|
|
36
|
+
} from "./internal/gen/v1/cache_pb.ts";
|
|
35
37
|
import {
|
|
36
38
|
SecretsProvider as SecretsProviderService,
|
|
37
39
|
GetSecretResponseSchema,
|
|
38
40
|
type GetSecretRequest,
|
|
39
|
-
} from "
|
|
41
|
+
} from "./internal/gen/v1/secrets_pb.ts";
|
|
40
42
|
import {
|
|
41
43
|
CatalogOperationSchema as ProtoCatalogOperationSchema,
|
|
42
44
|
CatalogParameterSchema as ProtoCatalogParameterSchema,
|
|
@@ -56,10 +58,10 @@ import {
|
|
|
56
58
|
type ExecuteRequest,
|
|
57
59
|
type GetSessionCatalogRequest,
|
|
58
60
|
type StartProviderRequest,
|
|
59
|
-
} from "
|
|
61
|
+
} from "./internal/gen/v1/plugin_pb.ts";
|
|
60
62
|
import {
|
|
61
63
|
PluginRuntimeProvider as PluginRuntimeProviderService,
|
|
62
|
-
} from "
|
|
64
|
+
} from "./internal/gen/v1/pluginruntime_pb.ts";
|
|
63
65
|
import {
|
|
64
66
|
ConfigureProviderResponseSchema,
|
|
65
67
|
HealthCheckResponseSchema,
|
|
@@ -68,9 +70,9 @@ import {
|
|
|
68
70
|
ProviderLifecycle,
|
|
69
71
|
StartRuntimeProviderResponseSchema,
|
|
70
72
|
type ConfigureProviderRequest,
|
|
71
|
-
} from "
|
|
72
|
-
import { S3 as S3Service } from "
|
|
73
|
-
import { WorkflowProvider as WorkflowProviderService } from "
|
|
73
|
+
} from "./internal/gen/v1/runtime_pb.ts";
|
|
74
|
+
import { S3 as S3Service } from "./internal/gen/v1/s3_pb.ts";
|
|
75
|
+
import { WorkflowProvider as WorkflowProviderService } from "./internal/gen/v1/workflow_pb.ts";
|
|
74
76
|
import { errorMessage, type Request } from "./api.ts";
|
|
75
77
|
import {
|
|
76
78
|
AgentProvider,
|
package/src/s3.ts
CHANGED
|
@@ -26,14 +26,17 @@ import {
|
|
|
26
26
|
type S3ObjectMeta as ProtoS3ObjectMeta,
|
|
27
27
|
type S3ObjectRef as ProtoS3ObjectRef,
|
|
28
28
|
WriteObjectResponseSchema,
|
|
29
|
-
} from "
|
|
29
|
+
} from "./internal/gen/v1/s3_pb.ts";
|
|
30
30
|
import { errorMessage, type MaybePromise } from "./api.ts";
|
|
31
31
|
import { RuntimeProvider, type RuntimeProviderOptions } from "./provider.ts";
|
|
32
32
|
|
|
33
|
+
/** Base environment variable for discovering S3 runtime sockets. */
|
|
33
34
|
export const ENV_S3_SOCKET = "GESTALT_S3_SOCKET";
|
|
34
35
|
const S3_SOCKET_TOKEN_SUFFIX = "_TOKEN";
|
|
35
36
|
const S3_RELAY_TOKEN_HEADER = "x-gestalt-host-service-relay-token";
|
|
36
|
-
|
|
37
|
+
/** Base environment variable for the default S3 relay token. */
|
|
38
|
+
export const ENV_S3_SOCKET_TOKEN =
|
|
39
|
+
`${ENV_S3_SOCKET}${S3_SOCKET_TOKEN_SUFFIX}`;
|
|
37
40
|
const WRITE_CHUNK_SIZE = 64 * 1024;
|
|
38
41
|
const textEncoder = new TextEncoder();
|
|
39
42
|
|
|
@@ -288,14 +291,20 @@ export class S3Provider extends RuntimeProvider {
|
|
|
288
291
|
this.presignObjectHandler = options.presignObject;
|
|
289
292
|
}
|
|
290
293
|
|
|
294
|
+
/** Fetches object metadata without reading the object body. */
|
|
291
295
|
async headObject(ref: ObjectRef): Promise<ObjectMeta> {
|
|
292
296
|
return await this.headObjectHandler(ref);
|
|
293
297
|
}
|
|
294
298
|
|
|
295
|
-
|
|
299
|
+
/** Reads an object body from the provider implementation. */
|
|
300
|
+
async readObject(
|
|
301
|
+
ref: ObjectRef,
|
|
302
|
+
options?: ReadOptions,
|
|
303
|
+
): Promise<ProviderReadResult> {
|
|
296
304
|
return await this.readObjectHandler(ref, options);
|
|
297
305
|
}
|
|
298
306
|
|
|
307
|
+
/** Writes an object body through the provider implementation. */
|
|
299
308
|
async writeObject(
|
|
300
309
|
ref: ObjectRef,
|
|
301
310
|
body: AsyncIterable<Uint8Array>,
|
|
@@ -304,14 +313,17 @@ export class S3Provider extends RuntimeProvider {
|
|
|
304
313
|
return await this.writeObjectHandler(ref, body, options);
|
|
305
314
|
}
|
|
306
315
|
|
|
316
|
+
/** Deletes an object from the provider implementation. */
|
|
307
317
|
async deleteObject(ref: ObjectRef): Promise<void> {
|
|
308
318
|
await this.deleteObjectHandler(ref);
|
|
309
319
|
}
|
|
310
320
|
|
|
321
|
+
/** Lists objects from the provider implementation. */
|
|
311
322
|
async listObjects(options: ListOptions): Promise<ListPage> {
|
|
312
323
|
return await this.listObjectsHandler(options);
|
|
313
324
|
}
|
|
314
325
|
|
|
326
|
+
/** Copies an object in the provider implementation. */
|
|
315
327
|
async copyObject(
|
|
316
328
|
source: ObjectRef,
|
|
317
329
|
destination: ObjectRef,
|
|
@@ -320,7 +332,11 @@ export class S3Provider extends RuntimeProvider {
|
|
|
320
332
|
return await this.copyObjectHandler(source, destination, options);
|
|
321
333
|
}
|
|
322
334
|
|
|
323
|
-
|
|
335
|
+
/** Generates a presigned URL from the provider implementation. */
|
|
336
|
+
async presignObject(
|
|
337
|
+
ref: ObjectRef,
|
|
338
|
+
options?: PresignOptions,
|
|
339
|
+
): Promise<PresignResult> {
|
|
324
340
|
return await this.presignObjectHandler(ref, options);
|
|
325
341
|
}
|
|
326
342
|
}
|
|
@@ -555,14 +571,17 @@ export class S3 {
|
|
|
555
571
|
this.client = createClient(S3Service, transport);
|
|
556
572
|
}
|
|
557
573
|
|
|
574
|
+
/** Returns a convenience helper for the latest version of an object. */
|
|
558
575
|
object(bucket: string, key: string): S3Object {
|
|
559
576
|
return new S3Object(this, { bucket, key });
|
|
560
577
|
}
|
|
561
578
|
|
|
579
|
+
/** Returns a convenience helper pinned to a specific object version. */
|
|
562
580
|
objectVersion(bucket: string, key: string, versionId: string): S3Object {
|
|
563
581
|
return new S3Object(this, { bucket, key, versionId });
|
|
564
582
|
}
|
|
565
583
|
|
|
584
|
+
/** Fetches object metadata without reading the object body. */
|
|
566
585
|
async headObject(ref: ObjectRef): Promise<ObjectMeta> {
|
|
567
586
|
const response = await s3Rpc(() =>
|
|
568
587
|
this.client.headObject({
|
|
@@ -572,6 +591,7 @@ export class S3 {
|
|
|
572
591
|
return fromProtoObjectMeta(response.meta);
|
|
573
592
|
}
|
|
574
593
|
|
|
594
|
+
/** Opens a streaming read for an object. */
|
|
575
595
|
async readObject(ref: ObjectRef, options?: ReadOptions): Promise<ReadResult> {
|
|
576
596
|
const response = this.client.readObject({
|
|
577
597
|
ref: toProtoObjectRef(ref),
|
|
@@ -588,6 +608,7 @@ export class S3 {
|
|
|
588
608
|
};
|
|
589
609
|
}
|
|
590
610
|
|
|
611
|
+
/** Writes an object body and returns the resulting metadata. */
|
|
591
612
|
async writeObject(
|
|
592
613
|
ref: ObjectRef,
|
|
593
614
|
body?: S3BodySource,
|
|
@@ -601,6 +622,7 @@ export class S3 {
|
|
|
601
622
|
return fromProtoObjectMeta(response.meta);
|
|
602
623
|
}
|
|
603
624
|
|
|
625
|
+
/** Deletes an object. */
|
|
604
626
|
async deleteObject(ref: ObjectRef): Promise<void> {
|
|
605
627
|
await s3Rpc(() =>
|
|
606
628
|
this.client.deleteObject({
|
|
@@ -609,6 +631,7 @@ export class S3 {
|
|
|
609
631
|
);
|
|
610
632
|
}
|
|
611
633
|
|
|
634
|
+
/** Lists objects within a bucket. */
|
|
612
635
|
async listObjects(options: ListOptions): Promise<ListPage> {
|
|
613
636
|
const response = await s3Rpc(() =>
|
|
614
637
|
this.client.listObjects({
|
|
@@ -628,6 +651,7 @@ export class S3 {
|
|
|
628
651
|
};
|
|
629
652
|
}
|
|
630
653
|
|
|
654
|
+
/** Copies an object and returns metadata for the destination. */
|
|
631
655
|
async copyObject(
|
|
632
656
|
source: ObjectRef,
|
|
633
657
|
destination: ObjectRef,
|
|
@@ -644,7 +668,11 @@ export class S3 {
|
|
|
644
668
|
return fromProtoObjectMeta(response.meta);
|
|
645
669
|
}
|
|
646
670
|
|
|
647
|
-
|
|
671
|
+
/** Generates a presigned URL for an object operation. */
|
|
672
|
+
async presignObject(
|
|
673
|
+
ref: ObjectRef,
|
|
674
|
+
options?: PresignOptions,
|
|
675
|
+
): Promise<PresignResult> {
|
|
648
676
|
const requestedMethod = options?.method ?? PresignMethod.Get;
|
|
649
677
|
const response = await s3Rpc(() =>
|
|
650
678
|
this.client.presignObject({
|
|
@@ -669,6 +697,7 @@ export class S3 {
|
|
|
669
697
|
return result;
|
|
670
698
|
}
|
|
671
699
|
|
|
700
|
+
/** Creates a host-mediated object access URL. */
|
|
672
701
|
async createObjectAccessURL(
|
|
673
702
|
ref: ObjectRef,
|
|
674
703
|
options?: ObjectAccessURLOptions,
|
|
@@ -704,6 +733,7 @@ export class S3 {
|
|
|
704
733
|
return this.objectAccessClient;
|
|
705
734
|
}
|
|
706
735
|
|
|
736
|
+
/** Alias for `createObjectAccessURL`. */
|
|
707
737
|
async createObjectAccessUrl(
|
|
708
738
|
ref: ObjectRef,
|
|
709
739
|
options?: ObjectAccessURLOptions,
|
|
@@ -711,6 +741,7 @@ export class S3 {
|
|
|
711
741
|
return await this.createObjectAccessURL(ref, options);
|
|
712
742
|
}
|
|
713
743
|
|
|
744
|
+
/** Alias for `createObjectAccessURL`. */
|
|
714
745
|
async createAccessURL(
|
|
715
746
|
ref: ObjectRef,
|
|
716
747
|
options?: ObjectAccessURLOptions,
|
|
@@ -718,6 +749,7 @@ export class S3 {
|
|
|
718
749
|
return await this.createObjectAccessURL(ref, options);
|
|
719
750
|
}
|
|
720
751
|
|
|
752
|
+
/** Alias for `createObjectAccessURL`. */
|
|
721
753
|
async createAccessUrl(
|
|
722
754
|
ref: ObjectRef,
|
|
723
755
|
options?: ObjectAccessURLOptions,
|
|
@@ -846,7 +878,10 @@ export class S3Object {
|
|
|
846
878
|
return await this.client.createObjectAccessURL(this.ref, options);
|
|
847
879
|
}
|
|
848
880
|
|
|
849
|
-
|
|
881
|
+
/** Alias for `createAccessURL`. */
|
|
882
|
+
async createAccessUrl(
|
|
883
|
+
options?: ObjectAccessURLOptions,
|
|
884
|
+
): Promise<ObjectAccessURL> {
|
|
850
885
|
return await this.createAccessURL(options);
|
|
851
886
|
}
|
|
852
887
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { create } from "@bufbuild/protobuf";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AgentHost as AgentHostService,
|
|
5
|
+
AgentProvider as AgentProviderService,
|
|
6
|
+
CancelAgentProviderTurnRequestSchema,
|
|
7
|
+
CreateAgentProviderSessionRequestSchema,
|
|
8
|
+
CreateAgentProviderTurnRequestSchema,
|
|
9
|
+
ExecuteAgentToolResponseSchema,
|
|
10
|
+
GetAgentProviderCapabilitiesRequestSchema,
|
|
11
|
+
GetAgentProviderSessionRequestSchema,
|
|
12
|
+
GetAgentProviderTurnRequestSchema,
|
|
13
|
+
ListAgentProviderTurnEventsRequestSchema,
|
|
14
|
+
ListAgentToolsResponseSchema,
|
|
15
|
+
ListedAgentToolSchema,
|
|
16
|
+
} from "./internal/gen/v1/agent_pb.ts";
|
|
17
|
+
|
|
18
|
+
export const agentContractServices: Record<string, unknown> = {
|
|
19
|
+
AgentHost: AgentHostService,
|
|
20
|
+
AgentHostService,
|
|
21
|
+
AgentProvider: AgentProviderService,
|
|
22
|
+
AgentProviderService,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const agentContractSchemas: Record<string, unknown> = {
|
|
26
|
+
CancelAgentProviderTurnRequestSchema,
|
|
27
|
+
CreateAgentProviderSessionRequestSchema,
|
|
28
|
+
CreateAgentProviderTurnRequestSchema,
|
|
29
|
+
ExecuteAgentToolResponseSchema,
|
|
30
|
+
GetAgentProviderCapabilitiesRequestSchema,
|
|
31
|
+
GetAgentProviderSessionRequestSchema,
|
|
32
|
+
GetAgentProviderTurnRequestSchema,
|
|
33
|
+
ListAgentProviderTurnEventsRequestSchema,
|
|
34
|
+
ListAgentToolsResponseSchema,
|
|
35
|
+
ListedAgentToolSchema,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export function createAgentContractMessage<T = unknown>(
|
|
39
|
+
schema: unknown,
|
|
40
|
+
input: Record<string, unknown>,
|
|
41
|
+
): T {
|
|
42
|
+
return create(schema as never, input as never) as T;
|
|
43
|
+
}
|
package/src/workflow-manager.ts
CHANGED
|
@@ -24,57 +24,84 @@ import {
|
|
|
24
24
|
type ManagedWorkflowSchedule,
|
|
25
25
|
type ManagedWorkflowEventTrigger,
|
|
26
26
|
type WorkflowEvent,
|
|
27
|
-
} from "
|
|
27
|
+
} from "./internal/gen/v1/workflow_pb.ts";
|
|
28
28
|
import type { Request } from "./api.ts";
|
|
29
29
|
|
|
30
|
+
/** Environment variable containing the workflow-manager host-service target. */
|
|
30
31
|
export const ENV_WORKFLOW_MANAGER_SOCKET = "GESTALT_WORKFLOW_MANAGER_SOCKET";
|
|
31
|
-
|
|
32
|
+
/** Environment variable containing the optional workflow-manager relay token. */
|
|
33
|
+
export const ENV_WORKFLOW_MANAGER_SOCKET_TOKEN =
|
|
34
|
+
`${ENV_WORKFLOW_MANAGER_SOCKET}_TOKEN`;
|
|
32
35
|
const WORKFLOW_MANAGER_RELAY_TOKEN_HEADER =
|
|
33
36
|
"x-gestalt-host-service-relay-token";
|
|
34
37
|
|
|
38
|
+
/** Managed workflow schedule message returned by the host manager. */
|
|
35
39
|
export type ManagedWorkflowScheduleMessage = ManagedWorkflowSchedule;
|
|
40
|
+
/** Managed workflow event-trigger message returned by the host manager. */
|
|
36
41
|
export type ManagedWorkflowEventTriggerMessage = ManagedWorkflowEventTrigger;
|
|
42
|
+
/** Workflow event message returned after publishing an event. */
|
|
37
43
|
export type WorkflowEventMessage = WorkflowEvent;
|
|
44
|
+
/** Shape accepted when creating a workflow schedule. */
|
|
38
45
|
export type WorkflowManagerCreateScheduleInput = MessageInitShape<
|
|
39
46
|
typeof WorkflowManagerCreateScheduleRequestSchema
|
|
40
47
|
>;
|
|
48
|
+
/** Shape accepted when creating an event trigger. */
|
|
41
49
|
export type WorkflowManagerCreateTriggerInput = MessageInitShape<
|
|
42
50
|
typeof WorkflowManagerCreateEventTriggerRequestSchema
|
|
43
51
|
>;
|
|
52
|
+
/** Shape accepted when fetching a workflow schedule. */
|
|
44
53
|
export type WorkflowManagerGetScheduleInput = MessageInitShape<
|
|
45
54
|
typeof WorkflowManagerGetScheduleRequestSchema
|
|
46
55
|
>;
|
|
56
|
+
/** Shape accepted when fetching an event trigger. */
|
|
47
57
|
export type WorkflowManagerGetTriggerInput = MessageInitShape<
|
|
48
58
|
typeof WorkflowManagerGetEventTriggerRequestSchema
|
|
49
59
|
>;
|
|
60
|
+
/** Shape accepted when updating a workflow schedule. */
|
|
50
61
|
export type WorkflowManagerUpdateScheduleInput = MessageInitShape<
|
|
51
62
|
typeof WorkflowManagerUpdateScheduleRequestSchema
|
|
52
63
|
>;
|
|
64
|
+
/** Shape accepted when updating an event trigger. */
|
|
53
65
|
export type WorkflowManagerUpdateTriggerInput = MessageInitShape<
|
|
54
66
|
typeof WorkflowManagerUpdateEventTriggerRequestSchema
|
|
55
67
|
>;
|
|
68
|
+
/** Shape accepted when deleting a workflow schedule. */
|
|
56
69
|
export type WorkflowManagerDeleteScheduleInput = MessageInitShape<
|
|
57
70
|
typeof WorkflowManagerDeleteScheduleRequestSchema
|
|
58
71
|
>;
|
|
72
|
+
/** Shape accepted when deleting an event trigger. */
|
|
59
73
|
export type WorkflowManagerDeleteTriggerInput = MessageInitShape<
|
|
60
74
|
typeof WorkflowManagerDeleteEventTriggerRequestSchema
|
|
61
75
|
>;
|
|
76
|
+
/** Shape accepted when pausing a workflow schedule. */
|
|
62
77
|
export type WorkflowManagerPauseScheduleInput = MessageInitShape<
|
|
63
78
|
typeof WorkflowManagerPauseScheduleRequestSchema
|
|
64
79
|
>;
|
|
80
|
+
/** Shape accepted when pausing an event trigger. */
|
|
65
81
|
export type WorkflowManagerPauseTriggerInput = MessageInitShape<
|
|
66
82
|
typeof WorkflowManagerPauseEventTriggerRequestSchema
|
|
67
83
|
>;
|
|
84
|
+
/** Shape accepted when resuming a workflow schedule. */
|
|
68
85
|
export type WorkflowManagerResumeScheduleInput = MessageInitShape<
|
|
69
86
|
typeof WorkflowManagerResumeScheduleRequestSchema
|
|
70
87
|
>;
|
|
88
|
+
/** Shape accepted when resuming an event trigger. */
|
|
71
89
|
export type WorkflowManagerResumeTriggerInput = MessageInitShape<
|
|
72
90
|
typeof WorkflowManagerResumeEventTriggerRequestSchema
|
|
73
91
|
>;
|
|
92
|
+
/** Shape accepted when publishing a workflow event. */
|
|
74
93
|
export type WorkflowManagerPublishEventInput = MessageInitShape<
|
|
75
94
|
typeof WorkflowManagerPublishEventRequestSchema
|
|
76
95
|
>;
|
|
77
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Client for creating and controlling workflow schedules and event triggers.
|
|
99
|
+
*
|
|
100
|
+
* The constructor accepts either a Gestalt request or an invocation token. Each
|
|
101
|
+
* manager call forwards that token to the host service. When constructed from a
|
|
102
|
+
* request, create operations reuse the request idempotency key unless the call
|
|
103
|
+
* provides one explicitly.
|
|
104
|
+
*/
|
|
78
105
|
export class WorkflowManager {
|
|
79
106
|
private readonly client: Client<typeof WorkflowManagerHostService>;
|
|
80
107
|
private readonly invocationToken: string;
|
|
@@ -104,6 +131,7 @@ export class WorkflowManager {
|
|
|
104
131
|
this.client = createClient(WorkflowManagerHostService, transport);
|
|
105
132
|
}
|
|
106
133
|
|
|
134
|
+
/** Creates a workflow schedule. */
|
|
107
135
|
async createSchedule(
|
|
108
136
|
request: WorkflowManagerCreateScheduleInput,
|
|
109
137
|
): Promise<ManagedWorkflowScheduleMessage> {
|
|
@@ -114,6 +142,7 @@ export class WorkflowManager {
|
|
|
114
142
|
});
|
|
115
143
|
}
|
|
116
144
|
|
|
145
|
+
/** Fetches one workflow schedule. */
|
|
117
146
|
async getSchedule(
|
|
118
147
|
request: WorkflowManagerGetScheduleInput,
|
|
119
148
|
): Promise<ManagedWorkflowScheduleMessage> {
|
|
@@ -123,6 +152,7 @@ export class WorkflowManager {
|
|
|
123
152
|
});
|
|
124
153
|
}
|
|
125
154
|
|
|
155
|
+
/** Updates a workflow schedule. */
|
|
126
156
|
async updateSchedule(
|
|
127
157
|
request: WorkflowManagerUpdateScheduleInput,
|
|
128
158
|
): Promise<ManagedWorkflowScheduleMessage> {
|
|
@@ -132,6 +162,7 @@ export class WorkflowManager {
|
|
|
132
162
|
});
|
|
133
163
|
}
|
|
134
164
|
|
|
165
|
+
/** Deletes a workflow schedule. */
|
|
135
166
|
async deleteSchedule(
|
|
136
167
|
request: WorkflowManagerDeleteScheduleInput,
|
|
137
168
|
): Promise<void> {
|
|
@@ -141,6 +172,7 @@ export class WorkflowManager {
|
|
|
141
172
|
});
|
|
142
173
|
}
|
|
143
174
|
|
|
175
|
+
/** Pauses a workflow schedule. */
|
|
144
176
|
async pauseSchedule(
|
|
145
177
|
request: WorkflowManagerPauseScheduleInput,
|
|
146
178
|
): Promise<ManagedWorkflowScheduleMessage> {
|
|
@@ -150,6 +182,7 @@ export class WorkflowManager {
|
|
|
150
182
|
});
|
|
151
183
|
}
|
|
152
184
|
|
|
185
|
+
/** Resumes a workflow schedule. */
|
|
153
186
|
async resumeSchedule(
|
|
154
187
|
request: WorkflowManagerResumeScheduleInput,
|
|
155
188
|
): Promise<ManagedWorkflowScheduleMessage> {
|
|
@@ -159,6 +192,7 @@ export class WorkflowManager {
|
|
|
159
192
|
});
|
|
160
193
|
}
|
|
161
194
|
|
|
195
|
+
/** Creates an event trigger. */
|
|
162
196
|
async createTrigger(
|
|
163
197
|
request: WorkflowManagerCreateTriggerInput,
|
|
164
198
|
): Promise<ManagedWorkflowEventTriggerMessage> {
|
|
@@ -169,6 +203,7 @@ export class WorkflowManager {
|
|
|
169
203
|
});
|
|
170
204
|
}
|
|
171
205
|
|
|
206
|
+
/** Fetches one event trigger. */
|
|
172
207
|
async getTrigger(
|
|
173
208
|
request: WorkflowManagerGetTriggerInput,
|
|
174
209
|
): Promise<ManagedWorkflowEventTriggerMessage> {
|
|
@@ -178,6 +213,7 @@ export class WorkflowManager {
|
|
|
178
213
|
});
|
|
179
214
|
}
|
|
180
215
|
|
|
216
|
+
/** Updates an event trigger. */
|
|
181
217
|
async updateTrigger(
|
|
182
218
|
request: WorkflowManagerUpdateTriggerInput,
|
|
183
219
|
): Promise<ManagedWorkflowEventTriggerMessage> {
|
|
@@ -187,6 +223,7 @@ export class WorkflowManager {
|
|
|
187
223
|
});
|
|
188
224
|
}
|
|
189
225
|
|
|
226
|
+
/** Deletes an event trigger. */
|
|
190
227
|
async deleteTrigger(
|
|
191
228
|
request: WorkflowManagerDeleteTriggerInput,
|
|
192
229
|
): Promise<void> {
|
|
@@ -196,6 +233,7 @@ export class WorkflowManager {
|
|
|
196
233
|
});
|
|
197
234
|
}
|
|
198
235
|
|
|
236
|
+
/** Pauses an event trigger. */
|
|
199
237
|
async pauseTrigger(
|
|
200
238
|
request: WorkflowManagerPauseTriggerInput,
|
|
201
239
|
): Promise<ManagedWorkflowEventTriggerMessage> {
|
|
@@ -205,6 +243,7 @@ export class WorkflowManager {
|
|
|
205
243
|
});
|
|
206
244
|
}
|
|
207
245
|
|
|
246
|
+
/** Resumes an event trigger. */
|
|
208
247
|
async resumeTrigger(
|
|
209
248
|
request: WorkflowManagerResumeTriggerInput,
|
|
210
249
|
): Promise<ManagedWorkflowEventTriggerMessage> {
|
|
@@ -214,6 +253,7 @@ export class WorkflowManager {
|
|
|
214
253
|
});
|
|
215
254
|
}
|
|
216
255
|
|
|
256
|
+
/** Publishes an event into the workflow manager. */
|
|
217
257
|
async publishEvent(
|
|
218
258
|
request: WorkflowManagerPublishEventInput,
|
|
219
259
|
): Promise<WorkflowEventMessage> {
|
package/src/workflow.ts
CHANGED
|
@@ -44,12 +44,19 @@ import {
|
|
|
44
44
|
type UpsertWorkflowProviderScheduleRequest,
|
|
45
45
|
type WorkflowEvent,
|
|
46
46
|
WorkflowRunStatus,
|
|
47
|
-
} from "
|
|
47
|
+
} from "./internal/gen/v1/workflow_pb.ts";
|
|
48
48
|
import { errorMessage, type MaybePromise } from "./api.ts";
|
|
49
49
|
import { RuntimeProvider, type RuntimeProviderOptions } from "./provider.ts";
|
|
50
50
|
|
|
51
|
+
/** Environment variable containing the workflow-host service socket path. */
|
|
51
52
|
export const ENV_WORKFLOW_HOST_SOCKET = "GESTALT_WORKFLOW_HOST_SOCKET";
|
|
52
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Generated workflow protocol message types commonly used by providers.
|
|
56
|
+
*
|
|
57
|
+
* These are re-exported so workflow provider code can type runs, schedules,
|
|
58
|
+
* triggers, and operation-invocation requests without importing from `gen`.
|
|
59
|
+
*/
|
|
53
60
|
export type {
|
|
54
61
|
BoundWorkflowEventTrigger,
|
|
55
62
|
BoundWorkflowRun,
|
|
@@ -77,6 +84,7 @@ export type {
|
|
|
77
84
|
};
|
|
78
85
|
export { WorkflowRunStatus };
|
|
79
86
|
|
|
87
|
+
/** Handlers and runtime metadata for a workflow provider. */
|
|
80
88
|
export interface WorkflowProviderOptions extends RuntimeProviderOptions {
|
|
81
89
|
startRun: (
|
|
82
90
|
request: StartWorkflowProviderRunRequest,
|
|
@@ -131,6 +139,7 @@ export interface WorkflowProviderOptions extends RuntimeProviderOptions {
|
|
|
131
139
|
) => MaybePromise<void>;
|
|
132
140
|
}
|
|
133
141
|
|
|
142
|
+
/** Runtime provider implementation for the Gestalt workflow host contract. */
|
|
134
143
|
export class WorkflowProvider extends RuntimeProvider {
|
|
135
144
|
readonly kind = "workflow" as const;
|
|
136
145
|
|
|
@@ -276,12 +285,14 @@ export class WorkflowProvider extends RuntimeProvider {
|
|
|
276
285
|
}
|
|
277
286
|
}
|
|
278
287
|
|
|
288
|
+
/** Creates a workflow provider for export from a provider module. */
|
|
279
289
|
export function defineWorkflowProvider(
|
|
280
290
|
options: WorkflowProviderOptions,
|
|
281
291
|
): WorkflowProvider {
|
|
282
292
|
return new WorkflowProvider(options);
|
|
283
293
|
}
|
|
284
294
|
|
|
295
|
+
/** Runtime type guard for workflow providers loaded from user modules. */
|
|
285
296
|
export function isWorkflowProvider(value: unknown): value is WorkflowProvider {
|
|
286
297
|
return (
|
|
287
298
|
value instanceof WorkflowProvider ||
|
|
@@ -309,6 +320,7 @@ export function isWorkflowProvider(value: unknown): value is WorkflowProvider {
|
|
|
309
320
|
);
|
|
310
321
|
}
|
|
311
322
|
|
|
323
|
+
/** Client for invoking operations from workflow provider code. */
|
|
312
324
|
export class WorkflowHost {
|
|
313
325
|
private readonly client: Client<typeof WorkflowHostService>;
|
|
314
326
|
|
|
@@ -326,6 +338,7 @@ export class WorkflowHost {
|
|
|
326
338
|
this.client = createClient(WorkflowHostService, transport);
|
|
327
339
|
}
|
|
328
340
|
|
|
341
|
+
/** Invokes an operation through the workflow host service. */
|
|
329
342
|
async invokeOperation(
|
|
330
343
|
request: InvokeWorkflowOperationRequest,
|
|
331
344
|
): Promise<InvokeWorkflowOperationResponse> {
|
|
@@ -333,6 +346,7 @@ export class WorkflowHost {
|
|
|
333
346
|
}
|
|
334
347
|
}
|
|
335
348
|
|
|
349
|
+
/** Builds the Connect service implementation used by the TypeScript runtime. */
|
|
336
350
|
export function createWorkflowProviderService(
|
|
337
351
|
provider: WorkflowProvider,
|
|
338
352
|
): Partial<ServiceImpl<typeof WorkflowProviderService>> {
|
package/tsconfig.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|