@powerhousedao/pieces-framework 6.2.3-dev.11

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/dist/index.js ADDED
@@ -0,0 +1,1569 @@
1
+ import { _ as ErrorHandlingOptionsParam, a as ObjectProperty, c as DynamicProp, d as ArrayProperty, f as ArraySubProps, g as MultiSelectDropdownProperty, h as DropdownProperty, i as RichTextProperty, l as DynamicProperties, m as JsonProperty, n as Property, o as assertNotNullOrUndefined, p as DateTimeProperty, r as CustomProperty, s as isNotUndefined, t as InputProperty, u as DynamicPropsValue, v as IAction, y as createAction } from "./input-COuhC1I-.js";
2
+ import { A as PropertyType, C as CheckboxProperty, D as DropdownState, E as DropdownOption, O as LongTextProperty, S as NumberProperty, T as StaticMultiSelectDropdownProperty, _ as DateRangeProperty, a as chunk, b as ApFile, c as isNil, f as pickBy, g as DateRangePreset, h as MarkdownVariant, i as camelCase, j as BasePropertySchema, k as ShortTextProperty, l as isString, m as unique, n as tryCatch, p as startCase, s as isEmpty, u as kebabCase, v as DateRangeValue, w as StaticDropdownProperty, x as FileProperty, y as dateRangeUtils } from "./markdown-property-Df2l6_y_.js";
3
+ import { _ as TriggerStrategy, a as OAuth2AuthorizationMethod, b as AppConnectionType, c as OAuth2Props, d as SecretTextProperty, f as BasicAuthProperty, g as AUTHENTICATION_PROPERTY_NAME, h as spreadIfDefined, i as getAuthPropertyForValue, l as OIDCProperty, n as PieceAuth, o as OAuth2Property, p as BasicAuthPropertyValue, r as PieceAuthProperty, s as OAuth2PropertyValue, t as DEFAULT_CONNECTION_DISPLAY_NAME, u as CustomAuthProperty, v as TriggerTestStrategy, x as OAuth2GrantType, y as WebhookHandshakeStrategy } from "./authentication-B7brX_It.js";
4
+ import * as z from "zod/mini";
5
+ import { customAlphabet } from "nanoid";
6
+ import path from "node:path";
7
+ import fs from "node:fs/promises";
8
+
9
+ //#region upstream/core-piece-types/lib/piece.ts
10
+ let PackageType = /* @__PURE__ */ function(PackageType) {
11
+ PackageType["ARCHIVE"] = "ARCHIVE";
12
+ PackageType["REGISTRY"] = "REGISTRY";
13
+ return PackageType;
14
+ }({});
15
+ let PieceType = /* @__PURE__ */ function(PieceType) {
16
+ PieceType["CUSTOM"] = "CUSTOM";
17
+ PieceType["OFFICIAL"] = "OFFICIAL";
18
+ return PieceType;
19
+ }({});
20
+ let PieceCategory = /* @__PURE__ */ function(PieceCategory) {
21
+ PieceCategory["ARTIFICIAL_INTELLIGENCE"] = "ARTIFICIAL_INTELLIGENCE";
22
+ PieceCategory["COMMUNICATION"] = "COMMUNICATION";
23
+ PieceCategory["COMMERCE"] = "COMMERCE";
24
+ PieceCategory["CORE"] = "CORE";
25
+ PieceCategory["UNIVERSAL_AI"] = "UNIVERSAL_AI";
26
+ PieceCategory["FLOW_CONTROL"] = "FLOW_CONTROL";
27
+ PieceCategory["BUSINESS_INTELLIGENCE"] = "BUSINESS_INTELLIGENCE";
28
+ PieceCategory["ACCOUNTING"] = "ACCOUNTING";
29
+ PieceCategory["PRODUCTIVITY"] = "PRODUCTIVITY";
30
+ PieceCategory["CONTENT_AND_FILES"] = "CONTENT_AND_FILES";
31
+ PieceCategory["DEVELOPER_TOOLS"] = "DEVELOPER_TOOLS";
32
+ PieceCategory["CUSTOMER_SUPPORT"] = "CUSTOMER_SUPPORT";
33
+ PieceCategory["FORMS_AND_SURVEYS"] = "FORMS_AND_SURVEYS";
34
+ PieceCategory["HUMAN_RESOURCES"] = "HUMAN_RESOURCES";
35
+ PieceCategory["PAYMENT_PROCESSING"] = "PAYMENT_PROCESSING";
36
+ PieceCategory["MARKETING"] = "MARKETING";
37
+ PieceCategory["SALES_AND_CRM"] = "SALES_AND_CRM";
38
+ return PieceCategory;
39
+ }({});
40
+
41
+ //#endregion
42
+ //#region upstream/core-piece-types/lib/execution.ts
43
+ let ExecutionType = /* @__PURE__ */ function(ExecutionType) {
44
+ ExecutionType["BEGIN"] = "BEGIN";
45
+ ExecutionType["RESUME"] = "RESUME";
46
+ return ExecutionType;
47
+ }({});
48
+ let PauseType = /* @__PURE__ */ function(PauseType) {
49
+ PauseType["DELAY"] = "DELAY";
50
+ PauseType["WEBHOOK"] = "WEBHOOK";
51
+ return PauseType;
52
+ }({});
53
+ let StreamStepProgress = /* @__PURE__ */ function(StreamStepProgress) {
54
+ StreamStepProgress["WEBSOCKET"] = "WEBSOCKET";
55
+ StreamStepProgress["NONE"] = "NONE";
56
+ return StreamStepProgress;
57
+ }({});
58
+ const RespondResponse = z.object({
59
+ status: z.optional(z.number()),
60
+ body: z.optional(z.unknown()),
61
+ headers: z.optional(z.record(z.string(), z.string()))
62
+ });
63
+ const DelayPauseMetadata = z.object({
64
+ type: z.literal(PauseType.DELAY),
65
+ resumeDateTime: z.string(),
66
+ requestIdToReply: z.optional(z.string()),
67
+ handlerId: z.optional(z.string()),
68
+ streamStepProgress: z.optional(z.enum(StreamStepProgress))
69
+ });
70
+ const WebhookPauseMetadata = z.object({
71
+ type: z.literal(PauseType.WEBHOOK),
72
+ requestId: z.string(),
73
+ requestIdToReply: z.optional(z.string()),
74
+ response: RespondResponse,
75
+ handlerId: z.optional(z.string()),
76
+ streamStepProgress: z.optional(z.enum(StreamStepProgress))
77
+ });
78
+ const PauseMetadata = z.union([DelayPauseMetadata, WebhookPauseMetadata]);
79
+
80
+ //#endregion
81
+ //#region upstream/core-utils/lib/id-generator.ts
82
+ const ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
83
+ const ID_LENGTH = 21;
84
+ const ApId = z.string().check(z.regex(new RegExp(`^[0-9a-zA-Z]{${ID_LENGTH}}$`)));
85
+ const apId = customAlphabet(ALPHABET, ID_LENGTH);
86
+
87
+ //#endregion
88
+ //#region upstream/core-utils/lib/base-model.ts
89
+ const DateOrString = z.pipe(z.transform((val) => val instanceof Date ? val.toISOString() : val), z.string());
90
+ const BaseModelSchema = {
91
+ id: z.string(),
92
+ created: DateOrString,
93
+ updated: DateOrString
94
+ };
95
+ const Nullable = (schema) => z.optional(z.nullable(schema));
96
+ function NullableEnum(enumObj) {
97
+ return z.optional(z.nullable(z.enum(enumObj)));
98
+ }
99
+ const OptionalBooleanFromQuery = z.pipe(z.transform((val) => val === "true" || val === true ? true : val === "false" || val === false ? false : void 0), z.optional(z.boolean()));
100
+ const OptionalArrayFromQuery = (schema) => z.pipe(z.transform((val) => Array.isArray(val) ? val : val !== void 0 ? [val] : void 0), z.optional(z.array(schema)));
101
+
102
+ //#endregion
103
+ //#region upstream/core-utils/lib/seek-page.ts
104
+ const SeekPage = (t) => z.object({
105
+ data: z.array(t),
106
+ next: Nullable(z.string()),
107
+ previous: Nullable(z.string())
108
+ });
109
+
110
+ //#endregion
111
+ //#region upstream/core-utils/lib/locale.ts
112
+ let LocalesEnum = /* @__PURE__ */ function(LocalesEnum) {
113
+ LocalesEnum["DUTCH"] = "nl";
114
+ LocalesEnum["ENGLISH"] = "en";
115
+ LocalesEnum["GERMAN"] = "de";
116
+ LocalesEnum["FRENCH"] = "fr";
117
+ LocalesEnum["SPANISH"] = "es";
118
+ LocalesEnum["JAPANESE"] = "ja";
119
+ LocalesEnum["CHINESE_SIMPLIFIED"] = "zh";
120
+ LocalesEnum["PORTUGUESE"] = "pt";
121
+ LocalesEnum["ARABIC"] = "ar";
122
+ LocalesEnum["CHINESE_TRADITIONAL"] = "zh-TW";
123
+ return LocalesEnum;
124
+ }({});
125
+
126
+ //#endregion
127
+ //#region upstream/core-utils/lib/permission.ts
128
+ let AIProviderName = /* @__PURE__ */ function(AIProviderName) {
129
+ AIProviderName["OPENAI"] = "openai";
130
+ AIProviderName["OPENROUTER"] = "openrouter";
131
+ AIProviderName["ANTHROPIC"] = "anthropic";
132
+ AIProviderName["AZURE"] = "azure";
133
+ AIProviderName["GOOGLE"] = "google";
134
+ AIProviderName["ACTIVEPIECES"] = "activepieces";
135
+ AIProviderName["CLOUDFLARE_GATEWAY"] = "cloudflare-gateway";
136
+ AIProviderName["CUSTOM"] = "custom";
137
+ AIProviderName["BEDROCK"] = "bedrock";
138
+ AIProviderName["VERTEX"] = "vertex";
139
+ AIProviderName["MISTRAL"] = "mistral";
140
+ AIProviderName["XAI"] = "xai";
141
+ AIProviderName["DEEPSEEK"] = "deepseek";
142
+ AIProviderName["ZAI"] = "zai";
143
+ AIProviderName["QWEN"] = "qwen";
144
+ AIProviderName["MINIMAX"] = "minimax";
145
+ AIProviderName["MOONSHOT"] = "moonshot";
146
+ return AIProviderName;
147
+ }({});
148
+
149
+ //#endregion
150
+ //#region upstream/core-piece-types/lib/agents.ts
151
+ const TASK_COMPLETION_TOOL_NAME = "updateTaskStatus";
152
+ let AgentToolType = /* @__PURE__ */ function(AgentToolType) {
153
+ AgentToolType["PIECE"] = "PIECE";
154
+ AgentToolType["FLOW"] = "FLOW";
155
+ AgentToolType["MCP"] = "MCP";
156
+ AgentToolType["KNOWLEDGE_BASE"] = "KNOWLEDGE_BASE";
157
+ return AgentToolType;
158
+ }({});
159
+ let FieldControlMode = /* @__PURE__ */ function(FieldControlMode) {
160
+ FieldControlMode["AGENT_DECIDE"] = "agent-decide";
161
+ FieldControlMode["CHOOSE_YOURSELF"] = "choose-yourself";
162
+ FieldControlMode["LEAVE_EMPTY"] = "leave-empty";
163
+ return FieldControlMode;
164
+ }({});
165
+ let KnowledgeBaseSourceType = /* @__PURE__ */ function(KnowledgeBaseSourceType) {
166
+ KnowledgeBaseSourceType["FILE"] = "FILE";
167
+ KnowledgeBaseSourceType["TABLE"] = "TABLE";
168
+ return KnowledgeBaseSourceType;
169
+ }({});
170
+ let McpProtocol = /* @__PURE__ */ function(McpProtocol) {
171
+ McpProtocol["SSE"] = "sse";
172
+ McpProtocol["STREAMABLE_HTTP"] = "streamable-http";
173
+ McpProtocol["SIMPLE_HTTP"] = "http";
174
+ return McpProtocol;
175
+ }({});
176
+ let McpAuthType = /* @__PURE__ */ function(McpAuthType) {
177
+ McpAuthType["NONE"] = "none";
178
+ McpAuthType["ACCESS_TOKEN"] = "access_token";
179
+ McpAuthType["API_KEY"] = "api_key";
180
+ McpAuthType["HEADERS"] = "headers";
181
+ return McpAuthType;
182
+ }({});
183
+ let AgentOutputFieldType = /* @__PURE__ */ function(AgentOutputFieldType) {
184
+ AgentOutputFieldType["TEXT"] = "text";
185
+ AgentOutputFieldType["NUMBER"] = "number";
186
+ AgentOutputFieldType["BOOLEAN"] = "boolean";
187
+ return AgentOutputFieldType;
188
+ }({});
189
+ let AgentTaskStatus = /* @__PURE__ */ function(AgentTaskStatus) {
190
+ AgentTaskStatus["COMPLETED"] = "COMPLETED";
191
+ AgentTaskStatus["FAILED"] = "FAILED";
192
+ AgentTaskStatus["IN_PROGRESS"] = "IN_PROGRESS";
193
+ return AgentTaskStatus;
194
+ }({});
195
+ let ContentBlockType = /* @__PURE__ */ function(ContentBlockType) {
196
+ ContentBlockType["MARKDOWN"] = "MARKDOWN";
197
+ ContentBlockType["TOOL_CALL"] = "TOOL_CALL";
198
+ return ContentBlockType;
199
+ }({});
200
+ let ToolCallStatus = /* @__PURE__ */ function(ToolCallStatus) {
201
+ ToolCallStatus["IN_PROGRESS"] = "in-progress";
202
+ ToolCallStatus["COMPLETED"] = "completed";
203
+ return ToolCallStatus;
204
+ }({});
205
+ let ExecutionToolStatus = /* @__PURE__ */ function(ExecutionToolStatus) {
206
+ ExecutionToolStatus["SUCCESS"] = "SUCCESS";
207
+ ExecutionToolStatus["FAILED"] = "FAILED";
208
+ return ExecutionToolStatus;
209
+ }({});
210
+ let ToolCallType = /* @__PURE__ */ function(ToolCallType) {
211
+ ToolCallType["PIECE"] = "PIECE";
212
+ ToolCallType["FLOW"] = "FLOW";
213
+ ToolCallType["MCP"] = "MCP";
214
+ ToolCallType["KNOWLEDGE_BASE"] = "KNOWLEDGE_BASE";
215
+ ToolCallType["UNKNOWN"] = "UNKNOWN";
216
+ return ToolCallType;
217
+ }({});
218
+ let AgentPieceProps = /* @__PURE__ */ function(AgentPieceProps) {
219
+ AgentPieceProps["AGENT_ID"] = "agentId";
220
+ AgentPieceProps["AGENT_TOOLS"] = "agentTools";
221
+ AgentPieceProps["STRUCTURED_OUTPUT"] = "structuredOutput";
222
+ AgentPieceProps["PROMPT"] = "prompt";
223
+ AgentPieceProps["MAX_STEPS"] = "maxSteps";
224
+ AgentPieceProps["AI_PROVIDER_MODEL"] = "aiProviderModel";
225
+ AgentPieceProps["WEB_SEARCH"] = "webSearch";
226
+ AgentPieceProps["WEB_SEARCH_OPTIONS"] = "webSearchOptions";
227
+ return AgentPieceProps;
228
+ }({});
229
+ const PredefinedInputField = z.object({
230
+ mode: z.enum(FieldControlMode),
231
+ value: z.unknown()
232
+ });
233
+ const PredefinedInputsStructure = z.object({
234
+ auth: z.optional(z.string()),
235
+ fields: z.record(z.string(), PredefinedInputField)
236
+ });
237
+ const AgentPieceToolMetadata = z.object({
238
+ pieceName: z.string(),
239
+ pieceVersion: z.string(),
240
+ actionName: z.string(),
241
+ predefinedInput: z.optional(PredefinedInputsStructure)
242
+ });
243
+ const AgentPieceTool = z.object({
244
+ type: z.literal(AgentToolType.PIECE),
245
+ toolName: z.string().check(z.minLength(1)),
246
+ pieceMetadata: AgentPieceToolMetadata
247
+ });
248
+ const McpAuthNone = z.object({ type: z.literal(McpAuthType.NONE) });
249
+ const McpAuthAccessToken = z.object({
250
+ type: z.literal(McpAuthType.ACCESS_TOKEN),
251
+ accessToken: z.string()
252
+ });
253
+ const McpAuthApiKey = z.object({
254
+ type: z.literal(McpAuthType.API_KEY),
255
+ apiKey: z.string(),
256
+ apiKeyHeader: z.string()
257
+ });
258
+ const McpAuthHeaders = z.object({
259
+ type: z.literal(McpAuthType.HEADERS),
260
+ headers: z.record(z.string(), z.string())
261
+ });
262
+ const McpAuthConfig = z.discriminatedUnion("type", [
263
+ McpAuthNone,
264
+ McpAuthAccessToken,
265
+ McpAuthApiKey,
266
+ McpAuthHeaders
267
+ ]);
268
+ const AgentFlowTool = z.object({
269
+ type: z.literal(AgentToolType.FLOW),
270
+ toolName: z.string().check(z.minLength(1)),
271
+ externalFlowId: z.string(),
272
+ flowDisplayName: z.optional(z.string())
273
+ });
274
+ const AgentMcpTool = z.object({
275
+ type: z.literal(AgentToolType.MCP),
276
+ toolName: z.string().check(z.minLength(1)),
277
+ serverUrl: z.url(),
278
+ protocol: z.enum(McpProtocol),
279
+ auth: McpAuthConfig
280
+ });
281
+ const AgentKnowledgeBaseTool = z.object({
282
+ type: z.literal(AgentToolType.KNOWLEDGE_BASE),
283
+ toolName: z.string().check(z.minLength(1)),
284
+ sourceType: z.enum(KnowledgeBaseSourceType),
285
+ sourceId: z.string(),
286
+ sourceName: z.string()
287
+ });
288
+ const AgentTool = z.discriminatedUnion("type", [
289
+ AgentPieceTool,
290
+ AgentFlowTool,
291
+ AgentMcpTool,
292
+ AgentKnowledgeBaseTool
293
+ ]);
294
+ const AgentOutputField = z.object({
295
+ displayName: z.string(),
296
+ description: z.optional(z.string()),
297
+ type: z.enum(AgentOutputFieldType)
298
+ });
299
+ const MarkdownContentBlock = z.object({
300
+ type: z.literal(ContentBlockType.MARKDOWN),
301
+ markdown: z.string()
302
+ });
303
+ const toolCallBaseShape = {
304
+ type: z.literal(ContentBlockType.TOOL_CALL),
305
+ input: Nullable(z.record(z.string(), z.unknown())),
306
+ output: z.optional(z.unknown()),
307
+ toolName: z.string(),
308
+ status: z.enum(ToolCallStatus),
309
+ toolCallId: z.string(),
310
+ startTime: z.string(),
311
+ endTime: z.optional(z.string())
312
+ };
313
+ z.object(toolCallBaseShape);
314
+ const ToolCallContentBlock = z.discriminatedUnion("toolCallType", [
315
+ z.object({
316
+ ...toolCallBaseShape,
317
+ toolCallType: z.literal(ToolCallType.PIECE),
318
+ pieceName: z.string(),
319
+ pieceVersion: z.string(),
320
+ actionName: z.string()
321
+ }),
322
+ z.object({
323
+ ...toolCallBaseShape,
324
+ toolCallType: z.literal(ToolCallType.FLOW),
325
+ displayName: z.string(),
326
+ externalFlowId: z.string()
327
+ }),
328
+ z.object({
329
+ ...toolCallBaseShape,
330
+ toolCallType: z.literal(ToolCallType.MCP),
331
+ displayName: z.string(),
332
+ serverUrl: z.string()
333
+ }),
334
+ z.object({
335
+ ...toolCallBaseShape,
336
+ toolCallType: z.literal(ToolCallType.KNOWLEDGE_BASE),
337
+ displayName: z.string(),
338
+ sourceType: z.string()
339
+ }),
340
+ z.object({
341
+ ...toolCallBaseShape,
342
+ toolCallType: z.literal(ToolCallType.UNKNOWN),
343
+ displayName: z.string()
344
+ })
345
+ ]);
346
+ const AgentStepBlock = z.union([MarkdownContentBlock, ToolCallContentBlock]);
347
+ function buildAuthHeaders(authConfig) {
348
+ let headers = {};
349
+ switch (authConfig.type) {
350
+ case McpAuthType.NONE: break;
351
+ case McpAuthType.HEADERS:
352
+ headers = authConfig.headers;
353
+ break;
354
+ case McpAuthType.ACCESS_TOKEN:
355
+ headers["Authorization"] = `Bearer ${authConfig.accessToken}`;
356
+ break;
357
+ case McpAuthType.API_KEY: {
358
+ const headerName = authConfig.apiKeyHeader;
359
+ headers[headerName] = authConfig.apiKey;
360
+ break;
361
+ }
362
+ }
363
+ return headers;
364
+ }
365
+ function shortHash(str) {
366
+ let h = 5381;
367
+ for (let i = 0; i < str.length; i++) h = (Math.imul(h, 33) ^ str.charCodeAt(i)) >>> 0;
368
+ return h.toString(36).padStart(6, "0").slice(-6);
369
+ }
370
+ function sanitizeToolName(name) {
371
+ return name.toLowerCase().replace(/[^a-z0-9_-]/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
372
+ }
373
+ function createToolName(name) {
374
+ const sanitized = sanitizeToolName(name);
375
+ return `${sanitized.slice(0, MAX_PREFIX_LENGTH)}_${shortHash(sanitized.length > 0 ? sanitized : name)}_mcp`;
376
+ }
377
+ function toValidToolName(name) {
378
+ if (PROVIDER_TOOL_NAME_PATTERN.test(name)) return name;
379
+ const generated = createToolName(name);
380
+ return PROVIDER_TOOL_NAME_PATTERN.test(generated) ? generated : createToolName(`tool_${name}`);
381
+ }
382
+ function suggestToolName(sourceName) {
383
+ return toValidToolName(sanitizeToolName(sourceName));
384
+ }
385
+ function isProviderSafeIdentifier(name) {
386
+ return PROVIDER_TOOL_NAME_PATTERN.test(name);
387
+ }
388
+ function toProviderSafeIdentifier({ name, fallback }) {
389
+ if (isProviderSafeIdentifier(name)) return name;
390
+ const sanitized = sanitizeToolName(name).slice(0, MAX_IDENTIFIER_LENGTH);
391
+ if (sanitized.length === 0) return fallback;
392
+ const seeded = /^[a-z_]/.test(sanitized) ? sanitized : `_${sanitized}`;
393
+ return isProviderSafeIdentifier(seeded) ? seeded : fallback;
394
+ }
395
+ function createPieceToolName(pieceName, actionName) {
396
+ const idx = pieceName.indexOf("piece-");
397
+ return createToolName(`${idx >= 0 ? pieceName.substring(idx + 6) : pieceName}-${actionName}`);
398
+ }
399
+ const MAX_PREFIX_LENGTH = 53;
400
+ const MAX_IDENTIFIER_LENGTH = 64;
401
+ const PROVIDER_TOOL_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_-]{0,63}$/;
402
+ const mcpToolNameUtils = {
403
+ createToolName,
404
+ createPieceToolName,
405
+ toValidToolName,
406
+ suggestToolName,
407
+ isProviderSafeIdentifier,
408
+ toProviderSafeIdentifier
409
+ };
410
+ const AGENT_STEP_TIMEOUT_MS = 10800 * 1e3;
411
+ const AGENT_STEP_TEST_TIMEOUT_MS = 900 * 1e3;
412
+
413
+ //#endregion
414
+ //#region upstream/core-piece-types/lib/ai-providers.ts
415
+ let AIProviderModelType = /* @__PURE__ */ function(AIProviderModelType) {
416
+ AIProviderModelType["IMAGE"] = "image";
417
+ AIProviderModelType["TEXT"] = "text";
418
+ return AIProviderModelType;
419
+ }({});
420
+ const BaseAIProviderAuthConfig = z.object({ apiKey: z.string() });
421
+ const AnthropicProviderAuthConfig = BaseAIProviderAuthConfig;
422
+ const ActivePiecesProviderAuthConfig = z.object({
423
+ apiKey: z.string(),
424
+ apiKeyHash: z.string()
425
+ });
426
+ const OpenAICompatibleProviderAuthConfig = BaseAIProviderAuthConfig;
427
+ const CloudflareGatewayProviderAuthConfig = BaseAIProviderAuthConfig;
428
+ const AzureProviderAuthConfig = BaseAIProviderAuthConfig;
429
+ const GoogleProviderAuthConfig = BaseAIProviderAuthConfig;
430
+ const OpenAIProviderAuthConfig = BaseAIProviderAuthConfig;
431
+ const OpenRouterProviderAuthConfig = BaseAIProviderAuthConfig;
432
+ const MistralProviderAuthConfig = BaseAIProviderAuthConfig;
433
+ const VertexProviderAuthConfig = z.object({ serviceAccountJson: z.string().check(z.minLength(1)) });
434
+ const BedrockProviderAuthConfig = z.object({
435
+ accessKeyId: z.string().check(z.minLength(1)),
436
+ secretAccessKey: z.string().check(z.minLength(1))
437
+ });
438
+ const AnthropicProviderConfig = z.object({});
439
+ const ActivePiecesProviderConfig = z.object({});
440
+ const GoogleProviderConfig = z.object({});
441
+ const OpenAIProviderConfig = z.object({});
442
+ const OpenRouterProviderConfig = z.object({});
443
+ const MistralProviderConfig = z.object({});
444
+ const ProviderModelConfig = z.object({
445
+ modelId: z.string(),
446
+ modelName: z.string(),
447
+ modelType: z.enum(AIProviderModelType)
448
+ });
449
+ const OpenAICompatibleProviderConfig = z.object({
450
+ apiKeyHeader: z.string(),
451
+ baseUrl: z.string(),
452
+ models: z.array(ProviderModelConfig),
453
+ defaultHeaders: z.optional(z.record(z.string(), z.string())),
454
+ apiStyle: z.optional(z.enum(["chat", "responses"]))
455
+ });
456
+ const CloudflareGatewayProviderConfig = z.object({
457
+ accountId: z.string(),
458
+ gatewayId: z.string(),
459
+ models: z.array(ProviderModelConfig),
460
+ vertexProject: z.optional(z.string()),
461
+ vertexRegion: z.optional(z.string())
462
+ });
463
+ const AzureProviderConfig = z.object({
464
+ resourceName: z.string(),
465
+ apiVersion: z.pipe(z.transform((v) => typeof v === "string" && v.trim().length === 0 ? void 0 : v), z.optional(z.string()))
466
+ });
467
+ const BedrockProviderConfig = z.object({ region: z.string().check(z.minLength(1)) });
468
+ const VertexProviderConfig = z.object({
469
+ project: z.string().check(z.regex(/^[a-z0-9][a-z0-9-]{0,62}$/)),
470
+ region: z.string().check(z.regex(/^[a-z0-9][a-z0-9-]{0,62}$/)),
471
+ models: z.array(ProviderModelConfig)
472
+ });
473
+ const OpenAiCompatibleVendorConfig = z.object({});
474
+ const AIProviderAuthConfig = z.union([
475
+ AnthropicProviderAuthConfig,
476
+ AzureProviderAuthConfig,
477
+ GoogleProviderAuthConfig,
478
+ OpenAIProviderAuthConfig,
479
+ OpenRouterProviderAuthConfig,
480
+ CloudflareGatewayProviderAuthConfig,
481
+ OpenAICompatibleProviderAuthConfig,
482
+ ActivePiecesProviderAuthConfig,
483
+ BedrockProviderAuthConfig,
484
+ VertexProviderAuthConfig,
485
+ MistralProviderAuthConfig
486
+ ]);
487
+ const AIProviderConfig = z.union([
488
+ OpenAICompatibleProviderConfig,
489
+ CloudflareGatewayProviderConfig,
490
+ AzureProviderConfig,
491
+ VertexProviderConfig,
492
+ BedrockProviderConfig,
493
+ AnthropicProviderConfig,
494
+ GoogleProviderConfig,
495
+ OpenAIProviderConfig,
496
+ OpenRouterProviderConfig,
497
+ ActivePiecesProviderConfig,
498
+ MistralProviderConfig,
499
+ OpenAiCompatibleVendorConfig
500
+ ]);
501
+ const AIProviderModel = z.object({
502
+ id: z.string(),
503
+ name: z.string(),
504
+ type: z.enum(AIProviderModelType)
505
+ });
506
+ const AIProviderWithoutSensitiveData = z.object({
507
+ id: z.string(),
508
+ name: z.string(),
509
+ provider: z.enum(AIProviderName),
510
+ config: AIProviderConfig,
511
+ enabledForChat: z.boolean()
512
+ });
513
+ const ProjectAIProvider = z.object({
514
+ provider: z.enum(AIProviderName),
515
+ name: z.string(),
516
+ enabledForChat: z.boolean(),
517
+ keys: z.array(z.object({
518
+ id: z.string(),
519
+ name: z.string()
520
+ }))
521
+ });
522
+ const GetProviderConfigResponse = z.object({
523
+ provider: z.enum(AIProviderName),
524
+ configId: z.string(),
525
+ config: AIProviderConfig,
526
+ auth: AIProviderAuthConfig,
527
+ platformId: z.string()
528
+ });
529
+ function splitCloudflareGatewayModelId(modelId) {
530
+ const slashIndex = modelId.indexOf("/");
531
+ if (slashIndex === -1) return {
532
+ provider: void 0,
533
+ model: modelId,
534
+ publisher: void 0
535
+ };
536
+ const provider = modelId.substring(0, slashIndex).trim().toLowerCase();
537
+ const rest = modelId.substring(slashIndex + 1);
538
+ if (provider === "google-vertex-ai") {
539
+ const secondSlashIndex = rest.indexOf("/");
540
+ if (secondSlashIndex === -1) return {
541
+ provider: void 0,
542
+ model: modelId,
543
+ publisher: void 0
544
+ };
545
+ return {
546
+ provider: "google-vertex-ai",
547
+ publisher: rest.substring(0, secondSlashIndex),
548
+ model: rest.substring(secondSlashIndex + 1)
549
+ };
550
+ }
551
+ return {
552
+ provider,
553
+ model: rest,
554
+ publisher: void 0
555
+ };
556
+ }
557
+ function getEffectiveProviderAndModel({ provider, model }) {
558
+ if (provider !== AIProviderName.CLOUDFLARE_GATEWAY || !model) return {
559
+ provider,
560
+ model
561
+ };
562
+ const split = splitCloudflareGatewayModelId(model);
563
+ const mapped = CF_GATEWAY_SUBMODEL_TO_PROVIDER[(split.provider ?? "").trim().toLowerCase()];
564
+ if (!mapped) return {
565
+ provider,
566
+ model
567
+ };
568
+ return {
569
+ provider: mapped,
570
+ model: split.model
571
+ };
572
+ }
573
+ const CF_GATEWAY_SUBMODEL_TO_PROVIDER = {
574
+ openai: AIProviderName.OPENAI,
575
+ anthropic: AIProviderName.ANTHROPIC,
576
+ "google-ai-studio": AIProviderName.GOOGLE,
577
+ "google-vertex-ai": AIProviderName.GOOGLE
578
+ };
579
+ const OPENAI_CHAT_MODELS = [
580
+ "gpt-5.5",
581
+ "gpt-5.4-mini",
582
+ "gpt-5.4-nano",
583
+ "gpt-4.1",
584
+ "gpt-4.1-mini"
585
+ ];
586
+ const ANTHROPIC_CHAT_MODELS = [
587
+ "claude-sonnet-4-6",
588
+ "claude-opus-4-7",
589
+ "claude-haiku-4-5"
590
+ ];
591
+ const ANTHROPIC_OPENROUTER_CHAT_MODELS = [
592
+ "claude-sonnet-4.6",
593
+ "claude-opus-4.7",
594
+ "claude-opus-4.8",
595
+ "claude-haiku-4.5"
596
+ ];
597
+ const GOOGLE_CHAT_MODELS = [
598
+ "gemini-2.5-pro",
599
+ "gemini-2.5-flash",
600
+ "gemini-3.7-flash",
601
+ "gemini-3.1-pro-preview",
602
+ "gemini-3-flash-preview"
603
+ ];
604
+ const X_AI_OPENROUTER_CHAT_MODELS = ["grok-4.20"];
605
+ const REASONING_OPTIONAL_CHAT_MODELS = ANTHROPIC_OPENROUTER_CHAT_MODELS.map((model) => `${AIProviderName.ANTHROPIC}/${model}`);
606
+ const ALLOWED_CHAT_MODELS_BY_PROVIDER = {
607
+ [AIProviderName.OPENAI]: OPENAI_CHAT_MODELS,
608
+ [AIProviderName.ANTHROPIC]: ANTHROPIC_CHAT_MODELS,
609
+ [AIProviderName.GOOGLE]: GOOGLE_CHAT_MODELS,
610
+ [AIProviderName.VERTEX]: GOOGLE_CHAT_MODELS,
611
+ [AIProviderName.ACTIVEPIECES]: [
612
+ ...ANTHROPIC_OPENROUTER_CHAT_MODELS.map((m) => `${AIProviderName.ANTHROPIC}/${m}`),
613
+ ...OPENAI_CHAT_MODELS.map((m) => `${AIProviderName.OPENAI}/${m}`),
614
+ ...GOOGLE_CHAT_MODELS.map((m) => `${AIProviderName.GOOGLE}/${m}`),
615
+ ...X_AI_OPENROUTER_CHAT_MODELS.map((m) => `x-ai/${m}`)
616
+ ]
617
+ };
618
+ const DEFAULT_MAX_CONTEXT_TOKENS = 128e3;
619
+ const PROVIDER_MAX_CONTEXT_TOKENS = {
620
+ [AIProviderName.OPENAI]: 128e3,
621
+ [AIProviderName.ANTHROPIC]: 2e5,
622
+ [AIProviderName.GOOGLE]: 1048576,
623
+ [AIProviderName.BEDROCK]: 2e5,
624
+ [AIProviderName.VERTEX]: 1048576,
625
+ [AIProviderName.AZURE]: 128e3,
626
+ [AIProviderName.OPENROUTER]: 128e3,
627
+ [AIProviderName.ACTIVEPIECES]: 2e5,
628
+ [AIProviderName.MISTRAL]: 128e3
629
+ };
630
+ function getMaxContextTokens({ provider }) {
631
+ if (!provider) return DEFAULT_MAX_CONTEXT_TOKENS;
632
+ return PROVIDER_MAX_CONTEXT_TOKENS[provider] ?? DEFAULT_MAX_CONTEXT_TOKENS;
633
+ }
634
+ const DEFAULT_EMBEDDING_MODELS = {
635
+ [AIProviderName.OPENAI]: "text-embedding-3-small",
636
+ [AIProviderName.GOOGLE]: "text-embedding-004",
637
+ [AIProviderName.AZURE]: "text-embedding-3-small",
638
+ [AIProviderName.ACTIVEPIECES]: "text-embedding-3-small",
639
+ [AIProviderName.OPENROUTER]: "openai/text-embedding-3-small"
640
+ };
641
+ const WEB_SEARCH_MODE_BY_PROVIDER = {
642
+ [AIProviderName.ANTHROPIC]: "native",
643
+ [AIProviderName.GOOGLE]: "native",
644
+ [AIProviderName.OPENROUTER]: "plugin",
645
+ [AIProviderName.ACTIVEPIECES]: "plugin"
646
+ };
647
+ const NO_IMAGE_GENERATION_PROVIDERS = new Set([
648
+ AIProviderName.ANTHROPIC,
649
+ AIProviderName.MISTRAL,
650
+ AIProviderName.XAI,
651
+ AIProviderName.DEEPSEEK,
652
+ AIProviderName.ZAI,
653
+ AIProviderName.QWEN,
654
+ AIProviderName.MINIMAX,
655
+ AIProviderName.MOONSHOT
656
+ ]);
657
+ const OPENAI_COMPATIBLE_VENDOR_BASE_URLS = {
658
+ [AIProviderName.XAI]: "https://api.x.ai/v1",
659
+ [AIProviderName.DEEPSEEK]: "https://api.deepseek.com/v1",
660
+ [AIProviderName.ZAI]: "https://api.z.ai/api/paas/v4",
661
+ [AIProviderName.QWEN]: "https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
662
+ [AIProviderName.MINIMAX]: "https://api.minimax.io/v1",
663
+ [AIProviderName.MOONSHOT]: "https://api.moonshot.ai/v1"
664
+ };
665
+ function buildProviderCapabilities(provider) {
666
+ return {
667
+ chatModels: ALLOWED_CHAT_MODELS_BY_PROVIDER[provider],
668
+ maxContextTokens: getMaxContextTokens({ provider }),
669
+ defaultEmbeddingModel: DEFAULT_EMBEDDING_MODELS[provider],
670
+ supportsEmbedding: DEFAULT_EMBEDDING_MODELS[provider] !== void 0,
671
+ supportsImageGeneration: !NO_IMAGE_GENERATION_PROVIDERS.has(provider),
672
+ webSearch: WEB_SEARCH_MODE_BY_PROVIDER[provider]
673
+ };
674
+ }
675
+ const ACTIVEPIECES_CHAT_TIERS = [
676
+ {
677
+ id: "fast",
678
+ label: "Fast",
679
+ modelId: "anthropic/claude-haiku-4.5",
680
+ nativeModelId: "claude-haiku-4-5",
681
+ thinkingBudget: 5e3,
682
+ creditWeight: 2
683
+ },
684
+ {
685
+ id: "smart",
686
+ label: "Expert",
687
+ modelId: "anthropic/claude-sonnet-4.6",
688
+ nativeModelId: "claude-sonnet-4-6",
689
+ thinkingBudget: 1e4,
690
+ creditWeight: 10
691
+ },
692
+ {
693
+ id: "premium",
694
+ label: "Heavy",
695
+ modelId: "anthropic/claude-opus-4.8",
696
+ nativeModelId: "claude-opus-4-7",
697
+ thinkingBudget: 2e4,
698
+ creditWeight: 20
699
+ }
700
+ ];
701
+ const DEFAULT_CHAT_TIER_ID = "smart";
702
+ const AI_PROVIDER_CAPABILITIES = {
703
+ [AIProviderName.OPENAI]: buildProviderCapabilities(AIProviderName.OPENAI),
704
+ [AIProviderName.ANTHROPIC]: buildProviderCapabilities(AIProviderName.ANTHROPIC),
705
+ [AIProviderName.OPENROUTER]: buildProviderCapabilities(AIProviderName.OPENROUTER),
706
+ [AIProviderName.AZURE]: buildProviderCapabilities(AIProviderName.AZURE),
707
+ [AIProviderName.GOOGLE]: buildProviderCapabilities(AIProviderName.GOOGLE),
708
+ [AIProviderName.CLOUDFLARE_GATEWAY]: buildProviderCapabilities(AIProviderName.CLOUDFLARE_GATEWAY),
709
+ [AIProviderName.CUSTOM]: buildProviderCapabilities(AIProviderName.CUSTOM),
710
+ [AIProviderName.BEDROCK]: buildProviderCapabilities(AIProviderName.BEDROCK),
711
+ [AIProviderName.VERTEX]: buildProviderCapabilities(AIProviderName.VERTEX),
712
+ [AIProviderName.MISTRAL]: buildProviderCapabilities(AIProviderName.MISTRAL),
713
+ [AIProviderName.ACTIVEPIECES]: buildProviderCapabilities(AIProviderName.ACTIVEPIECES),
714
+ [AIProviderName.XAI]: buildProviderCapabilities(AIProviderName.XAI),
715
+ [AIProviderName.DEEPSEEK]: buildProviderCapabilities(AIProviderName.DEEPSEEK),
716
+ [AIProviderName.ZAI]: buildProviderCapabilities(AIProviderName.ZAI),
717
+ [AIProviderName.QWEN]: buildProviderCapabilities(AIProviderName.QWEN),
718
+ [AIProviderName.MINIMAX]: buildProviderCapabilities(AIProviderName.MINIMAX),
719
+ [AIProviderName.MOONSHOT]: buildProviderCapabilities(AIProviderName.MOONSHOT)
720
+ };
721
+
722
+ //#endregion
723
+ //#region upstream/core-piece-types/lib/forms.ts
724
+ const FileResponseInterfaceV1 = z.object({
725
+ base64Url: z.string(),
726
+ fileName: z.string(),
727
+ extension: z.optional(z.string())
728
+ });
729
+ const FileResponseInterfaceV2 = z.object({
730
+ mimeType: z.string(),
731
+ url: z.string(),
732
+ fileName: z.optional(z.string())
733
+ });
734
+ const FileResponseInterface = z.union([FileResponseInterfaceV1, FileResponseInterfaceV2]);
735
+ let HumanInputFormResultTypes = /* @__PURE__ */ function(HumanInputFormResultTypes) {
736
+ HumanInputFormResultTypes["FILE"] = "file";
737
+ HumanInputFormResultTypes["MARKDOWN"] = "markdown";
738
+ return HumanInputFormResultTypes;
739
+ }({});
740
+ function createKeyForFormInput(displayName) {
741
+ /**We do this because react form inputs must not contain quotes */
742
+ return displayName.toLowerCase().replace(/\s+(\w)/g, (_, letter) => letter.toUpperCase()).replace(/^(.)/, (letter) => letter.toLowerCase()).replaceAll(/[\\"''\n\r\t]/g, "");
743
+ }
744
+ const HumanInputFormResult = z.union([z.object({
745
+ type: z.literal(HumanInputFormResultTypes.FILE),
746
+ value: FileResponseInterface
747
+ }), z.object({
748
+ type: z.literal(HumanInputFormResultTypes.MARKDOWN),
749
+ value: z.string(),
750
+ files: z.optional(z.array(FileResponseInterface))
751
+ })]);
752
+ const ChatFormResponse = z.object({
753
+ sessionId: z.string(),
754
+ message: z.string(),
755
+ files: z.optional(z.array(z.string()))
756
+ });
757
+
758
+ //#endregion
759
+ //#region upstream/core-piece-types/lib/tables.ts
760
+ let FieldType = /* @__PURE__ */ function(FieldType) {
761
+ FieldType["TEXT"] = "TEXT";
762
+ FieldType["NUMBER"] = "NUMBER";
763
+ FieldType["DATE"] = "DATE";
764
+ FieldType["DATETIME"] = "DATETIME";
765
+ FieldType["STATIC_DROPDOWN"] = "STATIC_DROPDOWN";
766
+ return FieldType;
767
+ }({});
768
+ let TableAutomationTrigger = /* @__PURE__ */ function(TableAutomationTrigger) {
769
+ TableAutomationTrigger["ON_NEW_RECORD"] = "ON_NEW_RECORD";
770
+ TableAutomationTrigger["ON_UPDATE_RECORD"] = "ON_UPDATE_RECORD";
771
+ return TableAutomationTrigger;
772
+ }({});
773
+ let TableAutomationStatus = /* @__PURE__ */ function(TableAutomationStatus) {
774
+ TableAutomationStatus["ENABLED"] = "ENABLED";
775
+ TableAutomationStatus["DISABLED"] = "DISABLED";
776
+ return TableAutomationStatus;
777
+ }({});
778
+ let TableWebhookEventType = /* @__PURE__ */ function(TableWebhookEventType) {
779
+ TableWebhookEventType["RECORD_CREATED"] = "RECORD_CREATED";
780
+ TableWebhookEventType["RECORD_UPDATED"] = "RECORD_UPDATED";
781
+ TableWebhookEventType["RECORD_DELETED"] = "RECORD_DELETED";
782
+ return TableWebhookEventType;
783
+ }({});
784
+ let FilterOperator = /* @__PURE__ */ function(FilterOperator) {
785
+ FilterOperator["EQ"] = "eq";
786
+ FilterOperator["NEQ"] = "neq";
787
+ FilterOperator["GT"] = "gt";
788
+ FilterOperator["GTE"] = "gte";
789
+ FilterOperator["LT"] = "lt";
790
+ FilterOperator["LTE"] = "lte";
791
+ FilterOperator["CO"] = "co";
792
+ FilterOperator["EXISTS"] = "exists";
793
+ FilterOperator["NOT_EXISTS"] = "not_exists";
794
+ return FilterOperator;
795
+ }({});
796
+ const Field = z.union([z.object({
797
+ ...BaseModelSchema,
798
+ name: z.string(),
799
+ externalId: z.string(),
800
+ type: z.literal(FieldType.STATIC_DROPDOWN),
801
+ tableId: z.string(),
802
+ projectId: z.string(),
803
+ data: z.object({ options: z.array(z.object({ value: z.string() })) })
804
+ }), z.object({
805
+ ...BaseModelSchema,
806
+ name: z.string(),
807
+ externalId: z.string(),
808
+ type: z.union([
809
+ z.literal(FieldType.TEXT),
810
+ z.literal(FieldType.NUMBER),
811
+ z.literal(FieldType.DATE),
812
+ z.literal(FieldType.DATETIME)
813
+ ]),
814
+ tableId: z.string(),
815
+ projectId: z.string()
816
+ })]);
817
+ const Table = z.object({
818
+ ...BaseModelSchema,
819
+ name: z.string(),
820
+ folderId: Nullable(z.string()),
821
+ projectId: z.string(),
822
+ externalId: z.string(),
823
+ status: NullableEnum(TableAutomationStatus),
824
+ trigger: NullableEnum(TableAutomationTrigger)
825
+ });
826
+ const PopulatedRecord = z.object({
827
+ ...BaseModelSchema,
828
+ tableId: z.string(),
829
+ projectId: z.string(),
830
+ cells: z.record(z.string(), z.object({
831
+ updated: z.string(),
832
+ created: z.string(),
833
+ value: z.unknown(),
834
+ fieldName: z.string()
835
+ }))
836
+ });
837
+ const CreateTableWebhookRequest = z.object({
838
+ events: z.array(z.enum(TableWebhookEventType)),
839
+ webhookUrl: z.string(),
840
+ flowId: z.string()
841
+ });
842
+ const ExportTableResponse = z.object({
843
+ fields: z.array(z.object({
844
+ id: z.string(),
845
+ name: z.string()
846
+ })),
847
+ rows: z.array(z.record(z.string(), z.string())),
848
+ name: z.string()
849
+ });
850
+ const ListTablesRequest = z.object({
851
+ projectId: z.string(),
852
+ limit: z.optional(z.coerce.number()),
853
+ cursor: z.optional(z.string()),
854
+ name: z.optional(z.string()),
855
+ externalIds: OptionalArrayFromQuery(z.string()),
856
+ folderId: z.optional(z.string()),
857
+ folderIds: OptionalArrayFromQuery(z.string())
858
+ });
859
+ const CreateRecordsRequest = z.object({
860
+ records: z.array(z.array(z.object({
861
+ fieldId: z.string(),
862
+ value: coerceToString()
863
+ }))),
864
+ tableId: z.string()
865
+ });
866
+ const UpdateRecordRequest = z.object({
867
+ cells: z.optional(z.array(z.object({
868
+ fieldId: z.string(),
869
+ value: coerceToString()
870
+ }))),
871
+ tableId: z.string(),
872
+ agentUpdate: z.optional(z.boolean())
873
+ });
874
+ const Filter = z.discriminatedUnion("operator", [
875
+ valueFilter(FilterOperator.EQ),
876
+ valueFilter(FilterOperator.NEQ),
877
+ valueFilter(FilterOperator.GT),
878
+ valueFilter(FilterOperator.GTE),
879
+ valueFilter(FilterOperator.LT),
880
+ valueFilter(FilterOperator.LTE),
881
+ valueFilter(FilterOperator.CO),
882
+ existenceFilter(FilterOperator.EXISTS),
883
+ existenceFilter(FilterOperator.NOT_EXISTS)
884
+ ]);
885
+ const ListRecordsRequest = z.object({
886
+ tableId: z.string(),
887
+ limit: z.optional(z.coerce.number()),
888
+ cursor: z.optional(z.string()),
889
+ filters: OptionalArrayFromQuery(Filter)
890
+ });
891
+ const StaticDropdownEmptyOption = {
892
+ label: "",
893
+ value: ""
894
+ };
895
+ function coerceToString() {
896
+ return z.pipe(z.transform((v) => v === null || v === void 0 ? v : String(v)), z.nullable(z.string()));
897
+ }
898
+ function valueFilter(op) {
899
+ return z.object({
900
+ fieldId: z.string(),
901
+ operator: z.literal(op),
902
+ value: z.string()
903
+ });
904
+ }
905
+ function existenceFilter(op) {
906
+ return z.object({
907
+ fieldId: z.string(),
908
+ operator: z.literal(op)
909
+ });
910
+ }
911
+
912
+ //#endregion
913
+ //#region upstream/core-piece-types/lib/flow-contracts.ts
914
+ let FlowStatus = /* @__PURE__ */ function(FlowStatus) {
915
+ FlowStatus["ENABLED"] = "ENABLED";
916
+ FlowStatus["DISABLED"] = "DISABLED";
917
+ return FlowStatus;
918
+ }({});
919
+ let FlowTriggerType = /* @__PURE__ */ function(FlowTriggerType) {
920
+ FlowTriggerType["EMPTY"] = "EMPTY";
921
+ FlowTriggerType["PIECE"] = "PIECE_TRIGGER";
922
+ return FlowTriggerType;
923
+ }({});
924
+ const StopResponse = z.object({
925
+ status: z.optional(z.number()),
926
+ body: z.optional(z.unknown()),
927
+ headers: z.optional(z.record(z.string(), z.string()))
928
+ });
929
+ const Project = z.object({
930
+ ...BaseModelSchema,
931
+ deleted: Nullable(DateOrString),
932
+ ownerId: z.string(),
933
+ displayName: z.string(),
934
+ platformId: z.string(),
935
+ externalId: Nullable(z.string())
936
+ });
937
+ const USE_DRAFT_QUERY_PARAM_NAME = "useDraft";
938
+ const PARENT_RUN_ID_HEADER = "ap-parent-run-id";
939
+ const FAIL_PARENT_ON_FAILURE_HEADER = "ap-fail-parent-on-failure";
940
+ const RAW_PAYLOAD_HEADER = "ap-raw-payload";
941
+
942
+ //#endregion
943
+ //#region upstream/core-piece-types/lib/mcp-piece.ts
944
+ let McpPropertyType = /* @__PURE__ */ function(McpPropertyType) {
945
+ McpPropertyType["TEXT"] = "Text";
946
+ McpPropertyType["BOOLEAN"] = "Boolean";
947
+ McpPropertyType["DATE"] = "Date";
948
+ McpPropertyType["NUMBER"] = "Number";
949
+ McpPropertyType["ARRAY"] = "Array";
950
+ McpPropertyType["OBJECT"] = "Object";
951
+ return McpPropertyType;
952
+ }({});
953
+ const McpProperty = z.object({
954
+ name: z.string(),
955
+ description: z.optional(z.string()),
956
+ type: z.string(),
957
+ required: z.boolean()
958
+ });
959
+ const McpTrigger = z.object({
960
+ pieceName: z.string(),
961
+ triggerName: z.string(),
962
+ input: z.object({
963
+ toolName: z.string(),
964
+ toolDescription: z.string(),
965
+ inputSchema: z.array(McpProperty),
966
+ returnsResponse: z.boolean()
967
+ })
968
+ });
969
+
970
+ //#endregion
971
+ //#region upstream/core-piece-types/lib/engine-tools.ts
972
+ function normalizeToolOutputToExecuteResponse(raw) {
973
+ if (raw === null || typeof raw !== "object") return {
974
+ status: ExecutionToolStatus.FAILED,
975
+ output: raw,
976
+ resolvedInput: {},
977
+ errorMessage: "Invalid tool output"
978
+ };
979
+ const o = raw;
980
+ if (o["status"] === ExecutionToolStatus.SUCCESS || o["status"] === ExecutionToolStatus.FAILED) return {
981
+ status: o["status"],
982
+ output: o["output"],
983
+ resolvedInput: o["resolvedInput"] ?? {},
984
+ errorMessage: o["errorMessage"]
985
+ };
986
+ const isError = o["isError"] === true;
987
+ let output = o["structuredContent"];
988
+ if (output === void 0 && Array.isArray(o["content"])) {
989
+ const parts = o["content"].map((c) => c?.text).filter(Boolean);
990
+ output = parts.length === 1 ? parts[0] : parts.length ? { text: parts.join("") } : o["content"];
991
+ }
992
+ if (output === void 0) output = o;
993
+ return {
994
+ status: isError ? ExecutionToolStatus.FAILED : ExecutionToolStatus.SUCCESS,
995
+ output,
996
+ resolvedInput: {},
997
+ errorMessage: isError ? o["content"]?.[0]?.text ?? o["message"] ?? "Tool failed" : void 0
998
+ };
999
+ }
1000
+
1001
+ //#endregion
1002
+ //#region upstream/framework/lib/property/util.ts
1003
+ function buildSchema(props, auth, requireAuth = true) {
1004
+ const entries = Object.entries(props);
1005
+ const propsSchema = {};
1006
+ for (const [name, property] of entries) {
1007
+ switch (property.type) {
1008
+ case PropertyType.MARKDOWN:
1009
+ propsSchema[name] = z.optional(z.union([
1010
+ z.null(),
1011
+ z.undefined(),
1012
+ z.never(),
1013
+ z.unknown()
1014
+ ]));
1015
+ break;
1016
+ case PropertyType.DATE_TIME:
1017
+ case PropertyType.SHORT_TEXT:
1018
+ case PropertyType.LONG_TEXT:
1019
+ case PropertyType.RICH_TEXT:
1020
+ case PropertyType.COLOR:
1021
+ case PropertyType.FILE:
1022
+ propsSchema[name] = property.required ? z.string().check(z.minLength(1)) : z.string();
1023
+ break;
1024
+ case PropertyType.CHECKBOX:
1025
+ propsSchema[name] = z.union([z.boolean(), z.string()]);
1026
+ break;
1027
+ case PropertyType.NUMBER:
1028
+ propsSchema[name] = z.union([property.required ? z.string().check(z.minLength(1)) : z.string(), z.number()]);
1029
+ break;
1030
+ case PropertyType.STATIC_DROPDOWN:
1031
+ case PropertyType.DROPDOWN:
1032
+ propsSchema[name] = z.unknown().check(z.refine((val) => val !== null && val !== void 0, { error: "Value must not be null or undefined" }));
1033
+ break;
1034
+ case PropertyType.SECRET_TEXT:
1035
+ propsSchema[name] = property.required ? z.string().check(z.minLength(1)) : z.string();
1036
+ break;
1037
+ case PropertyType.BASIC_AUTH:
1038
+ case PropertyType.CUSTOM_AUTH:
1039
+ case PropertyType.OAUTH2: break;
1040
+ case PropertyType.ARRAY: {
1041
+ const arrayItemSchema = isNil(property.properties) ? property.required ? z.string().check(z.minLength(1)) : z.string() : buildSchema(property.properties, void 0);
1042
+ propsSchema[name] = z.union([
1043
+ property.required ? z.array(arrayItemSchema).check(z.minLength(1)) : z.array(arrayItemSchema),
1044
+ z.record(z.string(), z.unknown()),
1045
+ property.required ? z.string().check(z.minLength(1)) : z.string()
1046
+ ]);
1047
+ break;
1048
+ }
1049
+ case PropertyType.OBJECT:
1050
+ propsSchema[name] = z.union([z.record(z.string(), z.any()), property.required ? z.string().check(z.minLength(1)) : z.string()]);
1051
+ break;
1052
+ case PropertyType.DATE_RANGE:
1053
+ propsSchema[name] = z.union([z.record(z.string(), z.any()), z.string()]);
1054
+ break;
1055
+ case PropertyType.JSON:
1056
+ propsSchema[name] = z.union([
1057
+ z.record(z.string(), z.any()),
1058
+ z.array(z.any()),
1059
+ property.required ? z.string().check(z.minLength(1)) : z.string()
1060
+ ]);
1061
+ break;
1062
+ case PropertyType.MULTI_SELECT_DROPDOWN:
1063
+ case PropertyType.STATIC_MULTI_SELECT_DROPDOWN:
1064
+ propsSchema[name] = z.union([property.required ? z.array(z.any()).check(z.minLength(1)) : z.array(z.any()), property.required ? z.string().check(z.minLength(1)) : z.string()]);
1065
+ break;
1066
+ case PropertyType.DYNAMIC:
1067
+ propsSchema[name] = z.record(z.string(), z.any());
1068
+ break;
1069
+ case PropertyType.CUSTOM:
1070
+ propsSchema[name] = z.unknown();
1071
+ break;
1072
+ }
1073
+ if (!property.required && property.type !== PropertyType.ARRAY) propsSchema[name] = z.optional(z.union(isEmpty(propsSchema[name]) ? [
1074
+ z.any(),
1075
+ z.null(),
1076
+ z.undefined()
1077
+ ] : [
1078
+ propsSchema[name],
1079
+ z.null(),
1080
+ z.undefined()
1081
+ ]));
1082
+ }
1083
+ if (auth && requireAuth) propsSchema[AUTHENTICATION_PROPERTY_NAME] = z.string().check(z.minLength(1));
1084
+ return z.object(propsSchema);
1085
+ }
1086
+ const piecePropertiesUtils = { buildSchema };
1087
+
1088
+ //#endregion
1089
+ //#region upstream/framework/lib/property/index.ts
1090
+ const PieceProperty = z.union([InputProperty, PieceAuthProperty]);
1091
+ const PiecePropertyMap = z.record(z.string(), PieceProperty);
1092
+ const InputPropertyMap = z.record(z.string(), InputProperty);
1093
+
1094
+ //#endregion
1095
+ //#region upstream/framework/lib/trigger/trigger.ts
1096
+ const DEDUPE_KEY_PROPERTY = "_dedupe_key";
1097
+ let WebhookRenewStrategy = /* @__PURE__ */ function(WebhookRenewStrategy) {
1098
+ WebhookRenewStrategy["CRON"] = "CRON";
1099
+ WebhookRenewStrategy["NONE"] = "NONE";
1100
+ return WebhookRenewStrategy;
1101
+ }({});
1102
+ const WebhookRenewConfiguration = z.union([z.object({
1103
+ strategy: z.literal(WebhookRenewStrategy.CRON),
1104
+ cronExpression: z.string()
1105
+ }), z.object({ strategy: z.literal(WebhookRenewStrategy.NONE) })]);
1106
+ var ITrigger = class {
1107
+ constructor(name, displayName, description, requireAuth, props, type, handshakeConfiguration, onHandshake, renewConfiguration, onRenew, onEnable, onDisable, onStart, run, test, sampleData, testStrategy, outputSchema, aiMetadata, classification, propertyGroups) {
1108
+ this.name = name;
1109
+ this.displayName = displayName;
1110
+ this.description = description;
1111
+ this.requireAuth = requireAuth;
1112
+ this.props = props;
1113
+ this.type = type;
1114
+ this.handshakeConfiguration = handshakeConfiguration;
1115
+ this.onHandshake = onHandshake;
1116
+ this.renewConfiguration = renewConfiguration;
1117
+ this.onRenew = onRenew;
1118
+ this.onEnable = onEnable;
1119
+ this.onDisable = onDisable;
1120
+ this.onStart = onStart;
1121
+ this.run = run;
1122
+ this.test = test;
1123
+ this.sampleData = sampleData;
1124
+ this.testStrategy = testStrategy;
1125
+ this.outputSchema = outputSchema;
1126
+ this.aiMetadata = aiMetadata;
1127
+ this.classification = classification;
1128
+ this.propertyGroups = propertyGroups;
1129
+ }
1130
+ };
1131
+ const createTrigger = (params) => {
1132
+ switch (params.type) {
1133
+ case TriggerStrategy.WEBHOOK: return new ITrigger(params.name, params.displayName, params.description, params.requireAuth ?? true, params.props, params.type, params.handshakeConfiguration ?? { strategy: WebhookHandshakeStrategy.NONE }, params.onHandshake ?? (async () => ({ status: 200 })), params.renewConfiguration ?? { strategy: WebhookRenewStrategy.NONE }, params.onRenew ?? (async () => Promise.resolve()), params.onEnable, params.onDisable, params.onStart ?? (async () => Promise.resolve()), params.run, params.test ?? (() => Promise.resolve([params.sampleData])), params.sampleData, params.test ? TriggerTestStrategy.TEST_FUNCTION : TriggerTestStrategy.SIMULATION, params.outputSchema, params.aiMetadata, params.classification, params.propertyGroups);
1134
+ case TriggerStrategy.POLLING: return new ITrigger(params.name, params.displayName, params.description, params.requireAuth ?? true, params.props, params.type, { strategy: WebhookHandshakeStrategy.NONE }, async () => ({ status: 200 }), { strategy: WebhookRenewStrategy.NONE }, async () => Promise.resolve(), params.onEnable, params.onDisable, params.onStart ?? (async () => Promise.resolve()), params.run, params.test ?? (() => Promise.resolve([params.sampleData])), params.sampleData, TriggerTestStrategy.TEST_FUNCTION, params.outputSchema, params.aiMetadata, params.classification, params.propertyGroups);
1135
+ case TriggerStrategy.MANUAL: return new ITrigger(params.name, params.displayName, params.description, params.requireAuth ?? true, params.props, params.type, { strategy: WebhookHandshakeStrategy.NONE }, async () => ({ status: 200 }), { strategy: WebhookRenewStrategy.NONE }, async () => Promise.resolve(), params.onEnable, params.onDisable, params.onStart ?? (async () => Promise.resolve()), params.run, params.test ?? (() => Promise.resolve([params.sampleData])), params.sampleData, TriggerTestStrategy.TEST_FUNCTION, params.outputSchema, params.aiMetadata, params.classification, params.propertyGroups);
1136
+ case TriggerStrategy.APP_WEBHOOK: return new ITrigger(params.name, params.displayName, params.description, params.requireAuth ?? true, params.props, params.type, { strategy: WebhookHandshakeStrategy.NONE }, async () => ({ status: 200 }), { strategy: WebhookRenewStrategy.NONE }, async () => Promise.resolve(), params.onEnable, params.onDisable, params.onStart ?? (async () => Promise.resolve()), params.run, params.test ?? (() => Promise.resolve([params.sampleData])), params.sampleData, isNil(params.sampleData) && isNil(params.test) ? TriggerTestStrategy.SIMULATION : TriggerTestStrategy.TEST_FUNCTION, params.outputSchema, params.aiMetadata, params.classification, params.propertyGroups);
1137
+ }
1138
+ };
1139
+
1140
+ //#endregion
1141
+ //#region upstream/framework/lib/context/index.ts
1142
+ var PieceServerContextError = class extends Error {
1143
+ constructor(message) {
1144
+ super(message);
1145
+ this.name = "PieceServerContextError";
1146
+ }
1147
+ };
1148
+ function isPieceServerContextError(error) {
1149
+ return error instanceof Error && error.name === "PieceServerContextError";
1150
+ }
1151
+ let StoreScope = /* @__PURE__ */ function(StoreScope) {
1152
+ StoreScope["PROJECT"] = "COLLECTION";
1153
+ StoreScope["FLOW"] = "FLOW";
1154
+ return StoreScope;
1155
+ }({});
1156
+
1157
+ //#endregion
1158
+ //#region upstream/framework/lib/context/versioning.ts
1159
+ let ContextVersion = /* @__PURE__ */ function(ContextVersion) {
1160
+ ContextVersion["V1"] = "1";
1161
+ ContextVersion["V2"] = "2";
1162
+ return ContextVersion;
1163
+ }({});
1164
+ const LATEST_CONTEXT_VERSION = ContextVersion.V2;
1165
+ const MINIMUM_SUPPORTED_RELEASE_AFTER_LATEST_CONTEXT_VERSION = "0.82.0";
1166
+ const backwardCompatabilityContextUtils = { makeActionContextBackwardCompatible({ context, contextVersion }) {
1167
+ switch (contextVersion) {
1168
+ case ContextVersion.V2: return context;
1169
+ case ContextVersion.V1: return addLegacyMethods({ context });
1170
+ case void 0: return addLegacyMethodsAndServerUrl({ context });
1171
+ }
1172
+ } };
1173
+ function addLegacyMethods({ context }) {
1174
+ return {
1175
+ ...context,
1176
+ generateResumeUrl: buildLegacyGenerateResumeUrl({ context }),
1177
+ run: {
1178
+ ...context.run,
1179
+ pause: buildLegacyPauseHook({ context })
1180
+ }
1181
+ };
1182
+ }
1183
+ function addLegacyMethodsAndServerUrl({ context }) {
1184
+ return {
1185
+ ...addLegacyMethods({ context }),
1186
+ serverUrl: context.server.publicUrl
1187
+ };
1188
+ }
1189
+ /**
1190
+ * @deprecated Since 2026-04-12. Remove after 2026-10-12 once all pieces migrate to createWaitpoint/waitForWaitpoint.
1191
+ */
1192
+ function buildLegacyPauseHook({ context }) {
1193
+ return (req) => {
1194
+ const type = req.pauseMetadata.type === PauseType.DELAY ? "DELAY" : "WEBHOOK";
1195
+ const responseToSend = req.pauseMetadata.type === PauseType.WEBHOOK ? req.pauseMetadata.response : void 0;
1196
+ const resumeDateTime = req.pauseMetadata.type === PauseType.DELAY ? req.pauseMetadata.resumeDateTime : void 0;
1197
+ context.run.createWaitpoint({
1198
+ type,
1199
+ version: "V0",
1200
+ resumeDateTime,
1201
+ responseToSend
1202
+ }).catch((e) => {
1203
+ console.error("[buildLegacyPauseHook] Failed to create waitpoint", e);
1204
+ process.exit(1);
1205
+ });
1206
+ context.run.waitForWaitpoint("");
1207
+ };
1208
+ }
1209
+ /**
1210
+ * @deprecated Since 2026-04-12. Remove after 2026-10-12 once all pieces migrate to createWaitpoint/waitForWaitpoint.
1211
+ */
1212
+ function buildLegacyGenerateResumeUrl({ context }) {
1213
+ return (params) => {
1214
+ const randomId = Math.random().toString(36).substring(2);
1215
+ const url = new URL(`${context.server.publicUrl}v1/flow-runs/${context.run.id}/requests/${randomId}${params.sync ? "/sync" : ""}`);
1216
+ url.search = new URLSearchParams(params.queryParams).toString();
1217
+ return url.toString();
1218
+ };
1219
+ }
1220
+
1221
+ //#endregion
1222
+ //#region upstream/framework/lib/piece.ts
1223
+ var Piece = class {
1224
+ _actions = {};
1225
+ _triggers = {};
1226
+ getContextInfo = () => ({ version: LATEST_CONTEXT_VERSION });
1227
+ constructor(displayName, logoUrl, authors, events, actions, triggers, categories, auth, minimumSupportedRelease = MINIMUM_SUPPORTED_RELEASE_AFTER_LATEST_CONTEXT_VERSION, maximumSupportedRelease, description = "", deprecated) {
1228
+ this.displayName = displayName;
1229
+ this.logoUrl = logoUrl;
1230
+ this.authors = authors;
1231
+ this.events = events;
1232
+ this.categories = categories;
1233
+ this.auth = auth;
1234
+ this.minimumSupportedRelease = minimumSupportedRelease;
1235
+ this.maximumSupportedRelease = maximumSupportedRelease;
1236
+ this.description = description;
1237
+ this.deprecated = deprecated;
1238
+ if (!isValidSimpleSemver(minimumSupportedRelease) || isSemverLessThan(minimumSupportedRelease, "0.82.0")) this.minimumSupportedRelease = MINIMUM_SUPPORTED_RELEASE_AFTER_LATEST_CONTEXT_VERSION;
1239
+ actions.forEach((action) => this._actions[action.name] = action);
1240
+ triggers.forEach((trigger) => this._triggers[trigger.name] = trigger);
1241
+ }
1242
+ metadata() {
1243
+ return {
1244
+ displayName: this.displayName,
1245
+ logoUrl: this.logoUrl,
1246
+ actions: this._actions,
1247
+ triggers: this._triggers,
1248
+ categories: this.categories,
1249
+ description: this.description,
1250
+ authors: this.authors,
1251
+ auth: withConnectionIdentifierFlag(this.auth),
1252
+ minimumSupportedRelease: this.minimumSupportedRelease,
1253
+ maximumSupportedRelease: this.maximumSupportedRelease,
1254
+ deprecated: this.deprecated,
1255
+ contextInfo: this.getContextInfo?.()
1256
+ };
1257
+ }
1258
+ getAction(actionName) {
1259
+ return this._actions[actionName];
1260
+ }
1261
+ getTrigger(triggerName) {
1262
+ return this._triggers[triggerName];
1263
+ }
1264
+ actions() {
1265
+ return this._actions;
1266
+ }
1267
+ triggers() {
1268
+ return this._triggers;
1269
+ }
1270
+ };
1271
+ const createPiece = (params) => {
1272
+ if (params.auth && Array.isArray(params.auth)) {
1273
+ if (!params.auth.every((auth, index, self) => index === self.findIndex((t) => t.type === auth.type))) throw new Error("Auth properties must be unique by type");
1274
+ }
1275
+ return new Piece(params.displayName, params.logoUrl, params.authors ?? [], params.events, params.actions, params.triggers, params.categories ?? [], params.auth, params.minimumSupportedRelease, params.maximumSupportedRelease, params.description, params.deprecated);
1276
+ };
1277
+ function withConnectionIdentifierFlag(auth) {
1278
+ if (auth === void 0) return;
1279
+ return Array.isArray(auth) ? auth.map(flagConnectionIdentifier) : flagConnectionIdentifier(auth);
1280
+ }
1281
+ function flagConnectionIdentifier(auth) {
1282
+ return {
1283
+ ...auth,
1284
+ hasConnectionIdentifier: auth.getConnectionIdentifier !== void 0
1285
+ };
1286
+ }
1287
+ function isValidSimpleSemver(version) {
1288
+ return /^\d+\.\d+\.\d+$/.test(version);
1289
+ }
1290
+ function isSemverLessThan(a, b) {
1291
+ const [a1, a2, a3] = a.split(".").map(Number);
1292
+ const [b1, b2, b3] = b.split(".").map(Number);
1293
+ if (a1 !== b1) return a1 < b1;
1294
+ if (a2 !== b2) return a2 < b2;
1295
+ return a3 < b3;
1296
+ }
1297
+
1298
+ //#endregion
1299
+ //#region upstream/framework/lib/piece-metadata.ts
1300
+ const I18nForPiece = z.optional(z.record(z.string(), z.record(z.string(), z.string())));
1301
+ const PieceBase = z.object({
1302
+ id: z.optional(z.string()),
1303
+ name: z.string(),
1304
+ displayName: z.string(),
1305
+ logoUrl: z.string(),
1306
+ description: z.string(),
1307
+ authors: z.array(z.string()),
1308
+ platformId: z.optional(z.string()),
1309
+ directoryPath: z.optional(z.string()),
1310
+ auth: z.optional(z.union([PieceAuthProperty, z.array(PieceAuthProperty)])),
1311
+ version: z.string(),
1312
+ categories: z.optional(z.array(z.enum(PieceCategory))),
1313
+ minimumSupportedRelease: z.optional(z.string()),
1314
+ maximumSupportedRelease: z.optional(z.string()),
1315
+ deprecated: z.optional(z.boolean()),
1316
+ i18n: I18nForPiece
1317
+ });
1318
+ const Audience = z.enum([
1319
+ "human",
1320
+ "ai",
1321
+ "both"
1322
+ ]);
1323
+ const AiMetadata = z.object({
1324
+ description: z.optional(z.string()),
1325
+ idempotent: z.optional(z.boolean())
1326
+ });
1327
+ const ActionClassification = z.enum([
1328
+ "READ",
1329
+ "SEARCH",
1330
+ "WRITE",
1331
+ "DESTRUCTIVE"
1332
+ ]);
1333
+ const READ_ONLY_CLASSIFICATIONS = ["READ", "SEARCH"];
1334
+ const isReadOnlyClassification = (classification) => classification !== void 0 && READ_ONLY_CLASSIFICATIONS.includes(classification);
1335
+ const PropertyGroupDisplay = z.enum([
1336
+ "tabs",
1337
+ "section",
1338
+ "summary",
1339
+ "builder",
1340
+ "footer"
1341
+ ]);
1342
+ const PropertyGroup = z.object({
1343
+ key: z.string(),
1344
+ display: PropertyGroupDisplay,
1345
+ label: z.optional(z.string()),
1346
+ description: z.optional(z.string()),
1347
+ icon: z.optional(z.string()),
1348
+ props: z.array(z.string())
1349
+ });
1350
+ const ActionBase = z.object({
1351
+ name: z.string(),
1352
+ displayName: z.string(),
1353
+ description: z.string(),
1354
+ props: PiecePropertyMap,
1355
+ propertyGroups: z.optional(z.array(PropertyGroup)),
1356
+ requireAuth: z.boolean(),
1357
+ errorHandlingOptions: z.optional(ErrorHandlingOptionsParam),
1358
+ outputSchema: z.optional(z.custom()),
1359
+ audience: z.optional(Audience),
1360
+ aiMetadata: z.optional(AiMetadata),
1361
+ classification: z.optional(ActionClassification)
1362
+ });
1363
+ const TriggerBase = z.object({
1364
+ name: z.string(),
1365
+ displayName: z.string(),
1366
+ description: z.string(),
1367
+ props: PiecePropertyMap,
1368
+ propertyGroups: z.optional(z.array(PropertyGroup)),
1369
+ errorHandlingOptions: z.optional(ErrorHandlingOptionsParam),
1370
+ type: z.enum(TriggerStrategy),
1371
+ sampleData: z.unknown(),
1372
+ handshakeConfiguration: z.optional(z.custom()),
1373
+ renewConfiguration: z.optional(WebhookRenewConfiguration),
1374
+ testStrategy: z.enum(TriggerTestStrategy),
1375
+ outputSchema: z.optional(z.custom()),
1376
+ aiMetadata: z.optional(AiMetadata),
1377
+ classification: z.optional(ActionClassification)
1378
+ });
1379
+ const PieceMetadata = z.object({
1380
+ ...PieceBase.shape,
1381
+ actions: z.record(z.string(), ActionBase),
1382
+ triggers: z.record(z.string(), TriggerBase)
1383
+ });
1384
+ const PieceMetadataSummary = z.object({
1385
+ ...PieceBase.shape,
1386
+ actions: z.number(),
1387
+ triggers: z.number(),
1388
+ suggestedActions: z.optional(z.array(ActionBase)),
1389
+ suggestedTriggers: z.optional(z.array(TriggerBase))
1390
+ });
1391
+ const PiecePackageMetadata = z.object({
1392
+ projectUsage: z.number(),
1393
+ pieceType: z.enum(PieceType),
1394
+ packageType: z.enum(PackageType),
1395
+ platformId: z.optional(z.string()),
1396
+ archiveId: z.optional(z.string())
1397
+ });
1398
+ const PieceMetadataModel = z.object({
1399
+ ...PieceMetadata.shape,
1400
+ ...PiecePackageMetadata.shape
1401
+ });
1402
+ const PieceMetadataModelSummary = z.object({
1403
+ ...PieceMetadataSummary.shape,
1404
+ ...PiecePackageMetadata.shape
1405
+ });
1406
+ const PiecePackageInformation = z.object({
1407
+ name: z.string(),
1408
+ version: z.string()
1409
+ });
1410
+
1411
+ //#endregion
1412
+ //#region upstream/framework/lib/i18n.ts
1413
+ const pieceTranslation = {
1414
+ translatePiece: (params) => {
1415
+ const { piece, locale, mutate = false } = params;
1416
+ if (!locale) return piece;
1417
+ try {
1418
+ const target = piece.i18n?.[locale];
1419
+ if (!target) return piece;
1420
+ const translatedPiece = mutate ? piece : JSON.parse(JSON.stringify(piece));
1421
+ pieceTranslation.pathsToValuesToTranslate.forEach((key) => {
1422
+ translateProperty(translatedPiece, key, target);
1423
+ });
1424
+ return translatedPiece;
1425
+ } catch (err) {
1426
+ console.error(`error translating piece ${piece.name}:`, err);
1427
+ return piece;
1428
+ }
1429
+ },
1430
+ initializeI18n: async (pieceOutputPath) => {
1431
+ try {
1432
+ const locales = Object.values(LocalesEnum);
1433
+ const i18n = {};
1434
+ for (const locale of locales) {
1435
+ const translations = await readLocaleFile(locale, pieceOutputPath);
1436
+ if (translations) i18n[locale] = translations;
1437
+ }
1438
+ return Object.keys(i18n).length > 0 ? i18n : void 0;
1439
+ } catch (err) {
1440
+ console.log(`Error initializing i18n for ${pieceOutputPath}:`, err);
1441
+ return;
1442
+ }
1443
+ },
1444
+ pathsToValuesToTranslate: [
1445
+ "description",
1446
+ "auth.username.displayName",
1447
+ "auth.username.description",
1448
+ "auth.password.displayName",
1449
+ "auth.password.description",
1450
+ "auth.props.*.displayName",
1451
+ "auth.props.*.description",
1452
+ "auth.props.*.options.options.*.label",
1453
+ "auth.description",
1454
+ "actions.*.displayName",
1455
+ "actions.*.description",
1456
+ "actions.*.props.*.displayName",
1457
+ "actions.*.props.*.description",
1458
+ "actions.*.props.*.options.options.*.label",
1459
+ "triggers.*.displayName",
1460
+ "triggers.*.description",
1461
+ "triggers.*.props.*.displayName",
1462
+ "triggers.*.props.*.description",
1463
+ "triggers.*.props.*.options.options.*.label"
1464
+ ]
1465
+ };
1466
+ /**This function translates a property inside a piece, i.e description, displayName, etc...
1467
+ *
1468
+ * @param pieceModelOrProperty - The piece model or property to translate
1469
+ * @param path - The path to the property to translate, i.e auth.username.displayName
1470
+ * @param i18n - The i18n object
1471
+ */
1472
+ function translateProperty(pieceModelOrProperty, path, i18n) {
1473
+ const parsedKeys = path.split(".");
1474
+ if (parsedKeys[0] === "*") return Object.values(pieceModelOrProperty).forEach((item) => translateProperty(item, parsedKeys.slice(1).join("."), i18n));
1475
+ const nextObject = pieceModelOrProperty[parsedKeys[0]];
1476
+ if (!nextObject) return;
1477
+ if (parsedKeys.length > 1) return translateProperty(nextObject, parsedKeys.slice(1).join("."), i18n);
1478
+ const valueInI18n = i18n[pieceModelOrProperty[parsedKeys[0]].slice(0, 512)];
1479
+ if (valueInI18n) pieceModelOrProperty[parsedKeys[0]] = valueInI18n;
1480
+ }
1481
+ async function fileExists(filePath) {
1482
+ try {
1483
+ await fs.access(filePath);
1484
+ return true;
1485
+ } catch {
1486
+ return false;
1487
+ }
1488
+ }
1489
+ const readLocaleFile = async (locale, pieceOutputPath) => {
1490
+ const filePath = path.join(pieceOutputPath, "src", "i18n", `${locale}.json`);
1491
+ if (!await fileExists(filePath)) return null;
1492
+ try {
1493
+ const fileContent = await fs.readFile(filePath, "utf8");
1494
+ const translations = JSON.parse(fileContent);
1495
+ if (typeof translations === "object" && translations !== null) return translations;
1496
+ throw new Error(`Invalid i18n file format for ${locale} in piece ${pieceOutputPath}`);
1497
+ } catch (error) {
1498
+ console.error(`Error reading i18n file for ${locale} in piece ${pieceOutputPath}:`, error);
1499
+ return null;
1500
+ }
1501
+ };
1502
+
1503
+ //#endregion
1504
+ //#region upstream/framework/lib/test/index.ts
1505
+ function createMockActionContext(params) {
1506
+ return {
1507
+ executionType: ExecutionType.BEGIN,
1508
+ auth: void 0,
1509
+ propsValue: params.propsValue,
1510
+ store: {
1511
+ put: async (key, value) => value,
1512
+ get: async () => null,
1513
+ delete: async () => {}
1514
+ },
1515
+ connections: { get: async () => null },
1516
+ tags: { add: async () => {} },
1517
+ server: {
1518
+ apiUrl: "http://localhost:3000",
1519
+ publicUrl: "http://localhost:4200",
1520
+ token: "test-token"
1521
+ },
1522
+ files: { write: async () => "test-file-url" },
1523
+ output: { update: async () => {} },
1524
+ agent: { tools: async () => ({}) },
1525
+ run: {
1526
+ id: "test-run-id",
1527
+ stop: () => {},
1528
+ pause: () => {},
1529
+ respond: () => {}
1530
+ },
1531
+ project: {
1532
+ id: "test-project-id",
1533
+ externalId: async () => void 0
1534
+ },
1535
+ flows: {
1536
+ list: async () => ({
1537
+ data: [],
1538
+ next: null,
1539
+ previous: null
1540
+ }),
1541
+ current: {
1542
+ id: "test-flow-id",
1543
+ version: { id: "test-flow-version-id" }
1544
+ }
1545
+ },
1546
+ step: { name: "test-step" },
1547
+ generateResumeUrl: () => "http://localhost:3000/resume"
1548
+ };
1549
+ }
1550
+ function createMockPollingTriggerContext(params) {
1551
+ return {
1552
+ ...createMockActionContext({ propsValue: params.propsValue }),
1553
+ setSchedule: (schedule) => {
1554
+ params.onSetSchedule?.(schedule);
1555
+ }
1556
+ };
1557
+ }
1558
+
1559
+ //#endregion
1560
+ //#region src/powerhouse/context.ts
1561
+ function reactorOf(ctx) {
1562
+ const reactor = ctx !== null && typeof ctx === "object" ? ctx.reactor : void 0;
1563
+ if (!reactor) throw new Error("ctx.reactor is not available: this piece is not running on a Powerhouse reactor");
1564
+ return reactor;
1565
+ }
1566
+
1567
+ //#endregion
1568
+ export { ACTIVEPIECES_CHAT_TIERS, AGENT_STEP_TEST_TIMEOUT_MS, AGENT_STEP_TIMEOUT_MS, AIProviderModel, AIProviderName, AIProviderWithoutSensitiveData, AI_PROVIDER_CAPABILITIES, ActionBase, ActionClassification, AgentFlowTool, AgentKnowledgeBaseTool, AgentMcpTool, AgentOutputField, AgentOutputFieldType, AgentPieceProps, AgentStepBlock, AgentTaskStatus, AgentTool, AgentToolType, AiMetadata, ApFile, AppConnectionType, ArrayProperty, ArraySubProps, Audience, AzureProviderConfig, BaseAIProviderAuthConfig, BasePropertySchema, BasicAuthProperty, BasicAuthPropertyValue, BedrockProviderAuthConfig, BedrockProviderConfig, ChatFormResponse, CheckboxProperty, CloudflareGatewayProviderConfig, ContentBlockType, ContextVersion, CreateRecordsRequest, CreateTableWebhookRequest, CustomAuthProperty, CustomProperty, DEDUPE_KEY_PROPERTY, DEFAULT_CHAT_TIER_ID, DEFAULT_CONNECTION_DISPLAY_NAME, DateRangePreset, DateRangeProperty, DateRangeValue, DateTimeProperty, DropdownOption, DropdownProperty, DropdownState, DynamicProp, DynamicProperties, DynamicPropsValue, ErrorHandlingOptionsParam, ExecutionToolStatus, ExecutionType, ExportTableResponse, FAIL_PARENT_ON_FAILURE_HEADER, Field, FieldType, FileProperty, FileResponseInterface, Filter, FilterOperator, FlowStatus, FlowTriggerType, GetProviderConfigResponse, HumanInputFormResult, HumanInputFormResultTypes, IAction, ITrigger, InputProperty, InputPropertyMap, JsonProperty, KnowledgeBaseSourceType, LATEST_CONTEXT_VERSION, ListRecordsRequest, ListTablesRequest, LongTextProperty, MINIMUM_SUPPORTED_RELEASE_AFTER_LATEST_CONTEXT_VERSION, MarkdownContentBlock, MarkdownVariant, McpAuthConfig, McpAuthType, McpProperty, McpPropertyType, McpProtocol, McpTrigger, MultiSelectDropdownProperty, NumberProperty, OAuth2AuthorizationMethod, OAuth2GrantType, OAuth2Property, OAuth2PropertyValue, OAuth2Props, OIDCProperty, OPENAI_COMPATIBLE_VENDOR_BASE_URLS, ObjectProperty, OpenAICompatibleProviderConfig, OpenAiCompatibleVendorConfig, PARENT_RUN_ID_HEADER, Piece, PieceAuth, PieceAuthProperty, PieceBase, PieceCategory, PieceMetadata, PieceMetadataModel, PieceMetadataModelSummary, PieceMetadataSummary, PiecePackageInformation, PieceProperty, PiecePropertyMap, PieceServerContextError, PopulatedRecord, Project, ProjectAIProvider, Property, PropertyGroup, PropertyGroupDisplay, PropertyType, RAW_PAYLOAD_HEADER, READ_ONLY_CLASSIFICATIONS, RichTextProperty, SecretTextProperty, SeekPage, ShortTextProperty, StaticDropdownEmptyOption, StaticDropdownProperty, StaticMultiSelectDropdownProperty, StopResponse, StoreScope, TASK_COMPLETION_TOOL_NAME, Table, TableWebhookEventType, ToolCallContentBlock, ToolCallStatus, ToolCallType, TriggerBase, TriggerStrategy, USE_DRAFT_QUERY_PARAM_NAME, UpdateRecordRequest, VertexProviderAuthConfig, VertexProviderConfig, WebhookHandshakeStrategy, WebhookRenewConfiguration, WebhookRenewStrategy, apId, assertNotNullOrUndefined, backwardCompatabilityContextUtils, buildAuthHeaders, camelCase, chunk, createAction, createKeyForFormInput, createMockActionContext, createMockPollingTriggerContext, createPiece, createTrigger, dateRangeUtils, getAuthPropertyForValue, getEffectiveProviderAndModel, isEmpty, isNil, isNotUndefined, isPieceServerContextError, isReadOnlyClassification, isString, kebabCase, mcpToolNameUtils, normalizeToolOutputToExecuteResponse, pickBy, piecePropertiesUtils, pieceTranslation, reactorOf, splitCloudflareGatewayModelId, spreadIfDefined, startCase, tryCatch, unique };
1569
+ //# sourceMappingURL=index.js.map