Extract client SDK package (#1052)
* Extract client SDK package * Polish SDK client identity defaults * Build client before dependent CI jobs * Restore daemon client server export * Extract protocol and client SDK packages * Fix provider override schema validation * Fix app test daemon client imports * Simplify workspace build targets * Fix CLI test server build bootstrap * Run SDK package tests in CI * Fix rebase package split drift * Restore lockfile registry metadata * Update SDK config test for prompt default * Move terminal stream router test to client package * Fix rebase drift for protocol imports * Fix SDK agent capability fixture * Restore legacy server client exports * Fix server export compatibility test * Advertise custom mode icon client capability * Remove server daemon-client exports * Format rebased mode control import * Fix rebase drift for protocol imports Files added by upstream PRs (#893, #1147, #1154) referenced the pre-split shared/ paths that this branch moves into @getpaseo/protocol. Redirect those imports to the protocol package so typecheck stays green after the rebase.
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildAgentAttentionNotificationPayload,
|
||||
findLatestAssistantMessageFromTimeline,
|
||||
findLatestPermissionRequest,
|
||||
} from "./agent-attention-notification.js";
|
||||
|
||||
describe("buildAgentAttentionNotificationPayload", () => {
|
||||
it("builds finished notifications from markdown assistant text", () => {
|
||||
const payload = buildAgentAttentionNotificationPayload({
|
||||
reason: "finished",
|
||||
serverId: "srv-1",
|
||||
agentId: "agent-1",
|
||||
assistantMessage: "**Done**. Updated `README.md` and [link](https://example.com).",
|
||||
});
|
||||
|
||||
expect(payload).toEqual({
|
||||
title: "Agent finished",
|
||||
body: "Done. Updated README.md and link.",
|
||||
data: {
|
||||
serverId: "srv-1",
|
||||
agentId: "agent-1",
|
||||
reason: "finished",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("builds permission notifications from request details", () => {
|
||||
const payload = buildAgentAttentionNotificationPayload({
|
||||
reason: "permission",
|
||||
serverId: "srv-2",
|
||||
agentId: "agent-2",
|
||||
permissionRequest: {
|
||||
id: "perm-1",
|
||||
provider: "claude",
|
||||
name: "exec",
|
||||
kind: "tool",
|
||||
title: "**Approve command**",
|
||||
description: "Run `git push`",
|
||||
},
|
||||
});
|
||||
|
||||
expect(payload).toEqual({
|
||||
title: "Agent needs permission",
|
||||
body: "Approve command - Run git push",
|
||||
data: {
|
||||
serverId: "srv-2",
|
||||
agentId: "agent-2",
|
||||
reason: "permission",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("uses error-specific defaults when reason is error", () => {
|
||||
const payload = buildAgentAttentionNotificationPayload({
|
||||
reason: "error",
|
||||
serverId: "srv-3",
|
||||
agentId: "agent-3",
|
||||
});
|
||||
|
||||
expect(payload).toEqual({
|
||||
title: "Agent needs attention",
|
||||
body: "Encountered an error.",
|
||||
data: {
|
||||
serverId: "srv-3",
|
||||
agentId: "agent-3",
|
||||
reason: "error",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("findLatestAssistantMessageFromTimeline", () => {
|
||||
it("joins the latest contiguous assistant chunks", () => {
|
||||
expect(
|
||||
findLatestAssistantMessageFromTimeline([
|
||||
{ type: "user_message", text: "start" },
|
||||
{ type: "assistant_message", text: "Part " },
|
||||
{ type: "assistant_message", text: "one" },
|
||||
{ type: "reasoning", text: "thinking..." },
|
||||
{ type: "assistant_message", text: "Done " },
|
||||
{ type: "assistant_message", text: "now" },
|
||||
]),
|
||||
).toBe("Done now");
|
||||
});
|
||||
});
|
||||
|
||||
describe("findLatestPermissionRequest", () => {
|
||||
it("returns the most recently inserted request", () => {
|
||||
const pending = new Map([
|
||||
["first", { id: "first", provider: "claude", name: "a", kind: "tool" } as const],
|
||||
["second", { id: "second", provider: "claude", name: "b", kind: "tool" } as const],
|
||||
]);
|
||||
|
||||
expect(findLatestPermissionRequest(pending)?.id).toBe("second");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user