@vincemakes/kiso-runtime 0.1.11 → 0.1.13
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 +13 -43
- package/dist/trust.d.ts +2 -0
- package/dist/trust.js +7 -3
- package/package.json +5 -5
package/dist/session.js
CHANGED
|
@@ -787,6 +787,15 @@ export class Run {
|
|
|
787
787
|
result = await this.#config.hooks.onPostTool({ callId, name, input }, result, { sessionId: this.#session.id });
|
|
788
788
|
}
|
|
789
789
|
}
|
|
790
|
+
// 裁决 #12 修正一: the honest note rides the recovered failure too —
|
|
791
|
+
// the receipt and the repaired tool_result reproduce the live path
|
|
792
|
+
// losslessly.
|
|
793
|
+
if (result.isError && tool?.idempotent !== true) {
|
|
794
|
+
result = {
|
|
795
|
+
...result,
|
|
796
|
+
content: `${result.content}\n[non-idempotent tool failed — its side effects may have partially applied; verify before retrying]`,
|
|
797
|
+
};
|
|
798
|
+
}
|
|
790
799
|
if (result.isError) {
|
|
791
800
|
yield log.append({
|
|
792
801
|
type: "tool_execution_failed",
|
|
@@ -819,49 +828,10 @@ export class Run {
|
|
|
819
828
|
...(result.tags !== undefined ? { tags: result.tags } : {}),
|
|
820
829
|
executionId,
|
|
821
830
|
});
|
|
822
|
-
//
|
|
823
|
-
//
|
|
824
|
-
//
|
|
825
|
-
//
|
|
826
|
-
// resume blocks on it (ResumeBlockedError) instead of continuing.
|
|
827
|
-
if (result.isError && tool !== undefined && tool.idempotent !== true) {
|
|
828
|
-
const pendingResolution = new Promise((resolve) => {
|
|
829
|
-
this.#uncertaintyIds.push(executionId);
|
|
830
|
-
this.#session.registerUncertaintyResolver(executionId, resolve);
|
|
831
|
-
});
|
|
832
|
-
const pendingUncertain = log.append({
|
|
833
|
-
type: "uncertain_pending",
|
|
834
|
-
executionId,
|
|
835
|
-
callId,
|
|
836
|
-
name,
|
|
837
|
-
error: result.content,
|
|
838
|
-
});
|
|
839
|
-
yield pendingUncertain;
|
|
840
|
-
const verdict = await abortable(pendingResolution, signal);
|
|
841
|
-
if (verdict === ABORTED) {
|
|
842
|
-
// 第四轮(对抗): a verdict given in the same instant as the
|
|
843
|
-
// abort is recorded (exactly once), never lost.
|
|
844
|
-
const given = this.#session.uncertaintyVerdict(executionId);
|
|
845
|
-
if (given !== undefined) {
|
|
846
|
-
yield log.append({
|
|
847
|
-
type: "tool_execution_resolved",
|
|
848
|
-
executionId,
|
|
849
|
-
callId,
|
|
850
|
-
resolution: given,
|
|
851
|
-
});
|
|
852
|
-
}
|
|
853
|
-
return;
|
|
854
|
-
}
|
|
855
|
-
// 七: the recovery generator owns the resolution event — appended
|
|
856
|
-
// and yielded here, persisted by the Run's wrapper (a live
|
|
857
|
-
// resolveUncertain() only passed the verdict).
|
|
858
|
-
yield log.append({
|
|
859
|
-
type: "tool_execution_resolved",
|
|
860
|
-
executionId,
|
|
861
|
-
callId,
|
|
862
|
-
resolution: verdict,
|
|
863
|
-
});
|
|
864
|
-
}
|
|
831
|
+
// 裁决 #12 (ADR-0038): the failed-receipt uncertain PAUSE is REMOVED
|
|
832
|
+
// here too (it mirrored the live loop's C 组 pause) — a complete
|
|
833
|
+
// receipt IS the outcome; uncertainty belongs to the crash window
|
|
834
|
+
// alone. A retry passes the approval chain again.
|
|
865
835
|
}
|
|
866
836
|
/** The model-facing result of a durable denial — no execution happened. */
|
|
867
837
|
async *#denialResult(callId, reason) {
|
package/dist/trust.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ export interface ProjectArtifacts {
|
|
|
51
51
|
* no recognized artifacts (an empty .kiso has nothing to gate).
|
|
52
52
|
*/
|
|
53
53
|
export declare function projectArtifacts(cwd: string): Promise<ProjectArtifacts | null>;
|
|
54
|
+
/** 发现#11: KISO_HOME is the ONE root — the store derives from it. */
|
|
55
|
+
export declare function kisoHome(): string;
|
|
54
56
|
/**
|
|
55
57
|
* The last record matching (root, digest) — append-only, last wins. A
|
|
56
58
|
* corrupt line is skipped (trust is a memo, not an event stream — see the
|
package/dist/trust.js
CHANGED
|
@@ -49,7 +49,7 @@ export async function projectArtifacts(cwd) {
|
|
|
49
49
|
// never a project (KISO_HOME override respected the same way); a
|
|
50
50
|
// stale trust.jsonl grant for the home becomes inert — discovery
|
|
51
51
|
// returns null and never queries it.
|
|
52
|
-
const homeDir =
|
|
52
|
+
const homeDir = kisoHome();
|
|
53
53
|
let homeRoot = null;
|
|
54
54
|
try {
|
|
55
55
|
homeRoot = await realpath(homeDir);
|
|
@@ -120,8 +120,12 @@ async function readdirOrEmpty(dir) {
|
|
|
120
120
|
function isMissing(err) {
|
|
121
121
|
return err.code === "ENOENT" || err.code === "ENOTDIR";
|
|
122
122
|
}
|
|
123
|
+
/** 发现#11: KISO_HOME is the ONE root — the store derives from it. */
|
|
124
|
+
export function kisoHome() {
|
|
125
|
+
return process.env.KISO_HOME ?? join(homedir(), ".kiso");
|
|
126
|
+
}
|
|
123
127
|
function trustFile() {
|
|
124
|
-
return join(
|
|
128
|
+
return join(kisoHome(), "trust.jsonl");
|
|
125
129
|
}
|
|
126
130
|
/**
|
|
127
131
|
* The last record matching (root, digest) — append-only, last wins. A
|
|
@@ -157,7 +161,7 @@ export function trustFor(root, digest) {
|
|
|
157
161
|
/** Append one verdict. The same (root, digest) may be re-recorded — the
|
|
158
162
|
* newest record wins on read. */
|
|
159
163
|
export function recordTrust(record) {
|
|
160
|
-
const home =
|
|
164
|
+
const home = kisoHome();
|
|
161
165
|
mkdirSync(home, { recursive: true });
|
|
162
166
|
appendFileSync(join(home, "trust.jsonl"), `${JSON.stringify({ root: record.root, digest: record.digest, decision: record.decision, ts: record.ts ?? new Date().toISOString() })}\n`, "utf8");
|
|
163
167
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vincemakes/kiso-runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
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.13"
|
|
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.13",
|
|
28
|
+
"@vincemakes/kiso-provider-openai": "0.1.13"
|
|
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.13",
|
|
40
40
|
"@types/node": "^26.1.2",
|
|
41
41
|
"typescript": "^5.7.2",
|
|
42
42
|
"vitest": "^3.0.0"
|