@codemation/core 0.8.1 → 1.0.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 +74 -0
- package/dist/{EngineRuntimeRegistration.types-BP6tsaNP.d.ts → EngineRuntimeRegistration.types-kxQA5NLt.d.ts} +2 -2
- package/dist/{EngineWorkflowRunnerService-DzOCa1BW.d.cts → EngineWorkflowRunnerService-Ba2AvBnL.d.cts} +2 -2
- package/dist/{InMemoryRunDataFactory-1iz7_SnO.d.cts → InMemoryRunDataFactory-Ou4tQUOS.d.cts} +2 -2
- package/dist/{RunIntentService-S-1lW-gS.d.cts → RunIntentService-Dyh_dH0k.d.cts} +528 -467
- package/dist/{RunIntentService-BqhmdoA1.d.ts → RunIntentService-dteLjNiT.d.ts} +568 -462
- package/dist/bootstrap/index.cjs +2 -2
- package/dist/bootstrap/index.d.cts +3 -3
- package/dist/bootstrap/index.d.ts +3 -3
- package/dist/bootstrap/index.js +2 -2
- package/dist/{bootstrap-BoknFKnw.js → bootstrap-CL68rqWg.js} +3 -2
- package/dist/bootstrap-CL68rqWg.js.map +1 -0
- package/dist/{bootstrap-Bx1u4cbS.cjs → bootstrap-Cko6udwL.cjs} +3 -2
- package/dist/bootstrap-Cko6udwL.cjs.map +1 -0
- package/dist/{index-CVs9rVhl.d.ts → index-CyfGTfU1.d.ts} +84 -14
- package/dist/index.cjs +10 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +129 -14
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -11
- package/dist/index.js.map +1 -1
- package/dist/{runtime-DUW6tIJ1.js → runtime-284ok0cm.js} +201 -31
- package/dist/runtime-284ok0cm.js.map +1 -0
- package/dist/{runtime-Dvo2ru5A.cjs → runtime-B3Og-_St.cjs} +223 -29
- package/dist/runtime-B3Og-_St.cjs.map +1 -0
- package/dist/testing.cjs +2 -2
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +2 -2
- package/package.json +1 -1
- package/src/ai/AiHost.ts +42 -14
- package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +4 -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/executionPersistenceContracts.ts +30 -0
- package/src/contracts/runTypes.ts +10 -0
- package/src/contracts/runtimeTypes.ts +8 -0
- package/src/contracts/telemetryTypes.ts +8 -0
- package/src/contracts/workflowTypes.ts +6 -0
- package/src/events/ConnectionInvocationEventPublisher.ts +46 -0
- package/src/events/index.ts +1 -0
- package/src/events/runEvents.ts +25 -0
- package/src/execution/ChildExecutionScopeFactory.ts +58 -0
- package/src/execution/ExecutionTelemetryCostTrackingDecoratorFactory.ts +18 -0
- package/src/execution/NodeExecutor.ts +10 -2
- package/src/execution/NodeRunStateWriter.ts +7 -0
- package/src/execution/NodeRunStateWriterFactory.ts +7 -0
- package/src/execution/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/orchestration/RunStartService.ts +8 -1
- package/src/runtime/EngineFactory.ts +1 -0
- package/src/workflow/definition/NodeIterationIdFactory.ts +26 -0
- package/src/workflow/index.ts +1 -0
- package/dist/bootstrap-BoknFKnw.js.map +0 -1
- package/dist/bootstrap-Bx1u4cbS.cjs.map +0 -1
- package/dist/runtime-DUW6tIJ1.js.map +0 -1
- package/dist/runtime-Dvo2ru5A.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
1
|
# @codemation/core
|
|
2
2
|
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ed75183`](https://github.com/MadeRelevant/codemation/commit/ed75183f51ae71b06aa2e57ae4fc48ce9db2e4ce) - Establish "per Item per Call" identity end-to-end so the workflow run inspector reports, visualizes, and dashboards multi-item AI agents correctly.
|
|
8
|
+
|
|
9
|
+
Previously, an orchestrator agent that processed N items emitted one flat list of LLM rounds and tool calls — the bottom execution tree, the right-panel agent timeline, cost dashboards, and the realtime event stream all collapsed iterations into one bucket, making sub-agent fan-outs (and parallel item processing in general) unreadable.
|
|
10
|
+
|
|
11
|
+
**What changed**
|
|
12
|
+
- **Engine** (`@codemation/core`): `NodeExecutor` mints a `NodeIterationId` per item inside per-item runnable activations and stamps it (with `itemIndex`) onto `NodeExecutionContext`. Connection invocations, telemetry spans (`gen_ai.chat.completion`, `agent.tool.call`), metric points (`codemation.cost.estimated`, `codemation.agent.turns`, `codemation.agent.tool_calls`), and run events all carry the per-item identity. New `ChildExecutionScopeFactory` re-roots `NodeExecutionContext` for sub-agents so credentials and iteration ids resolve correctly across the orchestrator → tool → sub-agent boundary.
|
|
13
|
+
- **Sub-agent credentials** (`@codemation/core-nodes`): `NodeBackedToolRuntime.resolveNodeCtx` no longer re-wraps `args.ctx.nodeId` with `ConnectionNodeIdFactory.toolConnectionNodeId` — the caller already pre-wraps it. The previous double-nesting produced exponentially deep node ids (`AIAgentNode:2__conn__tool__conn__searchInMail__conn__tool__conn__searchInMail__conn__llm`) that didn't match user-bound credential slots. Sub-agent OpenAI / API-key slots resolve again.
|
|
14
|
+
- **Realtime events**: new `connectionInvocationStarted` / `connectionInvocationCompleted` / `connectionInvocationFailed` events carry the full `ConnectionInvocationRecord` (incl. `iterationId`, `itemIndex`, `parentInvocationId`) and surgical reducers update the run cache without waiting for a coarse `runSaved` snapshot. Run-query polling dropped from 250 ms → 5 s now that WebSocket events drive most updates.
|
|
15
|
+
- **Persistence** (`@codemation/host`): Prisma `ExecutionInstance` model gains `iteration_id`, `item_index`, `parent_invocation_id` columns + index (sqlite + postgres migrations); `PrismaWorkflowRunRepository` round-trips them on read/save and via `ExecutionInstanceDto`. Without this the cold reload of a finished run silently flattens the per-item tree because `runSaved` events stream through Prisma. Telemetry tables already carried these columns from Phase 4; both sides now agree.
|
|
16
|
+
- **Iteration projection / cost queries** (`@codemation/host`): new `RunIterationProjectionFactory` projects `RunIterationRecord`s from connection invocations + iteration cost metrics and `GetIterationCostQueryHandler` serves per-iteration cost rollups for dashboards.
|
|
17
|
+
- **Inspector view model** (`@codemation/next-host`): `NodeInspectorTelemetryPresenter` groups LLM and tool spans by `iterationId` into "Item N" accordion entries (single-item agents fall back to flat layout). New `FocusedInvocationModelFactory` powers item-level prev/next navigation when a specific invocation is selected — the breadcrumb shows "Item X of Y" and nav targets the first invocation of adjacent items. Tool spans now interleave chronologically with LLM rounds (request → tools → response) instead of LLM rounds first then orphan tools at the bottom.
|
|
18
|
+
- **Bottom execution tree** (`@codemation/next-host`): new `ExecutionTreeItemGroupInjector` injects synthetic "Item N" parent rows between an agent and its connection invocations when the agent processed 2+ items. Single-item activations are left untouched; sub-agent invocations whose `parentInvocationId` already points at a tool-call row stay nested under the orchestrator's specific tool call.
|
|
19
|
+
- **Sub-agent credential boundary**: `ChildExecutionScopeFactory.forSubAgent` ensures sub-agent `NodeExecutionContext` keeps the parent invocation id and span context intact so trace nesting and credential resolution agree on the connection-node id.
|
|
20
|
+
- **Tests**: new unit + UI suites for each layer (sub-agent scope, item-group injector, focused invocation model, agent timeline per-item grouping, chronological ordering, Prisma iterationId round trip, item-aware properties panel, connection-invocation event publisher) and a runnable `apps/test-dev` sample (`agentSubAgentToolFanout`) that exercises the orchestrator → sub-agent fan-out across 2 items end-to-end.
|
|
21
|
+
|
|
22
|
+
## 1.0.0
|
|
23
|
+
|
|
24
|
+
### Major Changes
|
|
25
|
+
|
|
26
|
+
- [#93](https://github.com/MadeRelevant/codemation/pull/93) [`640e303`](https://github.com/MadeRelevant/codemation/commit/640e3032b1386568df725980a27761b6e230302c) Thanks [@cblokland90](https://github.com/cblokland90)! - Replace LangChain with the Vercel AI SDK for all AIAgent flows.
|
|
27
|
+
|
|
28
|
+
Codemation no longer depends on `@langchain/core` or `@langchain/openai`. Chat model providers, the turn loop, structured output, and tool calls now run on top of the Vercel **AI SDK** (`ai`, `@ai-sdk/openai`, `@ai-sdk/provider`). Custom Codemation behaviors that LangChain did not cover — the **tool-args repair loop**, the **structured-output repair loop**, **connection-invocation tracking**, and our **telemetry / cost-tracking spans** — are preserved and built on top of the new primitives.
|
|
29
|
+
|
|
30
|
+
### Dependency changes
|
|
31
|
+
- **Removed**: `@langchain/core`, `@langchain/openai` (from `@codemation/core-nodes`).
|
|
32
|
+
- **Added**: `ai` `^6.0.168`, `@ai-sdk/openai` `^3.0.53`, `@ai-sdk/provider` `^3.0.8` (to `@codemation/core-nodes`). `@codemation/host` picks up `ai` + `@ai-sdk/provider` for its test harness only.
|
|
33
|
+
|
|
34
|
+
### Public API renames (`@codemation/core`)
|
|
35
|
+
|
|
36
|
+
| Before | After |
|
|
37
|
+
| ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
38
|
+
| `LangChainChatModelLike` | `ChatLanguageModel` |
|
|
39
|
+
| `LangChainStructuredOutputModelLike` | _(removed — replaced by `StructuredOutputOptions` + `generateText({ experimental_output: Output.object(...) })`)_ |
|
|
40
|
+
| `ChatModelFactory.create` → `LangChainChatModelLike` | `ChatModelFactory.create` → `ChatLanguageModel` (thin wrapper around an AI SDK `LanguageModelV2`) |
|
|
41
|
+
|
|
42
|
+
`ChatLanguageModel` exposes the underlying AI SDK `LanguageModel` via `languageModel` plus `modelName`, `provider`, and optional `defaultCallOptions` (`maxOutputTokens`, `temperature`, `providerOptions`). `StructuredOutputOptions` mirrors `generateText({ output: Output.object(...) })` and carries an optional `schemaName` plus `strict` flag.
|
|
43
|
+
|
|
44
|
+
### Custom behavior preserved (not delegated to the AI SDK)
|
|
45
|
+
- **Tool dispatch + tool-args repair**: tools are passed to `generateText` **without `execute`** so tool calls surface back to Codemation; `AgentToolExecutionCoordinator` still drives parallel execution, per-tool Zod-input validation, repair prompts, and retry accounting via `repairAttemptsByToolName`.
|
|
46
|
+
- **Structured output repair**: `AgentStructuredOutputRunner` still runs the `OpenAiStrictJsonSchemaFactory` + `AgentStructuredOutputRepairPromptFactory` loop; AI SDK's `Output.object(...)` is used only for the **first** structured attempt when the provider supports it.
|
|
47
|
+
- **Connection-invocation tracking**: `ConnectionInvocationIdFactory` + synthetic `LanguageModelConnectionNode` / tool connection node states (`queued` / `running` / `completed` / `failed`) are still emitted per turn and per tool call.
|
|
48
|
+
- **Telemetry span names (intentional, short-term)**: LLM calls stay on `gen_ai.chat.completion`, tool calls on `agent.tool.call`, metrics on `codemation.ai.turns` / `codemation.ai.tool_calls` / `codemation.cost.estimated`. We disable AI SDK's built-in telemetry (`experimental_telemetry`) for this cut so host-side telemetry aggregations keep working unchanged. Migrating to AI SDK native span names is intentionally deferred.
|
|
49
|
+
- **Engine-level retry control**: every `generateText` call uses `maxRetries: 0` so Codemation's own retry / repair policy is the single source of truth.
|
|
50
|
+
|
|
51
|
+
### New test utilities
|
|
52
|
+
|
|
53
|
+
Tests that previously scripted `LangChainChatModelLike` now script AI SDK `LanguageModelV3` via `MockLanguageModelV3` from `ai/test`. `@codemation/core-nodes` and `@codemation/host` test files ship small adapters (`ScriptedResponseConverter`, `ScriptedDoGenerateFactory`, `TelemetryResponseConverter`) that translate Codemation's legacy `{ content, tool_calls, usage_metadata }` fixtures into `LanguageModelV3GenerateResult`.
|
|
54
|
+
|
|
55
|
+
### Migration notes for consumers
|
|
56
|
+
- If you implemented a **custom `ChatModelFactory`**, return a `ChatLanguageModel` (wrap an AI SDK `LanguageModelV2`) instead of a LangChain-shaped chat model. The `name` / `modelName` / `provider` on your config still drive cost tracking.
|
|
57
|
+
- If you imported the type `LangChainChatModelLike` (or `LangChainStructuredOutputModelLike`) from `@codemation/core`, switch to `ChatLanguageModel` (and drop structured-output-method imports — `generateText({ experimental_output })` covers it).
|
|
58
|
+
- `OpenAIChatModelFactory` now builds an AI SDK OpenAI provider under the hood; behavior for end users (model presets, credential resolution, token accounting, structured output against strict mode) is unchanged.
|
|
59
|
+
- Telemetry dashboards, trace views, and cost-tracking queries continue to work against the existing Codemation span / metric names.
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- [#93](https://github.com/MadeRelevant/codemation/pull/93) [`640e303`](https://github.com/MadeRelevant/codemation/commit/640e3032b1386568df725980a27761b6e230302c) Thanks [@cblokland90](https://github.com/cblokland90)! - Fix `Unique constraint failed on the fields: (instance_id)` crash when rerunning a workflow that contains an AI agent.
|
|
64
|
+
|
|
65
|
+
Reproduction: build `Manual trigger → AI agent → node → node`, click play on the agent, then click play on the next node (sometimes twice). The second run would fail at `PrismaWorkflowRunRepository.saveOnce` with a Postgres PK violation on the `ExecutionInstance` table.
|
|
66
|
+
|
|
67
|
+
Root cause: `RunStartService.createRunCurrentState` was deep-copying the prior run's `connectionInvocations` verbatim into the new run's initial state. Each record kept its original globally-unique `invocationId`, which is the primary key in `ExecutionInstance`. `saveOnce`'s existing-row lookup is scoped to the current `runId`, so the collision against the prior run's rows was only detected by Postgres when the insert fired.
|
|
68
|
+
|
|
69
|
+
Beyond the crash, the old behavior was also a data-model lie for compliance / OTEL: a `ConnectionInvocationRecord` represents a single auditable LLM / tool call and must belong to exactly one run. Copying it into another run made the same event appear to have happened twice.
|
|
70
|
+
|
|
71
|
+
Fix (domain + defense-in-depth):
|
|
72
|
+
- `@codemation/core` — `RunStartService.createRunCurrentState` now starts new runs with an empty invocation ledger. The prior run's invocations remain queryable on that run's persisted state (their true owner).
|
|
73
|
+
- `@codemation/host` — `PrismaWorkflowRunRepository.buildExecutionInstances` skips any invocation whose `runId` differs from the run being saved, so a stray carry-over from any other code path self-heals instead of crashing the save.
|
|
74
|
+
|
|
75
|
+
UI impact: none for the historical-run view (it reads invocations directly from the selected run). The client-side debugger overlay continues to surface the prior run's invocations locally during a rerun, and inspector telemetry already fetches against each invocation's original `runId`.
|
|
76
|
+
|
|
3
77
|
## 0.8.1
|
|
4
78
|
|
|
5
79
|
### Patch Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Li as DependencyContainer, Nr as WebhookTriggerRoutingDiagnostics, gr as TriggerRuntimeDiagnostics, jr as WebhookTriggerMatcher, na as EngineExecutionLimitsPolicyConfig, vn as WorkflowPolicyRuntimeDefaults } from "./RunIntentService-dteLjNiT.js";
|
|
2
2
|
|
|
3
3
|
//#region src/bootstrap/runtime/EngineRuntimeRegistration.types.d.ts
|
|
4
4
|
|
|
@@ -41,4 +41,4 @@ interface EngineRuntimeRegistrationOptions {
|
|
|
41
41
|
}
|
|
42
42
|
//#endregion
|
|
43
43
|
export { TriggerRuntimeDiagnosticsProvider as n, WebhookTriggerMatcherProvider as r, EngineRuntimeRegistrationOptions as t };
|
|
44
|
-
//# sourceMappingURL=EngineRuntimeRegistration.types-
|
|
44
|
+
//# sourceMappingURL=EngineRuntimeRegistration.types-kxQA5NLt.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Cr as DependencyContainer, E as NodeId, Hr as EngineExecutionLimitsPolicyConfig, I as ParentExecutionRef, X as WorkflowDefinition, _n as WebhookTriggerMatcher, b as NodeConfigBase, ci as PersistedWorkflowSnapshot, cn as WorkflowRepository, f as Items, it as WorkflowPolicyRuntimeDefaults, li as PersistedWorkflowSnapshotNode, nn as TriggerRuntimeDiagnostics, nt as WorkflowId, r as Engine, ui as PersistedWorkflowTokenRegistryLike, vi as RunResult, yn as WebhookTriggerRoutingDiagnostics } from "./RunIntentService-Dyh_dH0k.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/workflowSnapshots/WorkflowSnapshotCodec.d.ts
|
|
4
4
|
declare class WorkflowSnapshotCodec {
|
|
@@ -72,4 +72,4 @@ declare class EngineWorkflowRunnerService {
|
|
|
72
72
|
}
|
|
73
73
|
//#endregion
|
|
74
74
|
export { WorkflowSnapshotCodec as a, WebhookTriggerMatcherProvider as i, EngineRuntimeRegistrationOptions as n, TriggerRuntimeDiagnosticsProvider as r, EngineWorkflowRunnerService as t };
|
|
75
|
-
//# sourceMappingURL=EngineWorkflowRunnerService-
|
|
75
|
+
//# sourceMappingURL=EngineWorkflowRunnerService-Ba2AvBnL.d.cts.map
|
package/dist/{InMemoryRunDataFactory-1iz7_SnO.d.cts → InMemoryRunDataFactory-Ou4tQUOS.d.cts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { At as ExecutionBinaryService, B as RunDataSnapshot, Cn as ExecutionTelemetryFactory, Ct as BinaryStorageReadResult, E as NodeId, Et as BinaryStorageWriteResult, Ht as NodeExecutionContext, I as ParentExecutionRef, Kt as NodeExecutionStatePublisher, L as PersistedRunPolicySnapshot, Mt as ExecutionContextFactory, St as BinaryStorage, U as RunnableNodeConfig, V as RunId, Vt as NodeBinaryAttachmentService, Yn as CostTrackingUsageRecord, a as BinaryAttachment, j as NodeOutputs, jt as ExecutionContext, mr as CredentialSessionService, nt as WorkflowId, qn as CostTrackingTelemetryFactory, u as Item, v as MutableRunData, wt as BinaryStorageStatResult, xt as BinaryBody, y as NodeActivationId, yt as RetryPolicySpec, z as RunDataFactory } from "./RunIntentService-Dyh_dH0k.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/contracts/CostCatalogContract.d.ts
|
|
4
4
|
interface CostCatalogEntry {
|
|
@@ -128,4 +128,4 @@ declare class InMemoryRunDataFactory implements RunDataFactory {
|
|
|
128
128
|
}
|
|
129
129
|
//#endregion
|
|
130
130
|
export { RunnableOutputBehavior as a, InProcessRetryRunner as c, AsyncSleeper as d, CredentialResolverFactory as f, UnavailableBinaryStorage as i, DefaultExecutionContextFactory as l, CostCatalogEntry as m, InMemoryBinaryStorage as n, RunnableOutputBehaviorResolver as o, CostCatalog as p, DefaultExecutionBinaryService as r, ItemExprResolver as s, InMemoryRunDataFactory as t, DefaultAsyncSleeper as u };
|
|
131
|
-
//# sourceMappingURL=InMemoryRunDataFactory-
|
|
131
|
+
//# sourceMappingURL=InMemoryRunDataFactory-Ou4tQUOS.d.cts.map
|