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:
Mohamed Boudra
2026-05-28 01:58:18 +08:00
committed by GitHub
parent 0ea41378a4
commit 53c14d9855
403 changed files with 3193 additions and 1417 deletions
@@ -0,0 +1,198 @@
import { describe, expect, it } from "vitest";
import { AgentTimelineItemPayloadSchema } from "./messages.js";
function canonicalBase() {
return {
type: "tool_call" as const,
callId: "call_123",
name: "shell",
detail: {
type: "shell" as const,
command: "pwd",
},
};
}
describe("shared messages tool_call schema", () => {
it("parses each status-discriminated tool_call variant at runtime", () => {
const running = AgentTimelineItemPayloadSchema.parse({
...canonicalBase(),
status: "running",
error: null,
});
const completed = AgentTimelineItemPayloadSchema.parse({
...canonicalBase(),
status: "completed",
error: null,
});
const failed = AgentTimelineItemPayloadSchema.parse({
...canonicalBase(),
status: "failed",
error: { message: "command failed" },
});
const canceled = AgentTimelineItemPayloadSchema.parse({
...canonicalBase(),
status: "canceled",
error: null,
});
expect(running.type).toBe("tool_call");
expect(completed.type).toBe("tool_call");
expect(failed.type).toBe("tool_call");
expect(canceled.type).toBe("tool_call");
});
it("rejects non-recoverable invalid tool_call payloads", () => {
const missingCallId = AgentTimelineItemPayloadSchema.safeParse({
type: "tool_call",
name: "shell",
status: "running",
detail: {
type: "shell",
command: "pwd",
},
error: null,
});
const unknownStatus = AgentTimelineItemPayloadSchema.safeParse({
...canonicalBase(),
status: "mystery_status",
error: null,
});
const withTopLevelInputOutput = AgentTimelineItemPayloadSchema.safeParse({
...canonicalBase(),
status: "running",
error: null,
input: { command: "pwd" },
output: { exitCode: 0 },
});
expect(missingCallId.success).toBe(false);
expect(unknownStatus.success).toBe(false);
expect(withTopLevelInputOutput.success).toBe(false);
});
it("rejects legacy status/error combinations without normalization", () => {
const completedWithError = AgentTimelineItemPayloadSchema.safeParse({
...canonicalBase(),
status: "completed",
error: { message: "unexpected" },
});
const failedWithoutError = AgentTimelineItemPayloadSchema.safeParse({
...canonicalBase(),
status: "failed",
error: null,
});
const missingDetail = AgentTimelineItemPayloadSchema.safeParse({
type: "tool_call",
callId: "call_missing_detail",
name: "shell",
status: "running",
error: null,
});
const legacyStatus = AgentTimelineItemPayloadSchema.safeParse({
...canonicalBase(),
status: "inProgress",
error: null,
});
expect(completedWithError.success).toBe(false);
expect(failedWithoutError.success).toBe(false);
expect(missingDetail.success).toBe(false);
expect(legacyStatus.success).toBe(false);
});
it("parses canonical sub_agent detail payload", () => {
const parsed = AgentTimelineItemPayloadSchema.parse({
type: "tool_call",
callId: "call_sub_agent_1",
name: "Task",
status: "running",
error: null,
detail: {
type: "sub_agent",
subAgentType: "Explore",
description: "Inspect repository structure",
log: "[Read] README.md\n[Bash] ls",
},
});
expect(parsed.type).toBe("tool_call");
if (parsed.type === "tool_call") {
expect(parsed.detail.type).toBe("sub_agent");
if (parsed.detail.type === "sub_agent") {
expect(parsed.detail.subAgentType).toBe("Explore");
}
}
});
it("parses sub_agent detail without structured actions", () => {
const parsed = AgentTimelineItemPayloadSchema.parse({
type: "tool_call",
callId: "call_sub_agent_legacy",
name: "Task",
status: "running",
error: null,
detail: {
type: "sub_agent",
subAgentType: "Explore",
description: "Inspect repository structure",
log: "[Read] README.md",
},
});
expect(parsed.type).toBe("tool_call");
if (parsed.type === "tool_call") {
expect(parsed.detail.type).toBe("sub_agent");
if (parsed.detail.type === "sub_agent") {
expect(parsed.detail.log).toBe("[Read] README.md");
}
}
});
it("parses plain_text detail with icon and rejects unknown icon names", () => {
const parsed = AgentTimelineItemPayloadSchema.parse({
type: "tool_call",
callId: "call_plain_text_1",
name: "task_notification",
status: "completed",
error: null,
detail: {
type: "plain_text",
label: "Background task completed",
icon: "wrench",
},
});
expect(parsed.type).toBe("tool_call");
if (parsed.type === "tool_call") {
expect(parsed.detail.type).toBe("plain_text");
if (parsed.detail.type === "plain_text") {
expect(parsed.detail.icon).toBe("wrench");
}
}
const invalid = AgentTimelineItemPayloadSchema.safeParse({
type: "tool_call",
callId: "call_plain_text_invalid",
name: "task_notification",
status: "completed",
error: null,
detail: {
type: "plain_text",
label: "Background task completed",
icon: "laser",
},
});
expect(invalid.success).toBe(false);
});
});