feat(dot): add guided invitations and persistent agent connections (#15581)

Add guided external-agent invitations with live Dot connection checks and ongoing access until revoked. Keep expired credentials invalid and enforce permissions for private avatar uploads. Preserve Runner recovery and remote launch boundaries.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip authored and GitHub committed 2026-10-08 16:26:41 -05:00
1 parent 04de3132c2
commit 2b4a1d7073
61 files changed
+7529 -4422

No files matched your search

@@ -14,6 +14,12 @@ describe("agent appearance", () => {
expect(legacyAgentAppearance("agent-1")).toEqual(legacyAgentAppearance("agent-1"));
expect(agentAvatarUrl(appearance, 24, 2)).toBe("/api/agent-avatars/cap-v1/deep-tide/rest.png?size=24&scale=2");
});
it("uses a private asset URL for custom avatars while retaining the fallback palette", () => {
const appearance = { ...appearanceForPalette("deep-tide"), customAvatarAssetId: "22222222-2222-4222-8222-222222222222" };
expect(resolveAgentAppearance(appearance)).toEqual(appearance);
expect(agentAvatarUrl(appearance, 128, 2)).toBe("/api/assets/22222222-2222-4222-8222-222222222222/content");
expect(agentAppearanceSchema.safeParse({ ...appearance, customAvatarAssetId: "https://example.test/image" }).success).toBe(false);
});
it("renders without a browser and preserves logical-size detail at high density", () => {
const appearance = appearanceForPalette("bubblegum-sky");
// ClipLab v0.2.0 draws an enlarged compact face from 16px; only 12px and
+3
View File
@@ -14,6 +14,8 @@ export const agentAppearanceSchema = z.object({
schemaVersion: z.literal(1),
characterVersion: z.literal("cap-v1"),
paletteId: z.enum(AGENT_PALETTE_IDS),
/** Company-scoped normalized image, set through the avatar upload service. */
customAvatarAssetId: z.uuid().optional(),
}).strict();
export type AgentAppearance = z.infer<typeof agentAppearanceSchema>;
@@ -39,6 +41,7 @@ export function resolveAgentAppearance(appearance: unknown, id = "agent"): Agent
return parsed.success ? parsed.data : legacyAgentAppearance(id);
}
export function agentAvatarUrl(appearance: AgentAppearance, size: AgentAvatarSize = 512, scale: 1 | 2 = 1, pose: CharacterState = "rest", muted = false, background: AgentAvatarBackground = "transparent"): string {
if (appearance.customAvatarAssetId) return `/api/assets/${appearance.customAvatarAssetId}/content`;
return `/api/agent-avatars/${appearance.characterVersion}/${muted ? "muted-dream" : appearance.paletteId}/${pose}.png?size=${size}&scale=${scale}${background === "paperclip-dark" ? "&background=paperclip-dark" : ""}`;
}
export function characterStateForAgent(status: string): CharacterState {
@@ -0,0 +1,10 @@
import { z } from "zod";
export const MAX_AGENT_AVATAR_BYTES = 512 * 1024;
/** Raw PNG/JPEG/WebP bytes, not a URL or a data URL. Null restores the Paperclip character. */
export const setAgentAvatarSchema = z.object({
imageBase64: z.string().min(4).max(4 * Math.ceil(MAX_AGENT_AVATAR_BYTES / 3))
.regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/)
.nullable(),
}).strict();
export type SetAgentAvatarInput = z.infer<typeof setAgentAvatarSchema>;
+22
View File
@@ -0,0 +1,22 @@
/** JSON responses for the operator-owned Dot invitation flow. Pairing capabilities are transient. */
export interface DotBinding {
id: string;
status: string;
connected: boolean;
subscriptionVerified: boolean;
hasPendingChallenge: boolean;
pairingExpiresAt: string | null;
challengeExpiresAt: string | null;
}
export interface DotInvitation {
agent: { id: string; name: string; status: string };
approvalId: string | null;
binding: DotBinding | null;
}
export interface DotConnection {
enabled: boolean;
resourceUrl: string | null;
agentStatus: string;
binding: DotBinding | null;
}
export interface DotPairing { bindingId: string; pairingCode: string; expiresAt: string }
+4
View File
@@ -2854,3 +2854,7 @@ export * from "./connection-instructions.js";
export * from "./customer-success.js";
export * from "./decision-models.js";
export { updatePrimaryAgentSchema, type UpdatePrimaryAgent, type PrimaryAgentPreference } from "./primary-agent.js";
export * from "./agent-avatar-upload.js";
export type { DotBinding, DotInvitation, DotConnection, DotPairing } from "./dot-invitations.js";