mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-06 08:24:46 +00:00
refactor(creation): name receipt inputs and tag compatibility gate
This commit is contained in:
@@ -4338,7 +4338,7 @@ export class DaemonClient {
|
||||
},
|
||||
requestId?: string,
|
||||
): Promise<WorkspaceCreatePayload> {
|
||||
// COMPAT(workspaceRequestReceipts): added in v0.7.3; remove gate after 2027-03-07.
|
||||
// COMPAT(workspaceRequestReceipts): added in v0.8.0; remove gate after 2027-03-07.
|
||||
if (
|
||||
input.idempotencyKey !== undefined &&
|
||||
!this.lastServerInfoMessage?.features?.workspaceRequestReceipts
|
||||
|
||||
@@ -3481,6 +3481,7 @@ export const ServerInfoStatusPayloadSchema = z
|
||||
.object({
|
||||
// COMPAT(agentRequestReceipts): added in v0.8.0; remove gate after 2027-03-05.
|
||||
agentRequestReceipts: z.boolean().optional(),
|
||||
// COMPAT(workspaceRequestReceipts): added in v0.8.0; remove gate after 2027-03-07.
|
||||
workspaceRequestReceipts: z.boolean().optional(),
|
||||
// COMPAT(hubAgentRpc): added in v0.8.0; remove gate after 2027-03-05.
|
||||
hubAgentRpc: z.boolean().optional(),
|
||||
|
||||
@@ -17,18 +17,36 @@ type Receipt = z.infer<typeof ReceiptStateSchema> & {
|
||||
resource: { kind: "agent" | "workspace"; id: string };
|
||||
};
|
||||
|
||||
interface CreateAgentInput {
|
||||
key: string;
|
||||
request: unknown;
|
||||
findAgent: (agentId: string) => Promise<boolean>;
|
||||
create: (agentId: string) => Promise<void>;
|
||||
}
|
||||
|
||||
interface CreateWorkspaceInput {
|
||||
key: string;
|
||||
request: unknown;
|
||||
workspaceId: string;
|
||||
findWorkspace: (workspaceId: string) => Promise<boolean>;
|
||||
create: (workspaceId: string) => Promise<void>;
|
||||
}
|
||||
|
||||
interface SendMessageInput {
|
||||
agentId: string;
|
||||
messageId: string;
|
||||
request: unknown;
|
||||
send: () => Promise<void>;
|
||||
prepare?: () => Promise<void>;
|
||||
}
|
||||
|
||||
/** One daemon-owned request journal, shared by all of its socket sessions. */
|
||||
export class RequestReceipts {
|
||||
private readonly pending = new Map<string, Promise<string>>();
|
||||
|
||||
constructor(private readonly directory: string) {}
|
||||
|
||||
createAgent(input: {
|
||||
key: string;
|
||||
request: unknown;
|
||||
findAgent: (agentId: string) => Promise<boolean>;
|
||||
create: (agentId: string) => Promise<void>;
|
||||
}): Promise<string> {
|
||||
createAgent(input: CreateAgentInput): Promise<string> {
|
||||
return this.execute(["create", input.key], input.request, {
|
||||
resource: { kind: "agent", id: randomUUID() },
|
||||
recover: input.findAgent,
|
||||
@@ -37,13 +55,7 @@ export class RequestReceipts {
|
||||
});
|
||||
}
|
||||
|
||||
createWorkspace(input: {
|
||||
key: string;
|
||||
request: unknown;
|
||||
workspaceId: string;
|
||||
findWorkspace: (workspaceId: string) => Promise<boolean>;
|
||||
create: (workspaceId: string) => Promise<void>;
|
||||
}): Promise<string> {
|
||||
createWorkspace(input: CreateWorkspaceInput): Promise<string> {
|
||||
return this.execute(["create-workspace", input.key], input.request, {
|
||||
resource: { kind: "workspace", id: input.workspaceId },
|
||||
// A registry entry can survive failed provisioning and checkout rollback.
|
||||
@@ -54,13 +66,7 @@ export class RequestReceipts {
|
||||
});
|
||||
}
|
||||
|
||||
async sendMessage(input: {
|
||||
agentId: string;
|
||||
messageId: string;
|
||||
request: unknown;
|
||||
send: () => Promise<void>;
|
||||
prepare?: () => Promise<void>;
|
||||
}): Promise<void> {
|
||||
async sendMessage(input: SendMessageInput): Promise<void> {
|
||||
await this.execute(["send", input.agentId, input.messageId], input.request, {
|
||||
resource: { kind: "agent", id: input.agentId },
|
||||
// A provider call can take effect before the daemon records its outcome.
|
||||
|
||||
Reference in New Issue
Block a user