@capybara-hq/kernel 0.1.0-rc.29 → 0.1.0-rc.30
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/bootstrap.json +27 -27
- package/dist/admin/admin.schemas.d.ts +7 -0
- package/dist/config/schema.d.ts +0 -2
- package/dist/config/schema.js +0 -16
- package/dist/conversations/conversations.controller.d.ts +11 -1
- package/dist/conversations/conversations.controller.js +25 -1
- package/dist/conversations/conversations.schemas.d.ts +8 -0
- package/dist/conversations/conversations.schemas.js +14 -0
- package/dist/conversations/conversations.service.d.ts +12 -0
- package/dist/conversations/conversations.service.js +10 -0
- package/dist/conversations/event-log.d.ts +14 -0
- package/dist/conversations/events.d.ts +12 -0
- package/dist/conversations/events.js +35 -3
- package/dist/db/kernel-schema.d.ts +5 -0
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +3 -0
- package/dist/evals/plan.d.ts +20 -15
- package/dist/evals/plan.js +29 -6
- package/dist/evals/reconstruct.d.ts +16 -1
- package/dist/evals/reconstruct.js +55 -1
- package/dist/evals/sets.service.d.ts +3 -2
- package/dist/evals/sets.service.js +16 -2
- package/dist/evals/step-replay.d.ts +6 -0
- package/dist/evals/step-replay.js +5 -0
- package/dist/evals/trajectory.d.ts +5 -1
- package/dist/evals/trajectory.js +3 -1
- package/dist/evals/worker.js +2 -1
- package/dist/identity/settings.d.ts +64 -0
- package/dist/identity/settings.js +86 -2
- package/dist/orgs/roles.d.ts +1 -1
- package/dist/orgs/roles.js +2 -0
- package/dist/orgs/settings.service.d.ts +17 -0
- package/dist/orgs/settings.service.js +31 -3
- package/dist/platform/ops/admin.ops.js +8 -2
- package/dist/platform/ops/conversations.ops.js +34 -0
- package/dist/platform/ops/evals.ops.js +12 -1
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/runtime/compaction-progress.d.ts +62 -0
- package/dist/runtime/compaction-progress.js +82 -0
- package/dist/runtime/compaction-settings.service.d.ts +16 -0
- package/dist/runtime/compaction-settings.service.js +42 -0
- package/dist/runtime/compaction.service.d.ts +50 -0
- package/dist/runtime/compaction.service.js +75 -0
- package/dist/runtime/context/compaction.d.ts +90 -12
- package/dist/runtime/context/compaction.js +256 -21
- package/dist/runtime/context/fit.d.ts +79 -0
- package/dist/runtime/context/fit.js +202 -0
- package/dist/runtime/model-call.d.ts +134 -5
- package/dist/runtime/model-call.js +766 -335
- package/dist/runtime/run-control.d.ts +6 -1
- package/dist/runtime/run-control.js +7 -0
- package/dist/runtime/run-queue.d.ts +14 -0
- package/dist/runtime/run-queue.js +75 -0
- package/dist/runtime/run-steps.d.ts +3 -1
- package/dist/runtime/run-steps.js +9 -2
- package/dist/runtime/run-worker.d.ts +14 -2
- package/dist/runtime/run-worker.js +160 -33
- package/dist/runtime/runtime.module.js +11 -0
- package/dist/runtime/stream.js +15 -0
- package/dist/tools/pipeline.js +6 -3
- package/package.json +1 -1
- package/src/migrations/0132_compact_runs.sql +6 -0
package/dist/evals/plan.js
CHANGED
|
@@ -17,21 +17,44 @@ const asUsage = (p) => {
|
|
|
17
17
|
cacheWriteTokens: x.cacheWriteTokens ?? 0,
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
/**
|
|
20
|
+
/** The token estimate of a text (the same estimator as the runtime). */
|
|
21
21
|
export const textTokens = (text) => estimateTokens([], [{ text, cache: false }], []);
|
|
22
|
-
/**
|
|
22
|
+
/** The newest user message before `beforeSeq` in the snapshot (the "user request" the judge sees). */
|
|
23
23
|
export function userRequestOf(s, beforeSeq) {
|
|
24
24
|
const msg = s.events.findLast((e) => e.type === "user_message" && e.seq < beforeSeq);
|
|
25
25
|
const content = msg?.payload?.content ?? [];
|
|
26
26
|
return replyParts(content).text;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
29
|
+
* Whether the case's run is a manual compact run (`run_started.trigger: "compact"`, context
|
|
30
|
+
* compaction spec §4.7): it ran no model step (its boundary message was consumed by an earlier
|
|
31
|
+
* run), so there is nothing to replay and planning it as an ordinary run would dispatch a step the
|
|
32
|
+
* original never made.
|
|
33
|
+
*/
|
|
34
|
+
function compactRun(s) {
|
|
35
|
+
return s.events.some((e) => e.runId === s.runId &&
|
|
36
|
+
e.type === "run_started" &&
|
|
37
|
+
e.payload.trigger === "compact");
|
|
38
|
+
}
|
|
39
|
+
/** A plan with nothing to replay (no result rows, no requests, no usage). */
|
|
40
|
+
const NO_PLAN = {
|
|
41
|
+
results: [],
|
|
42
|
+
modelRequests: 0,
|
|
43
|
+
usage: { ...ZERO },
|
|
44
|
+
judgeContextTokens: 0,
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* A case's replay plan:
|
|
48
|
+
* - `step`: requests = the replayable calls (`replayableCalls`), usage = each call's recorded usage
|
|
49
|
+
* (the first one after that call, same step);
|
|
50
|
+
* - `run`: requests = every `model_call` of the original run, usage = every usage of the run.
|
|
51
|
+
* Computed when the case is written and stored in `plan_step` / `plan_run` ({@link casePlans}), so
|
|
52
|
+
* estimates and starts do not read the snapshot.
|
|
53
|
+
* A compact run has no plan in either mode ({@link compactRun}): estimates and starts skip it.
|
|
33
54
|
*/
|
|
34
55
|
export function casePlan(s, mode) {
|
|
56
|
+
if (compactRun(s))
|
|
57
|
+
return { ...NO_PLAN, results: [], usage: { ...ZERO } };
|
|
35
58
|
const own = s.events.filter((e) => e.runId === s.runId);
|
|
36
59
|
if (mode === "run") {
|
|
37
60
|
let usage = ZERO;
|
|
@@ -27,7 +27,10 @@ import { type CaseSnapshot } from "./snapshot.js";
|
|
|
27
27
|
* - `params_changed`:没给候选参数时,记录的参数按所用模型的声明清洗后有键被丢弃或值变了(换了模型或模型声明变了);
|
|
28
28
|
* - `media_missing`:某附件记录里不是「不再可用」,还原时却取不到;
|
|
29
29
|
* - `media_changed`(只在基线判定):其余任何媒体结果与记录不同(按附件 id 比 outcome 与 etag:预算省略、
|
|
30
|
-
* 图片数 / 页数上限、对象被替换后 etag
|
|
30
|
+
* 图片数 / 页数上限、对象被替换后 etag 变了等);
|
|
31
|
+
* - `context_fit` (context compaction spec §4.9, never for a baseline): the candidate model's window
|
|
32
|
+
* makes the hard fit guard plan a different trim than the recorded `model_call.request.fit` (the
|
|
33
|
+
* recorded plan is replayed for a baseline; a candidate applies its recomputed plan).
|
|
31
34
|
*/
|
|
32
35
|
/** 还原结果与原请求不一致的原因。 */
|
|
33
36
|
export type DriftReason = "system_hash" | "tools_changed" | "tool_spec_missing" | "definition_missing"
|
|
@@ -43,6 +46,12 @@ export type DriftReason = "system_hash" | "tools_changed" | "tool_spec_missing"
|
|
|
43
46
|
* switch (`model_switched`) and whose candidate model (`modelRef`) replaces it.
|
|
44
47
|
*/
|
|
45
48
|
| "model_switched" | "media_missing" | "media_changed"
|
|
49
|
+
/**
|
|
50
|
+
* Context compaction spec §4.9: a candidate model whose context window makes the hard-fit guard
|
|
51
|
+
* trim differently from the recorded plan (`model_call.request.fit`). The fitted request still
|
|
52
|
+
* goes out against the candidate's window.
|
|
53
|
+
*/
|
|
54
|
+
| "context_fit"
|
|
46
55
|
/** 整轮回放(T5):有工具调用没有匹配到记录(模型收到 REPLAY_NO_RECORDING)。 */
|
|
47
56
|
| "tool_unmatched";
|
|
48
57
|
export interface ReconstructOptions {
|
|
@@ -74,6 +83,12 @@ export interface ReconstructOptions {
|
|
|
74
83
|
* that version.
|
|
75
84
|
*/
|
|
76
85
|
subagentVersion?: AgentDefinition;
|
|
86
|
+
/**
|
|
87
|
+
* The safety reserve (`R`) the run's organization had when the call was recorded: a candidate
|
|
88
|
+
* model recomputes the hard fit against `W - O - R` with it (context compaction spec §4.9).
|
|
89
|
+
* Defaults to the built-in platform default; the eval worker passes the resolved settings.
|
|
90
|
+
*/
|
|
91
|
+
reserveTokens?: number;
|
|
77
92
|
}
|
|
78
93
|
export interface ReconstructResult {
|
|
79
94
|
request: ModelRequest;
|
|
@@ -2,7 +2,10 @@ import { sanitizeParams, } from "@capybara-hq/plugin-sdk";
|
|
|
2
2
|
import { AgentDefinitionSchema, builtinDisabled, canonicalDisabledSkills, canonicalDisabledTools, normalizeStoredDefinition, } from "../agents/definition.js";
|
|
3
3
|
import { sameModel, selectionAt } from "../conversations/selection.js";
|
|
4
4
|
import { ApiError } from "../errors.js";
|
|
5
|
+
import { COMPACTION_SETTINGS } from "../identity/settings.js";
|
|
5
6
|
import { mediaRefs, planMedia, } from "../runtime/context/build.js";
|
|
7
|
+
import { applyFit, clampOutput, planFit } from "../runtime/context/fit.js";
|
|
8
|
+
import { estimateTokens } from "../runtime/context/tokens.js";
|
|
6
9
|
import { assembleModelRequest } from "../runtime/model-call.js";
|
|
7
10
|
import { CHILD_REMOVED_TOOLS } from "../runtime/subagents/definition.js";
|
|
8
11
|
import { AGENT_TOOL } from "../tools/builtin-names.js";
|
|
@@ -19,6 +22,26 @@ const pinsSkills = (d) => {
|
|
|
19
22
|
: undefined;
|
|
20
23
|
return Array.isArray(pinned) && pinned.length > 0;
|
|
21
24
|
};
|
|
25
|
+
/** `R` when the caller did not resolve the org's settings (the built-in platform default). */
|
|
26
|
+
const DEFAULT_RESERVE_TOKENS = COMPACTION_SETTINGS.parse({}).reserveTokens;
|
|
27
|
+
/** Two hard-fit plans trim the same messages and blocks (the recorded plan may be absent). */
|
|
28
|
+
function samePlan(a, b) {
|
|
29
|
+
if (a === null || a === undefined || b === undefined)
|
|
30
|
+
return (a ?? undefined) === b;
|
|
31
|
+
if (a.droppedMessageIndexes.length !== b.droppedMessageIndexes.length)
|
|
32
|
+
return false;
|
|
33
|
+
if (a.droppedMessageIndexes.some((x, i) => x !== b.droppedMessageIndexes[i]))
|
|
34
|
+
return false;
|
|
35
|
+
if (a.truncated.length !== b.truncated.length)
|
|
36
|
+
return false;
|
|
37
|
+
return a.truncated.every((t, i) => {
|
|
38
|
+
const o = b.truncated[i];
|
|
39
|
+
return (o !== undefined &&
|
|
40
|
+
t.messageIndex === o.messageIndex &&
|
|
41
|
+
t.block === o.block &&
|
|
42
|
+
t.note === o.note);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
22
45
|
const DRIFT_ORDER = [
|
|
23
46
|
"system_hash",
|
|
24
47
|
"tools_changed",
|
|
@@ -31,6 +54,7 @@ const DRIFT_ORDER = [
|
|
|
31
54
|
"model_switched",
|
|
32
55
|
"media_missing",
|
|
33
56
|
"media_changed",
|
|
57
|
+
"context_fit",
|
|
34
58
|
"tool_unmatched",
|
|
35
59
|
];
|
|
36
60
|
function findCall(events, seq) {
|
|
@@ -156,7 +180,7 @@ export function reconstructRequest(s, modelCallSeq, opts) {
|
|
|
156
180
|
drift.add("params_changed");
|
|
157
181
|
}
|
|
158
182
|
const budget = opts.mediaBudgetBytes ?? rec.mediaBudgetBytes;
|
|
159
|
-
const
|
|
183
|
+
const built = assembleModelRequest({
|
|
160
184
|
events: inputEvents(all, call),
|
|
161
185
|
agent,
|
|
162
186
|
agentVersion: version,
|
|
@@ -171,7 +195,37 @@ export function reconstructRequest(s, modelCallSeq, opts) {
|
|
|
171
195
|
...(opts.media !== undefined && { media: opts.media }),
|
|
172
196
|
...(budget !== undefined && { mediaBudgetBytes: budget }),
|
|
173
197
|
defaultMaxOutputTokens: rec.maxOutputTokens ?? opts.model.maxOutputTokens,
|
|
198
|
+
// The baseline replays the recorded output cap as sent: the runtime may have clamped it below
|
|
199
|
+
// the agent's `maxOutputTokens` knob (context compaction spec §4.3), and recomputing it from the
|
|
200
|
+
// knob would replay a larger cap. A candidate below recomputes the clamp and the trim instead.
|
|
201
|
+
...(baseline && rec.maxOutputTokens !== undefined
|
|
202
|
+
? { recordedMaxOutputTokens: rec.maxOutputTokens }
|
|
203
|
+
: {}),
|
|
204
|
+
// the baseline replays the recorded trim (no reserve needed); a candidate below recomputes it
|
|
205
|
+
...(baseline && rec.fit !== undefined ? { fit: rec.fit } : {}),
|
|
174
206
|
});
|
|
207
|
+
const { request, meta, mediaTokens } = built;
|
|
208
|
+
if (!baseline) {
|
|
209
|
+
// The hard fit guard against the candidate's window (spec §4.9): clamp the output cap and the
|
|
210
|
+
// reserve to that window, apply the fit the candidate would have used, and report
|
|
211
|
+
// `context_fit` when the plan differs from the recorded one.
|
|
212
|
+
const reserve = opts.reserveTokens ?? DEFAULT_RESERVE_TOKENS;
|
|
213
|
+
const estimate = estimateTokens(request.messages, request.system, request.tools, mediaTokens);
|
|
214
|
+
request.maxOutputTokens = clampOutput(opts.model.contextWindow, request.maxOutputTokens, estimate);
|
|
215
|
+
const recomputed = planFit({
|
|
216
|
+
events: inputEvents(all, call),
|
|
217
|
+
request,
|
|
218
|
+
model: opts.model,
|
|
219
|
+
maxOutputTokens: request.maxOutputTokens,
|
|
220
|
+
reserveTokens: reserve,
|
|
221
|
+
estimate,
|
|
222
|
+
});
|
|
223
|
+
if (!samePlan(recomputed, rec.fit))
|
|
224
|
+
drift.add("context_fit");
|
|
225
|
+
if (recomputed !== null) {
|
|
226
|
+
request.messages = applyFit(request, recomputed).messages;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
175
229
|
if (baseline) {
|
|
176
230
|
if (meta.systemHash !== rec.systemHash)
|
|
177
231
|
drift.add("system_hash");
|
|
@@ -119,8 +119,9 @@ export declare class EvalSetsService {
|
|
|
119
119
|
private insertCase;
|
|
120
120
|
/**
|
|
121
121
|
* 把某次运行加为用例。对话不在本组织(或是 eval 对话)→ `conversation.not_found`;对话的 agent 不是集合的 agent →
|
|
122
|
-
* `eval.agent_mismatch
|
|
123
|
-
*
|
|
122
|
+
* `eval.agent_mismatch`;手动压缩运行(无模型步骤)→ `eval.compact_not_replayable`;已在集合里 →
|
|
123
|
+
* `eval.case_exists`;集合满了 → `eval.too_many_cases`;运行未终态 / 快照超大 →
|
|
124
|
+
* `eval.run_not_finished` / `eval.case_too_large`(`takeSnapshot`)。
|
|
124
125
|
*/
|
|
125
126
|
addCase(orgId: string, actor: string, setId: string, input: {
|
|
126
127
|
conversationId: string;
|
|
@@ -403,8 +403,9 @@ let EvalSetsService = EvalSetsService_1 = class EvalSetsService {
|
|
|
403
403
|
}
|
|
404
404
|
/**
|
|
405
405
|
* 把某次运行加为用例。对话不在本组织(或是 eval 对话)→ `conversation.not_found`;对话的 agent 不是集合的 agent →
|
|
406
|
-
* `eval.agent_mismatch
|
|
407
|
-
*
|
|
406
|
+
* `eval.agent_mismatch`;手动压缩运行(无模型步骤)→ `eval.compact_not_replayable`;已在集合里 →
|
|
407
|
+
* `eval.case_exists`;集合满了 → `eval.too_many_cases`;运行未终态 / 快照超大 →
|
|
408
|
+
* `eval.run_not_finished` / `eval.case_too_large`(`takeSnapshot`)。
|
|
408
409
|
*/
|
|
409
410
|
async addCase(orgId, actor, setId, input, actorTokenId, auditDetail) {
|
|
410
411
|
const set = await this.liveSet(orgId, setId);
|
|
@@ -422,6 +423,17 @@ let EvalSetsService = EvalSetsService_1 = class EvalSetsService {
|
|
|
422
423
|
if (conv.agent_id !== set.agent_id) {
|
|
423
424
|
throw new ApiError("eval.agent_mismatch", "The run belongs to a different agent");
|
|
424
425
|
}
|
|
426
|
+
// a manual compaction run has no model step to replay (context compaction spec §4.7): it would
|
|
427
|
+
// take a set slot and never produce a result, so it is refused with a clear code
|
|
428
|
+
const run = await this.db
|
|
429
|
+
.selectFrom("runs")
|
|
430
|
+
.select("compact")
|
|
431
|
+
.where("id", "=", input.runId)
|
|
432
|
+
.where("conversation_id", "=", input.conversationId)
|
|
433
|
+
.executeTakeFirst();
|
|
434
|
+
if (run?.compact === true) {
|
|
435
|
+
throw new ApiError("eval.compact_not_replayable", "A manual compaction run has no model step to replay, so it cannot be an eval case");
|
|
436
|
+
}
|
|
425
437
|
const exists = await this.db
|
|
426
438
|
.selectFrom("eval_cases")
|
|
427
439
|
.select("id")
|
|
@@ -465,6 +477,8 @@ let EvalSetsService = EvalSetsService_1 = class EvalSetsService {
|
|
|
465
477
|
.where("c.agent_id", "=", set.agent_id)
|
|
466
478
|
.where("c.kind", "=", "chat")
|
|
467
479
|
.where("r.status", "in", STATUSES[input.status ?? "completed"])
|
|
480
|
+
// a manual compaction run has no model step to replay (context compaction spec §4.7)
|
|
481
|
+
.where("r.compact", "=", false)
|
|
468
482
|
.where((eb) => eb.not(eb.exists(eb
|
|
469
483
|
.selectFrom("eval_cases as e")
|
|
470
484
|
.select(sql `1`.as("one"))
|
|
@@ -2,6 +2,7 @@ import { type ContentBlock, type ModelUsage, type ParamValue, type StopReason }
|
|
|
2
2
|
import type { AgentDefinition, ModelRef } from "../agents/definition.js";
|
|
3
3
|
import { type Selection } from "../conversations/selection.js";
|
|
4
4
|
import type { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
5
|
+
import type { CompactionSettingsService } from "../runtime/compaction-settings.service.js";
|
|
5
6
|
import { type MediaSourceDeps } from "../runtime/model-call.js";
|
|
6
7
|
import type { ProviderRegistry } from "../runtime/providers.js";
|
|
7
8
|
import { type DriftReason, type SubagentTemplateRef } from "./reconstruct.js";
|
|
@@ -56,6 +57,11 @@ export interface StepReplayDeps {
|
|
|
56
57
|
config: Pick<KernelConfigService, "get">;
|
|
57
58
|
/** 附件来源(与运行时同一个,按组织 + 对话取);不给时媒体一律按「不再可用」占位。 */
|
|
58
59
|
media?: MediaSourceDeps;
|
|
60
|
+
/**
|
|
61
|
+
* The org's effective compaction settings (context compaction spec §4.9): a candidate model
|
|
62
|
+
* recomputes the hard fit against the same `R` the run used. Absent: the built-in default.
|
|
63
|
+
*/
|
|
64
|
+
compactionSettings?: Pick<CompactionSettingsService, "resolve">;
|
|
59
65
|
}
|
|
60
66
|
/**
|
|
61
67
|
* 候选在某个用例上所用的模型({@link resolveCandidate} 的同一规则):候选模型,否则候选版本的模型,否则用例原版本的
|
|
@@ -133,6 +133,10 @@ function baselineOf(s, call) {
|
|
|
133
133
|
export async function replayStep(d, s, call, candidate, signal) {
|
|
134
134
|
const baseline = baselineOf(s, call);
|
|
135
135
|
const { provider, info } = await d.registry.resolve(s.orgId, candidate.model);
|
|
136
|
+
// the reserve the run's hard fit guard used (a candidate recomputes the fit against its window)
|
|
137
|
+
const reserveTokens = d.compactionSettings === undefined
|
|
138
|
+
? undefined
|
|
139
|
+
: (await d.compactionSettings.resolve(s.orgId)).reserveTokens;
|
|
136
140
|
let media;
|
|
137
141
|
if (d.media) {
|
|
138
142
|
try {
|
|
@@ -144,6 +148,7 @@ export async function replayStep(d, s, call, candidate, signal) {
|
|
|
144
148
|
}
|
|
145
149
|
const { request, drift, mediaTokens } = reconstructRequest(s, call.seq, {
|
|
146
150
|
model: info,
|
|
151
|
+
...(reserveTokens !== undefined && { reserveTokens }),
|
|
147
152
|
...(candidate.changed && {
|
|
148
153
|
definition: candidate.definition,
|
|
149
154
|
agentVersion: candidate.agentVersion,
|
|
@@ -139,7 +139,11 @@ export interface TrajectoryRun {
|
|
|
139
139
|
skillFork?: TrajectorySkillFork;
|
|
140
140
|
steps: TrajectoryStep[];
|
|
141
141
|
totals: {
|
|
142
|
-
/**
|
|
142
|
+
/**
|
|
143
|
+
* Usage of the step calls plus the non-step calls (`usage` with a `purpose`: a compaction,
|
|
144
|
+
* title or `web_fetch` call). A compact run has only the latter, so its totals are the sum of
|
|
145
|
+
* its (possibly chunked) compaction calls, and it has no steps.
|
|
146
|
+
*/
|
|
143
147
|
usage: ModelUsage;
|
|
144
148
|
/** 各次成功调用的成本之和(含压缩调用);任一成功调用没有价格时为 null(部分求和会误导)。 */
|
|
145
149
|
cost: number | null;
|
package/dist/evals/trajectory.js
CHANGED
|
@@ -131,7 +131,9 @@ function buildRun({ started, events }, prices, forks) {
|
|
|
131
131
|
assistants.set(e.payload.step, [...(assistants.get(e.payload.step) ?? []), e]);
|
|
132
132
|
break;
|
|
133
133
|
case "usage":
|
|
134
|
-
// a compaction, title, web_fetch or review call's usage is not a step call's: counted in the
|
|
134
|
+
// a compaction, title, web_fetch or review call's usage is not a step call's: counted in the
|
|
135
|
+
// totals only (I-1). A compact run's chunked calls land here too (step 0, no model step), so
|
|
136
|
+
// no step is paired with them.
|
|
135
137
|
if (e.payload.purpose !== undefined) {
|
|
136
138
|
compactions.push(e);
|
|
137
139
|
break;
|
package/dist/evals/worker.js
CHANGED
|
@@ -182,6 +182,7 @@ let EvalWorker = class EvalWorker {
|
|
|
182
182
|
replay: {
|
|
183
183
|
registry,
|
|
184
184
|
config,
|
|
185
|
+
compactionSettings: stepDeps.compactionSettings,
|
|
185
186
|
...(stepDeps.media !== undefined && { media: stepDeps.media }),
|
|
186
187
|
},
|
|
187
188
|
// 整轮回放(C6):同一个 loop 工厂(同一 LangGraphLoop),只换工具管线(RecordedToolPipeline,
|
|
@@ -202,7 +203,7 @@ let EvalWorker = class EvalWorker {
|
|
|
202
203
|
// publish sub-agent progress on a live conversation's stream
|
|
203
204
|
loop: (d) => {
|
|
204
205
|
// nor dispatch fork invocations: run-replay passes the recorded reports instead
|
|
205
|
-
const { db: _snapshot, hooks: _noHooks, subagentProgress: _noProgress, skillForks: _noForks, ...replayDeps } = stepDeps;
|
|
206
|
+
const { db: _snapshot, hooks: _noHooks, subagentProgress: _noProgress, compactionProgress: _noCompactionProgress, skillForks: _noForks, ...replayDeps } = stepDeps;
|
|
206
207
|
// the object rest above copied `db` as a value: read it through the step deps' getter
|
|
207
208
|
// instead, so the loop always resolves the context-aware handle
|
|
208
209
|
return loops.create({
|
|
@@ -72,6 +72,50 @@ export declare const clientExtensionsDefault: () => ClientExtensionsKillSwitch;
|
|
|
72
72
|
* check read through it.
|
|
73
73
|
*/
|
|
74
74
|
export declare function parseClientExtensions(value: unknown, log?: Pick<KernelLogger, "warn">): ClientExtensionsKillSwitch;
|
|
75
|
+
/**
|
|
76
|
+
* Conversation compaction (context compaction spec §4.8): the platform's defaults and the bounds
|
|
77
|
+
* every organization's override is validated against. `enabled: false` turns proactive early
|
|
78
|
+
* compaction off; the hard line, hard fit guard and reactive path stay armed. `reserveTokens` is
|
|
79
|
+
* the safety margin left below the window, `maxOutputTokens` the summary call's output cap.
|
|
80
|
+
*/
|
|
81
|
+
export declare const COMPACTION_SETTINGS: z.ZodObject<{
|
|
82
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
83
|
+
threshold: z.ZodDefault<z.ZodNumber>;
|
|
84
|
+
keepRecentTurns: z.ZodDefault<z.ZodNumber>;
|
|
85
|
+
reserveTokens: z.ZodDefault<z.ZodNumber>;
|
|
86
|
+
maxOutputTokens: z.ZodDefault<z.ZodNumber>;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
export type CompactionSettings = z.infer<typeof COMPACTION_SETTINGS>;
|
|
89
|
+
/**
|
|
90
|
+
* The partial form the platform and org patches carry: only the given fields, validated against
|
|
91
|
+
* the same bounds, so merging them into the stored settings never injects a default for a field
|
|
92
|
+
* the caller left out.
|
|
93
|
+
*/
|
|
94
|
+
export declare const COMPACTION_SETTINGS_PARTIAL: z.ZodObject<{
|
|
95
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
96
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
keepRecentTurns: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
reserveTokens: z.ZodOptional<z.ZodNumber>;
|
|
99
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
}, z.core.$strip>;
|
|
101
|
+
/**
|
|
102
|
+
* The patch form both settings writers take: the partial form above, strict, so a misspelled
|
|
103
|
+
* field (`treshold`) is a 400 instead of being silently stripped into an empty no-op. Stored
|
|
104
|
+
* values stay lenient ({@link COMPACTION_SETTINGS_PARTIAL}); only the request bodies are strict.
|
|
105
|
+
*/
|
|
106
|
+
export declare const COMPACTION_SETTINGS_PATCH: z.ZodObject<{
|
|
107
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
108
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
109
|
+
keepRecentTurns: z.ZodOptional<z.ZodNumber>;
|
|
110
|
+
reserveTokens: z.ZodOptional<z.ZodNumber>;
|
|
111
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
112
|
+
}, z.core.$strict>;
|
|
113
|
+
export type CompactionSettingsPatch = z.infer<typeof COMPACTION_SETTINGS_PARTIAL>;
|
|
114
|
+
/**
|
|
115
|
+
* The compaction settings in effect for an organization (spec §4.8): every field the org gives wins,
|
|
116
|
+
* the rest follow the platform's settings, which are themselves the built-in defaults when unset.
|
|
117
|
+
*/
|
|
118
|
+
export declare function effectiveCompactionSettings(platform: CompactionSettings, org: CompactionSettingsPatch | undefined): CompactionSettings;
|
|
75
119
|
export declare const DEPLOYMENT_SETTINGS: z.ZodObject<{
|
|
76
120
|
orgCreation: z.ZodDefault<z.ZodEnum<{
|
|
77
121
|
anyone: "anyone";
|
|
@@ -106,6 +150,13 @@ export declare const DEPLOYMENT_SETTINGS: z.ZodObject<{
|
|
|
106
150
|
enabled: z.ZodBoolean;
|
|
107
151
|
disabled: z.ZodArray<z.ZodString>;
|
|
108
152
|
}, z.core.$strip>>;
|
|
153
|
+
compaction: z.ZodPrefault<z.ZodObject<{
|
|
154
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
155
|
+
threshold: z.ZodDefault<z.ZodNumber>;
|
|
156
|
+
keepRecentTurns: z.ZodDefault<z.ZodNumber>;
|
|
157
|
+
reserveTokens: z.ZodDefault<z.ZodNumber>;
|
|
158
|
+
maxOutputTokens: z.ZodDefault<z.ZodNumber>;
|
|
159
|
+
}, z.core.$strip>>;
|
|
109
160
|
}, z.core.$strip>;
|
|
110
161
|
export type DeploymentSettings = z.infer<typeof DEPLOYMENT_SETTINGS>;
|
|
111
162
|
/**
|
|
@@ -171,6 +222,13 @@ export declare const DEPLOYMENT_SETTINGS_PATCH: z.ZodObject<{
|
|
|
171
222
|
pr: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
172
223
|
sessionUrl: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
173
224
|
}, z.core.$strict>>;
|
|
225
|
+
compaction: z.ZodOptional<z.ZodObject<{
|
|
226
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
227
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
228
|
+
keepRecentTurns: z.ZodOptional<z.ZodNumber>;
|
|
229
|
+
reserveTokens: z.ZodOptional<z.ZodNumber>;
|
|
230
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
231
|
+
}, z.core.$strict>>;
|
|
174
232
|
}, z.core.$strict>;
|
|
175
233
|
export type DeploymentSettingsPatch = z.infer<typeof DEPLOYMENT_SETTINGS_PATCH>;
|
|
176
234
|
/**
|
|
@@ -184,6 +242,12 @@ export declare function readSandboxLimitOverride(db: KernelSchemaDb, orgId: stri
|
|
|
184
242
|
* is parsed: no setting, no entry, or an invalid stored entry → undefined.
|
|
185
243
|
*/
|
|
186
244
|
export declare function readSubagentLimitOverride(db: KernelSchemaDb, orgId: string): Promise<SubagentLimitOverride | undefined>;
|
|
245
|
+
/**
|
|
246
|
+
* The platform's conversation compaction settings, read live from PG (the org settings page shows
|
|
247
|
+
* what an organization that follows the platform gets): missing or invalid -> the built-in
|
|
248
|
+
* defaults, as {@link SettingsService.get} reads them.
|
|
249
|
+
*/
|
|
250
|
+
export declare function readPlatformCompactionSettings(db: KernelSchemaDb): Promise<CompactionSettings>;
|
|
187
251
|
/**
|
|
188
252
|
* When orgs may not create their own connectors / skills (deployment setting `customConnectors` /
|
|
189
253
|
* `customSkills` is `deny`, C22) throws `catalog.custom_disabled`: install from the platform
|
|
@@ -119,6 +119,56 @@ export function parseClientExtensions(value, log) {
|
|
|
119
119
|
});
|
|
120
120
|
return clientExtensionsDefault();
|
|
121
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* The compaction field schemas and their bounds, before defaults: the partial form below shares
|
|
124
|
+
* them, so a patch validates the same ranges as a stored value without filling defaults for the
|
|
125
|
+
* fields it leaves out.
|
|
126
|
+
*/
|
|
127
|
+
const COMPACTION_FIELDS = {
|
|
128
|
+
enabled: z.boolean(),
|
|
129
|
+
threshold: z.number().min(0.5).max(0.95),
|
|
130
|
+
keepRecentTurns: z.number().int().min(0).max(20),
|
|
131
|
+
reserveTokens: z.number().int().min(0).max(50_000),
|
|
132
|
+
maxOutputTokens: z.number().int().min(1024).max(32_000),
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Conversation compaction (context compaction spec §4.8): the platform's defaults and the bounds
|
|
136
|
+
* every organization's override is validated against. `enabled: false` turns proactive early
|
|
137
|
+
* compaction off; the hard line, hard fit guard and reactive path stay armed. `reserveTokens` is
|
|
138
|
+
* the safety margin left below the window, `maxOutputTokens` the summary call's output cap.
|
|
139
|
+
*/
|
|
140
|
+
export const COMPACTION_SETTINGS = z.object({
|
|
141
|
+
enabled: COMPACTION_FIELDS.enabled.default(true),
|
|
142
|
+
threshold: COMPACTION_FIELDS.threshold.default(0.8),
|
|
143
|
+
keepRecentTurns: COMPACTION_FIELDS.keepRecentTurns.default(4),
|
|
144
|
+
reserveTokens: COMPACTION_FIELDS.reserveTokens.default(8000),
|
|
145
|
+
maxOutputTokens: COMPACTION_FIELDS.maxOutputTokens.default(20_000),
|
|
146
|
+
});
|
|
147
|
+
/**
|
|
148
|
+
* The partial form the platform and org patches carry: only the given fields, validated against
|
|
149
|
+
* the same bounds, so merging them into the stored settings never injects a default for a field
|
|
150
|
+
* the caller left out.
|
|
151
|
+
*/
|
|
152
|
+
export const COMPACTION_SETTINGS_PARTIAL = z.object(COMPACTION_FIELDS).partial();
|
|
153
|
+
/**
|
|
154
|
+
* The patch form both settings writers take: the partial form above, strict, so a misspelled
|
|
155
|
+
* field (`treshold`) is a 400 instead of being silently stripped into an empty no-op. Stored
|
|
156
|
+
* values stay lenient ({@link COMPACTION_SETTINGS_PARTIAL}); only the request bodies are strict.
|
|
157
|
+
*/
|
|
158
|
+
export const COMPACTION_SETTINGS_PATCH = COMPACTION_SETTINGS_PARTIAL.strict();
|
|
159
|
+
/**
|
|
160
|
+
* The compaction settings in effect for an organization (spec §4.8): every field the org gives wins,
|
|
161
|
+
* the rest follow the platform's settings, which are themselves the built-in defaults when unset.
|
|
162
|
+
*/
|
|
163
|
+
export function effectiveCompactionSettings(platform, org) {
|
|
164
|
+
return {
|
|
165
|
+
enabled: org?.enabled ?? platform.enabled,
|
|
166
|
+
threshold: org?.threshold ?? platform.threshold,
|
|
167
|
+
keepRecentTurns: org?.keepRecentTurns ?? platform.keepRecentTurns,
|
|
168
|
+
reserveTokens: org?.reserveTokens ?? platform.reserveTokens,
|
|
169
|
+
maxOutputTokens: org?.maxOutputTokens ?? platform.maxOutputTokens,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
122
172
|
export const DEPLOYMENT_SETTINGS = z.object({
|
|
123
173
|
orgCreation: z.enum(["anyone", "super_admin"]).default("anyone"),
|
|
124
174
|
/** 按组织覆盖运行并发上限(orgId → 上限);未列出的组织用 `runtime.orgConcurrency`。 */
|
|
@@ -154,6 +204,11 @@ export const DEPLOYMENT_SETTINGS = z.object({
|
|
|
154
204
|
uiArrangement: UiArrangementSchema.default({}),
|
|
155
205
|
/** The client code kill switch (client extensions spec §10.2). */
|
|
156
206
|
clientExtensions: ClientExtensionsSetting.default(clientExtensionsDefault),
|
|
207
|
+
/**
|
|
208
|
+
* Conversation compaction (context compaction spec §4.8): the platform defaults, with the built-in
|
|
209
|
+
* values; an organization may override any field in its own settings.
|
|
210
|
+
*/
|
|
211
|
+
compaction: COMPACTION_SETTINGS.prefault({}),
|
|
157
212
|
});
|
|
158
213
|
const DEFAULTS = DEPLOYMENT_SETTINGS.parse({});
|
|
159
214
|
const autoModeWidenRefused = () => new ApiError("deployment.auto_mode_not_allowed", "Turning auto mode on at the platform level (devicesAutoMode) needs a super admin in the admin console; an API token or the Platform tool may only turn it off.");
|
|
@@ -216,6 +271,11 @@ export const DEPLOYMENT_SETTINGS_PATCH = z
|
|
|
216
271
|
* read-only (409 `deployment.setting_readonly`).
|
|
217
272
|
*/
|
|
218
273
|
attribution: PLATFORM_ATTRIBUTION_PATCH.optional(),
|
|
274
|
+
/**
|
|
275
|
+
* Conversation compaction (context compaction spec §4.8): each given field replaces the stored
|
|
276
|
+
* one, fields left out keep their value.
|
|
277
|
+
*/
|
|
278
|
+
compaction: COMPACTION_SETTINGS_PATCH.optional(),
|
|
219
279
|
})
|
|
220
280
|
.strict();
|
|
221
281
|
/**
|
|
@@ -257,6 +317,20 @@ export async function readSubagentLimitOverride(db, orgId) {
|
|
|
257
317
|
const parsed = SUBAGENT_LIMIT_OVERRIDE.safeParse(all[orgId]);
|
|
258
318
|
return parsed.success ? parsed.data : undefined;
|
|
259
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* The platform's conversation compaction settings, read live from PG (the org settings page shows
|
|
322
|
+
* what an organization that follows the platform gets): missing or invalid -> the built-in
|
|
323
|
+
* defaults, as {@link SettingsService.get} reads them.
|
|
324
|
+
*/
|
|
325
|
+
export async function readPlatformCompactionSettings(db) {
|
|
326
|
+
const row = await db
|
|
327
|
+
.selectFrom("deployment_settings")
|
|
328
|
+
.select("value")
|
|
329
|
+
.where("key", "=", "compaction")
|
|
330
|
+
.executeTakeFirst();
|
|
331
|
+
const parsed = COMPACTION_SETTINGS.safeParse(row?.value ?? {});
|
|
332
|
+
return parsed.success ? parsed.data : DEFAULTS.compaction;
|
|
333
|
+
}
|
|
260
334
|
/**
|
|
261
335
|
* When orgs may not create their own connectors / skills (deployment setting `customConnectors` /
|
|
262
336
|
* `customSkills` is `deny`, C22) throws `catalog.custom_disabled`: install from the platform
|
|
@@ -504,12 +578,13 @@ let SettingsService = class SettingsService {
|
|
|
504
578
|
}
|
|
505
579
|
next.uiTheme = { id: patch.uiTheme.id };
|
|
506
580
|
}
|
|
507
|
-
const { runConcurrencyOverrides: runPatch, sandboxLimitOverrides: sandboxPatch, subagentLimitOverrides: subagentPatch, uiArrangement: arrangementPatch, clientExtensions: clientPatch, } = patch;
|
|
581
|
+
const { runConcurrencyOverrides: runPatch, sandboxLimitOverrides: sandboxPatch, subagentLimitOverrides: subagentPatch, uiArrangement: arrangementPatch, clientExtensions: clientPatch, compaction: compactionPatch, } = patch;
|
|
508
582
|
if (runPatch !== undefined ||
|
|
509
583
|
sandboxPatch !== undefined ||
|
|
510
584
|
subagentPatch !== undefined ||
|
|
511
585
|
arrangementPatch !== undefined ||
|
|
512
|
-
clientPatch !== undefined
|
|
586
|
+
clientPatch !== undefined ||
|
|
587
|
+
compactionPatch !== undefined) {
|
|
513
588
|
const current = await this.get();
|
|
514
589
|
if (clientPatch !== undefined) {
|
|
515
590
|
next.clientExtensions = {
|
|
@@ -519,6 +594,15 @@ let SettingsService = class SettingsService {
|
|
|
519
594
|
: [...new Set(clientPatch.disabled)].sort(),
|
|
520
595
|
};
|
|
521
596
|
}
|
|
597
|
+
if (compactionPatch !== undefined) {
|
|
598
|
+
next.compaction = {
|
|
599
|
+
enabled: compactionPatch.enabled ?? current.compaction.enabled,
|
|
600
|
+
threshold: compactionPatch.threshold ?? current.compaction.threshold,
|
|
601
|
+
keepRecentTurns: compactionPatch.keepRecentTurns ?? current.compaction.keepRecentTurns,
|
|
602
|
+
reserveTokens: compactionPatch.reserveTokens ?? current.compaction.reserveTokens,
|
|
603
|
+
maxOutputTokens: compactionPatch.maxOutputTokens ?? current.compaction.maxOutputTokens,
|
|
604
|
+
};
|
|
605
|
+
}
|
|
522
606
|
if (arrangementPatch !== undefined) {
|
|
523
607
|
next.uiArrangement = mergeArrangement(current.uiArrangement, arrangementPatch);
|
|
524
608
|
}
|
package/dist/orgs/roles.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type OrgRole = (typeof ORG_ROLES)[number];
|
|
|
4
4
|
/** `role` 是否不低于 `min`。 */
|
|
5
5
|
export declare function roleAtLeast(role: OrgRole, min: OrgRole): boolean;
|
|
6
6
|
/** 组织级动作;路由用 `@OrgAction(action)` 声明所需动作。 */
|
|
7
|
-
export type OrgAction = "org.read" | "org.update" | "org.delete" | "org.transfer" | "org.members.read" | "org.members.manage" | "org.invitations.manage" | "org.tokens.manage" | "org.extensions.read" | "org.extensions.manage" | "agents.create" | "agents.use" | "agents.manage" | "connectors.manage" | "connectors.use" | "approvals.decide" | "channels.manage" | "skills.read" | "skills.manage" | "ui.use" | "trajectories.read" | "evals.manage" | "org.models.manage" | "catalog.read" | "catalog.request" | "catalog.decide" | "catalog.upload" | "schedules.use" | "schedules.manage";
|
|
7
|
+
export type OrgAction = "org.read" | "org.update" | "org.delete" | "org.transfer" | "org.members.read" | "org.members.manage" | "org.invitations.manage" | "org.tokens.manage" | "org.extensions.read" | "org.extensions.manage" | "agents.create" | "agents.use" | "agents.manage" | "conversations.compact" | "connectors.manage" | "connectors.use" | "approvals.decide" | "channels.manage" | "skills.read" | "skills.manage" | "ui.use" | "trajectories.read" | "evals.manage" | "org.models.manage" | "catalog.read" | "catalog.request" | "catalog.decide" | "catalog.upload" | "schedules.use" | "schedules.manage";
|
|
8
8
|
/** 每个动作所需的最低角色。 */
|
|
9
9
|
export declare const ACTION_MIN_ROLE: Record<OrgAction, OrgRole>;
|
|
10
10
|
/** 只允许 user principal 执行的动作:服务令牌即使角色足够也拒绝(除 SERVICE_ALLOWED 外全部)。 */
|
package/dist/orgs/roles.js
CHANGED
|
@@ -19,6 +19,8 @@ export const ACTION_MIN_ROLE = {
|
|
|
19
19
|
"org.transfer": "owner",
|
|
20
20
|
"agents.create": "member",
|
|
21
21
|
"agents.use": "guest",
|
|
22
|
+
// 手动压缩自己可见的会话(context compaction spec §4.7):成员及以上
|
|
23
|
+
"conversations.compact": "member",
|
|
22
24
|
// 管理他人的 agent(如离职后重新指派负责人)
|
|
23
25
|
"agents.manage": "admin",
|
|
24
26
|
// 安装 / 配置连接器与审阅工具
|
|
@@ -2,6 +2,7 @@ import { type SandboxLimits } from "@capybara-hq/plugin-sdk";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { type PlatformAttribution } from "../attribution/platform-attribution.js";
|
|
4
4
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
5
|
+
import { type CompactionSettings } from "../identity/settings.js";
|
|
5
6
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
6
7
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
7
8
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
@@ -188,6 +189,13 @@ export declare const OrgSettingsSchema: z.ZodObject<{
|
|
|
188
189
|
pauseAfterFailures: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
|
|
189
190
|
forbiddenTools: z.ZodCatch<z.ZodPreprocess<z.ZodDefault<z.ZodArray<z.ZodString>>, unknown>>;
|
|
190
191
|
}, z.core.$strip>>>;
|
|
192
|
+
compaction: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
193
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
194
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
195
|
+
keepRecentTurns: z.ZodOptional<z.ZodNumber>;
|
|
196
|
+
reserveTokens: z.ZodOptional<z.ZodNumber>;
|
|
197
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
198
|
+
}, z.core.$strip>>>;
|
|
191
199
|
}, z.core.$strip>;
|
|
192
200
|
export type OrgSettings = z.infer<typeof OrgSettingsSchema>;
|
|
193
201
|
/** PATCH 体:只改给出的字段;未知字段 → 400。 */
|
|
@@ -245,6 +253,13 @@ export declare const OrgSettingsPatchSchema: z.ZodObject<{
|
|
|
245
253
|
pauseAfterFailures: z.ZodOptional<z.ZodNumber>;
|
|
246
254
|
forbiddenTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
247
255
|
}, z.core.$strict>>;
|
|
256
|
+
compaction: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
257
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
258
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
259
|
+
keepRecentTurns: z.ZodOptional<z.ZodNumber>;
|
|
260
|
+
reserveTokens: z.ZodOptional<z.ZodNumber>;
|
|
261
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
262
|
+
}, z.core.$strict>>>;
|
|
248
263
|
}, z.core.$strict>;
|
|
249
264
|
export type OrgSettingsPatch = z.infer<typeof OrgSettingsPatchSchema>;
|
|
250
265
|
/** Whether a finished background task wakes an idle conversation: the org's setting, else the deployment's. */
|
|
@@ -283,6 +298,8 @@ export interface OrgSettingsDeployment {
|
|
|
283
298
|
* added to a pull request, so the agent page can say why the link setting has no effect.
|
|
284
299
|
*/
|
|
285
300
|
publicUrl: boolean;
|
|
301
|
+
/** The platform's conversation compaction settings (what "follow the platform" means). */
|
|
302
|
+
compaction: CompactionSettings;
|
|
286
303
|
}
|
|
287
304
|
/** 把存储的 jsonb 解析为设置(宽松,见 {@link OrgSettingsSchema})。 */
|
|
288
305
|
export declare function parseOrgSettings(raw: unknown): OrgSettings;
|