Skip to content

Commit d320f13

Browse files
authored
feat(byoc): runtime config, sessions and vaults updates (#32)
Change-Id: I5d340bb58f1d0d9a68607024aa49fe0b37c1eab6 Co-developed-by: Qoder <noreply@qoder.com>
1 parent 414589e commit d320f13

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

apps/server/src/services/sessions/playbook-session-adapter/runtime.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
PlaybookAgentIdentityMismatchError,
77
pickPlaybookAgent,
88
type RemotePlaybookAgent,
9+
readinessFromPick,
910
} from "./runtime";
1011
import type { PlaybookSessionDetail } from "./sessions";
1112

@@ -77,6 +78,28 @@ describe("pickPlaybookAgent", () => {
7778
});
7879
});
7980

81+
describe("readinessFromPick", () => {
82+
test("maps agent picks to playbook readiness states", () => {
83+
expect(readinessFromPick({ agent: agent(), duplicates: [], identityMismatch: false }, "designer")).toEqual({
84+
status: "ready",
85+
playbookId: "designer",
86+
remoteAgentId: "agent_1",
87+
});
88+
89+
expect(readinessFromPick({ agent: undefined, duplicates: [], identityMismatch: false }, "designer")).toEqual({
90+
status: "missing",
91+
playbookId: "designer",
92+
reason: "not_provisioned",
93+
});
94+
95+
expect(readinessFromPick({ agent: undefined, duplicates: [], identityMismatch: true }, "designer")).toMatchObject({
96+
status: "blocked",
97+
playbookId: "designer",
98+
reason: "identity_mismatch",
99+
});
100+
});
101+
});
102+
80103
describe("createPlaybookSessionRuntime", () => {
81104
test("start ensures the selected agent, starts the provider session, attaches events, then returns detail", async () => {
82105
const calls: string[] = [];

apps/server/src/services/sessions/playbook-session-adapter/runtime.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ export type PlaybookAgentPick = {
9494
identityMismatch: boolean;
9595
};
9696

97+
export type PlaybookReadiness =
98+
| { status: "ready"; playbookId: string; remoteAgentId: string }
99+
| { status: "missing"; playbookId: string; reason: "not_provisioned" }
100+
| { status: "unknown"; playbookId: string; reason: "not_checked" | "check_failed" }
101+
| { status: "blocked"; playbookId: string; reason: "identity_mismatch"; message: string };
102+
97103
// ---------------------------------------------------------------------------
98104
// Identity-mismatch error
99105
// ---------------------------------------------------------------------------
@@ -135,6 +141,21 @@ export function pickPlaybookAgent(
135141
return { agent, duplicates, identityMismatch: false };
136142
}
137143

144+
// The single source of the pick-to-readiness mapping, so identity-drift
145+
// handling lives in one place.
146+
export function readinessFromPick(pick: PlaybookAgentPick, playbookId: string): PlaybookReadiness {
147+
if (pick.identityMismatch) {
148+
return {
149+
status: "blocked",
150+
playbookId,
151+
reason: "identity_mismatch",
152+
message: playbookIdentityMismatchMessage(playbookId),
153+
};
154+
}
155+
if (!pick.agent) return { status: "missing", playbookId, reason: "not_provisioned" };
156+
return { status: "ready", playbookId, remoteAgentId: pick.agent.id };
157+
}
158+
138159
// ---------------------------------------------------------------------------
139160
// Dependency contract (concrete types, no generics)
140161
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)