@code-yeongyu/senpi-agent-core 2026.11.3-2 → 2026.11.3-3
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/conformance/index.d.ts +14 -0
- package/dist/conformance/index.js +8 -0
- package/dist/conformance/registry.js +22 -0
- package/dist/execution/coordinator-codec.d.ts +5 -0
- package/dist/execution/coordinator-codec.js +93 -0
- package/dist/execution/coordinator-plan.d.ts +33 -0
- package/dist/execution/coordinator-plan.js +106 -0
- package/dist/execution/coordinator-types.d.ts +116 -0
- package/dist/execution/coordinator-types.js +2 -0
- package/dist/execution/coordinator.d.ts +25 -0
- package/dist/execution/coordinator.js +132 -0
- package/dist/execution/grant-verify.d.ts +70 -0
- package/dist/execution/grant-verify.js +87 -0
- package/dist/execution/ledger.d.ts +2 -0
- package/dist/execution/ledger.js +1 -0
- package/dist/execution/remote-executor.d.ts +64 -0
- package/dist/execution/remote-executor.js +159 -0
- package/dist/execution/remote-hand-ledger.d.ts +40 -0
- package/dist/execution/remote-hand-ledger.js +137 -0
- package/dist/execution/remote-protocol.d.ts +87 -0
- package/dist/execution/remote-protocol.js +88 -0
- package/dist/execution/remote-tool-host.d.ts +29 -0
- package/dist/execution/remote-tool-host.js +155 -0
- package/dist/execution/testing/batch-cases.d.ts +6 -0
- package/dist/execution/testing/batch-cases.js +210 -0
- package/dist/execution/testing/batch-executor.d.ts +34 -0
- package/dist/execution/testing/batch-executor.js +141 -0
- package/dist/execution/testing/batch-harness.d.ts +36 -0
- package/dist/execution/testing/batch-harness.js +208 -0
- package/dist/execution/testing/batch-registry.d.ts +3 -0
- package/dist/execution/testing/batch-registry.js +30 -0
- package/dist/execution/testing/fault-hand-cases.d.ts +6 -0
- package/dist/execution/testing/fault-hand-cases.js +70 -0
- package/dist/execution/testing/hand-harness.d.ts +48 -0
- package/dist/execution/testing/hand-harness.js +136 -0
- package/dist/execution/testing/kill-batch.d.ts +12 -0
- package/dist/execution/testing/kill-batch.js +70 -0
- package/dist/execution/testing/kill-hand.d.ts +16 -0
- package/dist/execution/testing/kill-hand.js +75 -0
- package/dist/execution/testing/multi-hand-cases.d.ts +6 -0
- package/dist/execution/testing/multi-hand-cases.js +44 -0
- package/dist/harness/env/nodejs.js +4 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +8 -0
- package/package.json +3 -3
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { TOOL_RESULT_PLACEHOLDER } from "@earendil-works/pi-ai";
|
|
2
|
+
import { expectEqual } from "../../durable/testing/store-harness.js";
|
|
3
|
+
import { call, openHandRig } from "./hand-harness.js";
|
|
4
|
+
/** The ledger commits one call makes on a hand, in order. */
|
|
5
|
+
const COMMITS = ["admit", "prepare", "effect", "freeze", "release", "dispatch", "settle", "ack"];
|
|
6
|
+
const PLACEMENTS = ["split-local", "cross-machine"];
|
|
7
|
+
function expectedAfter(lastDurable) {
|
|
8
|
+
if (lastDurable < 0)
|
|
9
|
+
return { outcome: "result" };
|
|
10
|
+
if (lastDurable <= 2)
|
|
11
|
+
return { outcome: "restarted", uncertain: lastDurable >= 2 };
|
|
12
|
+
if (lastDurable <= 4)
|
|
13
|
+
return { outcome: "result" };
|
|
14
|
+
if (lastDurable === 5)
|
|
15
|
+
return { outcome: "restarted", uncertain: true };
|
|
16
|
+
return { outcome: "result" };
|
|
17
|
+
}
|
|
18
|
+
/** How many times the body ran in total: once, or never when the kill came before it ran. */
|
|
19
|
+
function bodyRuns(kill, lastDurable) {
|
|
20
|
+
if (lastDurable >= 0 && lastDurable <= 2)
|
|
21
|
+
return 0;
|
|
22
|
+
if (lastDurable === 5)
|
|
23
|
+
return kill.commit === 6 ? 1 : 0;
|
|
24
|
+
return 1;
|
|
25
|
+
}
|
|
26
|
+
function describeExpected(placement, expected, runs) {
|
|
27
|
+
const body = runs === 0 ? "the tool never runs" : "the tool runs exactly once";
|
|
28
|
+
if (expected.outcome === "result")
|
|
29
|
+
return `the session gets the tool's result; ${body}`;
|
|
30
|
+
return placement === "split-local"
|
|
31
|
+
? `the session gets today's placeholder result, no uncertain outcome; ${body}`
|
|
32
|
+
: `the session gets hand_restarted, ${expected.uncertain ? "uncertain" : "not uncertain"}, never rerun; ${body}`;
|
|
33
|
+
}
|
|
34
|
+
const cases = COMMITS.flatMap((operation, commit) => ["before", "durable"].flatMap((at) => PLACEMENTS.map((placement) => {
|
|
35
|
+
const kill = { commit, at };
|
|
36
|
+
const lastDurable = at === "durable" ? commit : commit - 1;
|
|
37
|
+
const expected = expectedAfter(lastDurable);
|
|
38
|
+
const runs = bodyRuns(kill, lastDurable);
|
|
39
|
+
const id = `KILL-HAND-${String(commit + 1).padStart(2, "0")}-${at === "before" ? "B" : "D"}-${placement === "split-local" ? "SL" : "XM"}`;
|
|
40
|
+
const what = `${id} (${operation} ${at}, ${placement})`;
|
|
41
|
+
const run = async (adapters) => {
|
|
42
|
+
const rig = await openHandRig(adapters, { placement, killAt: kill });
|
|
43
|
+
const outcome = rig.execute("scope", [call("c1")]);
|
|
44
|
+
await rig.settle(rig.killed, `${what}: the kill point fired`);
|
|
45
|
+
await rig.restart();
|
|
46
|
+
const { messages } = await rig.settle(outcome, `${what}: the session got the call's outcome`);
|
|
47
|
+
await rig.advance(200);
|
|
48
|
+
const [message] = messages;
|
|
49
|
+
const text = message?.content.map((part) => (part.type === "text" ? part.text : "")).join("");
|
|
50
|
+
if (expected.outcome === "result") {
|
|
51
|
+
expectEqual([text, message?.isError], ["ran:c1", false], `${what}: the tool's result`);
|
|
52
|
+
}
|
|
53
|
+
else if (placement === "split-local") {
|
|
54
|
+
expectEqual([text, message?.isError], [TOOL_RESULT_PLACEHOLDER, false], `${what}: today's placeholder`);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
expectEqual(message?.details, { outcome: "hand_restarted", uncertain: expected.uncertain, hooksRan: expected.uncertain }, `${what}: the endpoint outcome`);
|
|
58
|
+
expectEqual(message?.isError, true, `${what}: reported as an error`);
|
|
59
|
+
}
|
|
60
|
+
expectEqual(rig.bodies.length, runs, `${what}: tool body runs`);
|
|
61
|
+
const rows = await rig.rows();
|
|
62
|
+
expectEqual(rows.map((row) => row.progress.state), ["acked"], `${what}: one durable record, acknowledged`);
|
|
63
|
+
};
|
|
64
|
+
const declaration = {
|
|
65
|
+
id,
|
|
66
|
+
operation,
|
|
67
|
+
at,
|
|
68
|
+
placement,
|
|
69
|
+
expected: `${placement}: kill ${at} the ${operation} commit; ${describeExpected(placement, expected, runs)}; one durable record`,
|
|
70
|
+
};
|
|
71
|
+
return { declaration, run };
|
|
72
|
+
})));
|
|
73
|
+
export const KILL_HAND_DECLARATIONS = cases.map(({ declaration }) => declaration);
|
|
74
|
+
export const KILL_HAND_CASES = new Map(cases.map(({ declaration, run }) => [declaration.id, run]));
|
|
75
|
+
//# sourceMappingURL=kill-hand.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CaseImplementation } from "../../conformance/runner.ts";
|
|
2
|
+
import { type HandCaseAdapters } from "./hand-harness.ts";
|
|
3
|
+
type HandCase = CaseImplementation<HandCaseAdapters>;
|
|
4
|
+
export declare const MULTI_HAND_CASES: ReadonlyMap<string, HandCase>;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=multi-hand-cases.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { expectEqual } from "../../durable/testing/store-harness.js";
|
|
2
|
+
import { call, openHandRig } from "./hand-harness.js";
|
|
3
|
+
const SCOPES = ["a", "b", "c"];
|
|
4
|
+
const CALLS_PER_SCOPE = 3;
|
|
5
|
+
const callIds = (scope) => Array.from({ length: CALLS_PER_SCOPE }, (_, index) => `${scope}${index + 1}`);
|
|
6
|
+
const texts = (messages) => messages.map((message) => message.content.map((part) => (part.type === "text" ? part.text : "")).join(""));
|
|
7
|
+
/** Several sessions' scopes run batches at once on one hand: each scope's calls start in its lane order. */
|
|
8
|
+
const manyScopesOnOneHand = async (adapters) => {
|
|
9
|
+
const rig = await openHandRig(adapters, { placement: "split-local" });
|
|
10
|
+
rig.gateBodies();
|
|
11
|
+
const batches = SCOPES.map((scope) => rig.execute(scope, callIds(scope).map(call)));
|
|
12
|
+
await rig.runUntil(() => rig.bodies.length === SCOPES.length * CALLS_PER_SCOPE, "MULTI-HAND-01: every body started");
|
|
13
|
+
for (const scope of SCOPES)
|
|
14
|
+
expectEqual(rig.bodies.filter((body) => body.startsWith(`${scope}:`)), callIds(scope).map((id) => `${scope}:${id}`), `MULTI-HAND-01: scope ${scope} kept its lane order`);
|
|
15
|
+
for (const scope of [...SCOPES].reverse())
|
|
16
|
+
for (const id of [...callIds(scope)].reverse())
|
|
17
|
+
rig.release(id);
|
|
18
|
+
const results = await rig.settle(Promise.all(batches), "MULTI-HAND-01: every batch settled");
|
|
19
|
+
expectEqual(results.map(({ messages }) => texts(messages)), SCOPES.map((scope) => callIds(scope).map((id) => `ran:${id}`)), "MULTI-HAND-01: each scope's results in its source order");
|
|
20
|
+
};
|
|
21
|
+
/** A hand killed with several scopes' calls in flight: each scope recovers on its own, nothing runs twice. */
|
|
22
|
+
const killWithScopesInFlight = async (adapters) => {
|
|
23
|
+
const dispatchCommits = SCOPES.length * 6;
|
|
24
|
+
const rig = await openHandRig(adapters, {
|
|
25
|
+
placement: "cross-machine",
|
|
26
|
+
killAt: { commit: dispatchCommits, at: "before" },
|
|
27
|
+
});
|
|
28
|
+
rig.gateBodies();
|
|
29
|
+
const batches = SCOPES.map((scope) => rig.execute(scope, [call(`${scope}1`)]));
|
|
30
|
+
await rig.runUntil(() => rig.bodies.length === SCOPES.length, "MULTI-KILL-01: every scope's call is running");
|
|
31
|
+
rig.release("a1");
|
|
32
|
+
await rig.settle(rig.killed, "MULTI-KILL-01: the hand died while the scopes were in flight");
|
|
33
|
+
await rig.restart();
|
|
34
|
+
const results = await rig.settle(Promise.all(batches), "MULTI-KILL-01: every scope got its outcome");
|
|
35
|
+
expectEqual(results.map(({ messages }) => messages.map((message) => message.details)), SCOPES.map(() => [{ outcome: "hand_restarted", uncertain: true, hooksRan: true }]), "MULTI-KILL-01: each scope's call ended hand_restarted, uncertain");
|
|
36
|
+
expectEqual(rig.bodies, SCOPES.map((scope) => `${scope}:${scope}1`), "MULTI-KILL-01: no call ran twice");
|
|
37
|
+
await rig.advance(200);
|
|
38
|
+
expectEqual((await rig.rows()).map((row) => row.progress.state), SCOPES.map(() => "acked"), "MULTI-KILL-01: one durable record per call, acknowledged");
|
|
39
|
+
};
|
|
40
|
+
export const MULTI_HAND_CASES = new Map([
|
|
41
|
+
["MULTI-HAND-01", manyScopesOnOneHand],
|
|
42
|
+
["MULTI-KILL-01", killWithScopesInFlight],
|
|
43
|
+
]);
|
|
44
|
+
//# sourceMappingURL=multi-hand-cases.js.map
|
|
@@ -888,6 +888,10 @@ export class NodeExecutionEnv {
|
|
|
888
888
|
infos.push(info.value);
|
|
889
889
|
}
|
|
890
890
|
catch (error) {
|
|
891
|
+
// Another process can remove an entry after readdir listed it (a released lock
|
|
892
|
+
// directory, a renamed staging file); the listing omits it as if readdir had run later.
|
|
893
|
+
if (isNodeError(error) && error.code === "ENOENT")
|
|
894
|
+
continue;
|
|
891
895
|
return err(toFileError(error, entryPath));
|
|
892
896
|
}
|
|
893
897
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,15 @@ export * from "./agent.ts";
|
|
|
5
5
|
export * from "./agent-loop.ts";
|
|
6
6
|
export { createInternalAgentChannel, type InternalAgentChannel, type OrderedAgentRecord } from "./internal-events.ts";
|
|
7
7
|
export { EMPTY_TOOL_USE_DEMOTION_DIAGNOSTIC, ProviderRetryWatchdogAbortError } from "./assistant-terminal-state.ts";
|
|
8
|
+
export { createRemoteExecutor, type HandCall, type HandScope, type OpenHandScope, type RemoteExecutor, type RemoteExecutorOptions, } from "./execution/remote-executor.ts";
|
|
9
|
+
export { createHandLedger, type HandAdmission, type HandLedger, type HandLedgerOptions, } from "./execution/remote-hand-ledger.ts";
|
|
10
|
+
export { decodeRemoteMessage, encodeRemoteMessage, HAND_CONTROL_LANE, type RemoteAbort, type RemoteAck, type RemoteHandMessage, type RemoteHello, type RemoteInvoke, type RemoteRefused, type RemoteSettled, RemoteProtocolError, type RemoteTerminal, type RemoteTerminalReason, type RemoteToolResult, } from "./execution/remote-protocol.ts";
|
|
11
|
+
export { authorize, createGrantVerifier, DEFAULT_WORKSPACE, type GrantRefusal, type GrantRow, type GrantSnapshot, type GrantVerdict, type GrantVerifier, type GrantVerifierOptions, HAND_CAPABILITY, type HandAuthority, type WorkspaceRoot, } from "./execution/grant-verify.ts";
|
|
12
|
+
export { createRemoteToolHost, type HandPlacement, type RemoteToolHostOptions } from "./execution/remote-tool-host.ts";
|
|
13
|
+
export { type CarrierLink, createInProcessNetwork, type InProcessNetwork } from "./transport/in-process-carrier.ts";
|
|
14
|
+
export { type LocalEndpoint, localEndpoint } from "./transport/local-endpoint.ts";
|
|
15
|
+
export { createReliableTransport, type ReliableTransportOptions } from "./transport/reliable-transport.ts";
|
|
16
|
+
export type { Transport, TransportClock, TransportFrame, TransportSide } from "./transport/transport.ts";
|
|
8
17
|
export * from "./harness/agent-harness.ts";
|
|
9
18
|
export { type BranchPreparation, type BranchSummaryDetails, type BranchSummaryResult, type CollectEntriesResult, collectEntriesForBranchSummary, type FileOperations, type GenerateBranchSummaryOptions, generateBranchSummary, prepareBranchEntries, } from "./harness/compaction/branch-summarization.ts";
|
|
10
19
|
export { type CompactionPreparation, type CompactionSettings, type CompactResult, calculateContextTokens, compact, DEFAULT_COMPACTION_SETTINGS, estimateContextTokens, estimateTokens, findCutPoint, findTurnStartIndex, generateSummary, generateSummaryWithUsage, getLastAssistantUsage, prepareCompaction, serializeConversation, shouldCompact, } from "./harness/compaction/compaction.ts";
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,14 @@ export * from "./agent.js";
|
|
|
4
4
|
export * from "./agent-loop.js";
|
|
5
5
|
export { createInternalAgentChannel } from "./internal-events.js";
|
|
6
6
|
export { EMPTY_TOOL_USE_DEMOTION_DIAGNOSTIC, ProviderRetryWatchdogAbortError } from "./assistant-terminal-state.js";
|
|
7
|
+
export { createRemoteExecutor, } from "./execution/remote-executor.js";
|
|
8
|
+
export { createHandLedger, } from "./execution/remote-hand-ledger.js";
|
|
9
|
+
export { decodeRemoteMessage, encodeRemoteMessage, HAND_CONTROL_LANE, RemoteProtocolError, } from "./execution/remote-protocol.js";
|
|
10
|
+
export { authorize, createGrantVerifier, DEFAULT_WORKSPACE, HAND_CAPABILITY, } from "./execution/grant-verify.js";
|
|
11
|
+
export { createRemoteToolHost } from "./execution/remote-tool-host.js";
|
|
12
|
+
export { createInProcessNetwork } from "./transport/in-process-carrier.js";
|
|
13
|
+
export { localEndpoint } from "./transport/local-endpoint.js";
|
|
14
|
+
export { createReliableTransport } from "./transport/reliable-transport.js";
|
|
7
15
|
export * from "./harness/agent-harness.js";
|
|
8
16
|
export { collectEntriesForBranchSummary, generateBranchSummary, prepareBranchEntries, } from "./harness/compaction/branch-summarization.js";
|
|
9
17
|
export { calculateContextTokens, compact, DEFAULT_COMPACTION_SETTINGS, estimateContextTokens, estimateTokens, findCutPoint, findTurnStartIndex, generateSummary, generateSummaryWithUsage, getLastAssistantUsage, prepareCompaction, serializeConversation, shouldCompact, } from "./harness/compaction/compaction.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-yeongyu/senpi-agent-core",
|
|
3
|
-
"version": "2026.11.3-
|
|
3
|
+
"version": "2026.11.3-3",
|
|
4
4
|
"description": "General-purpose agent with transport abstraction, state management, and attachment support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@earendil-works/chord": "0.99.1",
|
|
75
|
-
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.11.3-
|
|
76
|
-
"@earendil-works/pi-telemetry": "npm:@code-yeongyu/senpi-telemetry@2026.11.3-
|
|
75
|
+
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.11.3-3",
|
|
76
|
+
"@earendil-works/pi-telemetry": "npm:@code-yeongyu/senpi-telemetry@2026.11.3-3",
|
|
77
77
|
"diff": "9.0.0",
|
|
78
78
|
"ignore": "7.0.9",
|
|
79
79
|
"typebox": "1.3.34",
|