feat: publish standalone Pi connect extension
This commit is contained in:
37
src/localAgentProtocol.ts
Normal file
37
src/localAgentProtocol.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const DEFAULT_HEARTBEAT_INTERVAL_MS = 15_000;
|
||||
|
||||
const pairOkServerMessageSchema = z.object({
|
||||
type: z.literal('pair.ok'),
|
||||
projectName: z.string().min(1),
|
||||
reconnectCredential: z.string().min(1),
|
||||
connectionEpoch: z.number().int().positive(),
|
||||
});
|
||||
|
||||
const reconnectOkServerMessageSchema = z.object({
|
||||
type: z.literal('reconnect.ok'),
|
||||
projectName: z.string().min(1),
|
||||
connectionEpoch: z.number().int().positive(),
|
||||
});
|
||||
|
||||
const taskDispatchServerMessageSchema = z.object({
|
||||
type: z.literal('task.dispatch'),
|
||||
taskId: z.string().min(1),
|
||||
prompt: z.string().min(1),
|
||||
});
|
||||
|
||||
const errorServerMessageSchema = z.object({
|
||||
type: z.literal('error'),
|
||||
code: z.string().min(1),
|
||||
message: z.string().min(1),
|
||||
});
|
||||
|
||||
export const localAgentServerMessageSchema = z.discriminatedUnion('type', [
|
||||
pairOkServerMessageSchema,
|
||||
reconnectOkServerMessageSchema,
|
||||
taskDispatchServerMessageSchema,
|
||||
errorServerMessageSchema,
|
||||
]);
|
||||
|
||||
export type LocalAgentServerMessage = z.infer<typeof localAgentServerMessageSchema>;
|
||||
Reference in New Issue
Block a user