@codemation/core 1.0.0 → 2.0.0
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/CHANGELOG.md +312 -0
- package/dist/{EngineRuntimeRegistration.types-BP6tsaNP.d.ts → EngineRuntimeRegistration.types-D1fyApMI.d.ts} +2 -2
- package/dist/{EngineWorkflowRunnerService-DzOCa1BW.d.cts → EngineRuntimeRegistration.types-pB3FnzqR.d.cts} +17 -17
- package/dist/{InMemoryRunDataFactory-1iz7_SnO.d.cts → InMemoryRunDataFactory-Xw7v4-sj.d.cts} +31 -29
- package/dist/InMemoryRunEventBusRegistry-VM3OWnHo.cjs +47 -0
- package/dist/InMemoryRunEventBusRegistry-VM3OWnHo.cjs.map +1 -0
- package/dist/InMemoryRunEventBusRegistry-sM4z4n_i.js +41 -0
- package/dist/InMemoryRunEventBusRegistry-sM4z4n_i.js.map +1 -0
- package/dist/{RunIntentService-BqhmdoA1.d.ts → RunIntentService-BE9CAkbf.d.ts} +966 -471
- package/dist/{RunIntentService-S-1lW-gS.d.cts → RunIntentService-siBSjaaY.d.cts} +859 -493
- package/dist/bootstrap/index.cjs +5 -2
- package/dist/bootstrap/index.d.cts +212 -135
- package/dist/bootstrap/index.d.ts +4 -4
- package/dist/bootstrap/index.js +3 -3
- package/dist/{bootstrap-BfZE19lK.cjs → bootstrap-Cm5ruQxx.cjs} +253 -2
- package/dist/bootstrap-Cm5ruQxx.cjs.map +1 -0
- package/dist/{bootstrap-jqh1kCNI.js → bootstrap-D3r505ko.js} +236 -3
- package/dist/bootstrap-D3r505ko.js.map +1 -0
- package/dist/{index-CGs3Hnoz.d.ts → index-DeLl1Tne.d.ts} +599 -219
- package/dist/index.cjs +323 -176
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +511 -80
- package/dist/index.d.ts +3 -3
- package/dist/index.js +299 -166
- package/dist/index.js.map +1 -1
- package/dist/{runtime-u6O644ST.js → runtime-BGNbRnqs.js} +933 -74
- package/dist/runtime-BGNbRnqs.js.map +1 -0
- package/dist/{runtime-DWKfb0BI.cjs → runtime-DKXJwTNv.cjs} +1027 -72
- package/dist/runtime-DKXJwTNv.cjs.map +1 -0
- package/dist/testing.cjs +4 -4
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +3 -3
- package/package.json +7 -2
- package/src/ai/AiHost.ts +9 -0
- package/src/authoring/DefinedCollectionRegistry.ts +17 -0
- package/src/authoring/defineCollection.types.ts +181 -0
- package/src/authoring/definePollingTrigger.types.ts +396 -0
- package/src/authoring/definePollingTriggerInternals.ts +74 -0
- package/src/authoring/index.ts +19 -0
- package/src/bootstrap/index.ts +9 -0
- package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +8 -0
- package/src/browser.ts +1 -0
- package/src/contracts/CodemationTelemetryAttributeNames.ts +6 -0
- package/src/contracts/NoOpNodeExecutionTelemetry.ts +2 -11
- package/src/contracts/NoOpTelemetrySpanScope.ts +46 -10
- package/src/contracts/assertionTypes.ts +63 -0
- package/src/contracts/baseTypes.ts +12 -0
- package/src/contracts/collectionTypes.ts +44 -0
- package/src/contracts/credentialTypes.ts +23 -1
- package/src/contracts/executionPersistenceContracts.ts +30 -0
- package/src/contracts/index.ts +4 -0
- package/src/contracts/runTypes.ts +37 -1
- package/src/contracts/runtimeTypes.ts +42 -0
- package/src/contracts/telemetryTypes.ts +8 -0
- package/src/contracts/testTriggerTypes.ts +66 -0
- package/src/contracts/workflowTypes.ts +36 -7
- package/src/contracts.ts +59 -0
- package/src/events/ConnectionInvocationEventPublisher.ts +46 -0
- package/src/events/index.ts +1 -0
- package/src/events/runEvents.ts +74 -0
- package/src/execution/ChildExecutionScopeFactory.ts +55 -0
- package/src/execution/DefaultExecutionContextFactory.ts +6 -0
- package/src/execution/ExecutionTelemetryCostTrackingDecoratorFactory.ts +18 -0
- package/src/execution/NodeExecutor.ts +10 -2
- package/src/execution/NodeInstanceFactory.ts +13 -1
- package/src/execution/NodeInstantiationError.ts +16 -0
- package/src/execution/NodeRunStateWriter.ts +7 -0
- package/src/execution/NodeRunStateWriterFactory.ts +7 -0
- package/src/execution/WorkflowRunExecutionContextFactory.ts +3 -0
- package/src/execution/index.ts +2 -0
- package/src/index.ts +8 -0
- package/src/orchestration/AbortControllerFactory.ts +9 -0
- package/src/orchestration/NodeExecutionRequestHandlerService.ts +1 -0
- package/src/orchestration/RunContinuationService.ts +3 -0
- package/src/orchestration/RunStartService.ts +114 -2
- package/src/orchestration/TestSuiteOrchestrator.ts +350 -0
- package/src/orchestration/TestSuiteRunIdFactory.ts +11 -0
- package/src/orchestration/TriggerRuntimeService.ts +34 -7
- package/src/orchestration/index.ts +9 -0
- package/src/runtime/EngineFactory.ts +12 -0
- package/src/triggers/polling/PollingTriggerDedupWindow.ts +23 -0
- package/src/triggers/polling/PollingTriggerLogger.ts +18 -0
- package/src/triggers/polling/PollingTriggerRuntime.ts +122 -0
- package/src/triggers/polling/index.ts +5 -0
- package/src/types/index.ts +12 -9
- package/src/workflow/definition/NodeIterationIdFactory.ts +26 -0
- package/src/workflow/dsl/NodeIdSlugifier.ts +18 -0
- package/src/workflow/dsl/WorkflowBuilder.ts +71 -3
- package/src/workflow/dsl/WorkflowDefinitionError.ts +15 -0
- package/src/workflow/index.ts +3 -0
- package/dist/InMemoryRunEventBusRegistry-B0_C4OnP.cjs +0 -262
- package/dist/InMemoryRunEventBusRegistry-B0_C4OnP.cjs.map +0 -1
- package/dist/InMemoryRunEventBusRegistry-C2U83Hmv.js +0 -238
- package/dist/InMemoryRunEventBusRegistry-C2U83Hmv.js.map +0 -1
- package/dist/bootstrap-BfZE19lK.cjs.map +0 -1
- package/dist/bootstrap-jqh1kCNI.js.map +0 -1
- package/dist/runtime-DWKfb0BI.cjs.map +0 -1
- package/dist/runtime-u6O644ST.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import {
|
|
1
|
+
import { $ as NoOpCostTrackingTelemetryFactory, $t as singleton, At as AgentConfigInspector, B as DefaultExecutionContextFactory, Bt as InjectableRuntimeDecoratorComposer, Ct as WorkflowBuilder, Dt as WhenBuilder, Et as ChainCursor, F as RunnableOutputBehaviorResolver, Ft as NodeBackedToolConfig, G as CodemationTelemetryAttributeNames, Gt as delay, H as nodeRef, Ht as StackTraceCallSitePathResolver, I as NodeOutputNormalizer, It as chatModel, J as NoOpExecutionTelemetryFactory, Jt as injectable, K as AllWorkflowsActiveWorkflowActivationPolicy, Kt as inject, L as ItemExprResolver, Lt as getPersistedRuntimeTypeMetadata, Mt as itemExpr, Nt as resolveItemExprsForExecution, Ot as AgentConnectionNodeCollector, Pt as resolveItemExprsInUnknown, Q as NoOpTelemetryArtifactReference, Qt as registry, R as InProcessRetryRunner, Rt as node, St as ConnectionInvocationIdFactory, Tt as NodeIdSlugifier, U as CodemationTelemetryMetricNames, Ut as PersistedRuntimeTypeNameResolver, V as branchRef, Vt as PersistedRuntimeTypeMetadataStore, W as GenAiTelemetryAttributeNames, Wt as container, X as NoOpNodeExecutionTelemetry, Xt as instancePerContainerCachingFactory, Y as NoOpExecutionTelemetry, Yt as instanceCachingFactory, Z as NoOpTelemetrySpanScope, Zt as predicateAwareClassFactory, _t as ConnectionInvocationEventPublisher, a as InMemoryLiveWorkflowRepository, at as RetryPolicy, bt as WorkflowExecutableNodeClassifier, ct as isPortsEmission, d as PollingTriggerRuntime, dt as CredentialResolverFactory, en as CoreTokens, et as NoOpCostTrackingTelemetry, f as PollingTriggerDedupWindow, ft as getOriginIndexFromItem, gt as NodeEventPublisher, ht as UnavailableBinaryStorage, i as RunIntentService, it as ExpRetryPolicy, jt as isItemExpr, kt as ConnectionNodeIdFactory, lt as isUnbrandedPortsEmissionShape, m as InMemoryBinaryStorage, mt as DefaultExecutionBinaryService, nt as CostTrackingTelemetryMetricNames, ot as NoRetryPolicy, p as InMemoryRunDataFactory, pt as ChildExecutionScopeFactory, q as RunFinishedAtFactory, qt as injectAll, rt as CredentialUnboundError, st as emitPorts, tt as CostTrackingTelemetryAttributeNames, u as NoOpPollingTriggerLogger, ut as DefaultAsyncSleeper, vt as DefaultWorkflowGraphFactory, wt as WorkflowDefinitionError, xt as NodeIterationIdFactory, y as EngineExecutionLimitsPolicy, yt as WorkflowExecutableNodeClassifierFactory, zt as tool } from "./runtime-BGNbRnqs.js";
|
|
2
|
+
import { t as InMemoryRunEventBus } from "./InMemoryRunEventBusRegistry-sM4z4n_i.js";
|
|
3
3
|
import { ZodError, z } from "zod";
|
|
4
|
-
import { randomUUID } from "node:crypto";
|
|
5
4
|
|
|
6
5
|
//#region src/contracts/Clock.ts
|
|
7
6
|
var SystemClock = class {
|
|
@@ -24,7 +23,7 @@ var DefinedNodeRegistry = class {
|
|
|
24
23
|
|
|
25
24
|
//#endregion
|
|
26
25
|
//#region src/authoring/defineNode.types.ts
|
|
27
|
-
const definedNodeCredentialRequirementFactory = {
|
|
26
|
+
const definedNodeCredentialRequirementFactory$1 = {
|
|
28
27
|
create(bindings) {
|
|
29
28
|
if (!bindings) return [];
|
|
30
29
|
return Object.entries(bindings).map(([slotKey, binding]) => {
|
|
@@ -54,13 +53,13 @@ const definedNodeCredentialRequirementFactory = {
|
|
|
54
53
|
return key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[-_.]+/g, " ").replace(/\s+/g, " ").trim().replace(/^./, (character) => character.toUpperCase());
|
|
55
54
|
}
|
|
56
55
|
};
|
|
57
|
-
const definedNodeCredentialAccessorFactory = { create(bindings, ctx) {
|
|
56
|
+
const definedNodeCredentialAccessorFactory$1 = { create(bindings, ctx) {
|
|
58
57
|
if (!bindings) return {};
|
|
59
58
|
const entries = Object.keys(bindings).map((slotKey) => [slotKey, () => ctx.getCredential(slotKey)]);
|
|
60
59
|
return Object.fromEntries(entries);
|
|
61
60
|
} };
|
|
62
61
|
function defineNode(options) {
|
|
63
|
-
const credentialRequirements = definedNodeCredentialRequirementFactory.create(options.credentials);
|
|
62
|
+
const credentialRequirements = definedNodeCredentialRequirementFactory$1.create(options.credentials);
|
|
64
63
|
const DefinedNodeRuntime = class {
|
|
65
64
|
kind = "node";
|
|
66
65
|
outputPorts = ["main"];
|
|
@@ -69,7 +68,7 @@ function defineNode(options) {
|
|
|
69
68
|
const ctx = args.ctx;
|
|
70
69
|
const context = {
|
|
71
70
|
config: ctx.config.config,
|
|
72
|
-
credentials: definedNodeCredentialAccessorFactory.create(options.credentials, ctx),
|
|
71
|
+
credentials: definedNodeCredentialAccessorFactory$1.create(options.credentials, ctx),
|
|
73
72
|
execution: ctx
|
|
74
73
|
};
|
|
75
74
|
const payload = {
|
|
@@ -115,7 +114,7 @@ function defineNode(options) {
|
|
|
115
114
|
return definition;
|
|
116
115
|
}
|
|
117
116
|
function defineBatchNode(options) {
|
|
118
|
-
const credentialRequirements = definedNodeCredentialRequirementFactory.create(options.credentials);
|
|
117
|
+
const credentialRequirements = definedNodeCredentialRequirementFactory$1.create(options.credentials);
|
|
119
118
|
const DefinedNodeRuntime = class {
|
|
120
119
|
kind = "node";
|
|
121
120
|
outputPorts = ["main"];
|
|
@@ -124,7 +123,7 @@ function defineBatchNode(options) {
|
|
|
124
123
|
const ctx = args.ctx;
|
|
125
124
|
const context = {
|
|
126
125
|
config: ctx.config.config,
|
|
127
|
-
credentials: definedNodeCredentialAccessorFactory.create(options.credentials, ctx),
|
|
126
|
+
credentials: definedNodeCredentialAccessorFactory$1.create(options.credentials, ctx),
|
|
128
127
|
execution: ctx
|
|
129
128
|
};
|
|
130
129
|
return [...await options.run(args.items.map((item) => item.json), context)];
|
|
@@ -332,75 +331,286 @@ function callableTool(options) {
|
|
|
332
331
|
}
|
|
333
332
|
|
|
334
333
|
//#endregion
|
|
335
|
-
//#region src/
|
|
336
|
-
var
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
presentation;
|
|
341
|
-
inputSchemaValue;
|
|
342
|
-
outputSchemaValue;
|
|
343
|
-
mapInputValue;
|
|
344
|
-
mapOutputValue;
|
|
345
|
-
constructor(name, node$1, options) {
|
|
346
|
-
this.name = name;
|
|
347
|
-
this.node = node$1;
|
|
348
|
-
this.type = node$1.type;
|
|
349
|
-
this.description = options.description;
|
|
350
|
-
this.presentation = options.presentation;
|
|
351
|
-
this.inputSchemaValue = options.inputSchema;
|
|
352
|
-
this.outputSchemaValue = options.outputSchema;
|
|
353
|
-
this.mapInputValue = options.mapInput;
|
|
354
|
-
this.mapOutputValue = options.mapOutput;
|
|
334
|
+
//#region src/authoring/DefinedCollectionRegistry.ts
|
|
335
|
+
var DefinedCollectionRegistry = class {
|
|
336
|
+
static definitions = /* @__PURE__ */ new Map();
|
|
337
|
+
static register(definition) {
|
|
338
|
+
this.definitions.set(definition.name, definition);
|
|
355
339
|
}
|
|
356
|
-
|
|
357
|
-
return this.
|
|
340
|
+
static resolve(name) {
|
|
341
|
+
return this.definitions.get(name);
|
|
358
342
|
}
|
|
359
|
-
|
|
360
|
-
return this.
|
|
343
|
+
static list() {
|
|
344
|
+
return Array.from(this.definitions.values());
|
|
361
345
|
}
|
|
362
|
-
|
|
363
|
-
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/authoring/defineCollection.types.ts
|
|
350
|
+
var CollectionColumnBuilderImpl = class {
|
|
351
|
+
_nullable;
|
|
352
|
+
_default;
|
|
353
|
+
constructor(_type) {
|
|
354
|
+
this._type = _type;
|
|
355
|
+
this._nullable = true;
|
|
356
|
+
}
|
|
357
|
+
notNull() {
|
|
358
|
+
this._nullable = false;
|
|
359
|
+
return this;
|
|
360
|
+
}
|
|
361
|
+
default(value) {
|
|
362
|
+
this._default = value;
|
|
363
|
+
this._nullable = false;
|
|
364
|
+
return this;
|
|
364
365
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
return
|
|
366
|
+
};
|
|
367
|
+
const c = {
|
|
368
|
+
text() {
|
|
369
|
+
return new CollectionColumnBuilderImpl("text");
|
|
370
|
+
},
|
|
371
|
+
int() {
|
|
372
|
+
return new CollectionColumnBuilderImpl("int");
|
|
373
|
+
},
|
|
374
|
+
bigint() {
|
|
375
|
+
return new CollectionColumnBuilderImpl("bigint");
|
|
376
|
+
},
|
|
377
|
+
double() {
|
|
378
|
+
return new CollectionColumnBuilderImpl("double");
|
|
379
|
+
},
|
|
380
|
+
bool() {
|
|
381
|
+
return new CollectionColumnBuilderImpl("bool");
|
|
382
|
+
},
|
|
383
|
+
timestamptz() {
|
|
384
|
+
return new CollectionColumnBuilderImpl("timestamptz");
|
|
385
|
+
},
|
|
386
|
+
jsonb() {
|
|
387
|
+
return new CollectionColumnBuilderImpl("jsonb");
|
|
388
|
+
},
|
|
389
|
+
uuid() {
|
|
390
|
+
return new CollectionColumnBuilderImpl("uuid");
|
|
369
391
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
392
|
+
};
|
|
393
|
+
/**
|
|
394
|
+
* Validates that a name follows the required pattern: lowercase + underscores, starts with letter.
|
|
395
|
+
*/
|
|
396
|
+
function validateCollectionName(name) {
|
|
397
|
+
if (!/^[a-z][a-z0-9_]*$/.test(name)) throw new Error(`Collection name "${name}" must start with a lowercase letter and contain only lowercase letters, digits, and underscores.`);
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Validates that all field names follow the required pattern.
|
|
401
|
+
*/
|
|
402
|
+
function validateFieldNames(fields) {
|
|
403
|
+
const pattern = /^[a-z][a-z0-9_]*$/;
|
|
404
|
+
const reserved = [
|
|
405
|
+
"id",
|
|
406
|
+
"created_at",
|
|
407
|
+
"updated_at"
|
|
408
|
+
];
|
|
409
|
+
for (const fieldName of Object.keys(fields)) {
|
|
410
|
+
if (reserved.includes(fieldName)) throw new Error(`Field name "${fieldName}" is reserved for internal use.`);
|
|
411
|
+
if (!pattern.test(fieldName)) throw new Error(`Field name "${fieldName}" must start with a lowercase letter and contain only lowercase letters, digits, and underscores.`);
|
|
373
412
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Validates that all indexed fields exist in the declared fields.
|
|
416
|
+
*/
|
|
417
|
+
function validateIndexes(indexes, fieldNames) {
|
|
418
|
+
for (const index of indexes) for (const fieldName of index.on) if (!fieldNames.has(fieldName)) throw new Error(`Index references non-existent field "${fieldName}".`);
|
|
419
|
+
}
|
|
420
|
+
function defineCollection(options) {
|
|
421
|
+
validateCollectionName(options.name);
|
|
422
|
+
const fields = {};
|
|
423
|
+
for (const [fieldName, builder] of Object.entries(options.fields)) {
|
|
424
|
+
const columnBuilder = builder;
|
|
425
|
+
fields[fieldName] = {
|
|
426
|
+
type: columnBuilder._type,
|
|
427
|
+
nullable: columnBuilder._nullable,
|
|
428
|
+
default: columnBuilder._default
|
|
429
|
+
};
|
|
378
430
|
}
|
|
379
|
-
|
|
380
|
-
|
|
431
|
+
validateFieldNames(fields);
|
|
432
|
+
const fieldNames = new Set(Object.keys(fields));
|
|
433
|
+
const indexes = options.indexes ?? [];
|
|
434
|
+
validateIndexes(indexes, fieldNames);
|
|
435
|
+
const definition = {
|
|
436
|
+
name: options.name,
|
|
437
|
+
fields,
|
|
438
|
+
indexes
|
|
439
|
+
};
|
|
440
|
+
DefinedCollectionRegistry.register(definition);
|
|
441
|
+
return {
|
|
442
|
+
kind: "defined-collection",
|
|
443
|
+
definition,
|
|
444
|
+
register(context) {
|
|
445
|
+
context.registerCollection(definition);
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
//#endregion
|
|
451
|
+
//#region src/authoring/definePollingTriggerInternals.ts
|
|
452
|
+
const definedNodeCredentialRequirementFactory = {
|
|
453
|
+
create(bindings) {
|
|
454
|
+
if (!bindings) return [];
|
|
455
|
+
return Object.entries(bindings).map(([slotKey, binding]) => {
|
|
456
|
+
if (typeof binding === "string" || this.isCredentialType(binding)) return {
|
|
457
|
+
slotKey,
|
|
458
|
+
label: this.humanize(slotKey),
|
|
459
|
+
acceptedTypes: [this.resolveTypeId(binding)]
|
|
460
|
+
};
|
|
461
|
+
const types = Array.isArray(binding.type) ? binding.type : [binding.type];
|
|
462
|
+
return {
|
|
463
|
+
slotKey,
|
|
464
|
+
label: binding.label ?? this.humanize(slotKey),
|
|
465
|
+
acceptedTypes: types.map((entry) => this.resolveTypeId(entry)),
|
|
466
|
+
optional: binding.optional,
|
|
467
|
+
helpText: binding.helpText,
|
|
468
|
+
helpUrl: binding.helpUrl
|
|
469
|
+
};
|
|
470
|
+
});
|
|
471
|
+
},
|
|
472
|
+
isCredentialType(value) {
|
|
473
|
+
return Boolean(value) && typeof value === "object" && "definition" in value && typeof value.definition?.typeId === "string";
|
|
474
|
+
},
|
|
475
|
+
resolveTypeId(type) {
|
|
476
|
+
return typeof type === "string" ? type : type.definition.typeId;
|
|
477
|
+
},
|
|
478
|
+
humanize(key) {
|
|
479
|
+
return key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[-_.]+/g, " ").replace(/\s+/g, " ").trim().replace(/^./, (character) => character.toUpperCase());
|
|
381
480
|
}
|
|
382
481
|
};
|
|
482
|
+
const definedNodeCredentialAccessorFactory = { create(bindings, ctx) {
|
|
483
|
+
if (!bindings) return {};
|
|
484
|
+
const entries = Object.keys(bindings).map((slotKey) => [slotKey, () => ctx.getCredential(slotKey)]);
|
|
485
|
+
return Object.fromEntries(entries);
|
|
486
|
+
} };
|
|
383
487
|
|
|
384
488
|
//#endregion
|
|
385
|
-
//#region src/
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
489
|
+
//#region src/authoring/definePollingTrigger.types.ts
|
|
490
|
+
/**
|
|
491
|
+
* TriggerNodeConfig produced by `DefinedPollingTrigger.create(...)`.
|
|
492
|
+
* Holds user configuration and credential requirements for the engine.
|
|
493
|
+
* The setup state type is opaque `JsonValue | undefined` — the runtime
|
|
494
|
+
* uses an internal wrapped shape that plugin authors never see.
|
|
495
|
+
*/
|
|
496
|
+
var DefinedPollingTriggerConfig = class {
|
|
497
|
+
kind = "trigger";
|
|
498
|
+
type;
|
|
499
|
+
icon;
|
|
500
|
+
constructor(name, cfg, typeToken, icon, credentialRequirements, id) {
|
|
501
|
+
this.name = name;
|
|
502
|
+
this.cfg = cfg;
|
|
503
|
+
this.credentialRequirements = credentialRequirements;
|
|
504
|
+
this.id = id;
|
|
505
|
+
this.type = typeToken;
|
|
506
|
+
this.icon = icon;
|
|
507
|
+
}
|
|
508
|
+
getCredentialRequirements() {
|
|
509
|
+
return this.credentialRequirements;
|
|
402
510
|
}
|
|
403
511
|
};
|
|
512
|
+
function isWrappedState(value) {
|
|
513
|
+
return value !== null && typeof value === "object" && "seenKeys" in value && Array.isArray(value.seenKeys);
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Declarative helper for authoring polling triggers.
|
|
517
|
+
*
|
|
518
|
+
* ```ts
|
|
519
|
+
* export const onNewMail = definePollingTrigger({
|
|
520
|
+
* key: "my-plugin.on-new-mail",
|
|
521
|
+
* title: "On new mail",
|
|
522
|
+
* configSchema: z.object({ folder: z.string() }),
|
|
523
|
+
* credentials: { auth: myOAuthCredentialType },
|
|
524
|
+
* initialState: () => ({ lastSeenId: undefined }),
|
|
525
|
+
* pollIntervalMs: 60_000,
|
|
526
|
+
* async poll({ config, state, credentials }) {
|
|
527
|
+
* const session = await credentials.auth();
|
|
528
|
+
* const messages = await fetchMessages(session, config.folder, state.lastSeenId);
|
|
529
|
+
* return {
|
|
530
|
+
* items: messages.map(m => ({ json: m, dedupKey: m.id })),
|
|
531
|
+
* nextState: { lastSeenId: messages[0]?.id ?? state.lastSeenId },
|
|
532
|
+
* };
|
|
533
|
+
* },
|
|
534
|
+
* });
|
|
535
|
+
* ```
|
|
536
|
+
*/
|
|
537
|
+
function definePollingTrigger(options) {
|
|
538
|
+
const credentialRequirements = definedNodeCredentialRequirementFactory.create(options.credentials);
|
|
539
|
+
const DEFAULT_INTERVAL_MS = 6e4;
|
|
540
|
+
const DefinedPollingTriggerRuntime = class {
|
|
541
|
+
kind = "trigger";
|
|
542
|
+
outputPorts = ["main"];
|
|
543
|
+
async setup(ctx) {
|
|
544
|
+
const cfg = ctx.config.cfg;
|
|
545
|
+
const intervalMs = cfg.pollIntervalMs ?? options.pollIntervalMs ?? DEFAULT_INTERVAL_MS;
|
|
546
|
+
const persisted = ctx.previousState;
|
|
547
|
+
const seedWrapped = (isWrappedState(persisted) ? persisted : void 0) ?? {
|
|
548
|
+
userState: options.initialState ? options.initialState() : void 0,
|
|
549
|
+
seenKeys: []
|
|
550
|
+
};
|
|
551
|
+
return await ctx.polling.start({
|
|
552
|
+
intervalMs,
|
|
553
|
+
seedState: seedWrapped,
|
|
554
|
+
runCycle: async ({ previousState }) => {
|
|
555
|
+
const wrapped = previousState ?? seedWrapped;
|
|
556
|
+
const seenSet = new Set(wrapped.seenKeys);
|
|
557
|
+
const credentialAccessors = definedNodeCredentialAccessorFactory.create(options.credentials, ctx);
|
|
558
|
+
const pollResult = await options.poll({
|
|
559
|
+
config: cfg,
|
|
560
|
+
state: wrapped.userState,
|
|
561
|
+
credentials: credentialAccessors
|
|
562
|
+
});
|
|
563
|
+
const newItems = [];
|
|
564
|
+
const newKeys = [];
|
|
565
|
+
for (const item of pollResult.items) {
|
|
566
|
+
if (item.dedupKey !== void 0) {
|
|
567
|
+
if (seenSet.has(item.dedupKey)) continue;
|
|
568
|
+
newKeys.push(item.dedupKey);
|
|
569
|
+
}
|
|
570
|
+
newItems.push({ json: item.json });
|
|
571
|
+
}
|
|
572
|
+
const allKeys = [...wrapped.seenKeys, ...newKeys];
|
|
573
|
+
const cappedKeys = allKeys.length > 2e3 ? allKeys.slice(allKeys.length - 2e3) : allKeys;
|
|
574
|
+
return {
|
|
575
|
+
items: newItems,
|
|
576
|
+
nextState: {
|
|
577
|
+
userState: pollResult.nextState,
|
|
578
|
+
seenKeys: cappedKeys
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
async execute(items, ctx) {
|
|
585
|
+
if (options.execute) return await options.execute(items, ctx);
|
|
586
|
+
return { main: items };
|
|
587
|
+
}
|
|
588
|
+
async getTestItems(ctx) {
|
|
589
|
+
if (options.testItems) return await options.testItems(ctx);
|
|
590
|
+
return [];
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
node({ name: options.key })(DefinedPollingTriggerRuntime);
|
|
594
|
+
return {
|
|
595
|
+
kind: "defined-polling-trigger",
|
|
596
|
+
key: options.key,
|
|
597
|
+
title: options.title,
|
|
598
|
+
description: options.description,
|
|
599
|
+
create(cfg, name = options.title, id) {
|
|
600
|
+
return new DefinedPollingTriggerConfig(name, cfg, DefinedPollingTriggerRuntime, options.icon, credentialRequirements, id);
|
|
601
|
+
},
|
|
602
|
+
poll(pollCtx) {
|
|
603
|
+
return options.poll({
|
|
604
|
+
config: pollCtx.config,
|
|
605
|
+
state: pollCtx.state,
|
|
606
|
+
credentials: pollCtx.credentials ?? {}
|
|
607
|
+
});
|
|
608
|
+
},
|
|
609
|
+
register(context) {
|
|
610
|
+
context.registerNode(DefinedPollingTriggerRuntime);
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
}
|
|
404
614
|
|
|
405
615
|
//#endregion
|
|
406
616
|
//#region src/ai/AgentToolFactory.ts
|
|
@@ -489,103 +699,6 @@ const AgentGuardrailDefaults = {
|
|
|
489
699
|
onTurnLimitReached: "error"
|
|
490
700
|
};
|
|
491
701
|
|
|
492
|
-
//#endregion
|
|
493
|
-
//#region src/ai/AgentConnectionNodeCollector.ts
|
|
494
|
-
const AgentConnectionNodeCollector = new class {
|
|
495
|
-
collect(parentNodeId, agentConfig) {
|
|
496
|
-
const collected = [];
|
|
497
|
-
this.collectInto(parentNodeId, agentConfig, collected);
|
|
498
|
-
return collected;
|
|
499
|
-
}
|
|
500
|
-
collectInto(parentNodeId, agentConfig, collected) {
|
|
501
|
-
collected.push({
|
|
502
|
-
nodeId: ConnectionNodeIdFactory.languageModelConnectionNodeId(parentNodeId),
|
|
503
|
-
parentNodeId,
|
|
504
|
-
connectionName: "llm",
|
|
505
|
-
role: "languageModel",
|
|
506
|
-
name: agentConfig.chatModel.presentation?.label ?? agentConfig.chatModel.name,
|
|
507
|
-
typeName: agentConfig.chatModel.name,
|
|
508
|
-
icon: agentConfig.chatModel.presentation?.icon,
|
|
509
|
-
credentialSource: agentConfig.chatModel
|
|
510
|
-
});
|
|
511
|
-
for (const tool$1 of agentConfig.tools ?? []) {
|
|
512
|
-
const toolNodeId = ConnectionNodeIdFactory.toolConnectionNodeId(parentNodeId, tool$1.name);
|
|
513
|
-
const isNestedAgent = this.isNodeBackedAgentTool(tool$1);
|
|
514
|
-
collected.push({
|
|
515
|
-
nodeId: toolNodeId,
|
|
516
|
-
parentNodeId,
|
|
517
|
-
connectionName: "tools",
|
|
518
|
-
role: isNestedAgent ? "nestedAgent" : "tool",
|
|
519
|
-
name: tool$1.presentation?.label ?? tool$1.name,
|
|
520
|
-
typeName: tool$1.name,
|
|
521
|
-
icon: tool$1.presentation?.icon,
|
|
522
|
-
credentialSource: tool$1
|
|
523
|
-
});
|
|
524
|
-
this.collectNestedAgentTools(toolNodeId, tool$1, collected);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
collectNestedAgentTools(toolNodeId, tool$1, collected) {
|
|
528
|
-
if (!this.isNodeBackedAgentTool(tool$1)) return;
|
|
529
|
-
const innerAgent = tool$1 instanceof NodeBackedToolConfig ? tool$1.node : tool$1.node;
|
|
530
|
-
this.collectInto(toolNodeId, innerAgent, collected);
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* After JSON round-trip (persisted snapshots), tools are plain objects — `instanceof NodeBackedToolConfig` fails.
|
|
534
|
-
* Detect node-backed tools structurally via {@link NodeBackedToolConfig#toolKind}.
|
|
535
|
-
*/
|
|
536
|
-
isNodeBackedAgentTool(tool$1) {
|
|
537
|
-
if (tool$1 instanceof NodeBackedToolConfig) return AgentConfigInspector.isAgentNodeConfig(tool$1.node);
|
|
538
|
-
if (!tool$1 || typeof tool$1 !== "object") return false;
|
|
539
|
-
const t = tool$1;
|
|
540
|
-
if (t.toolKind !== "nodeBacked") return false;
|
|
541
|
-
return AgentConfigInspector.isAgentNodeConfig(t.node);
|
|
542
|
-
}
|
|
543
|
-
}();
|
|
544
|
-
|
|
545
|
-
//#endregion
|
|
546
|
-
//#region src/workflow/definition/ConnectionInvocationIdFactory.ts
|
|
547
|
-
/**
|
|
548
|
-
* Unique ids for persisted connection invocation history rows (LLM/tool calls under an owning node).
|
|
549
|
-
*/
|
|
550
|
-
var ConnectionInvocationIdFactory = class {
|
|
551
|
-
static create() {
|
|
552
|
-
return `cinv_${randomUUID()}`;
|
|
553
|
-
}
|
|
554
|
-
/** Deterministic id for tests when a stable sequence is needed. */
|
|
555
|
-
static createForTest(runId, connectionNodeId, sequence) {
|
|
556
|
-
return `cinv_${runId}_${connectionNodeId}_${sequence}`;
|
|
557
|
-
}
|
|
558
|
-
};
|
|
559
|
-
|
|
560
|
-
//#endregion
|
|
561
|
-
//#region src/workflow/graph/ExecutableGraph.ts
|
|
562
|
-
var ExecutableGraph = class {
|
|
563
|
-
outgoingByNodeAndPort = /* @__PURE__ */ new Map();
|
|
564
|
-
constructor(def) {
|
|
565
|
-
for (const e of def.edges) {
|
|
566
|
-
const byPort = this.outgoingByNodeAndPort.get(e.from.nodeId) ?? /* @__PURE__ */ new Map();
|
|
567
|
-
const next = byPort.get(e.from.output) ?? [];
|
|
568
|
-
next.push({
|
|
569
|
-
nodeId: e.to.nodeId,
|
|
570
|
-
input: e.to.input
|
|
571
|
-
});
|
|
572
|
-
byPort.set(e.from.output, next);
|
|
573
|
-
this.outgoingByNodeAndPort.set(e.from.nodeId, byPort);
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
next(nodeId, output$1) {
|
|
577
|
-
return this.outgoingByNodeAndPort.get(nodeId)?.get(output$1) ?? [];
|
|
578
|
-
}
|
|
579
|
-
};
|
|
580
|
-
|
|
581
|
-
//#endregion
|
|
582
|
-
//#region src/workflow/graph/DefaultWorkflowGraphFactory.ts
|
|
583
|
-
var DefaultWorkflowGraphFactory = class {
|
|
584
|
-
create(def) {
|
|
585
|
-
return new ExecutableGraph(def);
|
|
586
|
-
}
|
|
587
|
-
};
|
|
588
|
-
|
|
589
702
|
//#endregion
|
|
590
703
|
//#region src/events/EventPublishingWorkflowExecutionRepository.ts
|
|
591
704
|
var EventPublishingWorkflowExecutionRepository = class {
|
|
@@ -640,10 +753,10 @@ var EventPublishingWorkflowExecutionRepository = class {
|
|
|
640
753
|
//#endregion
|
|
641
754
|
//#region \0@oxc-project+runtime@0.95.0/helpers/decorate.js
|
|
642
755
|
function __decorate(decorators, target, key, desc) {
|
|
643
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
756
|
+
var c$1 = arguments.length, r = c$1 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
644
757
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
645
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
646
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
758
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c$1 < 3 ? d(r) : c$1 > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
759
|
+
return c$1 > 3 && r && Object.defineProperty(target, key, r), r;
|
|
647
760
|
}
|
|
648
761
|
|
|
649
762
|
//#endregion
|
|
@@ -670,5 +783,25 @@ let ItemsInputNormalizer = class ItemsInputNormalizer$1 {
|
|
|
670
783
|
ItemsInputNormalizer = __decorate([injectable()], ItemsInputNormalizer);
|
|
671
784
|
|
|
672
785
|
//#endregion
|
|
673
|
-
|
|
786
|
+
//#region src/contracts/assertionTypes.ts
|
|
787
|
+
/**
|
|
788
|
+
* Default {@link AssertionResult.passThreshold} when authors omit it. Boolean-style assertions
|
|
789
|
+
* (assertEqual / contains / etc.) emit `score: 1` or `score: 0` so this default works for them;
|
|
790
|
+
* AI-judge assertions are expected to set their own threshold.
|
|
791
|
+
*/
|
|
792
|
+
const DEFAULT_ASSERTION_PASS_THRESHOLD = .5;
|
|
793
|
+
/**
|
|
794
|
+
* Derive whether an assertion result is considered "passing" using the score-based contract:
|
|
795
|
+
* `errored` always fails, otherwise `score >= (passThreshold ?? 0.5)`. This is the canonical
|
|
796
|
+
* derivation — UI and rollup code should call it rather than inlining the comparison so future
|
|
797
|
+
* tweaks (e.g. NaN handling) land in one place.
|
|
798
|
+
*/
|
|
799
|
+
function deriveAssertionPassed(result) {
|
|
800
|
+
if (result.errored === true) return false;
|
|
801
|
+
const threshold = result.passThreshold ?? DEFAULT_ASSERTION_PASS_THRESHOLD;
|
|
802
|
+
return result.score >= threshold;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
//#endregion
|
|
806
|
+
export { AgentConfigInspector, AgentConnectionNodeCollector, AgentGuardrailDefaults, AgentMessageConfigNormalizer, AgentToolFactory, AllWorkflowsActiveWorkflowActivationPolicy, CallableToolConfig, CallableToolFactory, CallableToolKindToken, ChainCursor, ChildExecutionScopeFactory, CodemationTelemetryAttributeNames, CodemationTelemetryMetricNames, ConnectionInvocationEventPublisher, ConnectionInvocationIdFactory, ConnectionNodeIdFactory, CoreTokens, CostTrackingTelemetryAttributeNames, CostTrackingTelemetryMetricNames, CredentialResolverFactory, CredentialUnboundError, DEFAULT_ASSERTION_PASS_THRESHOLD, DefaultAsyncSleeper, DefaultExecutionBinaryService, DefaultExecutionContextFactory, DefaultWorkflowGraphFactory, DefinedCollectionRegistry, DefinedNodeRegistry, DefinedPollingTriggerConfig, EngineExecutionLimitsPolicy, EventPublishingWorkflowExecutionRepository, ExpRetryPolicy, GenAiTelemetryAttributeNames, InMemoryBinaryStorage, InMemoryLiveWorkflowRepository, InMemoryRunDataFactory, InMemoryRunEventBus, InProcessRetryRunner, InjectableRuntimeDecoratorComposer, ItemExprResolver, ItemsInputNormalizer, NoOpCostTrackingTelemetry, NoOpCostTrackingTelemetryFactory, NoOpExecutionTelemetry, NoOpExecutionTelemetryFactory, NoOpNodeExecutionTelemetry, NoOpPollingTriggerLogger, NoOpTelemetryArtifactReference, NoOpTelemetrySpanScope, NoRetryPolicy, NodeBackedToolConfig, NodeEventPublisher, NodeIdSlugifier, NodeIterationIdFactory, NodeOutputNormalizer, PersistedRuntimeTypeMetadataStore, PersistedRuntimeTypeNameResolver, PollingTriggerDedupWindow, PollingTriggerRuntime, RetryPolicy, RunFinishedAtFactory, RunIntentService, RunnableOutputBehaviorResolver, StackTraceCallSitePathResolver, SystemClock, UnavailableBinaryStorage, WhenBuilder, WorkflowBuilder, WorkflowDefinitionError, WorkflowExecutableNodeClassifier, WorkflowExecutableNodeClassifierFactory, branchRef, c, callableTool, chatModel, container, defineBatchNode, defineCollection, defineCredential, defineNode, definePollingTrigger, delay, deriveAssertionPassed, emitPorts, getOriginIndexFromItem, getPersistedRuntimeTypeMetadata, inject, injectAll, injectable, instanceCachingFactory, instancePerContainerCachingFactory, isItemExpr, isPortsEmission, isUnbrandedPortsEmissionShape, itemExpr, node, nodeRef, predicateAwareClassFactory, registry, resolveItemExprsForExecution, resolveItemExprsInUnknown, singleton, tool };
|
|
674
807
|
//# sourceMappingURL=index.js.map
|