@codemation/core-nodes 0.10.2 → 0.13.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/dist/index.cjs +427 -102
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +205 -67
  5. package/dist/index.d.ts +206 -68
  6. package/dist/index.js +427 -99
  7. package/dist/index.js.map +1 -1
  8. package/dist/metadata.json +1 -1
  9. package/package.json +3 -2
  10. package/src/chatModels/CodemationChatModelConfig.ts +9 -21
  11. package/src/chatModels/CodemationChatModelFactory.ts +12 -9
  12. package/src/chatModels/OpenAIChatModelFactory.ts +3 -2
  13. package/src/index.ts +1 -1
  14. package/src/nodes/AIAgentConfig.ts +36 -0
  15. package/src/nodes/AIAgentNode.ts +81 -15
  16. package/src/nodes/AgentBinaryContentFactory.ts +74 -0
  17. package/src/nodes/AgentMessageFactory.ts +22 -6
  18. package/src/nodes/AgentToolResultContentFactory.ts +155 -0
  19. package/src/nodes/CallbackNodeFactory.ts +9 -6
  20. package/src/nodes/CronTriggerFactory.ts +6 -2
  21. package/src/nodes/DeferredMetaToolStrategy.ts +8 -2
  22. package/src/nodes/ManualTriggerFactory.ts +15 -11
  23. package/src/nodes/WebhookTriggerFactory.ts +9 -2
  24. package/src/nodes/aggregate.ts +9 -2
  25. package/src/nodes/assertion.ts +3 -0
  26. package/src/nodes/filter.ts +9 -2
  27. package/src/nodes/httpRequest.ts +6 -1
  28. package/src/nodes/if.ts +9 -2
  29. package/src/nodes/isTestRun.ts +6 -2
  30. package/src/nodes/mapData.ts +4 -2
  31. package/src/nodes/merge.ts +9 -2
  32. package/src/nodes/noOp.ts +9 -2
  33. package/src/nodes/nodeOptions.types.ts +12 -0
  34. package/src/nodes/split.ts +9 -2
  35. package/src/nodes/subWorkflow.ts +9 -2
  36. package/src/nodes/switch.ts +7 -1
  37. package/src/nodes/wait.ts +9 -2
  38. package/src/workflowAuthoring/WorkflowChatModelFactory.types.ts +8 -2
  39. package/src/chatModels/ManagedModelFetcher.ts +0 -23
@@ -6,6 +6,7 @@ import type {
6
6
  UpstreamRefPlaceholder,
7
7
  } from "@codemation/core";
8
8
  import { SubWorkflowNode } from "./SubWorkflowNode";
9
+ import type { NodeBaseOptions } from "./nodeOptions.types";
9
10
 
10
11
  export class SubWorkflow<TInputJson = unknown, TOutputJson = unknown> implements RunnableNodeConfig<
11
12
  TInputJson,
@@ -14,13 +15,19 @@ export class SubWorkflow<TInputJson = unknown, TOutputJson = unknown> implements
14
15
  readonly kind = "node" as const;
15
16
  readonly type: TypeToken<unknown> = SubWorkflowNode;
16
17
  readonly icon = "lucide:workflow";
18
+ readonly id?: string;
19
+ readonly description?: string;
17
20
  constructor(
18
21
  public readonly name: string,
19
22
  public readonly workflowId: string,
20
23
  public upstreamRefs?: Array<{ nodeId: NodeId } | UpstreamRefPlaceholder>,
21
24
  public readonly startAt?: NodeId,
22
- public readonly id?: string,
23
- ) {}
25
+ idOrOptions?: string | NodeBaseOptions,
26
+ ) {
27
+ const options = typeof idOrOptions === "string" ? { id: idOrOptions } : idOrOptions;
28
+ this.id = options?.id;
29
+ this.description = options?.description;
30
+ }
24
31
 
25
32
  inspectorSummary(): ReadonlyArray<NodeInspectorSummaryRow> {
26
33
  const rows: NodeInspectorSummaryRow[] = [{ label: "Workflow", value: this.workflowId }];
@@ -7,6 +7,7 @@ import type {
7
7
  TypeToken,
8
8
  } from "@codemation/core";
9
9
  import { SwitchNode } from "./SwitchNode";
10
+ import type { NodeBaseOptions } from "./nodeOptions.types";
10
11
 
11
12
  export type SwitchCaseKeyResolver<TInputJson = unknown> = (
12
13
  item: Item<TInputJson>,
@@ -21,6 +22,8 @@ export class Switch<TInputJson = unknown> implements RunnableNodeConfig<TInputJs
21
22
  readonly execution = { hint: "local" } as const;
22
23
  readonly icon = "lucide:git-branch-plus" as const;
23
24
  readonly declaredOutputPorts: ReadonlyArray<string>;
25
+ readonly id?: string;
26
+ readonly description?: string;
24
27
 
25
28
  constructor(
26
29
  public readonly name: string,
@@ -29,9 +32,12 @@ export class Switch<TInputJson = unknown> implements RunnableNodeConfig<TInputJs
29
32
  defaultCase: string;
30
33
  resolveCaseKey: SwitchCaseKeyResolver<TInputJson>;
31
34
  }>,
32
- public readonly id?: string,
35
+ idOrOptions?: string | NodeBaseOptions,
33
36
  ) {
34
37
  this.declaredOutputPorts = [...new Set([...cfg.cases, cfg.defaultCase])].sort();
38
+ const options = typeof idOrOptions === "string" ? { id: idOrOptions } : idOrOptions;
39
+ this.id = options?.id;
40
+ this.description = options?.description;
35
41
  }
36
42
 
37
43
  inspectorSummary(): ReadonlyArray<NodeInspectorSummaryRow> {
package/src/nodes/wait.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { NodeInspectorSummaryRow, RunnableNodeConfig, TypeToken } from "@codemation/core";
2
2
 
3
3
  import { WaitNode } from "./WaitNode";
4
+ import type { NodeBaseOptions } from "./nodeOptions.types";
4
5
 
5
6
  export class Wait<TItemJson = unknown> implements RunnableNodeConfig<TItemJson, TItemJson> {
6
7
  readonly kind = "node" as const;
@@ -9,12 +10,18 @@ export class Wait<TItemJson = unknown> implements RunnableNodeConfig<TItemJson,
9
10
  /** Pass-through empty batches should still advance to downstream nodes. */
10
11
  readonly continueWhenEmptyOutput = true as const;
11
12
  readonly icon = "lucide:hourglass" as const;
13
+ readonly id?: string;
14
+ readonly description?: string;
12
15
 
13
16
  constructor(
14
17
  public readonly name: string,
15
18
  public readonly milliseconds: number,
16
- public readonly id?: string,
17
- ) {}
19
+ idOrOptions?: string | NodeBaseOptions,
20
+ ) {
21
+ const options = typeof idOrOptions === "string" ? { id: idOrOptions } : idOrOptions;
22
+ this.id = options?.id;
23
+ this.description = options?.description;
24
+ }
18
25
 
19
26
  inspectorSummary(): ReadonlyArray<NodeInspectorSummaryRow> {
20
27
  const seconds = this.milliseconds / 1000;
@@ -1,6 +1,8 @@
1
1
  import type { ChatModelConfig } from "@codemation/core";
2
2
  import { OpenAIChatModelConfig } from "../chatModels/openAiChatModelConfig";
3
- import { CodemationChatModelConfig } from "../chatModels/CodemationChatModelConfig";
3
+ import { CodemationChatModelConfig, type ManagedComplexity } from "../chatModels/CodemationChatModelConfig";
4
+
5
+ const VALID_COMPLEXITY: ReadonlySet<string> = new Set(["low", "medium", "high", "xhigh"]);
4
6
 
5
7
  export class WorkflowChatModelFactory {
6
8
  static create(model: string | ChatModelConfig): ChatModelConfig {
@@ -9,7 +11,11 @@ export class WorkflowChatModelFactory {
9
11
  }
10
12
  const [provider, resolvedModel] = model.includes(":") ? model.split(":", 2) : ["openai", model];
11
13
  if (provider === "codemation-managed") {
12
- return new CodemationChatModelConfig("Codemation Managed", resolvedModel ?? "");
14
+ const complexity = resolvedModel ?? "medium";
15
+ if (!VALID_COMPLEXITY.has(complexity)) {
16
+ throw new Error(`Invalid managed complexity "${complexity}". Must be one of: low, medium, high, xhigh.`);
17
+ }
18
+ return new CodemationChatModelConfig("Codemation Managed", complexity as ManagedComplexity);
13
19
  }
14
20
  if (provider !== "openai") {
15
21
  throw new Error(`Unsupported workflow().agent() model provider "${provider}".`);
@@ -1,23 +0,0 @@
1
- import type { ManagedModelDto } from "./CodemationChatModelConfig";
2
-
3
- /**
4
- * Fetches the active platform-managed model allowlist from the CP.
5
- * Reads CONTROL_PLANE_URL from the workspace process env.
6
- * Returns an empty array if the env var is absent or the fetch fails.
7
- * Cache the result per session — the allowlist changes infrequently.
8
- */
9
- export class ManagedModelFetcher {
10
- async fetch(): Promise<ManagedModelDto[]> {
11
- // eslint-disable-next-line no-restricted-properties -- CONTROL_PLANE_URL is injected by the provisioner; this class is the justified boundary.
12
- const cpUrl = process.env["CONTROL_PLANE_URL"];
13
- if (!cpUrl) return [];
14
-
15
- try {
16
- const res = await globalThis.fetch(`${cpUrl}/api/llm/managed-models`);
17
- if (!res.ok) return [];
18
- return (await res.json()) as ManagedModelDto[];
19
- } catch {
20
- return [];
21
- }
22
- }
23
- }