@valon-technologies/gestalt 0.0.1-alpha.17 → 0.0.1-alpha.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -12
- package/package.json +5 -3
- package/src/agent-conversions.ts +201 -0
- package/src/agent-manager.ts +272 -83
- package/src/agent.ts +1029 -219
- package/src/api.ts +54 -0
- package/src/auth.ts +3 -3
- package/src/authorization.ts +1702 -52
- package/src/cache.ts +5 -4
- package/src/catalog.ts +22 -0
- package/src/http-subject.ts +13 -2
- package/src/index.ts +194 -17
- package/src/indexeddb.ts +5 -16
- package/src/internal/gen/v1/agent_pb.ts +353 -74
- package/src/internal/gen/v1/authentication_pb.ts +1 -1
- package/src/internal/gen/v1/authorization_pb.ts +505 -27
- 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 +434 -29
- package/src/internal/gen/v1/plugin_pb.ts +92 -22
- package/src/internal/gen/v1/pluginruntime_pb.ts +95 -6
- 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 +349 -67
- package/src/invoker.ts +6 -35
- package/src/plugin.ts +12 -12
- package/src/pluginruntime.ts +337 -49
- package/src/protocol/v1.ts +19 -0
- package/src/protocol-internal.ts +19 -0
- package/src/protocol.ts +183 -0
- package/src/provider-kind.ts +7 -3
- package/src/provider.ts +21 -13
- package/src/runtime-log-host.ts +81 -53
- package/src/runtime.ts +72 -0
- package/src/s3.ts +15 -29
- package/src/secrets.ts +3 -3
- package/src/workflow-manager.ts +350 -121
- package/src/workflow.ts +2598 -389
package/src/workflow.ts
CHANGED
|
@@ -1,477 +1,2672 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { create, type MessageInitShape } from "@bufbuild/protobuf";
|
|
1
|
+
import { create, type JsonObject } from "@bufbuild/protobuf";
|
|
4
2
|
import { EmptySchema } from "@bufbuild/protobuf/wkt";
|
|
5
3
|
import {
|
|
6
4
|
Code,
|
|
7
5
|
ConnectError,
|
|
8
6
|
createClient,
|
|
9
7
|
type Client,
|
|
8
|
+
type Interceptor,
|
|
10
9
|
type ServiceImpl,
|
|
11
10
|
} from "@connectrpc/connect";
|
|
12
11
|
import { createGrpcTransport } from "@connectrpc/connect-node";
|
|
13
12
|
|
|
14
13
|
import {
|
|
14
|
+
BoundWorkflowAgentTargetSchema,
|
|
15
|
+
BoundWorkflowDefinitionSchema,
|
|
15
16
|
BoundWorkflowEventTriggerSchema,
|
|
17
|
+
BoundWorkflowPluginTargetSchema,
|
|
16
18
|
BoundWorkflowRunSchema,
|
|
17
19
|
BoundWorkflowScheduleSchema,
|
|
20
|
+
BoundWorkflowTargetSchema,
|
|
21
|
+
InvokeWorkflowOperationRequestSchema,
|
|
22
|
+
ListWorkflowExecutionReferencesResponseSchema,
|
|
18
23
|
ListWorkflowProviderEventTriggersResponseSchema,
|
|
19
24
|
ListWorkflowProviderRunsResponseSchema,
|
|
20
25
|
ListWorkflowProviderSchedulesResponseSchema,
|
|
26
|
+
SignalWorkflowRunResponseSchema,
|
|
27
|
+
WorkflowAccessPermissionSchema,
|
|
28
|
+
WorkflowActorSchema,
|
|
29
|
+
WorkflowEventMatchSchema,
|
|
30
|
+
WorkflowEventSchema,
|
|
31
|
+
WorkflowEventTriggerInvocationSchema,
|
|
32
|
+
WorkflowExecutionReferenceSchema,
|
|
21
33
|
WorkflowHost as WorkflowHostService,
|
|
34
|
+
WorkflowManualTriggerSchema,
|
|
35
|
+
WorkflowOutputBindingSchema,
|
|
36
|
+
WorkflowOutputDeliverySchema,
|
|
37
|
+
WorkflowOutputValueSourceSchema,
|
|
22
38
|
WorkflowProvider as WorkflowProviderService,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
type
|
|
29
|
-
type
|
|
30
|
-
type
|
|
31
|
-
type
|
|
32
|
-
type
|
|
33
|
-
type
|
|
34
|
-
type
|
|
35
|
-
type
|
|
36
|
-
type
|
|
37
|
-
type
|
|
38
|
-
type
|
|
39
|
-
type
|
|
40
|
-
type
|
|
41
|
-
type
|
|
42
|
-
type
|
|
43
|
-
type
|
|
44
|
-
type
|
|
45
|
-
type
|
|
46
|
-
|
|
39
|
+
WorkflowRunAsSubjectSchema,
|
|
40
|
+
WorkflowRunStatus as ProtoWorkflowRunStatus,
|
|
41
|
+
WorkflowRunTriggerSchema,
|
|
42
|
+
WorkflowScheduleTriggerSchema,
|
|
43
|
+
WorkflowSignalSchema,
|
|
44
|
+
type BoundWorkflowAgentTarget as ProtoBoundWorkflowAgentTarget,
|
|
45
|
+
type BoundWorkflowDefinition as ProtoBoundWorkflowDefinition,
|
|
46
|
+
type BoundWorkflowEventTrigger as ProtoBoundWorkflowEventTrigger,
|
|
47
|
+
type BoundWorkflowPluginTarget as ProtoBoundWorkflowPluginTarget,
|
|
48
|
+
type BoundWorkflowRun as ProtoBoundWorkflowRun,
|
|
49
|
+
type BoundWorkflowSchedule as ProtoBoundWorkflowSchedule,
|
|
50
|
+
type BoundWorkflowTarget as ProtoBoundWorkflowTarget,
|
|
51
|
+
type CancelWorkflowProviderRunRequest as ProtoCancelWorkflowProviderRunRequest,
|
|
52
|
+
type DeleteWorkflowProviderEventTriggerRequest as ProtoDeleteWorkflowProviderEventTriggerRequest,
|
|
53
|
+
type DeleteWorkflowProviderScheduleRequest as ProtoDeleteWorkflowProviderScheduleRequest,
|
|
54
|
+
type GetWorkflowExecutionReferenceRequest as ProtoGetWorkflowExecutionReferenceRequest,
|
|
55
|
+
type GetWorkflowProviderEventTriggerRequest as ProtoGetWorkflowProviderEventTriggerRequest,
|
|
56
|
+
type GetWorkflowProviderRunRequest as ProtoGetWorkflowProviderRunRequest,
|
|
57
|
+
type GetWorkflowProviderScheduleRequest as ProtoGetWorkflowProviderScheduleRequest,
|
|
58
|
+
type ListWorkflowExecutionReferencesRequest as ProtoListWorkflowExecutionReferencesRequest,
|
|
59
|
+
type ListWorkflowProviderEventTriggersRequest as ProtoListWorkflowProviderEventTriggersRequest,
|
|
60
|
+
type ListWorkflowProviderRunsRequest as ProtoListWorkflowProviderRunsRequest,
|
|
61
|
+
type ListWorkflowProviderSchedulesRequest as ProtoListWorkflowProviderSchedulesRequest,
|
|
62
|
+
type PauseWorkflowProviderEventTriggerRequest as ProtoPauseWorkflowProviderEventTriggerRequest,
|
|
63
|
+
type PauseWorkflowProviderScheduleRequest as ProtoPauseWorkflowProviderScheduleRequest,
|
|
64
|
+
type PublishWorkflowProviderEventRequest as ProtoPublishWorkflowProviderEventRequest,
|
|
65
|
+
type PutWorkflowExecutionReferenceRequest as ProtoPutWorkflowExecutionReferenceRequest,
|
|
66
|
+
type ResumeWorkflowProviderEventTriggerRequest as ProtoResumeWorkflowProviderEventTriggerRequest,
|
|
67
|
+
type ResumeWorkflowProviderScheduleRequest as ProtoResumeWorkflowProviderScheduleRequest,
|
|
68
|
+
type SignalOrStartWorkflowProviderRunRequest as ProtoSignalOrStartWorkflowProviderRunRequest,
|
|
69
|
+
type SignalWorkflowProviderRunRequest as ProtoSignalWorkflowProviderRunRequest,
|
|
70
|
+
type SignalWorkflowRunResponse as ProtoSignalWorkflowRunResponse,
|
|
71
|
+
type StartWorkflowProviderRunRequest as ProtoStartWorkflowProviderRunRequest,
|
|
72
|
+
type UpsertWorkflowProviderEventTriggerRequest as ProtoUpsertWorkflowProviderEventTriggerRequest,
|
|
73
|
+
type UpsertWorkflowProviderScheduleRequest as ProtoUpsertWorkflowProviderScheduleRequest,
|
|
74
|
+
type WorkflowAccessPermission as ProtoWorkflowAccessPermission,
|
|
75
|
+
type WorkflowActor as ProtoWorkflowActor,
|
|
76
|
+
type WorkflowEvent as ProtoWorkflowEvent,
|
|
77
|
+
type WorkflowEventMatch as ProtoWorkflowEventMatch,
|
|
78
|
+
type WorkflowEventTriggerInvocation as ProtoWorkflowEventTriggerInvocation,
|
|
79
|
+
type WorkflowExecutionReference as ProtoWorkflowExecutionReference,
|
|
80
|
+
type WorkflowOutputBinding as ProtoWorkflowOutputBinding,
|
|
81
|
+
type WorkflowOutputDelivery as ProtoWorkflowOutputDelivery,
|
|
82
|
+
type WorkflowOutputValueSource as ProtoWorkflowOutputValueSource,
|
|
83
|
+
type WorkflowRunAsSubject as ProtoWorkflowRunAsSubject,
|
|
84
|
+
type WorkflowRunTrigger as ProtoWorkflowRunTrigger,
|
|
85
|
+
type WorkflowScheduleTrigger as ProtoWorkflowScheduleTrigger,
|
|
86
|
+
type WorkflowSignal as ProtoWorkflowSignal,
|
|
47
87
|
} from "./internal/gen/v1/workflow_pb.ts";
|
|
88
|
+
import type {
|
|
89
|
+
AgentMessage,
|
|
90
|
+
AgentToolRef,
|
|
91
|
+
} from "./agent.ts";
|
|
92
|
+
import {
|
|
93
|
+
agentMessageFromProto,
|
|
94
|
+
agentMessageToProto,
|
|
95
|
+
agentToolRefFromProto,
|
|
96
|
+
agentToolRefToProto,
|
|
97
|
+
} from "./agent-conversions.ts";
|
|
48
98
|
import { errorMessage, type MaybePromise } from "./api.ts";
|
|
49
|
-
import {
|
|
99
|
+
import { ProviderBase, type ProviderBaseOptions } from "./provider.ts";
|
|
100
|
+
import {
|
|
101
|
+
dateFromTimestamp,
|
|
102
|
+
jsonFromValue,
|
|
103
|
+
jsonObjectFromStruct,
|
|
104
|
+
structFromObject,
|
|
105
|
+
timestampFromDate,
|
|
106
|
+
valueFromJson,
|
|
107
|
+
type JsonInput,
|
|
108
|
+
type JsonObjectInput,
|
|
109
|
+
} from "./protocol.ts";
|
|
110
|
+
import {
|
|
111
|
+
optionalObjectFromStruct,
|
|
112
|
+
optionalStruct,
|
|
113
|
+
} from "./protocol-internal.ts";
|
|
50
114
|
|
|
51
|
-
|
|
115
|
+
type WorkflowProviderServiceImpl = Partial<
|
|
116
|
+
ServiceImpl<typeof WorkflowProviderService>
|
|
117
|
+
>;
|
|
118
|
+
|
|
119
|
+
/** Environment variable containing the workflow-host service target. */
|
|
52
120
|
export const ENV_WORKFLOW_HOST_SOCKET = "GESTALT_WORKFLOW_HOST_SOCKET";
|
|
121
|
+
/** Environment variable containing the optional workflow-host relay token. */
|
|
122
|
+
export const ENV_WORKFLOW_HOST_SOCKET_TOKEN = `${ENV_WORKFLOW_HOST_SOCKET}_TOKEN`;
|
|
123
|
+
const WORKFLOW_HOST_RELAY_TOKEN_HEADER = "x-gestalt-host-service-relay-token";
|
|
53
124
|
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
DeleteWorkflowProviderEventTriggerRequest,
|
|
66
|
-
DeleteWorkflowProviderScheduleRequest,
|
|
67
|
-
GetWorkflowProviderEventTriggerRequest,
|
|
68
|
-
GetWorkflowProviderRunRequest,
|
|
69
|
-
GetWorkflowProviderScheduleRequest,
|
|
70
|
-
InvokeWorkflowOperationRequest,
|
|
71
|
-
InvokeWorkflowOperationResponse,
|
|
72
|
-
ListWorkflowProviderEventTriggersRequest,
|
|
73
|
-
ListWorkflowProviderRunsRequest,
|
|
74
|
-
ListWorkflowProviderSchedulesRequest,
|
|
75
|
-
PauseWorkflowProviderEventTriggerRequest,
|
|
76
|
-
PauseWorkflowProviderScheduleRequest,
|
|
77
|
-
PublishWorkflowProviderEventRequest,
|
|
78
|
-
ResumeWorkflowProviderEventTriggerRequest,
|
|
79
|
-
ResumeWorkflowProviderScheduleRequest,
|
|
80
|
-
StartWorkflowProviderRunRequest,
|
|
81
|
-
UpsertWorkflowProviderEventTriggerRequest,
|
|
82
|
-
UpsertWorkflowProviderScheduleRequest,
|
|
83
|
-
WorkflowEvent,
|
|
84
|
-
};
|
|
85
|
-
export { WorkflowRunStatus };
|
|
125
|
+
/** Native workflow-run status constants for authored workflow providers. */
|
|
126
|
+
export const WorkflowRunStatus = {
|
|
127
|
+
UNSPECIFIED: ProtoWorkflowRunStatus.UNSPECIFIED,
|
|
128
|
+
PENDING: ProtoWorkflowRunStatus.PENDING,
|
|
129
|
+
RUNNING: ProtoWorkflowRunStatus.RUNNING,
|
|
130
|
+
SUCCEEDED: ProtoWorkflowRunStatus.SUCCEEDED,
|
|
131
|
+
FAILED: ProtoWorkflowRunStatus.FAILED,
|
|
132
|
+
CANCELED: ProtoWorkflowRunStatus.CANCELED,
|
|
133
|
+
} as const;
|
|
134
|
+
export type WorkflowRunStatus =
|
|
135
|
+
(typeof WorkflowRunStatus)[keyof typeof WorkflowRunStatus];
|
|
86
136
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
) => MaybePromise<MessageInitShape<typeof BoundWorkflowRunSchema>>;
|
|
95
|
-
listRuns: (
|
|
96
|
-
request: ListWorkflowProviderRunsRequest,
|
|
97
|
-
) => MaybePromise<MessageInitShape<typeof BoundWorkflowRunSchema>[]>;
|
|
98
|
-
cancelRun: (
|
|
99
|
-
request: CancelWorkflowProviderRunRequest,
|
|
100
|
-
) => MaybePromise<MessageInitShape<typeof BoundWorkflowRunSchema>>;
|
|
101
|
-
upsertSchedule: (
|
|
102
|
-
request: UpsertWorkflowProviderScheduleRequest,
|
|
103
|
-
) => MaybePromise<MessageInitShape<typeof BoundWorkflowScheduleSchema>>;
|
|
104
|
-
getSchedule: (
|
|
105
|
-
request: GetWorkflowProviderScheduleRequest,
|
|
106
|
-
) => MaybePromise<MessageInitShape<typeof BoundWorkflowScheduleSchema>>;
|
|
107
|
-
listSchedules: (
|
|
108
|
-
request: ListWorkflowProviderSchedulesRequest,
|
|
109
|
-
) => MaybePromise<MessageInitShape<typeof BoundWorkflowScheduleSchema>[]>;
|
|
110
|
-
deleteSchedule: (
|
|
111
|
-
request: DeleteWorkflowProviderScheduleRequest,
|
|
112
|
-
) => MaybePromise<void>;
|
|
113
|
-
pauseSchedule: (
|
|
114
|
-
request: PauseWorkflowProviderScheduleRequest,
|
|
115
|
-
) => MaybePromise<MessageInitShape<typeof BoundWorkflowScheduleSchema>>;
|
|
116
|
-
resumeSchedule: (
|
|
117
|
-
request: ResumeWorkflowProviderScheduleRequest,
|
|
118
|
-
) => MaybePromise<MessageInitShape<typeof BoundWorkflowScheduleSchema>>;
|
|
119
|
-
upsertEventTrigger: (
|
|
120
|
-
request: UpsertWorkflowProviderEventTriggerRequest,
|
|
121
|
-
) => MaybePromise<MessageInitShape<typeof BoundWorkflowEventTriggerSchema>>;
|
|
122
|
-
getEventTrigger: (
|
|
123
|
-
request: GetWorkflowProviderEventTriggerRequest,
|
|
124
|
-
) => MaybePromise<MessageInitShape<typeof BoundWorkflowEventTriggerSchema>>;
|
|
125
|
-
listEventTriggers: (
|
|
126
|
-
request: ListWorkflowProviderEventTriggersRequest,
|
|
127
|
-
) => MaybePromise<MessageInitShape<typeof BoundWorkflowEventTriggerSchema>[]>;
|
|
128
|
-
deleteEventTrigger: (
|
|
129
|
-
request: DeleteWorkflowProviderEventTriggerRequest,
|
|
130
|
-
) => MaybePromise<void>;
|
|
131
|
-
pauseEventTrigger: (
|
|
132
|
-
request: PauseWorkflowProviderEventTriggerRequest,
|
|
133
|
-
) => MaybePromise<MessageInitShape<typeof BoundWorkflowEventTriggerSchema>>;
|
|
134
|
-
resumeEventTrigger: (
|
|
135
|
-
request: ResumeWorkflowProviderEventTriggerRequest,
|
|
136
|
-
) => MaybePromise<MessageInitShape<typeof BoundWorkflowEventTriggerSchema>>;
|
|
137
|
-
publishEvent: (
|
|
138
|
-
request: PublishWorkflowProviderEventRequest,
|
|
139
|
-
) => MaybePromise<void>;
|
|
137
|
+
export interface BoundWorkflowPluginTarget {
|
|
138
|
+
pluginName?: string | undefined;
|
|
139
|
+
operation?: string | undefined;
|
|
140
|
+
input?: JsonObjectInput | undefined;
|
|
141
|
+
connection?: string | undefined;
|
|
142
|
+
instance?: string | undefined;
|
|
143
|
+
credentialMode?: string | undefined;
|
|
140
144
|
}
|
|
145
|
+
export type BoundWorkflowPluginTargetInput = BoundWorkflowPluginTarget;
|
|
141
146
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
147
|
+
export type WorkflowOutputValueSourceKind =
|
|
148
|
+
| { case: "agentOutput"; value: string }
|
|
149
|
+
| { case: "signalPayload"; value: string }
|
|
150
|
+
| { case: "signalMetadata"; value: string }
|
|
151
|
+
| { case: "literal"; value: JsonInput }
|
|
152
|
+
| { case: "agentSession"; value: string }
|
|
153
|
+
| { case: undefined; value?: undefined };
|
|
145
154
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
private readonly cancelRunHandler: WorkflowProviderOptions["cancelRun"];
|
|
150
|
-
private readonly upsertScheduleHandler: WorkflowProviderOptions["upsertSchedule"];
|
|
151
|
-
private readonly getScheduleHandler: WorkflowProviderOptions["getSchedule"];
|
|
152
|
-
private readonly listSchedulesHandler: WorkflowProviderOptions["listSchedules"];
|
|
153
|
-
private readonly deleteScheduleHandler: WorkflowProviderOptions["deleteSchedule"];
|
|
154
|
-
private readonly pauseScheduleHandler: WorkflowProviderOptions["pauseSchedule"];
|
|
155
|
-
private readonly resumeScheduleHandler: WorkflowProviderOptions["resumeSchedule"];
|
|
156
|
-
private readonly upsertEventTriggerHandler: WorkflowProviderOptions["upsertEventTrigger"];
|
|
157
|
-
private readonly getEventTriggerHandler: WorkflowProviderOptions["getEventTrigger"];
|
|
158
|
-
private readonly listEventTriggersHandler: WorkflowProviderOptions["listEventTriggers"];
|
|
159
|
-
private readonly deleteEventTriggerHandler: WorkflowProviderOptions["deleteEventTrigger"];
|
|
160
|
-
private readonly pauseEventTriggerHandler: WorkflowProviderOptions["pauseEventTrigger"];
|
|
161
|
-
private readonly resumeEventTriggerHandler: WorkflowProviderOptions["resumeEventTrigger"];
|
|
162
|
-
private readonly publishEventHandler: WorkflowProviderOptions["publishEvent"];
|
|
155
|
+
export interface WorkflowOutputValueSource {
|
|
156
|
+
kind: WorkflowOutputValueSourceKind;
|
|
157
|
+
}
|
|
163
158
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
this.listSchedulesHandler = options.listSchedules;
|
|
173
|
-
this.deleteScheduleHandler = options.deleteSchedule;
|
|
174
|
-
this.pauseScheduleHandler = options.pauseSchedule;
|
|
175
|
-
this.resumeScheduleHandler = options.resumeSchedule;
|
|
176
|
-
this.upsertEventTriggerHandler = options.upsertEventTrigger;
|
|
177
|
-
this.getEventTriggerHandler = options.getEventTrigger;
|
|
178
|
-
this.listEventTriggersHandler = options.listEventTriggers;
|
|
179
|
-
this.deleteEventTriggerHandler = options.deleteEventTrigger;
|
|
180
|
-
this.pauseEventTriggerHandler = options.pauseEventTrigger;
|
|
181
|
-
this.resumeEventTriggerHandler = options.resumeEventTrigger;
|
|
182
|
-
this.publishEventHandler = options.publishEvent;
|
|
183
|
-
}
|
|
159
|
+
export interface WorkflowOutputValueSourceInput {
|
|
160
|
+
agentOutput?: string | undefined;
|
|
161
|
+
signalPayload?: string | undefined;
|
|
162
|
+
signalMetadata?: string | undefined;
|
|
163
|
+
literal?: JsonInput | undefined;
|
|
164
|
+
agentSession?: string | undefined;
|
|
165
|
+
kind?: WorkflowOutputValueSourceKind | undefined;
|
|
166
|
+
}
|
|
184
167
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
168
|
+
export interface WorkflowOutputBinding {
|
|
169
|
+
inputField?: string | undefined;
|
|
170
|
+
value?: WorkflowOutputValueSource | WorkflowOutputValueSourceInput | undefined;
|
|
171
|
+
}
|
|
172
|
+
export type WorkflowOutputBindingInput = WorkflowOutputBinding;
|
|
190
173
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
174
|
+
export interface WorkflowOutputDelivery {
|
|
175
|
+
target?: BoundWorkflowPluginTarget | undefined;
|
|
176
|
+
inputBindings?: readonly WorkflowOutputBinding[] | undefined;
|
|
177
|
+
credentialMode?: string | undefined;
|
|
178
|
+
}
|
|
179
|
+
export type WorkflowOutputDeliveryInput = WorkflowOutputDelivery;
|
|
196
180
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
181
|
+
export interface BoundWorkflowAgentTarget {
|
|
182
|
+
providerName?: string | undefined;
|
|
183
|
+
model?: string | undefined;
|
|
184
|
+
prompt?: string | undefined;
|
|
185
|
+
messages?: readonly AgentMessage[] | undefined;
|
|
186
|
+
toolRefs?: readonly AgentToolRef[] | undefined;
|
|
187
|
+
responseSchema?: JsonObjectInput | undefined;
|
|
188
|
+
metadata?: JsonObjectInput | undefined;
|
|
189
|
+
timeoutSeconds?: number | undefined;
|
|
190
|
+
outputDelivery?: WorkflowOutputDelivery | undefined;
|
|
191
|
+
modelOptions?: JsonObjectInput | undefined;
|
|
192
|
+
sessionReadyDelivery?: WorkflowOutputDelivery | undefined;
|
|
193
|
+
}
|
|
194
|
+
export type BoundWorkflowAgentTargetInput = BoundWorkflowAgentTarget;
|
|
202
195
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
196
|
+
export type BoundWorkflowTargetKind =
|
|
197
|
+
| { case: "plugin"; value: BoundWorkflowPluginTarget }
|
|
198
|
+
| { case: "agent"; value: BoundWorkflowAgentTarget }
|
|
199
|
+
| { case: undefined; value?: undefined };
|
|
208
200
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
return await this.upsertScheduleHandler(request);
|
|
213
|
-
}
|
|
201
|
+
export interface BoundWorkflowTarget {
|
|
202
|
+
kind: BoundWorkflowTargetKind;
|
|
203
|
+
}
|
|
214
204
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
205
|
+
export interface BoundWorkflowTargetInput {
|
|
206
|
+
plugin?: BoundWorkflowPluginTarget | undefined;
|
|
207
|
+
agent?: BoundWorkflowAgentTarget | undefined;
|
|
208
|
+
kind?: BoundWorkflowTargetKind | undefined;
|
|
209
|
+
}
|
|
220
210
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
211
|
+
export interface WorkflowActor {
|
|
212
|
+
subjectId?: string | undefined;
|
|
213
|
+
subjectKind?: string | undefined;
|
|
214
|
+
displayName?: string | undefined;
|
|
215
|
+
authSource?: string | undefined;
|
|
216
|
+
}
|
|
217
|
+
export type WorkflowActorInput = WorkflowActor;
|
|
226
218
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
219
|
+
export interface WorkflowRunAsSubject {
|
|
220
|
+
subjectId?: string | undefined;
|
|
221
|
+
subjectKind?: string | undefined;
|
|
222
|
+
displayName?: string | undefined;
|
|
223
|
+
authSource?: string | undefined;
|
|
224
|
+
}
|
|
225
|
+
export type WorkflowRunAsSubjectInput = WorkflowRunAsSubject;
|
|
232
226
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
227
|
+
export interface WorkflowAccessPermission {
|
|
228
|
+
plugin?: string | undefined;
|
|
229
|
+
operations?: readonly string[] | undefined;
|
|
230
|
+
}
|
|
231
|
+
export type WorkflowAccessPermissionInput = WorkflowAccessPermission;
|
|
238
232
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
233
|
+
export interface WorkflowEvent {
|
|
234
|
+
id?: string | undefined;
|
|
235
|
+
source?: string | undefined;
|
|
236
|
+
specVersion?: string | undefined;
|
|
237
|
+
type?: string | undefined;
|
|
238
|
+
subject?: string | undefined;
|
|
239
|
+
time?: Date | undefined;
|
|
240
|
+
datacontenttype?: string | undefined;
|
|
241
|
+
data?: JsonObjectInput | undefined;
|
|
242
|
+
extensions?: Record<string, JsonInput> | undefined;
|
|
243
|
+
}
|
|
244
|
+
export type WorkflowEventInput = WorkflowEvent;
|
|
244
245
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
246
|
+
export interface WorkflowEventMatch {
|
|
247
|
+
type?: string | undefined;
|
|
248
|
+
source?: string | undefined;
|
|
249
|
+
subject?: string | undefined;
|
|
250
|
+
}
|
|
251
|
+
export type WorkflowEventMatchInput = WorkflowEventMatch;
|
|
250
252
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
253
|
+
export interface WorkflowSignal {
|
|
254
|
+
id?: string | undefined;
|
|
255
|
+
name?: string | undefined;
|
|
256
|
+
payload?: JsonObjectInput | undefined;
|
|
257
|
+
metadata?: JsonObjectInput | undefined;
|
|
258
|
+
createdBy?: WorkflowActor | undefined;
|
|
259
|
+
createdAt?: Date | undefined;
|
|
260
|
+
idempotencyKey?: string | undefined;
|
|
261
|
+
sequence?: bigint | number | undefined;
|
|
262
|
+
}
|
|
263
|
+
export type WorkflowSignalInput = WorkflowSignal;
|
|
256
264
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
265
|
+
export interface WorkflowScheduleTrigger {
|
|
266
|
+
scheduleId?: string | undefined;
|
|
267
|
+
scheduledFor?: Date | undefined;
|
|
268
|
+
}
|
|
269
|
+
export type WorkflowScheduleTriggerInput = WorkflowScheduleTrigger;
|
|
262
270
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
271
|
+
export interface WorkflowEventTriggerInvocation {
|
|
272
|
+
triggerId?: string | undefined;
|
|
273
|
+
event?: WorkflowEvent | undefined;
|
|
274
|
+
}
|
|
275
|
+
export type WorkflowEventTriggerInvocationInput = WorkflowEventTriggerInvocation;
|
|
268
276
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
277
|
+
export type WorkflowRunTriggerKind =
|
|
278
|
+
| { case: "manual"; value?: Record<string, never> }
|
|
279
|
+
| { case: "schedule"; value: WorkflowScheduleTrigger }
|
|
280
|
+
| { case: "event"; value: WorkflowEventTriggerInvocation }
|
|
281
|
+
| { case: undefined; value?: undefined };
|
|
274
282
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return await this.resumeEventTriggerHandler(request);
|
|
279
|
-
}
|
|
283
|
+
export interface WorkflowRunTrigger {
|
|
284
|
+
kind: WorkflowRunTriggerKind;
|
|
285
|
+
}
|
|
280
286
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
287
|
+
export interface WorkflowRunTriggerInput {
|
|
288
|
+
manual?: boolean | undefined;
|
|
289
|
+
schedule?: WorkflowScheduleTrigger | undefined;
|
|
290
|
+
event?: WorkflowEventTriggerInvocation | undefined;
|
|
291
|
+
kind?: WorkflowRunTriggerKind | undefined;
|
|
286
292
|
}
|
|
287
293
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
294
|
+
export interface BoundWorkflowRun {
|
|
295
|
+
id: string;
|
|
296
|
+
status: WorkflowRunStatus;
|
|
297
|
+
target?: BoundWorkflowTarget | undefined;
|
|
298
|
+
trigger?: WorkflowRunTrigger | undefined;
|
|
299
|
+
createdAt?: Date | undefined;
|
|
300
|
+
startedAt?: Date | undefined;
|
|
301
|
+
completedAt?: Date | undefined;
|
|
302
|
+
statusMessage: string;
|
|
303
|
+
resultBody: string;
|
|
304
|
+
createdBy?: WorkflowActor | undefined;
|
|
305
|
+
executionRef: string;
|
|
306
|
+
workflowKey: string;
|
|
307
|
+
}
|
|
308
|
+
export interface BoundWorkflowRunInput {
|
|
309
|
+
id?: string | undefined;
|
|
310
|
+
status?: WorkflowRunStatus | undefined;
|
|
311
|
+
target?: BoundWorkflowTarget | BoundWorkflowTargetInput | undefined;
|
|
312
|
+
trigger?: WorkflowRunTrigger | WorkflowRunTriggerInput | undefined;
|
|
313
|
+
createdAt?: Date | undefined;
|
|
314
|
+
startedAt?: Date | undefined;
|
|
315
|
+
completedAt?: Date | undefined;
|
|
316
|
+
statusMessage?: string | undefined;
|
|
317
|
+
resultBody?: string | undefined;
|
|
318
|
+
createdBy?: WorkflowActor | WorkflowActorInput | undefined;
|
|
319
|
+
executionRef?: string | undefined;
|
|
320
|
+
workflowKey?: string | undefined;
|
|
293
321
|
}
|
|
294
322
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
"resumeEventTrigger" in value &&
|
|
319
|
-
"publishEvent" in value)
|
|
320
|
-
);
|
|
323
|
+
export interface BoundWorkflowSchedule {
|
|
324
|
+
id: string;
|
|
325
|
+
cron: string;
|
|
326
|
+
timezone: string;
|
|
327
|
+
target?: BoundWorkflowTarget | undefined;
|
|
328
|
+
paused: boolean;
|
|
329
|
+
createdAt?: Date | undefined;
|
|
330
|
+
updatedAt?: Date | undefined;
|
|
331
|
+
nextRunAt?: Date | undefined;
|
|
332
|
+
createdBy?: WorkflowActor | undefined;
|
|
333
|
+
executionRef: string;
|
|
334
|
+
}
|
|
335
|
+
export interface BoundWorkflowScheduleInput {
|
|
336
|
+
id?: string | undefined;
|
|
337
|
+
cron?: string | undefined;
|
|
338
|
+
timezone?: string | undefined;
|
|
339
|
+
target?: BoundWorkflowTarget | BoundWorkflowTargetInput | undefined;
|
|
340
|
+
paused?: boolean | undefined;
|
|
341
|
+
createdAt?: Date | undefined;
|
|
342
|
+
updatedAt?: Date | undefined;
|
|
343
|
+
nextRunAt?: Date | undefined;
|
|
344
|
+
createdBy?: WorkflowActor | WorkflowActorInput | undefined;
|
|
345
|
+
executionRef?: string | undefined;
|
|
321
346
|
}
|
|
322
347
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
348
|
+
export interface BoundWorkflowEventTrigger {
|
|
349
|
+
id: string;
|
|
350
|
+
match?: WorkflowEventMatch | undefined;
|
|
351
|
+
target?: BoundWorkflowTarget | undefined;
|
|
352
|
+
paused: boolean;
|
|
353
|
+
createdAt?: Date | undefined;
|
|
354
|
+
updatedAt?: Date | undefined;
|
|
355
|
+
createdBy?: WorkflowActor | undefined;
|
|
356
|
+
executionRef: string;
|
|
357
|
+
}
|
|
358
|
+
export interface BoundWorkflowEventTriggerInput {
|
|
359
|
+
id?: string | undefined;
|
|
360
|
+
match?: WorkflowEventMatch | WorkflowEventMatchInput | undefined;
|
|
361
|
+
target?: BoundWorkflowTarget | BoundWorkflowTargetInput | undefined;
|
|
362
|
+
paused?: boolean | undefined;
|
|
363
|
+
createdAt?: Date | undefined;
|
|
364
|
+
updatedAt?: Date | undefined;
|
|
365
|
+
createdBy?: WorkflowActor | WorkflowActorInput | undefined;
|
|
366
|
+
executionRef?: string | undefined;
|
|
367
|
+
}
|
|
326
368
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
369
|
+
export interface BoundWorkflowDefinition {
|
|
370
|
+
id: string;
|
|
371
|
+
target?: BoundWorkflowTarget | undefined;
|
|
372
|
+
createdBy?: WorkflowActor | undefined;
|
|
373
|
+
createdAt?: Date | undefined;
|
|
374
|
+
}
|
|
375
|
+
export interface BoundWorkflowDefinitionInput {
|
|
376
|
+
id?: string | undefined;
|
|
377
|
+
target?: BoundWorkflowTarget | BoundWorkflowTargetInput | undefined;
|
|
378
|
+
createdBy?: WorkflowActor | WorkflowActorInput | undefined;
|
|
379
|
+
createdAt?: Date | undefined;
|
|
380
|
+
}
|
|
340
381
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
382
|
+
export interface WorkflowExecutionReference {
|
|
383
|
+
id: string;
|
|
384
|
+
providerName: string;
|
|
385
|
+
target?: BoundWorkflowTarget | undefined;
|
|
386
|
+
subjectId: string;
|
|
387
|
+
credentialSubjectId: string;
|
|
388
|
+
permissions: readonly WorkflowAccessPermission[];
|
|
389
|
+
createdAt?: Date | undefined;
|
|
390
|
+
revokedAt?: Date | undefined;
|
|
391
|
+
subjectKind: string;
|
|
392
|
+
displayName: string;
|
|
393
|
+
authSource: string;
|
|
394
|
+
callerPluginName: string;
|
|
395
|
+
runAs?: WorkflowRunAsSubject | undefined;
|
|
396
|
+
sourceDefinitionId: string;
|
|
397
|
+
}
|
|
398
|
+
export interface WorkflowExecutionReferenceInput {
|
|
399
|
+
id?: string | undefined;
|
|
400
|
+
providerName?: string | undefined;
|
|
401
|
+
target?: BoundWorkflowTarget | BoundWorkflowTargetInput | undefined;
|
|
402
|
+
subjectId?: string | undefined;
|
|
403
|
+
credentialSubjectId?: string | undefined;
|
|
404
|
+
permissions?: readonly (WorkflowAccessPermission | WorkflowAccessPermissionInput)[] | undefined;
|
|
405
|
+
createdAt?: Date | undefined;
|
|
406
|
+
revokedAt?: Date | undefined;
|
|
407
|
+
subjectKind?: string | undefined;
|
|
408
|
+
displayName?: string | undefined;
|
|
409
|
+
authSource?: string | undefined;
|
|
410
|
+
callerPluginName?: string | undefined;
|
|
411
|
+
runAs?: WorkflowRunAsSubject | WorkflowRunAsSubjectInput | undefined;
|
|
412
|
+
sourceDefinitionId?: string | undefined;
|
|
347
413
|
}
|
|
348
414
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
415
|
+
export interface StartWorkflowProviderRunRequest {
|
|
416
|
+
target?: BoundWorkflowTarget | undefined;
|
|
417
|
+
idempotencyKey: string;
|
|
418
|
+
createdBy?: WorkflowActor | undefined;
|
|
419
|
+
executionRef: string;
|
|
420
|
+
workflowKey: string;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export interface GetWorkflowProviderRunRequest {
|
|
424
|
+
runId: string;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export interface ListWorkflowProviderRunsRequest {}
|
|
428
|
+
|
|
429
|
+
export interface CancelWorkflowProviderRunRequest {
|
|
430
|
+
runId: string;
|
|
431
|
+
reason: string;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export interface SignalWorkflowProviderRunRequest {
|
|
435
|
+
runId: string;
|
|
436
|
+
signal?: WorkflowSignal | undefined;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export interface SignalOrStartWorkflowProviderRunRequest {
|
|
440
|
+
workflowKey: string;
|
|
441
|
+
target?: BoundWorkflowTarget | undefined;
|
|
442
|
+
idempotencyKey: string;
|
|
443
|
+
createdBy?: WorkflowActor | undefined;
|
|
444
|
+
executionRef: string;
|
|
445
|
+
signal?: WorkflowSignal | undefined;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export interface SignalWorkflowRunResponse {
|
|
449
|
+
run?: BoundWorkflowRun | undefined;
|
|
450
|
+
signal?: WorkflowSignal | undefined;
|
|
451
|
+
startedRun: boolean;
|
|
452
|
+
workflowKey: string;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
export interface UpsertWorkflowProviderScheduleRequest {
|
|
456
|
+
scheduleId: string;
|
|
457
|
+
cron: string;
|
|
458
|
+
timezone: string;
|
|
459
|
+
target?: BoundWorkflowTarget | undefined;
|
|
460
|
+
paused: boolean;
|
|
461
|
+
requestedBy?: WorkflowActor | undefined;
|
|
462
|
+
executionRef: string;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
export interface GetWorkflowProviderScheduleRequest {
|
|
466
|
+
scheduleId: string;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
export interface ListWorkflowProviderSchedulesRequest {}
|
|
470
|
+
|
|
471
|
+
export interface DeleteWorkflowProviderScheduleRequest {
|
|
472
|
+
scheduleId: string;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export interface PauseWorkflowProviderScheduleRequest {
|
|
476
|
+
scheduleId: string;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export interface ResumeWorkflowProviderScheduleRequest {
|
|
480
|
+
scheduleId: string;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
export interface UpsertWorkflowProviderEventTriggerRequest {
|
|
484
|
+
triggerId: string;
|
|
485
|
+
match?: WorkflowEventMatch | undefined;
|
|
486
|
+
target?: BoundWorkflowTarget | undefined;
|
|
487
|
+
paused: boolean;
|
|
488
|
+
requestedBy?: WorkflowActor | undefined;
|
|
489
|
+
executionRef: string;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
export interface GetWorkflowProviderEventTriggerRequest {
|
|
493
|
+
triggerId: string;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
export interface ListWorkflowProviderEventTriggersRequest {}
|
|
497
|
+
|
|
498
|
+
export interface DeleteWorkflowProviderEventTriggerRequest {
|
|
499
|
+
triggerId: string;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export interface PauseWorkflowProviderEventTriggerRequest {
|
|
503
|
+
triggerId: string;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export interface ResumeWorkflowProviderEventTriggerRequest {
|
|
507
|
+
triggerId: string;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
export interface PutWorkflowExecutionReferenceRequest {
|
|
511
|
+
reference?: WorkflowExecutionReference | undefined;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
export interface GetWorkflowExecutionReferenceRequest {
|
|
515
|
+
id: string;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
export interface ListWorkflowExecutionReferencesRequest {
|
|
519
|
+
subjectId: string;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
export interface PublishWorkflowProviderEventRequest {
|
|
523
|
+
pluginName: string;
|
|
524
|
+
event?: WorkflowEvent | undefined;
|
|
525
|
+
publishedBy?: WorkflowActor | undefined;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/** Native input for invoking a workflow operation through the host service. */
|
|
529
|
+
export interface InvokeWorkflowOperationInput {
|
|
530
|
+
target?: BoundWorkflowTarget | BoundWorkflowTargetInput | undefined;
|
|
531
|
+
runId?: string | undefined;
|
|
532
|
+
trigger?: WorkflowRunTrigger | WorkflowRunTriggerInput | undefined;
|
|
533
|
+
input?: JsonObjectInput | undefined;
|
|
534
|
+
metadata?: JsonObjectInput | undefined;
|
|
535
|
+
createdBy?: WorkflowActor | undefined;
|
|
536
|
+
executionRef?: string | undefined;
|
|
537
|
+
signals?: readonly WorkflowSignal[] | undefined;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/** Native response returned after invoking a workflow operation. */
|
|
541
|
+
export interface InvokeWorkflowOperationResponse {
|
|
542
|
+
status: number;
|
|
543
|
+
body: string;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
export interface ManagedWorkflowSchedule {
|
|
547
|
+
providerName?: string | undefined;
|
|
548
|
+
schedule?: BoundWorkflowSchedule | undefined;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
export interface ManagedWorkflowEventTrigger {
|
|
552
|
+
providerName?: string | undefined;
|
|
553
|
+
trigger?: BoundWorkflowEventTrigger | undefined;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
export interface ManagedWorkflowDefinition {
|
|
557
|
+
providerName?: string | undefined;
|
|
558
|
+
definition?: BoundWorkflowDefinition | undefined;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
export interface ManagedWorkflowRun {
|
|
562
|
+
providerName?: string | undefined;
|
|
563
|
+
run?: BoundWorkflowRun | undefined;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
export interface ManagedWorkflowRunSignal {
|
|
567
|
+
providerName?: string | undefined;
|
|
568
|
+
run?: BoundWorkflowRun | undefined;
|
|
569
|
+
signal?: WorkflowSignal | undefined;
|
|
570
|
+
startedRun?: boolean | undefined;
|
|
571
|
+
workflowKey?: string | undefined;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/** Creates workflow actor metadata from native input. */
|
|
575
|
+
export function workflowActor(input: WorkflowActorInput = {}): WorkflowActor {
|
|
576
|
+
return {
|
|
577
|
+
subjectId: input.subjectId ?? "",
|
|
578
|
+
subjectKind: input.subjectKind ?? "",
|
|
579
|
+
displayName: input.displayName ?? "",
|
|
580
|
+
authSource: input.authSource ?? "",
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/** Returns native input copied from workflow actor metadata. */
|
|
585
|
+
export function workflowActorInputFromActor(input?: WorkflowActor): WorkflowActorInput | undefined {
|
|
586
|
+
return input === undefined ? undefined : { ...input };
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/** Creates workflow run-as metadata from native input. */
|
|
590
|
+
export function workflowRunAsSubject(
|
|
591
|
+
input: WorkflowRunAsSubjectInput = {},
|
|
592
|
+
): WorkflowRunAsSubject {
|
|
593
|
+
return {
|
|
594
|
+
subjectId: input.subjectId ?? "",
|
|
595
|
+
subjectKind: input.subjectKind ?? "",
|
|
596
|
+
displayName: input.displayName ?? "",
|
|
597
|
+
authSource: input.authSource ?? "",
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/** Returns native input copied from workflow run-as metadata. */
|
|
602
|
+
export function workflowRunAsSubjectInputFromSubject(
|
|
603
|
+
input?: WorkflowRunAsSubject,
|
|
604
|
+
): WorkflowRunAsSubjectInput | undefined {
|
|
605
|
+
return input === undefined ? undefined : { ...input };
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/** Creates an execution-reference permission from native input. */
|
|
609
|
+
export function workflowAccessPermission(
|
|
610
|
+
input: WorkflowAccessPermissionInput = {},
|
|
611
|
+
): WorkflowAccessPermission {
|
|
612
|
+
return {
|
|
613
|
+
plugin: input.plugin ?? "",
|
|
614
|
+
operations: [...(input.operations ?? [])],
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/** Returns native input copied from an execution-reference permission. */
|
|
619
|
+
export function workflowAccessPermissionInputFromPermission(
|
|
620
|
+
input: WorkflowAccessPermission,
|
|
621
|
+
): WorkflowAccessPermissionInput {
|
|
622
|
+
return {
|
|
623
|
+
plugin: input.plugin,
|
|
624
|
+
operations: [...(input.operations ?? [])],
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/** Creates workflow event-match fields from native input. */
|
|
629
|
+
export function workflowEventMatch(
|
|
630
|
+
input: WorkflowEventMatchInput = {},
|
|
631
|
+
): WorkflowEventMatch {
|
|
632
|
+
return {
|
|
633
|
+
type: input.type ?? "",
|
|
634
|
+
source: input.source ?? "",
|
|
635
|
+
subject: input.subject ?? "",
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/** Returns native input copied from workflow event-match fields. */
|
|
640
|
+
export function workflowEventMatchInputFromMatch(
|
|
641
|
+
input?: WorkflowEventMatch,
|
|
642
|
+
): WorkflowEventMatchInput | undefined {
|
|
643
|
+
return input === undefined ? undefined : { ...input };
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/** Creates a workflow output value source from native input. */
|
|
647
|
+
export function workflowOutputValueSource(
|
|
648
|
+
input: WorkflowOutputValueSourceInput | WorkflowOutputValueSource = {},
|
|
649
|
+
): WorkflowOutputValueSource {
|
|
650
|
+
if ("kind" in input && input.kind !== undefined) {
|
|
651
|
+
return { kind: cloneWorkflowOutputValueSourceKind(input.kind) };
|
|
652
|
+
}
|
|
653
|
+
const sourceInput = input as WorkflowOutputValueSourceInput;
|
|
654
|
+
const selected = [
|
|
655
|
+
sourceInput.agentOutput === undefined ? undefined : "agentOutput",
|
|
656
|
+
sourceInput.signalPayload === undefined ? undefined : "signalPayload",
|
|
657
|
+
sourceInput.signalMetadata === undefined ? undefined : "signalMetadata",
|
|
658
|
+
Object.prototype.hasOwnProperty.call(sourceInput, "literal") ? "literal" : undefined,
|
|
659
|
+
sourceInput.agentSession === undefined ? undefined : "agentSession",
|
|
660
|
+
].filter((value): value is string => value !== undefined);
|
|
661
|
+
if (selected.length === 0) {
|
|
662
|
+
return { kind: { case: undefined } };
|
|
663
|
+
}
|
|
664
|
+
if (selected.length > 1) {
|
|
665
|
+
throw new Error("workflow output value source must set exactly one source");
|
|
666
|
+
}
|
|
667
|
+
switch (selected[0]) {
|
|
668
|
+
case "agentOutput":
|
|
669
|
+
return { kind: { case: "agentOutput", value: sourceInput.agentOutput ?? "" } };
|
|
670
|
+
case "signalPayload":
|
|
671
|
+
return { kind: { case: "signalPayload", value: sourceInput.signalPayload ?? "" } };
|
|
672
|
+
case "signalMetadata":
|
|
673
|
+
return { kind: { case: "signalMetadata", value: sourceInput.signalMetadata ?? "" } };
|
|
674
|
+
case "agentSession":
|
|
675
|
+
return { kind: { case: "agentSession", value: sourceInput.agentSession ?? "" } };
|
|
676
|
+
default:
|
|
677
|
+
return { kind: { case: "literal", value: sourceInput.literal ?? null } };
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/** Returns native input copied from a workflow output value source. */
|
|
682
|
+
export function workflowOutputValueSourceInputFromSource(
|
|
683
|
+
input?: WorkflowOutputValueSource,
|
|
684
|
+
): WorkflowOutputValueSourceInput | undefined {
|
|
685
|
+
if (input === undefined) {
|
|
686
|
+
return undefined;
|
|
687
|
+
}
|
|
688
|
+
switch (input.kind.case) {
|
|
689
|
+
case "agentOutput":
|
|
690
|
+
return { agentOutput: input.kind.value };
|
|
691
|
+
case "signalPayload":
|
|
692
|
+
return { signalPayload: input.kind.value };
|
|
693
|
+
case "signalMetadata":
|
|
694
|
+
return { signalMetadata: input.kind.value };
|
|
695
|
+
case "agentSession":
|
|
696
|
+
return { agentSession: input.kind.value };
|
|
697
|
+
case "literal":
|
|
698
|
+
return { literal: input.kind.value };
|
|
699
|
+
default:
|
|
700
|
+
return {};
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/** Creates a workflow output binding from native input. */
|
|
705
|
+
export function workflowOutputBinding(
|
|
706
|
+
input: WorkflowOutputBindingInput = {},
|
|
707
|
+
): WorkflowOutputBinding {
|
|
708
|
+
return {
|
|
709
|
+
inputField: input.inputField ?? "",
|
|
710
|
+
value: input.value === undefined ? undefined : workflowOutputValueSource(input.value),
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/** Returns native input copied from a workflow output binding. */
|
|
715
|
+
export function workflowOutputBindingInputFromBinding(
|
|
716
|
+
input: WorkflowOutputBinding,
|
|
717
|
+
): WorkflowOutputBindingInput {
|
|
718
|
+
return {
|
|
719
|
+
inputField: input.inputField,
|
|
720
|
+
value: input.value === undefined
|
|
721
|
+
? undefined
|
|
722
|
+
: workflowOutputValueSourceInputFromSource(workflowOutputValueSource(input.value)),
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/** Creates a workflow output delivery from native input. */
|
|
727
|
+
export function workflowOutputDelivery(
|
|
728
|
+
input: WorkflowOutputDeliveryInput = {},
|
|
729
|
+
): WorkflowOutputDelivery {
|
|
730
|
+
return {
|
|
731
|
+
target: input.target === undefined ? undefined : boundWorkflowPluginTarget(input.target),
|
|
732
|
+
inputBindings: input.inputBindings?.map((binding) => workflowOutputBinding(binding)) ?? [],
|
|
733
|
+
credentialMode: input.credentialMode ?? "",
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/** Returns native input copied from a workflow output delivery. */
|
|
738
|
+
export function workflowOutputDeliveryInputFromDelivery(
|
|
739
|
+
input?: WorkflowOutputDelivery,
|
|
740
|
+
): WorkflowOutputDeliveryInput | undefined {
|
|
741
|
+
if (input === undefined) {
|
|
742
|
+
return undefined;
|
|
743
|
+
}
|
|
744
|
+
return {
|
|
745
|
+
target: boundWorkflowPluginTargetInputFromTarget(input.target),
|
|
746
|
+
inputBindings: input.inputBindings?.map((binding) => workflowOutputBindingInputFromBinding(binding)) ?? [],
|
|
747
|
+
credentialMode: input.credentialMode,
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/** Creates a bound plugin workflow target from native input. */
|
|
752
|
+
export function boundWorkflowPluginTarget(
|
|
753
|
+
input: BoundWorkflowPluginTargetInput = {},
|
|
754
|
+
): BoundWorkflowPluginTarget {
|
|
755
|
+
return {
|
|
756
|
+
pluginName: input.pluginName ?? "",
|
|
757
|
+
operation: input.operation ?? "",
|
|
758
|
+
input: input.input === undefined ? undefined : structFromObject(input.input),
|
|
759
|
+
connection: input.connection ?? "",
|
|
760
|
+
instance: input.instance ?? "",
|
|
761
|
+
credentialMode: input.credentialMode ?? "",
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/** Returns native input copied from a bound plugin workflow target. */
|
|
766
|
+
export function boundWorkflowPluginTargetInputFromTarget(
|
|
767
|
+
input?: BoundWorkflowPluginTarget,
|
|
768
|
+
): BoundWorkflowPluginTargetInput | undefined {
|
|
769
|
+
if (input === undefined) {
|
|
770
|
+
return undefined;
|
|
771
|
+
}
|
|
772
|
+
return {
|
|
773
|
+
pluginName: input.pluginName,
|
|
774
|
+
operation: input.operation,
|
|
775
|
+
input: input.input === undefined ? undefined : jsonObjectClone(input.input),
|
|
776
|
+
connection: input.connection,
|
|
777
|
+
instance: input.instance,
|
|
778
|
+
credentialMode: input.credentialMode,
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
/** Creates a bound agent workflow target from native input. */
|
|
783
|
+
export function boundWorkflowAgentTarget(
|
|
784
|
+
input: BoundWorkflowAgentTargetInput = {},
|
|
785
|
+
): BoundWorkflowAgentTarget {
|
|
786
|
+
return {
|
|
787
|
+
providerName: input.providerName ?? "",
|
|
788
|
+
model: input.model ?? "",
|
|
789
|
+
prompt: input.prompt ?? "",
|
|
790
|
+
messages: [...(input.messages ?? [])],
|
|
791
|
+
toolRefs: [...(input.toolRefs ?? [])],
|
|
792
|
+
responseSchema: input.responseSchema === undefined ? undefined : structFromObject(input.responseSchema),
|
|
793
|
+
metadata: input.metadata === undefined ? undefined : structFromObject(input.metadata),
|
|
794
|
+
timeoutSeconds: input.timeoutSeconds ?? 0,
|
|
795
|
+
outputDelivery: input.outputDelivery === undefined ? undefined : workflowOutputDelivery(input.outputDelivery),
|
|
796
|
+
modelOptions: input.modelOptions === undefined ? undefined : structFromObject(input.modelOptions),
|
|
797
|
+
sessionReadyDelivery: input.sessionReadyDelivery === undefined
|
|
798
|
+
? undefined
|
|
799
|
+
: workflowOutputDelivery(input.sessionReadyDelivery),
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/** Returns native input copied from a bound agent workflow target. */
|
|
804
|
+
export function boundWorkflowAgentTargetInputFromTarget(
|
|
805
|
+
input?: BoundWorkflowAgentTarget,
|
|
806
|
+
): BoundWorkflowAgentTargetInput | undefined {
|
|
807
|
+
if (input === undefined) {
|
|
808
|
+
return undefined;
|
|
809
|
+
}
|
|
810
|
+
return {
|
|
811
|
+
providerName: input.providerName,
|
|
812
|
+
model: input.model,
|
|
813
|
+
prompt: input.prompt,
|
|
814
|
+
messages: [...(input.messages ?? [])],
|
|
815
|
+
toolRefs: [...(input.toolRefs ?? [])],
|
|
816
|
+
responseSchema: input.responseSchema === undefined ? undefined : jsonObjectClone(input.responseSchema),
|
|
817
|
+
metadata: input.metadata === undefined ? undefined : jsonObjectClone(input.metadata),
|
|
818
|
+
timeoutSeconds: input.timeoutSeconds,
|
|
819
|
+
outputDelivery: workflowOutputDeliveryInputFromDelivery(input.outputDelivery),
|
|
820
|
+
modelOptions: input.modelOptions === undefined ? undefined : jsonObjectClone(input.modelOptions),
|
|
821
|
+
sessionReadyDelivery: workflowOutputDeliveryInputFromDelivery(input.sessionReadyDelivery),
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
/** Creates a bound workflow target from native input. */
|
|
826
|
+
export function boundWorkflowTarget(
|
|
827
|
+
input: BoundWorkflowTargetInput | BoundWorkflowTarget = {},
|
|
828
|
+
): BoundWorkflowTarget {
|
|
829
|
+
if ("kind" in input && input.kind !== undefined) {
|
|
830
|
+
return boundWorkflowTargetFromTarget({ kind: input.kind });
|
|
831
|
+
}
|
|
832
|
+
const targetInput = input as BoundWorkflowTargetInput;
|
|
833
|
+
if (targetInput.plugin !== undefined && targetInput.agent !== undefined) {
|
|
834
|
+
throw new Error("bound workflow target must set either plugin or agent");
|
|
835
|
+
}
|
|
836
|
+
if (targetInput.plugin !== undefined) {
|
|
837
|
+
return { kind: { case: "plugin", value: boundWorkflowPluginTarget(targetInput.plugin) } };
|
|
838
|
+
}
|
|
839
|
+
if (targetInput.agent !== undefined) {
|
|
840
|
+
return { kind: { case: "agent", value: boundWorkflowAgentTarget(targetInput.agent) } };
|
|
841
|
+
}
|
|
842
|
+
return { kind: { case: undefined } };
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
/** Returns native input copied from a bound workflow target. */
|
|
846
|
+
export function boundWorkflowTargetInputFromTarget(
|
|
847
|
+
input?: BoundWorkflowTarget,
|
|
848
|
+
): BoundWorkflowTargetInput | undefined {
|
|
849
|
+
if (input === undefined) {
|
|
850
|
+
return undefined;
|
|
851
|
+
}
|
|
852
|
+
switch (input.kind.case) {
|
|
853
|
+
case "plugin":
|
|
854
|
+
return { plugin: boundWorkflowPluginTargetInputFromTarget(input.kind.value) };
|
|
855
|
+
case "agent":
|
|
856
|
+
return { agent: boundWorkflowAgentTargetInputFromTarget(input.kind.value) };
|
|
857
|
+
default:
|
|
858
|
+
return {};
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/** Returns a deep copy of a bound workflow target. */
|
|
863
|
+
export function boundWorkflowTargetFromTarget(input: BoundWorkflowTarget): BoundWorkflowTarget {
|
|
864
|
+
return boundWorkflowTarget(boundWorkflowTargetInputFromTarget(input) ?? {});
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
/** Creates a workflow event from native input. */
|
|
868
|
+
export function workflowEvent(input: WorkflowEventInput = {}): WorkflowEvent {
|
|
869
|
+
return {
|
|
870
|
+
id: input.id ?? "",
|
|
871
|
+
source: input.source ?? "",
|
|
872
|
+
specVersion: input.specVersion ?? "",
|
|
873
|
+
type: input.type ?? "",
|
|
874
|
+
subject: input.subject ?? "",
|
|
875
|
+
time: input.time,
|
|
876
|
+
datacontenttype: input.datacontenttype ?? "",
|
|
877
|
+
data: input.data === undefined ? undefined : structFromObject(input.data),
|
|
878
|
+
extensions: valueMapInput(input.extensions),
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
/** Returns native input copied from a workflow event. */
|
|
883
|
+
export function workflowEventInputFromEvent(input?: WorkflowEvent): WorkflowEventInput | undefined {
|
|
884
|
+
if (input === undefined) {
|
|
885
|
+
return undefined;
|
|
886
|
+
}
|
|
887
|
+
return {
|
|
888
|
+
id: input.id,
|
|
889
|
+
source: input.source,
|
|
890
|
+
specVersion: input.specVersion,
|
|
891
|
+
type: input.type,
|
|
892
|
+
subject: input.subject,
|
|
893
|
+
time: input.time,
|
|
894
|
+
datacontenttype: input.datacontenttype,
|
|
895
|
+
data: input.data === undefined ? undefined : jsonObjectClone(input.data),
|
|
896
|
+
extensions: input.extensions === undefined ? undefined : { ...input.extensions },
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/** Returns a deep copy of a workflow event. */
|
|
901
|
+
export function workflowEventFromEvent(input: WorkflowEvent): WorkflowEvent {
|
|
902
|
+
return workflowEvent(workflowEventInputFromEvent(input) ?? {});
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/** Creates a workflow signal from native input. */
|
|
906
|
+
export function workflowSignal(input: WorkflowSignalInput = {}): WorkflowSignal {
|
|
907
|
+
return {
|
|
908
|
+
id: input.id ?? "",
|
|
909
|
+
name: input.name ?? "",
|
|
910
|
+
payload: input.payload === undefined ? undefined : structFromObject(input.payload),
|
|
911
|
+
metadata: input.metadata === undefined ? undefined : structFromObject(input.metadata),
|
|
912
|
+
createdBy: input.createdBy === undefined ? undefined : workflowActor(input.createdBy),
|
|
913
|
+
createdAt: input.createdAt,
|
|
914
|
+
idempotencyKey: input.idempotencyKey ?? "",
|
|
915
|
+
sequence: input.sequence === undefined ? 0n : BigInt(input.sequence),
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
/** Returns native input copied from a workflow signal. */
|
|
920
|
+
export function workflowSignalInputFromSignal(input?: WorkflowSignal): WorkflowSignalInput | undefined {
|
|
921
|
+
if (input === undefined) {
|
|
922
|
+
return undefined;
|
|
923
|
+
}
|
|
924
|
+
return {
|
|
925
|
+
id: input.id,
|
|
926
|
+
name: input.name,
|
|
927
|
+
payload: input.payload === undefined ? undefined : jsonObjectClone(input.payload),
|
|
928
|
+
metadata: input.metadata === undefined ? undefined : jsonObjectClone(input.metadata),
|
|
929
|
+
createdBy: workflowActorInputFromActor(input.createdBy),
|
|
930
|
+
createdAt: input.createdAt,
|
|
931
|
+
idempotencyKey: input.idempotencyKey,
|
|
932
|
+
sequence: input.sequence,
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
/** Returns a deep copy of a workflow signal. */
|
|
937
|
+
export function workflowSignalFromSignal(input: WorkflowSignal): WorkflowSignal {
|
|
938
|
+
return workflowSignal(workflowSignalInputFromSignal(input) ?? {});
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
/** Creates a workflow schedule trigger from native input. */
|
|
942
|
+
export function workflowScheduleTrigger(
|
|
943
|
+
input: WorkflowScheduleTriggerInput = {},
|
|
944
|
+
): WorkflowScheduleTrigger {
|
|
945
|
+
return {
|
|
946
|
+
scheduleId: input.scheduleId ?? "",
|
|
947
|
+
scheduledFor: input.scheduledFor,
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
/** Creates a workflow event-trigger invocation from native input. */
|
|
952
|
+
export function workflowEventTriggerInvocation(
|
|
953
|
+
input: WorkflowEventTriggerInvocationInput = {},
|
|
954
|
+
): WorkflowEventTriggerInvocation {
|
|
955
|
+
return {
|
|
956
|
+
triggerId: input.triggerId ?? "",
|
|
957
|
+
event: input.event === undefined ? undefined : workflowEvent(input.event),
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/** Creates a workflow run trigger from native input. */
|
|
962
|
+
export function workflowRunTrigger(
|
|
963
|
+
input: WorkflowRunTriggerInput | WorkflowRunTrigger = {},
|
|
964
|
+
): WorkflowRunTrigger {
|
|
965
|
+
if ("kind" in input && input.kind !== undefined) {
|
|
966
|
+
return workflowRunTriggerFromTrigger({ kind: input.kind });
|
|
967
|
+
}
|
|
968
|
+
const triggerInput = input as WorkflowRunTriggerInput;
|
|
969
|
+
const selected = [
|
|
970
|
+
triggerInput.manual === true ? "manual" : undefined,
|
|
971
|
+
triggerInput.schedule === undefined ? undefined : "schedule",
|
|
972
|
+
triggerInput.event === undefined ? undefined : "event",
|
|
973
|
+
].filter((value): value is string => value !== undefined);
|
|
974
|
+
if (selected.length === 0) {
|
|
975
|
+
return { kind: { case: undefined } };
|
|
976
|
+
}
|
|
977
|
+
if (selected.length > 1) {
|
|
978
|
+
throw new Error("workflow run trigger must set exactly one trigger kind");
|
|
979
|
+
}
|
|
980
|
+
switch (selected[0]) {
|
|
981
|
+
case "manual":
|
|
982
|
+
return { kind: { case: "manual", value: {} } };
|
|
983
|
+
case "schedule":
|
|
984
|
+
return { kind: { case: "schedule", value: workflowScheduleTrigger(triggerInput.schedule!) } };
|
|
985
|
+
default:
|
|
986
|
+
return { kind: { case: "event", value: workflowEventTriggerInvocation(triggerInput.event!) } };
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/** Returns native input copied from a workflow run trigger. */
|
|
991
|
+
export function workflowRunTriggerInputFromTrigger(
|
|
992
|
+
input?: WorkflowRunTrigger,
|
|
993
|
+
): WorkflowRunTriggerInput | undefined {
|
|
994
|
+
if (input === undefined) {
|
|
995
|
+
return undefined;
|
|
996
|
+
}
|
|
997
|
+
switch (input.kind.case) {
|
|
998
|
+
case "manual":
|
|
999
|
+
return { manual: true };
|
|
1000
|
+
case "schedule":
|
|
1001
|
+
return { schedule: { ...input.kind.value } };
|
|
1002
|
+
case "event":
|
|
1003
|
+
return {
|
|
1004
|
+
event: {
|
|
1005
|
+
triggerId: input.kind.value.triggerId,
|
|
1006
|
+
event: workflowEventInputFromEvent(input.kind.value.event),
|
|
1007
|
+
},
|
|
1008
|
+
};
|
|
1009
|
+
default:
|
|
1010
|
+
return {};
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/** Returns a deep copy of a workflow run trigger. */
|
|
1015
|
+
export function workflowRunTriggerFromTrigger(input: WorkflowRunTrigger): WorkflowRunTrigger {
|
|
1016
|
+
return workflowRunTrigger(workflowRunTriggerInputFromTrigger(input) ?? {});
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
/** Creates a workflow-provider run from native input. */
|
|
1020
|
+
export function boundWorkflowRun(input: BoundWorkflowRunInput = {}): BoundWorkflowRun {
|
|
1021
|
+
return {
|
|
1022
|
+
id: input.id ?? "",
|
|
1023
|
+
status: input.status ?? WorkflowRunStatus.UNSPECIFIED,
|
|
1024
|
+
target: input.target === undefined ? undefined : boundWorkflowTarget(input.target),
|
|
1025
|
+
trigger: input.trigger === undefined ? undefined : workflowRunTrigger(input.trigger),
|
|
1026
|
+
createdAt: input.createdAt,
|
|
1027
|
+
startedAt: input.startedAt,
|
|
1028
|
+
completedAt: input.completedAt,
|
|
1029
|
+
statusMessage: input.statusMessage ?? "",
|
|
1030
|
+
resultBody: input.resultBody ?? "",
|
|
1031
|
+
createdBy: input.createdBy === undefined ? undefined : workflowActor(input.createdBy),
|
|
1032
|
+
executionRef: input.executionRef ?? "",
|
|
1033
|
+
workflowKey: input.workflowKey ?? "",
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
/** Returns native input copied from a workflow-provider run. */
|
|
1038
|
+
export function boundWorkflowRunInputFromRun(input?: BoundWorkflowRun): BoundWorkflowRunInput | undefined {
|
|
1039
|
+
if (input === undefined) {
|
|
1040
|
+
return undefined;
|
|
1041
|
+
}
|
|
1042
|
+
return {
|
|
1043
|
+
...input,
|
|
1044
|
+
target: boundWorkflowTargetInputFromTarget(input.target) === undefined
|
|
1045
|
+
? undefined
|
|
1046
|
+
: boundWorkflowTarget(input.target!),
|
|
1047
|
+
trigger: workflowRunTriggerInputFromTrigger(input.trigger) === undefined
|
|
1048
|
+
? undefined
|
|
1049
|
+
: workflowRunTrigger(input.trigger!),
|
|
1050
|
+
createdBy: workflowActorInputFromActor(input.createdBy),
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
/** Returns a deep copy of a workflow-provider run. */
|
|
1055
|
+
export function boundWorkflowRunFromRun(input: BoundWorkflowRun): BoundWorkflowRun {
|
|
1056
|
+
return boundWorkflowRun(boundWorkflowRunInputFromRun(input) ?? {});
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
/** Creates a workflow-provider schedule from native input. */
|
|
1060
|
+
export function boundWorkflowSchedule(
|
|
1061
|
+
input: BoundWorkflowScheduleInput = {},
|
|
1062
|
+
): BoundWorkflowSchedule {
|
|
1063
|
+
return {
|
|
1064
|
+
id: input.id ?? "",
|
|
1065
|
+
cron: input.cron ?? "",
|
|
1066
|
+
timezone: input.timezone ?? "",
|
|
1067
|
+
target: input.target === undefined ? undefined : boundWorkflowTarget(input.target),
|
|
1068
|
+
paused: input.paused ?? false,
|
|
1069
|
+
createdAt: input.createdAt,
|
|
1070
|
+
updatedAt: input.updatedAt,
|
|
1071
|
+
nextRunAt: input.nextRunAt,
|
|
1072
|
+
createdBy: input.createdBy === undefined ? undefined : workflowActor(input.createdBy),
|
|
1073
|
+
executionRef: input.executionRef ?? "",
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/** Returns native input copied from a workflow-provider schedule. */
|
|
1078
|
+
export function boundWorkflowScheduleInputFromSchedule(
|
|
1079
|
+
input?: BoundWorkflowSchedule,
|
|
1080
|
+
): BoundWorkflowScheduleInput | undefined {
|
|
1081
|
+
if (input === undefined) {
|
|
1082
|
+
return undefined;
|
|
1083
|
+
}
|
|
1084
|
+
return {
|
|
1085
|
+
...input,
|
|
1086
|
+
target: input.target === undefined ? undefined : boundWorkflowTarget(input.target),
|
|
1087
|
+
createdBy: workflowActorInputFromActor(input.createdBy),
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
/** Returns a deep copy of a workflow-provider schedule. */
|
|
1092
|
+
export function boundWorkflowScheduleFromSchedule(
|
|
1093
|
+
input: BoundWorkflowSchedule,
|
|
1094
|
+
): BoundWorkflowSchedule {
|
|
1095
|
+
return boundWorkflowSchedule(boundWorkflowScheduleInputFromSchedule(input) ?? {});
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
/** Creates a workflow-provider event trigger from native input. */
|
|
1099
|
+
export function boundWorkflowEventTrigger(
|
|
1100
|
+
input: BoundWorkflowEventTriggerInput = {},
|
|
1101
|
+
): BoundWorkflowEventTrigger {
|
|
1102
|
+
return {
|
|
1103
|
+
id: input.id ?? "",
|
|
1104
|
+
match: input.match === undefined ? undefined : workflowEventMatch(input.match),
|
|
1105
|
+
target: input.target === undefined ? undefined : boundWorkflowTarget(input.target),
|
|
1106
|
+
paused: input.paused ?? false,
|
|
1107
|
+
createdAt: input.createdAt,
|
|
1108
|
+
updatedAt: input.updatedAt,
|
|
1109
|
+
createdBy: input.createdBy === undefined ? undefined : workflowActor(input.createdBy),
|
|
1110
|
+
executionRef: input.executionRef ?? "",
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
/** Returns native input copied from a workflow-provider event trigger. */
|
|
1115
|
+
export function boundWorkflowEventTriggerInputFromTrigger(
|
|
1116
|
+
input?: BoundWorkflowEventTrigger,
|
|
1117
|
+
): BoundWorkflowEventTriggerInput | undefined {
|
|
1118
|
+
if (input === undefined) {
|
|
1119
|
+
return undefined;
|
|
1120
|
+
}
|
|
1121
|
+
return {
|
|
1122
|
+
...input,
|
|
1123
|
+
match: workflowEventMatchInputFromMatch(input.match),
|
|
1124
|
+
target: input.target === undefined ? undefined : boundWorkflowTarget(input.target),
|
|
1125
|
+
createdBy: workflowActorInputFromActor(input.createdBy),
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
/** Returns a deep copy of a workflow-provider event trigger. */
|
|
1130
|
+
export function boundWorkflowEventTriggerFromTrigger(
|
|
1131
|
+
input: BoundWorkflowEventTrigger,
|
|
1132
|
+
): BoundWorkflowEventTrigger {
|
|
1133
|
+
return boundWorkflowEventTrigger(boundWorkflowEventTriggerInputFromTrigger(input) ?? {});
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
/** Creates a workflow execution reference from native input. */
|
|
1137
|
+
export function workflowExecutionReference(
|
|
1138
|
+
input: WorkflowExecutionReferenceInput = {},
|
|
1139
|
+
): WorkflowExecutionReference {
|
|
1140
|
+
return {
|
|
1141
|
+
id: input.id ?? "",
|
|
1142
|
+
providerName: input.providerName ?? "",
|
|
1143
|
+
target: input.target === undefined ? undefined : boundWorkflowTarget(input.target),
|
|
1144
|
+
subjectId: input.subjectId ?? "",
|
|
1145
|
+
credentialSubjectId: input.credentialSubjectId ?? "",
|
|
1146
|
+
permissions: input.permissions?.map((permission) => workflowAccessPermission(permission)) ?? [],
|
|
1147
|
+
createdAt: input.createdAt,
|
|
1148
|
+
revokedAt: input.revokedAt,
|
|
1149
|
+
subjectKind: input.subjectKind ?? "",
|
|
1150
|
+
displayName: input.displayName ?? "",
|
|
1151
|
+
authSource: input.authSource ?? "",
|
|
1152
|
+
callerPluginName: input.callerPluginName ?? "",
|
|
1153
|
+
runAs: input.runAs === undefined ? undefined : workflowRunAsSubject(input.runAs),
|
|
1154
|
+
sourceDefinitionId: input.sourceDefinitionId ?? "",
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
/** Returns native input copied from a workflow execution reference. */
|
|
1159
|
+
export function workflowExecutionReferenceInputFromReference(
|
|
1160
|
+
input?: WorkflowExecutionReference,
|
|
1161
|
+
): WorkflowExecutionReferenceInput | undefined {
|
|
1162
|
+
if (input === undefined) {
|
|
1163
|
+
return undefined;
|
|
1164
|
+
}
|
|
1165
|
+
return {
|
|
1166
|
+
...input,
|
|
1167
|
+
target: input.target === undefined ? undefined : boundWorkflowTarget(input.target),
|
|
1168
|
+
permissions: input.permissions?.map((permission) => workflowAccessPermissionInputFromPermission(permission)) ?? [],
|
|
1169
|
+
runAs: workflowRunAsSubjectInputFromSubject(input.runAs),
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
/** Returns a deep copy of a workflow execution reference. */
|
|
1174
|
+
export function workflowExecutionReferenceFromReference(
|
|
1175
|
+
input: WorkflowExecutionReference,
|
|
1176
|
+
): WorkflowExecutionReference {
|
|
1177
|
+
return workflowExecutionReference(workflowExecutionReferenceInputFromReference(input) ?? {});
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
/** Handlers and runtime metadata for a workflow provider. */
|
|
1181
|
+
export interface WorkflowProviderOptions extends ProviderBaseOptions {
|
|
1182
|
+
startRun: (
|
|
1183
|
+
request: StartWorkflowProviderRunRequest,
|
|
1184
|
+
) => MaybePromise<BoundWorkflowRun>;
|
|
1185
|
+
getRun: (
|
|
1186
|
+
request: GetWorkflowProviderRunRequest,
|
|
1187
|
+
) => MaybePromise<BoundWorkflowRun>;
|
|
1188
|
+
listRuns: (
|
|
1189
|
+
request: ListWorkflowProviderRunsRequest,
|
|
1190
|
+
) => MaybePromise<readonly BoundWorkflowRun[]>;
|
|
1191
|
+
cancelRun: (
|
|
1192
|
+
request: CancelWorkflowProviderRunRequest,
|
|
1193
|
+
) => MaybePromise<BoundWorkflowRun>;
|
|
1194
|
+
signalRun: (
|
|
1195
|
+
request: SignalWorkflowProviderRunRequest,
|
|
1196
|
+
) => MaybePromise<SignalWorkflowRunResponse>;
|
|
1197
|
+
signalOrStartRun: (
|
|
1198
|
+
request: SignalOrStartWorkflowProviderRunRequest,
|
|
1199
|
+
) => MaybePromise<SignalWorkflowRunResponse>;
|
|
1200
|
+
upsertSchedule: (
|
|
1201
|
+
request: UpsertWorkflowProviderScheduleRequest,
|
|
1202
|
+
) => MaybePromise<BoundWorkflowSchedule>;
|
|
1203
|
+
getSchedule: (
|
|
1204
|
+
request: GetWorkflowProviderScheduleRequest,
|
|
1205
|
+
) => MaybePromise<BoundWorkflowSchedule>;
|
|
1206
|
+
listSchedules: (
|
|
1207
|
+
request: ListWorkflowProviderSchedulesRequest,
|
|
1208
|
+
) => MaybePromise<readonly BoundWorkflowSchedule[]>;
|
|
1209
|
+
deleteSchedule: (
|
|
1210
|
+
request: DeleteWorkflowProviderScheduleRequest,
|
|
1211
|
+
) => MaybePromise<void>;
|
|
1212
|
+
pauseSchedule: (
|
|
1213
|
+
request: PauseWorkflowProviderScheduleRequest,
|
|
1214
|
+
) => MaybePromise<BoundWorkflowSchedule>;
|
|
1215
|
+
resumeSchedule: (
|
|
1216
|
+
request: ResumeWorkflowProviderScheduleRequest,
|
|
1217
|
+
) => MaybePromise<BoundWorkflowSchedule>;
|
|
1218
|
+
upsertEventTrigger: (
|
|
1219
|
+
request: UpsertWorkflowProviderEventTriggerRequest,
|
|
1220
|
+
) => MaybePromise<BoundWorkflowEventTrigger>;
|
|
1221
|
+
getEventTrigger: (
|
|
1222
|
+
request: GetWorkflowProviderEventTriggerRequest,
|
|
1223
|
+
) => MaybePromise<BoundWorkflowEventTrigger>;
|
|
1224
|
+
listEventTriggers: (
|
|
1225
|
+
request: ListWorkflowProviderEventTriggersRequest,
|
|
1226
|
+
) => MaybePromise<readonly BoundWorkflowEventTrigger[]>;
|
|
1227
|
+
deleteEventTrigger: (
|
|
1228
|
+
request: DeleteWorkflowProviderEventTriggerRequest,
|
|
1229
|
+
) => MaybePromise<void>;
|
|
1230
|
+
pauseEventTrigger: (
|
|
1231
|
+
request: PauseWorkflowProviderEventTriggerRequest,
|
|
1232
|
+
) => MaybePromise<BoundWorkflowEventTrigger>;
|
|
1233
|
+
resumeEventTrigger: (
|
|
1234
|
+
request: ResumeWorkflowProviderEventTriggerRequest,
|
|
1235
|
+
) => MaybePromise<BoundWorkflowEventTrigger>;
|
|
1236
|
+
/** Store or update an execution reference for a workflow target. */
|
|
1237
|
+
putExecutionReference?: (
|
|
1238
|
+
request: PutWorkflowExecutionReferenceRequest,
|
|
1239
|
+
) => MaybePromise<WorkflowExecutionReference>;
|
|
1240
|
+
/** Load one execution reference by provider-owned lookup fields. */
|
|
1241
|
+
getExecutionReference?: (
|
|
1242
|
+
request: GetWorkflowExecutionReferenceRequest,
|
|
1243
|
+
) => MaybePromise<WorkflowExecutionReference>;
|
|
1244
|
+
/** List execution references for the requested scope. */
|
|
1245
|
+
listExecutionReferences?: (
|
|
1246
|
+
request: ListWorkflowExecutionReferencesRequest,
|
|
1247
|
+
) => MaybePromise<readonly WorkflowExecutionReference[]>;
|
|
1248
|
+
publishEvent: (
|
|
1249
|
+
request: PublishWorkflowProviderEventRequest,
|
|
1250
|
+
) => MaybePromise<void>;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
/** Runtime provider implementation for the Gestalt workflow host contract. */
|
|
1254
|
+
export class WorkflowProvider extends ProviderBase {
|
|
1255
|
+
readonly kind = "workflow" as const;
|
|
1256
|
+
|
|
1257
|
+
private readonly startRunHandler: WorkflowProviderOptions["startRun"];
|
|
1258
|
+
private readonly getRunHandler: WorkflowProviderOptions["getRun"];
|
|
1259
|
+
private readonly listRunsHandler: WorkflowProviderOptions["listRuns"];
|
|
1260
|
+
private readonly cancelRunHandler: WorkflowProviderOptions["cancelRun"];
|
|
1261
|
+
private readonly signalRunHandler: WorkflowProviderOptions["signalRun"];
|
|
1262
|
+
private readonly signalOrStartRunHandler: WorkflowProviderOptions["signalOrStartRun"];
|
|
1263
|
+
private readonly upsertScheduleHandler: WorkflowProviderOptions["upsertSchedule"];
|
|
1264
|
+
private readonly getScheduleHandler: WorkflowProviderOptions["getSchedule"];
|
|
1265
|
+
private readonly listSchedulesHandler: WorkflowProviderOptions["listSchedules"];
|
|
1266
|
+
private readonly deleteScheduleHandler: WorkflowProviderOptions["deleteSchedule"];
|
|
1267
|
+
private readonly pauseScheduleHandler: WorkflowProviderOptions["pauseSchedule"];
|
|
1268
|
+
private readonly resumeScheduleHandler: WorkflowProviderOptions["resumeSchedule"];
|
|
1269
|
+
private readonly upsertEventTriggerHandler: WorkflowProviderOptions["upsertEventTrigger"];
|
|
1270
|
+
private readonly getEventTriggerHandler: WorkflowProviderOptions["getEventTrigger"];
|
|
1271
|
+
private readonly listEventTriggersHandler: WorkflowProviderOptions["listEventTriggers"];
|
|
1272
|
+
private readonly deleteEventTriggerHandler: WorkflowProviderOptions["deleteEventTrigger"];
|
|
1273
|
+
private readonly pauseEventTriggerHandler: WorkflowProviderOptions["pauseEventTrigger"];
|
|
1274
|
+
private readonly resumeEventTriggerHandler: WorkflowProviderOptions["resumeEventTrigger"];
|
|
1275
|
+
private readonly putExecutionReferenceHandler: WorkflowProviderOptions["putExecutionReference"];
|
|
1276
|
+
private readonly getExecutionReferenceHandler: WorkflowProviderOptions["getExecutionReference"];
|
|
1277
|
+
private readonly listExecutionReferencesHandler: WorkflowProviderOptions["listExecutionReferences"];
|
|
1278
|
+
private readonly publishEventHandler: WorkflowProviderOptions["publishEvent"];
|
|
1279
|
+
|
|
1280
|
+
constructor(options: WorkflowProviderOptions) {
|
|
1281
|
+
super(options);
|
|
1282
|
+
this.startRunHandler = options.startRun;
|
|
1283
|
+
this.getRunHandler = options.getRun;
|
|
1284
|
+
this.listRunsHandler = options.listRuns;
|
|
1285
|
+
this.cancelRunHandler = options.cancelRun;
|
|
1286
|
+
this.signalRunHandler = options.signalRun;
|
|
1287
|
+
this.signalOrStartRunHandler = options.signalOrStartRun;
|
|
1288
|
+
this.upsertScheduleHandler = options.upsertSchedule;
|
|
1289
|
+
this.getScheduleHandler = options.getSchedule;
|
|
1290
|
+
this.listSchedulesHandler = options.listSchedules;
|
|
1291
|
+
this.deleteScheduleHandler = options.deleteSchedule;
|
|
1292
|
+
this.pauseScheduleHandler = options.pauseSchedule;
|
|
1293
|
+
this.resumeScheduleHandler = options.resumeSchedule;
|
|
1294
|
+
this.upsertEventTriggerHandler = options.upsertEventTrigger;
|
|
1295
|
+
this.getEventTriggerHandler = options.getEventTrigger;
|
|
1296
|
+
this.listEventTriggersHandler = options.listEventTriggers;
|
|
1297
|
+
this.deleteEventTriggerHandler = options.deleteEventTrigger;
|
|
1298
|
+
this.pauseEventTriggerHandler = options.pauseEventTrigger;
|
|
1299
|
+
this.resumeEventTriggerHandler = options.resumeEventTrigger;
|
|
1300
|
+
this.putExecutionReferenceHandler = options.putExecutionReference;
|
|
1301
|
+
this.getExecutionReferenceHandler = options.getExecutionReference;
|
|
1302
|
+
this.listExecutionReferencesHandler = options.listExecutionReferences;
|
|
1303
|
+
this.publishEventHandler = options.publishEvent;
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
async startRun(request: StartWorkflowProviderRunRequest): Promise<BoundWorkflowRun> {
|
|
1307
|
+
return await this.startRunHandler(request);
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
async getRun(request: GetWorkflowProviderRunRequest): Promise<BoundWorkflowRun> {
|
|
1311
|
+
return await this.getRunHandler(request);
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
async listRuns(request: ListWorkflowProviderRunsRequest): Promise<readonly BoundWorkflowRun[]> {
|
|
1315
|
+
return await this.listRunsHandler(request);
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
async cancelRun(request: CancelWorkflowProviderRunRequest): Promise<BoundWorkflowRun> {
|
|
1319
|
+
return await this.cancelRunHandler(request);
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
async signalRun(request: SignalWorkflowProviderRunRequest): Promise<SignalWorkflowRunResponse> {
|
|
1323
|
+
return await this.signalRunHandler(request);
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
async signalOrStartRun(
|
|
1327
|
+
request: SignalOrStartWorkflowProviderRunRequest,
|
|
1328
|
+
): Promise<SignalWorkflowRunResponse> {
|
|
1329
|
+
return await this.signalOrStartRunHandler(request);
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
async upsertSchedule(request: UpsertWorkflowProviderScheduleRequest): Promise<BoundWorkflowSchedule> {
|
|
1333
|
+
return await this.upsertScheduleHandler(request);
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
async getSchedule(request: GetWorkflowProviderScheduleRequest): Promise<BoundWorkflowSchedule> {
|
|
1337
|
+
return await this.getScheduleHandler(request);
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
async listSchedules(
|
|
1341
|
+
request: ListWorkflowProviderSchedulesRequest,
|
|
1342
|
+
): Promise<readonly BoundWorkflowSchedule[]> {
|
|
1343
|
+
return await this.listSchedulesHandler(request);
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
async deleteSchedule(request: DeleteWorkflowProviderScheduleRequest): Promise<void> {
|
|
1347
|
+
await this.deleteScheduleHandler(request);
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
async pauseSchedule(request: PauseWorkflowProviderScheduleRequest): Promise<BoundWorkflowSchedule> {
|
|
1351
|
+
return await this.pauseScheduleHandler(request);
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
async resumeSchedule(request: ResumeWorkflowProviderScheduleRequest): Promise<BoundWorkflowSchedule> {
|
|
1355
|
+
return await this.resumeScheduleHandler(request);
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
async upsertEventTrigger(
|
|
1359
|
+
request: UpsertWorkflowProviderEventTriggerRequest,
|
|
1360
|
+
): Promise<BoundWorkflowEventTrigger> {
|
|
1361
|
+
return await this.upsertEventTriggerHandler(request);
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
async getEventTrigger(
|
|
1365
|
+
request: GetWorkflowProviderEventTriggerRequest,
|
|
1366
|
+
): Promise<BoundWorkflowEventTrigger> {
|
|
1367
|
+
return await this.getEventTriggerHandler(request);
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
async listEventTriggers(
|
|
1371
|
+
request: ListWorkflowProviderEventTriggersRequest,
|
|
1372
|
+
): Promise<readonly BoundWorkflowEventTrigger[]> {
|
|
1373
|
+
return await this.listEventTriggersHandler(request);
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
async deleteEventTrigger(request: DeleteWorkflowProviderEventTriggerRequest): Promise<void> {
|
|
1377
|
+
await this.deleteEventTriggerHandler(request);
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
async pauseEventTrigger(
|
|
1381
|
+
request: PauseWorkflowProviderEventTriggerRequest,
|
|
1382
|
+
): Promise<BoundWorkflowEventTrigger> {
|
|
1383
|
+
return await this.pauseEventTriggerHandler(request);
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
async resumeEventTrigger(
|
|
1387
|
+
request: ResumeWorkflowProviderEventTriggerRequest,
|
|
1388
|
+
): Promise<BoundWorkflowEventTrigger> {
|
|
1389
|
+
return await this.resumeEventTriggerHandler(request);
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
/** Store or update an execution reference for a workflow target. */
|
|
1393
|
+
async putExecutionReference(
|
|
1394
|
+
request: PutWorkflowExecutionReferenceRequest,
|
|
1395
|
+
): Promise<WorkflowExecutionReference> {
|
|
1396
|
+
return await requireWorkflowProviderHandler(
|
|
1397
|
+
"put execution reference",
|
|
1398
|
+
this.putExecutionReferenceHandler,
|
|
1399
|
+
request,
|
|
1400
|
+
);
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
/** Load one execution reference by provider-owned lookup fields. */
|
|
1404
|
+
async getExecutionReference(
|
|
1405
|
+
request: GetWorkflowExecutionReferenceRequest,
|
|
1406
|
+
): Promise<WorkflowExecutionReference> {
|
|
1407
|
+
return await requireWorkflowProviderHandler(
|
|
1408
|
+
"get execution reference",
|
|
1409
|
+
this.getExecutionReferenceHandler,
|
|
1410
|
+
request,
|
|
1411
|
+
);
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
/** List execution references for the requested scope. */
|
|
1415
|
+
async listExecutionReferences(
|
|
1416
|
+
request: ListWorkflowExecutionReferencesRequest,
|
|
1417
|
+
): Promise<readonly WorkflowExecutionReference[]> {
|
|
1418
|
+
return await requireWorkflowProviderHandler(
|
|
1419
|
+
"list execution references",
|
|
1420
|
+
this.listExecutionReferencesHandler,
|
|
1421
|
+
request,
|
|
1422
|
+
);
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
async publishEvent(request: PublishWorkflowProviderEventRequest): Promise<void> {
|
|
1426
|
+
await this.publishEventHandler(request);
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
/** Creates a workflow provider for export from a provider module. */
|
|
1431
|
+
export function defineWorkflowProvider(
|
|
1432
|
+
options: WorkflowProviderOptions,
|
|
1433
|
+
): WorkflowProvider {
|
|
1434
|
+
return new WorkflowProvider(options);
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
/** Runtime type guard for workflow providers loaded from user modules. */
|
|
1438
|
+
export function isWorkflowProvider(value: unknown): value is WorkflowProvider {
|
|
1439
|
+
return (
|
|
1440
|
+
value instanceof WorkflowProvider ||
|
|
1441
|
+
(typeof value === "object" &&
|
|
1442
|
+
value !== null &&
|
|
1443
|
+
"kind" in value &&
|
|
1444
|
+
(value as { kind?: unknown }).kind === "workflow" &&
|
|
1445
|
+
"startRun" in value &&
|
|
1446
|
+
"getRun" in value &&
|
|
1447
|
+
"listRuns" in value &&
|
|
1448
|
+
"cancelRun" in value &&
|
|
1449
|
+
"signalRun" in value &&
|
|
1450
|
+
"signalOrStartRun" in value &&
|
|
1451
|
+
"upsertSchedule" in value &&
|
|
1452
|
+
"getSchedule" in value &&
|
|
1453
|
+
"listSchedules" in value &&
|
|
1454
|
+
"deleteSchedule" in value &&
|
|
1455
|
+
"pauseSchedule" in value &&
|
|
1456
|
+
"resumeSchedule" in value &&
|
|
1457
|
+
"upsertEventTrigger" in value &&
|
|
1458
|
+
"getEventTrigger" in value &&
|
|
1459
|
+
"listEventTriggers" in value &&
|
|
1460
|
+
"deleteEventTrigger" in value &&
|
|
1461
|
+
"pauseEventTrigger" in value &&
|
|
1462
|
+
"resumeEventTrigger" in value &&
|
|
1463
|
+
"publishEvent" in value)
|
|
1464
|
+
);
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
/** Client for invoking operations from workflow provider code. */
|
|
1468
|
+
export class WorkflowHost {
|
|
1469
|
+
private readonly client: Client<typeof WorkflowHostService>;
|
|
1470
|
+
|
|
1471
|
+
constructor() {
|
|
1472
|
+
const target = process.env[ENV_WORKFLOW_HOST_SOCKET];
|
|
1473
|
+
if (!target) {
|
|
1474
|
+
throw new Error(`workflow host: ${ENV_WORKFLOW_HOST_SOCKET} is not set`);
|
|
1475
|
+
}
|
|
1476
|
+
const relayToken = process.env[ENV_WORKFLOW_HOST_SOCKET_TOKEN]?.trim() ?? "";
|
|
1477
|
+
const transport = createGrpcTransport({
|
|
1478
|
+
...workflowHostTransportOptions(target),
|
|
1479
|
+
interceptors: relayToken
|
|
1480
|
+
? [workflowHostRelayTokenInterceptor(relayToken)]
|
|
1481
|
+
: [],
|
|
1482
|
+
});
|
|
1483
|
+
this.client = createClient(WorkflowHostService, transport);
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
/** Invokes an operation through the workflow host service. */
|
|
1487
|
+
async invokeOperation(
|
|
1488
|
+
input: InvokeWorkflowOperationInput,
|
|
1489
|
+
): Promise<InvokeWorkflowOperationResponse> {
|
|
1490
|
+
const response = await this.client.invokeOperation(invokeWorkflowOperationRequestToProto(input));
|
|
1491
|
+
return { status: response.status, body: response.body };
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
/** Builds the Connect service implementation used by the TypeScript runtime. */
|
|
1496
|
+
export function createWorkflowProviderService(
|
|
1497
|
+
provider: WorkflowProvider,
|
|
1498
|
+
): WorkflowProviderServiceImpl {
|
|
1499
|
+
return {
|
|
1500
|
+
async startRun(request) {
|
|
1501
|
+
return create(
|
|
1502
|
+
BoundWorkflowRunSchema,
|
|
1503
|
+
boundWorkflowRunToProto(
|
|
1504
|
+
await invokeWorkflowProvider("start run", () =>
|
|
1505
|
+
provider.startRun(startWorkflowProviderRunRequestFromProto(request)),
|
|
1506
|
+
),
|
|
1507
|
+
),
|
|
1508
|
+
);
|
|
1509
|
+
},
|
|
1510
|
+
async getRun(request) {
|
|
1511
|
+
return create(
|
|
1512
|
+
BoundWorkflowRunSchema,
|
|
1513
|
+
boundWorkflowRunToProto(
|
|
1514
|
+
await invokeWorkflowProvider("get run", () =>
|
|
1515
|
+
provider.getRun(getWorkflowProviderRunRequestFromProto(request)),
|
|
1516
|
+
),
|
|
1517
|
+
),
|
|
1518
|
+
);
|
|
1519
|
+
},
|
|
1520
|
+
async listRuns(request) {
|
|
1521
|
+
return create(ListWorkflowProviderRunsResponseSchema, {
|
|
1522
|
+
runs: (
|
|
1523
|
+
await invokeWorkflowProvider("list runs", () =>
|
|
1524
|
+
provider.listRuns(listWorkflowProviderRunsRequestFromProto(request)),
|
|
1525
|
+
)
|
|
1526
|
+
).map(boundWorkflowRunToProto),
|
|
1527
|
+
});
|
|
1528
|
+
},
|
|
1529
|
+
async cancelRun(request) {
|
|
1530
|
+
return create(
|
|
1531
|
+
BoundWorkflowRunSchema,
|
|
1532
|
+
boundWorkflowRunToProto(
|
|
1533
|
+
await invokeWorkflowProvider("cancel run", () =>
|
|
1534
|
+
provider.cancelRun(cancelWorkflowProviderRunRequestFromProto(request)),
|
|
1535
|
+
),
|
|
1536
|
+
),
|
|
1537
|
+
);
|
|
1538
|
+
},
|
|
1539
|
+
async signalRun(request) {
|
|
1540
|
+
return create(
|
|
1541
|
+
SignalWorkflowRunResponseSchema,
|
|
1542
|
+
signalWorkflowRunResponseToProto(
|
|
1543
|
+
await invokeWorkflowProvider("signal run", () =>
|
|
1544
|
+
provider.signalRun(signalWorkflowProviderRunRequestFromProto(request)),
|
|
1545
|
+
),
|
|
1546
|
+
),
|
|
1547
|
+
);
|
|
1548
|
+
},
|
|
1549
|
+
async signalOrStartRun(request) {
|
|
1550
|
+
return create(
|
|
1551
|
+
SignalWorkflowRunResponseSchema,
|
|
1552
|
+
signalWorkflowRunResponseToProto(
|
|
1553
|
+
await invokeWorkflowProvider("signal or start run", () =>
|
|
1554
|
+
provider.signalOrStartRun(signalOrStartWorkflowProviderRunRequestFromProto(request)),
|
|
1555
|
+
),
|
|
1556
|
+
),
|
|
1557
|
+
);
|
|
1558
|
+
},
|
|
1559
|
+
async upsertSchedule(request) {
|
|
1560
|
+
return create(
|
|
1561
|
+
BoundWorkflowScheduleSchema,
|
|
1562
|
+
boundWorkflowScheduleToProto(
|
|
1563
|
+
await invokeWorkflowProvider("upsert schedule", () =>
|
|
1564
|
+
provider.upsertSchedule(upsertWorkflowProviderScheduleRequestFromProto(request)),
|
|
1565
|
+
),
|
|
1566
|
+
),
|
|
1567
|
+
);
|
|
1568
|
+
},
|
|
1569
|
+
async getSchedule(request) {
|
|
1570
|
+
return create(
|
|
1571
|
+
BoundWorkflowScheduleSchema,
|
|
1572
|
+
boundWorkflowScheduleToProto(
|
|
1573
|
+
await invokeWorkflowProvider("get schedule", () =>
|
|
1574
|
+
provider.getSchedule(getWorkflowProviderScheduleRequestFromProto(request)),
|
|
1575
|
+
),
|
|
1576
|
+
),
|
|
1577
|
+
);
|
|
1578
|
+
},
|
|
1579
|
+
async listSchedules(request) {
|
|
1580
|
+
return create(ListWorkflowProviderSchedulesResponseSchema, {
|
|
1581
|
+
schedules: (
|
|
1582
|
+
await invokeWorkflowProvider("list schedules", () =>
|
|
1583
|
+
provider.listSchedules(listWorkflowProviderSchedulesRequestFromProto(request)),
|
|
1584
|
+
)
|
|
1585
|
+
).map(boundWorkflowScheduleToProto),
|
|
1586
|
+
});
|
|
1587
|
+
},
|
|
1588
|
+
async deleteSchedule(request) {
|
|
1589
|
+
await invokeWorkflowProvider("delete schedule", () =>
|
|
1590
|
+
provider.deleteSchedule(deleteWorkflowProviderScheduleRequestFromProto(request)),
|
|
1591
|
+
);
|
|
1592
|
+
return create(EmptySchema, {});
|
|
1593
|
+
},
|
|
1594
|
+
async pauseSchedule(request) {
|
|
1595
|
+
return create(
|
|
410
1596
|
BoundWorkflowScheduleSchema,
|
|
411
|
-
|
|
412
|
-
|
|
1597
|
+
boundWorkflowScheduleToProto(
|
|
1598
|
+
await invokeWorkflowProvider("pause schedule", () =>
|
|
1599
|
+
provider.pauseSchedule(pauseWorkflowProviderScheduleRequestFromProto(request)),
|
|
1600
|
+
),
|
|
413
1601
|
),
|
|
414
1602
|
);
|
|
415
1603
|
},
|
|
416
1604
|
async resumeSchedule(request) {
|
|
417
1605
|
return create(
|
|
418
1606
|
BoundWorkflowScheduleSchema,
|
|
419
|
-
|
|
420
|
-
|
|
1607
|
+
boundWorkflowScheduleToProto(
|
|
1608
|
+
await invokeWorkflowProvider("resume schedule", () =>
|
|
1609
|
+
provider.resumeSchedule(resumeWorkflowProviderScheduleRequestFromProto(request)),
|
|
1610
|
+
),
|
|
421
1611
|
),
|
|
422
1612
|
);
|
|
423
1613
|
},
|
|
424
1614
|
async upsertEventTrigger(request) {
|
|
425
1615
|
return create(
|
|
426
1616
|
BoundWorkflowEventTriggerSchema,
|
|
427
|
-
|
|
428
|
-
|
|
1617
|
+
boundWorkflowEventTriggerToProto(
|
|
1618
|
+
await invokeWorkflowProvider("upsert event trigger", () =>
|
|
1619
|
+
provider.upsertEventTrigger(upsertWorkflowProviderEventTriggerRequestFromProto(request)),
|
|
1620
|
+
),
|
|
429
1621
|
),
|
|
430
1622
|
);
|
|
431
1623
|
},
|
|
432
1624
|
async getEventTrigger(request) {
|
|
433
1625
|
return create(
|
|
434
1626
|
BoundWorkflowEventTriggerSchema,
|
|
435
|
-
|
|
436
|
-
|
|
1627
|
+
boundWorkflowEventTriggerToProto(
|
|
1628
|
+
await invokeWorkflowProvider("get event trigger", () =>
|
|
1629
|
+
provider.getEventTrigger(getWorkflowProviderEventTriggerRequestFromProto(request)),
|
|
1630
|
+
),
|
|
437
1631
|
),
|
|
438
1632
|
);
|
|
439
1633
|
},
|
|
440
1634
|
async listEventTriggers(request) {
|
|
441
1635
|
return create(ListWorkflowProviderEventTriggersResponseSchema, {
|
|
442
|
-
triggers:
|
|
443
|
-
|
|
1636
|
+
triggers: (
|
|
1637
|
+
await invokeWorkflowProvider("list event triggers", () =>
|
|
1638
|
+
provider.listEventTriggers(listWorkflowProviderEventTriggersRequestFromProto(request)),
|
|
1639
|
+
)
|
|
1640
|
+
).map(boundWorkflowEventTriggerToProto),
|
|
1641
|
+
});
|
|
1642
|
+
},
|
|
1643
|
+
async deleteEventTrigger(request) {
|
|
1644
|
+
await invokeWorkflowProvider("delete event trigger", () =>
|
|
1645
|
+
provider.deleteEventTrigger(deleteWorkflowProviderEventTriggerRequestFromProto(request)),
|
|
1646
|
+
);
|
|
1647
|
+
return create(EmptySchema, {});
|
|
1648
|
+
},
|
|
1649
|
+
async pauseEventTrigger(request) {
|
|
1650
|
+
return create(
|
|
1651
|
+
BoundWorkflowEventTriggerSchema,
|
|
1652
|
+
boundWorkflowEventTriggerToProto(
|
|
1653
|
+
await invokeWorkflowProvider("pause event trigger", () =>
|
|
1654
|
+
provider.pauseEventTrigger(pauseWorkflowProviderEventTriggerRequestFromProto(request)),
|
|
1655
|
+
),
|
|
1656
|
+
),
|
|
1657
|
+
);
|
|
1658
|
+
},
|
|
1659
|
+
async resumeEventTrigger(request) {
|
|
1660
|
+
return create(
|
|
1661
|
+
BoundWorkflowEventTriggerSchema,
|
|
1662
|
+
boundWorkflowEventTriggerToProto(
|
|
1663
|
+
await invokeWorkflowProvider("resume event trigger", () =>
|
|
1664
|
+
provider.resumeEventTrigger(resumeWorkflowProviderEventTriggerRequestFromProto(request)),
|
|
1665
|
+
),
|
|
1666
|
+
),
|
|
1667
|
+
);
|
|
1668
|
+
},
|
|
1669
|
+
async putExecutionReference(request) {
|
|
1670
|
+
return create(
|
|
1671
|
+
WorkflowExecutionReferenceSchema,
|
|
1672
|
+
workflowExecutionReferenceToProto(
|
|
1673
|
+
await invokeWorkflowProvider("put execution reference", () =>
|
|
1674
|
+
provider.putExecutionReference(putWorkflowExecutionReferenceRequestFromProto(request)),
|
|
1675
|
+
),
|
|
1676
|
+
),
|
|
1677
|
+
);
|
|
1678
|
+
},
|
|
1679
|
+
async getExecutionReference(request) {
|
|
1680
|
+
return create(
|
|
1681
|
+
WorkflowExecutionReferenceSchema,
|
|
1682
|
+
workflowExecutionReferenceToProto(
|
|
1683
|
+
await invokeWorkflowProvider("get execution reference", () =>
|
|
1684
|
+
provider.getExecutionReference(getWorkflowExecutionReferenceRequestFromProto(request)),
|
|
1685
|
+
),
|
|
444
1686
|
),
|
|
1687
|
+
);
|
|
1688
|
+
},
|
|
1689
|
+
async listExecutionReferences(request) {
|
|
1690
|
+
return create(ListWorkflowExecutionReferencesResponseSchema, {
|
|
1691
|
+
references: (
|
|
1692
|
+
await invokeWorkflowProvider("list execution references", () =>
|
|
1693
|
+
provider.listExecutionReferences(listWorkflowExecutionReferencesRequestFromProto(request)),
|
|
1694
|
+
)
|
|
1695
|
+
).map(workflowExecutionReferenceToProto),
|
|
1696
|
+
});
|
|
1697
|
+
},
|
|
1698
|
+
async publishEvent(request) {
|
|
1699
|
+
await invokeWorkflowProvider("publish event", () =>
|
|
1700
|
+
provider.publishEvent(publishWorkflowProviderEventRequestFromProto(request)),
|
|
1701
|
+
);
|
|
1702
|
+
return create(EmptySchema, {});
|
|
1703
|
+
},
|
|
1704
|
+
};
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
export function workflowActorToProto(input?: WorkflowActor | undefined): ProtoWorkflowActor | undefined {
|
|
1708
|
+
if (input === undefined) {
|
|
1709
|
+
return undefined;
|
|
1710
|
+
}
|
|
1711
|
+
return create(WorkflowActorSchema, {
|
|
1712
|
+
subjectId: input.subjectId ?? "",
|
|
1713
|
+
subjectKind: input.subjectKind ?? "",
|
|
1714
|
+
displayName: input.displayName ?? "",
|
|
1715
|
+
authSource: input.authSource ?? "",
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
export function workflowActorFromProto(input?: ProtoWorkflowActor | undefined): WorkflowActor | undefined {
|
|
1720
|
+
if (input === undefined) {
|
|
1721
|
+
return undefined;
|
|
1722
|
+
}
|
|
1723
|
+
return {
|
|
1724
|
+
subjectId: input.subjectId,
|
|
1725
|
+
subjectKind: input.subjectKind,
|
|
1726
|
+
displayName: input.displayName,
|
|
1727
|
+
authSource: input.authSource,
|
|
1728
|
+
};
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
export function workflowRunAsSubjectToProto(
|
|
1732
|
+
input?: WorkflowRunAsSubject | undefined,
|
|
1733
|
+
): ProtoWorkflowRunAsSubject | undefined {
|
|
1734
|
+
if (input === undefined) {
|
|
1735
|
+
return undefined;
|
|
1736
|
+
}
|
|
1737
|
+
return create(WorkflowRunAsSubjectSchema, {
|
|
1738
|
+
subjectId: input.subjectId ?? "",
|
|
1739
|
+
subjectKind: input.subjectKind ?? "",
|
|
1740
|
+
displayName: input.displayName ?? "",
|
|
1741
|
+
authSource: input.authSource ?? "",
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
export function workflowRunAsSubjectFromProto(
|
|
1746
|
+
input?: ProtoWorkflowRunAsSubject | undefined,
|
|
1747
|
+
): WorkflowRunAsSubject | undefined {
|
|
1748
|
+
if (input === undefined) {
|
|
1749
|
+
return undefined;
|
|
1750
|
+
}
|
|
1751
|
+
return {
|
|
1752
|
+
subjectId: input.subjectId,
|
|
1753
|
+
subjectKind: input.subjectKind,
|
|
1754
|
+
displayName: input.displayName,
|
|
1755
|
+
authSource: input.authSource,
|
|
1756
|
+
};
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
export function workflowAccessPermissionToProto(input: WorkflowAccessPermission) {
|
|
1760
|
+
return create(WorkflowAccessPermissionSchema, {
|
|
1761
|
+
plugin: input.plugin ?? "",
|
|
1762
|
+
operations: [...(input.operations ?? [])],
|
|
1763
|
+
});
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
export function workflowAccessPermissionFromProto(
|
|
1767
|
+
input: ProtoWorkflowAccessPermission,
|
|
1768
|
+
): WorkflowAccessPermission {
|
|
1769
|
+
return {
|
|
1770
|
+
plugin: input.plugin,
|
|
1771
|
+
operations: [...input.operations],
|
|
1772
|
+
};
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
export function workflowEventMatchToProto(
|
|
1776
|
+
input?: WorkflowEventMatch | undefined,
|
|
1777
|
+
): ProtoWorkflowEventMatch | undefined {
|
|
1778
|
+
if (input === undefined) {
|
|
1779
|
+
return undefined;
|
|
1780
|
+
}
|
|
1781
|
+
return create(WorkflowEventMatchSchema, {
|
|
1782
|
+
type: input.type ?? "",
|
|
1783
|
+
source: input.source ?? "",
|
|
1784
|
+
subject: input.subject ?? "",
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
export function workflowEventMatchFromProto(
|
|
1789
|
+
input?: ProtoWorkflowEventMatch | undefined,
|
|
1790
|
+
): WorkflowEventMatch | undefined {
|
|
1791
|
+
if (input === undefined) {
|
|
1792
|
+
return undefined;
|
|
1793
|
+
}
|
|
1794
|
+
return {
|
|
1795
|
+
type: input.type,
|
|
1796
|
+
source: input.source,
|
|
1797
|
+
subject: input.subject,
|
|
1798
|
+
};
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
export function workflowOutputValueSourceToProto(
|
|
1802
|
+
input?: WorkflowOutputValueSource | WorkflowOutputValueSourceInput | undefined,
|
|
1803
|
+
): ProtoWorkflowOutputValueSource | undefined {
|
|
1804
|
+
if (input === undefined) {
|
|
1805
|
+
return undefined;
|
|
1806
|
+
}
|
|
1807
|
+
const source = workflowOutputValueSource(input);
|
|
1808
|
+
switch (source.kind.case) {
|
|
1809
|
+
case "agentOutput":
|
|
1810
|
+
return create(WorkflowOutputValueSourceSchema, {
|
|
1811
|
+
kind: { case: "agentOutput", value: source.kind.value },
|
|
1812
|
+
});
|
|
1813
|
+
case "signalPayload":
|
|
1814
|
+
return create(WorkflowOutputValueSourceSchema, {
|
|
1815
|
+
kind: { case: "signalPayload", value: source.kind.value },
|
|
1816
|
+
});
|
|
1817
|
+
case "signalMetadata":
|
|
1818
|
+
return create(WorkflowOutputValueSourceSchema, {
|
|
1819
|
+
kind: { case: "signalMetadata", value: source.kind.value },
|
|
445
1820
|
});
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
return create(
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
1821
|
+
case "agentSession":
|
|
1822
|
+
return create(WorkflowOutputValueSourceSchema, {
|
|
1823
|
+
kind: { case: "agentSession", value: source.kind.value },
|
|
1824
|
+
});
|
|
1825
|
+
case "literal":
|
|
1826
|
+
return create(WorkflowOutputValueSourceSchema, {
|
|
1827
|
+
kind: { case: "literal", value: valueFromJson(source.kind.value) },
|
|
1828
|
+
});
|
|
1829
|
+
default:
|
|
1830
|
+
return create(WorkflowOutputValueSourceSchema);
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
export function workflowOutputValueSourceFromProto(
|
|
1835
|
+
input?: ProtoWorkflowOutputValueSource | undefined,
|
|
1836
|
+
): WorkflowOutputValueSource | undefined {
|
|
1837
|
+
if (input === undefined) {
|
|
1838
|
+
return undefined;
|
|
1839
|
+
}
|
|
1840
|
+
switch (input.kind.case) {
|
|
1841
|
+
case "agentOutput":
|
|
1842
|
+
return { kind: { case: "agentOutput", value: input.kind.value } };
|
|
1843
|
+
case "signalPayload":
|
|
1844
|
+
return { kind: { case: "signalPayload", value: input.kind.value } };
|
|
1845
|
+
case "signalMetadata":
|
|
1846
|
+
return { kind: { case: "signalMetadata", value: input.kind.value } };
|
|
1847
|
+
case "agentSession":
|
|
1848
|
+
return { kind: { case: "agentSession", value: input.kind.value } };
|
|
1849
|
+
case "literal":
|
|
1850
|
+
return { kind: { case: "literal", value: jsonFromValue(input.kind.value) as JsonInput } };
|
|
1851
|
+
default:
|
|
1852
|
+
return { kind: { case: undefined } };
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
export function workflowOutputBindingToProto(input: WorkflowOutputBinding) {
|
|
1857
|
+
return create(WorkflowOutputBindingSchema, {
|
|
1858
|
+
inputField: input.inputField ?? "",
|
|
1859
|
+
value: workflowOutputValueSourceToProto(input.value),
|
|
1860
|
+
});
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
export function workflowOutputBindingFromProto(
|
|
1864
|
+
input: ProtoWorkflowOutputBinding,
|
|
1865
|
+
): WorkflowOutputBinding {
|
|
1866
|
+
return {
|
|
1867
|
+
inputField: input.inputField,
|
|
1868
|
+
value: workflowOutputValueSourceFromProto(input.value),
|
|
1869
|
+
};
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
export function workflowOutputDeliveryToProto(
|
|
1873
|
+
input?: WorkflowOutputDelivery | undefined,
|
|
1874
|
+
): ProtoWorkflowOutputDelivery | undefined {
|
|
1875
|
+
if (input === undefined) {
|
|
1876
|
+
return undefined;
|
|
1877
|
+
}
|
|
1878
|
+
return create(WorkflowOutputDeliverySchema, {
|
|
1879
|
+
target: boundWorkflowPluginTargetToProto(input.target),
|
|
1880
|
+
inputBindings: input.inputBindings?.map(workflowOutputBindingToProto) ?? [],
|
|
1881
|
+
credentialMode: input.credentialMode ?? "",
|
|
1882
|
+
});
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
export function workflowOutputDeliveryFromProto(
|
|
1886
|
+
input?: ProtoWorkflowOutputDelivery | undefined,
|
|
1887
|
+
): WorkflowOutputDelivery | undefined {
|
|
1888
|
+
if (input === undefined) {
|
|
1889
|
+
return undefined;
|
|
1890
|
+
}
|
|
1891
|
+
return {
|
|
1892
|
+
target: boundWorkflowPluginTargetFromProto(input.target),
|
|
1893
|
+
inputBindings: input.inputBindings.map(workflowOutputBindingFromProto),
|
|
1894
|
+
credentialMode: input.credentialMode,
|
|
1895
|
+
};
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
export function boundWorkflowPluginTargetToProto(
|
|
1899
|
+
input?: BoundWorkflowPluginTarget | undefined,
|
|
1900
|
+
): ProtoBoundWorkflowPluginTarget | undefined {
|
|
1901
|
+
if (input === undefined) {
|
|
1902
|
+
return undefined;
|
|
1903
|
+
}
|
|
1904
|
+
return create(BoundWorkflowPluginTargetSchema, {
|
|
1905
|
+
pluginName: input.pluginName ?? "",
|
|
1906
|
+
operation: input.operation ?? "",
|
|
1907
|
+
input: optionalStruct(input.input),
|
|
1908
|
+
connection: input.connection ?? "",
|
|
1909
|
+
instance: input.instance ?? "",
|
|
1910
|
+
credentialMode: input.credentialMode ?? "",
|
|
1911
|
+
});
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
export function boundWorkflowPluginTargetFromProto(
|
|
1915
|
+
input?: ProtoBoundWorkflowPluginTarget | undefined,
|
|
1916
|
+
): BoundWorkflowPluginTarget | undefined {
|
|
1917
|
+
if (input === undefined) {
|
|
1918
|
+
return undefined;
|
|
1919
|
+
}
|
|
1920
|
+
return {
|
|
1921
|
+
pluginName: input.pluginName,
|
|
1922
|
+
operation: input.operation,
|
|
1923
|
+
input: optionalObjectFromStruct(input.input),
|
|
1924
|
+
connection: input.connection,
|
|
1925
|
+
instance: input.instance,
|
|
1926
|
+
credentialMode: input.credentialMode,
|
|
1927
|
+
};
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
export function boundWorkflowAgentTargetToProto(
|
|
1931
|
+
input?: BoundWorkflowAgentTarget | undefined,
|
|
1932
|
+
): ProtoBoundWorkflowAgentTarget | undefined {
|
|
1933
|
+
if (input === undefined) {
|
|
1934
|
+
return undefined;
|
|
1935
|
+
}
|
|
1936
|
+
return create(BoundWorkflowAgentTargetSchema, {
|
|
1937
|
+
providerName: input.providerName ?? "",
|
|
1938
|
+
model: input.model ?? "",
|
|
1939
|
+
prompt: input.prompt ?? "",
|
|
1940
|
+
messages: input.messages?.map(agentMessageToProto) ?? [],
|
|
1941
|
+
toolRefs: input.toolRefs?.map(agentToolRefToProto) ?? [],
|
|
1942
|
+
responseSchema: optionalStruct(input.responseSchema),
|
|
1943
|
+
metadata: optionalStruct(input.metadata),
|
|
1944
|
+
timeoutSeconds: input.timeoutSeconds ?? 0,
|
|
1945
|
+
outputDelivery: workflowOutputDeliveryToProto(input.outputDelivery),
|
|
1946
|
+
modelOptions: optionalStruct(input.modelOptions),
|
|
1947
|
+
sessionReadyDelivery: workflowOutputDeliveryToProto(input.sessionReadyDelivery),
|
|
1948
|
+
});
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
export function boundWorkflowAgentTargetFromProto(
|
|
1952
|
+
input?: ProtoBoundWorkflowAgentTarget | undefined,
|
|
1953
|
+
): BoundWorkflowAgentTarget | undefined {
|
|
1954
|
+
if (input === undefined) {
|
|
1955
|
+
return undefined;
|
|
1956
|
+
}
|
|
1957
|
+
return {
|
|
1958
|
+
providerName: input.providerName,
|
|
1959
|
+
model: input.model,
|
|
1960
|
+
prompt: input.prompt,
|
|
1961
|
+
messages: input.messages.map(agentMessageFromProto),
|
|
1962
|
+
toolRefs: input.toolRefs.map(agentToolRefFromProto),
|
|
1963
|
+
responseSchema: optionalObjectFromStruct(input.responseSchema),
|
|
1964
|
+
metadata: optionalObjectFromStruct(input.metadata),
|
|
1965
|
+
timeoutSeconds: input.timeoutSeconds,
|
|
1966
|
+
outputDelivery: workflowOutputDeliveryFromProto(input.outputDelivery),
|
|
1967
|
+
modelOptions: optionalObjectFromStruct(input.modelOptions),
|
|
1968
|
+
sessionReadyDelivery: workflowOutputDeliveryFromProto(input.sessionReadyDelivery),
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
export function boundWorkflowTargetToProto(
|
|
1973
|
+
input?: BoundWorkflowTarget | BoundWorkflowTargetInput | undefined,
|
|
1974
|
+
): ProtoBoundWorkflowTarget | undefined {
|
|
1975
|
+
if (input === undefined) {
|
|
1976
|
+
return undefined;
|
|
1977
|
+
}
|
|
1978
|
+
const target = boundWorkflowTarget(input);
|
|
1979
|
+
switch (target.kind.case) {
|
|
1980
|
+
case "plugin":
|
|
1981
|
+
return create(BoundWorkflowTargetSchema, {
|
|
1982
|
+
kind: { case: "plugin", value: boundWorkflowPluginTargetToProto(target.kind.value)! },
|
|
1983
|
+
});
|
|
1984
|
+
case "agent":
|
|
1985
|
+
return create(BoundWorkflowTargetSchema, {
|
|
1986
|
+
kind: { case: "agent", value: boundWorkflowAgentTargetToProto(target.kind.value)! },
|
|
1987
|
+
});
|
|
1988
|
+
default:
|
|
1989
|
+
return create(BoundWorkflowTargetSchema);
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
export function boundWorkflowTargetFromProto(
|
|
1994
|
+
input?: ProtoBoundWorkflowTarget | undefined,
|
|
1995
|
+
): BoundWorkflowTarget | undefined {
|
|
1996
|
+
if (input === undefined) {
|
|
1997
|
+
return undefined;
|
|
1998
|
+
}
|
|
1999
|
+
switch (input.kind.case) {
|
|
2000
|
+
case "plugin":
|
|
2001
|
+
return { kind: { case: "plugin", value: boundWorkflowPluginTargetFromProto(input.kind.value)! } };
|
|
2002
|
+
case "agent":
|
|
2003
|
+
return { kind: { case: "agent", value: boundWorkflowAgentTargetFromProto(input.kind.value)! } };
|
|
2004
|
+
default:
|
|
2005
|
+
return { kind: { case: undefined } };
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
export function workflowEventToProto(input?: WorkflowEvent | undefined): ProtoWorkflowEvent | undefined {
|
|
2010
|
+
if (input === undefined) {
|
|
2011
|
+
return undefined;
|
|
2012
|
+
}
|
|
2013
|
+
return create(WorkflowEventSchema, {
|
|
2014
|
+
id: input.id ?? "",
|
|
2015
|
+
source: input.source ?? "",
|
|
2016
|
+
specVersion: input.specVersion ?? "",
|
|
2017
|
+
type: input.type ?? "",
|
|
2018
|
+
subject: input.subject ?? "",
|
|
2019
|
+
time: optionalTimestamp(input.time),
|
|
2020
|
+
datacontenttype: input.datacontenttype ?? "",
|
|
2021
|
+
data: optionalStruct(input.data),
|
|
2022
|
+
extensions: Object.fromEntries(
|
|
2023
|
+
Object.entries(input.extensions ?? {}).map(([key, value]) => [key, valueFromJson(value)]),
|
|
2024
|
+
),
|
|
2025
|
+
});
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
export function workflowEventFromProto(input?: ProtoWorkflowEvent | undefined): WorkflowEvent | undefined {
|
|
2029
|
+
if (input === undefined) {
|
|
2030
|
+
return undefined;
|
|
2031
|
+
}
|
|
2032
|
+
return {
|
|
2033
|
+
id: input.id,
|
|
2034
|
+
source: input.source,
|
|
2035
|
+
specVersion: input.specVersion,
|
|
2036
|
+
type: input.type,
|
|
2037
|
+
subject: input.subject,
|
|
2038
|
+
time: optionalDate(input.time),
|
|
2039
|
+
datacontenttype: input.datacontenttype,
|
|
2040
|
+
data: optionalObjectFromStruct(input.data),
|
|
2041
|
+
extensions: Object.fromEntries(
|
|
2042
|
+
Object.entries(input.extensions).map(([key, value]) => [key, jsonFromValue(value) as JsonInput]),
|
|
2043
|
+
),
|
|
2044
|
+
};
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
export function workflowSignalToProto(input?: WorkflowSignal | undefined): ProtoWorkflowSignal | undefined {
|
|
2048
|
+
if (input === undefined) {
|
|
2049
|
+
return undefined;
|
|
2050
|
+
}
|
|
2051
|
+
return create(WorkflowSignalSchema, {
|
|
2052
|
+
id: input.id ?? "",
|
|
2053
|
+
name: input.name ?? "",
|
|
2054
|
+
payload: optionalStruct(input.payload),
|
|
2055
|
+
metadata: optionalStruct(input.metadata),
|
|
2056
|
+
createdBy: workflowActorToProto(input.createdBy),
|
|
2057
|
+
createdAt: optionalTimestamp(input.createdAt),
|
|
2058
|
+
idempotencyKey: input.idempotencyKey ?? "",
|
|
2059
|
+
sequence: BigInt(input.sequence ?? 0),
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
export function workflowSignalFromProto(input?: ProtoWorkflowSignal | undefined): WorkflowSignal | undefined {
|
|
2064
|
+
if (input === undefined) {
|
|
2065
|
+
return undefined;
|
|
2066
|
+
}
|
|
2067
|
+
return {
|
|
2068
|
+
id: input.id,
|
|
2069
|
+
name: input.name,
|
|
2070
|
+
payload: optionalObjectFromStruct(input.payload),
|
|
2071
|
+
metadata: optionalObjectFromStruct(input.metadata),
|
|
2072
|
+
createdBy: workflowActorFromProto(input.createdBy),
|
|
2073
|
+
createdAt: optionalDate(input.createdAt),
|
|
2074
|
+
idempotencyKey: input.idempotencyKey,
|
|
2075
|
+
sequence: input.sequence,
|
|
2076
|
+
};
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
export function workflowScheduleTriggerToProto(
|
|
2080
|
+
input?: WorkflowScheduleTrigger | undefined,
|
|
2081
|
+
): ProtoWorkflowScheduleTrigger | undefined {
|
|
2082
|
+
if (input === undefined) {
|
|
2083
|
+
return undefined;
|
|
2084
|
+
}
|
|
2085
|
+
return create(WorkflowScheduleTriggerSchema, {
|
|
2086
|
+
scheduleId: input.scheduleId ?? "",
|
|
2087
|
+
scheduledFor: optionalTimestamp(input.scheduledFor),
|
|
2088
|
+
});
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
export function workflowScheduleTriggerFromProto(
|
|
2092
|
+
input?: ProtoWorkflowScheduleTrigger | undefined,
|
|
2093
|
+
): WorkflowScheduleTrigger | undefined {
|
|
2094
|
+
if (input === undefined) {
|
|
2095
|
+
return undefined;
|
|
2096
|
+
}
|
|
2097
|
+
return {
|
|
2098
|
+
scheduleId: input.scheduleId,
|
|
2099
|
+
scheduledFor: optionalDate(input.scheduledFor),
|
|
2100
|
+
};
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
export function workflowEventTriggerInvocationToProto(
|
|
2104
|
+
input?: WorkflowEventTriggerInvocation | undefined,
|
|
2105
|
+
): ProtoWorkflowEventTriggerInvocation | undefined {
|
|
2106
|
+
if (input === undefined) {
|
|
2107
|
+
return undefined;
|
|
2108
|
+
}
|
|
2109
|
+
return create(WorkflowEventTriggerInvocationSchema, {
|
|
2110
|
+
triggerId: input.triggerId ?? "",
|
|
2111
|
+
event: workflowEventToProto(input.event),
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
export function workflowEventTriggerInvocationFromProto(
|
|
2116
|
+
input?: ProtoWorkflowEventTriggerInvocation | undefined,
|
|
2117
|
+
): WorkflowEventTriggerInvocation | undefined {
|
|
2118
|
+
if (input === undefined) {
|
|
2119
|
+
return undefined;
|
|
2120
|
+
}
|
|
2121
|
+
return {
|
|
2122
|
+
triggerId: input.triggerId,
|
|
2123
|
+
event: workflowEventFromProto(input.event),
|
|
2124
|
+
};
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
export function workflowRunTriggerToProto(
|
|
2128
|
+
input?: WorkflowRunTrigger | WorkflowRunTriggerInput | undefined,
|
|
2129
|
+
): ProtoWorkflowRunTrigger | undefined {
|
|
2130
|
+
if (input === undefined) {
|
|
2131
|
+
return undefined;
|
|
2132
|
+
}
|
|
2133
|
+
const trigger = workflowRunTrigger(input);
|
|
2134
|
+
switch (trigger.kind.case) {
|
|
2135
|
+
case "manual":
|
|
2136
|
+
return create(WorkflowRunTriggerSchema, {
|
|
2137
|
+
kind: { case: "manual", value: create(WorkflowManualTriggerSchema) },
|
|
2138
|
+
});
|
|
2139
|
+
case "schedule":
|
|
2140
|
+
return create(WorkflowRunTriggerSchema, {
|
|
2141
|
+
kind: { case: "schedule", value: workflowScheduleTriggerToProto(trigger.kind.value)! },
|
|
2142
|
+
});
|
|
2143
|
+
case "event":
|
|
2144
|
+
return create(WorkflowRunTriggerSchema, {
|
|
2145
|
+
kind: { case: "event", value: workflowEventTriggerInvocationToProto(trigger.kind.value)! },
|
|
2146
|
+
});
|
|
2147
|
+
default:
|
|
2148
|
+
return create(WorkflowRunTriggerSchema);
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
export function workflowRunTriggerFromProto(
|
|
2153
|
+
input?: ProtoWorkflowRunTrigger | undefined,
|
|
2154
|
+
): WorkflowRunTrigger | undefined {
|
|
2155
|
+
if (input === undefined) {
|
|
2156
|
+
return undefined;
|
|
2157
|
+
}
|
|
2158
|
+
switch (input.kind.case) {
|
|
2159
|
+
case "manual":
|
|
2160
|
+
return { kind: { case: "manual", value: {} } };
|
|
2161
|
+
case "schedule":
|
|
2162
|
+
return { kind: { case: "schedule", value: workflowScheduleTriggerFromProto(input.kind.value)! } };
|
|
2163
|
+
case "event":
|
|
2164
|
+
return { kind: { case: "event", value: workflowEventTriggerInvocationFromProto(input.kind.value)! } };
|
|
2165
|
+
default:
|
|
2166
|
+
return { kind: { case: undefined } };
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
export function boundWorkflowRunToProto(input: BoundWorkflowRun): ProtoBoundWorkflowRun {
|
|
2171
|
+
return create(BoundWorkflowRunSchema, {
|
|
2172
|
+
id: input.id ?? "",
|
|
2173
|
+
status: input.status ?? WorkflowRunStatus.UNSPECIFIED,
|
|
2174
|
+
target: boundWorkflowTargetToProto(input.target),
|
|
2175
|
+
trigger: workflowRunTriggerToProto(input.trigger),
|
|
2176
|
+
createdAt: optionalTimestamp(input.createdAt),
|
|
2177
|
+
startedAt: optionalTimestamp(input.startedAt),
|
|
2178
|
+
completedAt: optionalTimestamp(input.completedAt),
|
|
2179
|
+
statusMessage: input.statusMessage ?? "",
|
|
2180
|
+
resultBody: input.resultBody ?? "",
|
|
2181
|
+
createdBy: workflowActorToProto(input.createdBy),
|
|
2182
|
+
executionRef: input.executionRef ?? "",
|
|
2183
|
+
workflowKey: input.workflowKey ?? "",
|
|
2184
|
+
});
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
export function boundWorkflowRunFromProto(input?: ProtoBoundWorkflowRun | undefined): BoundWorkflowRun | undefined {
|
|
2188
|
+
if (input === undefined) {
|
|
2189
|
+
return undefined;
|
|
2190
|
+
}
|
|
2191
|
+
return {
|
|
2192
|
+
id: input.id,
|
|
2193
|
+
status: input.status as WorkflowRunStatus,
|
|
2194
|
+
target: boundWorkflowTargetFromProto(input.target),
|
|
2195
|
+
trigger: workflowRunTriggerFromProto(input.trigger),
|
|
2196
|
+
createdAt: optionalDate(input.createdAt),
|
|
2197
|
+
startedAt: optionalDate(input.startedAt),
|
|
2198
|
+
completedAt: optionalDate(input.completedAt),
|
|
2199
|
+
statusMessage: input.statusMessage,
|
|
2200
|
+
resultBody: input.resultBody,
|
|
2201
|
+
createdBy: workflowActorFromProto(input.createdBy),
|
|
2202
|
+
executionRef: input.executionRef,
|
|
2203
|
+
workflowKey: input.workflowKey,
|
|
2204
|
+
};
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
export function signalWorkflowRunResponseToProto(
|
|
2208
|
+
input: SignalWorkflowRunResponse,
|
|
2209
|
+
): ProtoSignalWorkflowRunResponse {
|
|
2210
|
+
return create(SignalWorkflowRunResponseSchema, {
|
|
2211
|
+
run: input.run === undefined ? undefined : boundWorkflowRunToProto(input.run),
|
|
2212
|
+
signal: input.signal === undefined ? undefined : workflowSignalToProto(input.signal),
|
|
2213
|
+
startedRun: input.startedRun ?? false,
|
|
2214
|
+
workflowKey: input.workflowKey ?? "",
|
|
2215
|
+
});
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
export function boundWorkflowScheduleToProto(input: BoundWorkflowSchedule): ProtoBoundWorkflowSchedule {
|
|
2219
|
+
return create(BoundWorkflowScheduleSchema, {
|
|
2220
|
+
id: input.id ?? "",
|
|
2221
|
+
cron: input.cron ?? "",
|
|
2222
|
+
timezone: input.timezone ?? "",
|
|
2223
|
+
target: boundWorkflowTargetToProto(input.target),
|
|
2224
|
+
paused: input.paused ?? false,
|
|
2225
|
+
createdAt: optionalTimestamp(input.createdAt),
|
|
2226
|
+
updatedAt: optionalTimestamp(input.updatedAt),
|
|
2227
|
+
nextRunAt: optionalTimestamp(input.nextRunAt),
|
|
2228
|
+
createdBy: workflowActorToProto(input.createdBy),
|
|
2229
|
+
executionRef: input.executionRef ?? "",
|
|
2230
|
+
});
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
export function boundWorkflowScheduleFromProto(
|
|
2234
|
+
input?: ProtoBoundWorkflowSchedule | undefined,
|
|
2235
|
+
): BoundWorkflowSchedule | undefined {
|
|
2236
|
+
if (input === undefined) {
|
|
2237
|
+
return undefined;
|
|
2238
|
+
}
|
|
2239
|
+
return {
|
|
2240
|
+
id: input.id,
|
|
2241
|
+
cron: input.cron,
|
|
2242
|
+
timezone: input.timezone,
|
|
2243
|
+
target: boundWorkflowTargetFromProto(input.target),
|
|
2244
|
+
paused: input.paused,
|
|
2245
|
+
createdAt: optionalDate(input.createdAt),
|
|
2246
|
+
updatedAt: optionalDate(input.updatedAt),
|
|
2247
|
+
nextRunAt: optionalDate(input.nextRunAt),
|
|
2248
|
+
createdBy: workflowActorFromProto(input.createdBy),
|
|
2249
|
+
executionRef: input.executionRef,
|
|
2250
|
+
};
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
export function boundWorkflowEventTriggerToProto(
|
|
2254
|
+
input: BoundWorkflowEventTrigger,
|
|
2255
|
+
): ProtoBoundWorkflowEventTrigger {
|
|
2256
|
+
return create(BoundWorkflowEventTriggerSchema, {
|
|
2257
|
+
id: input.id ?? "",
|
|
2258
|
+
match: workflowEventMatchToProto(input.match),
|
|
2259
|
+
target: boundWorkflowTargetToProto(input.target),
|
|
2260
|
+
paused: input.paused ?? false,
|
|
2261
|
+
createdAt: optionalTimestamp(input.createdAt),
|
|
2262
|
+
updatedAt: optionalTimestamp(input.updatedAt),
|
|
2263
|
+
createdBy: workflowActorToProto(input.createdBy),
|
|
2264
|
+
executionRef: input.executionRef ?? "",
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
export function boundWorkflowEventTriggerFromProto(
|
|
2269
|
+
input?: ProtoBoundWorkflowEventTrigger | undefined,
|
|
2270
|
+
): BoundWorkflowEventTrigger | undefined {
|
|
2271
|
+
if (input === undefined) {
|
|
2272
|
+
return undefined;
|
|
2273
|
+
}
|
|
2274
|
+
return {
|
|
2275
|
+
id: input.id,
|
|
2276
|
+
match: workflowEventMatchFromProto(input.match),
|
|
2277
|
+
target: boundWorkflowTargetFromProto(input.target),
|
|
2278
|
+
paused: input.paused,
|
|
2279
|
+
createdAt: optionalDate(input.createdAt),
|
|
2280
|
+
updatedAt: optionalDate(input.updatedAt),
|
|
2281
|
+
createdBy: workflowActorFromProto(input.createdBy),
|
|
2282
|
+
executionRef: input.executionRef,
|
|
2283
|
+
};
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
export function boundWorkflowDefinitionToProto(input: BoundWorkflowDefinition) {
|
|
2287
|
+
return create(BoundWorkflowDefinitionSchema, {
|
|
2288
|
+
id: input.id ?? "",
|
|
2289
|
+
target: boundWorkflowTargetToProto(input.target),
|
|
2290
|
+
createdBy: workflowActorToProto(input.createdBy),
|
|
2291
|
+
createdAt: optionalTimestamp(input.createdAt),
|
|
2292
|
+
});
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
export function boundWorkflowDefinitionFromProto(
|
|
2296
|
+
input?: ProtoBoundWorkflowDefinition | undefined,
|
|
2297
|
+
): BoundWorkflowDefinition | undefined {
|
|
2298
|
+
if (input === undefined) {
|
|
2299
|
+
return undefined;
|
|
2300
|
+
}
|
|
2301
|
+
return {
|
|
2302
|
+
id: input.id,
|
|
2303
|
+
target: boundWorkflowTargetFromProto(input.target),
|
|
2304
|
+
createdBy: workflowActorFromProto(input.createdBy),
|
|
2305
|
+
createdAt: optionalDate(input.createdAt),
|
|
2306
|
+
};
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
export function workflowExecutionReferenceToProto(
|
|
2310
|
+
input: WorkflowExecutionReference,
|
|
2311
|
+
): ProtoWorkflowExecutionReference {
|
|
2312
|
+
return create(WorkflowExecutionReferenceSchema, {
|
|
2313
|
+
id: input.id ?? "",
|
|
2314
|
+
providerName: input.providerName ?? "",
|
|
2315
|
+
target: boundWorkflowTargetToProto(input.target),
|
|
2316
|
+
subjectId: input.subjectId ?? "",
|
|
2317
|
+
credentialSubjectId: input.credentialSubjectId ?? "",
|
|
2318
|
+
permissions: input.permissions?.map(workflowAccessPermissionToProto) ?? [],
|
|
2319
|
+
createdAt: optionalTimestamp(input.createdAt),
|
|
2320
|
+
revokedAt: optionalTimestamp(input.revokedAt),
|
|
2321
|
+
subjectKind: input.subjectKind ?? "",
|
|
2322
|
+
displayName: input.displayName ?? "",
|
|
2323
|
+
authSource: input.authSource ?? "",
|
|
2324
|
+
callerPluginName: input.callerPluginName ?? "",
|
|
2325
|
+
runAs: workflowRunAsSubjectToProto(input.runAs),
|
|
2326
|
+
sourceDefinitionId: input.sourceDefinitionId ?? "",
|
|
2327
|
+
});
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
export function workflowExecutionReferenceFromProto(
|
|
2331
|
+
input?: ProtoWorkflowExecutionReference | undefined,
|
|
2332
|
+
): WorkflowExecutionReference | undefined {
|
|
2333
|
+
if (input === undefined) {
|
|
2334
|
+
return undefined;
|
|
2335
|
+
}
|
|
2336
|
+
return {
|
|
2337
|
+
id: input.id,
|
|
2338
|
+
providerName: input.providerName,
|
|
2339
|
+
target: boundWorkflowTargetFromProto(input.target),
|
|
2340
|
+
subjectId: input.subjectId,
|
|
2341
|
+
credentialSubjectId: input.credentialSubjectId,
|
|
2342
|
+
permissions: input.permissions.map(workflowAccessPermissionFromProto),
|
|
2343
|
+
createdAt: optionalDate(input.createdAt),
|
|
2344
|
+
revokedAt: optionalDate(input.revokedAt),
|
|
2345
|
+
subjectKind: input.subjectKind,
|
|
2346
|
+
displayName: input.displayName,
|
|
2347
|
+
authSource: input.authSource,
|
|
2348
|
+
callerPluginName: input.callerPluginName,
|
|
2349
|
+
runAs: workflowRunAsSubjectFromProto(input.runAs),
|
|
2350
|
+
sourceDefinitionId: input.sourceDefinitionId,
|
|
2351
|
+
};
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
function invokeWorkflowOperationRequestToProto(input: InvokeWorkflowOperationInput) {
|
|
2355
|
+
return create(InvokeWorkflowOperationRequestSchema, {
|
|
2356
|
+
target: boundWorkflowTargetToProto(input.target),
|
|
2357
|
+
runId: input.runId ?? "",
|
|
2358
|
+
trigger: workflowRunTriggerToProto(input.trigger),
|
|
2359
|
+
input: optionalStruct(input.input),
|
|
2360
|
+
metadata: optionalStruct(input.metadata),
|
|
2361
|
+
createdBy: workflowActorToProto(input.createdBy),
|
|
2362
|
+
executionRef: input.executionRef ?? "",
|
|
2363
|
+
signals: input.signals?.map((signal) => workflowSignalToProto(signal)!) ?? [],
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
function startWorkflowProviderRunRequestFromProto(
|
|
2368
|
+
input: ProtoStartWorkflowProviderRunRequest,
|
|
2369
|
+
): StartWorkflowProviderRunRequest {
|
|
2370
|
+
return {
|
|
2371
|
+
target: boundWorkflowTargetFromProto(input.target),
|
|
2372
|
+
idempotencyKey: input.idempotencyKey,
|
|
2373
|
+
createdBy: workflowActorFromProto(input.createdBy),
|
|
2374
|
+
executionRef: input.executionRef,
|
|
2375
|
+
workflowKey: input.workflowKey,
|
|
2376
|
+
};
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
function getWorkflowProviderRunRequestFromProto(
|
|
2380
|
+
input: ProtoGetWorkflowProviderRunRequest,
|
|
2381
|
+
): GetWorkflowProviderRunRequest {
|
|
2382
|
+
return { runId: input.runId };
|
|
2383
|
+
}
|
|
2384
|
+
|
|
2385
|
+
function listWorkflowProviderRunsRequestFromProto(
|
|
2386
|
+
_input: ProtoListWorkflowProviderRunsRequest,
|
|
2387
|
+
): ListWorkflowProviderRunsRequest {
|
|
2388
|
+
return {};
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
function cancelWorkflowProviderRunRequestFromProto(
|
|
2392
|
+
input: ProtoCancelWorkflowProviderRunRequest,
|
|
2393
|
+
): CancelWorkflowProviderRunRequest {
|
|
2394
|
+
return { runId: input.runId, reason: input.reason };
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
function signalWorkflowProviderRunRequestFromProto(
|
|
2398
|
+
input: ProtoSignalWorkflowProviderRunRequest,
|
|
2399
|
+
): SignalWorkflowProviderRunRequest {
|
|
2400
|
+
return {
|
|
2401
|
+
runId: input.runId,
|
|
2402
|
+
signal: workflowSignalFromProto(input.signal),
|
|
2403
|
+
};
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
function signalOrStartWorkflowProviderRunRequestFromProto(
|
|
2407
|
+
input: ProtoSignalOrStartWorkflowProviderRunRequest,
|
|
2408
|
+
): SignalOrStartWorkflowProviderRunRequest {
|
|
2409
|
+
return {
|
|
2410
|
+
workflowKey: input.workflowKey,
|
|
2411
|
+
target: boundWorkflowTargetFromProto(input.target),
|
|
2412
|
+
idempotencyKey: input.idempotencyKey,
|
|
2413
|
+
createdBy: workflowActorFromProto(input.createdBy),
|
|
2414
|
+
executionRef: input.executionRef,
|
|
2415
|
+
signal: workflowSignalFromProto(input.signal),
|
|
2416
|
+
};
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
function upsertWorkflowProviderScheduleRequestFromProto(
|
|
2420
|
+
input: ProtoUpsertWorkflowProviderScheduleRequest,
|
|
2421
|
+
): UpsertWorkflowProviderScheduleRequest {
|
|
2422
|
+
return {
|
|
2423
|
+
scheduleId: input.scheduleId,
|
|
2424
|
+
cron: input.cron,
|
|
2425
|
+
timezone: input.timezone,
|
|
2426
|
+
target: boundWorkflowTargetFromProto(input.target),
|
|
2427
|
+
paused: input.paused,
|
|
2428
|
+
requestedBy: workflowActorFromProto(input.requestedBy),
|
|
2429
|
+
executionRef: input.executionRef,
|
|
2430
|
+
};
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
function getWorkflowProviderScheduleRequestFromProto(
|
|
2434
|
+
input: ProtoGetWorkflowProviderScheduleRequest,
|
|
2435
|
+
): GetWorkflowProviderScheduleRequest {
|
|
2436
|
+
return { scheduleId: input.scheduleId };
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2439
|
+
function listWorkflowProviderSchedulesRequestFromProto(
|
|
2440
|
+
_input: ProtoListWorkflowProviderSchedulesRequest,
|
|
2441
|
+
): ListWorkflowProviderSchedulesRequest {
|
|
2442
|
+
return {};
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
function deleteWorkflowProviderScheduleRequestFromProto(
|
|
2446
|
+
input: ProtoDeleteWorkflowProviderScheduleRequest,
|
|
2447
|
+
): DeleteWorkflowProviderScheduleRequest {
|
|
2448
|
+
return { scheduleId: input.scheduleId };
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
function pauseWorkflowProviderScheduleRequestFromProto(
|
|
2452
|
+
input: ProtoPauseWorkflowProviderScheduleRequest,
|
|
2453
|
+
): PauseWorkflowProviderScheduleRequest {
|
|
2454
|
+
return { scheduleId: input.scheduleId };
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
function resumeWorkflowProviderScheduleRequestFromProto(
|
|
2458
|
+
input: ProtoResumeWorkflowProviderScheduleRequest,
|
|
2459
|
+
): ResumeWorkflowProviderScheduleRequest {
|
|
2460
|
+
return { scheduleId: input.scheduleId };
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2463
|
+
function upsertWorkflowProviderEventTriggerRequestFromProto(
|
|
2464
|
+
input: ProtoUpsertWorkflowProviderEventTriggerRequest,
|
|
2465
|
+
): UpsertWorkflowProviderEventTriggerRequest {
|
|
2466
|
+
return {
|
|
2467
|
+
triggerId: input.triggerId,
|
|
2468
|
+
match: workflowEventMatchFromProto(input.match),
|
|
2469
|
+
target: boundWorkflowTargetFromProto(input.target),
|
|
2470
|
+
paused: input.paused,
|
|
2471
|
+
requestedBy: workflowActorFromProto(input.requestedBy),
|
|
2472
|
+
executionRef: input.executionRef,
|
|
2473
|
+
};
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
function getWorkflowProviderEventTriggerRequestFromProto(
|
|
2477
|
+
input: ProtoGetWorkflowProviderEventTriggerRequest,
|
|
2478
|
+
): GetWorkflowProviderEventTriggerRequest {
|
|
2479
|
+
return { triggerId: input.triggerId };
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2482
|
+
function listWorkflowProviderEventTriggersRequestFromProto(
|
|
2483
|
+
_input: ProtoListWorkflowProviderEventTriggersRequest,
|
|
2484
|
+
): ListWorkflowProviderEventTriggersRequest {
|
|
2485
|
+
return {};
|
|
2486
|
+
}
|
|
2487
|
+
|
|
2488
|
+
function deleteWorkflowProviderEventTriggerRequestFromProto(
|
|
2489
|
+
input: ProtoDeleteWorkflowProviderEventTriggerRequest,
|
|
2490
|
+
): DeleteWorkflowProviderEventTriggerRequest {
|
|
2491
|
+
return { triggerId: input.triggerId };
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2494
|
+
function pauseWorkflowProviderEventTriggerRequestFromProto(
|
|
2495
|
+
input: ProtoPauseWorkflowProviderEventTriggerRequest,
|
|
2496
|
+
): PauseWorkflowProviderEventTriggerRequest {
|
|
2497
|
+
return { triggerId: input.triggerId };
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
function resumeWorkflowProviderEventTriggerRequestFromProto(
|
|
2501
|
+
input: ProtoResumeWorkflowProviderEventTriggerRequest,
|
|
2502
|
+
): ResumeWorkflowProviderEventTriggerRequest {
|
|
2503
|
+
return { triggerId: input.triggerId };
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
function putWorkflowExecutionReferenceRequestFromProto(
|
|
2507
|
+
input: ProtoPutWorkflowExecutionReferenceRequest,
|
|
2508
|
+
): PutWorkflowExecutionReferenceRequest {
|
|
2509
|
+
return { reference: workflowExecutionReferenceFromProto(input.reference) };
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2512
|
+
function getWorkflowExecutionReferenceRequestFromProto(
|
|
2513
|
+
input: ProtoGetWorkflowExecutionReferenceRequest,
|
|
2514
|
+
): GetWorkflowExecutionReferenceRequest {
|
|
2515
|
+
return { id: input.id };
|
|
2516
|
+
}
|
|
2517
|
+
|
|
2518
|
+
function listWorkflowExecutionReferencesRequestFromProto(
|
|
2519
|
+
input: ProtoListWorkflowExecutionReferencesRequest,
|
|
2520
|
+
): ListWorkflowExecutionReferencesRequest {
|
|
2521
|
+
return { subjectId: input.subjectId };
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
function publishWorkflowProviderEventRequestFromProto(
|
|
2525
|
+
input: ProtoPublishWorkflowProviderEventRequest,
|
|
2526
|
+
): PublishWorkflowProviderEventRequest {
|
|
2527
|
+
return {
|
|
2528
|
+
pluginName: input.pluginName,
|
|
2529
|
+
event: workflowEventFromProto(input.event),
|
|
2530
|
+
publishedBy: workflowActorFromProto(input.publishedBy),
|
|
2531
|
+
};
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
export function managedWorkflowScheduleFromProto(input: {
|
|
2535
|
+
providerName: string;
|
|
2536
|
+
schedule?: ProtoBoundWorkflowSchedule | undefined;
|
|
2537
|
+
}): ManagedWorkflowSchedule {
|
|
2538
|
+
return {
|
|
2539
|
+
providerName: input.providerName,
|
|
2540
|
+
schedule: boundWorkflowScheduleFromProto(input.schedule),
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2544
|
+
export function managedWorkflowEventTriggerFromProto(input: {
|
|
2545
|
+
providerName: string;
|
|
2546
|
+
trigger?: ProtoBoundWorkflowEventTrigger | undefined;
|
|
2547
|
+
}): ManagedWorkflowEventTrigger {
|
|
2548
|
+
return {
|
|
2549
|
+
providerName: input.providerName,
|
|
2550
|
+
trigger: boundWorkflowEventTriggerFromProto(input.trigger),
|
|
2551
|
+
};
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
export function managedWorkflowDefinitionFromProto(input: {
|
|
2555
|
+
providerName: string;
|
|
2556
|
+
definition?: ProtoBoundWorkflowDefinition | undefined;
|
|
2557
|
+
}): ManagedWorkflowDefinition {
|
|
2558
|
+
return {
|
|
2559
|
+
providerName: input.providerName,
|
|
2560
|
+
definition: boundWorkflowDefinitionFromProto(input.definition),
|
|
2561
|
+
};
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
export function managedWorkflowRunFromProto(input: {
|
|
2565
|
+
providerName: string;
|
|
2566
|
+
run?: ProtoBoundWorkflowRun | undefined;
|
|
2567
|
+
}): ManagedWorkflowRun {
|
|
2568
|
+
return {
|
|
2569
|
+
providerName: input.providerName,
|
|
2570
|
+
run: boundWorkflowRunFromProto(input.run),
|
|
2571
|
+
};
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
export function managedWorkflowRunSignalFromProto(input: {
|
|
2575
|
+
providerName: string;
|
|
2576
|
+
run?: ProtoBoundWorkflowRun | undefined;
|
|
2577
|
+
signal?: ProtoWorkflowSignal | undefined;
|
|
2578
|
+
startedRun: boolean;
|
|
2579
|
+
workflowKey: string;
|
|
2580
|
+
}): ManagedWorkflowRunSignal {
|
|
2581
|
+
return {
|
|
2582
|
+
providerName: input.providerName,
|
|
2583
|
+
run: boundWorkflowRunFromProto(input.run),
|
|
2584
|
+
signal: workflowSignalFromProto(input.signal),
|
|
2585
|
+
startedRun: input.startedRun,
|
|
2586
|
+
workflowKey: input.workflowKey,
|
|
2587
|
+
};
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
function cloneWorkflowOutputValueSourceKind(
|
|
2591
|
+
kind: WorkflowOutputValueSourceKind,
|
|
2592
|
+
): WorkflowOutputValueSourceKind {
|
|
2593
|
+
switch (kind.case) {
|
|
2594
|
+
case "literal":
|
|
2595
|
+
return { case: "literal", value: kind.value };
|
|
2596
|
+
case "agentOutput":
|
|
2597
|
+
case "signalPayload":
|
|
2598
|
+
case "signalMetadata":
|
|
2599
|
+
case "agentSession":
|
|
2600
|
+
return { case: kind.case, value: kind.value };
|
|
2601
|
+
default:
|
|
2602
|
+
return { case: undefined };
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2606
|
+
function valueMapInput(input?: Record<string, JsonInput>): Record<string, JsonInput> {
|
|
2607
|
+
return input === undefined ? {} : { ...input };
|
|
2608
|
+
}
|
|
2609
|
+
|
|
2610
|
+
function jsonObjectClone(input: JsonObjectInput): JsonObjectInput {
|
|
2611
|
+
return structFromObject(jsonObjectFromStruct(input as JsonObject));
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
function optionalTimestamp(value?: Date | undefined) {
|
|
2615
|
+
return value === undefined ? undefined : timestampFromDate(value);
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
function optionalDate(timestamp?: Parameters<typeof dateFromTimestamp>[0]) {
|
|
2619
|
+
return timestamp === undefined ? undefined : dateFromTimestamp(timestamp);
|
|
2620
|
+
}
|
|
2621
|
+
|
|
2622
|
+
function workflowHostTransportOptions(rawTarget: string): {
|
|
2623
|
+
baseUrl: string;
|
|
2624
|
+
nodeOptions?: { path: string };
|
|
2625
|
+
} {
|
|
2626
|
+
const target = rawTarget.trim();
|
|
2627
|
+
if (!target) {
|
|
2628
|
+
throw new Error("workflow host: transport target is required");
|
|
2629
|
+
}
|
|
2630
|
+
if (target.startsWith("tcp://")) {
|
|
2631
|
+
const address = target.slice("tcp://".length).trim();
|
|
2632
|
+
if (!address) {
|
|
2633
|
+
throw new Error(
|
|
2634
|
+
`workflow host: tcp target ${JSON.stringify(rawTarget)} is missing host:port`,
|
|
459
2635
|
);
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
2636
|
+
}
|
|
2637
|
+
return { baseUrl: `http://${address}` };
|
|
2638
|
+
}
|
|
2639
|
+
if (target.startsWith("tls://")) {
|
|
2640
|
+
const address = target.slice("tls://".length).trim();
|
|
2641
|
+
if (!address) {
|
|
2642
|
+
throw new Error(
|
|
2643
|
+
`workflow host: tls target ${JSON.stringify(rawTarget)} is missing host:port`,
|
|
467
2644
|
);
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
2645
|
+
}
|
|
2646
|
+
return { baseUrl: `https://${address}` };
|
|
2647
|
+
}
|
|
2648
|
+
if (target.startsWith("unix://")) {
|
|
2649
|
+
const socketPath = target.slice("unix://".length).trim();
|
|
2650
|
+
if (!socketPath) {
|
|
2651
|
+
throw new Error(
|
|
2652
|
+
`workflow host: unix target ${JSON.stringify(rawTarget)} is missing a socket path`,
|
|
472
2653
|
);
|
|
473
|
-
|
|
474
|
-
}
|
|
2654
|
+
}
|
|
2655
|
+
return { baseUrl: "http://localhost", nodeOptions: { path: socketPath } };
|
|
2656
|
+
}
|
|
2657
|
+
if (target.includes("://")) {
|
|
2658
|
+
const parsed = new URL(target);
|
|
2659
|
+
throw new Error(
|
|
2660
|
+
`workflow host: unsupported target scheme ${JSON.stringify(parsed.protocol.replace(/:$/, ""))}`,
|
|
2661
|
+
);
|
|
2662
|
+
}
|
|
2663
|
+
return { baseUrl: "http://localhost", nodeOptions: { path: target } };
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
function workflowHostRelayTokenInterceptor(token: string): Interceptor {
|
|
2667
|
+
return (next) => async (req) => {
|
|
2668
|
+
req.header.set(WORKFLOW_HOST_RELAY_TOKEN_HEADER, token);
|
|
2669
|
+
return next(req);
|
|
475
2670
|
};
|
|
476
2671
|
}
|
|
477
2672
|
|
|
@@ -491,3 +2686,17 @@ async function invokeWorkflowProvider<T>(
|
|
|
491
2686
|
);
|
|
492
2687
|
}
|
|
493
2688
|
}
|
|
2689
|
+
|
|
2690
|
+
async function requireWorkflowProviderHandler<Request, Response>(
|
|
2691
|
+
action: string,
|
|
2692
|
+
fn: ((request: Request) => MaybePromise<Response>) | undefined,
|
|
2693
|
+
request: Request,
|
|
2694
|
+
): Promise<Response> {
|
|
2695
|
+
if (!fn) {
|
|
2696
|
+
throw new ConnectError(
|
|
2697
|
+
`workflow provider ${action} is not implemented`,
|
|
2698
|
+
Code.Unimplemented,
|
|
2699
|
+
);
|
|
2700
|
+
}
|
|
2701
|
+
return await fn(request);
|
|
2702
|
+
}
|