@graphrefly/graphrefly 0.20.0 → 0.21.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 (42) hide show
  1. package/README.md +20 -3
  2. package/dist/{chunk-3N2Y6PCR.js → chunk-2UDLYZHT.js} +3 -3
  3. package/dist/{chunk-XYL3GLB3.js → chunk-4MQ2J6IG.js} +2 -2
  4. package/dist/{chunk-XYL3GLB3.js.map → chunk-4MQ2J6IG.js.map} +1 -1
  5. package/dist/{chunk-2L5J6RPM.js → chunk-7IGHIFTT.js} +2 -2
  6. package/dist/{chunk-PGEU5MEH.js → chunk-DOSLSFKL.js} +3 -3
  7. package/dist/{chunk-BJAOEU4D.js → chunk-ECN37NVS.js} +154 -196
  8. package/dist/chunk-ECN37NVS.js.map +1 -0
  9. package/dist/{chunk-R2LPZIY2.js → chunk-G66H6ZRK.js} +3 -3
  10. package/dist/{chunk-OOA2UTXF.js → chunk-VOQFK7YN.js} +2 -2
  11. package/dist/{chunk-5PSVTDNZ.js → chunk-XWBVAO2R.js} +4 -4
  12. package/dist/{chunk-IAPLC4NR.js → chunk-ZTCDY5NQ.js} +3 -3
  13. package/dist/compat/nestjs/index.cjs +1 -1
  14. package/dist/compat/nestjs/index.cjs.map +1 -1
  15. package/dist/compat/nestjs/index.js +7 -7
  16. package/dist/core/index.cjs +1 -1
  17. package/dist/core/index.cjs.map +1 -1
  18. package/dist/core/index.js +3 -3
  19. package/dist/extra/index.cjs +152 -194
  20. package/dist/extra/index.cjs.map +1 -1
  21. package/dist/extra/index.js +3 -3
  22. package/dist/graph/index.cjs +1 -1
  23. package/dist/graph/index.cjs.map +1 -1
  24. package/dist/graph/index.js +4 -4
  25. package/dist/index.cjs +312 -196
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +201 -5
  28. package/dist/index.d.ts +201 -5
  29. package/dist/index.js +173 -15
  30. package/dist/index.js.map +1 -1
  31. package/dist/patterns/reactive-layout/index.cjs +1 -1
  32. package/dist/patterns/reactive-layout/index.cjs.map +1 -1
  33. package/dist/patterns/reactive-layout/index.js +4 -4
  34. package/package.json +2 -1
  35. package/dist/chunk-BJAOEU4D.js.map +0 -1
  36. /package/dist/{chunk-3N2Y6PCR.js.map → chunk-2UDLYZHT.js.map} +0 -0
  37. /package/dist/{chunk-2L5J6RPM.js.map → chunk-7IGHIFTT.js.map} +0 -0
  38. /package/dist/{chunk-PGEU5MEH.js.map → chunk-DOSLSFKL.js.map} +0 -0
  39. /package/dist/{chunk-R2LPZIY2.js.map → chunk-G66H6ZRK.js.map} +0 -0
  40. /package/dist/{chunk-OOA2UTXF.js.map → chunk-VOQFK7YN.js.map} +0 -0
  41. /package/dist/{chunk-5PSVTDNZ.js.map → chunk-XWBVAO2R.js.map} +0 -0
  42. /package/dist/{chunk-IAPLC4NR.js.map → chunk-ZTCDY5NQ.js.map} +0 -0
package/dist/index.js CHANGED
@@ -136,18 +136,13 @@ import {
136
136
  workerBridge,
137
137
  workerSelf,
138
138
  zip
139
- } from "./chunk-BJAOEU4D.js";
139
+ } from "./chunk-ECN37NVS.js";
140
140
  import {
141
141
  cqrs_exports,
142
142
  domainMeta,
143
143
  nestjs_exports,
144
144
  trackingKey
145
- } from "./chunk-5PSVTDNZ.js";
146
- import {
147
- DEFAULT_DOWN,
148
- bridge,
149
- core_exports
150
- } from "./chunk-PGEU5MEH.js";
145
+ } from "./chunk-XWBVAO2R.js";
151
146
  import {
152
147
  JsonCodec,
153
148
  createDagCborCodec,
@@ -155,7 +150,12 @@ import {
155
150
  graph_exports,
156
151
  negotiateCodec,
157
152
  replayWAL
158
- } from "./chunk-R2LPZIY2.js";
153
+ } from "./chunk-G66H6ZRK.js";
154
+ import {
155
+ DEFAULT_DOWN,
156
+ bridge,
157
+ core_exports
158
+ } from "./chunk-DOSLSFKL.js";
159
159
  import {
160
160
  cached,
161
161
  createWatermarkController,
@@ -188,7 +188,7 @@ import {
188
188
  throwError,
189
189
  toArray,
190
190
  toObservable
191
- } from "./chunk-OOA2UTXF.js";
191
+ } from "./chunk-VOQFK7YN.js";
192
192
  import {
193
193
  ResettableTimer
194
194
  } from "./chunk-WZ2Z2CRV.js";
@@ -196,18 +196,18 @@ import {
196
196
  analyzeAndMeasure,
197
197
  computeLineBreaks,
198
198
  reactive_layout_exports
199
- } from "./chunk-IAPLC4NR.js";
199
+ } from "./chunk-ZTCDY5NQ.js";
200
200
  import {
201
201
  GRAPH_META_SEGMENT,
202
202
  Graph,
203
203
  graphProfile,
204
204
  reachable,
205
205
  sizeof
206
- } from "./chunk-3N2Y6PCR.js";
206
+ } from "./chunk-2UDLYZHT.js";
207
207
  import {
208
208
  describeNode,
209
209
  resolveDescribeFields
210
- } from "./chunk-2L5J6RPM.js";
210
+ } from "./chunk-7IGHIFTT.js";
211
211
  import {
212
212
  CLEANUP_RESULT,
213
213
  COMPLETE,
@@ -253,7 +253,7 @@ import {
253
253
  propagatesToMeta,
254
254
  state,
255
255
  wallClockNs
256
- } from "./chunk-XYL3GLB3.js";
256
+ } from "./chunk-4MQ2J6IG.js";
257
257
 
258
258
  // src/compat/index.ts
259
259
  var compat_exports = {};
@@ -1105,6 +1105,7 @@ __export(ai_exports, {
1105
1105
  agentLoop: () => agentLoop,
1106
1106
  agentMemory: () => agentMemory,
1107
1107
  chatStream: () => chatStream,
1108
+ contentGate: () => contentGate,
1108
1109
  costMeterExtractor: () => costMeterExtractor,
1109
1110
  fromLLM: () => fromLLM,
1110
1111
  gatedStream: () => gatedStream,
@@ -1115,6 +1116,7 @@ __export(ai_exports, {
1115
1116
  llmConsolidator: () => llmConsolidator,
1116
1117
  llmExtractor: () => llmExtractor,
1117
1118
  promptNode: () => promptNode,
1119
+ redactor: () => redactor,
1118
1120
  streamExtractor: () => streamExtractor,
1119
1121
  streamingPromptNode: () => streamingPromptNode,
1120
1122
  suggestStrategy: () => suggestStrategy,
@@ -2611,6 +2613,53 @@ function costMeterExtractor(streamTopic, opts) {
2611
2613
  }
2612
2614
  );
2613
2615
  }
2616
+ function redactor(streamTopic, patterns, replaceFn, opts) {
2617
+ const replace = replaceFn ?? (() => "[REDACTED]");
2618
+ function sanitize(text) {
2619
+ let result = text;
2620
+ for (const pat of patterns) {
2621
+ const global = pat.global ? pat : new RegExp(pat.source, `${pat.flags}g`);
2622
+ result = result.replace(global, (m) => replace(m, pat));
2623
+ }
2624
+ return result;
2625
+ }
2626
+ return derived(
2627
+ [streamTopic.latest],
2628
+ ([chunk]) => {
2629
+ if (chunk == null) {
2630
+ return { source: "", token: "", accumulated: "", index: -1 };
2631
+ }
2632
+ const c = chunk;
2633
+ const sanitizedAccumulated = sanitize(c.accumulated);
2634
+ const sanitizedToken = sanitize(c.token);
2635
+ return {
2636
+ source: c.source,
2637
+ token: sanitizedToken,
2638
+ accumulated: sanitizedAccumulated,
2639
+ index: c.index
2640
+ };
2641
+ },
2642
+ { name: opts?.name ?? "redactor" }
2643
+ );
2644
+ }
2645
+ function contentGate(streamTopic, classifier, threshold, opts) {
2646
+ const hardThreshold = threshold * (opts?.hardMultiplier ?? 1.5);
2647
+ const isNodeClassifier = typeof classifier !== "function";
2648
+ const deps = [streamTopic.latest];
2649
+ if (isNodeClassifier) deps.push(classifier);
2650
+ return derived(
2651
+ deps,
2652
+ (values) => {
2653
+ const chunk = values[0];
2654
+ if (chunk == null) return "allow";
2655
+ const score = isNodeClassifier ? values[1] ?? 0 : classifier(chunk.accumulated);
2656
+ if (score >= hardThreshold) return "block";
2657
+ if (score >= threshold) return "review";
2658
+ return "allow";
2659
+ },
2660
+ { name: opts?.name ?? "content-gate", initial: "allow" }
2661
+ );
2662
+ }
2614
2663
  function gatedStream(graph, name, adapter, deps, prompt, opts) {
2615
2664
  const cancelSignal = state(0, { name: `${name}/cancel` });
2616
2665
  let cancelCounter = 0;
@@ -6030,12 +6079,17 @@ __export(harness_exports, {
6030
6079
  DEFAULT_SEVERITY_WEIGHTS: () => DEFAULT_SEVERITY_WEIGHTS,
6031
6080
  HarnessGraph: () => HarnessGraph,
6032
6081
  QUEUE_NAMES: () => QUEUE_NAMES,
6082
+ affectedTaskFilter: () => affectedTaskFilter,
6083
+ beforeAfterCompare: () => beforeAfterCompare,
6084
+ codeChangeBridge: () => codeChangeBridge,
6033
6085
  createIntakeBridge: () => createIntakeBridge,
6034
6086
  defaultErrorClassifier: () => defaultErrorClassifier,
6035
6087
  evalIntakeBridge: () => evalIntakeBridge,
6088
+ evalSource: () => evalSource,
6036
6089
  harnessLoop: () => harnessLoop,
6037
6090
  harnessProfile: () => harnessProfile,
6038
6091
  harnessTrace: () => harnessTrace,
6092
+ notifyEffect: () => notifyEffect,
6039
6093
  priorityScore: () => priorityScore,
6040
6094
  strategyKey: () => strategyKey,
6041
6095
  strategyModel: () => strategyModel
@@ -6055,10 +6109,10 @@ function createIntakeBridge(source, intakeTopic, parser, opts) {
6055
6109
  { name: opts?.name ?? "intake-bridge" }
6056
6110
  );
6057
6111
  }
6058
- function evalIntakeBridge(evalSource, intakeTopic, opts) {
6112
+ function evalIntakeBridge(evalSource2, intakeTopic, opts) {
6059
6113
  const defaultSeverity = opts?.defaultSeverity ?? "medium";
6060
6114
  return effect(
6061
- [evalSource],
6115
+ [evalSource2],
6062
6116
  ([results]) => {
6063
6117
  if (results == null) return;
6064
6118
  const runs = Array.isArray(results) ? results : [results];
@@ -6095,6 +6149,110 @@ function evalIntakeBridge(evalSource, intakeTopic, opts) {
6095
6149
  { name: opts?.name ?? "eval-intake-bridge" }
6096
6150
  );
6097
6151
  }
6152
+ function evalSource(trigger2, runner) {
6153
+ return switchMap(trigger2, () => fromAny(runner()));
6154
+ }
6155
+ function beforeAfterCompare(before, after) {
6156
+ return derived(
6157
+ [before, after],
6158
+ ([b, a]) => {
6159
+ const bRes = b;
6160
+ const aRes = a;
6161
+ const beforeMap = new Map(bRes.tasks.map((t) => [t.task_id, t]));
6162
+ const afterMap = new Map(aRes.tasks.map((t) => [t.task_id, t]));
6163
+ const allIds = /* @__PURE__ */ new Set([...beforeMap.keys(), ...afterMap.keys()]);
6164
+ const taskDeltas = [];
6165
+ const newFailures = [];
6166
+ const resolved = [];
6167
+ for (const id of allIds) {
6168
+ const bt = beforeMap.get(id);
6169
+ const at = afterMap.get(id);
6170
+ const beforeValid = bt?.valid ?? false;
6171
+ const afterValid = at?.valid ?? false;
6172
+ const beforeScore = bt?.judge_scores ? bt.judge_scores.filter((s) => s.pass).length : void 0;
6173
+ const afterScore = at?.judge_scores ? at.judge_scores.filter((s) => s.pass).length : void 0;
6174
+ const scoreDiff = beforeScore !== void 0 && afterScore !== void 0 ? afterScore - beforeScore : void 0;
6175
+ taskDeltas.push({ taskId: id, before: beforeValid, after: afterValid, scoreDiff });
6176
+ if (beforeValid && !afterValid) newFailures.push(id);
6177
+ if (!beforeValid && afterValid) resolved.push(id);
6178
+ }
6179
+ return {
6180
+ newFailures,
6181
+ resolved,
6182
+ taskDeltas,
6183
+ overallImproved: resolved.length > newFailures.length
6184
+ };
6185
+ },
6186
+ { name: "eval-delta" }
6187
+ );
6188
+ }
6189
+ function affectedTaskFilter(issues, fullTaskSet) {
6190
+ const taskSetNode = fullTaskSet == null ? null : Array.isArray(fullTaskSet) ? state(fullTaskSet) : fullTaskSet;
6191
+ const deps = [issues];
6192
+ if (taskSetNode) deps.push(taskSetNode);
6193
+ return derived(
6194
+ deps,
6195
+ (values) => {
6196
+ const items = values[0];
6197
+ const all = taskSetNode ? new Set(values[1]) : null;
6198
+ const affected = /* @__PURE__ */ new Set();
6199
+ for (const item of items) {
6200
+ for (const id of item.affectsEvalTasks ?? []) {
6201
+ if (all == null || all.has(id)) affected.add(id);
6202
+ }
6203
+ }
6204
+ return [...affected].sort();
6205
+ },
6206
+ { name: "affected-task-filter" }
6207
+ );
6208
+ }
6209
+ function codeChangeBridge(source, intakeTopic, parser, opts) {
6210
+ const defaultSeverity = opts?.defaultSeverity ?? "high";
6211
+ function defaultParser(change) {
6212
+ const items = [];
6213
+ for (const err of change.lintErrors ?? []) {
6214
+ items.push({
6215
+ source: "code-change",
6216
+ summary: `Lint: ${err.rule} in ${err.file}:${err.line}`,
6217
+ evidence: err.message,
6218
+ affectsAreas: [err.file],
6219
+ severity: defaultSeverity
6220
+ });
6221
+ }
6222
+ for (const fail of change.testFailures ?? []) {
6223
+ items.push({
6224
+ source: "test",
6225
+ summary: `Test failure: ${fail.testId}`,
6226
+ evidence: fail.message,
6227
+ affectsAreas: [fail.file],
6228
+ affectsEvalTasks: [fail.testId],
6229
+ severity: defaultSeverity
6230
+ });
6231
+ }
6232
+ return items;
6233
+ }
6234
+ const resolve = parser ?? defaultParser;
6235
+ return effect(
6236
+ [source],
6237
+ ([change]) => {
6238
+ if (change == null) return;
6239
+ for (const item of resolve(change)) {
6240
+ intakeTopic.publish(item);
6241
+ }
6242
+ },
6243
+ { name: opts?.name ?? "code-change-bridge" }
6244
+ );
6245
+ }
6246
+ function notifyEffect(topic2, transport, opts) {
6247
+ return effect(
6248
+ [topic2.latest],
6249
+ ([item]) => {
6250
+ if (item == null) return;
6251
+ void transport(item);
6252
+ },
6253
+ { name: opts?.name ?? "notify-effect" }
6254
+ );
6255
+ }
6098
6256
 
6099
6257
  // src/patterns/harness/types.ts
6100
6258
  var QUEUE_NAMES = [