Skip to content

Commit 43f2bc2

Browse files
committed
refactor(playbooks): drop unused readiness mapping
readinessFromPick, PlaybookReadiness, and their tests have no production consumer: the server's agent readiness flows through the sdk's listAgentsWithReadiness instead. Remove the dead code before inlining the session runtime. Change-Id: I131ba28e7fbee9ec2aaf3a44467d27bc590dfd28 Co-developed-by: OpenCode <noreply@opencode.ai>
1 parent c00849d commit 43f2bc2

3 files changed

Lines changed: 0 additions & 65 deletions

File tree

packages/playbooks/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export {
5454
pickPlaybookAgent,
5555
PlaybookAgentIdentityMismatchError,
5656
playbookIdentityMismatchMessage,
57-
readinessFromPick,
5857
} from "./session-runtime.ts";
5958

6059
export type {
@@ -83,7 +82,6 @@ export type {
8382
PlaybookAgentAdapter,
8483
PlaybookAgentPick,
8584
PlaybookProviderSessionAdapter,
86-
PlaybookReadiness,
8785
PlaybookSessionEventsAdapter,
8886
PlaybookSessionFile,
8987
PlaybookSessionRuntime,

packages/playbooks/src/session-runtime.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ export type PlaybookAgentPick<TAgent extends RemotePlaybookAgent> = {
7676
identityMismatch: boolean;
7777
};
7878

79-
export type PlaybookReadiness =
80-
| { status: "ready"; playbookId: string; remoteAgentId: string }
81-
| { status: "missing"; playbookId: string; reason: "not_provisioned" }
82-
| { status: "unknown"; playbookId: string; reason: "not_checked" | "check_failed" }
83-
| { status: "blocked"; playbookId: string; reason: "identity_mismatch"; message: string };
84-
8579
export interface PlaybookAgentAdapter<TAgent extends RemotePlaybookAgent = RemotePlaybookAgent> {
8680
listPlaybookAgents(input: { playbookId: string; includeArchived: boolean }): Promise<TAgent[]>;
8781
ensurePlaybookAgent(input: { playbookId: string; model?: string; matched?: TAgent }): Promise<TAgent>;
@@ -159,24 +153,6 @@ export function pickPlaybookAgent<TAgent extends RemotePlaybookAgent>(
159153
return { agent, duplicates, identityMismatch: false };
160154
}
161155

162-
// The single source of the pick→PlaybookReadiness mapping, so identity-drift
163-
// handling lives in one place.
164-
export function readinessFromPick<TAgent extends RemotePlaybookAgent>(
165-
pick: PlaybookAgentPick<TAgent>,
166-
playbookId: string,
167-
): PlaybookReadiness {
168-
if (pick.identityMismatch) {
169-
return {
170-
status: "blocked",
171-
playbookId,
172-
reason: "identity_mismatch",
173-
message: playbookIdentityMismatchMessage(playbookId),
174-
};
175-
}
176-
if (!pick.agent) return { status: "missing", playbookId, reason: "not_provisioned" };
177-
return { status: "ready", playbookId, remoteAgentId: pick.agent.id };
178-
}
179-
180156
export function createPlaybookSessionRuntime<
181157
TDetail,
182158
TEvent = unknown,

packages/playbooks/tests/session-runtime.test.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import {
55
PLAYBOOK_METADATA_KEY,
66
PlaybookAgentIdentityMismatchError,
77
pickPlaybookAgent,
8-
playbookIdentityMismatchMessage,
98
type RemotePlaybookAgent,
10-
readinessFromPick,
119
} from "../src/index.ts";
1210

1311
const APP_ID = "agents-webui";
@@ -62,43 +60,6 @@ describe("pickPlaybookAgent", () => {
6260
});
6361
});
6462

65-
describe("readinessFromPick", () => {
66-
test("a matched agent is ready and carries its remote id", () => {
67-
const pick = pickPlaybookAgent([agent({ id: "agent_ready" })], { playbookId: "designer", appId: APP_ID });
68-
69-
expect(readinessFromPick(pick, "designer")).toEqual({
70-
status: "ready",
71-
playbookId: "designer",
72-
remoteAgentId: "agent_ready",
73-
});
74-
});
75-
76-
test("no candidate is missing/not_provisioned", () => {
77-
const pick = pickPlaybookAgent([], { playbookId: "designer", appId: APP_ID });
78-
79-
expect(readinessFromPick(pick, "designer")).toEqual({
80-
status: "missing",
81-
playbookId: "designer",
82-
reason: "not_provisioned",
83-
});
84-
});
85-
86-
test("a same-name unstamped agent is blocked with the shared mismatch message", () => {
87-
const pick = pickPlaybookAgent([agent({ metadata: { [PLAYBOOK_APP_METADATA_KEY]: APP_ID } })], {
88-
playbookId: "designer",
89-
appId: APP_ID,
90-
expectedAgentName: "Agents/设计师助手",
91-
});
92-
93-
expect(readinessFromPick(pick, "designer")).toEqual({
94-
status: "blocked",
95-
playbookId: "designer",
96-
reason: "identity_mismatch",
97-
message: playbookIdentityMismatchMessage("designer"),
98-
});
99-
});
100-
});
101-
10263
describe("createPlaybookSessionRuntime", () => {
10364
test("start ensures the selected agent, starts the provider session, attaches events, then returns detail", async () => {
10465
const calls: string[] = [];

0 commit comments

Comments
 (0)