@oomol-lab/open-flow 0.1.0-beta.54 → 0.1.0-beta.55

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 (38) hide show
  1. package/dist/browser/{createResourceDialog-BsaBMf7_.js → createResourceDialog-4H5_lZ6s.js} +3 -3
  2. package/dist/browser/{main-BPABKzwN.js → dist-BFmpkX4P.js} +9 -1
  3. package/dist/browser/flow-authoring-node.d.ts +5 -0
  4. package/dist/browser/flow-authoring.d.ts +1 -1
  5. package/dist/browser/flow-authoring.js +9434 -9187
  6. package/dist/browser/flow-change.d.ts +6 -1
  7. package/dist/browser/flow-change.js +3108 -141
  8. package/dist/browser/{flowChanges-CcscgZsW.js → flowChanges-ZzG-f9cg.js} +1978 -5437
  9. package/dist/browser/{flowWorkspace-CoT_ewLX.js → flowWorkspace-ChpRaTMX.js} +3197 -310
  10. package/dist/browser/{icons-0s-Q_3lp.js → icons-CdAB9wyS.js} +4294 -54
  11. package/dist/browser/{markdownContent-D3FFc-u_.js → markdownContent-frwDfQQU.js} +1 -2
  12. package/dist/browser/preview.css +375 -322
  13. package/dist/browser/preview.js +5458 -1888
  14. package/dist/browser/theme.css +1 -0
  15. package/dist/browser/ui.css +30 -0
  16. package/dist/browser/ui.js +4 -3
  17. package/dist/browser/workbench.css +375 -322
  18. package/dist/browser/workbench.js +8 -8
  19. package/dist/browser/{workbenchSelect-BqUPacsr.js → workbenchSelect-BRZN4ish.js} +1 -1
  20. package/dist/common/authoringExamples.d.ts +3 -2
  21. package/dist/common/control-api-conformance.js +3410 -3285
  22. package/dist/common/control-api.js +3680 -3531
  23. package/dist/common/control-requests.js +2132 -1860
  24. package/dist/common/decision.d.ts +47 -0
  25. package/dist/common/decision.js +10153 -0
  26. package/dist/common/flow-encoding.js +3105 -124
  27. package/dist/common/flow-semantics.js +276 -2
  28. package/dist/common/integration-trigger.js +202 -1
  29. package/dist/common/mcp.js +3748 -3623
  30. package/dist/common/openapi.js +202 -1
  31. package/dist/common/poll-trigger.js +226 -1
  32. package/dist/common/run-events.js +1 -0
  33. package/dist/common/runtime-contract.d.ts +8 -0
  34. package/dist/common/scheduler.d.ts +1 -1
  35. package/dist/common/scheduler.js +2137 -1936
  36. package/dist/common/webhook-trigger.js +202 -1
  37. package/package.json +5 -1
  38. package/dist/browser/dist-BDBTOgS5.js +0 -9
@@ -5031,6 +5031,70 @@ var $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
5031
5031
  });
5032
5032
  };
5033
5033
  });
5034
+ function discriminatorMap(def) {
5035
+ const map = /* @__PURE__ */ new Map();
5036
+ for (const option of def.options) {
5037
+ const values = option._zod.propValues?.[def.discriminator];
5038
+ if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
5039
+ for (const value of values) if (map.has(value)) {
5040
+ if (value !== void 0) throw new Error(`Duplicate discriminator value "${String(value)}"`);
5041
+ map.set(value, null);
5042
+ } else map.set(value, option);
5043
+ }
5044
+ return map;
5045
+ }
5046
+ var $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
5047
+ def.inclusive = false;
5048
+ $ZodUnion.init(inst, def);
5049
+ const _super = inst._zod.parse;
5050
+ defineLazyInternal(inst, "propValues", (zod) => {
5051
+ const propValues = {};
5052
+ let undefinedCount = 0;
5053
+ for (const option of zod.def.options) {
5054
+ const pv = option._zod.propValues;
5055
+ if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
5056
+ if (pv[zod.def.discriminator]?.has(void 0)) undefinedCount++;
5057
+ for (const [k, v] of Object.entries(pv)) {
5058
+ if (!Object.prototype.hasOwnProperty.call(propValues, k)) assignProp(propValues, k, /* @__PURE__ */ new Set());
5059
+ for (const val of v) propValues[k].add(val);
5060
+ }
5061
+ }
5062
+ if (!zod.def.unionFallback && undefinedCount > 1) propValues[zod.def.discriminator]?.delete(void 0);
5063
+ return propValues;
5064
+ });
5065
+ def.options.forEach((option, i) => {
5066
+ const propShape = rawShape(option._zod.def);
5067
+ if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) throw new Error(`Invalid discriminated union option at index "${i}"`);
5068
+ });
5069
+ const disc = cached(() => discriminatorMap(def));
5070
+ inst._zod.parse = (payload, ctx) => {
5071
+ const input = payload.value;
5072
+ if (!isObject(input)) {
5073
+ payload.issues.push({
5074
+ code: "invalid_type",
5075
+ expected: "object",
5076
+ input,
5077
+ inst
5078
+ });
5079
+ return payload;
5080
+ }
5081
+ const value = input?.[def.discriminator];
5082
+ const opt = disc.value.get(value);
5083
+ if (opt && (value !== void 0 || ctx.direction !== "backward")) return opt._zod.run(payload, ctx);
5084
+ if (def.unionFallback || ctx.direction === "backward") return _super(payload, ctx);
5085
+ payload.issues.push({
5086
+ code: "invalid_union",
5087
+ errors: [],
5088
+ note: "No matching discriminator",
5089
+ discriminator: def.discriminator,
5090
+ options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
5091
+ input,
5092
+ path: [def.discriminator],
5093
+ inst
5094
+ });
5095
+ return payload;
5096
+ };
5097
+ });
5034
5098
  var $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def) => {
5035
5099
  $ZodType.init(inst, def);
5036
5100
  inst._zod.parse = (payload, ctx) => {
@@ -8079,6 +8143,18 @@ function union(options, params) {
8079
8143
  ...normalizeParams(params)
8080
8144
  });
8081
8145
  }
8146
+ var ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("ZodDiscriminatedUnion", (inst, def) => {
8147
+ ZodUnion.init(inst, def);
8148
+ $ZodDiscriminatedUnion.init(inst, def);
8149
+ });
8150
+ function discriminatedUnion(discriminator, options, params) {
8151
+ return new ZodDiscriminatedUnion({
8152
+ type: "union",
8153
+ options,
8154
+ discriminator,
8155
+ ...normalizeParams(params)
8156
+ });
8157
+ }
8082
8158
  var ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
8083
8159
  $ZodIntersection.init(inst, def);
8084
8160
  ZodType.init(inst, def);
@@ -8357,6 +8433,96 @@ function json$1(params) {
8357
8433
  return jsonSchema;
8358
8434
  }
8359
8435
  //#endregion
8436
+ //#region src/decision/common/decision.ts
8437
+ var decisionLimits = {
8438
+ choice: 255,
8439
+ score: 10
8440
+ };
8441
+ /** Ordered prefixes are shared by authoring, schemas, validation, and execution. */
8442
+ function limitDecisionQuestion(question) {
8443
+ if (question.type === "noul" || question.criteria.length <= decisionLimits[question.type]) return question;
8444
+ if (question.type === "choice") return {
8445
+ ...question,
8446
+ criteria: question.criteria.slice(0, decisionLimits.choice)
8447
+ };
8448
+ return {
8449
+ ...question,
8450
+ criteria: question.criteria.slice(0, decisionLimits.score)
8451
+ };
8452
+ }
8453
+ function limitDecisionQuestions(questions) {
8454
+ const limited = questions.map(limitDecisionQuestion);
8455
+ return limited.every((question, i) => question === questions[i]) ? questions : limited;
8456
+ }
8457
+ /** Loading an oversized task also updates its previously generated output schemas. */
8458
+ function limitDecisionTask(task) {
8459
+ if (task.executor.kind !== "decision") return task;
8460
+ const original = task.executor.questions;
8461
+ const questions = limitDecisionQuestions(original);
8462
+ if (questions === original) return task;
8463
+ const outputs = task.outputs.map((port) => {
8464
+ if (!("handle" in port)) return port;
8465
+ const index = original.findIndex((question) => question.name === port.handle);
8466
+ if (index < 0 || original[index] === questions[index] || !dequal(port.jsonSchema, answerSchema(original[index]))) return port;
8467
+ return {
8468
+ ...port,
8469
+ jsonSchema: decisionAnswerSchema(questions[index])
8470
+ };
8471
+ });
8472
+ return {
8473
+ ...task,
8474
+ executor: {
8475
+ ...task.executor,
8476
+ questions
8477
+ },
8478
+ outputs
8479
+ };
8480
+ }
8481
+ var probability = {
8482
+ type: "number",
8483
+ minimum: 0,
8484
+ maximum: 1
8485
+ };
8486
+ function decisionAnswerSchema(question) {
8487
+ return answerSchema(limitDecisionQuestion(question));
8488
+ }
8489
+ function answerSchema(question) {
8490
+ const properties = { type: { const: question.type } };
8491
+ if (question.type === "noul") properties.noul = probability;
8492
+ else {
8493
+ const keys = question.type === "choice" ? question.criteria.map((item) => item.name) : question.criteria.map((_, index) => String(index));
8494
+ properties.confidence = probability;
8495
+ properties.probabilities = {
8496
+ type: "object",
8497
+ properties: Object.fromEntries(keys.map((key) => [key, probability])),
8498
+ required: keys,
8499
+ additionalProperties: false
8500
+ };
8501
+ if (question.type === "choice") properties.choice = {
8502
+ type: "string",
8503
+ ...keys.length ? { enum: keys } : {}
8504
+ };
8505
+ else {
8506
+ properties.score = {
8507
+ type: "number",
8508
+ minimum: 0,
8509
+ maximum: Math.max(0, keys.length - 1)
8510
+ };
8511
+ properties.legend = {
8512
+ type: "object",
8513
+ properties: Object.fromEntries(keys.map((key) => [key, { type: "string" }])),
8514
+ required: keys,
8515
+ additionalProperties: false
8516
+ };
8517
+ }
8518
+ }
8519
+ return {
8520
+ type: "object",
8521
+ properties,
8522
+ required: Object.keys(properties)
8523
+ };
8524
+ }
8525
+ //#endregion
8360
8526
  //#region src/flow/common/triggerScheduleSchema.ts
8361
8527
  var triggerScheduleSchema = array(union([object({
8362
8528
  type: literal("cron"),
@@ -8476,6 +8642,32 @@ var agentValue = union([object({
8476
8642
  input: text
8477
8643
  })]);
8478
8644
  var agentInput = union([agentValue, object({ kind: literal("model") })]);
8645
+ var decisionQuestion = discriminatedUnion("type", [
8646
+ strictObject({
8647
+ name: text,
8648
+ instructions: text,
8649
+ type: literal("noul"),
8650
+ criteria: strictObject({
8651
+ true: text.optional(),
8652
+ false: text.optional()
8653
+ }).optional()
8654
+ }),
8655
+ strictObject({
8656
+ name: text,
8657
+ instructions: text,
8658
+ type: literal("choice"),
8659
+ criteria: array(strictObject({
8660
+ name: text,
8661
+ description: text
8662
+ }))
8663
+ }),
8664
+ strictObject({
8665
+ name: text,
8666
+ instructions: text,
8667
+ type: literal("score"),
8668
+ criteria: strings
8669
+ })
8670
+ ]);
8479
8671
  var managed = object({
8480
8672
  ...ports,
8481
8673
  name: text,
@@ -8503,6 +8695,10 @@ var managed = object({
8503
8695
  in: _enum(["header", "query"]).optional()
8504
8696
  }))
8505
8697
  }),
8698
+ strictObject({
8699
+ kind: literal("decision"),
8700
+ questions: array(decisionQuestion)
8701
+ }),
8506
8702
  object({
8507
8703
  kind: literal("llm"),
8508
8704
  mode: _enum(["chat", "json"])
@@ -8529,7 +8725,7 @@ var managed = object({
8529
8725
  }).optional()
8530
8726
  })
8531
8727
  ])
8532
- });
8728
+ }).transform(limitDecisionTask);
8533
8729
  var operand = union([object({
8534
8730
  kind: literal("value"),
8535
8731
  value: json.optional(),
@@ -8923,6 +9119,11 @@ var shapes = {
8923
9119
  before: text.optional(),
8924
9120
  value: text.optional()
8925
9121
  },
9122
+ "task.decision.set": {
9123
+ taskId: text,
9124
+ before: managed,
9125
+ value: managed
9126
+ },
8926
9127
  "task.openapi.set": {
8927
9128
  taskId: text,
8928
9129
  before: managed,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oomol-lab/open-flow",
3
- "version": "0.1.0-beta.54",
3
+ "version": "0.1.0-beta.55",
4
4
  "description": "TypeScript contracts and Browser runtime for Open Flow.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -13,6 +13,10 @@
13
13
  ".": {
14
14
  "types": "./dist/index.d.ts"
15
15
  },
16
+ "./decision": {
17
+ "types": "./dist/common/decision.d.ts",
18
+ "import": "./dist/common/decision.js"
19
+ },
16
20
  "./openapi": {
17
21
  "types": "./dist/common/openapi.d.ts",
18
22
  "import": "./dist/common/openapi.js"
@@ -1,9 +0,0 @@
1
- //#region ../../node_modules/.bun/@wopjs+cast@0.1.16/node_modules/@wopjs/cast/dist/index.mjs
2
- var isBoolean = (x) => x === true || x === false;
3
- var isString = (x) => typeof x === "string";
4
- var isArray = Array.isArray;
5
- var isObject = (x) => x !== null && typeof x === "object";
6
- var isPlainObject = (x) => isObject(x) && !isArray(x);
7
- var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
8
- //#endregion
9
- export { toPlainObject as a, isString as i, isBoolean as n, isPlainObject as r, isArray as t };