mirror of
http://192.168.0.88:13333/lywsvip/openclaw-zero-token.git
synced 2026-05-14 04:57:17 +08:00
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
116 lines
2.5 KiB
TypeScript
116 lines
2.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
deriveGatewaySessionLifecycleSnapshot,
|
|
derivePersistedSessionLifecyclePatch,
|
|
} from "./session-lifecycle-state.js";
|
|
|
|
describe("session lifecycle state", () => {
|
|
it("reactivates completed sessions on lifecycle start", () => {
|
|
expect(
|
|
deriveGatewaySessionLifecycleSnapshot({
|
|
session: {
|
|
updatedAt: 500,
|
|
status: "done",
|
|
startedAt: 100,
|
|
endedAt: 400,
|
|
runtimeMs: 300,
|
|
abortedLastRun: true,
|
|
},
|
|
event: {
|
|
ts: 1_000,
|
|
data: {
|
|
phase: "start",
|
|
startedAt: 900,
|
|
},
|
|
},
|
|
}),
|
|
).toEqual({
|
|
updatedAt: 900,
|
|
status: "running",
|
|
startedAt: 900,
|
|
endedAt: undefined,
|
|
runtimeMs: undefined,
|
|
abortedLastRun: false,
|
|
});
|
|
});
|
|
|
|
it("marks completed lifecycle end events as done with terminal timing", () => {
|
|
expect(
|
|
deriveGatewaySessionLifecycleSnapshot({
|
|
session: {
|
|
updatedAt: 1_000,
|
|
status: "running",
|
|
startedAt: 1_200,
|
|
},
|
|
event: {
|
|
ts: 2_000,
|
|
data: {
|
|
phase: "end",
|
|
startedAt: 1_200,
|
|
endedAt: 1_900,
|
|
},
|
|
},
|
|
}),
|
|
).toEqual({
|
|
updatedAt: 1_900,
|
|
status: "done",
|
|
startedAt: 1_200,
|
|
endedAt: 1_900,
|
|
runtimeMs: 700,
|
|
abortedLastRun: false,
|
|
});
|
|
});
|
|
|
|
it("maps aborted stop reasons to killed", () => {
|
|
expect(
|
|
derivePersistedSessionLifecyclePatch({
|
|
entry: {
|
|
updatedAt: 1_000,
|
|
startedAt: 1_100,
|
|
},
|
|
event: {
|
|
ts: 2_000,
|
|
data: {
|
|
phase: "end",
|
|
endedAt: 1_800,
|
|
stopReason: "aborted",
|
|
},
|
|
},
|
|
}),
|
|
).toEqual({
|
|
updatedAt: 1_800,
|
|
status: "killed",
|
|
startedAt: 1_100,
|
|
endedAt: 1_800,
|
|
runtimeMs: 700,
|
|
abortedLastRun: true,
|
|
});
|
|
});
|
|
|
|
it("maps aborted lifecycle end events without stopReason to timeout", () => {
|
|
expect(
|
|
derivePersistedSessionLifecyclePatch({
|
|
entry: {
|
|
updatedAt: 1_000,
|
|
startedAt: 1_050,
|
|
},
|
|
event: {
|
|
ts: 2_000,
|
|
data: {
|
|
phase: "end",
|
|
endedAt: 1_550,
|
|
aborted: true,
|
|
},
|
|
},
|
|
}),
|
|
).toEqual({
|
|
updatedAt: 1_550,
|
|
status: "timeout",
|
|
startedAt: 1_050,
|
|
endedAt: 1_550,
|
|
runtimeMs: 500,
|
|
abortedLastRun: false,
|
|
});
|
|
});
|
|
});
|