@orkestrel/agent 0.0.31 → 0.0.33
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/src/core/index.cjs +298 -209
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +119 -76
- package/dist/src/core/index.d.ts +119 -76
- package/dist/src/core/index.js +297 -210
- package/dist/src/core/index.js.map +1 -1
- package/package.json +28 -27
package/dist/src/core/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContractError, arrayOf, arrayShape, attempt, booleanShape, boundsOf, canonicalStringify, cloneJSONValue, createContract, isArray, isBoolean, isError, isFiniteNumber,
|
|
1
|
+
import { ContractError, INTRINSICS, arrayOf, arrayShape, attempt, booleanShape, boundsOf, canonicalStringify, cloneJSONValue, createContract, holds, isArray, isBoolean, isError, isFiniteNumber, isFunction, isJSONValue, isNumber, isObject, isRecord, isString, jsonShape, literalShape, nullableOf, numberShape, objectOf, objectShape, optionalOf, optionalShape, parseJSON, parseJSONAs, parseJSONValue, preview, rawShape, recordOf, recordShape, stringShape, unionShape } from "@orkestrel/contract";
|
|
2
2
|
import { createTokenBudget, createTokenMeter, isBudget, isBudgetError, isTokenUsage } from "@orkestrel/budget";
|
|
3
3
|
import { Timeout, createTimeout } from "@orkestrel/timeout";
|
|
4
4
|
import { createDatabase, createMemoryDriver } from "@orkestrel/database";
|
|
@@ -8,7 +8,7 @@ import { WorkspaceManager, isBinary, isText } from "@orkestrel/workspace";
|
|
|
8
8
|
import { createQueue } from "@orkestrel/queue";
|
|
9
9
|
import { createRunner, errorToMessage } from "@orkestrel/workflow";
|
|
10
10
|
import { createAbort } from "@orkestrel/abort";
|
|
11
|
-
|
|
11
|
+
// src/core/constants.ts
|
|
12
12
|
/**
|
|
13
13
|
* Lists the roles a conversation message can play, in the order the wire contract names them —
|
|
14
14
|
* the one list the {@link import('./types.js').MessageRole} union derives from, the message
|
|
@@ -20,8 +20,7 @@ var MESSAGE_ROLES = Object.freeze([
|
|
|
20
20
|
"assistant",
|
|
21
21
|
"tool"
|
|
22
22
|
]);
|
|
23
|
-
|
|
24
|
-
//#region src/core/errors.ts
|
|
23
|
+
// src/core/errors.ts
|
|
25
24
|
/**
|
|
26
25
|
* Reports a judge call cancelled by the caller's signal or its deadline, carrying the
|
|
27
26
|
* {@link JudgeResult} merged from the calls that completed before the cancel and the
|
|
@@ -40,11 +39,12 @@ var JudgeAbortError = class extends Error {
|
|
|
40
39
|
constructor(partial, options) {
|
|
41
40
|
super("judge call aborted", options);
|
|
42
41
|
this.name = "JudgeAbortError";
|
|
42
|
+
INTRINSICS.define(this, Symbol.for("@orkestrel/agent.JudgeAbortError"), { value: this });
|
|
43
43
|
this.partial = partial;
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
/**
|
|
47
|
-
* Narrows a caught value to a {@link JudgeAbortError} through
|
|
47
|
+
* Narrows a caught value to a {@link JudgeAbortError} through its identity brand and declared members, so a `catch` can
|
|
48
48
|
* recover its `partial` result.
|
|
49
49
|
*
|
|
50
50
|
* @param value - The caught value
|
|
@@ -55,10 +55,29 @@ var JudgeAbortError = class extends Error {
|
|
|
55
55
|
* ```
|
|
56
56
|
*/
|
|
57
57
|
function isJudgeAbortError(value) {
|
|
58
|
-
return
|
|
58
|
+
return holds(() => {
|
|
59
|
+
if (!(value instanceof Error && INTRINSICS.prototype(value) !== Error.prototype && INTRINSICS.describe(value, Symbol.for("@orkestrel/agent.JudgeAbortError"))?.value === value)) return false;
|
|
60
|
+
if (!(INTRINSICS.reflect.read(value, "code") === "ABORT")) return false;
|
|
61
|
+
const partial = INTRINSICS.reflect.read(value, "partial");
|
|
62
|
+
if (!(isObject(partial) || isFunction(partial))) return false;
|
|
63
|
+
const answers = INTRINSICS.reflect.read(partial, "answers");
|
|
64
|
+
const refusals = INTRINSICS.reflect.read(partial, "refusals");
|
|
65
|
+
const usage = INTRINSICS.reflect.read(partial, "usage");
|
|
66
|
+
return isString(INTRINSICS.reflect.read(partial, "model")) && (usage === void 0 || (isObject(usage) || isFunction(usage)) && [
|
|
67
|
+
"prompt",
|
|
68
|
+
"completion",
|
|
69
|
+
"total"
|
|
70
|
+
].every((key) => isNumber(INTRINSICS.reflect.read(usage, key)))) && (isObject(answers) || isFunction(answers)) && INTRINSICS.values(answers).every((answer) => {
|
|
71
|
+
if (!(isObject(answer) || isFunction(answer))) return false;
|
|
72
|
+
const form = INTRINSICS.reflect.read(answer, "form");
|
|
73
|
+
if (form === "noul") return isNumber(INTRINSICS.reflect.read(answer, "noul"));
|
|
74
|
+
const probabilities = INTRINSICS.reflect.read(answer, "probabilities");
|
|
75
|
+
if (form === "score") return arrayOf(isNumber)(probabilities);
|
|
76
|
+
return form === "choice" && (isObject(probabilities) || isFunction(probabilities)) && INTRINSICS.values(probabilities).every(isNumber);
|
|
77
|
+
}) && (refusals === void 0 || (isObject(refusals) || isFunction(refusals)) && INTRINSICS.values(refusals).every((refusal) => (isObject(refusal) || isFunction(refusal)) && arrayOf(isString)(INTRINSICS.reflect.read(refusal, "missing"))));
|
|
78
|
+
});
|
|
59
79
|
}
|
|
60
|
-
|
|
61
|
-
//#region src/core/shapers.ts
|
|
80
|
+
// src/core/shapers.ts
|
|
62
81
|
/**
|
|
63
82
|
* Describes a tool call's JSON wire projection.
|
|
64
83
|
*
|
|
@@ -88,12 +107,10 @@ var messageShape = objectShape({
|
|
|
88
107
|
images: optionalShape(arrayShape(stringShape())),
|
|
89
108
|
thinking: optionalShape(stringShape())
|
|
90
109
|
});
|
|
91
|
-
|
|
92
|
-
//#region src/core/contracts.ts
|
|
110
|
+
// src/core/contracts.ts
|
|
93
111
|
/** Validates and projects conversation messages at a JSON wire boundary. */
|
|
94
112
|
var messageContract = createContract(messageShape);
|
|
95
|
-
|
|
96
|
-
//#region src/core/cloners.ts
|
|
113
|
+
// src/core/cloners.ts
|
|
97
114
|
/**
|
|
98
115
|
* Owns a value by serializing it to JSON and parsing the text, so the copy shares nothing with its source.
|
|
99
116
|
*
|
|
@@ -115,8 +132,7 @@ function copyJSON(value) {
|
|
|
115
132
|
if (!text.success || typeof text.value !== "string") return void 0;
|
|
116
133
|
return parseJSON(text.value);
|
|
117
134
|
}
|
|
118
|
-
|
|
119
|
-
//#region src/core/helpers.ts
|
|
135
|
+
// src/core/helpers.ts
|
|
120
136
|
/**
|
|
121
137
|
* Filters a list of members by a {@link import('./contexts/index.js').ScopeInterface} allow-list of keys —
|
|
122
138
|
* `undefined` passes everything, `[]` passes nothing, and a non-empty list passes the listed keys
|
|
@@ -455,8 +471,7 @@ function renderJSON(value) {
|
|
|
455
471
|
function matchesJudgment(judgment, question, sources, state, model) {
|
|
456
472
|
return judgment.model === model && judgment.state === state && judgment.sources.length === sources.length && judgment.sources.every((id, index) => id === sources[index]) && JSON.stringify(judgment.question) === JSON.stringify(question);
|
|
457
473
|
}
|
|
458
|
-
|
|
459
|
-
//#region src/core/validators.ts
|
|
474
|
+
// src/core/validators.ts
|
|
460
475
|
/**
|
|
461
476
|
* Checks whether a value is a judge entry: a string, a JSON record, or a JSON array.
|
|
462
477
|
*
|
|
@@ -533,8 +548,7 @@ function isJudgeQuestion(value) {
|
|
|
533
548
|
function isNonNegativeSafeInteger(value) {
|
|
534
549
|
return isFiniteNumber(value) && Number.isSafeInteger(value) && value >= 0;
|
|
535
550
|
}
|
|
536
|
-
|
|
537
|
-
//#region src/core/providers/constants.ts
|
|
551
|
+
// src/core/providers/constants.ts
|
|
538
552
|
/**
|
|
539
553
|
* Names the opening tag a {@link import('./ThinkSplitter.js').ThinkSplitter} recognizes as the start of
|
|
540
554
|
* an in-content reasoning span — `'<think>'`, the de-facto wire convention thinking models
|
|
@@ -600,8 +614,7 @@ var INVALID_RELAY_STATUS = 400;
|
|
|
600
614
|
var OVERSIZED_RELAY_STATUS = 413;
|
|
601
615
|
/** Names the System One decision endpoint shared by compatible servers. */
|
|
602
616
|
var SYSTEM_ONE_PATH = "/v1/systemone";
|
|
603
|
-
|
|
604
|
-
//#region src/core/providers/errors.ts
|
|
617
|
+
// src/core/providers/errors.ts
|
|
605
618
|
/**
|
|
606
619
|
* Reports a provider stream cancelled mid-flight by its bound signal — thrown by the
|
|
607
620
|
* `stream` method of a {@link ProviderInterface}, carrying the {@link ProviderResult} assembled from
|
|
@@ -622,11 +635,12 @@ var ProviderAbortError = class extends Error {
|
|
|
622
635
|
constructor(partial, options) {
|
|
623
636
|
super("provider stream aborted", options);
|
|
624
637
|
this.name = "ProviderAbortError";
|
|
638
|
+
INTRINSICS.define(this, Symbol.for("@orkestrel/agent.ProviderAbortError"), { value: this });
|
|
625
639
|
this.partial = partial;
|
|
626
640
|
}
|
|
627
641
|
};
|
|
628
642
|
/**
|
|
629
|
-
* Narrows an unknown caught value to a {@link ProviderAbortError} through
|
|
643
|
+
* Narrows an unknown caught value to a {@link ProviderAbortError} through its identity brand and declared members, so a
|
|
630
644
|
* `catch` can recover its `partial` result.
|
|
631
645
|
*
|
|
632
646
|
* @param value - The value to test (typically a `catch` binding)
|
|
@@ -642,7 +656,19 @@ var ProviderAbortError = class extends Error {
|
|
|
642
656
|
* ```
|
|
643
657
|
*/
|
|
644
658
|
function isProviderAbortError(value) {
|
|
645
|
-
return
|
|
659
|
+
return holds(() => {
|
|
660
|
+
if (!(value instanceof Error && INTRINSICS.prototype(value) !== Error.prototype && INTRINSICS.describe(value, Symbol.for("@orkestrel/agent.ProviderAbortError"))?.value === value)) return false;
|
|
661
|
+
if (!(INTRINSICS.reflect.read(value, "code") === "ABORT")) return false;
|
|
662
|
+
const partial = INTRINSICS.reflect.read(value, "partial");
|
|
663
|
+
if (!(isObject(partial) || isFunction(partial))) return false;
|
|
664
|
+
const usage = INTRINSICS.reflect.read(partial, "usage");
|
|
665
|
+
const tools = INTRINSICS.reflect.read(partial, "tools");
|
|
666
|
+
return isString(INTRINSICS.reflect.read(partial, "content")) && (INTRINSICS.reflect.read(partial, "thinking") === void 0 || isString(INTRINSICS.reflect.read(partial, "thinking"))) && (INTRINSICS.reflect.read(partial, "truncated") === void 0 || isBoolean(INTRINSICS.reflect.read(partial, "truncated"))) && (usage === void 0 || (isObject(usage) || isFunction(usage)) && [
|
|
667
|
+
"prompt",
|
|
668
|
+
"completion",
|
|
669
|
+
"total"
|
|
670
|
+
].every((key) => isNumber(INTRINSICS.reflect.read(usage, key)))) && (tools === void 0 || arrayOf((tool) => (isObject(tool) || isFunction(tool)) && isString(INTRINSICS.reflect.read(tool, "id")) && isString(INTRINSICS.reflect.read(tool, "name")) && (isObject(INTRINSICS.reflect.read(tool, "arguments")) || isFunction(INTRINSICS.reflect.read(tool, "arguments"))))(tools));
|
|
671
|
+
});
|
|
646
672
|
}
|
|
647
673
|
/**
|
|
648
674
|
* Reports a coded provider failure with its HTTP status and underlying cause when available.
|
|
@@ -661,12 +687,13 @@ var ProviderError = class extends Error {
|
|
|
661
687
|
constructor(code, message, options) {
|
|
662
688
|
super(message, options);
|
|
663
689
|
this.name = "ProviderError";
|
|
690
|
+
INTRINSICS.define(this, Symbol.for("@orkestrel/agent.ProviderError"), { value: this });
|
|
664
691
|
this.code = code;
|
|
665
692
|
this.status = options?.status;
|
|
666
693
|
}
|
|
667
694
|
};
|
|
668
695
|
/**
|
|
669
|
-
* Narrows a caught value to the provider failure class through
|
|
696
|
+
* Narrows a caught value to the provider failure class through its identity brand and declared members.
|
|
670
697
|
*
|
|
671
698
|
* @param value - The caught value
|
|
672
699
|
* @returns True if the value is a provider failure; false otherwise
|
|
@@ -676,7 +703,13 @@ var ProviderError = class extends Error {
|
|
|
676
703
|
* ```
|
|
677
704
|
*/
|
|
678
705
|
function isProviderError(value) {
|
|
679
|
-
return
|
|
706
|
+
return holds(() => {
|
|
707
|
+
if (!(value instanceof Error && INTRINSICS.prototype(value) !== Error.prototype && INTRINSICS.describe(value, Symbol.for("@orkestrel/agent.ProviderError"))?.value === value)) return false;
|
|
708
|
+
const code = INTRINSICS.reflect.read(value, "code");
|
|
709
|
+
if (!(code === "HTTP" || code === "PROTOCOL" || code === "PROVIDER")) return false;
|
|
710
|
+
const status = INTRINSICS.reflect.read(value, "status");
|
|
711
|
+
return status === void 0 || isNumber(status);
|
|
712
|
+
});
|
|
680
713
|
}
|
|
681
714
|
/**
|
|
682
715
|
* Reports a coded judge failure with its HTTP status and underlying cause when available.
|
|
@@ -695,12 +728,13 @@ var JudgeError = class extends Error {
|
|
|
695
728
|
constructor(code, message, options) {
|
|
696
729
|
super(message, options);
|
|
697
730
|
this.name = "JudgeError";
|
|
731
|
+
INTRINSICS.define(this, Symbol.for("@orkestrel/agent.JudgeError"), { value: this });
|
|
698
732
|
this.code = code;
|
|
699
733
|
this.status = options?.status;
|
|
700
734
|
}
|
|
701
735
|
};
|
|
702
736
|
/**
|
|
703
|
-
* Narrows a caught value to the judge failure class through
|
|
737
|
+
* Narrows a caught value to the judge failure class through its identity brand and declared members.
|
|
704
738
|
*
|
|
705
739
|
* @param value - The caught value
|
|
706
740
|
* @returns True if the value is a {@link JudgeError}; false otherwise
|
|
@@ -710,10 +744,15 @@ var JudgeError = class extends Error {
|
|
|
710
744
|
* ```
|
|
711
745
|
*/
|
|
712
746
|
function isJudgeError(value) {
|
|
713
|
-
return
|
|
747
|
+
return holds(() => {
|
|
748
|
+
if (!(value instanceof Error && INTRINSICS.prototype(value) !== Error.prototype && INTRINSICS.describe(value, Symbol.for("@orkestrel/agent.JudgeError"))?.value === value)) return false;
|
|
749
|
+
const code = INTRINSICS.reflect.read(value, "code");
|
|
750
|
+
if (!(code === "HTTP" || code === "PROTOCOL" || code === "QUESTION")) return false;
|
|
751
|
+
const status = INTRINSICS.reflect.read(value, "status");
|
|
752
|
+
return status === void 0 || isNumber(status);
|
|
753
|
+
});
|
|
714
754
|
}
|
|
715
|
-
|
|
716
|
-
//#region src/core/providers/shapers.ts
|
|
755
|
+
// src/core/providers/shapers.ts
|
|
717
756
|
/**
|
|
718
757
|
* Describes a provider request's JSON wire projection.
|
|
719
758
|
*
|
|
@@ -773,16 +812,14 @@ var relayFrameShape = unionShape(objectShape({
|
|
|
773
812
|
channel: literalShape(["error"]),
|
|
774
813
|
message: stringShape()
|
|
775
814
|
}));
|
|
776
|
-
|
|
777
|
-
//#region src/core/providers/contracts.ts
|
|
815
|
+
// src/core/providers/contracts.ts
|
|
778
816
|
/** Validates and projects provider requests at a JSON wire boundary. */
|
|
779
817
|
var providerRequestContract = createContract(providerRequestShape);
|
|
780
818
|
/** Validates and projects provider results at a JSON wire boundary. */
|
|
781
819
|
var providerResultContract = createContract(providerResultShape);
|
|
782
820
|
/** Validates and projects channel-discriminated relay frames at a JSON wire boundary. */
|
|
783
821
|
var relayFrameContract = createContract(relayFrameShape);
|
|
784
|
-
|
|
785
|
-
//#region src/core/providers/helpers.ts
|
|
822
|
+
// src/core/providers/helpers.ts
|
|
786
823
|
/**
|
|
787
824
|
* Assembles a provider result with only populated optional fields.
|
|
788
825
|
*
|
|
@@ -1263,8 +1300,7 @@ function extractSystemOneUsage(usage) {
|
|
|
1263
1300
|
});
|
|
1264
1301
|
return extracted.success ? extracted.value : void 0;
|
|
1265
1302
|
}
|
|
1266
|
-
|
|
1267
|
-
//#region src/core/providers/RelayStream.ts
|
|
1303
|
+
// src/core/providers/RelayStream.ts
|
|
1268
1304
|
/**
|
|
1269
1305
|
* Streams a provider call as validated NDJSON frames under response backpressure.
|
|
1270
1306
|
*
|
|
@@ -1372,8 +1408,7 @@ var RelayStream = class {
|
|
|
1372
1408
|
this.#signal.removeEventListener("abort", this.#listener);
|
|
1373
1409
|
}
|
|
1374
1410
|
};
|
|
1375
|
-
|
|
1376
|
-
//#region src/core/providers/ThinkSplitter.ts
|
|
1411
|
+
// src/core/providers/ThinkSplitter.ts
|
|
1377
1412
|
/**
|
|
1378
1413
|
* Separates `<think>…</think>` spans from raw content deltas with per-stream state: text inside a
|
|
1379
1414
|
* span accumulates on `thinking`, and text outside it returns as clean content, so a provider
|
|
@@ -1491,8 +1526,7 @@ var ThinkSplitter = class {
|
|
|
1491
1526
|
return Array.from({ length: max }, (_, index) => max - index).find((length) => this.#pending.endsWith(tag.slice(0, length))) ?? 0;
|
|
1492
1527
|
}
|
|
1493
1528
|
};
|
|
1494
|
-
|
|
1495
|
-
//#region src/core/providers/AgentProvider.ts
|
|
1529
|
+
// src/core/providers/AgentProvider.ts
|
|
1496
1530
|
/**
|
|
1497
1531
|
* Implements bounded HTTP streaming and result assembly behind concrete wire seams.
|
|
1498
1532
|
*
|
|
@@ -1703,8 +1737,7 @@ var AgentProvider = class {
|
|
|
1703
1737
|
return response;
|
|
1704
1738
|
}
|
|
1705
1739
|
};
|
|
1706
|
-
|
|
1707
|
-
//#region src/core/providers/RelayProvider.ts
|
|
1740
|
+
// src/core/providers/RelayProvider.ts
|
|
1708
1741
|
/**
|
|
1709
1742
|
* Carries provider calls over an authenticated NDJSON relay endpoint.
|
|
1710
1743
|
*
|
|
@@ -1821,8 +1854,7 @@ var RelayProvider = class extends AgentProvider {
|
|
|
1821
1854
|
return parser.parse("\n");
|
|
1822
1855
|
}
|
|
1823
1856
|
};
|
|
1824
|
-
|
|
1825
|
-
//#region src/core/providers/AgentJudge.ts
|
|
1857
|
+
// src/core/providers/AgentJudge.ts
|
|
1826
1858
|
/**
|
|
1827
1859
|
* Implements the bounded HTTP calls, validation, and result merging of a judge behind concrete
|
|
1828
1860
|
* wire seams.
|
|
@@ -1962,8 +1994,7 @@ var AgentJudge = class {
|
|
|
1962
1994
|
}
|
|
1963
1995
|
}
|
|
1964
1996
|
};
|
|
1965
|
-
|
|
1966
|
-
//#region src/core/providers/validators.ts
|
|
1997
|
+
// src/core/providers/validators.ts
|
|
1967
1998
|
/**
|
|
1968
1999
|
* Checks whether a value is a System One response envelope with optional model and usage.
|
|
1969
2000
|
*
|
|
@@ -2021,8 +2052,7 @@ function isSystemOneAnswer(value) {
|
|
|
2021
2052
|
});
|
|
2022
2053
|
return checked.success && checked.value;
|
|
2023
2054
|
}
|
|
2024
|
-
|
|
2025
|
-
//#region src/core/providers/SystemOneJudge.ts
|
|
2055
|
+
// src/core/providers/SystemOneJudge.ts
|
|
2026
2056
|
/**
|
|
2027
2057
|
* Carries judge questions over the System One protocol and derives answers from server distributions.
|
|
2028
2058
|
*
|
|
@@ -2123,8 +2153,7 @@ var SystemOneJudge = class extends AgentJudge {
|
|
|
2123
2153
|
};
|
|
2124
2154
|
}
|
|
2125
2155
|
};
|
|
2126
|
-
|
|
2127
|
-
//#region src/core/providers/factories.ts
|
|
2156
|
+
// src/core/providers/factories.ts
|
|
2128
2157
|
/**
|
|
2129
2158
|
* Creates an authorized relay handler that validates a bounded JSON request before streaming.
|
|
2130
2159
|
*
|
|
@@ -2283,8 +2312,7 @@ function createThinkSplitter() {
|
|
|
2283
2312
|
function createSystemOneJudge(options) {
|
|
2284
2313
|
return new SystemOneJudge(options);
|
|
2285
2314
|
}
|
|
2286
|
-
|
|
2287
|
-
//#region src/core/conversations/constants.ts
|
|
2315
|
+
// src/core/conversations/constants.ts
|
|
2288
2316
|
/**
|
|
2289
2317
|
* Sets the default number of recent live messages the `compact()` method of a
|
|
2290
2318
|
* {@link ConversationInterface} retains verbatim — `0`, so a manual `compact()` keeps no recent tail and folds every
|
|
@@ -2311,8 +2339,7 @@ var DEFAULT_CONVERSATION_KEEP = 0;
|
|
|
2311
2339
|
* because it interpolates the per-call provenance `label`).
|
|
2312
2340
|
*/
|
|
2313
2341
|
var CONVERSATION_RECAP_PREFIX = "[Summary of earlier messages] ";
|
|
2314
|
-
|
|
2315
|
-
//#region src/core/conversations/errors.ts
|
|
2342
|
+
// src/core/conversations/errors.ts
|
|
2316
2343
|
/**
|
|
2317
2344
|
* Reports a conversation with no {@link ConversationSummaryHandler} to fold its messages with, a
|
|
2318
2345
|
* `sections` cap below `1`, a `keep` that is not a nonnegative safe integer, or a judgment or
|
|
@@ -2349,12 +2376,13 @@ var ConversationError = class extends Error {
|
|
|
2349
2376
|
constructor(code, message, options) {
|
|
2350
2377
|
super(message, options?.cause === void 0 ? void 0 : { cause: options.cause });
|
|
2351
2378
|
this.name = "ConversationError";
|
|
2379
|
+
INTRINSICS.define(this, Symbol.for("@orkestrel/agent.ConversationError"), { value: this });
|
|
2352
2380
|
this.code = code;
|
|
2353
2381
|
this.context = options?.context;
|
|
2354
2382
|
}
|
|
2355
2383
|
};
|
|
2356
2384
|
/**
|
|
2357
|
-
* Narrows an unknown caught value to a {@link ConversationError} through
|
|
2385
|
+
* Narrows an unknown caught value to a {@link ConversationError} through its identity brand and declared members, so a
|
|
2358
2386
|
* `catch` can branch on its `code`.
|
|
2359
2387
|
*
|
|
2360
2388
|
* @param value - The value to test (typically a `catch` binding)
|
|
@@ -2370,10 +2398,15 @@ var ConversationError = class extends Error {
|
|
|
2370
2398
|
* ```
|
|
2371
2399
|
*/
|
|
2372
2400
|
function isConversationError(value) {
|
|
2373
|
-
return
|
|
2401
|
+
return holds(() => {
|
|
2402
|
+
if (!(value instanceof Error && INTRINSICS.prototype(value) !== Error.prototype && INTRINSICS.describe(value, Symbol.for("@orkestrel/agent.ConversationError"))?.value === value)) return false;
|
|
2403
|
+
const code = INTRINSICS.reflect.read(value, "code");
|
|
2404
|
+
if (!(code === "SUMMARIZER" || code === "SECTIONS" || code === "JUDGMENT" || code === "KEEP")) return false;
|
|
2405
|
+
const context = INTRINSICS.reflect.read(value, "context");
|
|
2406
|
+
return context === void 0 || isObject(context) || isFunction(context);
|
|
2407
|
+
});
|
|
2374
2408
|
}
|
|
2375
|
-
|
|
2376
|
-
//#region src/core/conversations/validators.ts
|
|
2409
|
+
// src/core/conversations/validators.ts
|
|
2377
2410
|
/**
|
|
2378
2411
|
* Checks whether a value satisfies the domain conversation-message contract.
|
|
2379
2412
|
*
|
|
@@ -2515,8 +2548,7 @@ function isConversationSnapshot(value) {
|
|
|
2515
2548
|
judgments: optionalOf(arrayOf(isJudgment))
|
|
2516
2549
|
}, ["judgments"])(value);
|
|
2517
2550
|
}
|
|
2518
|
-
|
|
2519
|
-
//#region src/core/conversations/helpers.ts
|
|
2551
|
+
// src/core/conversations/helpers.ts
|
|
2520
2552
|
/**
|
|
2521
2553
|
* Builds records for answered or refused request keys, attaching usage only for a single question.
|
|
2522
2554
|
*
|
|
@@ -2725,8 +2757,7 @@ function raceSignal(promise, signal) {
|
|
|
2725
2757
|
promise.then(resolve, reject).finally(() => settled.abort());
|
|
2726
2758
|
});
|
|
2727
2759
|
}
|
|
2728
|
-
|
|
2729
|
-
//#region src/core/conversations/JudgmentManager.ts
|
|
2760
|
+
// src/core/conversations/JudgmentManager.ts
|
|
2730
2761
|
/**
|
|
2731
2762
|
* Stores judgments in insertion order and asks a judge only for unmatched question identities.
|
|
2732
2763
|
*
|
|
@@ -2822,8 +2853,7 @@ var JudgmentManager = class {
|
|
|
2822
2853
|
return structuredClone(judgment);
|
|
2823
2854
|
}
|
|
2824
2855
|
};
|
|
2825
|
-
|
|
2826
|
-
//#region src/core/conversations/Conversation.ts
|
|
2856
|
+
// src/core/conversations/Conversation.ts
|
|
2827
2857
|
/**
|
|
2828
2858
|
* Represents a conversation — a live uncompacted tail of messages it owns directly above a flat
|
|
2829
2859
|
* message store, plus compacted, summarized {@link Section} records and a `summarizable` flag,
|
|
@@ -3041,8 +3071,7 @@ var Conversation = class {
|
|
|
3041
3071
|
return message;
|
|
3042
3072
|
}
|
|
3043
3073
|
};
|
|
3044
|
-
|
|
3045
|
-
//#region src/core/conversations/ConversationManager.ts
|
|
3074
|
+
// src/core/conversations/ConversationManager.ts
|
|
3046
3075
|
/**
|
|
3047
3076
|
* Registers {@link Conversation} instances keyed by `id`, in insertion order, with an active pointer —
|
|
3048
3077
|
* the id-keyed store over the conversation layer, the `active` / `switch` seam the
|
|
@@ -3164,8 +3193,7 @@ var ConversationManager = class {
|
|
|
3164
3193
|
return removed;
|
|
3165
3194
|
}
|
|
3166
3195
|
};
|
|
3167
|
-
|
|
3168
|
-
//#region src/core/conversations/stores/MemoryConversationStore.ts
|
|
3196
|
+
// src/core/conversations/stores/MemoryConversationStore.ts
|
|
3169
3197
|
/**
|
|
3170
3198
|
* Implements the {@link ConversationStoreInterface} in memory — a process-lifetime `Map` of
|
|
3171
3199
|
* {@link ConversationSnapshot} records keyed by conversation id, the default store
|
|
@@ -3238,8 +3266,7 @@ var MemoryConversationStore = class {
|
|
|
3238
3266
|
return Promise.resolve();
|
|
3239
3267
|
}
|
|
3240
3268
|
};
|
|
3241
|
-
|
|
3242
|
-
//#region src/core/conversations/stores/DatabaseConversationStore.ts
|
|
3269
|
+
// src/core/conversations/stores/DatabaseConversationStore.ts
|
|
3243
3270
|
/**
|
|
3244
3271
|
* Backs a {@link ConversationStoreInterface} with one table of the `databases` layer — a
|
|
3245
3272
|
* conversation's durable state is a row holding the snapshot as one opaque JSON column, narrowed
|
|
@@ -3346,8 +3373,7 @@ var DatabaseConversationStore = class {
|
|
|
3346
3373
|
await this.#table.remove(id);
|
|
3347
3374
|
}
|
|
3348
3375
|
};
|
|
3349
|
-
|
|
3350
|
-
//#region src/core/conversations/factories.ts
|
|
3376
|
+
// src/core/conversations/factories.ts
|
|
3351
3377
|
/**
|
|
3352
3378
|
* Creates a conversation — a {@link ConversationInterface} grouping messages above a flat
|
|
3353
3379
|
* message store it owns directly, with compaction into summarized sections, on-demand
|
|
@@ -3522,8 +3548,7 @@ function createDatabaseConversationStore(driver = createMemoryDriver()) {
|
|
|
3522
3548
|
tables: { conversations: columns }
|
|
3523
3549
|
}).table("conversations"));
|
|
3524
3550
|
}
|
|
3525
|
-
|
|
3526
|
-
//#region src/core/contexts/constants.ts
|
|
3551
|
+
// src/core/contexts/constants.ts
|
|
3527
3552
|
/**
|
|
3528
3553
|
* Names the section header the `build()` method of {@link import('./AgentContext.js').AgentContext}
|
|
3529
3554
|
* renders the active workspace's text files under — `'## Workspace'`, the leading line of the dedicated
|
|
@@ -3539,8 +3564,7 @@ function createDatabaseConversationStore(driver = createMemoryDriver()) {
|
|
|
3539
3564
|
* `base64` payload attaches to the last user message.
|
|
3540
3565
|
*/
|
|
3541
3566
|
var WORKSPACE_SECTION_HEADER = "## Workspace";
|
|
3542
|
-
|
|
3543
|
-
//#region src/core/contexts/instructions/Instruction.ts
|
|
3567
|
+
// src/core/contexts/instructions/Instruction.ts
|
|
3544
3568
|
/**
|
|
3545
3569
|
* Represents an immutable named directive — an {@link InstructionInterface} assembled once from
|
|
3546
3570
|
* its input (`name` / `content` and an optional `priority`), the `id` minted at
|
|
@@ -3575,8 +3599,7 @@ var Instruction = class {
|
|
|
3575
3599
|
if (input.override !== void 0) this.override = input.override;
|
|
3576
3600
|
}
|
|
3577
3601
|
};
|
|
3578
|
-
|
|
3579
|
-
//#region src/core/contexts/instructions/InstructionManager.ts
|
|
3602
|
+
// src/core/contexts/instructions/InstructionManager.ts
|
|
3580
3603
|
/**
|
|
3581
3604
|
* Registers the immutable {@link Instruction} instances a richer context assembles a directives block
|
|
3582
3605
|
* from — keyed by `name` so adding an instruction whose name is already stored overwrites it,
|
|
@@ -3667,8 +3690,7 @@ var InstructionManager = class {
|
|
|
3667
3690
|
return removed;
|
|
3668
3691
|
}
|
|
3669
3692
|
};
|
|
3670
|
-
|
|
3671
|
-
//#region src/core/contexts/helpers.ts
|
|
3693
|
+
// src/core/contexts/helpers.ts
|
|
3672
3694
|
/**
|
|
3673
3695
|
* Renders a path-addressed text body as a fenced reference block — a `File: <path>` label line
|
|
3674
3696
|
* over a language-tagged fence, the framing the
|
|
@@ -3839,8 +3861,7 @@ function intersectKeys(parent, child) {
|
|
|
3839
3861
|
const allowed = new Set(parent);
|
|
3840
3862
|
return child.filter((key) => allowed.has(key));
|
|
3841
3863
|
}
|
|
3842
|
-
|
|
3843
|
-
//#region src/core/contexts/scopes/Scope.ts
|
|
3864
|
+
// src/core/contexts/scopes/Scope.ts
|
|
3844
3865
|
/**
|
|
3845
3866
|
* Represents a named, immutable filter over a richer context's items — an optional allow-list per
|
|
3846
3867
|
* category (`instructions` / `tools` / `files`), each keyed by that category's identity (an
|
|
@@ -3900,8 +3921,7 @@ var Scope = class Scope {
|
|
|
3900
3921
|
});
|
|
3901
3922
|
}
|
|
3902
3923
|
};
|
|
3903
|
-
|
|
3904
|
-
//#region src/core/contexts/scopes/ScopeManager.ts
|
|
3924
|
+
// src/core/contexts/scopes/ScopeManager.ts
|
|
3905
3925
|
/**
|
|
3906
3926
|
* Registers the named filters a richer context reuses — immutable {@link Scope} instances keyed by their
|
|
3907
3927
|
* minted `id`, in insertion order, where `add` always mints and stores rather than overwriting,
|
|
@@ -3968,8 +3988,7 @@ var ScopeManager = class {
|
|
|
3968
3988
|
return removed;
|
|
3969
3989
|
}
|
|
3970
3990
|
};
|
|
3971
|
-
|
|
3972
|
-
//#region src/core/contexts/AgentContext.ts
|
|
3991
|
+
// src/core/contexts/AgentContext.ts
|
|
3973
3992
|
/**
|
|
3974
3993
|
* Assembles a provider request from the richer turn context — the optional system prompt, the
|
|
3975
3994
|
* observable context managers (instructions / workspaces), the
|
|
@@ -4123,8 +4142,7 @@ var AgentContext = class {
|
|
|
4123
4142
|
return this.#conversations.active ?? conversation;
|
|
4124
4143
|
}
|
|
4125
4144
|
};
|
|
4126
|
-
|
|
4127
|
-
//#region src/core/contexts/factories.ts
|
|
4145
|
+
// src/core/contexts/factories.ts
|
|
4128
4146
|
/**
|
|
4129
4147
|
* Creates an instruction — an immutable {@link InstructionInterface} (a named directive)
|
|
4130
4148
|
* from its `name` / `content` and optional `priority`, the `id` minted at construction.
|
|
@@ -4268,8 +4286,7 @@ function createScopeManager(options) {
|
|
|
4268
4286
|
function createAgentContext(options) {
|
|
4269
4287
|
return new AgentContext(options);
|
|
4270
4288
|
}
|
|
4271
|
-
|
|
4272
|
-
//#region src/core/agents/constants.ts
|
|
4289
|
+
// src/core/agents/constants.ts
|
|
4273
4290
|
/**
|
|
4274
4291
|
* Caps an {@link AgentInterface} turn's tool iterations by default — `10` context → provider →
|
|
4275
4292
|
* tools cycles before the loop stops, so a model that keeps requesting tools can never loop
|
|
@@ -4296,8 +4313,7 @@ var MESSAGE_TOKEN_OVERHEAD = 4;
|
|
|
4296
4313
|
* exact count.
|
|
4297
4314
|
*/
|
|
4298
4315
|
var IMAGE_TOKEN_ESTIMATE = 512;
|
|
4299
|
-
|
|
4300
|
-
//#region src/core/agents/errors.ts
|
|
4316
|
+
// src/core/agents/errors.ts
|
|
4301
4317
|
/**
|
|
4302
4318
|
* Reports an {@link AgentInterface} run that ended {@link AgentResult.partial} under a
|
|
4303
4319
|
* `partial` policy of `false` (the default) — thrown by an agent-job handler (a
|
|
@@ -4323,11 +4339,12 @@ var AgentJobError = class extends Error {
|
|
|
4323
4339
|
constructor(message, partial) {
|
|
4324
4340
|
super(message);
|
|
4325
4341
|
this.name = "AgentJobError";
|
|
4342
|
+
INTRINSICS.define(this, Symbol.for("@orkestrel/agent.AgentJobError"), { value: this });
|
|
4326
4343
|
this.partial = partial;
|
|
4327
4344
|
}
|
|
4328
4345
|
};
|
|
4329
4346
|
/**
|
|
4330
|
-
* Narrows an unknown caught value to an {@link AgentJobError} through
|
|
4347
|
+
* Narrows an unknown caught value to an {@link AgentJobError} through its identity brand and declared members, so a
|
|
4331
4348
|
* `catch` can recover its `partial` result.
|
|
4332
4349
|
*
|
|
4333
4350
|
* @param value - The value to test (typically a `catch` binding or a rejected enqueue)
|
|
@@ -4343,7 +4360,30 @@ var AgentJobError = class extends Error {
|
|
|
4343
4360
|
* ```
|
|
4344
4361
|
*/
|
|
4345
4362
|
function isAgentJobError(value) {
|
|
4346
|
-
return
|
|
4363
|
+
return holds(() => {
|
|
4364
|
+
if (!(value instanceof Error && INTRINSICS.prototype(value) !== Error.prototype && INTRINSICS.describe(value, Symbol.for("@orkestrel/agent.AgentJobError"))?.value === value)) return false;
|
|
4365
|
+
if (!(INTRINSICS.reflect.read(value, "code") === "PARTIAL")) return false;
|
|
4366
|
+
const partial = INTRINSICS.reflect.read(value, "partial");
|
|
4367
|
+
if (!(isObject(partial) || isFunction(partial))) return false;
|
|
4368
|
+
const usage = INTRINSICS.reflect.read(partial, "usage");
|
|
4369
|
+
const stop = INTRINSICS.reflect.read(partial, "stop");
|
|
4370
|
+
if (stop !== void 0) {
|
|
4371
|
+
if (!(isObject(stop) || isFunction(stop))) return false;
|
|
4372
|
+
const layer = INTRINSICS.reflect.read(stop, "layer");
|
|
4373
|
+
const spent = INTRINSICS.reflect.read(stop, "usage");
|
|
4374
|
+
if (!isString(INTRINSICS.reflect.read(stop, "id")) || !(INTRINSICS.reflect.read(stop, "estimate") === void 0 || isNumber(INTRINSICS.reflect.read(stop, "estimate"))) || !(spent === void 0 || (isObject(spent) || isFunction(spent)) && [
|
|
4375
|
+
"prompt",
|
|
4376
|
+
"completion",
|
|
4377
|
+
"total"
|
|
4378
|
+
].every((key) => isNumber(INTRINSICS.reflect.read(spent, key))))) return false;
|
|
4379
|
+
if (layer !== "model" && !((layer === "meter" || layer === "budget") && isNumber(INTRINSICS.reflect.read(stop, "max")) && isNumber(INTRINSICS.reflect.read(stop, "consumed")))) return false;
|
|
4380
|
+
}
|
|
4381
|
+
return isString(INTRINSICS.reflect.read(partial, "content")) && (INTRINSICS.reflect.read(partial, "thinking") === void 0 || isString(INTRINSICS.reflect.read(partial, "thinking"))) && isBoolean(INTRINSICS.reflect.read(partial, "partial")) && (usage === void 0 || (isObject(usage) || isFunction(usage)) && [
|
|
4382
|
+
"prompt",
|
|
4383
|
+
"completion",
|
|
4384
|
+
"total"
|
|
4385
|
+
].every((key) => isNumber(INTRINSICS.reflect.read(usage, key))));
|
|
4386
|
+
});
|
|
4347
4387
|
}
|
|
4348
4388
|
/**
|
|
4349
4389
|
* Reports a run sharing accounting with a live run, a `limit` that is not a nonnegative safe integer, a name absent from a registry pool, or a strict run whose request exceeds its window. Agent construction, the `stream` and `generate` methods, and registry accessors throw synchronously, before returning a handle or promise; a `'WINDOW'` refusal rejects the run's `result` instead. Await the call inside `try`/`catch` to catch it.
|
|
@@ -4379,12 +4419,13 @@ var AgentError = class extends Error {
|
|
|
4379
4419
|
constructor(code, message, options) {
|
|
4380
4420
|
super(message, options?.cause === void 0 ? void 0 : { cause: options.cause });
|
|
4381
4421
|
this.name = "AgentError";
|
|
4422
|
+
INTRINSICS.define(this, Symbol.for("@orkestrel/agent.AgentError"), { value: this });
|
|
4382
4423
|
this.code = code;
|
|
4383
4424
|
this.context = options?.context;
|
|
4384
4425
|
}
|
|
4385
4426
|
};
|
|
4386
4427
|
/**
|
|
4387
|
-
* Narrows an unknown caught value to an {@link AgentError} through
|
|
4428
|
+
* Narrows an unknown caught value to an {@link AgentError} through its identity brand and declared members, so a `catch`
|
|
4388
4429
|
* can branch on its `code`.
|
|
4389
4430
|
*
|
|
4390
4431
|
* @param value - The value to test (typically a `catch` binding)
|
|
@@ -4400,10 +4441,15 @@ var AgentError = class extends Error {
|
|
|
4400
4441
|
* ```
|
|
4401
4442
|
*/
|
|
4402
4443
|
function isAgentError(value) {
|
|
4403
|
-
return
|
|
4444
|
+
return holds(() => {
|
|
4445
|
+
if (!(value instanceof Error && INTRINSICS.prototype(value) !== Error.prototype && INTRINSICS.describe(value, Symbol.for("@orkestrel/agent.AgentError"))?.value === value)) return false;
|
|
4446
|
+
const code = INTRINSICS.reflect.read(value, "code");
|
|
4447
|
+
if (!(code === "CONCURRENCY" || code === "LIMIT" || code === "REGISTRY" || code === "WINDOW")) return false;
|
|
4448
|
+
const context = INTRINSICS.reflect.read(value, "context");
|
|
4449
|
+
return context === void 0 || isObject(context) || isFunction(context);
|
|
4450
|
+
});
|
|
4404
4451
|
}
|
|
4405
|
-
|
|
4406
|
-
//#region src/core/agents/Channel.ts
|
|
4452
|
+
// src/core/agents/Channel.ts
|
|
4407
4453
|
/**
|
|
4408
4454
|
* Buffers chunks in a minimal unbounded async channel — the eager pump writes them in (`push`)
|
|
4409
4455
|
* and ends it (`close` / `fail`) regardless of consumption, while a consumer reads them back live
|
|
@@ -4473,8 +4519,7 @@ var Channel = class {
|
|
|
4473
4519
|
});
|
|
4474
4520
|
}
|
|
4475
4521
|
};
|
|
4476
|
-
|
|
4477
|
-
//#region src/core/agents/helpers.ts
|
|
4522
|
+
// src/core/agents/helpers.ts
|
|
4478
4523
|
/**
|
|
4479
4524
|
* Projects an unknown value onto a fresh, exact `JSONValue` representation of an
|
|
4480
4525
|
* {@link AgentResult} — capturing each structural field once through a total boundary,
|
|
@@ -4701,7 +4746,7 @@ function estimateTokens(text) {
|
|
|
4701
4746
|
function estimateMessages(messages) {
|
|
4702
4747
|
return messages.reduce((sum, message) => {
|
|
4703
4748
|
const measure = measureMessage(message);
|
|
4704
|
-
return sum + measure.content + measure.
|
|
4749
|
+
return sum + measure.content + measure.uniform + measure.calls + measure.thinking + measure.images;
|
|
4705
4750
|
}, 0);
|
|
4706
4751
|
}
|
|
4707
4752
|
/**
|
|
@@ -4711,7 +4756,7 @@ function estimateMessages(messages) {
|
|
|
4711
4756
|
* @remarks
|
|
4712
4757
|
* The result is a structural estimate, not a tokenizer allocation. `id` and `role` are joins back to
|
|
4713
4758
|
* the message, not token components, and a provider's template effects and the estimation error are
|
|
4714
|
-
* not individually attributed. `content` is `ceil(length / 4)`, `
|
|
4759
|
+
* not individually attributed. `content` is `ceil(length / 4)`, `uniform` is
|
|
4715
4760
|
* {@link import('./constants.js').MESSAGE_TOKEN_OVERHEAD}, `calls` is the estimate of the JSON-rendered
|
|
4716
4761
|
* calls (`0` when the message carries none, the framing overhead when they cannot be rendered),
|
|
4717
4762
|
* `thinking` is the estimate of the thinking (`0` when absent), and `images` is the attached image
|
|
@@ -4723,7 +4768,7 @@ function estimateMessages(messages) {
|
|
|
4723
4768
|
* @example
|
|
4724
4769
|
* ```ts
|
|
4725
4770
|
* measureMessage({ id: '1', role: 'user', content: 'hello' })
|
|
4726
|
-
* // { id: '1', role: 'user', content: 2,
|
|
4771
|
+
* // { id: '1', role: 'user', content: 2, uniform: 4, calls: 0, thinking: 0, images: 0 }
|
|
4727
4772
|
* ```
|
|
4728
4773
|
*/
|
|
4729
4774
|
function measureMessage(message) {
|
|
@@ -4733,7 +4778,7 @@ function measureMessage(message) {
|
|
|
4733
4778
|
id: message.id,
|
|
4734
4779
|
role: message.role,
|
|
4735
4780
|
content: estimateTokens(message.content),
|
|
4736
|
-
|
|
4781
|
+
uniform: 4,
|
|
4737
4782
|
calls,
|
|
4738
4783
|
thinking: message.thinking === void 0 ? 0 : estimateTokens(message.thinking),
|
|
4739
4784
|
images: (message.images?.length ?? 0) * 512
|
|
@@ -4765,7 +4810,7 @@ function measureMessage(message) {
|
|
|
4765
4810
|
*/
|
|
4766
4811
|
function estimateRequest(request) {
|
|
4767
4812
|
const measure = measureRequest(request);
|
|
4768
|
-
return measure.messages.reduce((sum, message) => sum + message.content + message.
|
|
4813
|
+
return measure.messages.reduce((sum, message) => sum + message.content + message.uniform + message.calls + message.thinking + message.images, measure.tools + measure.schema);
|
|
4769
4814
|
}
|
|
4770
4815
|
/**
|
|
4771
4816
|
* Measures the disjoint estimate components of a complete provider request — each message through
|
|
@@ -4786,7 +4831,7 @@ function estimateRequest(request) {
|
|
|
4786
4831
|
* @example
|
|
4787
4832
|
* ```ts
|
|
4788
4833
|
* measureRequest({ messages: [{ id: '1', role: 'user', content: 'hello' }] })
|
|
4789
|
-
* // { messages: [{ id: '1', role: 'user', content: 2,
|
|
4834
|
+
* // { messages: [{ id: '1', role: 'user', content: 2, uniform: 4, calls: 0, thinking: 0, images: 0 }], tools: 0, schema: 0 }
|
|
4790
4835
|
* ```
|
|
4791
4836
|
*/
|
|
4792
4837
|
function measureRequest(request) {
|
|
@@ -5056,8 +5101,7 @@ function extractQueueOptions(options) {
|
|
|
5056
5101
|
...timeout === void 0 ? {} : { timeout }
|
|
5057
5102
|
};
|
|
5058
5103
|
}
|
|
5059
|
-
|
|
5060
|
-
//#region src/core/agents/Agent.ts
|
|
5104
|
+
// src/core/agents/Agent.ts
|
|
5061
5105
|
/**
|
|
5062
5106
|
* Composes a {@link ProviderInterface}, an {@link AgentContext}, and a
|
|
5063
5107
|
* {@link ToolManagerInterface} into a bounded context → provider → tools → repeat turn, exposed
|
|
@@ -5238,7 +5282,7 @@ var Agent = class {
|
|
|
5238
5282
|
this.#window?.clear();
|
|
5239
5283
|
const cancelled = abort.signal.aborted;
|
|
5240
5284
|
const turns = [];
|
|
5241
|
-
while (turns.length < limit && (turns.at(-1)?.
|
|
5285
|
+
while (turns.length < limit && (turns.at(-1)?.outcome ?? "tools") === "tools") {
|
|
5242
5286
|
const index = turns.length;
|
|
5243
5287
|
const base = turns.at(-1)?.messages ?? entry.messages;
|
|
5244
5288
|
const futile = turns.at(-1)?.futile ?? false;
|
|
@@ -5248,7 +5292,7 @@ var Agent = class {
|
|
|
5248
5292
|
usage: void 0,
|
|
5249
5293
|
spent: void 0,
|
|
5250
5294
|
messages: base,
|
|
5251
|
-
|
|
5295
|
+
outcome: "cancel",
|
|
5252
5296
|
partial: true,
|
|
5253
5297
|
futile,
|
|
5254
5298
|
estimate: void 0,
|
|
@@ -5294,7 +5338,7 @@ var Agent = class {
|
|
|
5294
5338
|
if (!provided.success) {
|
|
5295
5339
|
turns.push({
|
|
5296
5340
|
...settled,
|
|
5297
|
-
|
|
5341
|
+
outcome: "cancel",
|
|
5298
5342
|
partial: true
|
|
5299
5343
|
});
|
|
5300
5344
|
continue;
|
|
@@ -5316,7 +5360,7 @@ var Agent = class {
|
|
|
5316
5360
|
if (abort.signal.aborted) {
|
|
5317
5361
|
turns.push({
|
|
5318
5362
|
...settled,
|
|
5319
|
-
|
|
5363
|
+
outcome: "cancel",
|
|
5320
5364
|
partial: true
|
|
5321
5365
|
});
|
|
5322
5366
|
continue;
|
|
@@ -5351,7 +5395,7 @@ var Agent = class {
|
|
|
5351
5395
|
assistant,
|
|
5352
5396
|
...replies
|
|
5353
5397
|
],
|
|
5354
|
-
|
|
5398
|
+
outcome: "tools",
|
|
5355
5399
|
partial: true
|
|
5356
5400
|
});
|
|
5357
5401
|
continue;
|
|
@@ -5364,7 +5408,7 @@ var Agent = class {
|
|
|
5364
5408
|
turns.push({
|
|
5365
5409
|
...settled,
|
|
5366
5410
|
content: result.content,
|
|
5367
|
-
|
|
5411
|
+
outcome: "answer",
|
|
5368
5412
|
partial: abort.signal.aborted,
|
|
5369
5413
|
truncated: result.truncated === true
|
|
5370
5414
|
});
|
|
@@ -5372,7 +5416,7 @@ var Agent = class {
|
|
|
5372
5416
|
const final = turns.at(-1);
|
|
5373
5417
|
const thinkings = turns.flatMap((turn) => turn.thinking === void 0 ? [] : [turn.thinking]);
|
|
5374
5418
|
return {
|
|
5375
|
-
content: final?.
|
|
5419
|
+
content: final?.outcome === "answer" ? final.content : turns.map((turn) => turn.content).join(""),
|
|
5376
5420
|
thinking: thinkings.length === 0 ? void 0 : thinkings.join("\n\n"),
|
|
5377
5421
|
usage: [
|
|
5378
5422
|
...turns.map((turn) => turn.usage),
|
|
@@ -5380,7 +5424,7 @@ var Agent = class {
|
|
|
5380
5424
|
...turns.map((turn) => turn.spent)
|
|
5381
5425
|
].reduce((total, one) => one === void 0 ? total : sumUsage(total, one), void 0),
|
|
5382
5426
|
partial: final?.partial ?? cancelled,
|
|
5383
|
-
exhausted: final?.
|
|
5427
|
+
exhausted: final?.outcome === "tools" && !abort.signal.aborted,
|
|
5384
5428
|
stop: inferStop(abort.signal.reason, allowance, budget, this.#provider.id, final)
|
|
5385
5429
|
};
|
|
5386
5430
|
}
|
|
@@ -5620,8 +5664,7 @@ var Agent = class {
|
|
|
5620
5664
|
return AbortSignal.any(signals);
|
|
5621
5665
|
}
|
|
5622
5666
|
};
|
|
5623
|
-
|
|
5624
|
-
//#region src/core/agents/AgentFanout.ts
|
|
5667
|
+
// src/core/agents/AgentFanout.ts
|
|
5625
5668
|
/**
|
|
5626
5669
|
* Executes one runner's agent jobs — spawning each unit's declared children on its first attempt
|
|
5627
5670
|
* only, then rehydrating the unit through a registry with the controller signal and settling it
|
|
@@ -5679,8 +5722,7 @@ var AgentFanout = class {
|
|
|
5679
5722
|
return settleAgentJob(this.#registry.build(controller.input, controller.signal), this.#partial);
|
|
5680
5723
|
}
|
|
5681
5724
|
};
|
|
5682
|
-
|
|
5683
|
-
//#region src/core/agents/Authority.ts
|
|
5725
|
+
// src/core/agents/Authority.ts
|
|
5684
5726
|
/**
|
|
5685
5727
|
* Gates the agent loop's tool calls — the synchronous policy consulted before each call runs,
|
|
5686
5728
|
* turning one {@link AuthorityContext} into an {@link AuthorityDecision} by walking the ordered
|
|
@@ -5734,8 +5776,7 @@ var Authority = class {
|
|
|
5734
5776
|
return this.#fallback;
|
|
5735
5777
|
}
|
|
5736
5778
|
};
|
|
5737
|
-
|
|
5738
|
-
//#region src/core/agents/AgentRegistry.ts
|
|
5779
|
+
// src/core/agents/AgentRegistry.ts
|
|
5739
5780
|
/**
|
|
5740
5781
|
* Makes a durable, JSON-serializable {@link AgentJobInput} runnable — holds the named pools of
|
|
5741
5782
|
* live, non-serializable pieces (providers, tools, authorities, schedulers), throws on a name
|
|
@@ -5822,8 +5863,7 @@ var AgentRegistry = class {
|
|
|
5822
5863
|
return manager;
|
|
5823
5864
|
}
|
|
5824
5865
|
};
|
|
5825
|
-
|
|
5826
|
-
//#region src/core/agents/factories.ts
|
|
5866
|
+
// src/core/agents/factories.ts
|
|
5827
5867
|
/**
|
|
5828
5868
|
* Creates an agent loop — an {@link AgentInterface} composing a
|
|
5829
5869
|
* {@link ProviderInterface}, its {@link AgentContextInterface}, and a tool registry
|
|
@@ -6058,8 +6098,7 @@ function createAgentRunner(options) {
|
|
|
6058
6098
|
handler: fanout.execute.bind(fanout)
|
|
6059
6099
|
});
|
|
6060
6100
|
}
|
|
6061
|
-
|
|
6062
|
-
//#region src/core/ledgers/constants.ts
|
|
6101
|
+
// src/core/ledgers/constants.ts
|
|
6063
6102
|
/**
|
|
6064
6103
|
* Lists the categories the ledger files a message under, in the order the category question
|
|
6065
6104
|
* names them — the one list the {@link LedgerCategory} union derives from.
|
|
@@ -6162,8 +6201,7 @@ var DEFAULT_RECALL_LIMIT = 2;
|
|
|
6162
6201
|
var LEDGER_SCALE_DRIFT = .06;
|
|
6163
6202
|
/** Matches the logprob decoding failure `invalid or duplicate top logprob token`, which the ledger holds for the ledger's life. */
|
|
6164
6203
|
var DETERMINISTIC_JUDGE_ERROR = /invalid or duplicate top logprob token/;
|
|
6165
|
-
|
|
6166
|
-
//#region src/core/ledgers/errors.ts
|
|
6204
|
+
// src/core/ledgers/errors.ts
|
|
6167
6205
|
/**
|
|
6168
6206
|
* Reports an invalid ledger configuration, failed calibration, or unowned request selection,
|
|
6169
6207
|
* carrying the machine-readable `code`.
|
|
@@ -6187,11 +6225,12 @@ var LedgerError = class extends Error {
|
|
|
6187
6225
|
constructor(code, message) {
|
|
6188
6226
|
super(message);
|
|
6189
6227
|
this.name = "LedgerError";
|
|
6228
|
+
INTRINSICS.define(this, Symbol.for("@orkestrel/agent.LedgerError"), { value: this });
|
|
6190
6229
|
this.code = code;
|
|
6191
6230
|
}
|
|
6192
6231
|
};
|
|
6193
6232
|
/**
|
|
6194
|
-
* Narrows an unknown caught value to a {@link LedgerError} through
|
|
6233
|
+
* Narrows an unknown caught value to a {@link LedgerError} through its identity brand and declared members, so a `catch` can
|
|
6195
6234
|
* branch on its `code`.
|
|
6196
6235
|
*
|
|
6197
6236
|
* @param value - The value to test (typically a `catch` binding)
|
|
@@ -6203,17 +6242,21 @@ var LedgerError = class extends Error {
|
|
|
6203
6242
|
* ```
|
|
6204
6243
|
*/
|
|
6205
6244
|
function isLedgerError(value) {
|
|
6206
|
-
return
|
|
6245
|
+
return holds(() => {
|
|
6246
|
+
if (!(value instanceof Error && INTRINSICS.prototype(value) !== Error.prototype && INTRINSICS.describe(value, Symbol.for("@orkestrel/agent.LedgerError"))?.value === value)) return false;
|
|
6247
|
+
const code = INTRINSICS.reflect.read(value, "code");
|
|
6248
|
+
if (!(code === "REQUEST" || code === "THRESHOLD" || code === "SHARE" || code === "CAPACITY" || code === "LIMIT" || code === "TOPIC" || code === "LOOKUP" || code === "GAUGE" || code === "REFERENCE")) return false;
|
|
6249
|
+
return true;
|
|
6250
|
+
});
|
|
6207
6251
|
}
|
|
6208
|
-
|
|
6209
|
-
//#region src/core/ledgers/helpers.ts
|
|
6252
|
+
// src/core/ledgers/helpers.ts
|
|
6210
6253
|
/**
|
|
6211
6254
|
* Collects the live message ids placed in records or left without a record.
|
|
6212
6255
|
* @param projection - The projected records and unplaced ids
|
|
6213
6256
|
* @returns The distinct live message ids
|
|
6214
6257
|
* @example
|
|
6215
6258
|
* ```ts
|
|
6216
|
-
* collectProjectionIds({ records: [],
|
|
6259
|
+
* collectProjectionIds({ records: [], amendments: [], orphans: ['message-1'] }) // Set { 'message-1' }
|
|
6217
6260
|
* ```
|
|
6218
6261
|
*/
|
|
6219
6262
|
function collectProjectionIds(projection) {
|
|
@@ -6652,8 +6695,8 @@ function matchEntities(registry, text, partial) {
|
|
|
6652
6695
|
* argument. A message that names no owner joins where its earlier side of an amendment pair joins,
|
|
6653
6696
|
* or on the rules record when it is filed as a rule or a correction, and is an orphan otherwise.
|
|
6654
6697
|
*
|
|
6655
|
-
*
|
|
6656
|
-
* that is itself
|
|
6698
|
+
* Every live sentence is retained. Accepted direct edges are listed in `amendments`. An amending message
|
|
6699
|
+
* that is itself superseded retains its accepted edge without restoring its text.
|
|
6657
6700
|
*
|
|
6658
6701
|
* A sentence that opens with a pronoun takes the party named in the sentence before it. The reading
|
|
6659
6702
|
* trusts capitals, so a capitalized word that is no person, such as a carrier named mid-sentence,
|
|
@@ -6661,7 +6704,7 @@ function matchEntities(registry, text, partial) {
|
|
|
6661
6704
|
* the follow-up facts the records exist for.
|
|
6662
6705
|
*
|
|
6663
6706
|
* @param input - The messages, readings, entities, and classification to project
|
|
6664
|
-
* @returns The records with owner records ordered by their first member and the rules record last, the
|
|
6707
|
+
* @returns The records with owner records ordered by their first member and the rules record last, the accepted amendments, and the live message ids no record placed
|
|
6665
6708
|
*
|
|
6666
6709
|
* @example
|
|
6667
6710
|
* ```ts
|
|
@@ -6686,8 +6729,7 @@ function buildRecords(input) {
|
|
|
6686
6729
|
earlier,
|
|
6687
6730
|
later
|
|
6688
6731
|
}))), (pair) => pair.later)].map(([later, pairs]) => [later, pairs.map((pair) => pair.earlier)]));
|
|
6689
|
-
const
|
|
6690
|
-
const dead = new Set(stale.map((entry) => `${entry.source} ${entry.sentence}`));
|
|
6732
|
+
const amendments = collectAmendments(input, byId, live);
|
|
6691
6733
|
const holders = [...input.owners.values()].flat();
|
|
6692
6734
|
const system = collectNames(input.system);
|
|
6693
6735
|
const settled = /* @__PURE__ */ new Map();
|
|
@@ -6702,7 +6744,7 @@ function buildRecords(input) {
|
|
|
6702
6744
|
id
|
|
6703
6745
|
}))), (entry) => entry.key)].map(([key, entries]) => {
|
|
6704
6746
|
const ids = entries.map((entry) => entry.id);
|
|
6705
|
-
const lines = ids.flatMap((id) => buildLines(input, byId, id,
|
|
6747
|
+
const lines = ids.flatMap((id) => buildLines(input, byId, id, holders, system));
|
|
6706
6748
|
const owner = key.slice(LEDGER_OWNER_PREFIX.length);
|
|
6707
6749
|
const holder = input.owners.get(owner)?.[0];
|
|
6708
6750
|
const title = key === "rules" ? "Rules" : holder === void 0 ? `account ${owner}` : `${holder} (account ${owner})`;
|
|
@@ -6716,17 +6758,19 @@ function buildRecords(input) {
|
|
|
6716
6758
|
}
|
|
6717
6759
|
};
|
|
6718
6760
|
}).sort((left, right) => Number(left.record.key === "rules") - Number(right.record.key === "rules") || left.first - right.first || (left.record.key < right.record.key ? -1 : left.record.key > right.record.key ? 1 : 0)).map(({ record }) => record),
|
|
6719
|
-
|
|
6761
|
+
amendments,
|
|
6720
6762
|
orphans
|
|
6721
6763
|
};
|
|
6722
6764
|
}
|
|
6723
6765
|
/**
|
|
6724
|
-
* Selects a request's
|
|
6766
|
+
* Selects a request's records, collapsing owners with equal ordered member ids under titles joined with `; `.
|
|
6725
6767
|
*
|
|
6726
6768
|
* @remarks
|
|
6727
6769
|
* The view holds the owner records the request names in the order it names them, then the rules
|
|
6728
6770
|
* record with the lines whose topics meet the request's first, each group in position order. The
|
|
6729
|
-
* returned records and lines are copies.
|
|
6771
|
+
* returned records and lines are copies. Owner records with the same member ids in the same order
|
|
6772
|
+
* collapse into the first requested record, keeping its key, members, and lines and joining their
|
|
6773
|
+
* titles with `; ` before trimming.
|
|
6730
6774
|
*
|
|
6731
6775
|
* @param projection - The output of {@link buildRecords}
|
|
6732
6776
|
* @param request - The owners and the desk topics the request names
|
|
@@ -6742,10 +6786,14 @@ function selectRecords(projection, request) {
|
|
|
6742
6786
|
const topics = new Set(request.topics);
|
|
6743
6787
|
const rules = projection.records.find((one) => one.key === LEDGER_RULES_KEY);
|
|
6744
6788
|
const sides = Map.groupBy((rules?.lines ?? []).filter(() => true), (line) => line.topics.some((topic) => topics.has(topic)));
|
|
6745
|
-
|
|
6789
|
+
const owners = [...new Set(request.owners)].flatMap((owner) => {
|
|
6746
6790
|
const record = projection.records.find((one) => one.key === `${LEDGER_OWNER_PREFIX}${owner}`);
|
|
6747
|
-
return record === void 0 ? [] : [
|
|
6748
|
-
})
|
|
6791
|
+
return record === void 0 ? [] : [record];
|
|
6792
|
+
});
|
|
6793
|
+
return [...[...Map.groupBy(owners, (record) => JSON.stringify(record.members)).values()].flatMap(([record, ...rest]) => record === void 0 ? [] : [structuredClone({
|
|
6794
|
+
...record,
|
|
6795
|
+
title: [record.title, ...rest.map((one) => one.title)].join("; ")
|
|
6796
|
+
})]), ...rules === void 0 ? [] : [structuredClone({
|
|
6749
6797
|
...rules,
|
|
6750
6798
|
lines: [...sides.get(true) ?? [], ...sides.get(false) ?? []]
|
|
6751
6799
|
})]];
|
|
@@ -6757,6 +6805,7 @@ function selectRecords(projection, request) {
|
|
|
6757
6805
|
* The briefing joins rendered records with one blank line.
|
|
6758
6806
|
*
|
|
6759
6807
|
* @param record - A record or view with a `title` and `lines`
|
|
6808
|
+
* @param context - Rendering facts for optional accepted amendment annotations
|
|
6760
6809
|
* @returns `## TITLE` followed by `- LINE` for each line
|
|
6761
6810
|
*
|
|
6762
6811
|
* @example
|
|
@@ -6765,13 +6814,14 @@ function selectRecords(projection, request) {
|
|
|
6765
6814
|
* // '## Rules\n- Refunds need a manager.'
|
|
6766
6815
|
* ```
|
|
6767
6816
|
*/
|
|
6768
|
-
function renderLedgerRecord(record) {
|
|
6769
|
-
return [`## ${record.title}`, ...record.lines.
|
|
6817
|
+
function renderLedgerRecord(record, context) {
|
|
6818
|
+
return [`## ${record.title}`, ...record.lines.flatMap((line) => [context === void 0 ? "" : renderLedgerAnnotation(line, context), `- ${line.text}`].filter((text) => text !== ""))].join("\n");
|
|
6770
6819
|
}
|
|
6771
6820
|
/**
|
|
6772
6821
|
* Renders one owner record under a `###` heading, which the briefing nests under its one `## Pinned` heading.
|
|
6773
6822
|
*
|
|
6774
6823
|
* @param record - An owner record or view with a `title` and `lines`
|
|
6824
|
+
* @param context - Rendering facts for optional accepted amendment annotations
|
|
6775
6825
|
* @returns `### TITLE` followed by `- LINE` for each line
|
|
6776
6826
|
*
|
|
6777
6827
|
* @example
|
|
@@ -6779,8 +6829,57 @@ function renderLedgerRecord(record) {
|
|
|
6779
6829
|
* renderLedgerPinned({ title: 'Odile Marlow (account OM-30418)', lines: [] }) // '### Odile Marlow (account OM-30418)'
|
|
6780
6830
|
* ```
|
|
6781
6831
|
*/
|
|
6782
|
-
function renderLedgerPinned(record) {
|
|
6783
|
-
return `#${renderLedgerRecord(record)}`;
|
|
6832
|
+
function renderLedgerPinned(record, context) {
|
|
6833
|
+
return `#${renderLedgerRecord(record, context)}`;
|
|
6834
|
+
}
|
|
6835
|
+
/**
|
|
6836
|
+
* Derives complete source identities, first occurrences, and local references from the actual briefing lines.
|
|
6837
|
+
* @param messages - Original messages whose indexed sentences establish completeness
|
|
6838
|
+
* @param lines - Retained lines in rendering order after deduplication and trimming
|
|
6839
|
+
* @param amendments - Accepted direct message amendment edges
|
|
6840
|
+
* @returns Immutable rendering facts for this retained population
|
|
6841
|
+
*
|
|
6842
|
+
* @example
|
|
6843
|
+
* ```ts
|
|
6844
|
+
* buildLedgerRenderContext([], [], []).complete.size // 0
|
|
6845
|
+
* ```
|
|
6846
|
+
*/
|
|
6847
|
+
function buildLedgerRenderContext(messages, lines, amendments) {
|
|
6848
|
+
const identities = new Set(lines.map((line) => `${line.source} ${line.sentence}`));
|
|
6849
|
+
return {
|
|
6850
|
+
amendments,
|
|
6851
|
+
complete: new Set(messages.filter((message) => {
|
|
6852
|
+
const sentences = splitSentences(message.content);
|
|
6853
|
+
return sentences.length > 0 && sentences.every((_, index) => identities.has(`${message.id} ${index}`));
|
|
6854
|
+
}).map((message) => message.id)),
|
|
6855
|
+
first: new Map(lines.toReversed().map((line) => [line.source, line])),
|
|
6856
|
+
references: new Map([...new Set(lines.map((line) => line.source))].map((source, index) => [source, String(index + 1)]))
|
|
6857
|
+
};
|
|
6858
|
+
}
|
|
6859
|
+
/**
|
|
6860
|
+
* Renders source framing and unresolved amendment scope at a source's first retained line.
|
|
6861
|
+
* @param line - The retained occurrence to annotate
|
|
6862
|
+
* @param context - Actual complete sources, first occurrences, local references, and accepted amendment edges
|
|
6863
|
+
* @returns Source framing and truthful inclusion notes, or empty text for an unrelated or repeated occurrence
|
|
6864
|
+
* @throws {LedgerError} Thrown when the context holds no reference for the annotated source or a fully included amender (code `'REQUEST'`)
|
|
6865
|
+
*
|
|
6866
|
+
* @example
|
|
6867
|
+
* ```ts
|
|
6868
|
+
* renderLedgerAnnotation({ text: 'Unchanged.', source: 'user-1', sentence: 0, topics: [], role: 'user' }, buildLedgerRenderContext([], [], [])) // ''
|
|
6869
|
+
* ```
|
|
6870
|
+
*/
|
|
6871
|
+
function renderLedgerAnnotation(line, context) {
|
|
6872
|
+
if (context.first.get(line.source) !== line) return "";
|
|
6873
|
+
const amendments = context.amendments.filter((pair) => pair.earlier === line.source);
|
|
6874
|
+
const endpoint = context.complete.has(line.source) && context.amendments.some((pair) => pair.later === line.source && context.first.has(pair.earlier));
|
|
6875
|
+
if (amendments.length === 0 && !endpoint) return "";
|
|
6876
|
+
const included = amendments.filter((pair) => context.complete.has(pair.later));
|
|
6877
|
+
if (context.references.get(line.source) === void 0 || included.some((pair) => context.references.get(pair.later) === void 0)) throw new LedgerError("REFERENCE", "Ledger rendering requires retained source references");
|
|
6878
|
+
return [
|
|
6879
|
+
`[Ledger source ${context.references.get(line.source)}]`,
|
|
6880
|
+
...included.map((pair) => `Accepted later amendment [Ledger source ${context.references.get(pair.later)}] is fully included in this briefing. Sentence scope is unresolved.`),
|
|
6881
|
+
...amendments.some((pair) => !context.complete.has(pair.later)) ? ["Accepted later amendment text is not fully included in this briefing. Sentence scope is unresolved."] : []
|
|
6882
|
+
].join("\n");
|
|
6784
6883
|
}
|
|
6785
6884
|
/**
|
|
6786
6885
|
* Splits a recall topic at its joints.
|
|
@@ -6976,74 +7075,62 @@ function placeMember(input, links, amending, id, seen, settled) {
|
|
|
6976
7075
|
return keys;
|
|
6977
7076
|
}
|
|
6978
7077
|
/**
|
|
6979
|
-
* Collects
|
|
7078
|
+
* Collects accepted direct amendments of live messages.
|
|
6980
7079
|
*
|
|
6981
7080
|
* @remarks
|
|
6982
|
-
*
|
|
6983
|
-
*
|
|
6984
|
-
*
|
|
6985
|
-
* input excludes or files quiet never takes effect.
|
|
7081
|
+
* An accepted edge relates an earlier live message to an amender without claiming which sentences
|
|
7082
|
+
* changed. An amender takes effect while live and retains its edge after another message supersedes
|
|
7083
|
+
* it, without restoring the superseded text. An excluded or quiet user or tool message has no effect.
|
|
6986
7084
|
*
|
|
6987
7085
|
* @param input - The exclusions and classification to read
|
|
6988
7086
|
* @param byId - The messages by id
|
|
6989
7087
|
* @param live - The live message ids from {@link collectLive}
|
|
6990
|
-
* @returns The
|
|
7088
|
+
* @returns The distinct accepted direct edges in conversation order
|
|
6991
7089
|
*
|
|
6992
7090
|
* @example
|
|
6993
7091
|
* ```ts
|
|
6994
|
-
*
|
|
7092
|
+
* collectAmendments(input, byId, ['user-1', 'user-3']) // [{ earlier: 'user-1', later: 'user-3' }]
|
|
6995
7093
|
* ```
|
|
6996
7094
|
*/
|
|
6997
|
-
function
|
|
7095
|
+
function collectAmendments(input, byId, live) {
|
|
6998
7096
|
const { classification } = input;
|
|
6999
7097
|
const excluded = new Set(input.exclusions);
|
|
7098
|
+
const living = new Set(live);
|
|
7099
|
+
const ordered = [...new Set(input.messages.map((message) => message.id))];
|
|
7100
|
+
const positions = new Map(ordered.map((id, index) => [id, index]));
|
|
7000
7101
|
const effective = /* @__PURE__ */ new Set([...live, ...[...byId.values()].filter((message) => message.role !== "assistant" && !excluded.has(message.id) && !classification.quiet.has(message.id) && (classification.supersessions.get(message.id) ?? []).length > 0).map((message) => message.id)]);
|
|
7001
|
-
return
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
});
|
|
7006
|
-
if (laters.length === 0) return [];
|
|
7007
|
-
return splitSentences(byId.get(id)?.content ?? "").flatMap((text, sentence) => {
|
|
7008
|
-
const own = extractTokens(text);
|
|
7009
|
-
const tokens = new Set(laters.flatMap((other) => [...[...own.ids].filter((token) => other.ids.has(token)), ...[...own.numbers].filter((token) => other.numbers.has(token)).map(String)]));
|
|
7010
|
-
return tokens.size > 0 ? [{
|
|
7011
|
-
source: id,
|
|
7012
|
-
sentence,
|
|
7013
|
-
tokens: [...tokens]
|
|
7014
|
-
}] : [];
|
|
7015
|
-
});
|
|
7016
|
-
});
|
|
7102
|
+
return ordered.filter((id) => living.has(id)).flatMap((earlier) => [...new Set(classification.amendments.get(earlier) ?? [])].filter((later) => effective.has(later) && positions.has(later)).sort((a, b) => (positions.get(a) ?? 0) - (positions.get(b) ?? 0)).map((later) => ({
|
|
7103
|
+
earlier,
|
|
7104
|
+
later
|
|
7105
|
+
})));
|
|
7017
7106
|
}
|
|
7018
7107
|
/**
|
|
7019
7108
|
* Builds the record lines of one message.
|
|
7020
7109
|
*
|
|
7021
7110
|
* @remarks
|
|
7022
|
-
* Each
|
|
7111
|
+
* Each original indexed sentence becomes a line. A sentence that opens with a pronoun and follows
|
|
7023
7112
|
* another sentence takes the last name of the sentence before it that is neither an owner name nor
|
|
7024
7113
|
* a system name, and its line text opens with that party and a colon.
|
|
7025
7114
|
*
|
|
7026
7115
|
* @param input - The classification whose topics the lines carry
|
|
7027
7116
|
* @param byId - The messages by id
|
|
7028
7117
|
* @param id - The message id
|
|
7029
|
-
* @param dead - The stale sentences as `SOURCE SENTENCE` keys
|
|
7030
7118
|
* @param holders - The owner names, which never serve as a party
|
|
7031
7119
|
* @param system - The system text's names, which never serve as a party
|
|
7032
7120
|
* @returns The lines in sentence order; empty when the message is absent
|
|
7033
7121
|
*
|
|
7034
7122
|
* @example
|
|
7035
7123
|
* ```ts
|
|
7036
|
-
* buildLines(input, byId, 'user-1',
|
|
7124
|
+
* buildLines(input, byId, 'user-1', [], []).map((line) => line.text)
|
|
7037
7125
|
* // ['Odile Marlow phoned about BW-5512.', 'Odile Marlow: She wants a refund.']
|
|
7038
7126
|
* ```
|
|
7039
7127
|
*/
|
|
7040
|
-
function buildLines(input, byId, id,
|
|
7128
|
+
function buildLines(input, byId, id, holders, system) {
|
|
7041
7129
|
const message = byId.get(id);
|
|
7042
7130
|
if (message === void 0) return [];
|
|
7043
7131
|
const sentences = splitSentences(message.content);
|
|
7044
7132
|
const topics = input.classification.topics.get(id) ?? [];
|
|
7045
7133
|
return sentences.flatMap((sentence, at) => {
|
|
7046
|
-
if (dead.has(`${id} ${at}`)) return [];
|
|
7047
7134
|
const party = /^(?:He|She|They|His|Her|Their)(?![\p{L}\p{N}])/u.test(sentence) && at > 0 ? collectNames(sentences[at - 1] ?? "").filter((name) => !holders.includes(name) && !system.includes(name)).at(-1) : void 0;
|
|
7048
7135
|
const line = {
|
|
7049
7136
|
text: party === void 0 ? sentence : `${party}: ${sentence}`,
|
|
@@ -7058,8 +7145,7 @@ function buildLines(input, byId, id, dead, holders, system) {
|
|
|
7058
7145
|
}];
|
|
7059
7146
|
});
|
|
7060
7147
|
}
|
|
7061
|
-
|
|
7062
|
-
//#region src/core/ledgers/Classifier.ts
|
|
7148
|
+
// src/core/ledgers/Classifier.ts
|
|
7063
7149
|
/**
|
|
7064
7150
|
* Files messages through the conversation's judgment manager and reads their categories and corrections.
|
|
7065
7151
|
*
|
|
@@ -7345,8 +7431,7 @@ var Classifier = class {
|
|
|
7345
7431
|
}
|
|
7346
7432
|
}
|
|
7347
7433
|
};
|
|
7348
|
-
|
|
7349
|
-
//#region src/core/ledgers/validators.ts
|
|
7434
|
+
// src/core/ledgers/validators.ts
|
|
7350
7435
|
/**
|
|
7351
7436
|
* Checks whether a value is finite and lies in the interval (0, 1].
|
|
7352
7437
|
* @param value - The value to inspect
|
|
@@ -7371,8 +7456,7 @@ function isFraction(value) {
|
|
|
7371
7456
|
function isPositiveSafeInteger(value) {
|
|
7372
7457
|
return isFiniteNumber(value) && Number.isSafeInteger(value) && value > 0;
|
|
7373
7458
|
}
|
|
7374
|
-
|
|
7375
|
-
//#region src/core/ledgers/Gauge.ts
|
|
7459
|
+
// src/core/ledgers/Gauge.ts
|
|
7376
7460
|
/**
|
|
7377
7461
|
* Prices prompts in tokens from a measured scale and overhead cost, and measures the room a request
|
|
7378
7462
|
* has left.
|
|
@@ -7465,8 +7549,7 @@ var Gauge = class {
|
|
|
7465
7549
|
if (isFiniteNumber(reply?.completion)) this.#reply = Math.max(this.#reply, reply.completion - (reply.thinking ?? 0));
|
|
7466
7550
|
}
|
|
7467
7551
|
};
|
|
7468
|
-
|
|
7469
|
-
//#region src/core/ledgers/LedgerPass.ts
|
|
7552
|
+
// src/core/ledgers/LedgerPass.ts
|
|
7470
7553
|
/**
|
|
7471
7554
|
* Holds what one pass of a ledger request keeps: the selection its run adopted last, the
|
|
7472
7555
|
* conversation boundary its calls count additions from, its summed usage, and its gauge calls.
|
|
@@ -7610,8 +7693,7 @@ var LedgerPass = class {
|
|
|
7610
7693
|
this.#log = [...this.#log, { thinking }];
|
|
7611
7694
|
}
|
|
7612
7695
|
};
|
|
7613
|
-
|
|
7614
|
-
//#region src/core/ledgers/LedgerRequest.ts
|
|
7696
|
+
// src/core/ledgers/LedgerRequest.ts
|
|
7615
7697
|
/**
|
|
7616
7698
|
* Holds what one ledger request keeps while it is served: its message, its filing readings and
|
|
7617
7699
|
* plan, the gauge calls of its passes, and its repeat and recall stops.
|
|
@@ -7764,8 +7846,7 @@ var LedgerRequest = class {
|
|
|
7764
7846
|
return this.#listings.get(result);
|
|
7765
7847
|
}
|
|
7766
7848
|
};
|
|
7767
|
-
|
|
7768
|
-
//#region src/core/ledgers/Ledger.ts
|
|
7849
|
+
// src/core/ledgers/Ledger.ts
|
|
7769
7850
|
/**
|
|
7770
7851
|
* Serves one conversation through classified records, a bounded briefing, and a final answer pass.
|
|
7771
7852
|
* @example
|
|
@@ -8123,17 +8204,17 @@ var Ledger = class {
|
|
|
8123
8204
|
projection: buildRecords(input)
|
|
8124
8205
|
};
|
|
8125
8206
|
}
|
|
8126
|
-
#projectLines(input,
|
|
8127
|
-
return buildLines(input, new Map(input.messages.map((message) => [message.id, message])), id,
|
|
8207
|
+
#projectLines(input, id) {
|
|
8208
|
+
return buildLines(input, new Map(input.messages.map((message) => [message.id, message])), id, [...input.owners.values()].flat(), collectNames(this.#options.system));
|
|
8128
8209
|
}
|
|
8129
|
-
#renderSource(id, lines) {
|
|
8210
|
+
#renderSource(id, lines, context) {
|
|
8130
8211
|
const message = this.#conversation.message(id);
|
|
8131
8212
|
if (message === void 0) return "";
|
|
8132
8213
|
const sentences = splitSentences(message.content);
|
|
8133
|
-
const text = sentences.
|
|
8134
|
-
if (text === ""
|
|
8214
|
+
const text = sentences.every((_, index) => lines.some((line) => line.sentence === index)) ? message.content : lines.map((line) => sentences[line.sentence] ?? "").join(" ");
|
|
8215
|
+
if (text === "") return "";
|
|
8135
8216
|
const reading = this.#readLookups().find((one) => one.id === id);
|
|
8136
|
-
return reading === void 0 ? text : `${renderLookupCall(reading.name, reading.arguments)}: ${text}
|
|
8217
|
+
return [...lines.map((line) => renderLedgerAnnotation(line, context)), message.role !== "tool" || reading === void 0 ? text : `${renderLookupCall(reading.name, reading.arguments)}: ${text}`].filter((part) => part !== "").join("\n");
|
|
8137
8218
|
}
|
|
8138
8219
|
#collectAfter(request) {
|
|
8139
8220
|
const messages = this.#conversation.messages();
|
|
@@ -8216,7 +8297,7 @@ var Ledger = class {
|
|
|
8216
8297
|
const score = [...words].filter((word) => asked?.words.has(word)).reduce((sum, word) => sum + Math.log(texts.length / (counts.get(word) ?? 1)), 0);
|
|
8217
8298
|
return [{
|
|
8218
8299
|
source: message.id,
|
|
8219
|
-
lines: this.#projectLines(input,
|
|
8300
|
+
lines: this.#projectLines(input, message.id),
|
|
8220
8301
|
position,
|
|
8221
8302
|
group,
|
|
8222
8303
|
ruled,
|
|
@@ -8250,7 +8331,7 @@ var Ledger = class {
|
|
|
8250
8331
|
source: unit.source,
|
|
8251
8332
|
record: this.#buildUnitRecord(unit.source, unit.category, input, projection, held)
|
|
8252
8333
|
}));
|
|
8253
|
-
const trimmed = this.#trim(steps, records, mapped, new Set(ordered.map((unit) => unit.source)), cap);
|
|
8334
|
+
const trimmed = this.#trim(steps, records, mapped, new Set(ordered.map((unit) => unit.source)), cap, projection.amendments);
|
|
8254
8335
|
const briefing = trimmed.briefing;
|
|
8255
8336
|
const shown = /* @__PURE__ */ new Set([...trimmed.included, ...records.flatMap((record) => record.members.filter((source) => {
|
|
8256
8337
|
const full = record.lines.filter((line) => line.source === source);
|
|
@@ -8262,10 +8343,10 @@ var Ledger = class {
|
|
|
8262
8343
|
...briefing === "" ? {} : { briefing }
|
|
8263
8344
|
};
|
|
8264
8345
|
}
|
|
8265
|
-
#trim(steps, records, mapped, included, cap) {
|
|
8346
|
+
#trim(steps, records, mapped, included, cap, amendments) {
|
|
8266
8347
|
const trimmed = steps.reduce((cut, step) => {
|
|
8267
8348
|
if (cut.briefing !== void 0) return cut;
|
|
8268
|
-
const briefing = this.#render(cut.records, mapped, cut.included);
|
|
8349
|
+
const briefing = this.#render(cut.records, mapped, cut.included, amendments);
|
|
8269
8350
|
const content = [this.#options.system, briefing].filter((part) => part !== "").join("\n\n");
|
|
8270
8351
|
if (this.#price([{
|
|
8271
8352
|
id: "system",
|
|
@@ -8291,7 +8372,7 @@ var Ledger = class {
|
|
|
8291
8372
|
return {
|
|
8292
8373
|
records: trimmed.records,
|
|
8293
8374
|
included: trimmed.included,
|
|
8294
|
-
briefing: trimmed.briefing ?? this.#render(trimmed.records, mapped, trimmed.included)
|
|
8375
|
+
briefing: trimmed.briefing ?? this.#render(trimmed.records, mapped, trimmed.included, amendments)
|
|
8295
8376
|
};
|
|
8296
8377
|
}
|
|
8297
8378
|
#buildUnitRecord(source, category, input, projection, held) {
|
|
@@ -8304,25 +8385,33 @@ var Ledger = class {
|
|
|
8304
8385
|
}
|
|
8305
8386
|
#collectAmended(input, projection, source, held) {
|
|
8306
8387
|
const live = collectProjectionIds(projection);
|
|
8307
|
-
return scanAmendments(input.classification.amendments, source, (id) => id === source || !held.has(id) && live.has(id)).flatMap((id) => this.#projectLines(input,
|
|
8388
|
+
return scanAmendments(input.classification.amendments, source, (id) => id === source || !held.has(id) && live.has(id)).flatMap((id) => this.#projectLines(input, id));
|
|
8308
8389
|
}
|
|
8309
|
-
#render(records, mapped, included) {
|
|
8310
|
-
const owners = records.filter((record) => record.key !== "rules" && record.lines.length > 0).map(renderLedgerPinned).join("\n\n");
|
|
8390
|
+
#render(records, mapped, included, amendments) {
|
|
8311
8391
|
const entries = mapped.filter((unit) => included.has(unit.source)).flatMap(({ record: unit }) => [...Map.groupBy(unit.lines, (line) => line.source)].map(([source, lines]) => ({
|
|
8312
8392
|
unit,
|
|
8313
8393
|
source,
|
|
8314
8394
|
lines
|
|
8315
8395
|
})));
|
|
8316
8396
|
const first = new Map(entries.toReversed().map((entry) => [entry.source, entry]));
|
|
8317
|
-
const
|
|
8397
|
+
const unique = entries.filter((entry) => first.get(entry.source) === entry);
|
|
8398
|
+
const record = records.find((candidate) => candidate.key === "rules" && candidate.lines.length > 0);
|
|
8399
|
+
const ownerRecords = records.filter((candidate) => candidate.key !== "rules" && candidate.lines.length > 0);
|
|
8400
|
+
const context = buildLedgerRenderContext(this.#conversation.messages(), [
|
|
8401
|
+
...ownerRecords.flatMap((candidate) => candidate.lines),
|
|
8402
|
+
...unique.filter((entry) => entry.unit.key !== LEDGER_RULES_KEY).flatMap((entry) => entry.lines),
|
|
8403
|
+
...record?.lines ?? [],
|
|
8404
|
+
...unique.filter((entry) => entry.unit.key === LEDGER_RULES_KEY).flatMap((entry) => entry.lines)
|
|
8405
|
+
], amendments);
|
|
8406
|
+
const owners = ownerRecords.map((owner) => renderLedgerPinned(owner, context)).join("\n\n");
|
|
8407
|
+
const rendered = unique.map(({ unit, source, lines }) => ({
|
|
8318
8408
|
rules: unit.key === LEDGER_RULES_KEY,
|
|
8319
|
-
texts: unit.key === "rules" && source === unit.members[0] ? lines.map((line) => this.#renderSource(source, [line])) : [this.#renderSource(source, lines)]
|
|
8409
|
+
texts: unit.key === "rules" && source === unit.members[0] ? lines.map((line) => this.#renderSource(source, [line], context)) : [this.#renderSource(source, lines, context)]
|
|
8320
8410
|
}));
|
|
8321
8411
|
const pinned = rendered.filter((one) => !one.rules).flatMap((one) => one.texts);
|
|
8322
8412
|
const rules = rendered.filter((one) => one.rules).flatMap((one) => one.texts);
|
|
8323
8413
|
const body = [owners, pinned.join("\n")].filter((text) => text !== "").join("\n\n");
|
|
8324
|
-
|
|
8325
|
-
return [body === "" ? "" : `## Pinned\n${body}`, record === void 0 ? rules.length === 0 ? "" : ["## Rules", ...rules].join("\n") : [renderLedgerRecord(record), ...rules].join("\n")].filter((text) => text !== "").join("\n\n");
|
|
8414
|
+
return [body === "" ? "" : `## Pinned\n${body}`, record === void 0 ? rules.length === 0 ? "" : ["## Rules", ...rules].join("\n") : [renderLedgerRecord(record, context), ...rules].join("\n")].filter((text) => text !== "").join("\n\n");
|
|
8326
8415
|
}
|
|
8327
8416
|
#selectTail(request, cap, input) {
|
|
8328
8417
|
const first = input.messages.findIndex((message) => this.#requests.has(message.id));
|
|
@@ -8462,8 +8551,7 @@ var Ledger = class {
|
|
|
8462
8551
|
return lines.length === 0 ? void 0 : `${LEDGER_NOTES.results}\n${lines.join("\n")}`;
|
|
8463
8552
|
}
|
|
8464
8553
|
};
|
|
8465
|
-
|
|
8466
|
-
//#region src/core/ledgers/factories.ts
|
|
8554
|
+
// src/core/ledgers/factories.ts
|
|
8467
8555
|
/**
|
|
8468
8556
|
* Creates a conversation ledger after checking its thresholds, allocation, and tool names.
|
|
8469
8557
|
* @param provider - The provider that answers requests
|
|
@@ -8479,7 +8567,6 @@ var Ledger = class {
|
|
|
8479
8567
|
function createLedger(provider, options) {
|
|
8480
8568
|
return new Ledger(provider, options);
|
|
8481
8569
|
}
|
|
8482
|
-
|
|
8483
|
-
export { Agent, AgentContext, AgentError, AgentFanout, AgentJobError, AgentJudge, AgentProvider, AgentRegistry, Authority, CONVERSATION_RECAP_PREFIX, Channel, Classifier, Conversation, ConversationError, ConversationManager, DECISIVE_CATEGORIES, DEFAULT_AGENT_LIMIT, DEFAULT_AUTHORITY_ZONE, DEFAULT_CONVERSATION_KEEP, DEFAULT_LEDGER_LIMIT, DEFAULT_LEDGER_SHARE, DEFAULT_PROVIDER_TIMEOUT, DEFAULT_RECALL_LIMIT, DEFAULT_RELAY_LIMIT, DETERMINISTIC_JUDGE_ERROR, DatabaseConversationStore, Gauge, IMAGE_TOKEN_ESTIMATE, INVALID_RELAY_STATUS, Instruction, InstructionManager, JudgeAbortError, JudgeError, JudgmentManager, LEDGER_CATEGORIES, LEDGER_NOTES, LEDGER_OWNER_PREFIX, LEDGER_QUESTIONS, LEDGER_RULES_KEY, LEDGER_SCALE_DRIFT, Ledger, LedgerError, LedgerRequest, MAX_ERROR_BODY_LENGTH, MESSAGE_ROLES, MESSAGE_TOKEN_OVERHEAD, MemoryConversationStore, OVERSIZED_RELAY_STATUS, PLACED_CATEGORIES, ProviderAbortError, ProviderError, QUIET_CATEGORIES, RELAY_CONTENT_TYPE, RELAY_PROVIDER_MESSAGE, RelayProvider, RelayStream, SYSTEM_ONE_PATH, Scope, ScopeManager, SystemOneJudge, THINK_CLOSE, THINK_OPEN, ThinkSplitter, UNAUTHORIZED_RELAY_STATUS, UPSTREAM_RELAY_STATUS, WORKSPACE_SECTION_HEADER, agentResultToJSON, armReaderAbort, assembleResult, attachImages, attachUserImages, buildJudgeResult, buildJudgments, buildLines, buildProviderHeaders, buildProviderResult, buildRecallMessage, buildRecapMessage, buildRecords, buildSummaryMessage, chargeUsage, collectExchanges, collectImageData, collectLive, collectNames, collectProjectionIds, collectRegistry, collectStale, collectToolGroups, computeReading, computeThinking, copyJSON, createAgent, createAgentContext, createAgentQueue, createAgentRegistry, createAgentRunner, createAuthority, createChannel, createConversation, createConversationManager, createDatabaseConversationStore, createInstruction, createInstructionManager, createLedger, createMemoryConversationStore, createRelay, createRelayProvider, createScope, createScopeManager, createSystemOneJudge, createThinkSplitter, cutListing, denyCall, estimateMessages, estimateRequest, estimateTokens, extractQueueOptions, extractSystemOneAnswer, extractSystemOneUsage, extractTokens, extractWords, filterAllowList, findLedgerCall, fitSlope, handleAgentQueueJob, hasCalls, identifyLookup, inferStop, intersectKeys, isAgentError, isAgentJobError, isConversationError, isConversationSnapshot, isFraction, isJudgeAbortError, isJudgeEntry, isJudgeError, isJudgeQuestion, isJudgment, isLedgerError, isMessage, isNonNegativeSafeInteger, isPositiveSafeInteger, isProviderAbortError, isProviderError, isSection, isSystemOneAnswer, isSystemOneResponse, joinThinking, linkOwners, matchEntities, matchesCutLine, matchesJudgment, measureMessage, measureRequest, messageContract, messageShape, normalizeArgument, placeMember, providerRequestContract, providerRequestShape, providerResultContract, providerResultShape, questionToSystemOne, raceSignal, rankLedgerCut, readChunks, readFailure, readText, relayFrameContract, relayFrameShape, releaseReader, removeEntries, renderCauseChain, renderFencedFile, renderJSON, renderLedgerPinned, renderLedgerRecord, renderLookupCall, renderSection, renderStub, renderToolValue, renderTopicNames, requestToRelay, requireBudget, requireEntry, requireJudgment, requireKeep, requireLimit, requireRolling, requireSectionsCap, resolvePredict, sanitizeToken, sanitizeUsage, scanAmendments, selectRecords, settleAgentJob, splitResultLines, splitSentences, splitTopic, splitWords, stripThinking, sumUsage, tokenUsageToJSON, toolCallShape };
|
|
8570
|
+
export { Agent, AgentContext, AgentError, AgentFanout, AgentJobError, AgentJudge, AgentProvider, AgentRegistry, Authority, CONVERSATION_RECAP_PREFIX, Channel, Classifier, Conversation, ConversationError, ConversationManager, DECISIVE_CATEGORIES, DEFAULT_AGENT_LIMIT, DEFAULT_AUTHORITY_ZONE, DEFAULT_CONVERSATION_KEEP, DEFAULT_LEDGER_LIMIT, DEFAULT_LEDGER_SHARE, DEFAULT_PROVIDER_TIMEOUT, DEFAULT_RECALL_LIMIT, DEFAULT_RELAY_LIMIT, DETERMINISTIC_JUDGE_ERROR, DatabaseConversationStore, Gauge, IMAGE_TOKEN_ESTIMATE, INVALID_RELAY_STATUS, Instruction, InstructionManager, JudgeAbortError, JudgeError, JudgmentManager, LEDGER_CATEGORIES, LEDGER_NOTES, LEDGER_OWNER_PREFIX, LEDGER_QUESTIONS, LEDGER_RULES_KEY, LEDGER_SCALE_DRIFT, Ledger, LedgerError, LedgerRequest, MAX_ERROR_BODY_LENGTH, MESSAGE_ROLES, MESSAGE_TOKEN_OVERHEAD, MemoryConversationStore, OVERSIZED_RELAY_STATUS, PLACED_CATEGORIES, ProviderAbortError, ProviderError, QUIET_CATEGORIES, RELAY_CONTENT_TYPE, RELAY_PROVIDER_MESSAGE, RelayProvider, RelayStream, SYSTEM_ONE_PATH, Scope, ScopeManager, SystemOneJudge, THINK_CLOSE, THINK_OPEN, ThinkSplitter, UNAUTHORIZED_RELAY_STATUS, UPSTREAM_RELAY_STATUS, WORKSPACE_SECTION_HEADER, agentResultToJSON, armReaderAbort, assembleResult, attachImages, attachUserImages, buildJudgeResult, buildJudgments, buildLedgerRenderContext, buildLines, buildProviderHeaders, buildProviderResult, buildRecallMessage, buildRecapMessage, buildRecords, buildSummaryMessage, chargeUsage, collectAmendments, collectExchanges, collectImageData, collectLive, collectNames, collectProjectionIds, collectRegistry, collectToolGroups, computeReading, computeThinking, copyJSON, createAgent, createAgentContext, createAgentQueue, createAgentRegistry, createAgentRunner, createAuthority, createChannel, createConversation, createConversationManager, createDatabaseConversationStore, createInstruction, createInstructionManager, createLedger, createMemoryConversationStore, createRelay, createRelayProvider, createScope, createScopeManager, createSystemOneJudge, createThinkSplitter, cutListing, denyCall, estimateMessages, estimateRequest, estimateTokens, extractQueueOptions, extractSystemOneAnswer, extractSystemOneUsage, extractTokens, extractWords, filterAllowList, findLedgerCall, fitSlope, handleAgentQueueJob, hasCalls, identifyLookup, inferStop, intersectKeys, isAgentError, isAgentJobError, isConversationError, isConversationSnapshot, isFraction, isJudgeAbortError, isJudgeEntry, isJudgeError, isJudgeQuestion, isJudgment, isLedgerError, isMessage, isNonNegativeSafeInteger, isPositiveSafeInteger, isProviderAbortError, isProviderError, isSection, isSystemOneAnswer, isSystemOneResponse, joinThinking, linkOwners, matchEntities, matchesCutLine, matchesJudgment, measureMessage, measureRequest, messageContract, messageShape, normalizeArgument, placeMember, providerRequestContract, providerRequestShape, providerResultContract, providerResultShape, questionToSystemOne, raceSignal, rankLedgerCut, readChunks, readFailure, readText, relayFrameContract, relayFrameShape, releaseReader, removeEntries, renderCauseChain, renderFencedFile, renderJSON, renderLedgerAnnotation, renderLedgerPinned, renderLedgerRecord, renderLookupCall, renderSection, renderStub, renderToolValue, renderTopicNames, requestToRelay, requireBudget, requireEntry, requireJudgment, requireKeep, requireLimit, requireRolling, requireSectionsCap, resolvePredict, sanitizeToken, sanitizeUsage, scanAmendments, selectRecords, settleAgentJob, splitResultLines, splitSentences, splitTopic, splitWords, stripThinking, sumUsage, tokenUsageToJSON, toolCallShape };
|
|
8484
8571
|
|
|
8485
8572
|
//# sourceMappingURL=index.js.map
|