@codemation/host 0.3.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.
Files changed (29) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/{AppConfigFactory-Dq7ttwQ_.d.ts → AppConfigFactory-PFmDg5Sg.d.ts} +3 -3
  3. package/dist/{AppContainerFactory-DL_qZ80U.js → AppContainerFactory-Cr3JeVmg.js} +2 -1
  4. package/dist/{AppContainerFactory-DL_qZ80U.js.map → AppContainerFactory-Cr3JeVmg.js.map} +1 -1
  5. package/dist/{CodemationAppContext-P7P-xZhQ.d.ts → CodemationAppContext-DP_-56c6.d.ts} +2 -2
  6. package/dist/{CodemationAuthoring.types-OMYu7vKP.d.ts → CodemationAuthoring.types-Cr2QZsUX.d.ts} +8 -6
  7. package/dist/{CodemationConfigNormalizer-BCtBrJDe.d.ts → CodemationConfigNormalizer-B8RGUwAe.d.ts} +2 -2
  8. package/dist/{CodemationConsumerConfigLoader-evvw4b_a.d.ts → CodemationConsumerConfigLoader-C_QVwcI3.d.ts} +2 -2
  9. package/dist/{CodemationPluginListMerger-PSTtEQjC.d.ts → CodemationPluginListMerger-Bgn1CIX9.d.ts} +5 -5
  10. package/dist/{CredentialServices-0Hk8RFY1.d.ts → CredentialServices-95DPogx-.d.ts} +3 -3
  11. package/dist/{PublicFrontendBootstrapFactory-D0_ds7nS.d.ts → PublicFrontendBootstrapFactory-C_iLgPV-.d.ts} +2 -2
  12. package/dist/authoring.d.ts +3 -3
  13. package/dist/consumer.d.ts +4 -4
  14. package/dist/credentials.d.ts +3 -3
  15. package/dist/devServerSidecar.d.ts +1 -1
  16. package/dist/{index-CeS2saCe.d.ts → index-W4eSjdCM.d.ts} +26 -15
  17. package/dist/index.d.ts +11 -11
  18. package/dist/index.js +2 -2
  19. package/dist/nextServer.d.ts +7 -7
  20. package/dist/nextServer.js +1 -1
  21. package/dist/{persistenceServer-CJeu1STC.d.ts → persistenceServer-_pqP_0nw.d.ts} +2 -2
  22. package/dist/persistenceServer.d.ts +5 -5
  23. package/dist/{server-DteBORJX.js → server-BE4PLhcb.js} +2 -2
  24. package/dist/{server-DteBORJX.js.map → server-BE4PLhcb.js.map} +1 -1
  25. package/dist/{server-Clvg5x1w.d.ts → server-Q5uwa6iR.d.ts} +5 -5
  26. package/dist/server.d.ts +8 -8
  27. package/dist/server.js +2 -2
  28. package/package.json +7 -5
  29. package/src/infrastructure/persistence/PrismaWorkflowRunRepository.ts +8 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,72 @@
1
1
  # @codemation/host
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`328c975`](https://github.com/MadeRelevant/codemation/commit/328c9759d45b711c177ea9a360ed4960ffdf5ffa)]:
8
+ - @codemation/core-nodes@1.0.1
9
+
10
+ ## 1.0.0
11
+
12
+ ### Major Changes
13
+
14
+ - [#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.
15
+
16
+ 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.
17
+
18
+ ### Dependency changes
19
+ - **Removed**: `@langchain/core`, `@langchain/openai` (from `@codemation/core-nodes`).
20
+ - **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.
21
+
22
+ ### Public API renames (`@codemation/core`)
23
+
24
+ | Before | After |
25
+ | ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
26
+ | `LangChainChatModelLike` | `ChatLanguageModel` |
27
+ | `LangChainStructuredOutputModelLike` | _(removed — replaced by `StructuredOutputOptions` + `generateText({ experimental_output: Output.object(...) })`)_ |
28
+ | `ChatModelFactory.create` → `LangChainChatModelLike` | `ChatModelFactory.create` → `ChatLanguageModel` (thin wrapper around an AI SDK `LanguageModelV2`) |
29
+
30
+ `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.
31
+
32
+ ### Custom behavior preserved (not delegated to the AI SDK)
33
+ - **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`.
34
+ - **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.
35
+ - **Connection-invocation tracking**: `ConnectionInvocationIdFactory` + synthetic `LanguageModelConnectionNode` / tool connection node states (`queued` / `running` / `completed` / `failed`) are still emitted per turn and per tool call.
36
+ - **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.
37
+ - **Engine-level retry control**: every `generateText` call uses `maxRetries: 0` so Codemation's own retry / repair policy is the single source of truth.
38
+
39
+ ### New test utilities
40
+
41
+ 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`.
42
+
43
+ ### Migration notes for consumers
44
+ - 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.
45
+ - 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).
46
+ - `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.
47
+ - Telemetry dashboards, trace views, and cost-tracking queries continue to work against the existing Codemation span / metric names.
48
+
49
+ ### Patch Changes
50
+
51
+ - [#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.
52
+
53
+ 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.
54
+
55
+ 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.
56
+
57
+ 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.
58
+
59
+ Fix (domain + defense-in-depth):
60
+ - `@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).
61
+ - `@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.
62
+
63
+ 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`.
64
+
65
+ - Updated dependencies [[`640e303`](https://github.com/MadeRelevant/codemation/commit/640e3032b1386568df725980a27761b6e230302c), [`640e303`](https://github.com/MadeRelevant/codemation/commit/640e3032b1386568df725980a27761b6e230302c)]:
66
+ - @codemation/core-nodes@1.0.0
67
+ - @codemation/core@1.0.0
68
+ - @codemation/eventbus-redis@0.0.32
69
+
3
70
  ## 0.3.1
4
71
 
5
72
  ### Patch Changes
@@ -1,5 +1,5 @@
1
- import { i as AppPersistenceConfig, r as AppConfig } from "./CodemationAppContext-P7P-xZhQ.js";
2
- import { t as NormalizedCodemationConfig } from "./CodemationConfigNormalizer-BCtBrJDe.js";
1
+ import { i as AppPersistenceConfig, r as AppConfig } from "./CodemationAppContext-DP_-56c6.js";
2
+ import { t as NormalizedCodemationConfig } from "./CodemationConfigNormalizer-B8RGUwAe.js";
3
3
  import { AnyNull, AnyNullClass, DbNull, DbNullClass, Decimal, JsonNull, JsonNullClass, NullTypes as NullTypes$1, ObjectEnumValue, PrismaClientInitializationError, PrismaClientKnownRequestError, PrismaClientRustPanicError, PrismaClientUnknownRequestError, PrismaClientValidationError, RawValue, Sql, Value, empty, isAnyNull, isDbNull, isJsonNull, isObjectEnumValue, join, raw, sql as sqltag } from "@prisma/client-runtime-utils";
4
4
 
5
5
  //#region src/infrastructure/persistence/generated/prisma-postgresql-client/runtime/client.d.ts
@@ -34760,4 +34760,4 @@ declare class AppConfigFactory {
34760
34760
  }
34761
34761
  //#endregion
34762
34762
  export { PrismaClient as i, PrismaMigrationDeployer as n, PrismaDatabaseClient as r, AppConfigFactory as t };
34763
- //# sourceMappingURL=AppConfigFactory-Dq7ttwQ_.d.ts.map
34763
+ //# sourceMappingURL=AppConfigFactory-PFmDg5Sg.d.ts.map
@@ -16571,6 +16571,7 @@ let PrismaWorkflowRunRepository = class PrismaWorkflowRunRepository$1 {
16571
16571
  }
16572
16572
  let cIdx = 0;
16573
16573
  for (const inv of state.connectionInvocations ?? []) {
16574
+ if (inv.runId !== state.runId) continue;
16574
16575
  rows.push({
16575
16576
  instanceId: inv.invocationId,
16576
16577
  runId: state.runId,
@@ -17771,4 +17772,4 @@ var AppContainerFactory = class AppContainerFactory {
17771
17772
 
17772
17773
  //#endregion
17773
17774
  export { GetWorkflowSummariesQuery as C, ListUserAccountsQuery as D, UpsertLocalBootstrapUserCommand as E, WorkflowPolicyUiPresentationFactory as S, RunBinaryAttachmentLookupService as T, FrontendAppConfigFactory as _, AppContainerLifecycle as a, ApiPaths as b, WebhookHttpRouteHandler as c, OAuth2HttpRouteHandler as d, CredentialHttpRouteHandler as f, InternalAuthBootstrapFactory as g, PublicFrontendBootstrapFactory as h, DatabaseMigrations as i, RequestToWebhookItemMapper as l, BinaryHttpRouteHandler as m, WorkerRuntime as n, WorkflowRunRetentionPruneScheduler as o, CodemationHonoApiApp as p, FrontendRuntime as r, WorkflowHttpRouteHandler as s, AppContainerFactory as t, RunHttpRouteHandler as u, CodemationFrontendAuthSnapshotFactory as v, GetWorkflowDetailQuery as w, WorkflowDefinitionMapper as x, WorkflowWebsocketServer as y };
17774
- //# sourceMappingURL=AppContainerFactory-DL_qZ80U.js.map
17775
+ //# sourceMappingURL=AppContainerFactory-Cr3JeVmg.js.map