@graphrefly/graphrefly 0.19.0 → 0.20.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 (48) hide show
  1. package/dist/{chunk-XUOY3YKN.js → chunk-2L5J6RPM.js} +2 -2
  2. package/dist/{chunk-JC2SN46B.js → chunk-3N2Y6PCR.js} +3 -3
  3. package/dist/{chunk-OO5QOAXI.js → chunk-5PSVTDNZ.js} +22 -9
  4. package/dist/chunk-5PSVTDNZ.js.map +1 -0
  5. package/dist/{chunk-BER7UYLM.js → chunk-BJAOEU4D.js} +10 -6
  6. package/dist/{chunk-BER7UYLM.js.map → chunk-BJAOEU4D.js.map} +1 -1
  7. package/dist/{chunk-UW77D7SP.js → chunk-IAPLC4NR.js} +3 -3
  8. package/dist/{chunk-IRZAGZUB.js → chunk-OOA2UTXF.js} +26 -2
  9. package/dist/chunk-OOA2UTXF.js.map +1 -0
  10. package/dist/{chunk-AHRKWMNI.js → chunk-PGEU5MEH.js} +3 -3
  11. package/dist/{chunk-YLR5JUJZ.js → chunk-R2LPZIY2.js} +3 -3
  12. package/dist/{chunk-YXR3WW3Q.js → chunk-XYL3GLB3.js} +3 -3
  13. package/dist/{chunk-YXR3WW3Q.js.map → chunk-XYL3GLB3.js.map} +1 -1
  14. package/dist/compat/nestjs/index.cjs +14 -5
  15. package/dist/compat/nestjs/index.cjs.map +1 -1
  16. package/dist/compat/nestjs/index.js +7 -7
  17. package/dist/core/index.cjs +2 -2
  18. package/dist/core/index.cjs.map +1 -1
  19. package/dist/core/index.d.cts +1 -1
  20. package/dist/core/index.d.ts +1 -1
  21. package/dist/core/index.js +3 -3
  22. package/dist/extra/index.cjs +31 -5
  23. package/dist/extra/index.cjs.map +1 -1
  24. package/dist/extra/index.d.cts +1 -1
  25. package/dist/extra/index.d.ts +1 -1
  26. package/dist/extra/index.js +7 -3
  27. package/dist/graph/index.cjs.map +1 -1
  28. package/dist/graph/index.js +4 -4
  29. package/dist/{index-CvKzv0AW.d.ts → index-BHfg_Ez3.d.ts} +1 -1
  30. package/dist/{index-BBUYZfJ1.d.cts → index-Bc_diYYJ.d.cts} +1 -1
  31. package/dist/{index-BnkMgNNa.d.ts → index-DuN3bhtm.d.ts} +47 -2
  32. package/dist/{index-Bjh5C1Tp.d.cts → index-SFzE_KTa.d.cts} +47 -2
  33. package/dist/index.cjs +153 -87
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +75 -6
  36. package/dist/index.d.ts +75 -6
  37. package/dist/index.js +126 -90
  38. package/dist/index.js.map +1 -1
  39. package/dist/patterns/reactive-layout/index.cjs.map +1 -1
  40. package/dist/patterns/reactive-layout/index.js +4 -4
  41. package/package.json +2 -2
  42. package/dist/chunk-IRZAGZUB.js.map +0 -1
  43. package/dist/chunk-OO5QOAXI.js.map +0 -1
  44. /package/dist/{chunk-XUOY3YKN.js.map → chunk-2L5J6RPM.js.map} +0 -0
  45. /package/dist/{chunk-JC2SN46B.js.map → chunk-3N2Y6PCR.js.map} +0 -0
  46. /package/dist/{chunk-UW77D7SP.js.map → chunk-IAPLC4NR.js.map} +0 -0
  47. /package/dist/{chunk-AHRKWMNI.js.map → chunk-PGEU5MEH.js.map} +0 -0
  48. /package/dist/{chunk-YLR5JUJZ.js.map → chunk-R2LPZIY2.js.map} +0 -0
package/dist/index.js CHANGED
@@ -136,16 +136,26 @@ import {
136
136
  workerBridge,
137
137
  workerSelf,
138
138
  zip
139
- } from "./chunk-BER7UYLM.js";
139
+ } from "./chunk-BJAOEU4D.js";
140
140
  import {
141
141
  cqrs_exports,
142
- nestjs_exports
143
- } from "./chunk-OO5QOAXI.js";
142
+ domainMeta,
143
+ nestjs_exports,
144
+ trackingKey
145
+ } from "./chunk-5PSVTDNZ.js";
144
146
  import {
145
147
  DEFAULT_DOWN,
146
148
  bridge,
147
149
  core_exports
148
- } from "./chunk-AHRKWMNI.js";
150
+ } from "./chunk-PGEU5MEH.js";
151
+ import {
152
+ JsonCodec,
153
+ createDagCborCodec,
154
+ createDagCborZstdCodec,
155
+ graph_exports,
156
+ negotiateCodec,
157
+ replayWAL
158
+ } from "./chunk-R2LPZIY2.js";
149
159
  import {
150
160
  cached,
151
161
  createWatermarkController,
@@ -163,12 +173,14 @@ import {
163
173
  fromPromise,
164
174
  fromTimer,
165
175
  globToRegExp,
176
+ keepalive,
166
177
  logSlice,
167
178
  matchesAnyPattern,
168
179
  matchesCron,
169
180
  never,
170
181
  of,
171
182
  parseCron,
183
+ reactiveCounter,
172
184
  reactiveLog,
173
185
  replay,
174
186
  share,
@@ -176,34 +188,26 @@ import {
176
188
  throwError,
177
189
  toArray,
178
190
  toObservable
179
- } from "./chunk-IRZAGZUB.js";
191
+ } from "./chunk-OOA2UTXF.js";
180
192
  import {
181
193
  ResettableTimer
182
194
  } from "./chunk-WZ2Z2CRV.js";
183
- import {
184
- JsonCodec,
185
- createDagCborCodec,
186
- createDagCborZstdCodec,
187
- graph_exports,
188
- negotiateCodec,
189
- replayWAL
190
- } from "./chunk-YLR5JUJZ.js";
191
195
  import {
192
196
  analyzeAndMeasure,
193
197
  computeLineBreaks,
194
198
  reactive_layout_exports
195
- } from "./chunk-UW77D7SP.js";
199
+ } from "./chunk-IAPLC4NR.js";
196
200
  import {
197
201
  GRAPH_META_SEGMENT,
198
202
  Graph,
199
203
  graphProfile,
200
204
  reachable,
201
205
  sizeof
202
- } from "./chunk-JC2SN46B.js";
206
+ } from "./chunk-3N2Y6PCR.js";
203
207
  import {
204
208
  describeNode,
205
209
  resolveDescribeFields
206
- } from "./chunk-XUOY3YKN.js";
210
+ } from "./chunk-2L5J6RPM.js";
207
211
  import {
208
212
  CLEANUP_RESULT,
209
213
  COMPLETE,
@@ -249,7 +253,7 @@ import {
249
253
  propagatesToMeta,
250
254
  state,
251
255
  wallClockNs
252
- } from "./chunk-YXR3WW3Q.js";
256
+ } from "./chunk-XYL3GLB3.js";
253
257
 
254
258
  // src/compat/index.ts
255
259
  var compat_exports = {};
@@ -1517,16 +1521,8 @@ function requireNonNegativeInt(value, label) {
1517
1521
  }
1518
1522
  return value;
1519
1523
  }
1520
- function keepalive(n) {
1521
- return n.subscribe(() => {
1522
- });
1523
- }
1524
1524
  function messagingMeta(kind, extra) {
1525
- return {
1526
- messaging: true,
1527
- messaging_type: kind,
1528
- ...extra ?? {}
1529
- };
1525
+ return domainMeta("messaging", kind, extra);
1530
1526
  }
1531
1527
  var TopicGraph = class extends Graph {
1532
1528
  _log;
@@ -1909,11 +1905,7 @@ function registerStep(graph, name, step, depPaths) {
1909
1905
  }
1910
1906
  }
1911
1907
  function baseMeta(kind, meta) {
1912
- return {
1913
- orchestration: true,
1914
- orchestration_type: kind,
1915
- ...meta ?? {}
1916
- };
1908
+ return domainMeta("orchestration", kind, meta);
1917
1909
  }
1918
1910
  function coerceLoopIterations(raw) {
1919
1911
  const parseString = (value) => {
@@ -2359,14 +2351,7 @@ function onFailure(graph, name, source, recover, opts) {
2359
2351
 
2360
2352
  // src/patterns/ai.ts
2361
2353
  function aiMeta(kind, extra) {
2362
- return {
2363
- ai: true,
2364
- ai_type: kind,
2365
- ...extra ?? {}
2366
- };
2367
- }
2368
- function keepalive2(n) {
2369
- return n.subscribe(() => void 0);
2354
+ return domainMeta("ai", kind, extra);
2370
2355
  }
2371
2356
  function isPromiseLike(x) {
2372
2357
  return x != null && typeof x.then === "function";
@@ -2500,7 +2485,7 @@ function streamingPromptNode(adapter, deps, prompt, opts) {
2500
2485
  }
2501
2486
  return fromAny(pumpAndCollect());
2502
2487
  });
2503
- const unsub = keepalive2(output);
2488
+ const unsub = keepalive(output);
2504
2489
  return {
2505
2490
  output,
2506
2491
  stream: streamTopic,
@@ -2685,7 +2670,7 @@ function gatedStream(graph, name, adapter, deps, prompt, opts) {
2685
2670
  }
2686
2671
  return fromAny(pumpAndCollect());
2687
2672
  });
2688
- const unsub = keepalive2(output);
2673
+ const unsub = keepalive(output);
2689
2674
  const nonNullOutput = derived(
2690
2675
  [output],
2691
2676
  ([v]) => {
@@ -2816,7 +2801,7 @@ var ChatStreamGraph = class extends Graph {
2816
2801
  );
2817
2802
  this.add("latest", this.latest);
2818
2803
  this.connect("messages", "latest");
2819
- this.addDisposer(keepalive2(this.latest));
2804
+ this.addDisposer(keepalive(this.latest));
2820
2805
  this.messageCount = derived(
2821
2806
  [this.messages],
2822
2807
  ([snapshot]) => snapshot.length,
@@ -2829,7 +2814,7 @@ var ChatStreamGraph = class extends Graph {
2829
2814
  );
2830
2815
  this.add("messageCount", this.messageCount);
2831
2816
  this.connect("messages", "messageCount");
2832
- this.addDisposer(keepalive2(this.messageCount));
2817
+ this.addDisposer(keepalive(this.messageCount));
2833
2818
  }
2834
2819
  append(role, content, extra) {
2835
2820
  this._log.append({ role, content, ...extra });
@@ -2870,7 +2855,7 @@ var ToolRegistryGraph = class extends Graph {
2870
2855
  );
2871
2856
  this.add("schemas", this.schemas);
2872
2857
  this.connect("definitions", "schemas");
2873
- this.addDisposer(keepalive2(this.schemas));
2858
+ this.addDisposer(keepalive(this.schemas));
2874
2859
  }
2875
2860
  register(tool) {
2876
2861
  const current = this.definitions.get();
@@ -2912,7 +2897,7 @@ function systemPromptBuilder(sections, opts) {
2912
2897
  initial: ""
2913
2898
  }
2914
2899
  );
2915
- const unsub = keepalive2(prompt);
2900
+ const unsub = keepalive(prompt);
2916
2901
  return Object.assign(prompt, { dispose: unsub });
2917
2902
  }
2918
2903
  function llmExtractor(systemPrompt, opts) {
@@ -4225,21 +4210,14 @@ __export(domain_templates_exports, {
4225
4210
  var reduction_exports = {};
4226
4211
  __export(reduction_exports, {
4227
4212
  budgetGate: () => budgetGate,
4213
+ effectivenessTracker: () => effectivenessTracker,
4228
4214
  feedback: () => feedback,
4229
4215
  funnel: () => funnel,
4230
4216
  scorer: () => scorer,
4231
4217
  stratify: () => stratify
4232
4218
  });
4233
4219
  function baseMeta2(kind, meta) {
4234
- return {
4235
- reduction: true,
4236
- reduction_type: kind,
4237
- ...meta ?? {}
4238
- };
4239
- }
4240
- function keepalive3(n) {
4241
- return n.subscribe(() => {
4242
- });
4220
+ return domainMeta("reduction", kind, meta);
4243
4221
  }
4244
4222
  function stratify(name, source, rules, opts) {
4245
4223
  const g = new Graph(name, opts);
@@ -4377,7 +4355,7 @@ function funnel(name, sources, stages, opts) {
4377
4355
  });
4378
4356
  g.add(bridgeName, br);
4379
4357
  g.connect(prevOutputPath, bridgeName);
4380
- g.addDisposer(keepalive3(br));
4358
+ g.addDisposer(keepalive(br));
4381
4359
  prevOutputPath = `${stage.name}::output`;
4382
4360
  }
4383
4361
  return g;
@@ -4429,7 +4407,7 @@ function feedback(graph, condition, reentry, opts) {
4429
4407
  });
4430
4408
  graph.add(feedbackEffectName, feedbackEffect);
4431
4409
  graph.connect(condition, feedbackEffectName);
4432
- graph.addDisposer(keepalive3(feedbackEffect));
4410
+ graph.addDisposer(keepalive(feedbackEffect));
4433
4411
  return graph;
4434
4412
  }
4435
4413
  function budgetGate(source, constraints, opts) {
@@ -4563,14 +4541,55 @@ function scorer(sources, weights, opts) {
4563
4541
  }
4564
4542
  );
4565
4543
  }
4566
-
4567
- // src/patterns/domain-templates.ts
4568
- function keepalive4(n) {
4569
- return n.subscribe(() => {
4544
+ function effectivenessTracker(opts) {
4545
+ const _map = reactiveMap({
4546
+ name: opts?.name ?? "effectiveness-entries"
4570
4547
  });
4548
+ const snapshot = derived(
4549
+ [_map.entries],
4550
+ ([mapSnap]) => {
4551
+ return new Map(mapSnap);
4552
+ },
4553
+ {
4554
+ name: `${opts?.name ?? "effectiveness"}-snapshot`,
4555
+ equals: (a, b) => {
4556
+ const am = a;
4557
+ const bm = b;
4558
+ if (am.size !== bm.size) return false;
4559
+ for (const [k, v] of am) {
4560
+ const bv = bm.get(k);
4561
+ if (!bv || v.attempts !== bv.attempts || v.successes !== bv.successes) return false;
4562
+ }
4563
+ return true;
4564
+ }
4565
+ }
4566
+ );
4567
+ function record(key, success) {
4568
+ const existing = _map.get(key);
4569
+ const attempts = (existing?.attempts ?? 0) + 1;
4570
+ const successes = (existing?.successes ?? 0) + (success ? 1 : 0);
4571
+ _map.set(key, {
4572
+ key,
4573
+ attempts,
4574
+ successes,
4575
+ successRate: successes / attempts
4576
+ });
4577
+ }
4578
+ function lookup(key) {
4579
+ return _map.get(key);
4580
+ }
4581
+ const _unsub = keepalive(snapshot);
4582
+ return {
4583
+ node: snapshot,
4584
+ record,
4585
+ lookup,
4586
+ dispose: () => _unsub()
4587
+ };
4571
4588
  }
4589
+
4590
+ // src/patterns/domain-templates.ts
4572
4591
  function baseMeta3(kind, extra) {
4573
- return { domain_template: true, template_type: kind, ...extra ?? {} };
4592
+ return domainMeta("domain_template", kind, extra);
4574
4593
  }
4575
4594
  function observabilityGraph(name, opts) {
4576
4595
  const g = new Graph(name, opts);
@@ -4810,7 +4829,7 @@ function contentModerationGraph(name, opts) {
4810
4829
  }
4811
4830
  });
4812
4831
  g.add("__review_accumulator", reviewAccumulator);
4813
- g.addDisposer(keepalive4(reviewAccumulator));
4832
+ g.addDisposer(keepalive(reviewAccumulator));
4814
4833
  try {
4815
4834
  g.connect("stratify::branch/review", "__review_accumulator");
4816
4835
  } catch {
@@ -4921,7 +4940,7 @@ function dataQualityGraph(name, opts) {
4921
4940
  });
4922
4941
  g.add("__baseline_updater", baselineUpdater);
4923
4942
  g.connect("validate", "__baseline_updater");
4924
- keepalive4(baselineUpdater);
4943
+ keepalive(baselineUpdater);
4925
4944
  const detectDriftFn = opts.detectDrift ?? (() => ({ drift: false }));
4926
4945
  const driftNode = derived(
4927
4946
  [opts.source, baseline],
@@ -6011,6 +6030,7 @@ __export(harness_exports, {
6011
6030
  DEFAULT_SEVERITY_WEIGHTS: () => DEFAULT_SEVERITY_WEIGHTS,
6012
6031
  HarnessGraph: () => HarnessGraph,
6013
6032
  QUEUE_NAMES: () => QUEUE_NAMES,
6033
+ createIntakeBridge: () => createIntakeBridge,
6014
6034
  defaultErrorClassifier: () => defaultErrorClassifier,
6015
6035
  evalIntakeBridge: () => evalIntakeBridge,
6016
6036
  harnessLoop: () => harnessLoop,
@@ -6022,41 +6042,58 @@ __export(harness_exports, {
6022
6042
  });
6023
6043
 
6024
6044
  // src/patterns/harness/bridge.ts
6045
+ function createIntakeBridge(source, intakeTopic, parser, opts) {
6046
+ return effect(
6047
+ [source],
6048
+ ([value]) => {
6049
+ if (value == null) return;
6050
+ const items = parser(value);
6051
+ for (const item of items) {
6052
+ intakeTopic.publish(item);
6053
+ }
6054
+ },
6055
+ { name: opts?.name ?? "intake-bridge" }
6056
+ );
6057
+ }
6025
6058
  function evalIntakeBridge(evalSource, intakeTopic, opts) {
6026
6059
  const defaultSeverity = opts?.defaultSeverity ?? "medium";
6027
- return effect([evalSource], ([results]) => {
6028
- if (results == null) return;
6029
- const runs = Array.isArray(results) ? results : [results];
6030
- for (const run of runs) {
6031
- for (const task2 of run.tasks) {
6032
- if (task2.valid && task2.judge_scores?.every((s) => s.pass)) continue;
6033
- if (!task2.valid && (!task2.judge_scores || task2.judge_scores.length === 0)) {
6034
- intakeTopic.publish({
6035
- source: "eval",
6036
- summary: `Task ${task2.task_id} invalid (model: ${run.model})`,
6037
- evidence: `Run ${run.run_id}: task produced invalid output`,
6038
- affectsAreas: ["graphspec"],
6039
- affectsEvalTasks: [task2.task_id],
6040
- severity: defaultSeverity
6041
- });
6042
- continue;
6043
- }
6044
- if (task2.judge_scores) {
6045
- for (const score of task2.judge_scores) {
6046
- if (score.pass) continue;
6060
+ return effect(
6061
+ [evalSource],
6062
+ ([results]) => {
6063
+ if (results == null) return;
6064
+ const runs = Array.isArray(results) ? results : [results];
6065
+ for (const run of runs) {
6066
+ for (const task2 of run.tasks) {
6067
+ if (task2.valid && task2.judge_scores?.every((s) => s.pass)) continue;
6068
+ if (!task2.valid && (!task2.judge_scores || task2.judge_scores.length === 0)) {
6047
6069
  intakeTopic.publish({
6048
6070
  source: "eval",
6049
- summary: `${task2.task_id}: ${score.claim} (model: ${run.model})`,
6050
- evidence: score.reasoning,
6071
+ summary: `Task ${task2.task_id} invalid (model: ${run.model})`,
6072
+ evidence: `Run ${run.run_id}: task produced invalid output`,
6051
6073
  affectsAreas: ["graphspec"],
6052
6074
  affectsEvalTasks: [task2.task_id],
6053
6075
  severity: defaultSeverity
6054
6076
  });
6077
+ continue;
6078
+ }
6079
+ if (task2.judge_scores) {
6080
+ for (const score of task2.judge_scores) {
6081
+ if (score.pass) continue;
6082
+ intakeTopic.publish({
6083
+ source: "eval",
6084
+ summary: `${task2.task_id}: ${score.claim} (model: ${run.model})`,
6085
+ evidence: score.reasoning,
6086
+ affectsAreas: ["graphspec"],
6087
+ affectsEvalTasks: [task2.task_id],
6088
+ severity: defaultSeverity
6089
+ });
6090
+ }
6055
6091
  }
6056
6092
  }
6057
6093
  }
6058
- }
6059
- });
6094
+ },
6095
+ { name: opts?.name ?? "eval-intake-bridge" }
6096
+ );
6060
6097
  }
6061
6098
 
6062
6099
  // src/patterns/harness/types.ts
@@ -6166,9 +6203,6 @@ function priorityScore(item, strategy, lastInteractionNs, urgency, signals) {
6166
6203
  }
6167
6204
 
6168
6205
  // src/patterns/harness/loop.ts
6169
- function trackingKey(item) {
6170
- return item.relatedTo?.[0] ?? item.summary;
6171
- }
6172
6206
  var DEFAULT_TRIAGE_PROMPT = `You are a triage classifier for a reactive collaboration harness.
6173
6207
 
6174
6208
  Given an intake item, classify it and output JSON:
@@ -6684,6 +6718,7 @@ export {
6684
6718
  isTerminalMessage,
6685
6719
  isV1,
6686
6720
  jotai_exports as jotai,
6721
+ keepalive,
6687
6722
  knownMessageTypes,
6688
6723
  last,
6689
6724
  reactive_layout_exports as layout,
@@ -6726,6 +6761,7 @@ export {
6726
6761
  rateLimiter,
6727
6762
  reachable,
6728
6763
  react_exports as react,
6764
+ reactiveCounter,
6729
6765
  reactiveIndex,
6730
6766
  reactiveList,
6731
6767
  reactiveLog,