@vincemakes/kiso-runtime 0.1.5 → 0.1.7
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/session.js +37 -2
- package/package.json +5 -5
package/dist/session.js
CHANGED
|
@@ -437,17 +437,24 @@ export class Run {
|
|
|
437
437
|
this.#session.beginRun(this);
|
|
438
438
|
const log = this.#session.log;
|
|
439
439
|
const signal = this.#externalSignal ? new MergedSignal(this.#abort.signal, this.#externalSignal) : this.#abort.signal;
|
|
440
|
+
// E2: the session's own microcompact wins; otherwise the FIRST
|
|
441
|
+
// extension providing a compaction config supplies it.
|
|
442
|
+
const microcompact = microcompactFor(this.#config);
|
|
443
|
+
// E2: the session's own systemPrompt first, then every extension
|
|
444
|
+
// append in LOAD order — deterministic (same extensions → same
|
|
445
|
+
// prompt); no appends → byte-identical to the extension-less run.
|
|
446
|
+
const systemPrompt = composeSystemPrompt(this.#config.systemPrompt, this.#config.extensions ?? []);
|
|
440
447
|
const loopConfig = () => ({
|
|
441
448
|
adapter: this.#adapter,
|
|
442
449
|
model: this.#config.model,
|
|
443
|
-
...(
|
|
450
|
+
...(systemPrompt !== undefined ? { systemPrompt } : {}),
|
|
444
451
|
registry: this.#config.registry,
|
|
445
452
|
...(this.#config.hooks !== undefined ? { hooks: this.#config.hooks } : {}),
|
|
446
453
|
...(this.#config.maxTurns !== undefined ? { maxTurns: this.#config.maxTurns } : {}),
|
|
447
454
|
...(this.#config.maxTokens !== undefined ? { maxTokens: this.#config.maxTokens } : {}),
|
|
448
455
|
...(this.#config.temperature !== undefined ? { temperature: this.#config.temperature } : {}),
|
|
449
456
|
...(this.#config.compaction !== undefined ? { compaction: this.#config.compaction } : {}),
|
|
450
|
-
...(
|
|
457
|
+
...(microcompact !== undefined ? { microcompact } : {}),
|
|
451
458
|
...(this.#config.maxRetries !== undefined ? { maxRetries: this.#config.maxRetries } : {}),
|
|
452
459
|
approvalPolicies: (this.#config.extensions ?? []).flatMap((e) => (e.approvals ?? []).map((policy) => ({ extension: e.name, policy }))),
|
|
453
460
|
log,
|
|
@@ -867,6 +874,17 @@ export class Run {
|
|
|
867
874
|
});
|
|
868
875
|
}
|
|
869
876
|
}
|
|
877
|
+
/**
|
|
878
|
+
* E2: the session's systemPrompt plus every extension's append, in LOAD
|
|
879
|
+
* order, \n\n-joined — deterministic (same extension list → same prompt).
|
|
880
|
+
* No appends → the base passes through byte-identical.
|
|
881
|
+
*/
|
|
882
|
+
function composeSystemPrompt(base, extensions) {
|
|
883
|
+
const appends = extensions.flatMap((e) => (e.systemPrompt?.append === undefined ? [] : [e.systemPrompt.append]));
|
|
884
|
+
if (appends.length === 0)
|
|
885
|
+
return base;
|
|
886
|
+
return base === undefined ? appends.join("\n\n") : `${base}\n\n${appends.join("\n\n")}`;
|
|
887
|
+
}
|
|
870
888
|
/**
|
|
871
889
|
* E1: extension hooks compose AFTER the agent's own (既有先行 — the existing
|
|
872
890
|
* hook sees every event first). Observers all run, in order; onUserMessage
|
|
@@ -951,6 +969,23 @@ function composeHooks(existing, extensions) {
|
|
|
951
969
|
}
|
|
952
970
|
return out;
|
|
953
971
|
}
|
|
972
|
+
/**
|
|
973
|
+
* E2: the loop's microcompact config — the session's own microcompact wins;
|
|
974
|
+
* otherwise the FIRST extension providing a compaction config supplies it.
|
|
975
|
+
* An extension config without a threshold contributes nothing (a boundary
|
|
976
|
+
* needs a threshold to ever fire).
|
|
977
|
+
*/
|
|
978
|
+
function microcompactFor(config) {
|
|
979
|
+
if (config.microcompact !== undefined)
|
|
980
|
+
return config.microcompact;
|
|
981
|
+
for (const ext of config.extensions ?? []) {
|
|
982
|
+
const c = ext.compaction;
|
|
983
|
+
if (c !== undefined && c.thresholdTokens !== undefined) {
|
|
984
|
+
return { thresholdTokens: c.thresholdTokens, ...(c.keepResults !== undefined ? { keepResults: c.keepResults } : {}) };
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
return undefined;
|
|
988
|
+
}
|
|
954
989
|
/**
|
|
955
990
|
* The most recent run WITHOUT a terminal, or undefined when every recorded
|
|
956
991
|
* run terminated. Recovery can only drive ONE run to its terminal, so an
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vincemakes/kiso-runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "kiso runtime — durable multi-turn agent sessions: AgentDefinition, AgentRuntime, AgentSession, Run, append-only JSONL store.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"test": "vitest run"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@vincemakes/kiso-core": "0.1.
|
|
24
|
+
"@vincemakes/kiso-core": "0.1.7"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@vincemakes/kiso-provider-anthropic": "0.1.
|
|
28
|
-
"@vincemakes/kiso-provider-openai": "0.1.
|
|
27
|
+
"@vincemakes/kiso-provider-anthropic": "0.1.7",
|
|
28
|
+
"@vincemakes/kiso-provider-openai": "0.1.7"
|
|
29
29
|
},
|
|
30
30
|
"peerDependenciesMeta": {
|
|
31
31
|
"@vincemakes/kiso-provider-anthropic": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@vincemakes/kiso-evals": "0.1.
|
|
39
|
+
"@vincemakes/kiso-evals": "0.1.7",
|
|
40
40
|
"@types/node": "^26.1.2",
|
|
41
41
|
"typescript": "^5.7.2",
|
|
42
42
|
"vitest": "^3.0.0"
|