diff --git a/apps/contract/src/contract.ts b/apps/contract/src/contract.ts index 3e81fa0e..1adf9c42 100644 --- a/apps/contract/src/contract.ts +++ b/apps/contract/src/contract.ts @@ -88,6 +88,34 @@ export const ProjectSpace = Schema.Struct({ }); export type ProjectSpace = typeof ProjectSpace.Type; +/** One skill as a space's sessions see it: its frontmatter `name` and `description`. */ +export const SpaceSkill = Schema.Struct({ + name: Schema.String, + description: Schema.String, + /** Its frontmatter keeps it out of the prompt. */ + hidden: Schema.Boolean, +}); +export type SpaceSkill = typeof SpaceSkill.Type; + +/** + * A space's skills. A host space is read each time; a sandbox only while it runs, else its last read + * is kept. `skills` is null when it was never read; `syncedAt` is when it was, in epoch milliseconds. + */ +export const SpaceSkills = Schema.Struct({ + space: ProjectSpace, + /** The sandbox it is in, as last observed; null for the host. */ + sandbox: Schema.NullOr( + Schema.Struct({ + driver: Schema.String, + providerResourceId: Schema.NullOr(Schema.String), + status: Schema.String, + }), + ), + skills: Schema.NullOr(Schema.Array(SpaceSkill)), + syncedAt: Schema.NullOr(Schema.Finite), +}); +export type SpaceSkills = typeof SpaceSkills.Type; + /** A host folder operation that failed: unreadable, not a directory, taken, or git/gh refused. */ export class HostError extends Schema.TaggedError()("Server.HostError", { message: Schema.String, @@ -139,6 +167,12 @@ export const SettingsFile = Schema.Struct({ retry: Schema.Struct({ maxRetries: Schema.Int, baseDelayMs: Schema.Int, maxDelayMs: Schema.Int }), }), ), + /** For `mcp.json`: the servers as sessions use them, user and project merged. */ + servers: Schema.optionalKey( + Schema.Array( + Schema.Struct({ name: Schema.String, from: Schema.Literals(["user", "project"]), enabled: Schema.Boolean }), + ), + ), }); export type SettingsFile = typeof SettingsFile.Type; @@ -498,6 +532,11 @@ export const Api = RpcGroup.make( payload: { machineId: Schema.String, projectId: Schema.String }, success: Schema.Array(ProjectSpace), }), + /** Each active space's skills, its main checkout first. Never wakes a sandbox. */ + Rpc.make("projects.skills", { + payload: { machineId: Schema.String, projectId: Schema.String }, + success: Schema.Array(SpaceSkills), + }), Rpc.make("sidebar.list", { payload: { organizationId: Schema.String, machines: Schema.Literals(["default", "all"]) }, success: Schema.Array(SidebarProject), diff --git a/apps/server/src/db.ts b/apps/server/src/db.ts index 3d8d4a37..474708d3 100644 --- a/apps/server/src/db.ts +++ b/apps/server/src/db.ts @@ -6,7 +6,7 @@ import { Migrator, SqlClient } from "effect/sql"; // "YYYYMMDD_