@codemation/core 0.8.1 → 1.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/dist/testing.cjs CHANGED
@@ -1,6 +1,6 @@
1
- const require_runtime = require('./runtime-Dvo2ru5A.cjs');
1
+ const require_runtime = require('./runtime-DWKfb0BI.cjs');
2
2
  const require_InMemoryRunEventBusRegistry = require('./InMemoryRunEventBusRegistry-B0_C4OnP.cjs');
3
- const require_bootstrap = require('./bootstrap-Bx1u4cbS.cjs');
3
+ const require_bootstrap = require('./bootstrap-BfZE19lK.cjs');
4
4
  let tsyringe = require("tsyringe");
5
5
  tsyringe = require_runtime.__toESM(tsyringe);
6
6
 
package/dist/testing.js CHANGED
@@ -1,6 +1,6 @@
1
- import { A as NodeExecutor, D as PersistedWorkflowTokenRegistry, E as WorkflowSnapshotCodec, F as InProcessRetryRunner, L as DefaultExecutionContextFactory, R as AllWorkflowsActiveWorkflowActivationPolicy, Rt as CoreTokens, T as NodeInstanceFactory, a as InMemoryLiveWorkflowRepository, b as DefaultDrivingScheduler, i as RunIntentService, it as emitPorts, l as Engine, st as DefaultAsyncSleeper, u as InMemoryRunDataFactory, v as InlineDrivingScheduler, y as HintOnlyOffloadPolicy } from "./runtime-DUW6tIJ1.js";
1
+ import { A as NodeExecutor, D as PersistedWorkflowTokenRegistry, E as WorkflowSnapshotCodec, F as InProcessRetryRunner, L as DefaultExecutionContextFactory, R as AllWorkflowsActiveWorkflowActivationPolicy, Rt as CoreTokens, T as NodeInstanceFactory, a as InMemoryLiveWorkflowRepository, b as DefaultDrivingScheduler, i as RunIntentService, it as emitPorts, l as Engine, st as DefaultAsyncSleeper, u as InMemoryRunDataFactory, v as InlineDrivingScheduler, y as HintOnlyOffloadPolicy } from "./runtime-u6O644ST.js";
2
2
  import { n as WorkflowBuilder, t as InMemoryRunEventBus } from "./InMemoryRunEventBusRegistry-C2U83Hmv.js";
3
- import { n as InMemoryWorkflowExecutionRepository, t as EngineRuntimeRegistrar } from "./bootstrap-BoknFKnw.js";
3
+ import { n as InMemoryWorkflowExecutionRepository, t as EngineRuntimeRegistrar } from "./bootstrap-jqh1kCNI.js";
4
4
  import { container } from "tsyringe";
5
5
 
6
6
  //#region src/testing/RejectingCredentialSessionService.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemation/core",
3
- "version": "0.8.1",
3
+ "version": "1.0.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/ai/AiHost.ts CHANGED
@@ -142,30 +142,49 @@ export interface ChatModelConfig {
142
142
  getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;
143
143
  }
144
144
 
145
- export interface LangChainChatModelLike {
146
- invoke(input: unknown, options?: unknown): Promise<unknown>;
147
- bindTools?(tools: ReadonlyArray<unknown>): LangChainChatModelLike;
148
- withStructuredOutput?(
149
- outputSchema: ZodSchemaAny,
150
- config?: ChatModelStructuredOutputOptions,
151
- ): LangChainStructuredOutputModelLike;
145
+ /**
146
+ * Provider-neutral chat language model wrapper returned by a {@link ChatModelFactory}.
147
+ *
148
+ * Thin adapter around an AI SDK `LanguageModelV2` (from `@ai-sdk/provider`) plus the call-site
149
+ * defaults Codemation needs at every generate/stream: the provider label, the model name used for
150
+ * pricing / telemetry, and the default invocation options (max output tokens, temperature,
151
+ * provider-specific overrides).
152
+ *
153
+ * The consumer (AIAgentNode / AgentStructuredOutputRunner) passes `languageModel` directly into
154
+ * `generateText({ model, ... })` from the `ai` package.
155
+ */
156
+ export interface ChatLanguageModel {
157
+ /** AI SDK `LanguageModelV2` instance (kept `unknown` to avoid leaking the SDK type into `@codemation/core`). */
158
+ readonly languageModel: unknown;
159
+ /** Stable pricing/telemetry key — e.g. `"gpt-4.1-nano"`. */
160
+ readonly modelName: string;
161
+ /** Provider label — e.g. `"openai"`. Used for cost tracking. */
162
+ readonly provider?: string;
163
+ /** Defaults merged into every call. Consumers may override per-invocation. */
164
+ readonly defaultCallOptions?: ChatLanguageModelCallOptions;
152
165
  }
153
166
 
154
- export interface LangChainStructuredOutputModelLike {
155
- invoke(input: unknown, options?: unknown): Promise<unknown>;
167
+ export interface ChatLanguageModelCallOptions {
168
+ readonly maxOutputTokens?: number;
169
+ readonly temperature?: number;
170
+ readonly providerOptions?: Readonly<Record<string, Readonly<Record<string, JsonValue>>>>;
156
171
  }
157
172
 
158
- export interface ChatModelStructuredOutputOptions {
159
- readonly method?: "jsonSchema" | "functionCalling" | "jsonMode";
173
+ /**
174
+ * Options for a structured-output generate call. Mirrors
175
+ * `generateText({ output: Output.object(...) })` from the `ai` package.
176
+ */
177
+ export interface StructuredOutputOptions {
178
+ /** Optional schema name — used by some providers as the JSON schema name attribute. */
179
+ readonly schemaName?: string;
180
+ /** When `true`, the consumer should pass a strict-mode-compatible JSON Schema record. */
160
181
  readonly strict?: boolean;
161
- readonly includeRaw?: boolean;
162
- readonly tools?: ReadonlyArray<unknown>;
163
182
  }
164
183
 
165
184
  export interface ChatModelFactory<TConfig extends ChatModelConfig = ChatModelConfig> {
166
185
  create(
167
186
  args: Readonly<{ config: TConfig; ctx: NodeExecutionContext<any> }>,
168
- ): Promise<LangChainChatModelLike> | LangChainChatModelLike;
187
+ ): Promise<ChatLanguageModel> | ChatLanguageModel;
169
188
  }
170
189
 
171
190
  export type NodeBackedToolInputMapperArgs<
@@ -229,10 +229,17 @@ export class RunStartService {
229
229
  currentState: RunCurrentState | undefined,
230
230
  mutableState: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["mutableState"],
231
231
  ): RunCurrentState {
232
+ // Each `ConnectionInvocationRecord` represents a single, auditable LLM/tool call
233
+ // that must belong to exactly one run. Reruns start from a fresh invocation
234
+ // ledger so the new run only records what it actually invokes. The prior run's
235
+ // invocations remain queryable on that run's persisted state (their true owner).
236
+ // Carrying them over here would write duplicate `ExecutionInstance` rows whose
237
+ // primary key (`invocationId`) already exists under the previous run, causing a
238
+ // `Unique constraint failed on the fields: (instance_id)` violation on first save.
232
239
  return {
233
240
  outputsByNode: { ...(currentState?.outputsByNode ?? {}) },
234
241
  nodeSnapshotsByNodeId: { ...(currentState?.nodeSnapshotsByNodeId ?? {}) },
235
- connectionInvocations: currentState?.connectionInvocations ? [...currentState.connectionInvocations] : undefined,
242
+ connectionInvocations: [],
236
243
  mutableState: mutableState ?? currentState?.mutableState,
237
244
  };
238
245
  }