@codemation/core 0.7.0 → 0.8.1
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 +32 -0
- package/dist/{EngineRuntimeRegistration.types-_M7KFD3D.d.ts → EngineRuntimeRegistration.types-BP6tsaNP.d.ts} +4 -2
- package/dist/{EngineWorkflowRunnerService-D0Cwngv7.d.cts → EngineWorkflowRunnerService-DzOCa1BW.d.cts} +4 -2
- package/dist/{InMemoryRunDataFactory-BIWx6e02.d.cts → InMemoryRunDataFactory-1iz7_SnO.d.cts} +24 -4
- package/dist/{workflowActivationPolicy-6V3OJD3N.cjs → InMemoryRunEventBusRegistry-B0_C4OnP.cjs} +1 -16
- package/dist/InMemoryRunEventBusRegistry-B0_C4OnP.cjs.map +1 -0
- package/dist/{workflowActivationPolicy-Td9HTOuD.js → InMemoryRunEventBusRegistry-C2U83Hmv.js} +2 -11
- package/dist/InMemoryRunEventBusRegistry-C2U83Hmv.js.map +1 -0
- package/dist/{RunIntentService-CuXAIO6_.d.ts → RunIntentService-BqhmdoA1.d.ts} +231 -3
- package/dist/{RunIntentService-5k0p-J67.d.cts → RunIntentService-S-1lW-gS.d.cts} +203 -3
- package/dist/bootstrap/index.cjs +4 -2
- package/dist/bootstrap/index.d.cts +24 -5
- package/dist/bootstrap/index.d.ts +4 -4
- package/dist/bootstrap/index.js +3 -3
- package/dist/{bootstrap-BhYxSivA.js → bootstrap-BoknFKnw.js} +16 -13
- package/dist/bootstrap-BoknFKnw.js.map +1 -0
- package/dist/{bootstrap-D-TDU9Lu.cjs → bootstrap-Bx1u4cbS.cjs} +16 -13
- package/dist/bootstrap-Bx1u4cbS.cjs.map +1 -0
- package/dist/{index-BnJ7_IrO.d.ts → index-CVs9rVhl.d.ts} +36 -6
- package/dist/index.cjs +48 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.js +27 -74
- package/dist/index.js.map +1 -1
- package/dist/{runtime-CJnObwsU.js → runtime-DUW6tIJ1.js} +423 -33
- package/dist/runtime-DUW6tIJ1.js.map +1 -0
- package/dist/{runtime-3YVDd2vY.cjs → runtime-Dvo2ru5A.cjs} +548 -32
- package/dist/runtime-Dvo2ru5A.cjs.map +1 -0
- package/dist/testing.cjs +7 -7
- 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 +4 -4
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/src/ai/AiHost.ts +2 -0
- package/src/ai/CallableToolConfig.ts +28 -3
- package/src/bootstrap/index.ts +6 -1
- package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +14 -14
- package/src/bootstrap/runtime/EngineRuntimeRegistration.types.ts +3 -0
- package/src/contracts/CodemationTelemetryAttributeNames.ts +12 -0
- package/src/contracts/CodemationTelemetryMetricNames.ts +7 -0
- package/src/contracts/CostCatalogContract.ts +16 -0
- package/src/contracts/CostTrackingTelemetryContract.ts +47 -0
- package/src/contracts/GenAiTelemetryAttributeNames.ts +10 -0
- package/src/contracts/NoOpCostTrackingTelemetry.ts +16 -0
- package/src/contracts/NoOpCostTrackingTelemetryFactory.ts +9 -0
- package/src/contracts/NoOpExecutionTelemetry.ts +26 -0
- package/src/contracts/NoOpExecutionTelemetryFactory.ts +16 -0
- package/src/contracts/NoOpNodeExecutionTelemetry.ts +15 -0
- package/src/contracts/NoOpTelemetryArtifactReference.ts +9 -0
- package/src/contracts/NoOpTelemetrySpanScope.ts +22 -0
- package/src/contracts/index.ts +1 -0
- package/src/contracts/runTypes.ts +4 -1
- package/src/contracts/runtimeTypes.ts +7 -0
- package/src/contracts/telemetryTypes.ts +105 -0
- package/src/contracts/workflowTypes.ts +9 -0
- package/src/events/EventPublishingWorkflowExecutionRepository.ts +1 -1
- package/src/execution/CatalogBackedCostTrackingTelemetry.ts +81 -0
- package/src/execution/CatalogBackedCostTrackingTelemetryFactory.ts +12 -0
- package/src/execution/DefaultExecutionContextFactory.ts +23 -0
- package/src/execution/ExecutionTelemetryCostTrackingDecoratorFactory.ts +84 -0
- package/src/execution/NodeActivationRequestComposer.ts +1 -0
- package/src/execution/NodeExecutionSnapshotFactory.ts +2 -0
- package/src/execution/StaticCostCatalog.ts +22 -0
- package/src/execution/WorkflowRunExecutionContextFactory.ts +2 -0
- package/src/execution/index.ts +4 -0
- package/src/orchestration/NodeExecutionRequestHandlerService.ts +1 -0
- package/src/orchestration/RunContinuationService.ts +4 -0
- package/src/orchestration/RunStartService.ts +2 -0
- package/src/policies/storage/RunPolicySnapshotFactory.ts +9 -0
- package/src/runStorage/InMemoryWorkflowExecutionRepository.ts +4 -2
- package/src/testing/WorkflowTestKitNodeRegistrationContextFactory.ts +1 -3
- package/src/types/index.ts +5 -0
- package/dist/bootstrap-BhYxSivA.js.map +0 -1
- package/dist/bootstrap-D-TDU9Lu.cjs.map +0 -1
- package/dist/runtime-3YVDd2vY.cjs.map +0 -1
- package/dist/runtime-CJnObwsU.js.map +0 -1
- package/dist/workflowActivationPolicy-6V3OJD3N.cjs.map +0 -1
- package/dist/workflowActivationPolicy-Td9HTOuD.js.map +0 -1
|
@@ -535,7 +535,8 @@ var NodeExecutionSnapshotFactory = class {
|
|
|
535
535
|
error: {
|
|
536
536
|
message: args.error.message,
|
|
537
537
|
name: args.error.name,
|
|
538
|
-
stack: args.error.stack
|
|
538
|
+
stack: args.error.stack,
|
|
539
|
+
details: args.error.details
|
|
539
540
|
}
|
|
540
541
|
};
|
|
541
542
|
}
|
|
@@ -809,14 +810,324 @@ var DefaultAsyncSleeper = class {
|
|
|
809
810
|
}
|
|
810
811
|
};
|
|
811
812
|
|
|
813
|
+
//#endregion
|
|
814
|
+
//#region src/contracts/emitPorts.ts
|
|
815
|
+
const EMIT_PORTS_BRAND = Symbol.for("codemation.emitPorts");
|
|
816
|
+
function emitPorts(ports) {
|
|
817
|
+
return {
|
|
818
|
+
[EMIT_PORTS_BRAND]: true,
|
|
819
|
+
ports
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
function isPortsEmission(value) {
|
|
823
|
+
return typeof value === "object" && value !== null && EMIT_PORTS_BRAND in value && value[EMIT_PORTS_BRAND] === true;
|
|
824
|
+
}
|
|
825
|
+
function isUnbrandedPortsEmissionShape(value) {
|
|
826
|
+
return typeof value === "object" && value !== null && "ports" in value && !isPortsEmission(value);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
//#endregion
|
|
830
|
+
//#region src/contracts/NoRetryPolicy.ts
|
|
831
|
+
var NoRetryPolicy = class {
|
|
832
|
+
kind = "none";
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
//#endregion
|
|
836
|
+
//#region src/contracts/RetryPolicy.ts
|
|
837
|
+
var RetryPolicy = class {
|
|
838
|
+
kind = "fixed";
|
|
839
|
+
constructor(maxAttempts, delayMs) {
|
|
840
|
+
this.maxAttempts = maxAttempts;
|
|
841
|
+
this.delayMs = delayMs;
|
|
842
|
+
if (!Number.isFinite(maxAttempts) || maxAttempts < 1 || !Number.isInteger(maxAttempts)) throw new Error(`RetryPolicy.maxAttempts must be a positive integer, got ${maxAttempts}`);
|
|
843
|
+
if (!Number.isFinite(delayMs) || delayMs < 0) throw new Error(`RetryPolicy.delayMs must be a non-negative finite number, got ${delayMs}`);
|
|
844
|
+
}
|
|
845
|
+
/** Default for HTTP-style transient failures: 3 tries, 1s between attempts. */
|
|
846
|
+
static defaultForHttp = {
|
|
847
|
+
kind: "fixed",
|
|
848
|
+
maxAttempts: 3,
|
|
849
|
+
delayMs: 1e3
|
|
850
|
+
};
|
|
851
|
+
/** Default for LLM / agent calls: 3 tries, 2s fixed backoff. */
|
|
852
|
+
static defaultForAiAgent = {
|
|
853
|
+
kind: "fixed",
|
|
854
|
+
maxAttempts: 3,
|
|
855
|
+
delayMs: 2e3
|
|
856
|
+
};
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
//#endregion
|
|
860
|
+
//#region src/contracts/ExpRetryPolicy.ts
|
|
861
|
+
var ExpRetryPolicy = class {
|
|
862
|
+
kind = "exponential";
|
|
863
|
+
constructor(maxAttempts, initialDelayMs, multiplier, maxDelayMs, jitter) {
|
|
864
|
+
this.maxAttempts = maxAttempts;
|
|
865
|
+
this.initialDelayMs = initialDelayMs;
|
|
866
|
+
this.multiplier = multiplier;
|
|
867
|
+
this.maxDelayMs = maxDelayMs;
|
|
868
|
+
this.jitter = jitter;
|
|
869
|
+
if (!Number.isFinite(maxAttempts) || maxAttempts < 1 || !Number.isInteger(maxAttempts)) throw new Error(`ExpRetryPolicy.maxAttempts must be a positive integer, got ${maxAttempts}`);
|
|
870
|
+
if (!Number.isFinite(initialDelayMs) || initialDelayMs < 0) throw new Error(`ExpRetryPolicy.initialDelayMs must be a non-negative finite number, got ${initialDelayMs}`);
|
|
871
|
+
if (!Number.isFinite(multiplier) || multiplier < 1) throw new Error(`ExpRetryPolicy.multiplier must be >= 1, got ${multiplier}`);
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
//#endregion
|
|
876
|
+
//#region src/contracts/credentialTypes.ts
|
|
877
|
+
var CredentialUnboundError = class CredentialUnboundError extends Error {
|
|
878
|
+
constructor(bindingKey, acceptedTypes = []) {
|
|
879
|
+
super(CredentialUnboundError.createMessage(bindingKey, acceptedTypes));
|
|
880
|
+
this.bindingKey = bindingKey;
|
|
881
|
+
this.acceptedTypes = acceptedTypes;
|
|
882
|
+
this.name = "CredentialUnboundError";
|
|
883
|
+
}
|
|
884
|
+
static createMessage(bindingKey, acceptedTypes) {
|
|
885
|
+
const acceptedTypesSuffix = acceptedTypes.length > 0 ? ` Accepted credential types: ${acceptedTypes.join(", ")}.` : "";
|
|
886
|
+
return `Credential slot "${bindingKey.slotKey}" is not bound for workflow ${bindingKey.workflowId} node ${bindingKey.nodeId}.${acceptedTypesSuffix}`;
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
//#endregion
|
|
891
|
+
//#region src/contracts/CostTrackingTelemetryContract.ts
|
|
892
|
+
const CostTrackingTelemetryMetricNames = {
|
|
893
|
+
usage: "codemation.cost.usage",
|
|
894
|
+
estimatedCost: "codemation.cost.estimated"
|
|
895
|
+
};
|
|
896
|
+
const CostTrackingTelemetryAttributeNames = {
|
|
897
|
+
component: "cost.component",
|
|
898
|
+
provider: "cost.provider",
|
|
899
|
+
operation: "cost.operation",
|
|
900
|
+
pricingKey: "cost.pricing_key",
|
|
901
|
+
usageUnit: "cost.usage_unit",
|
|
902
|
+
currency: "cost.currency",
|
|
903
|
+
currencyScale: "cost.currency_scale",
|
|
904
|
+
estimateKind: "cost.estimate_kind"
|
|
905
|
+
};
|
|
906
|
+
|
|
907
|
+
//#endregion
|
|
908
|
+
//#region src/contracts/NoOpCostTrackingTelemetry.ts
|
|
909
|
+
var NoOpCostTrackingTelemetry = class {
|
|
910
|
+
async captureUsage(_) {}
|
|
911
|
+
forScope(_) {
|
|
912
|
+
return this;
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
|
|
916
|
+
//#endregion
|
|
917
|
+
//#region src/contracts/NoOpCostTrackingTelemetryFactory.ts
|
|
918
|
+
var NoOpCostTrackingTelemetryFactory = class {
|
|
919
|
+
create(_) {
|
|
920
|
+
return new NoOpCostTrackingTelemetry();
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
|
|
924
|
+
//#endregion
|
|
925
|
+
//#region src/contracts/NoOpTelemetryArtifactReference.ts
|
|
926
|
+
var NoOpTelemetryArtifactReference = class {
|
|
927
|
+
static value = {
|
|
928
|
+
artifactId: "telemetry-artifact-noop",
|
|
929
|
+
traceId: void 0,
|
|
930
|
+
spanId: void 0
|
|
931
|
+
};
|
|
932
|
+
};
|
|
933
|
+
|
|
934
|
+
//#endregion
|
|
935
|
+
//#region src/contracts/NoOpTelemetrySpanScope.ts
|
|
936
|
+
var NoOpTelemetrySpanScope = class {
|
|
937
|
+
static value = {
|
|
938
|
+
traceId: "00000000000000000000000000000000",
|
|
939
|
+
spanId: "0000000000000000",
|
|
940
|
+
addSpanEvent(_) {},
|
|
941
|
+
recordMetric(_) {},
|
|
942
|
+
attachArtifact(_) {
|
|
943
|
+
return NoOpTelemetryArtifactReference.value;
|
|
944
|
+
},
|
|
945
|
+
end(_ = {}) {}
|
|
946
|
+
};
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
//#endregion
|
|
950
|
+
//#region src/contracts/NoOpNodeExecutionTelemetry.ts
|
|
951
|
+
var NoOpNodeExecutionTelemetry = class NoOpNodeExecutionTelemetry {
|
|
952
|
+
static value = {
|
|
953
|
+
...NoOpTelemetrySpanScope.value,
|
|
954
|
+
forNode(_) {
|
|
955
|
+
return NoOpNodeExecutionTelemetry.value;
|
|
956
|
+
},
|
|
957
|
+
startChildSpan(_) {
|
|
958
|
+
return NoOpTelemetrySpanScope.value;
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
};
|
|
962
|
+
|
|
963
|
+
//#endregion
|
|
964
|
+
//#region src/contracts/NoOpExecutionTelemetry.ts
|
|
965
|
+
var NoOpExecutionTelemetry = class {
|
|
966
|
+
static value = {
|
|
967
|
+
traceId: "00000000000000000000000000000000",
|
|
968
|
+
spanId: "0000000000000000",
|
|
969
|
+
addSpanEvent(_) {},
|
|
970
|
+
recordMetric(_) {},
|
|
971
|
+
attachArtifact(_) {
|
|
972
|
+
return NoOpTelemetryArtifactReference.value;
|
|
973
|
+
},
|
|
974
|
+
forNode(_) {
|
|
975
|
+
return NoOpNodeExecutionTelemetry.value;
|
|
976
|
+
}
|
|
977
|
+
};
|
|
978
|
+
};
|
|
979
|
+
|
|
980
|
+
//#endregion
|
|
981
|
+
//#region src/contracts/NoOpExecutionTelemetryFactory.ts
|
|
982
|
+
var NoOpExecutionTelemetryFactory = class {
|
|
983
|
+
create(_) {
|
|
984
|
+
return NoOpExecutionTelemetry.value;
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
//#endregion
|
|
989
|
+
//#region src/contracts/CodemationTelemetryAttributeNames.ts
|
|
990
|
+
var CodemationTelemetryAttributeNames = class {
|
|
991
|
+
static workflowId = "codemation.workflow.id";
|
|
992
|
+
static runId = "codemation.run.id";
|
|
993
|
+
static nodeId = "codemation.node.id";
|
|
994
|
+
static activationId = "codemation.activation.id";
|
|
995
|
+
static nodeType = "codemation.node.type";
|
|
996
|
+
static nodeRole = "codemation.node.role";
|
|
997
|
+
static workflowFolder = "codemation.workflow.folder";
|
|
998
|
+
static connectionInvocationId = "codemation.connection.invocation_id";
|
|
999
|
+
static toolName = "codemation.tool.name";
|
|
1000
|
+
static traceParentRunId = "codemation.parent.run.id";
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
//#endregion
|
|
1004
|
+
//#region src/contracts/GenAiTelemetryAttributeNames.ts
|
|
1005
|
+
var GenAiTelemetryAttributeNames = class {
|
|
1006
|
+
static operationName = "gen_ai.operation.name";
|
|
1007
|
+
static requestModel = "gen_ai.request.model";
|
|
1008
|
+
static usageInputTokens = "gen_ai.usage.input_tokens";
|
|
1009
|
+
static usageOutputTokens = "gen_ai.usage.output_tokens";
|
|
1010
|
+
static usageTotalTokens = "gen_ai.usage.total_tokens";
|
|
1011
|
+
static usageCacheReadInputTokens = "gen_ai.usage.cache_read.input_tokens";
|
|
1012
|
+
static usageCacheCreationInputTokens = "gen_ai.usage.cache_creation.input_tokens";
|
|
1013
|
+
static usageReasoningTokens = "codemation.gen_ai.usage.reasoning_tokens";
|
|
1014
|
+
};
|
|
1015
|
+
|
|
1016
|
+
//#endregion
|
|
1017
|
+
//#region src/contracts/CodemationTelemetryMetricNames.ts
|
|
1018
|
+
var CodemationTelemetryMetricNames = class {
|
|
1019
|
+
static agentTurns = "codemation.ai.turns";
|
|
1020
|
+
static agentToolCalls = "codemation.ai.tool_calls";
|
|
1021
|
+
static gmailMessagesEmitted = "codemation.gmail.messages_emitted";
|
|
1022
|
+
static gmailAttachments = "codemation.gmail.attachments";
|
|
1023
|
+
static gmailAttachmentBytes = "codemation.gmail.attachment_bytes";
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
//#endregion
|
|
1027
|
+
//#region src/contracts/runFinishedAtFactory.ts
|
|
1028
|
+
/** Derives workflow end time from persisted run root or node snapshots for run listings. */
|
|
1029
|
+
var RunFinishedAtFactory = class {
|
|
1030
|
+
static resolveIso(state) {
|
|
1031
|
+
if (state.finishedAt && state.status !== "running" && state.status !== "pending") return state.finishedAt;
|
|
1032
|
+
if (state.status === "running" || state.status === "pending") return;
|
|
1033
|
+
let max;
|
|
1034
|
+
for (const snap of Object.values(state.nodeSnapshotsByNodeId)) if (snap?.finishedAt && (!max || snap.finishedAt > max)) max = snap.finishedAt;
|
|
1035
|
+
return max;
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
|
|
1039
|
+
//#endregion
|
|
1040
|
+
//#region src/contracts/workflowTypes.ts
|
|
1041
|
+
function nodeRef(nodeId) {
|
|
1042
|
+
return nodeId;
|
|
1043
|
+
}
|
|
1044
|
+
const branchRef = (index) => `$${index}`;
|
|
1045
|
+
|
|
1046
|
+
//#endregion
|
|
1047
|
+
//#region src/contracts/workflowActivationPolicy.ts
|
|
1048
|
+
/** Default for tests and harnesses: every workflow is treated as active (legacy behavior). */
|
|
1049
|
+
var AllWorkflowsActiveWorkflowActivationPolicy = class {
|
|
1050
|
+
isActive(_workflowId) {
|
|
1051
|
+
return true;
|
|
1052
|
+
}
|
|
1053
|
+
};
|
|
1054
|
+
|
|
1055
|
+
//#endregion
|
|
1056
|
+
//#region src/execution/ExecutionTelemetryCostTrackingDecoratorFactory.ts
|
|
1057
|
+
var ExecutionTelemetryCostTrackingDecoratorFactory = class {
|
|
1058
|
+
decorateExecutionTelemetry(args) {
|
|
1059
|
+
return {
|
|
1060
|
+
traceId: args.telemetry.traceId,
|
|
1061
|
+
spanId: args.telemetry.spanId,
|
|
1062
|
+
costTracking: args.costTracking,
|
|
1063
|
+
addSpanEvent: (event) => args.telemetry.addSpanEvent(event),
|
|
1064
|
+
recordMetric: (metric) => args.telemetry.recordMetric(metric),
|
|
1065
|
+
attachArtifact: (artifact) => args.telemetry.attachArtifact(artifact),
|
|
1066
|
+
forNode: (nodeArgs) => {
|
|
1067
|
+
const nodeTelemetry = args.telemetry.forNode(nodeArgs);
|
|
1068
|
+
return this.decorateNodeExecutionTelemetry({
|
|
1069
|
+
telemetry: nodeTelemetry,
|
|
1070
|
+
costTracking: args.costTracking.forScope(nodeTelemetry)
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
decorateNodeExecutionTelemetry(args) {
|
|
1076
|
+
return {
|
|
1077
|
+
traceId: args.telemetry.traceId,
|
|
1078
|
+
spanId: args.telemetry.spanId,
|
|
1079
|
+
costTracking: args.costTracking,
|
|
1080
|
+
addSpanEvent: (event) => args.telemetry.addSpanEvent(event),
|
|
1081
|
+
recordMetric: (metric) => args.telemetry.recordMetric(metric),
|
|
1082
|
+
attachArtifact: (artifact) => args.telemetry.attachArtifact(artifact),
|
|
1083
|
+
end: (endArgs) => args.telemetry.end(endArgs),
|
|
1084
|
+
startChildSpan: (spanArgs) => this.decorateTelemetrySpanScope({
|
|
1085
|
+
scope: args.telemetry.startChildSpan(spanArgs),
|
|
1086
|
+
costTracking: args.costTracking
|
|
1087
|
+
}),
|
|
1088
|
+
forNode: (nodeArgs) => {
|
|
1089
|
+
const nodeTelemetry = args.telemetry.forNode(nodeArgs);
|
|
1090
|
+
return this.decorateNodeExecutionTelemetry({
|
|
1091
|
+
telemetry: nodeTelemetry,
|
|
1092
|
+
costTracking: args.costTracking.forScope(nodeTelemetry)
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
decorateTelemetrySpanScope(args) {
|
|
1098
|
+
return {
|
|
1099
|
+
traceId: args.scope.traceId,
|
|
1100
|
+
spanId: args.scope.spanId,
|
|
1101
|
+
costTracking: args.costTracking.forScope(args.scope),
|
|
1102
|
+
addSpanEvent: (event) => args.scope.addSpanEvent(event),
|
|
1103
|
+
recordMetric: (metric) => args.scope.recordMetric(metric),
|
|
1104
|
+
attachArtifact: (artifact) => args.scope.attachArtifact(artifact),
|
|
1105
|
+
end: (endArgs) => args.scope.end(endArgs)
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
};
|
|
1109
|
+
|
|
812
1110
|
//#endregion
|
|
813
1111
|
//#region src/execution/DefaultExecutionContextFactory.ts
|
|
814
1112
|
var DefaultExecutionContextFactory = class {
|
|
815
|
-
|
|
1113
|
+
telemetryDecoratorFactory = new ExecutionTelemetryCostTrackingDecoratorFactory();
|
|
1114
|
+
constructor(binaryStorage = new UnavailableBinaryStorage(), telemetryFactory = new NoOpExecutionTelemetryFactory(), costTrackingFactory = new NoOpCostTrackingTelemetryFactory(), currentDate = () => /* @__PURE__ */ new Date()) {
|
|
816
1115
|
this.binaryStorage = binaryStorage;
|
|
1116
|
+
this.telemetryFactory = telemetryFactory;
|
|
1117
|
+
this.costTrackingFactory = costTrackingFactory;
|
|
817
1118
|
this.currentDate = currentDate;
|
|
818
1119
|
}
|
|
819
1120
|
create(args) {
|
|
1121
|
+
const baseTelemetry = args.telemetry ?? this.telemetryFactory.create({
|
|
1122
|
+
runId: args.runId,
|
|
1123
|
+
workflowId: args.workflowId,
|
|
1124
|
+
parent: args.parent,
|
|
1125
|
+
policySnapshot: args.policySnapshot
|
|
1126
|
+
});
|
|
1127
|
+
const telemetry = this.telemetryDecoratorFactory.decorateExecutionTelemetry({
|
|
1128
|
+
telemetry: baseTelemetry,
|
|
1129
|
+
costTracking: baseTelemetry.costTracking ?? this.costTrackingFactory.create({ telemetry: baseTelemetry })
|
|
1130
|
+
});
|
|
820
1131
|
return {
|
|
821
1132
|
runId: args.runId,
|
|
822
1133
|
workflowId: args.workflowId,
|
|
@@ -827,12 +1138,84 @@ var DefaultExecutionContextFactory = class {
|
|
|
827
1138
|
now: this.currentDate,
|
|
828
1139
|
data: args.data,
|
|
829
1140
|
nodeState: args.nodeState,
|
|
1141
|
+
telemetry,
|
|
830
1142
|
binary: new DefaultExecutionBinaryService(this.binaryStorage, args.workflowId, args.runId, this.currentDate),
|
|
831
1143
|
getCredential: args.getCredential
|
|
832
1144
|
};
|
|
833
1145
|
}
|
|
834
1146
|
};
|
|
835
1147
|
|
|
1148
|
+
//#endregion
|
|
1149
|
+
//#region src/execution/CatalogBackedCostTrackingTelemetry.ts
|
|
1150
|
+
var CatalogBackedCostTrackingTelemetry = class CatalogBackedCostTrackingTelemetry {
|
|
1151
|
+
constructor(currentScope, costCatalog) {
|
|
1152
|
+
this.currentScope = currentScope;
|
|
1153
|
+
this.costCatalog = costCatalog;
|
|
1154
|
+
}
|
|
1155
|
+
async captureUsage(args) {
|
|
1156
|
+
const usageAttributes = this.createUsageAttributes(args);
|
|
1157
|
+
await this.currentScope.recordMetric({
|
|
1158
|
+
name: CostTrackingTelemetryMetricNames.usage,
|
|
1159
|
+
value: args.quantity,
|
|
1160
|
+
unit: args.usageUnit,
|
|
1161
|
+
attributes: usageAttributes
|
|
1162
|
+
});
|
|
1163
|
+
const catalogEntry = this.costCatalog.findEntry(args);
|
|
1164
|
+
if (!catalogEntry) return;
|
|
1165
|
+
const estimatedAmountMinor = Math.round(args.quantity * catalogEntry.pricePerUnitMinor);
|
|
1166
|
+
const costAttributes = this.createCostAttributes(args, catalogEntry.currency, catalogEntry.currencyScale);
|
|
1167
|
+
await this.currentScope.recordMetric({
|
|
1168
|
+
name: CostTrackingTelemetryMetricNames.estimatedCost,
|
|
1169
|
+
value: estimatedAmountMinor,
|
|
1170
|
+
unit: catalogEntry.currency,
|
|
1171
|
+
attributes: costAttributes
|
|
1172
|
+
});
|
|
1173
|
+
return {
|
|
1174
|
+
currency: catalogEntry.currency,
|
|
1175
|
+
currencyScale: catalogEntry.currencyScale,
|
|
1176
|
+
estimatedAmountMinor,
|
|
1177
|
+
estimateKind: "catalog"
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
forScope(scope) {
|
|
1181
|
+
return new CatalogBackedCostTrackingTelemetry(scope, this.costCatalog);
|
|
1182
|
+
}
|
|
1183
|
+
createUsageAttributes(args) {
|
|
1184
|
+
return {
|
|
1185
|
+
...args.attributes,
|
|
1186
|
+
[CostTrackingTelemetryAttributeNames.component]: args.component,
|
|
1187
|
+
[CostTrackingTelemetryAttributeNames.provider]: args.provider,
|
|
1188
|
+
[CostTrackingTelemetryAttributeNames.operation]: args.operation,
|
|
1189
|
+
[CostTrackingTelemetryAttributeNames.pricingKey]: args.pricingKey,
|
|
1190
|
+
[CostTrackingTelemetryAttributeNames.usageUnit]: args.usageUnit
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
createCostAttributes(args, currency, currencyScale) {
|
|
1194
|
+
return {
|
|
1195
|
+
...args.attributes,
|
|
1196
|
+
[CostTrackingTelemetryAttributeNames.component]: args.component,
|
|
1197
|
+
[CostTrackingTelemetryAttributeNames.provider]: args.provider,
|
|
1198
|
+
[CostTrackingTelemetryAttributeNames.operation]: args.operation,
|
|
1199
|
+
[CostTrackingTelemetryAttributeNames.pricingKey]: args.pricingKey,
|
|
1200
|
+
[CostTrackingTelemetryAttributeNames.usageUnit]: args.usageUnit,
|
|
1201
|
+
[CostTrackingTelemetryAttributeNames.currency]: currency,
|
|
1202
|
+
[CostTrackingTelemetryAttributeNames.currencyScale]: currencyScale,
|
|
1203
|
+
[CostTrackingTelemetryAttributeNames.estimateKind]: "catalog"
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
};
|
|
1207
|
+
|
|
1208
|
+
//#endregion
|
|
1209
|
+
//#region src/execution/CatalogBackedCostTrackingTelemetryFactory.ts
|
|
1210
|
+
var CatalogBackedCostTrackingTelemetryFactory = class {
|
|
1211
|
+
constructor(costCatalog) {
|
|
1212
|
+
this.costCatalog = costCatalog;
|
|
1213
|
+
}
|
|
1214
|
+
create(args) {
|
|
1215
|
+
return new CatalogBackedCostTrackingTelemetry(args.telemetry, this.costCatalog);
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1218
|
+
|
|
836
1219
|
//#endregion
|
|
837
1220
|
//#region src/execution/InProcessRetryRunner.ts
|
|
838
1221
|
var InProcessRetryRunner = class InProcessRetryRunner {
|
|
@@ -931,22 +1314,6 @@ var ItemExprResolver = class {
|
|
|
931
1314
|
}
|
|
932
1315
|
};
|
|
933
1316
|
|
|
934
|
-
//#endregion
|
|
935
|
-
//#region src/contracts/emitPorts.ts
|
|
936
|
-
const EMIT_PORTS_BRAND = Symbol.for("codemation.emitPorts");
|
|
937
|
-
function emitPorts(ports) {
|
|
938
|
-
return {
|
|
939
|
-
[EMIT_PORTS_BRAND]: true,
|
|
940
|
-
ports
|
|
941
|
-
};
|
|
942
|
-
}
|
|
943
|
-
function isPortsEmission(value) {
|
|
944
|
-
return typeof value === "object" && value !== null && EMIT_PORTS_BRAND in value && value[EMIT_PORTS_BRAND] === true;
|
|
945
|
-
}
|
|
946
|
-
function isUnbrandedPortsEmissionShape(value) {
|
|
947
|
-
return typeof value === "object" && value !== null && "ports" in value && !isPortsEmission(value);
|
|
948
|
-
}
|
|
949
|
-
|
|
950
1317
|
//#endregion
|
|
951
1318
|
//#region src/execution/NodeOutputNormalizer.ts
|
|
952
1319
|
var NodeOutputNormalizer = class {
|
|
@@ -1090,6 +1457,10 @@ var NodeActivationRequestComposer = class {
|
|
|
1090
1457
|
nodeId: definition.id,
|
|
1091
1458
|
activationId,
|
|
1092
1459
|
config: definition.config,
|
|
1460
|
+
telemetry: args.base.telemetry.forNode({
|
|
1461
|
+
nodeId: definition.id,
|
|
1462
|
+
activationId
|
|
1463
|
+
}),
|
|
1093
1464
|
binary: args.base.binary.forNode({
|
|
1094
1465
|
nodeId: definition.id,
|
|
1095
1466
|
activationId
|
|
@@ -1886,6 +2257,7 @@ var WorkflowRunExecutionContextFactory = class {
|
|
|
1886
2257
|
runId: args.runId,
|
|
1887
2258
|
workflowId: args.workflowId,
|
|
1888
2259
|
parent: args.parent,
|
|
2260
|
+
policySnapshot: args.policySnapshot,
|
|
1889
2261
|
subworkflowDepth: args.subworkflowDepth,
|
|
1890
2262
|
engineMaxNodeActivations: args.engineMaxNodeActivations,
|
|
1891
2263
|
engineMaxSubworkflowDepth: args.engineMaxSubworkflowDepth,
|
|
@@ -1896,6 +2268,24 @@ var WorkflowRunExecutionContextFactory = class {
|
|
|
1896
2268
|
}
|
|
1897
2269
|
};
|
|
1898
2270
|
|
|
2271
|
+
//#endregion
|
|
2272
|
+
//#region src/execution/StaticCostCatalog.ts
|
|
2273
|
+
var StaticCostCatalog = class {
|
|
2274
|
+
entriesByKey;
|
|
2275
|
+
constructor(entries) {
|
|
2276
|
+
this.entriesByKey = new Map(entries.map((entry) => [this.createKeyFromEntry(entry), entry]));
|
|
2277
|
+
}
|
|
2278
|
+
findEntry(args) {
|
|
2279
|
+
return this.entriesByKey.get(this.createKeyFromUsage(args));
|
|
2280
|
+
}
|
|
2281
|
+
createKeyFromEntry(entry) {
|
|
2282
|
+
return `${entry.component}::${entry.provider}::${entry.operation}::${entry.pricingKey}::${entry.usageUnit}`;
|
|
2283
|
+
}
|
|
2284
|
+
createKeyFromUsage(args) {
|
|
2285
|
+
return `${args.component}::${args.provider}::${args.operation}::${args.pricingKey}::${args.usageUnit}`;
|
|
2286
|
+
}
|
|
2287
|
+
};
|
|
2288
|
+
|
|
1899
2289
|
//#endregion
|
|
1900
2290
|
//#region src/planning/WorkflowTopologyPlanner.ts
|
|
1901
2291
|
var WorkflowTopology = class WorkflowTopology {
|
|
@@ -2035,6 +2425,7 @@ var RunContinuationService = class {
|
|
|
2035
2425
|
workflowId: state.workflowId,
|
|
2036
2426
|
nodeId: args.nodeId,
|
|
2037
2427
|
parent: state.parent,
|
|
2428
|
+
policySnapshot: state.policySnapshot,
|
|
2038
2429
|
subworkflowDepth: state.executionOptions?.subworkflowDepth ?? 0,
|
|
2039
2430
|
engineMaxNodeActivations: limits.engineMaxNodeActivations,
|
|
2040
2431
|
engineMaxSubworkflowDepth: limits.engineMaxSubworkflowDepth,
|
|
@@ -2555,6 +2946,7 @@ var RunContinuationService = class {
|
|
|
2555
2946
|
workflowId: args.state.workflowId,
|
|
2556
2947
|
nodeId: nextDefinition.id,
|
|
2557
2948
|
parent: args.state.parent,
|
|
2949
|
+
policySnapshot: args.state.policySnapshot,
|
|
2558
2950
|
subworkflowDepth: args.state.executionOptions?.subworkflowDepth ?? 0,
|
|
2559
2951
|
engineMaxNodeActivations: webhookLimits.engineMaxNodeActivations,
|
|
2560
2952
|
engineMaxSubworkflowDepth: webhookLimits.engineMaxSubworkflowDepth,
|
|
@@ -2645,6 +3037,7 @@ var RunContinuationService = class {
|
|
|
2645
3037
|
workflowId: state.workflowId,
|
|
2646
3038
|
nodeId,
|
|
2647
3039
|
parent: state.parent,
|
|
3040
|
+
policySnapshot: state.policySnapshot,
|
|
2648
3041
|
subworkflowDepth: state.executionOptions?.subworkflowDepth ?? 0,
|
|
2649
3042
|
engineMaxNodeActivations: limits.engineMaxNodeActivations,
|
|
2650
3043
|
engineMaxSubworkflowDepth: limits.engineMaxSubworkflowDepth,
|
|
@@ -2658,6 +3051,10 @@ var RunContinuationService = class {
|
|
|
2658
3051
|
nodeId,
|
|
2659
3052
|
activationId,
|
|
2660
3053
|
config: def.config,
|
|
3054
|
+
telemetry: base.telemetry.forNode({
|
|
3055
|
+
nodeId,
|
|
3056
|
+
activationId
|
|
3057
|
+
}),
|
|
2661
3058
|
binary: base.binary.forNode({
|
|
2662
3059
|
nodeId,
|
|
2663
3060
|
activationId
|
|
@@ -3026,6 +3423,9 @@ var RunPolicySnapshotFactory = class {
|
|
|
3026
3423
|
return {
|
|
3027
3424
|
retentionSeconds: prune?.runDataRetentionSeconds ?? defaults?.retentionSeconds,
|
|
3028
3425
|
binaryRetentionSeconds: prune?.binaryRetentionSeconds ?? defaults?.binaryRetentionSeconds,
|
|
3426
|
+
telemetrySpanRetentionSeconds: prune?.telemetrySpanRetentionSeconds ?? defaults?.telemetrySpanRetentionSeconds,
|
|
3427
|
+
telemetryArtifactRetentionSeconds: prune?.telemetryArtifactRetentionSeconds ?? defaults?.telemetryArtifactRetentionSeconds,
|
|
3428
|
+
telemetryMetricRetentionSeconds: prune?.telemetryMetricRetentionSeconds ?? defaults?.telemetryMetricRetentionSeconds,
|
|
3029
3429
|
storagePolicy: typeof workflow.storagePolicy === "string" ? workflow.storagePolicy : defaults?.storagePolicy ?? "ALL"
|
|
3030
3430
|
};
|
|
3031
3431
|
}
|
|
@@ -3073,6 +3473,7 @@ var RunStartService = class {
|
|
|
3073
3473
|
workflowId: workflow.id,
|
|
3074
3474
|
nodeId: startAt,
|
|
3075
3475
|
parent,
|
|
3476
|
+
policySnapshot,
|
|
3076
3477
|
subworkflowDepth: mergedExecutionOptions.subworkflowDepth ?? 0,
|
|
3077
3478
|
engineMaxNodeActivations: mergedExecutionOptions.maxNodeActivations,
|
|
3078
3479
|
engineMaxSubworkflowDepth: mergedExecutionOptions.maxSubworkflowDepth,
|
|
@@ -3171,6 +3572,7 @@ var RunStartService = class {
|
|
|
3171
3572
|
workflowId: request.workflow.id,
|
|
3172
3573
|
nodeId: WorkflowExecutableNodeClassifierFactory.create(request.workflow).firstExecutableNodeIdInDefinitionOrder(request.workflow) ?? "unknown_node",
|
|
3173
3574
|
parent: request.parent,
|
|
3575
|
+
policySnapshot,
|
|
3174
3576
|
subworkflowDepth: mergedExecutionOptions.subworkflowDepth ?? 0,
|
|
3175
3577
|
engineMaxNodeActivations: mergedExecutionOptions.maxNodeActivations,
|
|
3176
3578
|
engineMaxSubworkflowDepth: mergedExecutionOptions.maxSubworkflowDepth,
|
|
@@ -3823,19 +4225,6 @@ var InMemoryRunDataFactory = class {
|
|
|
3823
4225
|
}
|
|
3824
4226
|
};
|
|
3825
4227
|
|
|
3826
|
-
//#endregion
|
|
3827
|
-
//#region src/contracts/runFinishedAtFactory.ts
|
|
3828
|
-
/** Derives workflow end time from persisted run root or node snapshots for run listings. */
|
|
3829
|
-
var RunFinishedAtFactory = class {
|
|
3830
|
-
static resolveIso(state) {
|
|
3831
|
-
if (state.finishedAt && state.status !== "running" && state.status !== "pending") return state.finishedAt;
|
|
3832
|
-
if (state.status === "running" || state.status === "pending") return;
|
|
3833
|
-
let max;
|
|
3834
|
-
for (const snap of Object.values(state.nodeSnapshotsByNodeId)) if (snap?.finishedAt && (!max || snap.finishedAt > max)) max = snap.finishedAt;
|
|
3835
|
-
return max;
|
|
3836
|
-
}
|
|
3837
|
-
};
|
|
3838
|
-
|
|
3839
4228
|
//#endregion
|
|
3840
4229
|
//#region src/orchestration/NodeExecutionRequestHandlerService.ts
|
|
3841
4230
|
var NodeExecutionRequestHandlerService = class {
|
|
@@ -3870,6 +4259,7 @@ var NodeExecutionRequestHandlerService = class {
|
|
|
3870
4259
|
workflowId: state.workflowId,
|
|
3871
4260
|
nodeId: request.nodeId,
|
|
3872
4261
|
parent: resolvedParent,
|
|
4262
|
+
policySnapshot: state.policySnapshot,
|
|
3873
4263
|
subworkflowDepth: state.executionOptions?.subworkflowDepth ?? 0,
|
|
3874
4264
|
engineMaxNodeActivations: limits.engineMaxNodeActivations,
|
|
3875
4265
|
engineMaxSubworkflowDepth: limits.engineMaxSubworkflowDepth,
|
|
@@ -4880,5 +5270,5 @@ var WorkflowRepositoryWebhookTriggerMatcherFactory = class {
|
|
|
4880
5270
|
};
|
|
4881
5271
|
|
|
4882
5272
|
//#endregion
|
|
4883
|
-
export {
|
|
4884
|
-
//# sourceMappingURL=runtime-
|
|
5273
|
+
export { CostTrackingTelemetryMetricNames as $, NodeExecutor as A, inject as At, nodeRef as B, StaticCostCatalog as C, tool as Ct, PersistedWorkflowTokenRegistry as D, PersistedRuntimeTypeNameResolver as Dt, WorkflowSnapshotCodec as E, StackTraceCallSitePathResolver as Et, InProcessRetryRunner as F, predicateAwareClassFactory as Ft, NoOpExecutionTelemetryFactory as G, CodemationTelemetryMetricNames as H, CatalogBackedCostTrackingTelemetryFactory as I, registry as It, NoOpTelemetrySpanScope as J, NoOpExecutionTelemetry as K, DefaultExecutionContextFactory as L, singleton as Lt, RunnableOutputBehaviorResolver as M, injectable as Mt, NodeOutputNormalizer as N, instanceCachingFactory as Nt, MissingRuntimeTriggerToken as O, container$1 as Ot, ItemExprResolver as P, instancePerContainerCachingFactory as Pt, CostTrackingTelemetryAttributeNames as Q, AllWorkflowsActiveWorkflowActivationPolicy as R, CoreTokens as Rt, RunPolicySnapshotFactory as S, node as St, NodeInstanceFactory as T, PersistedRuntimeTypeMetadataStore as Tt, GenAiTelemetryAttributeNames as U, RunFinishedAtFactory as V, CodemationTelemetryAttributeNames as W, NoOpCostTrackingTelemetryFactory as X, NoOpTelemetryArtifactReference as Y, NoOpCostTrackingTelemetry as Z, LocalOnlyScheduler as _, itemExpr as _t, InMemoryLiveWorkflowRepository as a, isPortsEmission as at, DefaultDrivingScheduler as b, chatModel as bt, EngineFactory as c, CredentialResolverFactory as ct, InMemoryBinaryStorage as d, UnavailableBinaryStorage as dt, CredentialUnboundError as et, WorkflowStoragePolicyEvaluator as f, NodeEventPublisher as ft, EngineExecutionLimitsPolicy as g, isItemExpr as gt, ENGINE_EXECUTION_LIMITS_DEFAULTS as h, ConnectionNodeIdFactory as ht, RunIntentService as i, emitPorts as it, InProcessRetryRunnerFactory as j, injectAll as jt, NodeExecutorFactory as k, delay as kt, Engine as l, getOriginIndexFromItem as lt, RunTerminalPersistenceCoordinator as m, WorkflowExecutableNodeClassifier as mt, WorkflowRepositoryWebhookTriggerMatcher as n, RetryPolicy as nt, EngineWorkflowRunnerServiceFactory as o, isUnbrandedPortsEmissionShape as ot, WorkflowPolicyErrorServices as p, WorkflowExecutableNodeClassifierFactory as pt, NoOpNodeExecutionTelemetry as q, RunIntentServiceFactory as r, NoRetryPolicy as rt, EngineWorkflowRunnerService as s, DefaultAsyncSleeper as st, WorkflowRepositoryWebhookTriggerMatcherFactory as t, ExpRetryPolicy as tt, InMemoryRunDataFactory as u, DefaultExecutionBinaryService as ut, InlineDrivingScheduler as v, resolveItemExprsForExecution as vt, NodeInstanceFactoryFactory as w, InjectableRuntimeDecoratorComposer as wt, ConfigDrivenOffloadPolicy as x, getPersistedRuntimeTypeMetadata as xt, HintOnlyOffloadPolicy as y, resolveItemExprsInUnknown as yt, branchRef as z };
|
|
5274
|
+
//# sourceMappingURL=runtime-DUW6tIJ1.js.map
|