






















@@ -40,11 +40,7 @@ import {
4040import { buildPluginAgentTurnPrepareContext, isPluginJsonValue } from "../host-hooks.js";
4141import { createEmptyPluginRegistry } from "../registry-empty.js";
4242import { createPluginRegistry } from "../registry.js";
43-import {
44-pinActivePluginSessionExtensionRegistry,
45-releasePinnedPluginSessionExtensionRegistry,
46-setActivePluginRegistry,
47-} from "../runtime.js";
43+import { setActivePluginRegistry } from "../runtime.js";
4844import type { PluginRuntime } from "../runtime/types.js";
4945import { createPluginRecord } from "../status.test-helpers.js";
5046import { runTrustedToolPolicies } from "../trusted-tool-policy.js";
@@ -124,7 +120,6 @@ async function withHostHookState(
124120125121describe("host-hook fixture plugin contract", () => {
126122afterEach(() => {
127-releasePinnedPluginSessionExtensionRegistry();
128123setActivePluginRegistry(createEmptyPluginRegistry());
129124clearPluginHostRuntimeState();
130125resetAgentEventsForTest();
@@ -1563,138 +1558,6 @@ describe("host-hook fixture plugin contract", () => {
15631558});
15641559});
156515601566-it("patches and projects pinned session extensions after active registry churn", async () => {
1567-const { config, registry } = createPluginRegistryFixture();
1568-registerTestPlugin({
1569- registry,
1570- config,
1571-record: createPluginRecord({
1572-id: "session-pin-fixture",
1573-name: "Session Pin Fixture",
1574-}),
1575-register(api) {
1576-api.registerSessionExtension({
1577-namespace: "workflow",
1578-description: "Pinned workflow state",
1579-});
1580-},
1581-});
1582-setActivePluginRegistry(registry.registry);
1583-pinActivePluginSessionExtensionRegistry(registry.registry);
1584-setActivePluginRegistry(createEmptyPluginRegistry());
1585-1586-await withHostHookState(
1587-"openclaw-host-hooks-session-pin-",
1588-async ({ storePath, tempConfig }) => {
1589-await updateSessionStore(storePath, (store) => {
1590-store["agent:main:main"] = {
1591-sessionId: "session-1",
1592-updatedAt: Date.now(),
1593-};
1594-return undefined;
1595-});
1596-1597-await expect(
1598-patchPluginSessionExtension({
1599-cfg: tempConfig,
1600-sessionKey: "agent:main:main",
1601-pluginId: "session-pin-fixture",
1602-namespace: "workflow",
1603-value: { state: "approved" },
1604-}),
1605-).resolves.toEqual({
1606-ok: true,
1607-key: "agent:main:main",
1608-value: { state: "approved" },
1609-});
1610-1611-const entry = loadSessionStore(storePath)["agent:main:main"];
1612-expect(entry).toBeDefined();
1613-expect(
1614-projectPluginSessionExtensionsSync({
1615-sessionKey: "agent:main:main",
1616- entry,
1617-}),
1618-).toEqual([
1619-{
1620-pluginId: "session-pin-fixture",
1621-namespace: "workflow",
1622-value: { state: "approved" },
1623-},
1624-]);
1625-},
1626-);
1627-});
1628-1629-it("stops patching released pinned session extensions after registry removal", async () => {
1630-const { config, registry } = createPluginRegistryFixture();
1631-registerTestPlugin({
1632- registry,
1633- config,
1634-record: createPluginRecord({
1635-id: "session-release-fixture",
1636-name: "Session Release Fixture",
1637-}),
1638-register(api) {
1639-api.registerSessionExtension({
1640-namespace: "workflow",
1641-description: "Released workflow state",
1642-});
1643-},
1644-});
1645-setActivePluginRegistry(registry.registry);
1646-pinActivePluginSessionExtensionRegistry(registry.registry);
1647-setActivePluginRegistry(createEmptyPluginRegistry());
1648-1649-await withHostHookState(
1650-"openclaw-host-hooks-session-release-",
1651-async ({ storePath, tempConfig }) => {
1652-await updateSessionStore(storePath, (store) => {
1653-store["agent:main:main"] = {
1654-sessionId: "session-1",
1655-updatedAt: Date.now(),
1656-};
1657-return undefined;
1658-});
1659-1660-await expect(
1661-patchPluginSessionExtension({
1662-cfg: tempConfig,
1663-sessionKey: "agent:main:main",
1664-pluginId: "session-release-fixture",
1665-namespace: "workflow",
1666-value: { state: "before-release" },
1667-}),
1668-).resolves.toEqual({
1669-ok: true,
1670-key: "agent:main:main",
1671-value: { state: "before-release" },
1672-});
1673-1674-releasePinnedPluginSessionExtensionRegistry(registry.registry);
1675-1676-await expect(
1677-patchPluginSessionExtension({
1678-cfg: tempConfig,
1679-sessionKey: "agent:main:main",
1680-pluginId: "session-release-fixture",
1681-namespace: "workflow",
1682-value: { state: "after-release" },
1683-}),
1684-).resolves.toEqual({
1685-ok: false,
1686-error: "unknown plugin session extension: session-release-fixture/workflow",
1687-});
1688-1689-const entry = loadSessionStore(storePath)["agent:main:main"];
1690-expect(entry).toBeDefined();
1691-expect(
1692-projectPluginSessionExtensionsSync({ sessionKey: "agent:main:main", entry }),
1693-).toEqual([]);
1694-},
1695-);
1696-});
1697-16981561it("models queued next-turn injections and agent_turn_prepare as one prompt context", async () => {
16991562const { config, registry } = createPluginRegistryFixture();
17001563registerTestPlugin({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。