@codemation/core 0.0.18 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @codemation/core
2
2
 
3
+ ## 0.0.19
4
+
5
+ ### Patch Changes
6
+
7
+ - [#26](https://github.com/MadeRelevant/codemation/pull/26) [`405c854`](https://github.com/MadeRelevant/codemation/commit/405c8541961f41dcba653f352691a821b0470ca0) Thanks [@cblokland90](https://github.com/cblokland90)! - Fix manual trigger reruns and current-state resume behavior.
8
+
9
+ Current-state execution now treats empty upstream outputs like the live queue planner, so untaken branches stay dead on resume. Manual downstream runs can also synthesize trigger test items through core intent handling instead of relying on host-specific trigger logic.
10
+
3
11
  ## 0.0.18
4
12
 
5
13
  ### Patch Changes
@@ -2236,7 +2236,10 @@ var CurrentStateFrontierPlanner = class CurrentStateFrontierPlanner {
2236
2236
  isEdgeSatisfied(currentState, nodeId, input) {
2237
2237
  const incomingEdge = (this.topology.incomingByNode.get(nodeId) ?? []).find((edge) => edge.input === input);
2238
2238
  if (!incomingEdge) return false;
2239
- return this.hasOutputPort(currentState, incomingEdge.from.nodeId, incomingEdge.from.output);
2239
+ if (!this.hasOutputPort(currentState, incomingEdge.from.nodeId, incomingEdge.from.output)) return false;
2240
+ if (this.usesCollect(nodeId)) return true;
2241
+ if (this.resolveOutputItems(currentState, incomingEdge.from.nodeId, incomingEdge.from.output).length > 0) return true;
2242
+ return this.shouldContinueAfterEmptyOutputFromSource(incomingEdge.from.nodeId);
2240
2243
  }
2241
2244
  resolveInput(currentState, nodeId, input) {
2242
2245
  const incomingEdge = (this.topology.incomingByNode.get(nodeId) ?? []).find((edge) => edge.input === input);
@@ -2258,6 +2261,15 @@ var CurrentStateFrontierPlanner = class CurrentStateFrontierPlanner {
2258
2261
  resolveOutputItems(currentState, nodeId, output) {
2259
2262
  return currentState.outputsByNode[nodeId]?.[output] ?? [];
2260
2263
  }
2264
+ usesCollect(nodeId) {
2265
+ const expectedInputs = this.topology.expectedInputsByNode.get(nodeId) ?? [];
2266
+ return expectedInputs.length !== 1 || expectedInputs[0] !== "in";
2267
+ }
2268
+ shouldContinueAfterEmptyOutputFromSource(nodeId) {
2269
+ const definition = this.topology.defsById.get(nodeId);
2270
+ if (!definition) return false;
2271
+ return definition.config.continueWhenEmptyOutput === true;
2272
+ }
2261
2273
  getPinnedOutputs(currentState, nodeId) {
2262
2274
  return currentState.mutableState?.nodesById?.[nodeId]?.pinnedOutputsByPort;
2263
2275
  }
@@ -3052,13 +3064,14 @@ var RunIntentService = class {
3052
3064
  this.workflowRepository = workflowRepository;
3053
3065
  }
3054
3066
  async startWorkflow(args) {
3055
- if (args.startAt && !args.currentState && !args.stopCondition && !args.reset) return await this.engine.runWorkflow(args.workflow, args.startAt, args.items, args.parent, args.executionOptions, {
3067
+ const items = await this.resolveStartWorkflowItems(args);
3068
+ if (args.startAt && !args.currentState && !args.stopCondition && !args.reset) return await this.engine.runWorkflow(args.workflow, args.startAt, items, args.parent, args.executionOptions, {
3056
3069
  workflowSnapshot: args.workflowSnapshot,
3057
3070
  mutableState: args.mutableState
3058
3071
  });
3059
3072
  return await this.engine.runWorkflowFromState({
3060
3073
  workflow: args.workflow,
3061
- items: args.items,
3074
+ items,
3062
3075
  parent: args.parent,
3063
3076
  executionOptions: args.executionOptions,
3064
3077
  workflowSnapshot: args.workflowSnapshot,
@@ -3069,7 +3082,8 @@ var RunIntentService = class {
3069
3082
  });
3070
3083
  }
3071
3084
  async rerunFromNode(args) {
3072
- if (args.items) return await this.engine.runWorkflow(args.workflow, args.nodeId, args.items, args.parent, args.executionOptions, {
3085
+ const items = await this.resolveRerunItems(args);
3086
+ if (items) return await this.engine.runWorkflow(args.workflow, args.nodeId, items, args.parent, args.executionOptions, {
3073
3087
  workflowSnapshot: args.workflowSnapshot,
3074
3088
  mutableState: args.mutableState
3075
3089
  });
@@ -3084,6 +3098,44 @@ var RunIntentService = class {
3084
3098
  reset: { clearFromNodeId: args.nodeId }
3085
3099
  });
3086
3100
  }
3101
+ async resolveStartWorkflowItems(args) {
3102
+ if (this.hasNonEmptyItems(args.items)) return args.items;
3103
+ const triggerNodeId = this.resolveStartWorkflowTriggerNodeId(args);
3104
+ if (!triggerNodeId) return args.items;
3105
+ return await this.engine.createTriggerTestItems({
3106
+ workflow: args.workflow,
3107
+ nodeId: triggerNodeId
3108
+ }) ?? args.items;
3109
+ }
3110
+ async resolveRerunItems(args) {
3111
+ if (this.hasNonEmptyItems(args.items)) return args.items;
3112
+ const triggerNodeId = this.resolveRerunTriggerNodeId(args);
3113
+ if (!triggerNodeId) return args.items;
3114
+ return await this.engine.createTriggerTestItems({
3115
+ workflow: args.workflow,
3116
+ nodeId: triggerNodeId
3117
+ }) ?? args.items;
3118
+ }
3119
+ resolveStartWorkflowTriggerNodeId(args) {
3120
+ if (args.stopCondition?.kind === "nodeCompleted" && this.isTriggerNode(args.workflow, args.stopCondition.nodeId)) return args.stopCondition.nodeId;
3121
+ if (!args.synthesizeTriggerItems) return;
3122
+ if (args.startAt && this.isTriggerNode(args.workflow, args.startAt)) return args.startAt;
3123
+ return this.firstTriggerNodeId(args.workflow);
3124
+ }
3125
+ resolveRerunTriggerNodeId(args) {
3126
+ if (this.isTriggerNode(args.workflow, args.nodeId)) return args.nodeId;
3127
+ if (!args.synthesizeTriggerItems) return;
3128
+ return this.firstTriggerNodeId(args.workflow);
3129
+ }
3130
+ firstTriggerNodeId(workflow) {
3131
+ return workflow.nodes.find((node$1) => node$1.kind === "trigger")?.id;
3132
+ }
3133
+ isTriggerNode(workflow, nodeId) {
3134
+ return workflow.nodes.find((node$1) => node$1.id === nodeId)?.kind === "trigger";
3135
+ }
3136
+ hasNonEmptyItems(items) {
3137
+ return (items?.length ?? 0) > 0;
3138
+ }
3087
3139
  resolveWebhookTrigger(args) {
3088
3140
  return this.engine.resolveWebhookTrigger(args);
3089
3141
  }
@@ -3133,4 +3185,4 @@ var RunIntentService = class {
3133
3185
 
3134
3186
  //#endregion
3135
3187
  export { injectAll as $, InProcessRetryRunnerFactory as A, WorkflowExecutableNodeClassifier as B, PersistedWorkflowTokenRegistry as C, NodeExecutorFactory as D, MissingRuntimeExecutionMarker as E, ActivationEnqueueService as F, tool as G, chatModel as H, DefaultExecutionBinaryService as I, StackTraceCallSitePathResolver as J, InjectableRuntimeDecoratorComposer as K, UnavailableBinaryStorage as L, DefaultExecutionContextFactory as M, DefaultAsyncSleeper as N, NodeExecutor as O, CredentialResolverFactory as P, inject as Q, NodeEventPublisher as R, WorkflowSnapshotResolver as S, MissingRuntimeTriggerToken as T, getPersistedRuntimeTypeMetadata as U, ConnectionNodeIdFactory as V, node as W, container as X, PersistedRuntimeTypeNameResolver as Y, delay as Z, RunStateSemantics as _, ENGINE_EXECUTION_LIMITS_DEFAULTS as a, singleton as at, NodeInstanceFactoryFactory as b, InlineDrivingScheduler as c, ConfigDrivenOffloadPolicy as d, injectable as et, RunStartService as f, WorkflowRunExecutionContextFactory as g, WorkflowTopology as h, InMemoryBinaryStorage as i, registry as it, InProcessRetryRunner as j, NodeActivationRequestComposer as k, HintOnlyOffloadPolicy as l, RunContinuationService as m, RunFinishedAtFactory as n, instancePerContainerCachingFactory as nt, EngineExecutionLimitsPolicy as o, CoreTokens as ot, RunPolicySnapshotFactory as p, PersistedRuntimeTypeMetadataStore as q, InMemoryRunDataFactory as r, predicateAwareClassFactory as rt, LocalOnlyScheduler as s, RunIntentService as t, instanceCachingFactory as tt, DefaultDrivingScheduler as u, PersistedRunStateTerminalBuilder as v, MissingRuntimeFallbacks as w, NodeInstanceFactory as x, NodeRunStateWriterFactory as y, WorkflowExecutableNodeClassifierFactory as z };
3136
- //# sourceMappingURL=RunIntentService-BB4nqX3-.js.map
3188
+ //# sourceMappingURL=RunIntentService-C1nu_YwM.js.map