@reinsjs/core 0.1.1 → 0.2.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/CHANGELOG.md +22 -0
- package/README.md +2 -2
- package/dist/{chunk-BOJD54XN.js → chunk-63AJKR7J.js} +34 -22
- package/dist/chunk-63AJKR7J.js.map +1 -0
- package/dist/index.d.ts +33 -7
- package/dist/index.js +109 -40
- package/dist/index.js.map +1 -1
- package/dist/testing/index.d.ts +9 -2
- package/dist/testing/index.js +209 -92
- package/dist/testing/index.js.map +1 -1
- package/dist/{types-BeGSiC1e.d.ts → types-DJB-13o3.d.ts} +58 -5
- package/package.json +5 -5
- package/dist/chunk-BOJD54XN.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -6,8 +6,9 @@ import {
|
|
|
6
6
|
createCoreEvent,
|
|
7
7
|
createCoreRegistry,
|
|
8
8
|
createEvent,
|
|
9
|
+
renderToolReference,
|
|
9
10
|
uuidv7
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-63AJKR7J.js";
|
|
11
12
|
|
|
12
13
|
// src/events/core.ts
|
|
13
14
|
function contextTokensOf(usage) {
|
|
@@ -138,7 +139,7 @@ function defaultSleep(ms, signal) {
|
|
|
138
139
|
function resolveRetry(opts = {}) {
|
|
139
140
|
const maxAttempts = opts.maxAttempts ?? DEFAULT_RETRY_MAX_ATTEMPTS;
|
|
140
141
|
if (!Number.isInteger(maxAttempts) || maxAttempts < 1) {
|
|
141
|
-
throw new RangeError(`retry.maxAttempts
|
|
142
|
+
throw new RangeError(`retry.maxAttempts must be an integer >= 1, got ${String(maxAttempts)}`);
|
|
142
143
|
}
|
|
143
144
|
return {
|
|
144
145
|
maxAttempts,
|
|
@@ -190,7 +191,11 @@ function estimateTextTokens(text) {
|
|
|
190
191
|
}
|
|
191
192
|
function partsTokens(parts) {
|
|
192
193
|
let n = 0;
|
|
193
|
-
for (const p of parts)
|
|
194
|
+
for (const p of parts) {
|
|
195
|
+
if (p.type === "text") n += estimateTextTokens(p.text);
|
|
196
|
+
else if (p.type === "tool_reference") n += estimateTextTokens(renderToolReference(p));
|
|
197
|
+
else n += IMAGE_TOKENS;
|
|
198
|
+
}
|
|
194
199
|
return n;
|
|
195
200
|
}
|
|
196
201
|
function safeJson(value) {
|
|
@@ -543,13 +548,13 @@ function project(opts) {
|
|
|
543
548
|
const cur = timeline[i];
|
|
544
549
|
if (prev && cur && cur.seq <= prev.seq) {
|
|
545
550
|
throw new RangeError(
|
|
546
|
-
|
|
551
|
+
`projection input must be strictly ascending by seq: seq ${cur.seq} at index ${i} is not greater than the previous ${prev.seq}`
|
|
547
552
|
);
|
|
548
553
|
}
|
|
549
554
|
}
|
|
550
555
|
const last = timeline[timeline.length - 1];
|
|
551
556
|
const sessionId = opts.sessionId ?? last?.sessionId;
|
|
552
|
-
if (sessionId === void 0) throw new RangeError("
|
|
557
|
+
if (sessionId === void 0) throw new RangeError("an empty timeline requires an explicit sessionId");
|
|
553
558
|
const reserveTokens = opts.budget.reserveTokens ?? Math.floor(opts.budget.contextLimit * DEFAULT_RESERVE_RATIO);
|
|
554
559
|
const budget = { contextLimit: opts.budget.contextLimit, reserveTokens };
|
|
555
560
|
const estimate = opts.estimate ?? roughTokenEstimate;
|
|
@@ -693,7 +698,7 @@ var RunStateError = class extends Error {
|
|
|
693
698
|
function assertRunStateShape(raw) {
|
|
694
699
|
const s = raw;
|
|
695
700
|
const ok = typeof s === "object" && s !== null && s.v === 1 && typeof s.sessionId === "string" && Number.isInteger(s.lastSeq) && Array.isArray(s.pendingToolCallIds) && s.pendingToolCallIds.every((id) => typeof id === "string") && typeof s.configHash === "string" && typeof s.pendingDigest === "string" && (s.sig === void 0 || typeof s.sig === "string");
|
|
696
|
-
if (!ok) throw new RunStateError("malformed", "run
|
|
701
|
+
if (!ok) throw new RunStateError("malformed", "run state is not in the v1 shape");
|
|
697
702
|
}
|
|
698
703
|
async function validateResume(input) {
|
|
699
704
|
const { state } = input;
|
|
@@ -701,7 +706,7 @@ async function validateResume(input) {
|
|
|
701
706
|
if (state.sessionId !== input.sessionId) {
|
|
702
707
|
throw new RunStateError(
|
|
703
708
|
"session_mismatch",
|
|
704
|
-
|
|
709
|
+
`state belongs to session ${state.sessionId}, but the current session is ${input.sessionId}`,
|
|
705
710
|
{
|
|
706
711
|
expected: input.sessionId,
|
|
707
712
|
got: state.sessionId
|
|
@@ -709,15 +714,22 @@ async function validateResume(input) {
|
|
|
709
714
|
);
|
|
710
715
|
}
|
|
711
716
|
if (input.secret !== void 0) {
|
|
712
|
-
if (state.sig === void 0)
|
|
717
|
+
if (state.sig === void 0)
|
|
718
|
+
throw new RunStateError(
|
|
719
|
+
"missing_signature",
|
|
720
|
+
"a secret is configured but the state carries no signature"
|
|
721
|
+
);
|
|
713
722
|
if (!await verifyRunState(state, input.secret)) {
|
|
714
|
-
throw new RunStateError(
|
|
723
|
+
throw new RunStateError(
|
|
724
|
+
"bad_signature",
|
|
725
|
+
"state signature mismatch: the contents were altered or the secret differs"
|
|
726
|
+
);
|
|
715
727
|
}
|
|
716
728
|
}
|
|
717
729
|
if (state.configHash !== input.configHash && !input.allowConfigDrift) {
|
|
718
730
|
throw new RunStateError(
|
|
719
731
|
"config_mismatch",
|
|
720
|
-
"
|
|
732
|
+
"model, tool set or system prompt differs from when the run paused; pass allowConfigDrift if this is intended",
|
|
721
733
|
{
|
|
722
734
|
expected: state.configHash,
|
|
723
735
|
got: input.configHash
|
|
@@ -726,15 +738,19 @@ async function validateResume(input) {
|
|
|
726
738
|
}
|
|
727
739
|
const lastSeq = input.timeline[input.timeline.length - 1]?.seq ?? 0;
|
|
728
740
|
if (lastSeq < state.lastSeq) {
|
|
729
|
-
throw new RunStateError(
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
741
|
+
throw new RunStateError(
|
|
742
|
+
"log_behind",
|
|
743
|
+
`the log only reaches seq ${lastSeq}, but the state records ${state.lastSeq}`,
|
|
744
|
+
{
|
|
745
|
+
logLastSeq: lastSeq,
|
|
746
|
+
stateLastSeq: state.lastSeq
|
|
747
|
+
}
|
|
748
|
+
);
|
|
733
749
|
}
|
|
734
750
|
const pending = pendingToolCalls(input.timeline);
|
|
735
751
|
const ids = pending.map((c) => c.payload.toolCallId);
|
|
736
752
|
if (JSON.stringify(ids) !== JSON.stringify(state.pendingToolCallIds) || await computePendingDigest(pending) !== state.pendingDigest) {
|
|
737
|
-
throw new RunStateError("pending_mismatch", "
|
|
753
|
+
throw new RunStateError("pending_mismatch", "pending tool calls in the log do not match the state", {
|
|
738
754
|
expected: state.pendingToolCallIds,
|
|
739
755
|
got: ids
|
|
740
756
|
});
|
|
@@ -796,11 +812,17 @@ function defineTool(tool) {
|
|
|
796
812
|
function toolSpecOf(tool) {
|
|
797
813
|
return { name: tool.name, description: tool.description, inputSchema: tool.inputSchema };
|
|
798
814
|
}
|
|
815
|
+
function deferredToolSpecOf(tool, deferred) {
|
|
816
|
+
return deferred ? { ...toolSpecOf(tool), deferLoading: true } : toolSpecOf(tool);
|
|
817
|
+
}
|
|
799
818
|
function isContentPart(x) {
|
|
800
819
|
if (typeof x !== "object" || x === null) return false;
|
|
801
820
|
const p = x;
|
|
802
821
|
if (p.type === "text") return typeof p.text === "string";
|
|
803
822
|
if (p.type === "image") return typeof p.mime === "string" && typeof p.data === "string";
|
|
823
|
+
if (p.type === "tool_reference") {
|
|
824
|
+
return typeof p.name === "string" && typeof p.description === "string" && typeof p.inputSchema === "object" && p.inputSchema !== null && !Array.isArray(p.inputSchema);
|
|
825
|
+
}
|
|
804
826
|
return false;
|
|
805
827
|
}
|
|
806
828
|
function isToolResult(x) {
|
|
@@ -876,7 +898,7 @@ function inputDraft(input) {
|
|
|
876
898
|
return { type: "core.user_message", actor: "user", payload: { content: input } };
|
|
877
899
|
if (typeof input.type !== "string" || !INPUT_DRAFT_TYPES.has(input.type) && !input.type.startsWith("ext.")) {
|
|
878
900
|
throw new RangeError(
|
|
879
|
-
`input
|
|
901
|
+
`input draft rejects event type ${String(input.type)}: only core.user_message, core.tool_result, core.system_note or ext.* are accepted`
|
|
880
902
|
);
|
|
881
903
|
}
|
|
882
904
|
return input;
|
|
@@ -955,9 +977,13 @@ async function* runLoop(cfg) {
|
|
|
955
977
|
const pendingIds = new Set(pendingToolCalls(timeline).map((c) => c.payload.toolCallId));
|
|
956
978
|
for (const d of decisions) {
|
|
957
979
|
if (!pendingIds.has(d.toolCallId)) {
|
|
958
|
-
throw new RunStateError(
|
|
959
|
-
|
|
960
|
-
|
|
980
|
+
throw new RunStateError(
|
|
981
|
+
"unknown_tool_call",
|
|
982
|
+
`approval decision refers to call ${d.toolCallId}, which is not pending`,
|
|
983
|
+
{
|
|
984
|
+
toolCallId: d.toolCallId
|
|
985
|
+
}
|
|
986
|
+
);
|
|
961
987
|
}
|
|
962
988
|
}
|
|
963
989
|
if (cfg.resume !== void 0) {
|
|
@@ -1040,7 +1066,9 @@ async function* runLoop(cfg) {
|
|
|
1040
1066
|
return events;
|
|
1041
1067
|
};
|
|
1042
1068
|
if (cfg.signal?.aborted) {
|
|
1043
|
-
const { events, result } = await pause("host", [
|
|
1069
|
+
const { events, result } = await pause("host", [
|
|
1070
|
+
{ kind: "host", note: "host aborted before this turn started" }
|
|
1071
|
+
]);
|
|
1044
1072
|
yield* events;
|
|
1045
1073
|
return result;
|
|
1046
1074
|
}
|
|
@@ -1066,7 +1094,7 @@ async function* runLoop(cfg) {
|
|
|
1066
1094
|
continue;
|
|
1067
1095
|
}
|
|
1068
1096
|
if (turns >= maxTurns) {
|
|
1069
|
-
const note =
|
|
1097
|
+
const note = `reached the per-run turn limit of ${maxTurns}`;
|
|
1070
1098
|
const { events, result } = await pause("budget", [{ kind: "budget", note }]);
|
|
1071
1099
|
yield* events;
|
|
1072
1100
|
return result;
|
|
@@ -1077,12 +1105,14 @@ async function* runLoop(cfg) {
|
|
|
1077
1105
|
let visible = ctx.events;
|
|
1078
1106
|
let tools = baseTools;
|
|
1079
1107
|
let systemPrompt = baseSystemPrompt;
|
|
1108
|
+
let deferredTools = /* @__PURE__ */ new Set();
|
|
1080
1109
|
for (const s of sockets) {
|
|
1081
1110
|
const patch = await s.beforeModel?.(ctx);
|
|
1082
1111
|
if (!patch) continue;
|
|
1083
1112
|
if (patch.events) visible = patch.events;
|
|
1084
1113
|
if (patch.tools) tools = patch.tools;
|
|
1085
1114
|
if (patch.systemPrompt !== void 0) systemPrompt = patch.systemPrompt;
|
|
1115
|
+
if (patch.deferredTools) deferredTools = new Set(patch.deferredTools);
|
|
1086
1116
|
ctx.events = visible;
|
|
1087
1117
|
ctx.tools = tools;
|
|
1088
1118
|
}
|
|
@@ -1099,7 +1129,7 @@ async function* runLoop(cfg) {
|
|
|
1099
1129
|
try {
|
|
1100
1130
|
const request = lowering.toRequest({
|
|
1101
1131
|
events: visible,
|
|
1102
|
-
tools: tools.map(
|
|
1132
|
+
tools: tools.map((t) => deferredToolSpecOf(t, deferredTools.has(t.name))),
|
|
1103
1133
|
model,
|
|
1104
1134
|
...systemPrompt !== void 0 ? { systemPrompt } : {}
|
|
1105
1135
|
});
|
|
@@ -1128,7 +1158,7 @@ async function* runLoop(cfg) {
|
|
|
1128
1158
|
ctx.budget.tokensSpent = tokensSpent;
|
|
1129
1159
|
ctx.budget.lastUsage = outcome.usage;
|
|
1130
1160
|
if (outcome.stopReason === "error")
|
|
1131
|
-
failure = { kind: "outcome", message: outcome.errorMessage ?? "
|
|
1161
|
+
failure = { kind: "outcome", message: outcome.errorMessage ?? "model response failed" };
|
|
1132
1162
|
}
|
|
1133
1163
|
ctx.budget.wallMs = now() - startedAt;
|
|
1134
1164
|
if (!failure) break;
|
|
@@ -1171,16 +1201,21 @@ async function* runLoop(cfg) {
|
|
|
1171
1201
|
outcome = void 0;
|
|
1172
1202
|
await retry.sleep(delayMs, cfg.signal);
|
|
1173
1203
|
if (cfg.signal?.aborted) {
|
|
1174
|
-
const { events, result } = await pause("host", [
|
|
1204
|
+
const { events, result } = await pause("host", [
|
|
1205
|
+
{ kind: "host", note: "host aborted while waiting to retry" }
|
|
1206
|
+
]);
|
|
1175
1207
|
yield* events;
|
|
1176
1208
|
return result;
|
|
1177
1209
|
}
|
|
1178
1210
|
}
|
|
1179
|
-
if (!outcome)
|
|
1211
|
+
if (!outcome)
|
|
1212
|
+
throw new Error("runLoop internal error: the model call produced neither an outcome nor a failure");
|
|
1180
1213
|
for (const s of sockets) await s.afterModel?.(ctx, modelEvents);
|
|
1181
1214
|
yield* await flush();
|
|
1182
1215
|
if (outcome.stopReason === "aborted") {
|
|
1183
|
-
const { events, result } = await pause("host", [
|
|
1216
|
+
const { events, result } = await pause("host", [
|
|
1217
|
+
{ kind: "host", note: "host aborted the model response" }
|
|
1218
|
+
]);
|
|
1184
1219
|
yield* events;
|
|
1185
1220
|
return result;
|
|
1186
1221
|
}
|
|
@@ -1232,7 +1267,7 @@ async function* runLoop(cfg) {
|
|
|
1232
1267
|
if (decision === "continue") return void 0;
|
|
1233
1268
|
if (decision === "stop") return { status: "done", sessionId, lastSeq };
|
|
1234
1269
|
if ("pause" in decision) {
|
|
1235
|
-
const note = decision.pause.note ?? `
|
|
1270
|
+
const note = decision.pause.note ?? `a socket requested a pause (${decision.pause.reason})`;
|
|
1236
1271
|
const kind = decision.pause.reason;
|
|
1237
1272
|
const { events, result } = await pause(kind, [{ kind, note }]);
|
|
1238
1273
|
yield* events;
|
|
@@ -1323,7 +1358,7 @@ async function* executeToolCalls(ctx, calls, timeline, deps) {
|
|
|
1323
1358
|
});
|
|
1324
1359
|
const decided = decisions.get(toolCallId);
|
|
1325
1360
|
if (decided && !decided.approved) {
|
|
1326
|
-
yield* await append([errorResult(
|
|
1361
|
+
yield* await append([errorResult(`Approval denied${decided.reason ? `: ${decided.reason}` : ""}`)]);
|
|
1327
1362
|
continue;
|
|
1328
1363
|
}
|
|
1329
1364
|
let args = call.payload.args;
|
|
@@ -1342,17 +1377,17 @@ async function* executeToolCalls(ctx, calls, timeline, deps) {
|
|
|
1342
1377
|
break;
|
|
1343
1378
|
}
|
|
1344
1379
|
if (typeof verdict === "object" && "block" in verdict) {
|
|
1345
|
-
yield* await settle(errorResult(
|
|
1380
|
+
yield* await settle(errorResult(`Tool call blocked: ${verdict.block}`));
|
|
1346
1381
|
continue;
|
|
1347
1382
|
}
|
|
1348
1383
|
if (!tool) {
|
|
1349
|
-
yield* await settle(errorResult(
|
|
1384
|
+
yield* await settle(errorResult(`Unknown tool: ${name}`));
|
|
1350
1385
|
continue;
|
|
1351
1386
|
}
|
|
1352
1387
|
try {
|
|
1353
1388
|
if (tool.validate) args = tool.validate(args);
|
|
1354
1389
|
} catch (err) {
|
|
1355
|
-
yield* await settle(errorResult(
|
|
1390
|
+
yield* await settle(errorResult(`Invalid arguments: ${errorMessageOf(err)}`));
|
|
1356
1391
|
continue;
|
|
1357
1392
|
}
|
|
1358
1393
|
const toolCtx = {
|
|
@@ -1411,7 +1446,7 @@ async function* executeToolCalls(ctx, calls, timeline, deps) {
|
|
|
1411
1446
|
payload: { toolCallId, name, content: normalized.content, isError: normalized.isError ?? false }
|
|
1412
1447
|
};
|
|
1413
1448
|
} catch (err) {
|
|
1414
|
-
result = errorResult(
|
|
1449
|
+
result = errorResult(`Tool execution failed: ${errorMessageOf(err)}`);
|
|
1415
1450
|
}
|
|
1416
1451
|
for (const s of sockets) {
|
|
1417
1452
|
const replaced = await s.afterTool?.(ctx, call, result);
|
|
@@ -1543,19 +1578,19 @@ var StoreError = class extends Error {
|
|
|
1543
1578
|
var InMemoryEventLog = class {
|
|
1544
1579
|
sessions = /* @__PURE__ */ new Map();
|
|
1545
1580
|
async append(events) {
|
|
1546
|
-
if (events.length === 0) throw new StoreError("empty_batch", "append
|
|
1581
|
+
if (events.length === 0) throw new StoreError("empty_batch", "append received an empty event array");
|
|
1547
1582
|
const sessionId = events[0].sessionId;
|
|
1548
1583
|
const existing = this.sessions.get(sessionId) ?? [];
|
|
1549
1584
|
let expected = existing.length + 1;
|
|
1550
1585
|
for (const e of events) {
|
|
1551
1586
|
if (e.sessionId !== sessionId) {
|
|
1552
|
-
throw new StoreError("session_mismatch", "
|
|
1587
|
+
throw new StoreError("session_mismatch", "all events in one append must belong to the same session", {
|
|
1553
1588
|
expected: sessionId,
|
|
1554
1589
|
got: e.sessionId
|
|
1555
1590
|
});
|
|
1556
1591
|
}
|
|
1557
1592
|
if (e.seq !== expected) {
|
|
1558
|
-
throw new StoreError("seq_conflict",
|
|
1593
|
+
throw new StoreError("seq_conflict", `session ${sessionId} expected seq=${expected}, got ${e.seq}`, {
|
|
1559
1594
|
sessionId,
|
|
1560
1595
|
expected,
|
|
1561
1596
|
got: e.seq
|
|
@@ -1577,7 +1612,7 @@ var InMemoryEventLog = class {
|
|
|
1577
1612
|
}
|
|
1578
1613
|
async tail(sessionId, n) {
|
|
1579
1614
|
if (!Number.isInteger(n) || n < 0)
|
|
1580
|
-
throw new StoreError("invalid_argument", `tail
|
|
1615
|
+
throw new StoreError("invalid_argument", `tail: n must be a non-negative integer, got ${n}`);
|
|
1581
1616
|
const events = this.sessions.get(sessionId) ?? [];
|
|
1582
1617
|
return events.slice(Math.max(0, events.length - n)).map((e) => structuredClone(e));
|
|
1583
1618
|
}
|
|
@@ -1586,7 +1621,7 @@ var InMemoryEventLog = class {
|
|
|
1586
1621
|
if (!Number.isInteger(atSeq) || atSeq < 1 || atSeq > source.length) {
|
|
1587
1622
|
throw new StoreError(
|
|
1588
1623
|
"out_of_range",
|
|
1589
|
-
`fork
|
|
1624
|
+
`fork point ${atSeq} is outside session ${fromSessionId}'s range [1, ${source.length}]`,
|
|
1590
1625
|
{
|
|
1591
1626
|
fromSessionId,
|
|
1592
1627
|
atSeq,
|
|
@@ -1595,7 +1630,9 @@ var InMemoryEventLog = class {
|
|
|
1595
1630
|
);
|
|
1596
1631
|
}
|
|
1597
1632
|
if ((this.sessions.get(toSessionId)?.length ?? 0) > 0) {
|
|
1598
|
-
throw new StoreError("target_not_empty",
|
|
1633
|
+
throw new StoreError("target_not_empty", `target session ${toSessionId} already has events`, {
|
|
1634
|
+
toSessionId
|
|
1635
|
+
});
|
|
1599
1636
|
}
|
|
1600
1637
|
this.sessions.set(
|
|
1601
1638
|
toSessionId,
|
|
@@ -1616,7 +1653,7 @@ var InMemoryBlobStore = class {
|
|
|
1616
1653
|
}
|
|
1617
1654
|
async get(id) {
|
|
1618
1655
|
const hit = this.blobs.get(id);
|
|
1619
|
-
if (!hit) throw new StoreError("not_found", `blob
|
|
1656
|
+
if (!hit) throw new StoreError("not_found", `blob not found: ${id}`, { id });
|
|
1620
1657
|
return { bytes: hit.bytes.slice(), meta: { ...hit.meta } };
|
|
1621
1658
|
}
|
|
1622
1659
|
async slice(id, range) {
|
|
@@ -1639,12 +1676,40 @@ var InMemoryMemoryStore = class {
|
|
|
1639
1676
|
this.files.delete(path);
|
|
1640
1677
|
}
|
|
1641
1678
|
};
|
|
1679
|
+
var InMemoryRunLease = class {
|
|
1680
|
+
leases = /* @__PURE__ */ new Map();
|
|
1681
|
+
now;
|
|
1682
|
+
constructor(opts = {}) {
|
|
1683
|
+
this.now = opts.now ?? (() => Date.now());
|
|
1684
|
+
}
|
|
1685
|
+
async acquire(sessionId, owner, ttlMs) {
|
|
1686
|
+
const now = this.now();
|
|
1687
|
+
const held = this.leases.get(sessionId);
|
|
1688
|
+
if (held !== void 0 && held.expiresAt >= now && held.owner !== owner) return false;
|
|
1689
|
+
this.leases.set(sessionId, { owner, expiresAt: now + ttlMs });
|
|
1690
|
+
return true;
|
|
1691
|
+
}
|
|
1692
|
+
async renew(sessionId, owner, ttlMs) {
|
|
1693
|
+
const now = this.now();
|
|
1694
|
+
const held = this.leases.get(sessionId);
|
|
1695
|
+
if (held === void 0 || held.owner !== owner || held.expiresAt < now) return false;
|
|
1696
|
+
held.expiresAt = now + ttlMs;
|
|
1697
|
+
return true;
|
|
1698
|
+
}
|
|
1699
|
+
async release(sessionId, owner) {
|
|
1700
|
+
if (this.leases.get(sessionId)?.owner === owner) this.leases.delete(sessionId);
|
|
1701
|
+
}
|
|
1702
|
+
/** 测试观察用:当前持有者(不看是否过期) */
|
|
1703
|
+
holderOf(sessionId) {
|
|
1704
|
+
return this.leases.get(sessionId)?.owner;
|
|
1705
|
+
}
|
|
1706
|
+
};
|
|
1642
1707
|
function memoryStore() {
|
|
1643
1708
|
return { log: new InMemoryEventLog(), blobs: new InMemoryBlobStore(), memory: new InMemoryMemoryStore() };
|
|
1644
1709
|
}
|
|
1645
1710
|
|
|
1646
1711
|
// src/index.ts
|
|
1647
|
-
var REINS_VERSION = "0.
|
|
1712
|
+
var REINS_VERSION = "0.2.0";
|
|
1648
1713
|
export {
|
|
1649
1714
|
BUILTIN_APPROVAL_POLICY,
|
|
1650
1715
|
CORE_SCHEMAS,
|
|
@@ -1660,6 +1725,7 @@ export {
|
|
|
1660
1725
|
InMemoryBlobStore,
|
|
1661
1726
|
InMemoryEventLog,
|
|
1662
1727
|
InMemoryMemoryStore,
|
|
1728
|
+
InMemoryRunLease,
|
|
1663
1729
|
LoweringError,
|
|
1664
1730
|
REINS_VERSION,
|
|
1665
1731
|
RunStateError,
|
|
@@ -1680,6 +1746,7 @@ export {
|
|
|
1680
1746
|
defaultProjectionChain,
|
|
1681
1747
|
defaultSleep,
|
|
1682
1748
|
defaultThresholdSummary,
|
|
1749
|
+
deferredToolSpecOf,
|
|
1683
1750
|
defineTool,
|
|
1684
1751
|
diffToolNames,
|
|
1685
1752
|
digestArgs,
|
|
@@ -1692,6 +1759,7 @@ export {
|
|
|
1692
1759
|
forkSession,
|
|
1693
1760
|
inputDraft,
|
|
1694
1761
|
isCompaction,
|
|
1762
|
+
isContentPart,
|
|
1695
1763
|
isModelOutput,
|
|
1696
1764
|
isPinNote,
|
|
1697
1765
|
isSubagentPause,
|
|
@@ -1711,6 +1779,7 @@ export {
|
|
|
1711
1779
|
reinjectPins,
|
|
1712
1780
|
renderFoldedToolResults,
|
|
1713
1781
|
renderToolChangeNote,
|
|
1782
|
+
renderToolReference,
|
|
1714
1783
|
replayTurns,
|
|
1715
1784
|
resolveRetry,
|
|
1716
1785
|
resolveSocketContributions,
|