@oomol-lab/open-flow 0.1.0-beta.75 → 0.1.0-beta.77

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 (146) hide show
  1. package/README.md +3 -1
  2. package/dist/browser/{ContentIcon-FCpKiwjp.js → ContentIcon-VZQO8VZU.js} +9 -6
  3. package/dist/browser/{FlowCanvas-dzRBnlUT.js → FlowCanvas-BNGDMaWr.js} +75 -63
  4. package/dist/browser/{createResourceDialog-BeYDdUl-.js → createResourceDialog-BmtakfVg.js} +63 -57
  5. package/dist/browser/{dialog-ZtpsFbl4.js → dialog-BcFBfRB1.js} +126 -32
  6. package/dist/browser/{exportSvg-DqXw1yf-.js → exportSvg-CG8hEUNk.js} +2 -2
  7. package/dist/browser/{flowChanges-b_5UobFj.js → flowChanges-BGo_4Ypo.js} +6063 -11285
  8. package/dist/browser/{flowWorkspace-ItojZbO4.js → flowWorkspace-BFHGev7s.js} +1065 -2570
  9. package/dist/browser/preview.css +626 -653
  10. package/dist/browser/preview.js +1907 -9663
  11. package/dist/browser/theme.css +117 -263
  12. package/dist/browser/{tooltip-wZJRB9oP.js → tooltip-BAWSUexx.js} +2 -2
  13. package/dist/browser/{typeScriptSession-CSRwWmZm.js → typeScriptSession-CRoezJPN.js} +1 -1
  14. package/dist/browser/ui.css +464 -463
  15. package/dist/browser/ui.js +4 -3
  16. package/dist/browser/workbench.css +9891 -9897
  17. package/dist/browser/workbench.d.ts +6 -2
  18. package/dist/browser/workbench.js +838 -499
  19. package/dist/browser/{workbenchSelect-M441Lz0d.js → workbenchSelect-CjK-xdm3.js} +2 -2
  20. package/dist/command/index.js +48 -50
  21. package/dist/common/authoring.d.ts +5 -5
  22. package/dist/common/authoringExamples.d.ts +3 -2
  23. package/dist/common/authoringSchema.d.ts +26 -4
  24. package/dist/common/connector-proxy.d.ts +1 -1
  25. package/dist/common/control-api-conformance.js +352 -144
  26. package/dist/common/control-api-errors.d.ts +12 -0
  27. package/dist/common/control-api.d.ts +38 -4
  28. package/dist/common/control-api.js +373 -162
  29. package/dist/common/control-requests.d.ts +22 -3
  30. package/dist/common/control-requests.js +268 -28
  31. package/dist/common/cron-trigger.d.ts +2 -1
  32. package/dist/common/decision.d.ts +4 -4
  33. package/dist/common/decision.js +5 -2
  34. package/dist/common/engine-contract.d.ts +6 -1
  35. package/dist/common/event-source-definition.d.ts +1 -1
  36. package/dist/common/event-source-view.d.ts +22 -0
  37. package/dist/common/event-source.d.ts +1 -1
  38. package/dist/common/event-source.js +24 -65
  39. package/dist/common/event-sources.d.ts +0 -21
  40. package/dist/common/flow-authoring.js +90 -20
  41. package/dist/common/flow-change-schema.d.ts +9 -1
  42. package/dist/common/flow-change.d.ts +8 -202
  43. package/dist/common/flow-change.js +96 -24
  44. package/dist/common/flow-encoding.js +89 -21
  45. package/dist/common/flow-input-value.d.ts +1 -1
  46. package/dist/common/flow-model.d.ts +121 -0
  47. package/dist/common/flow-notifications.d.ts +1 -1
  48. package/dist/common/flow-retry.d.ts +2 -4
  49. package/dist/common/flow-semantics.js +161 -80
  50. package/dist/common/flow-state.d.ts +123 -0
  51. package/dist/common/flow-state.js +5852 -0
  52. package/dist/common/flow-workflowReferences.d.ts +8 -0
  53. package/dist/common/flowInspection.d.ts +1 -1
  54. package/dist/common/http-hosts.d.ts +6 -0
  55. package/dist/common/http-request.d.ts +13 -5
  56. package/dist/common/http-request.js +23 -5
  57. package/dist/common/integration-trigger.d.ts +2 -1
  58. package/dist/common/mcp.d.ts +96 -3
  59. package/dist/common/mcp.js +355 -142
  60. package/dist/common/openapi.d.ts +4 -4
  61. package/dist/common/openapi.js +4 -1
  62. package/dist/common/poll-trigger.d.ts +2 -1
  63. package/dist/common/run-events.js +1 -0
  64. package/dist/common/runtime-contract.d.ts +37 -1
  65. package/dist/common/runtime-contract.js +717 -72
  66. package/dist/common/runtime-nodejs-compat.d.ts +44 -0
  67. package/dist/common/runtime-nodejs-compat.js +5870 -0
  68. package/dist/common/scheduler-checkpoint.d.ts +1 -1
  69. package/dist/common/scheduler-node-execution.d.ts +2 -1
  70. package/dist/common/scheduler.d.ts +2 -2
  71. package/dist/common/scheduler.js +76 -6
  72. package/dist/common/state-conformance.d.ts +16 -0
  73. package/dist/common/tags.d.ts +4 -0
  74. package/dist/common/trigger-catalog.d.ts +1 -7
  75. package/dist/common/trigger-config-options.d.ts +1 -1
  76. package/dist/common/trigger-config.d.ts +1 -1
  77. package/dist/common/trigger-contract.d.ts +2 -1
  78. package/dist/common/trigger-localization.d.ts +8 -2
  79. package/dist/common/trigger-model.d.ts +101 -0
  80. package/dist/common/webhook-response.d.ts +1 -1
  81. package/dist/common/webhook-trigger.d.ts +3 -1
  82. package/dist/common/workflow.d.ts +3 -12
  83. package/dist/common/workflow.js +25 -23
  84. package/dist/index.d.ts +52 -14
  85. package/package.json +9 -1
  86. package/src/base/common/json.ts +1 -1
  87. package/src/connector/common/proxy.ts +1 -1
  88. package/src/control/common/api.ts +90 -16
  89. package/src/control/common/authoring.ts +6 -1
  90. package/src/control/common/authoringExamples.ts +8 -0
  91. package/src/control/common/authoringSchema.ts +26 -13
  92. package/src/control/common/authoringTools.ts +1 -1
  93. package/src/control/common/conformance.ts +1 -1
  94. package/src/control/common/connectorDecoders.ts +1 -1
  95. package/src/control/common/errors.ts +6 -0
  96. package/src/control/common/eventSources.ts +2 -29
  97. package/src/control/common/flowDecoders.ts +1 -0
  98. package/src/control/common/mcp.ts +16 -0
  99. package/src/control/common/requests.ts +10 -2
  100. package/src/control/common/tags.ts +20 -0
  101. package/src/control/common/triggerCatalog.ts +1 -8
  102. package/src/decision/common/decision.ts +15 -7
  103. package/src/event-source/common/definition.ts +1 -1
  104. package/src/event-source/common/index.ts +1 -1
  105. package/src/event-source/common/view.ts +20 -0
  106. package/src/execution/common/checkpoint.ts +1 -1
  107. package/src/execution/common/events.ts +3 -0
  108. package/src/execution/common/node-execution.ts +4 -1
  109. package/src/execution/common/scheduler.ts +3 -1
  110. package/src/flow/common/change.ts +60 -193
  111. package/src/flow/common/changeSchema.ts +39 -4
  112. package/src/flow/common/connectionUsage.ts +1 -1
  113. package/src/flow/common/errorHandling.ts +1 -1
  114. package/src/flow/common/inputValue.ts +1 -1
  115. package/src/flow/common/model.ts +130 -0
  116. package/src/flow/common/modules.ts +1 -1
  117. package/src/flow/common/portChanges.ts +1 -1
  118. package/src/flow/common/retry.ts +2 -4
  119. package/src/flow/common/semantics.ts +31 -4
  120. package/src/flow/common/webhookResponse.ts +1 -1
  121. package/src/flow/common/workflowReferences.ts +31 -0
  122. package/src/http/common/authBindings.ts +6 -9
  123. package/src/http/common/hosts.ts +13 -0
  124. package/src/http/common/httpRequest.ts +30 -15
  125. package/src/openapi/common/openapi.ts +9 -5
  126. package/src/{execution → runtime}/common/engineContract.ts +23 -15
  127. package/src/runtime/common/nodejsCompat.ts +275 -0
  128. package/src/runtime/common/nodejsGuest.generated.json +47 -0
  129. package/src/runtime/common/runtime.ts +1254 -0
  130. package/src/state/common/conformance.ts +86 -0
  131. package/src/state/common/state.ts +169 -0
  132. package/src/trigger/common/config.ts +1 -1
  133. package/src/trigger/common/configOptions.ts +1 -1
  134. package/src/trigger/common/contract.ts +2 -1
  135. package/src/trigger/common/cron.ts +2 -1
  136. package/src/trigger/common/integration.ts +2 -1
  137. package/src/trigger/common/model.ts +87 -0
  138. package/src/trigger/common/poll.ts +2 -1
  139. package/src/trigger/common/webhook.ts +3 -1
  140. package/src/trigger/providers/fieldDescriptions.ts +1 -1
  141. package/src/trigger/providers/localization.ts +9 -2
  142. package/src/trigger/providers/remote.ts +1 -1
  143. package/src/types/index.ts +55 -15
  144. package/src/workflow/common/workflow.ts +3 -44
  145. package/src/execution/common/runtime.ts +0 -563
  146. /package/src/{control → connector}/common/providerIconSprite.ts +0 -0
@@ -1,7 +1,7 @@
1
1
  import type { Graph, JsonValue } from './flow-change.js';
2
+ import type { AgentCheckpoint } from './runtime-contract.js';
2
3
  import type { DependenciesCheckpoint } from './scheduler-dependencies.js';
3
4
  import type { ExecutableNode } from './scheduler-node-execution.js';
4
- import type { AgentCheckpoint } from './runtime-contract.js';
5
5
  export interface PendingWait {
6
6
  readonly jobId: string;
7
7
  readonly nodeId: string;
@@ -1,9 +1,9 @@
1
1
  import type { AgentConfig } from './flow-agent.js';
2
2
  import type { Graph, GraphNode, JsonValue, TriggerNode } from './flow-change.js';
3
3
  import type { WebhookResponseSnapshot } from './webhook-response.js';
4
+ import type { AgentCheckpoint } from './runtime-contract.js';
4
5
  import type { FlowRunCheckpoint } from './scheduler-checkpoint.js';
5
6
  import type { Dependencies } from './scheduler-dependencies.js';
6
- import type { AgentCheckpoint } from './runtime-contract.js';
7
7
  import type { FlowRunOptions, SchedulerEvent, SchedulerFailure } from './scheduler.js';
8
8
  import * as Effect from 'effect/Effect';
9
9
  import { z } from 'zod';
@@ -63,6 +63,7 @@ export declare function executeNode(context: NodeExecutionContext, input: {
63
63
  readonly node: ExecutableNode;
64
64
  readonly jobId: string;
65
65
  readonly nodeInputs: Readonly<Record<string, JsonValue>>;
66
+ readonly launchInputs?: Readonly<Record<string, JsonValue>>;
66
67
  readonly flowId: string;
67
68
  readonly runId: string;
68
69
  readonly graph: Graph;
@@ -1,9 +1,9 @@
1
1
  import type { TaskCapability, JsonValue, WaitAction, WaitAutoContinue } from './flow-change.js';
2
2
  import type { PreparedFlow } from './flow-semantics.js';
3
3
  import type { WebhookResponseSnapshot } from './webhook-response.js';
4
+ import type { AgentCheckpoint } from './runtime-contract.js';
4
5
  import type { PreviousNode } from '../index.js';
5
6
  import type { FlowRunCheckpoint } from './scheduler-checkpoint.js';
6
- import type { AgentCheckpoint } from './runtime-contract.js';
7
7
  import * as Effect from 'effect/Effect';
8
8
  export type { DependenciesCheckpoint } from './scheduler-dependencies.js';
9
9
  export type { FlowRunCheckpoint, PendingWait, PendingWorkflowCall } from './scheduler-checkpoint.js';
@@ -33,7 +33,7 @@ export type SchedulerEvent = {
33
33
  readonly inputs: Readonly<Record<string, JsonValue>>;
34
34
  readonly jobId: string;
35
35
  readonly nodeId: string;
36
- readonly nodeKind: 'agent' | 'approval' | 'condition' | 'connector' | 'decision' | 'javascript' | 'openapi' | 'http-request' | 'llm' | 'value' | 'wait' | 'outputs' | 'workflow' | 'webhook-response';
36
+ readonly nodeKind: 'agent' | 'approval' | 'condition' | 'connector' | 'decision' | 'javascript' | 'openapi' | 'http-request' | 'dedupe' | 'llm' | 'value' | 'wait' | 'outputs' | 'workflow' | 'webhook-response';
37
37
  readonly nodeTitle?: string;
38
38
  readonly runId: string;
39
39
  readonly type: 'node.started';
@@ -9383,6 +9383,9 @@ function schemaValidationErrors(value, schema) {
9383
9383
  }
9384
9384
  //#endregion
9385
9385
  //#region src/decision/common/decision.ts
9386
+ function isDecisionExecutor(executor) {
9387
+ return executor.kind === "decision";
9388
+ }
9386
9389
  var decisionLimits = {
9387
9390
  choice: 255,
9388
9391
  score: 10
@@ -9405,7 +9408,7 @@ function limitDecisionQuestions(questions) {
9405
9408
  }
9406
9409
  /** Loading an oversized task also updates its previously generated output schemas. */
9407
9410
  function limitDecisionTask(task) {
9408
- if (task.executor.kind !== "decision") return task;
9411
+ if (!isDecisionExecutor(task.executor)) return task;
9409
9412
  const original = task.executor.questions;
9410
9413
  const questions = limitDecisionQuestions(original);
9411
9414
  if (questions === original) return task;
@@ -9472,6 +9475,14 @@ function answerSchema(question) {
9472
9475
  };
9473
9476
  }
9474
9477
  //#endregion
9478
+ //#region src/http/common/hosts.ts
9479
+ /** Hosts of a Code `http` Capability: lowercase DNS names or IPv4 addresses; `*.example.com` matches subdomains only. */
9480
+ var httpHostPattern = /^(?:\*\.)?(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
9481
+ /** Wildcards must name a registrable suffix, so `*.com` is rejected. */
9482
+ function isHttpHost(value) {
9483
+ return httpHostPattern.test(value) && (!value.startsWith("*.") || value.slice(2).includes("."));
9484
+ }
9485
+ //#endregion
9475
9486
  //#region src/http/common/headers.ts
9476
9487
  /** Header names are case-insensitive; never silently combine duplicate business fields. */
9477
9488
  function httpHeaderNameIssue(name, names) {
@@ -9524,6 +9535,51 @@ var httpRequestExecutorSchema = strictObject({
9524
9535
  ]).default("auto"),
9525
9536
  statusPolicy: _enum(["success", "all"]).default("success")
9526
9537
  }).extend({ kind: literal("http-request") });
9538
+ strictObject({
9539
+ scope: _enum(["draft", "live"]),
9540
+ values: boolean().optional()
9541
+ });
9542
+ strictObject({
9543
+ scope: _enum(["draft", "live"]),
9544
+ key: string$1().min(1).refine((key) => new TextEncoder().encode(key).length <= 256).optional()
9545
+ });
9546
+ strictObject({
9547
+ scope: _enum(["draft", "live"]),
9548
+ space: string$1().regex(/^(flow|node:.+)$/)
9549
+ });
9550
+ var dedupeExecutorSchema = strictObject({
9551
+ field: string$1().default(""),
9552
+ mode: _enum(["new", "increasing"]).default("new"),
9553
+ space: _enum(["node", "flow"]).default("node")
9554
+ }).extend({ kind: literal("dedupe") });
9555
+ object({
9556
+ version: literal(1),
9557
+ scope: _enum(["draft", "live"]),
9558
+ limits: object({
9559
+ maxValueBytes: number().positive(),
9560
+ maxValues: number().int().positive(),
9561
+ maxSpaces: number().int().positive(),
9562
+ maxIdentities: number().positive(),
9563
+ maxRunWrites: number().positive()
9564
+ }),
9565
+ values: array(object({
9566
+ key: string$1(),
9567
+ size: number().nonnegative(),
9568
+ updatedAt: number(),
9569
+ value: json$1().optional()
9570
+ })),
9571
+ spaces: array(object({
9572
+ space: string$1(),
9573
+ mode: _enum(["new", "increasing"]),
9574
+ count: number().nonnegative(),
9575
+ watermark: union([
9576
+ string$1(),
9577
+ number(),
9578
+ _null()
9579
+ ]),
9580
+ updatedAt: number()
9581
+ }))
9582
+ });
9527
9583
  //#endregion
9528
9584
  //#region src/flow/common/retry.ts
9529
9585
  var retryNodeTypes = [
@@ -9760,7 +9816,14 @@ var workflowCapabilitySchema = strictObject({
9760
9816
  inputs: array(port),
9761
9817
  outputs: array(port).nullable()
9762
9818
  });
9763
- var capability = union([connectorCapabilitySchema, workflowCapabilitySchema]);
9819
+ var capability = union([
9820
+ connectorCapabilitySchema,
9821
+ workflowCapabilitySchema,
9822
+ strictObject({
9823
+ kind: literal("http"),
9824
+ hosts: array(text.refine(isHttpHost, "Use a lowercase host name or IPv4 address, optionally prefixed by \"*.\" for subdomains.")).min(1).max(20).describe("Hosts Code may call with context.fetch. \"*.example.com\" matches subdomains only.")
9825
+ })
9826
+ ]);
9764
9827
  var inline = object({
9765
9828
  ...ports,
9766
9829
  name: text,
@@ -9871,7 +9934,8 @@ var managedFields = object({
9871
9934
  flowId: text,
9872
9935
  revisionId: text
9873
9936
  }),
9874
- httpRequestExecutorSchema
9937
+ httpRequestExecutorSchema,
9938
+ dedupeExecutorSchema
9875
9939
  ])
9876
9940
  });
9877
9941
  var managed = managedFields.transform(limitDecisionTask);
@@ -10124,7 +10188,9 @@ object({
10124
10188
  literal(8),
10125
10189
  literal(9),
10126
10190
  literal(10),
10127
- literal(11)
10191
+ literal(11),
10192
+ literal(12),
10193
+ literal(13)
10128
10194
  ]),
10129
10195
  document,
10130
10196
  modules: record$1(text, module)
@@ -10532,7 +10598,7 @@ var nodeErrorSchema = {
10532
10598
  }
10533
10599
  };
10534
10600
  function supportsNodeErrorHandling(node) {
10535
- return supportsNodeRetry(node);
10601
+ return supportsNodeRetry(node) || node.kind === "task" && "executor" in node.task && node.task.executor.kind === "dedupe";
10536
10602
  }
10537
10603
  function nodeSystemOutputPorts(node) {
10538
10604
  return supportsNodeErrorHandling(node) && node.onError == "error" ? { error: {
@@ -10541,10 +10607,12 @@ function nodeSystemOutputPorts(node) {
10541
10607
  } } : {};
10542
10608
  }
10543
10609
  //#endregion
10544
- //#region src/flow/common/change.ts
10610
+ //#region src/flow/common/model.ts
10545
10611
  function portsByHandle(ports) {
10546
10612
  return Object.fromEntries(ports.flatMap((port) => "handle" in port ? [[port.handle, port]] : []));
10547
10613
  }
10614
+ //#endregion
10615
+ //#region src/flow/common/change.ts
10548
10616
  function isTriggerNode(node) {
10549
10617
  return [
10550
10618
  "manual",
@@ -11559,6 +11627,7 @@ function executeNode(context, input) {
11559
11627
  if (additional.has(handle)) return false;
11560
11628
  const task = "executor" in node.task ? node.task : void 0;
11561
11629
  if (task == null || !["openapi", "http-request"].includes(task.executor.kind)) return true;
11630
+ if (Object.hasOwn(input.launchInputs ?? {}, handle)) return true;
11562
11631
  const mapping = node.inputs[handle];
11563
11632
  return mapping?.kind != "unset" && (mapping != null || task.inputs.some((port) => "handle" in port && port.handle == handle && port.value !== void 0));
11564
11633
  })),
@@ -11973,6 +12042,7 @@ function runGraph(context, target, runId, launchInputs = {}, trigger, resume) {
11973
12042
  node,
11974
12043
  jobId,
11975
12044
  nodeInputs,
12045
+ launchInputs: launch[nodeId],
11976
12046
  resolution,
11977
12047
  flowId: target.flowId,
11978
12048
  runId,
@@ -0,0 +1,16 @@
1
+ import type { JsonValue } from './flow-model.js';
2
+ import type { DedupeConfig } from './flow-state.js';
3
+ export interface StateConformanceHarness {
4
+ readonly maxIdentities: number;
5
+ /** Executes Code on the same initially empty Flow and scope on every call; returns its `result` output. */
6
+ run(source: string): Promise<JsonValue>;
7
+ /** Executes the same dedupe node across Runs, updating its business config and items. */
8
+ dedupe(config: DedupeConfig, items: JsonValue[]): Promise<{
9
+ items: JsonValue[];
10
+ duplicates: JsonValue[];
11
+ }>;
12
+ }
13
+ export declare const stateConformanceCases: readonly {
14
+ name: string;
15
+ verify(harness: StateConformanceHarness): Promise<void>;
16
+ }[];
@@ -0,0 +1,4 @@
1
+ import type { FlowQuery, Tag, TagListItem } from './control-api.js';
2
+ export declare function normalizeFlowQuery(query?: FlowQuery): Required<FlowQuery>;
3
+ export declare function decodeTag(value: unknown): Tag;
4
+ export declare function decodeTagListItem(value: unknown): TagListItem;
@@ -1,13 +1,7 @@
1
1
  import type { TriggerKeySnapshot } from './flow-change.js';
2
2
  import type { UiLanguage } from './localization.js';
3
+ import type { TriggerDisplay } from './trigger-localization.js';
3
4
  import type { TriggerKeySummary } from './control-api.js';
4
- export interface TriggerDisplay {
5
- readonly configInputs: Readonly<Record<string, string>>;
6
- readonly configInputLabels: Readonly<Record<string, string>>;
7
- readonly displayName: string;
8
- readonly description: string;
9
- readonly outputs: Readonly<Record<string, string>>;
10
- }
11
5
  export interface TriggerCatalog {
12
6
  readonly version: 3;
13
7
  readonly locale: UiLanguage;
@@ -1,5 +1,5 @@
1
1
  import type { ConnectorProxy } from './connector-proxy.js';
2
- import type { JsonValue } from './flow-change.js';
2
+ import type { JsonValue } from './flow-model.js';
3
3
  export interface TriggerConfigOption {
4
4
  readonly value: string;
5
5
  readonly label: string;
@@ -1,4 +1,4 @@
1
- import type { Group, InputPort, InputValues, JsonValue } from './flow-change.js';
1
+ import type { Group, InputPort, InputValues, JsonValue } from './flow-model.js';
2
2
  /** Deployment-bound selections owned by the Trigger configuration contract. */
3
3
  export declare function clearTriggerExternalConfig(key: string, config: InputValues): InputValues;
4
4
  export declare function triggerConfigValue(input: InputPort, config: InputValues): JsonValue | undefined;
@@ -1,4 +1,5 @@
1
- import type { JsonValue, Port, PortDefinition, TriggerNode } from './flow-change.js';
1
+ import type { JsonValue, Port, PortDefinition } from './flow-model.js';
2
+ import type { TriggerNode } from './trigger-model.js';
2
3
  import { webhookMethods, webhookSupportsBody } from './webhook-method.js';
3
4
  export { webhookMethods, webhookSupportsBody };
4
5
  export declare const errorOutputs: readonly Port[];
@@ -1,6 +1,12 @@
1
- import type { TriggerDisplay } from './trigger-catalog.js';
2
- import type { TriggerKeySnapshot } from './flow-change.js';
3
1
  import type { UiLanguage } from './localization.js';
2
+ import type { TriggerKeySnapshot } from './trigger-model.js';
3
+ export interface TriggerDisplay {
4
+ readonly configInputs: Readonly<Record<string, string>>;
5
+ readonly configInputLabels: Readonly<Record<string, string>>;
6
+ readonly displayName: string;
7
+ readonly description: string;
8
+ readonly outputs: Readonly<Record<string, string>>;
9
+ }
4
10
  type Translations = Readonly<Record<string, Partial<TriggerDisplay>>>;
5
11
  export declare function loadTriggerTranslations(locale: UiLanguage): Promise<Translations>;
6
12
  export declare function localizeTrigger(definition: TriggerKeySnapshot, locale: UiLanguage): Promise<TriggerDisplay>;
@@ -0,0 +1,101 @@
1
+ import type { Group, InputPort, InputValues, Port } from './flow-model.js';
2
+ import type { WebhookMethod } from './webhook-method.js';
3
+ /** Trigger node shapes. The graph node union and its operations belong to flow/common/change.ts. */
4
+ export type TriggerSchedule = {
5
+ readonly expression: string;
6
+ readonly timezone: string;
7
+ readonly type: 'cron';
8
+ } | {
9
+ readonly type: 'every';
10
+ readonly unit: 'day' | 'hour' | 'minute' | 'month' | 'week';
11
+ readonly value: number;
12
+ };
13
+ interface TriggerKeySnapshotBase {
14
+ readonly configInputs: readonly (InputPort | Group)[];
15
+ readonly definitionVersion: number;
16
+ readonly description: string;
17
+ readonly displayName: string;
18
+ readonly key: string;
19
+ readonly name: string;
20
+ readonly outputs: readonly Port[];
21
+ readonly provider: string;
22
+ }
23
+ export type IntegrationEndpointMethod = 'DELETE' | 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT';
24
+ export type IntegrationBodyFormat = 'form' | 'json' | 'multipart' | 'text';
25
+ export interface IntegrationEndpointDeclaration {
26
+ readonly body: {
27
+ readonly allowArray: boolean;
28
+ readonly allowEmpty: boolean;
29
+ readonly formats: readonly IntegrationBodyFormat[];
30
+ };
31
+ readonly methods: readonly IntegrationEndpointMethod[];
32
+ readonly successStatus: number;
33
+ }
34
+ export type TriggerKeySnapshot = (TriggerKeySnapshotBase & {
35
+ readonly type: 'poll';
36
+ }) | (TriggerKeySnapshotBase & {
37
+ readonly endpoint: IntegrationEndpointDeclaration;
38
+ readonly type: 'integration';
39
+ });
40
+ export interface WebhookBodyField extends InputPort {
41
+ }
42
+ export interface WebhookOptions {
43
+ readonly allowedOrigins?: readonly string[];
44
+ readonly responseBody?: {
45
+ readonly kind: 'workflow-outputs';
46
+ readonly output?: string;
47
+ readonly timeoutMs?: number;
48
+ } | {
49
+ readonly kind: 'webhook-response';
50
+ readonly nodeId?: string;
51
+ readonly timeoutMs?: number;
52
+ };
53
+ readonly responseData?: string;
54
+ readonly responseHeaders?: Readonly<Record<string, string>>;
55
+ readonly responseHeadersSource?: {
56
+ readonly kind: 'workflow-outputs';
57
+ readonly output?: string;
58
+ };
59
+ readonly responseHeaderOutputs?: Readonly<Record<string, string>>;
60
+ readonly responseStatusCode?: number;
61
+ readonly responseStatusCodeOutput?: string;
62
+ }
63
+ interface TriggerNodeBase {
64
+ readonly onError?: never;
65
+ readonly description?: string;
66
+ readonly icon?: string;
67
+ readonly name: string;
68
+ }
69
+ export type TriggerNode = (TriggerNodeBase & {
70
+ readonly kind: 'manual';
71
+ }) | (TriggerNodeBase & {
72
+ readonly kind: 'start';
73
+ readonly inputDefs: readonly Port[];
74
+ }) | (TriggerNodeBase & {
75
+ readonly kind: 'error';
76
+ readonly sourceFlowIds?: readonly string[];
77
+ }) | (TriggerNodeBase & {
78
+ readonly bodyFields: readonly WebhookBodyField[];
79
+ readonly kind: 'webhook';
80
+ readonly method: WebhookMethod;
81
+ readonly options?: WebhookOptions;
82
+ }) | (TriggerNodeBase & {
83
+ readonly cronTimes: readonly TriggerSchedule[];
84
+ readonly kind: 'cron';
85
+ }) | (TriggerNodeBase & {
86
+ readonly connectionId?: string;
87
+ readonly config: InputValues;
88
+ readonly definition: TriggerKeySnapshot & {
89
+ readonly type: 'poll';
90
+ };
91
+ readonly kind: 'poll';
92
+ readonly pollTimes: readonly TriggerSchedule[];
93
+ }) | (TriggerNodeBase & {
94
+ readonly connectionId?: string;
95
+ readonly config: InputValues;
96
+ readonly definition: TriggerKeySnapshot & {
97
+ readonly type: 'integration';
98
+ };
99
+ readonly kind: 'integration';
100
+ });
101
+ export {};
@@ -1,4 +1,4 @@
1
- import type { InputPort, JsonValue, Port, PortDefinition } from './flow-change.js';
1
+ import type { InputPort, JsonValue, Port, PortDefinition } from './flow-model.js';
2
2
  export declare const webhookResponseTimeout: {
3
3
  readonly defaultMs: 30000;
4
4
  readonly minMs: 1000;
@@ -1,4 +1,6 @@
1
- import type { JsonValue, WebhookBodyField, WebhookMethod, WebhookOptions } from './flow-change.js';
1
+ import type { JsonValue } from './flow-model.js';
2
+ import type { WebhookMethod } from './webhook-method.js';
3
+ import type { WebhookBodyField, WebhookOptions } from './trigger-model.js';
2
4
  export { webhookSupportsBody } from './trigger-contract.js';
3
5
  export { webhookResponseAllowsBody, webhookResponseTimeout } from './webhook-response.js';
4
6
  export type { WebhookResponseSnapshot } from './webhook-response.js';
@@ -1,10 +1,7 @@
1
- import type { TaskNode, ManagedTaskDefinition, Port, JsonValue, RevisionContent, GraphNode, WorkflowCapability, AgentWorkflowTool } from './flow-change.js';
1
+ import type { TaskNode, ManagedTaskDefinition, Port, JsonValue, RevisionContent, WorkflowCapability, AgentWorkflowTool } from './flow-change.js';
2
2
  import { z } from 'zod';
3
- export interface WorkflowExecutor {
4
- readonly kind: 'workflow';
5
- readonly flowId: string;
6
- readonly revisionId: string;
7
- }
3
+ export type { WorkflowExecutor } from './flow-model.js';
4
+ export { nodeWorkflowReferences } from './flow-workflowReferences.js';
8
5
  export declare const publishedWorkflowInterfaceSchema: z.ZodObject<{
9
6
  inputs: z.ZodNullable<z.ZodArray<z.ZodObject<{
10
7
  handle: z.ZodString;
@@ -91,12 +88,6 @@ export declare const workflowReferencesSchema: z.ZodObject<{
91
88
  }, z.core.$strip>>;
92
89
  }, z.core.$strip>;
93
90
  export type WorkflowReferences = z.infer<typeof workflowReferencesSchema>;
94
- /** Workflow declarations share discovery across authoring, admission and resource indexing. */
95
- export declare function nodeWorkflowReferences(node: GraphNode): readonly {
96
- readonly target: Omit<WorkflowCapability, 'kind' | 'name'>;
97
- readonly path: string;
98
- readonly tool?: string;
99
- }[];
100
91
  export declare function workflowCapability(name: string, target: WorkflowContract | WorkflowCandidate): WorkflowCapability;
101
92
  export declare function workflowAgentTool(id: string, name: string, target: WorkflowContract | WorkflowCandidate, previous?: AgentWorkflowTool): AgentWorkflowTool;
102
93
  export declare function workflowInterfaceIssues(target: {
@@ -9531,6 +9531,31 @@ function comparePorts(source, target) {
9531
9531
  } : result;
9532
9532
  }
9533
9533
  //#endregion
9534
+ //#region src/flow/common/workflowReferences.ts
9535
+ /** Workflow declarations share discovery across authoring, admission and resource indexing. */
9536
+ function nodeWorkflowReferences(node) {
9537
+ if (node.kind != "task") return [];
9538
+ if ("moduleId" in node.task) return (node.task.capabilities ?? []).flatMap((item, index) => item.kind == "workflow" ? [{
9539
+ target: item,
9540
+ path: `task/capabilities/${index}`,
9541
+ tool: item.name
9542
+ }] : []);
9543
+ if (node.task.executor.kind == "workflow") return [{
9544
+ target: {
9545
+ ...node.task.executor,
9546
+ inputs: node.task.inputs.filter((port) => "handle" in port),
9547
+ outputs: node.task.outputs.filter((port) => "handle" in port)
9548
+ },
9549
+ path: "task/executor"
9550
+ }];
9551
+ if (node.task.executor.kind == "agent") return node.task.executor.tools.flatMap((item, index) => item.kind == "workflow" ? [{
9552
+ target: item,
9553
+ path: `task/executor/tools/${index}`,
9554
+ tool: item.name
9555
+ }] : []);
9556
+ return [];
9557
+ }
9558
+ //#endregion
9534
9559
  //#region src/workflow/common/workflow.ts
9535
9560
  var portSchema = object({
9536
9561
  handle: string().min(1),
@@ -9686,29 +9711,6 @@ var workflowReferencesSchema = object({
9686
9711
  }).nullable()
9687
9712
  }))
9688
9713
  });
9689
- /** Workflow declarations share discovery across authoring, admission and resource indexing. */
9690
- function nodeWorkflowReferences(node) {
9691
- if (node.kind != "task") return [];
9692
- if ("moduleId" in node.task) return (node.task.capabilities ?? []).flatMap((item, index) => item.kind == "workflow" ? [{
9693
- target: item,
9694
- path: `task/capabilities/${index}`,
9695
- tool: item.name
9696
- }] : []);
9697
- if (node.task.executor.kind == "workflow") return [{
9698
- target: {
9699
- ...node.task.executor,
9700
- inputs: node.task.inputs.filter((port) => "handle" in port),
9701
- outputs: node.task.outputs.filter((port) => "handle" in port)
9702
- },
9703
- path: "task/executor"
9704
- }];
9705
- if (node.task.executor.kind == "agent") return node.task.executor.tools.flatMap((item, index) => item.kind == "workflow" ? [{
9706
- target: item,
9707
- path: `task/executor/tools/${index}`,
9708
- tool: item.name
9709
- }] : []);
9710
- return [];
9711
- }
9712
9714
  function workflowCapability(name, target) {
9713
9715
  return {
9714
9716
  kind: "workflow",
package/dist/index.d.ts CHANGED
@@ -20,18 +20,50 @@ export interface ArtifactRef {
20
20
  readonly kind: 'artifact';
21
21
  readonly id: string;
22
22
  readonly name: string;
23
- readonly mediaType: string | undefined;
23
+ readonly mediaType?: string;
24
24
  readonly size: number;
25
25
  readonly digest: string;
26
26
  }
27
27
  export interface ArtifactPutOptions {
28
28
  readonly name: string;
29
- readonly mediaType?: string | undefined;
29
+ readonly mediaType?: string;
30
30
  }
31
- export type ArtifactData = Uint8Array | Blob | ReadableStream<Uint8Array>;
31
+ /** Strings are stored as UTF-8. */
32
+ export type ArtifactData = string | Uint8Array;
33
+ /** Artifacts belong to the current Run; an ArtifactRef is JSON and can be passed to downstream nodes. */
32
34
  export interface ArtifactCapability {
33
35
  put(data: ArtifactData, options: ArtifactPutOptions): Promise<ArtifactRef>;
34
- open(ref: ArtifactRef): Promise<ReadableStream<Uint8Array>>;
36
+ open(ref: ArtifactRef): Promise<Uint8Array>;
37
+ }
38
+ export interface TaskFetchInit {
39
+ /** GET, HEAD, POST, PUT, PATCH, DELETE or OPTIONS. */
40
+ readonly method?: string;
41
+ readonly headers?: Readonly<Record<string, string>> | Iterable<readonly [string, string]>;
42
+ /** At most 1 MiB; strings are sent as UTF-8 text/plain unless a content-type header is supplied. */
43
+ readonly body?: string | Uint8Array | ArrayBuffer;
44
+ readonly signal?: AbortSignal;
45
+ }
46
+ export interface TaskFetchHeaders extends Iterable<[string, string]> {
47
+ get(name: string): string | null;
48
+ has(name: string): boolean;
49
+ entries(): IterableIterator<[string, string]>;
50
+ keys(): IterableIterator<string>;
51
+ values(): IterableIterator<string>;
52
+ forEach(callback: (value: string, name: string) => void): void;
53
+ }
54
+ /** A read-only subset of the Fetch Response; the body is buffered, at most 1 MiB, and readable once. */
55
+ export interface TaskFetchResponse {
56
+ readonly status: number;
57
+ readonly statusText: string;
58
+ readonly ok: boolean;
59
+ readonly redirected: false;
60
+ readonly url: string;
61
+ readonly headers: TaskFetchHeaders;
62
+ readonly bodyUsed: boolean;
63
+ bytes(): Promise<Uint8Array>;
64
+ arrayBuffer(): Promise<ArrayBuffer>;
65
+ text(): Promise<string>;
66
+ json(): Promise<unknown>;
35
67
  }
36
68
  export interface MediaPreviewPayload {
37
69
  readonly type: 'video' | 'audio' | 'markdown' | 'iframe' | 'html';
@@ -60,12 +92,6 @@ export interface CsvPreviewPayload {
60
92
  }
61
93
  export type PreviewPayload = MediaPreviewPayload | TextPreviewPayload | ImagePreviewPayload | TablePreviewPayload | CsvPreviewPayload;
62
94
  export type PreviewType = PreviewPayload['type'];
63
- export interface TaskLogger {
64
- debug(message: string, data?: unknown): void;
65
- info(message: string, data?: unknown): void;
66
- warn(message: string, data?: unknown): void;
67
- error(message: string, data?: unknown): void;
68
- }
69
95
  export interface TaskContext<Actions extends object = Record<string, never>, Workflows extends object = {
70
96
  call: (name: never, input?: never) => Promise<never>;
71
97
  }> {
@@ -76,13 +102,25 @@ export interface TaskContext<Actions extends object = Record<string, never>, Wor
76
102
  readonly inputs: Readonly<Record<string, unknown>>;
77
103
  readonly runId: string;
78
104
  readonly blockId: string;
105
+ readonly state: {
106
+ get(key: string): Promise<JsonValue | null>;
107
+ set(key: string, value: JsonValue): Promise<void>;
108
+ insert(key: string, value: Exclude<JsonValue, null>): Promise<boolean>;
109
+ delete(key: string): Promise<void>;
110
+ list(): Promise<string[]>;
111
+ };
112
+ readonly dedupe: {
113
+ insert(ids: readonly (string | number)[]): Promise<boolean[]>;
114
+ has(ids: readonly (string | number)[]): Promise<boolean[]>;
115
+ };
79
116
  readonly artifact: ArtifactCapability;
80
- readonly fetch: typeof fetch;
81
- readonly logger: TaskLogger;
82
117
  /** Reads the selected direct predecessors, sorted by node ID; empty for a graph root. */
83
118
  getPrevious(): Promise<readonly PreviousNode[]>;
84
- preview(payload: PreviewPayload, id?: string): Promise<void>;
85
- reportProgress(progress: number): Promise<void>;
119
+ /**
120
+ * Calls an HTTP(S) URL whose host the node declares in its `http` Capability. Redirects are returned, not followed,
121
+ * and no platform credentials are added. Network failures reject with a TypeError.
122
+ */
123
+ fetch(input: string | URL, init?: TaskFetchInit): Promise<TaskFetchResponse>;
86
124
  }
87
125
  export type TaskResult<Outputs extends object> = keyof Outputs extends never ? Outputs | void : Outputs;
88
126
  export interface Task<Inputs extends object = Record<string, unknown>, Outputs extends object = Record<string, unknown>, Actions extends object = Record<string, never>, Workflows extends object = TaskContext['workflows']> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oomol-lab/open-flow",
3
- "version": "0.1.0-beta.75",
3
+ "version": "0.1.0-beta.77",
4
4
  "description": "TypeScript contracts and Browser runtime for Open Flow.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -25,6 +25,10 @@
25
25
  "types": "./dist/common/decision.d.ts",
26
26
  "import": "./dist/common/decision.js"
27
27
  },
28
+ "./flow-state": {
29
+ "types": "./dist/common/flow-state.d.ts",
30
+ "import": "./dist/common/flow-state.js"
31
+ },
28
32
  "./http-request": {
29
33
  "types": "./dist/common/http-request.d.ts",
30
34
  "import": "./dist/common/http-request.js"
@@ -113,6 +117,10 @@
113
117
  "types": "./dist/common/runtime-contract.d.ts",
114
118
  "import": "./dist/common/runtime-contract.js"
115
119
  },
120
+ "./runtime-nodejs-compat": {
121
+ "types": "./dist/common/runtime-nodejs-compat.d.ts",
122
+ "import": "./dist/common/runtime-nodejs-compat.js"
123
+ },
116
124
  "./scheduler": {
117
125
  "types": "./dist/common/scheduler.d.ts",
118
126
  "import": "./dist/common/scheduler.js"
@@ -1,4 +1,4 @@
1
- export type JsonValue = null | boolean | number | string | readonly JsonValue[] | JsonObject
1
+ import type { JsonValue } from '../../types/index.ts'
2
2
 
3
3
  export type JsonObject = { readonly [key: string]: JsonValue }
4
4
 
@@ -1,5 +1,5 @@
1
1
  import type { SourceOperation, SourceReferenceOperation } from '../../event-source/common/definition.ts'
2
- import type { JsonValue } from '../../flow/common/change.ts'
2
+ import type { JsonValue } from '../../types/index.ts'
3
3
  export type TriggerOperationRequest =
4
4
  | { readonly operation: 'sourceReference'; readonly request: SourceReferenceOperation }
5
5
  | { readonly operation: 'source'; readonly request: SourceOperation }