feat: add fly-sprites-workers Paseo plugin
This commit is contained in:
commit
0c4027ebe5
15 files changed
+7446
No files matched your search
@@ -0,0 +1,238 @@
|
||||
import { defineRpc, defineSubscription } from "@getpaseo/plugin";
|
||||
import { z } from "zod";
|
||||
|
||||
export const SpriteSummarySchema = z.object({
|
||||
name: z.string(),
|
||||
id: z.string().optional(),
|
||||
status: z.string(),
|
||||
organization: z.string().optional(),
|
||||
primaryRegion: z.string().optional(),
|
||||
url: z.string().optional(),
|
||||
createdAt: z.string().optional(),
|
||||
updatedAt: z.string().optional(),
|
||||
});
|
||||
|
||||
export type SpriteSummary = z.output<typeof SpriteSummarySchema>;
|
||||
|
||||
export const WorkerStatusSchema = z.enum(["starting", "running", "completed", "failed", "stopped"]);
|
||||
|
||||
export const WorkerSummarySchema = z.object({
|
||||
workerId: z.string(),
|
||||
spriteName: z.string(),
|
||||
command: z.string(),
|
||||
cwd: z.string(),
|
||||
status: WorkerStatusSchema,
|
||||
exitCode: z.number().nullable(),
|
||||
error: z.string().nullable(),
|
||||
startedAt: z.string(),
|
||||
endedAt: z.string().nullable(),
|
||||
outputTail: z.string(),
|
||||
outputBytes: z.number(),
|
||||
});
|
||||
|
||||
export type WorkerSummary = z.output<typeof WorkerSummarySchema>;
|
||||
|
||||
export const CheckpointSummarySchema = z.object({
|
||||
id: z.string(),
|
||||
comment: z.string().optional(),
|
||||
createdAt: z.string(),
|
||||
isAuto: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export type CheckpointSummary = z.output<typeof CheckpointSummarySchema>;
|
||||
|
||||
export const testConnectionRpc = defineRpc({
|
||||
name: "sprites.test",
|
||||
input: z.object({}),
|
||||
output: z.discriminatedUnion("ok", [
|
||||
z.object({
|
||||
ok: z.literal(true),
|
||||
spriteCount: z.number(),
|
||||
source: z.enum(["settings", "env"]),
|
||||
}),
|
||||
z.object({
|
||||
ok: z.literal(false),
|
||||
error: z.string(),
|
||||
}),
|
||||
]),
|
||||
});
|
||||
|
||||
export const statusRpc = defineRpc({
|
||||
name: "sprites.status",
|
||||
input: z.object({
|
||||
includeRemote: z.boolean().optional(),
|
||||
}),
|
||||
output: z.object({
|
||||
configured: z.boolean(),
|
||||
tokenSource: z.enum(["settings", "env", "none"]),
|
||||
remoteError: z.string().nullable(),
|
||||
sprites: z.array(SpriteSummarySchema),
|
||||
workers: z.array(WorkerSummarySchema),
|
||||
}),
|
||||
});
|
||||
|
||||
export const createSpriteRpc = defineRpc({
|
||||
name: "sprites.create",
|
||||
input: z.object({
|
||||
name: z.string().optional(),
|
||||
region: z.string().optional(),
|
||||
ramMB: z.number().int().positive().optional(),
|
||||
cpus: z.number().int().positive().optional(),
|
||||
syncLocalPath: z.string().optional(),
|
||||
remoteDir: z.string().optional(),
|
||||
}),
|
||||
output: z.discriminatedUnion("ok", [
|
||||
z.object({
|
||||
ok: z.literal(true),
|
||||
sprite: SpriteSummarySchema,
|
||||
syncedFiles: z.number().optional(),
|
||||
}),
|
||||
z.object({
|
||||
ok: z.literal(false),
|
||||
error: z.string(),
|
||||
}),
|
||||
]),
|
||||
});
|
||||
|
||||
export const syncWorkspaceRpc = defineRpc({
|
||||
name: "sprites.sync",
|
||||
input: z.object({
|
||||
spriteName: z.string(),
|
||||
localPath: z.string(),
|
||||
remoteDir: z.string().optional(),
|
||||
}),
|
||||
output: z.discriminatedUnion("ok", [
|
||||
z.object({
|
||||
ok: z.literal(true),
|
||||
fileCount: z.number(),
|
||||
bytes: z.number(),
|
||||
remoteDir: z.string(),
|
||||
}),
|
||||
z.object({
|
||||
ok: z.literal(false),
|
||||
error: z.string(),
|
||||
}),
|
||||
]),
|
||||
});
|
||||
|
||||
export const spawnWorkerRpc = defineRpc({
|
||||
name: "sprites.worker.spawn",
|
||||
input: z.object({
|
||||
spriteName: z.string().optional(),
|
||||
command: z.string(),
|
||||
cwd: z.string().optional(),
|
||||
syncLocalPath: z.string().optional(),
|
||||
maxRunAfterDisconnect: z.string().optional(),
|
||||
}),
|
||||
output: z.discriminatedUnion("ok", [
|
||||
z.object({
|
||||
ok: z.literal(true),
|
||||
worker: WorkerSummarySchema,
|
||||
}),
|
||||
z.object({
|
||||
ok: z.literal(false),
|
||||
error: z.string(),
|
||||
}),
|
||||
]),
|
||||
});
|
||||
|
||||
export const stopWorkerRpc = defineRpc({
|
||||
name: "sprites.worker.stop",
|
||||
input: z.object({
|
||||
workerId: z.string(),
|
||||
}),
|
||||
output: z.object({
|
||||
ok: z.boolean(),
|
||||
error: z.string().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
export const workerLogsRpc = defineRpc({
|
||||
name: "sprites.worker.logs",
|
||||
input: z.object({
|
||||
workerId: z.string(),
|
||||
}),
|
||||
output: z.discriminatedUnion("ok", [
|
||||
z.object({
|
||||
ok: z.literal(true),
|
||||
worker: WorkerSummarySchema,
|
||||
output: z.string(),
|
||||
}),
|
||||
z.object({
|
||||
ok: z.literal(false),
|
||||
error: z.string(),
|
||||
}),
|
||||
]),
|
||||
});
|
||||
|
||||
export const destroySpriteRpc = defineRpc({
|
||||
name: "sprites.destroy",
|
||||
input: z.object({
|
||||
spriteName: z.string(),
|
||||
}),
|
||||
output: z.object({
|
||||
ok: z.boolean(),
|
||||
error: z.string().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
export const listCheckpointsRpc = defineRpc({
|
||||
name: "sprites.checkpoint.list",
|
||||
input: z.object({
|
||||
spriteName: z.string(),
|
||||
}),
|
||||
output: z.discriminatedUnion("ok", [
|
||||
z.object({
|
||||
ok: z.literal(true),
|
||||
checkpoints: z.array(CheckpointSummarySchema),
|
||||
}),
|
||||
z.object({
|
||||
ok: z.literal(false),
|
||||
error: z.string(),
|
||||
}),
|
||||
]),
|
||||
});
|
||||
|
||||
export const createCheckpointRpc = defineRpc({
|
||||
name: "sprites.checkpoint.create",
|
||||
input: z.object({
|
||||
spriteName: z.string(),
|
||||
comment: z.string().optional(),
|
||||
}),
|
||||
output: z.discriminatedUnion("ok", [
|
||||
z.object({
|
||||
ok: z.literal(true),
|
||||
messages: z.array(z.string()),
|
||||
}),
|
||||
z.object({
|
||||
ok: z.literal(false),
|
||||
error: z.string(),
|
||||
}),
|
||||
]),
|
||||
});
|
||||
|
||||
export const restoreCheckpointRpc = defineRpc({
|
||||
name: "sprites.checkpoint.restore",
|
||||
input: z.object({
|
||||
spriteName: z.string(),
|
||||
checkpointId: z.string(),
|
||||
}),
|
||||
output: z.discriminatedUnion("ok", [
|
||||
z.object({
|
||||
ok: z.literal(true),
|
||||
messages: z.array(z.string()),
|
||||
}),
|
||||
z.object({
|
||||
ok: z.literal(false),
|
||||
error: z.string(),
|
||||
}),
|
||||
]),
|
||||
});
|
||||
|
||||
export const watchWorkersSub = defineSubscription({
|
||||
name: "sprites.watch",
|
||||
input: z.object({}),
|
||||
event: z.object({
|
||||
workers: z.array(WorkerSummarySchema),
|
||||
}),
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
import { defineSettings } from "@getpaseo/plugin";
|
||||
import { z } from "zod";
|
||||
|
||||
export const flySpritesSettingsSchema = z.object({
|
||||
token: z.string().default(""),
|
||||
baseUrl: z.string().default("https://api.sprites.dev"),
|
||||
spritePrefix: z.string().default("paseo-worker-"),
|
||||
defaultRegion: z.string().default(""),
|
||||
defaultRamMB: z.number().int().nonnegative().default(0),
|
||||
defaultCpus: z.number().int().nonnegative().default(0),
|
||||
defaultRemoteCwd: z.string().default("/workspace"),
|
||||
defaultProviderMode: z.enum(["shell", "acp"]).default("shell"),
|
||||
acpCommand: z.string().default("claude-code-acp"),
|
||||
syncWorkspaceOnCreate: z.boolean().default(true),
|
||||
injectAgentTools: z.boolean().default(true),
|
||||
autoCleanupOnArchive: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export type FlySpritesSettings = z.output<typeof flySpritesSettingsSchema>;
|
||||
|
||||
export const flySpritesSettings = defineSettings({
|
||||
id: "fly-sprites",
|
||||
scope: "host",
|
||||
version: 1,
|
||||
schema: flySpritesSettingsSchema,
|
||||
});
|
||||
|
||||
export const defaultFlySpritesSettings: FlySpritesSettings = {
|
||||
token: "",
|
||||
baseUrl: "https://api.sprites.dev",
|
||||
spritePrefix: "paseo-worker-",
|
||||
defaultRegion: "",
|
||||
defaultRamMB: 0,
|
||||
defaultCpus: 0,
|
||||
defaultRemoteCwd: "/workspace",
|
||||
defaultProviderMode: "shell",
|
||||
acpCommand: "claude-code-acp",
|
||||
syncWorkspaceOnCreate: true,
|
||||
injectAgentTools: true,
|
||||
autoCleanupOnArchive: false,
|
||||
};
|
||||
Reference in new issue
Block a user