@graphrefly/graphrefly 0.11.0 → 0.12.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.
- package/dist/{chunk-UG2QZMRN.js → chunk-4F2ZFD5L.js} +2 -1
- package/dist/{chunk-OHUECHWY.js → chunk-6OLNYOGU.js} +2 -2
- package/dist/{chunk-2VHNCFGG.js → chunk-BRPCN2HJ.js} +46 -17
- package/dist/chunk-BRPCN2HJ.js.map +1 -0
- package/dist/{chunk-U5HFZGAQ.js → chunk-IXTW3BIO.js} +3 -3
- package/dist/{chunk-3WACHRHV.js → chunk-JYRHO63K.js} +3 -3
- package/dist/{chunk-PZCDQD2U.js → chunk-NULSP7U4.js} +4 -4
- package/dist/{chunk-2OTXEZQO.js → chunk-VQWLA6XQ.js} +3 -3
- package/dist/{chunk-5WXTWOD7.js → chunk-X732W3QA.js} +2 -2
- package/dist/{chunk-FMVFRP7L.js → chunk-XWMTVV2D.js} +3 -3
- package/dist/compat/nestjs/index.js +7 -7
- package/dist/core/index.js +3 -3
- package/dist/extra/index.cjs +42 -14
- package/dist/extra/index.cjs.map +1 -1
- package/dist/extra/index.d.cts +1 -1
- package/dist/extra/index.d.ts +1 -1
- package/dist/extra/index.js +5 -5
- package/dist/graph/index.js +4 -4
- package/dist/{index-Bbgvinsi.d.ts → index-CiAqgfFg.d.ts} +14 -10
- package/dist/{index-DpZozxaJ.d.cts → index-CthwPnHQ.d.cts} +14 -10
- package/dist/index.cjs +230 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +75 -5
- package/dist/index.d.ts +75 -5
- package/dist/index.js +198 -14
- package/dist/index.js.map +1 -1
- package/dist/patterns/reactive-layout/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-2VHNCFGG.js.map +0 -1
- /package/dist/{chunk-UG2QZMRN.js.map → chunk-4F2ZFD5L.js.map} +0 -0
- /package/dist/{chunk-OHUECHWY.js.map → chunk-6OLNYOGU.js.map} +0 -0
- /package/dist/{chunk-U5HFZGAQ.js.map → chunk-IXTW3BIO.js.map} +0 -0
- /package/dist/{chunk-3WACHRHV.js.map → chunk-JYRHO63K.js.map} +0 -0
- /package/dist/{chunk-PZCDQD2U.js.map → chunk-NULSP7U4.js.map} +0 -0
- /package/dist/{chunk-2OTXEZQO.js.map → chunk-VQWLA6XQ.js.map} +0 -0
- /package/dist/{chunk-5WXTWOD7.js.map → chunk-X732W3QA.js.map} +0 -0
- /package/dist/{chunk-FMVFRP7L.js.map → chunk-XWMTVV2D.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -64,7 +64,6 @@ import {
|
|
|
64
64
|
fromSyslog,
|
|
65
65
|
fromWebSocket,
|
|
66
66
|
fromWebhook,
|
|
67
|
-
gate,
|
|
68
67
|
interval,
|
|
69
68
|
last,
|
|
70
69
|
linear,
|
|
@@ -126,6 +125,7 @@ import {
|
|
|
126
125
|
toWebSocket,
|
|
127
126
|
tokenBucket,
|
|
128
127
|
tokenTracker,
|
|
128
|
+
valve,
|
|
129
129
|
verifiable,
|
|
130
130
|
window,
|
|
131
131
|
windowCount,
|
|
@@ -137,16 +137,16 @@ import {
|
|
|
137
137
|
workerBridge,
|
|
138
138
|
workerSelf,
|
|
139
139
|
zip
|
|
140
|
-
} from "./chunk-
|
|
140
|
+
} from "./chunk-BRPCN2HJ.js";
|
|
141
141
|
import {
|
|
142
142
|
cqrs_exports,
|
|
143
143
|
nestjs_exports
|
|
144
|
-
} from "./chunk-
|
|
144
|
+
} from "./chunk-NULSP7U4.js";
|
|
145
145
|
import {
|
|
146
146
|
DEFAULT_DOWN,
|
|
147
147
|
bridge,
|
|
148
148
|
core_exports
|
|
149
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-XWMTVV2D.js";
|
|
150
150
|
import {
|
|
151
151
|
JsonCodec,
|
|
152
152
|
createDagCborCodec,
|
|
@@ -154,7 +154,7 @@ import {
|
|
|
154
154
|
graph_exports,
|
|
155
155
|
negotiateCodec,
|
|
156
156
|
replayWAL
|
|
157
|
-
} from "./chunk-
|
|
157
|
+
} from "./chunk-IXTW3BIO.js";
|
|
158
158
|
import {
|
|
159
159
|
cached,
|
|
160
160
|
createWatermarkController,
|
|
@@ -187,7 +187,7 @@ import {
|
|
|
187
187
|
toArray,
|
|
188
188
|
toMessages$,
|
|
189
189
|
toObservable
|
|
190
|
-
} from "./chunk-
|
|
190
|
+
} from "./chunk-X732W3QA.js";
|
|
191
191
|
import {
|
|
192
192
|
ResettableTimer
|
|
193
193
|
} from "./chunk-WZ2Z2CRV.js";
|
|
@@ -195,17 +195,17 @@ import {
|
|
|
195
195
|
analyzeAndMeasure,
|
|
196
196
|
computeLineBreaks,
|
|
197
197
|
reactive_layout_exports
|
|
198
|
-
} from "./chunk-
|
|
198
|
+
} from "./chunk-JYRHO63K.js";
|
|
199
199
|
import {
|
|
200
200
|
GRAPH_META_SEGMENT,
|
|
201
201
|
Graph,
|
|
202
202
|
reachable
|
|
203
|
-
} from "./chunk-
|
|
203
|
+
} from "./chunk-VQWLA6XQ.js";
|
|
204
204
|
import {
|
|
205
205
|
describeNode,
|
|
206
206
|
metaSnapshot,
|
|
207
207
|
resolveDescribeFields
|
|
208
|
-
} from "./chunk-
|
|
208
|
+
} from "./chunk-6OLNYOGU.js";
|
|
209
209
|
import {
|
|
210
210
|
CLEANUP_RESULT,
|
|
211
211
|
COMPLETE,
|
|
@@ -249,7 +249,7 @@ import {
|
|
|
249
249
|
propagatesToMeta,
|
|
250
250
|
state,
|
|
251
251
|
wallClockNs
|
|
252
|
-
} from "./chunk-
|
|
252
|
+
} from "./chunk-4F2ZFD5L.js";
|
|
253
253
|
|
|
254
254
|
// src/compat/index.ts
|
|
255
255
|
var compat_exports = {};
|
|
@@ -1075,6 +1075,7 @@ __export(ai_exports, {
|
|
|
1075
1075
|
knobsAsTools: () => knobsAsTools,
|
|
1076
1076
|
llmConsolidator: () => llmConsolidator,
|
|
1077
1077
|
llmExtractor: () => llmExtractor,
|
|
1078
|
+
promptNode: () => promptNode,
|
|
1078
1079
|
suggestStrategy: () => suggestStrategy,
|
|
1079
1080
|
systemPromptBuilder: () => systemPromptBuilder,
|
|
1080
1081
|
toolRegistry: () => toolRegistry,
|
|
@@ -1590,6 +1591,75 @@ function fromLLMStream(adapter, messages, opts) {
|
|
|
1590
1591
|
}
|
|
1591
1592
|
};
|
|
1592
1593
|
}
|
|
1594
|
+
function extractContent(resp) {
|
|
1595
|
+
if (resp != null && typeof resp === "object" && "content" in resp) {
|
|
1596
|
+
return String(resp.content);
|
|
1597
|
+
}
|
|
1598
|
+
if (typeof resp === "string") return resp;
|
|
1599
|
+
return String(resp);
|
|
1600
|
+
}
|
|
1601
|
+
function promptNode(adapter, deps, prompt, opts) {
|
|
1602
|
+
const format = opts?.format ?? "text";
|
|
1603
|
+
const retries = opts?.retries ?? 0;
|
|
1604
|
+
const useCache = opts?.cache ?? false;
|
|
1605
|
+
const cache2 = useCache ? /* @__PURE__ */ new Map() : null;
|
|
1606
|
+
const messagesNode = derived(
|
|
1607
|
+
deps,
|
|
1608
|
+
(values) => {
|
|
1609
|
+
const text = typeof prompt === "string" ? prompt : prompt(...values);
|
|
1610
|
+
const msgs = [];
|
|
1611
|
+
if (opts?.systemPrompt) msgs.push({ role: "system", content: opts.systemPrompt });
|
|
1612
|
+
msgs.push({ role: "user", content: text });
|
|
1613
|
+
return msgs;
|
|
1614
|
+
},
|
|
1615
|
+
{
|
|
1616
|
+
name: opts?.name ? `${opts.name}::messages` : "prompt_node::messages",
|
|
1617
|
+
meta: aiMeta("prompt_node")
|
|
1618
|
+
}
|
|
1619
|
+
);
|
|
1620
|
+
const result = switchMap(messagesNode, (msgs) => {
|
|
1621
|
+
if (!msgs || msgs.length === 0) {
|
|
1622
|
+
return state(null);
|
|
1623
|
+
}
|
|
1624
|
+
const cacheKey = useCache ? JSON.stringify(msgs.map((m) => [m.role, m.content])) : "";
|
|
1625
|
+
if (cache2?.has(cacheKey)) {
|
|
1626
|
+
return state(cache2.get(cacheKey));
|
|
1627
|
+
}
|
|
1628
|
+
async function attempt(remaining) {
|
|
1629
|
+
try {
|
|
1630
|
+
const resp = await new Promise((resolve, reject) => {
|
|
1631
|
+
const input = adapter.invoke(msgs, {
|
|
1632
|
+
model: opts?.model,
|
|
1633
|
+
temperature: opts?.temperature,
|
|
1634
|
+
maxTokens: opts?.maxTokens,
|
|
1635
|
+
systemPrompt: opts?.systemPrompt
|
|
1636
|
+
});
|
|
1637
|
+
if (input && typeof input.then === "function") {
|
|
1638
|
+
input.then(resolve, reject);
|
|
1639
|
+
} else if (input && typeof input.get === "function") {
|
|
1640
|
+
resolve(input.get());
|
|
1641
|
+
} else {
|
|
1642
|
+
resolve(input);
|
|
1643
|
+
}
|
|
1644
|
+
});
|
|
1645
|
+
const content = extractContent(resp);
|
|
1646
|
+
let parsed;
|
|
1647
|
+
if (format === "json") {
|
|
1648
|
+
parsed = JSON.parse(stripFences(content));
|
|
1649
|
+
} else {
|
|
1650
|
+
parsed = content;
|
|
1651
|
+
}
|
|
1652
|
+
cache2?.set(cacheKey, parsed);
|
|
1653
|
+
return parsed;
|
|
1654
|
+
} catch (err) {
|
|
1655
|
+
if (remaining > 0) return attempt(remaining - 1);
|
|
1656
|
+
throw err;
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
return attempt(retries);
|
|
1660
|
+
});
|
|
1661
|
+
return result;
|
|
1662
|
+
}
|
|
1593
1663
|
var ChatStreamGraph = class extends Graph {
|
|
1594
1664
|
_log;
|
|
1595
1665
|
_keepaliveSubs = [];
|
|
@@ -5229,7 +5299,7 @@ __export(orchestration_exports, {
|
|
|
5229
5299
|
approval: () => approval,
|
|
5230
5300
|
branch: () => branch,
|
|
5231
5301
|
forEach: () => forEach2,
|
|
5232
|
-
gate: () =>
|
|
5302
|
+
gate: () => gate,
|
|
5233
5303
|
join: () => join,
|
|
5234
5304
|
loop: () => loop,
|
|
5235
5305
|
onFailure: () => onFailure,
|
|
@@ -5237,6 +5307,7 @@ __export(orchestration_exports, {
|
|
|
5237
5307
|
sensor: () => sensor,
|
|
5238
5308
|
subPipeline: () => subPipeline,
|
|
5239
5309
|
task: () => task,
|
|
5310
|
+
valve: () => valve2,
|
|
5240
5311
|
wait: () => wait
|
|
5241
5312
|
});
|
|
5242
5313
|
function resolveDep(graph, dep) {
|
|
@@ -5336,7 +5407,7 @@ function branch(graph, name, source, predicate, opts) {
|
|
|
5336
5407
|
registerStep(graph, name, step, src.path ? [src.path] : []);
|
|
5337
5408
|
return step;
|
|
5338
5409
|
}
|
|
5339
|
-
function
|
|
5410
|
+
function valve2(graph, name, source, control, opts) {
|
|
5340
5411
|
const src = resolveDep(graph, source);
|
|
5341
5412
|
const ctrl = resolveDep(graph, control);
|
|
5342
5413
|
const step = node(
|
|
@@ -5353,7 +5424,7 @@ function gate2(graph, name, source, control, opts) {
|
|
|
5353
5424
|
...opts,
|
|
5354
5425
|
name,
|
|
5355
5426
|
describeKind: "operator",
|
|
5356
|
-
meta: baseMeta3("
|
|
5427
|
+
meta: baseMeta3("valve", opts?.meta)
|
|
5357
5428
|
}
|
|
5358
5429
|
);
|
|
5359
5430
|
registerStep(
|
|
@@ -5392,6 +5463,119 @@ function approval(graph, name, source, approver, opts) {
|
|
|
5392
5463
|
);
|
|
5393
5464
|
return step;
|
|
5394
5465
|
}
|
|
5466
|
+
function gate(graph, name, source, opts) {
|
|
5467
|
+
const maxPending = opts?.maxPending ?? Infinity;
|
|
5468
|
+
if (maxPending < 1 && maxPending !== Infinity) {
|
|
5469
|
+
throw new RangeError("gate: maxPending must be >= 1");
|
|
5470
|
+
}
|
|
5471
|
+
const startOpen = opts?.startOpen ?? false;
|
|
5472
|
+
const src = resolveDep(graph, source);
|
|
5473
|
+
const pendingNode = state([], { name: "pending", equals: () => false });
|
|
5474
|
+
const isOpenNode = state(startOpen, { name: "isOpen" });
|
|
5475
|
+
const countNode = node([pendingNode], ([arr]) => arr.length, {
|
|
5476
|
+
name: "count",
|
|
5477
|
+
describeKind: "derived"
|
|
5478
|
+
});
|
|
5479
|
+
let queue = [];
|
|
5480
|
+
let torn = false;
|
|
5481
|
+
function syncPending() {
|
|
5482
|
+
pendingNode.down([[DATA, [...queue]]]);
|
|
5483
|
+
}
|
|
5484
|
+
function enqueue(value) {
|
|
5485
|
+
queue.push(value);
|
|
5486
|
+
if (queue.length > maxPending) queue.shift();
|
|
5487
|
+
syncPending();
|
|
5488
|
+
}
|
|
5489
|
+
function dequeue(n) {
|
|
5490
|
+
const items = queue.splice(0, n);
|
|
5491
|
+
syncPending();
|
|
5492
|
+
return items;
|
|
5493
|
+
}
|
|
5494
|
+
function guardTorn(method) {
|
|
5495
|
+
if (torn) throw new Error(`gate: ${method}() called after gate was torn down`);
|
|
5496
|
+
}
|
|
5497
|
+
const output = node([src.node], () => void 0, {
|
|
5498
|
+
name,
|
|
5499
|
+
describeKind: "operator",
|
|
5500
|
+
meta: baseMeta3("gate", opts?.meta),
|
|
5501
|
+
onMessage(msg, _depIndex, actions) {
|
|
5502
|
+
if (msg[0] === DATA) {
|
|
5503
|
+
if (isOpenNode.get()) {
|
|
5504
|
+
actions.emit(msg[1]);
|
|
5505
|
+
} else {
|
|
5506
|
+
enqueue(msg[1]);
|
|
5507
|
+
actions.down([[RESOLVED]]);
|
|
5508
|
+
}
|
|
5509
|
+
return true;
|
|
5510
|
+
}
|
|
5511
|
+
if (msg[0] === TEARDOWN) {
|
|
5512
|
+
torn = true;
|
|
5513
|
+
queue = [];
|
|
5514
|
+
syncPending();
|
|
5515
|
+
actions.down([msg]);
|
|
5516
|
+
return true;
|
|
5517
|
+
}
|
|
5518
|
+
if (msg[0] === COMPLETE || msg[0] === ERROR) {
|
|
5519
|
+
torn = true;
|
|
5520
|
+
queue = [];
|
|
5521
|
+
syncPending();
|
|
5522
|
+
actions.down([msg]);
|
|
5523
|
+
return true;
|
|
5524
|
+
}
|
|
5525
|
+
actions.down([msg]);
|
|
5526
|
+
return true;
|
|
5527
|
+
}
|
|
5528
|
+
});
|
|
5529
|
+
const controller = {
|
|
5530
|
+
node: output,
|
|
5531
|
+
pending: pendingNode,
|
|
5532
|
+
count: countNode,
|
|
5533
|
+
isOpen: isOpenNode,
|
|
5534
|
+
approve(count = 1) {
|
|
5535
|
+
guardTorn("approve");
|
|
5536
|
+
const items = dequeue(count);
|
|
5537
|
+
for (const item of items) {
|
|
5538
|
+
if (torn) break;
|
|
5539
|
+
output.down([[DATA, item]]);
|
|
5540
|
+
}
|
|
5541
|
+
},
|
|
5542
|
+
reject(count = 1) {
|
|
5543
|
+
guardTorn("reject");
|
|
5544
|
+
dequeue(count);
|
|
5545
|
+
},
|
|
5546
|
+
modify(fn, count = 1) {
|
|
5547
|
+
guardTorn("modify");
|
|
5548
|
+
const snapshot = [...queue];
|
|
5549
|
+
const items = dequeue(count);
|
|
5550
|
+
for (let i = 0; i < items.length; i++) {
|
|
5551
|
+
if (torn) break;
|
|
5552
|
+
output.down([[DATA, fn(items[i], i, snapshot)]]);
|
|
5553
|
+
}
|
|
5554
|
+
},
|
|
5555
|
+
open() {
|
|
5556
|
+
guardTorn("open");
|
|
5557
|
+
isOpenNode.down([[DATA, true]]);
|
|
5558
|
+
const items = dequeue(queue.length);
|
|
5559
|
+
for (const item of items) {
|
|
5560
|
+
if (torn) break;
|
|
5561
|
+
output.down([[DATA, item]]);
|
|
5562
|
+
}
|
|
5563
|
+
},
|
|
5564
|
+
close() {
|
|
5565
|
+
guardTorn("close");
|
|
5566
|
+
isOpenNode.down([[DATA, false]]);
|
|
5567
|
+
}
|
|
5568
|
+
};
|
|
5569
|
+
countNode.subscribe(() => void 0);
|
|
5570
|
+
registerStep(graph, name, output, src.path ? [src.path] : []);
|
|
5571
|
+
const internal = new Graph(`${name}_state`);
|
|
5572
|
+
internal.add("pending", pendingNode);
|
|
5573
|
+
internal.add("isOpen", isOpenNode);
|
|
5574
|
+
internal.add("count", countNode);
|
|
5575
|
+
internal.connect("pending", "count");
|
|
5576
|
+
graph.mount(`${name}_state`, internal);
|
|
5577
|
+
return controller;
|
|
5578
|
+
}
|
|
5395
5579
|
function forEach2(graph, name, source, run, opts) {
|
|
5396
5580
|
const src = resolveDep(graph, source);
|
|
5397
5581
|
let terminated = false;
|
|
@@ -5720,7 +5904,6 @@ export {
|
|
|
5720
5904
|
fromTimer,
|
|
5721
5905
|
fromWebSocket,
|
|
5722
5906
|
fromWebhook,
|
|
5723
|
-
gate,
|
|
5724
5907
|
globToRegExp,
|
|
5725
5908
|
graph_exports as graph,
|
|
5726
5909
|
graphspec_exports as graphspec,
|
|
@@ -5836,6 +6019,7 @@ export {
|
|
|
5836
6019
|
toWebSocket,
|
|
5837
6020
|
tokenBucket,
|
|
5838
6021
|
tokenTracker,
|
|
6022
|
+
valve,
|
|
5839
6023
|
verifiable,
|
|
5840
6024
|
version,
|
|
5841
6025
|
vue_exports as vue,
|