@vibest/schema 0.0.0-stage → 0.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 iamdin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,29 @@
1
1
  {
2
2
  "name": "@vibest/schema",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.1-beta.0",
4
+ "description": "The schemas of vibest's facts and wire types, shared by vibestd and the plugin API.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/vibest-dev/vibest.git",
9
+ "directory": "packages/schema"
10
+ },
11
+ "files": [
12
+ "src",
13
+ "LICENSE"
14
+ ],
15
+ "type": "module",
16
+ "exports": {
17
+ "./*": "./src/*.ts"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "dependencies": {
23
+ "effect": "4.0.2"
24
+ },
25
+ "scripts": {
26
+ "typecheck": "tsrs --noEmit --fast",
27
+ "test": "cd ../.. && bun ./node_modules/vitest/vitest.mjs run packages/schema"
28
+ }
6
29
  }
package/src/event.ts ADDED
@@ -0,0 +1,243 @@
1
+ import { Effect, Schema } from "effect"
2
+
3
+ import { Routing } from "./plugin.ts"
4
+
5
+ export type Envelope = "project" | "session" | "none"
6
+
7
+ export interface Definition<T extends string = string, S extends Schema.Top = Schema.Top> {
8
+ readonly type: T
9
+ readonly envelope: Envelope
10
+ readonly data: S
11
+ }
12
+
13
+ export const fact = <const T extends string, const F extends Schema.Struct.Fields>(
14
+ type: T,
15
+ envelope: Envelope,
16
+ fields: F,
17
+ ): Definition<T, Schema.Struct<F>> => ({ type, envelope, data: Schema.Struct(fields) })
18
+
19
+ const Text = Schema.NonEmptyString
20
+ const optional = <S extends Schema.Top>(schema: S) => Schema.optionalKey(schema)
21
+ const Seq = Schema.Int.check(Schema.isGreaterThan(0))
22
+ const Pid = Schema.Int.check(Schema.isGreaterThan(0))
23
+
24
+ const Repository = Schema.Struct({ path: Text, remote: optional(Text) })
25
+ const Repositories = Schema.Array(Repository)
26
+
27
+ export const ProjectCreated = fact("project.created", "project", {
28
+ directory: optional(Text),
29
+ repositories: Repositories,
30
+ })
31
+ export const ProjectMoved = fact("project.moved", "project", { from: Text, to: Text, repositories: Repositories })
32
+ export const ProjectRepositoriesChanged = fact("project.repositories_changed", "project", {
33
+ repositories: Repositories,
34
+ })
35
+ export const ProjectEntryChanged = fact("project.entry_changed", "project", { session: optional(Text) })
36
+
37
+ export const SessionCreated = fact("session.created", "session", {
38
+ role: Text,
39
+ name: Text,
40
+ directory: Schema.String,
41
+ parent: optional(Text),
42
+ reportTo: optional(Text),
43
+ archiveOnCompletion: Schema.Boolean,
44
+ origin: optional(Schema.Struct({ peer: Text, project: Text, parent: optional(Text), reportTo: optional(Text) })),
45
+ })
46
+ export const SessionRenamed = fact("session.renamed", "session", { name: Text })
47
+ export const SessionDirectoryChanged = fact("session.directory_changed", "session", { directory: Text })
48
+ export const SessionEnded = fact("session.ended", "session", { reason: Schema.Literals(["archived", "replaced"]) })
49
+
50
+ export const ProcessStarted = fact("process.started", "session", {
51
+ harness: Text,
52
+ provider: optional(Text),
53
+ model: optional(Text),
54
+ routing: optional(Routing),
55
+ resume: optional(Text),
56
+ runtime: Text,
57
+ terminal: optional(Text),
58
+ pid: optional(Pid),
59
+ })
60
+ export const ProcessPlaced = fact("process.placed", "session", { process: Seq, terminal: Text, pid: optional(Pid) })
61
+ export const ProcessReady = fact("process.ready", "session", {
62
+ process: Seq,
63
+ pid: optional(Pid),
64
+ integration: optional(Schema.Struct({ version: Text, protocol: Schema.Int })),
65
+ })
66
+ export const ProcessPid = fact("process.pid", "session", { process: Seq, pid: Pid })
67
+ export const ProcessConversation = fact("process.conversation", "session", { process: Seq, conversation: Text })
68
+ export const ProcessEndReason = Schema.Literals([
69
+ "exited",
70
+ "limited",
71
+ "restart",
72
+ "move",
73
+ "archived",
74
+ "launch_failed",
75
+ "superseded",
76
+ ])
77
+ export type ProcessEndReason = typeof ProcessEndReason.Type
78
+ export const ProcessEnded = fact("process.ended", "session", { process: Seq, reason: ProcessEndReason })
79
+
80
+ export const TurnStarted = fact("turn.started", "session", { process: optional(Seq), typed: optional(Text) })
81
+ export const TurnReported = fact("turn.reported", "session", {
82
+ process: optional(Seq),
83
+ harness: Text,
84
+ text: Schema.String,
85
+ error: optional(Text),
86
+ conversation: optional(Text),
87
+ interrupted: optional(Schema.Literal(true)),
88
+ })
89
+ export const TurnStatus = Schema.Literals(["completed", "failed", "interrupted", "lost", "not_started"])
90
+ export const TurnEnded = fact("turn.ended", "session", {
91
+ turn: Seq,
92
+ status: TurnStatus,
93
+ report: optional(Seq),
94
+ failure: optional(Schema.Struct({ message: Text })),
95
+ conversation: optional(Text),
96
+ reply: optional(Schema.String),
97
+ })
98
+
99
+ export const InboxKind = Schema.Literals(["task", "send", "report", "result", "notice"])
100
+ export type InboxKind = typeof InboxKind.Type
101
+ export const InboxQueued = fact("inbox.queued", "session", {
102
+ kind: InboxKind,
103
+ recipient: optional(Text),
104
+ sender: optional(Text),
105
+ content: Schema.String,
106
+ status: Schema.Literals(["pending", "delivered", "dropped"]),
107
+ turn: optional(Seq),
108
+ request: optional(Text),
109
+ peerItem: optional(Text),
110
+ })
111
+ export const InboxMoved = fact("inbox.moved", "session", {
112
+ inbox: Seq,
113
+ to: Schema.Literals(["pending", "delivering", "delivered", "failed", "dropped"]),
114
+ turn: optional(Seq),
115
+ })
116
+
117
+ export const MachineAdded = fact("machine.added", "none", { name: Text, target: Text, vibestd: Text })
118
+ export const MachineConnected = fact("machine.connected", "none", { name: Text })
119
+ export const MachineRemoved = fact("machine.removed", "none", { name: Text })
120
+
121
+ export const PeerSeen = fact("peer.seen", "none", { id: Text, name: Text, callsMe: Text })
122
+
123
+ export const OutboxQueued = fact("outbox.queued", "session", {
124
+ id: Text,
125
+ peer: Text,
126
+ kind: Schema.Literals(["result", "notice"]),
127
+ content: Schema.String,
128
+ })
129
+ export const OutboxAcked = fact("outbox.acked", "none", { peer: Text, ids: Schema.NonEmptyArray(Text) })
130
+
131
+ const definitions = [
132
+ ProjectCreated,
133
+ ProjectMoved,
134
+ ProjectRepositoriesChanged,
135
+ ProjectEntryChanged,
136
+ SessionCreated,
137
+ SessionRenamed,
138
+ SessionDirectoryChanged,
139
+ SessionEnded,
140
+ ProcessStarted,
141
+ ProcessPlaced,
142
+ ProcessReady,
143
+ ProcessPid,
144
+ ProcessConversation,
145
+ ProcessEnded,
146
+ TurnStarted,
147
+ TurnReported,
148
+ TurnEnded,
149
+ InboxQueued,
150
+ InboxMoved,
151
+ MachineAdded,
152
+ MachineConnected,
153
+ MachineRemoved,
154
+ PeerSeen,
155
+ OutboxQueued,
156
+ OutboxAcked,
157
+ ] as const
158
+
159
+ type Defined = (typeof definitions)[number]
160
+
161
+ export type FactType = Defined["type"]
162
+
163
+ export const Catalog = Object.fromEntries(definitions.map((d) => [d.type, d])) as {
164
+ readonly [D in Defined as D["type"]]: D
165
+ }
166
+
167
+ export const CATALOG_VERSION = 1
168
+
169
+ export type Fact = {
170
+ readonly [D in Defined as D["type"]]: {
171
+ readonly seq: number
172
+ readonly at: number
173
+ readonly type: D["type"]
174
+ readonly projectId?: string
175
+ readonly sessionId?: string
176
+ readonly data: D["data"]["Type"]
177
+ }
178
+ }[FactType]
179
+
180
+ export type FactOf<T extends FactType> = Extract<Fact, { readonly type: T }>
181
+
182
+ export interface Row {
183
+ readonly seq: number
184
+ readonly at: number
185
+ readonly type: string
186
+ readonly project_id: string | null
187
+ readonly session_id: string | null
188
+ readonly data: string
189
+ }
190
+
191
+ export class UnknownFact extends Schema.TaggedError<UnknownFact>()("UnknownFact", {
192
+ seq: Schema.Number,
193
+ type: Schema.String,
194
+ message: Schema.String,
195
+ }) {}
196
+
197
+ const strict = { onExcessProperty: "error" } as const
198
+
199
+ const envelopeFits = (envelope: Envelope, row: Pick<Row, "project_id" | "session_id">) =>
200
+ envelope === "none"
201
+ ? row.project_id === null && row.session_id === null
202
+ : envelope === "project"
203
+ ? row.project_id !== null && row.session_id === null
204
+ : row.project_id !== null && row.session_id !== null
205
+
206
+ export const encodeData = <D extends Defined>(
207
+ definition: D,
208
+ data: D["data"]["Type"],
209
+ ): Effect.Effect<string, Schema.SchemaError> =>
210
+ Schema.encodeUnknownEffect(definition.data)(data, strict).pipe(
211
+ Effect.map((encoded) => JSON.stringify(encoded)),
212
+ Effect.tap((json) => Schema.decodeUnknownEffect(definition.data)(JSON.parse(json), strict)),
213
+ )
214
+
215
+ export const decodeRow = (row: Row): Effect.Effect<Fact, UnknownFact> => {
216
+ const refuse = (message: string) => new UnknownFact({ seq: row.seq, type: row.type, message })
217
+ if (!Object.hasOwn(Catalog, row.type))
218
+ return Effect.fail(refuse(`event ${row.seq}: ${row.type} is not in the event catalog`))
219
+ const definition: Defined = Catalog[row.type as FactType]
220
+ if (!envelopeFits(definition.envelope, row))
221
+ return Effect.fail(refuse(`event ${row.seq}: ${row.type} needs a ${definition.envelope} envelope`))
222
+ return Effect.try({
223
+ try: () => JSON.parse(row.data) as unknown,
224
+ catch: (cause) => refuse(`event ${row.seq}: ${row.type} data is not JSON: ${String(cause)}`),
225
+ }).pipe(
226
+ Effect.flatMap((json) =>
227
+ Schema.decodeUnknownEffect(definition.data)(json, strict).pipe(
228
+ Effect.mapError((cause) => refuse(`event ${row.seq}: ${row.type} does not decode: ${cause.message}`)),
229
+ ),
230
+ ),
231
+ Effect.map(
232
+ (data) =>
233
+ ({
234
+ seq: row.seq,
235
+ at: row.at,
236
+ type: definition.type,
237
+ ...(row.project_id === null ? {} : { projectId: row.project_id }),
238
+ ...(row.session_id === null ? {} : { sessionId: row.session_id }),
239
+ data,
240
+ }) as Fact,
241
+ ),
242
+ )
243
+ }
package/src/id.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { Effect } from "effect"
2
+
3
+ export const ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/
4
+
5
+ export const shortId = (id: string) => id.slice(0, 8)
6
+
7
+ export const randomId = (): string =>
8
+ (globalThis as unknown as { readonly crypto: { readonly randomUUID: () => string } }).crypto.randomUUID()
9
+
10
+ export const newId = <E = never, R = never>(
11
+ taken: (short: string) => Effect.Effect<boolean, E, R> = () => Effect.succeed(false),
12
+ ) =>
13
+ Effect.sync(randomId).pipe(
14
+ Effect.flatMap((id) => taken(shortId(id)).pipe(Effect.map((used) => (used ? undefined : id)))),
15
+ Effect.repeat({ until: (id): id is string => id !== undefined }),
16
+ Effect.map((id) => id!),
17
+ )
package/src/layout.ts ADDED
@@ -0,0 +1,57 @@
1
+ import { Config, Context, Effect, Layer, Path } from "effect"
2
+
3
+ export class Layout extends Context.Service<
4
+ Layout,
5
+ {
6
+ readonly home: string
7
+ readonly database: string
8
+ readonly socket: string
9
+ readonly httpSocket: string
10
+ readonly daemonInfo: string
11
+ readonly identity: string
12
+ readonly worktrees: string
13
+ readonly projects: string
14
+ readonly config: string
15
+ readonly plugins: string
16
+ readonly allocationWorktree: (repository: string, name: string) => string
17
+ readonly project: (projectId: string) => string
18
+ readonly artifacts: (projectId: string) => string
19
+ }
20
+ >()("vibest/Layout") {
21
+ static readonly make = (home: string) =>
22
+ Effect.gen(function* () {
23
+ const path = yield* Path.Path
24
+ return Layout.of({
25
+ home,
26
+ database: path.join(home, "vibest.db"),
27
+ socket: path.join(home, "vibest.sock"),
28
+ httpSocket: path.join(home, "vibest-http.sock"),
29
+ daemonInfo: path.join(home, "vibestd.pid"),
30
+ identity: path.join(home, "identity.json"),
31
+ worktrees: path.join(home, "worktrees"),
32
+ projects: path.join(home, "projects"),
33
+ config: path.join(home, "vibest.json"),
34
+ plugins: path.join(home, "plugins"),
35
+ allocationWorktree: (repository, name) => path.join(home, "worktrees", repository, name),
36
+ project: (projectId) => path.join(home, "projects", projectId),
37
+ artifacts: (projectId) => path.join(home, "projects", projectId, "artifacts"),
38
+ })
39
+ })
40
+
41
+ static readonly layer = Layer.effect(
42
+ Layout,
43
+ Effect.gen(function* () {
44
+ const path = yield* Path.Path
45
+ const home = yield* Config.String("VIBEST_HOME").pipe(
46
+ Config.orElse(() => Config.String("HOME").pipe(Config.map((h) => path.join(h, ".vibest")))),
47
+ )
48
+ return yield* Layout.make(home)
49
+ }),
50
+ )
51
+ }
52
+
53
+ export const VibestCommand = Context.Reference<ReadonlyArray<string>>("vibest/VibestCommand", {
54
+ defaultValue: () => ["vibest"],
55
+ })
56
+
57
+ export const shellQuote = (s: string) => (/^[\w@%+=:,./-]+$/.test(s) ? s : `'${s.replace(/'/g, `'\\''`)}'`)
package/src/machine.ts ADDED
@@ -0,0 +1,106 @@
1
+ import { Schema, Struct } from "effect"
2
+
3
+ export class MachineFailed extends Schema.TaggedError<MachineFailed>()("MachineFailed", { message: Schema.String }) {}
4
+
5
+ export class UnknownMachine extends Schema.TaggedError<UnknownMachine>()("UnknownMachine", {
6
+ machine: Schema.String,
7
+ machines: Schema.Array(Schema.String),
8
+ }) {
9
+ override get message() {
10
+ const known =
11
+ this.machines.length === 0 ? "none is added (vibest machine add)" : `machines: ${this.machines.join(", ")}`
12
+ return `unknown machine ${JSON.stringify(this.machine)}; ${known}`
13
+ }
14
+ }
15
+
16
+ export class MachineUnavailable extends Schema.TaggedError<MachineUnavailable>()("MachineUnavailable", {
17
+ machine: Schema.String,
18
+ message: Schema.String,
19
+ }) {}
20
+
21
+ export class MachineIncompatible extends Schema.TaggedError<MachineIncompatible>()("MachineIncompatible", {
22
+ machine: Schema.String,
23
+ message: Schema.String,
24
+ }) {}
25
+
26
+ export class AlreadyAdded extends Schema.TaggedError<AlreadyAdded>()("AlreadyAdded", {
27
+ machine: Schema.String,
28
+ id: Schema.String,
29
+ }) {
30
+ override get message() {
31
+ return `this is the vibestd already added as ${this.machine} (${this.id.slice(0, 8)}); use that name`
32
+ }
33
+ }
34
+
35
+ export const MachineState = Schema.Literals(["connecting", "connected", "unreachable", "different"])
36
+ export type MachineState = typeof MachineState.Type
37
+
38
+ export const MachineNote = Schema.Struct({
39
+ plugin: Schema.optional(Schema.String),
40
+ message: Schema.String,
41
+ fix: Schema.optional(Schema.String),
42
+ })
43
+ export type MachineNote = typeof MachineNote.Type
44
+
45
+ export const RuntimeThere = Schema.Struct({
46
+ kind: Schema.String,
47
+ status: Schema.Literals(["online", "offline", "blocked"]),
48
+ reason: Schema.optional(Schema.String),
49
+ link: Schema.optional(Schema.Record(Schema.String, Schema.String)),
50
+ })
51
+ export type RuntimeThere = typeof RuntimeThere.Type
52
+
53
+ export const RuntimeView = Schema.Struct({
54
+ kind: Schema.String,
55
+ status: RuntimeThere.fields.status,
56
+ reason: Schema.optional(Schema.String),
57
+ here: Schema.Struct({
58
+ visible: Schema.Boolean,
59
+ as: Schema.optional(Schema.String),
60
+ note: Schema.optional(Schema.String),
61
+ }),
62
+ })
63
+ export type RuntimeView = typeof RuntimeView.Type
64
+
65
+ export const MachineInfo = Schema.Struct({
66
+ name: Schema.String,
67
+ target: Schema.String,
68
+ id: Schema.String,
69
+ state: MachineState,
70
+ since: Schema.Number,
71
+ reason: Schema.optional(Schema.String),
72
+ connectedAt: Schema.Number,
73
+ vibestd: Schema.optional(Schema.String),
74
+ version: Schema.optional(Schema.String),
75
+ runtimes: Schema.optional(Schema.Array(RuntimeView)),
76
+ runtimesAt: Schema.optional(Schema.Number),
77
+ notes: Schema.optional(Schema.Array(Schema.Struct({ ...MachineNote.fields, at: Schema.Number }))),
78
+ })
79
+ export type MachineInfo = typeof MachineInfo.Type
80
+
81
+ export const ListedMachine = MachineInfo.mapFields(Struct.pick(["name", "state", "since", "reason"]))
82
+ export type ListedMachine = typeof ListedMachine.Type
83
+
84
+ export class NoProject extends Schema.TaggedError<NoProject>()("NoProject", { message: Schema.String }) {}
85
+
86
+ export class NoCommit extends Schema.TaggedError<NoCommit>()("NoCommit", { message: Schema.String }) {}
87
+
88
+ export const OUTBOX_ITEM_MAX = 1024 * 1024
89
+
90
+ export const PROMPT_MAX = 1024 * 1024
91
+
92
+ export class PromptTooLarge extends Schema.TaggedError<PromptTooLarge>()("PromptTooLarge", { bytes: Schema.Number }) {
93
+ override get message() {
94
+ return `the prompt is ${this.bytes} bytes; another machine takes at most ${PROMPT_MAX} bytes (1 MiB)`
95
+ }
96
+ }
97
+
98
+ export const OutboxItem = Schema.Struct({
99
+ id: Schema.String,
100
+ session: Schema.String,
101
+ recipient: Schema.String,
102
+ kind: Schema.Literals(["result", "notice"]),
103
+ content: Schema.String,
104
+ cut: Schema.optional(Schema.Boolean),
105
+ })
106
+ export type OutboxItem = typeof OutboxItem.Type
package/src/model.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { Schema } from "effect"
2
+
3
+ export const MessageStatus = Schema.Literals(["working", "completed", "failed", "interrupted", "lost", "not_started"])
4
+ export type MessageStatus = typeof MessageStatus.Type
package/src/plugin.ts ADDED
@@ -0,0 +1,52 @@
1
+ import { Schema } from "effect"
2
+
3
+ export class AgentRefused extends Schema.TaggedError<AgentRefused>()("AgentRefused", {
4
+ plugin: Schema.String,
5
+ reason: Schema.String,
6
+ }) {
7
+ override get message() {
8
+ return `refused by ${this.plugin}: ${this.reason}`
9
+ }
10
+ }
11
+
12
+ export class HookFailed extends Schema.TaggedError<HookFailed>()("HookFailed", { message: Schema.String }) {}
13
+
14
+ export const Change = Schema.Struct({
15
+ field: Schema.String,
16
+ from: Schema.optional(Schema.Unknown),
17
+ to: Schema.optional(Schema.Unknown),
18
+ overwrote: Schema.optional(Schema.String),
19
+ })
20
+
21
+ export const TraceEntry = Schema.Struct({
22
+ plugin: Schema.String,
23
+ hook: Schema.String,
24
+ outcome: Schema.Literals(["ok", "refused", "crashed", "timeout"]),
25
+ ms: Schema.Number,
26
+ changes: Schema.Array(Change),
27
+ reason: Schema.optional(Schema.String),
28
+ error: Schema.optional(Schema.String),
29
+ })
30
+ export type TraceEntry = typeof TraceEntry.Type
31
+
32
+ export const Routing = Schema.Struct({
33
+ decidedBy: Schema.Record(Schema.String, Schema.String),
34
+ trace: Schema.Array(TraceEntry),
35
+ })
36
+ export type Routing = typeof Routing.Type
37
+
38
+ export const PluginInfo = Schema.Struct({
39
+ id: Schema.String,
40
+ source: Schema.String,
41
+ revision: Schema.String,
42
+ loadedAt: Schema.Number,
43
+ status: Schema.Literals(["active", "failed"]),
44
+ error: Schema.optional(Schema.String),
45
+ calls: Schema.Number,
46
+ changed: Schema.Number,
47
+ crashed: Schema.Number,
48
+ timedOut: Schema.Number,
49
+ refused: Schema.Number,
50
+ lastError: Schema.optional(Schema.String),
51
+ })
52
+ export type PluginInfo = typeof PluginInfo.Type
package/src/project.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { Schema } from "effect"
2
+
3
+ export const ProjectKind = Schema.Literals(["docs", "memories", "artifacts"])
4
+ export type ProjectKind = typeof ProjectKind.Type
5
+
6
+ export const ProjectInfoResult = Schema.Struct({
7
+ directory: Schema.String,
8
+ preferences: Schema.String,
9
+ docs: Schema.String,
10
+ memories: Schema.String,
11
+ artifacts: Schema.String,
12
+ })
13
+ export const ProjectSearchInput = Schema.Struct({ query: Schema.String, kind: Schema.optional(ProjectKind) })
package/src/remove.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { Schema } from "effect"
2
+
3
+ export const RemoveOutcome = Schema.Struct({
4
+ id: Schema.String,
5
+ processes: Schema.Literals(["exited", "alive", "unknown"]),
6
+ pane: Schema.Literals(["closed", "kept", "none"]),
7
+ workspace: Schema.Literals(["closed", "kept", "none"]),
8
+ worktree: Schema.Literals(["removed", "kept", "gone"]),
9
+ path: Schema.String,
10
+ branch: Schema.NullOr(Schema.String),
11
+ reasons: Schema.Array(Schema.String),
12
+ })
13
+ export type RemoveOutcome = typeof RemoveOutcome.Type
package/src/session.ts ADDED
@@ -0,0 +1,111 @@
1
+ import { Schema } from "effect"
2
+
3
+ import { InboxKind } from "./event.ts"
4
+
5
+ export const AgentStatus = Schema.Literals(["idle", "working", "blocked", "done", "unknown"])
6
+ export type AgentStatus = typeof AgentStatus.Type
7
+ export const TurnState = Schema.Literals(["none", "open", "completed", "failed", "interrupted", "lost", "not_started"])
8
+ export type TurnState = typeof TurnState.Type
9
+ export const InboxStatus = Schema.Literals(["pending", "sending", "delivered", "failed", "dropped"])
10
+ export type InboxStatus = typeof InboxStatus.Type
11
+
12
+ export const RuntimeAddress = Schema.Struct({
13
+ machine: Schema.String,
14
+ id: Schema.String,
15
+ })
16
+ export type RuntimeAddress = typeof RuntimeAddress.Type
17
+
18
+ export const RuntimeLocation = Schema.Union([
19
+ Schema.Struct({ socketPath: Schema.String }),
20
+ Schema.Struct({ session: Schema.String }),
21
+ ])
22
+ export type RuntimeLocation = typeof RuntimeLocation.Type
23
+
24
+ export const RuntimeMachine = Schema.Struct({
25
+ id: Schema.String,
26
+ target: Schema.optional(Schema.String),
27
+ })
28
+ export type RuntimeMachine = typeof RuntimeMachine.Type
29
+
30
+ export const InboxRow = Schema.Struct({
31
+ id: Schema.Number,
32
+ sender: Schema.NullOr(Schema.String),
33
+ recipient: Schema.NullOr(Schema.String),
34
+ kind: InboxKind,
35
+ message: Schema.String,
36
+ status: InboxStatus,
37
+ })
38
+ export type InboxRow = typeof InboxRow.Type
39
+
40
+ export type HarnessId = string
41
+
42
+ export class HarnessUnavailable extends Schema.TaggedError<HarnessUnavailable>()("HarnessUnavailable", {
43
+ harness: Schema.String,
44
+ message: Schema.String,
45
+ }) {}
46
+
47
+ export class RuntimeUnreachable extends Schema.TaggedError<RuntimeUnreachable>()("RuntimeUnreachable", {
48
+ session: Schema.String,
49
+ message: Schema.String,
50
+ }) {}
51
+
52
+ export class NoRuntime extends Schema.TaggedError<NoRuntime>()("NoRuntime", { message: Schema.String }) {}
53
+
54
+ export class RuntimeIncompatible extends Schema.TaggedError<RuntimeIncompatible>()("RuntimeIncompatible", {
55
+ session: Schema.String,
56
+ message: Schema.String,
57
+ }) {}
58
+
59
+ export class NoSuchSession extends Schema.TaggedError<NoSuchSession>()("NoSuchSession", {
60
+ id: Schema.String,
61
+ message: Schema.String,
62
+ }) {}
63
+ export class AmbiguousSession extends Schema.TaggedError<AmbiguousSession>()("AmbiguousSession", {
64
+ prefix: Schema.String,
65
+ matches: Schema.Array(Schema.String),
66
+ }) {
67
+ override get message() {
68
+ return `${this.prefix} matches ${this.matches.join(", ")}; give more characters of the session id`
69
+ }
70
+ }
71
+ export class ProjectMoved extends Schema.TaggedError<ProjectMoved>()("ProjectMoved", {
72
+ projectId: Schema.String,
73
+ from: Schema.String,
74
+ to: Schema.String,
75
+ }) {
76
+ override get message() {
77
+ return `the project moved from ${this.from} to ${this.to}; run vibest here to move it`
78
+ }
79
+ }
80
+ export class AllocationFailed extends Schema.TaggedError<AllocationFailed>()("AllocationFailed", {
81
+ message: Schema.String,
82
+ }) {}
83
+
84
+ export class SessionBusy extends Schema.TaggedError<SessionBusy>()("SessionBusy", {
85
+ id: Schema.String,
86
+ message: Schema.String,
87
+ }) {}
88
+ export class LimitReached extends Schema.TaggedError<LimitReached>()("LimitReached", { limit: Schema.Number }) {
89
+ override get message() {
90
+ return `VIBEST_MAX_SESSIONS=${this.limit} sessions are already open (working or kept); vibest archive one first`
91
+ }
92
+ }
93
+ export class NotReady extends Schema.TaggedError<NotReady>()("NotReady", {
94
+ id: Schema.String,
95
+ message: Schema.String,
96
+ }) {}
97
+ export class NoHarnessChosen extends Schema.TaggedError<NoHarnessChosen>()("NoHarnessChosen", {}) {
98
+ override get message() {
99
+ return "no harness to inherit: name one, for example `vibest run claude -- <prompt>`"
100
+ }
101
+ }
102
+
103
+ export class LaunchFailed extends Schema.TaggedError<LaunchFailed>()("LaunchFailed", {
104
+ message: Schema.String,
105
+ }) {}
106
+
107
+ export class NotInRepository extends Schema.TaggedError<NotInRepository>()("NotInRepository", { path: Schema.String }) {
108
+ override get message() {
109
+ return `${this.path} is not inside a git repository`
110
+ }
111
+ }
@@ -0,0 +1,27 @@
1
+ import { Schema } from "effect"
2
+
3
+ export const SubscriptionAccount = Schema.Struct({
4
+ kind: Schema.Literals(["subscription", "api-key", "none"]),
5
+ plan: Schema.optional(Schema.String),
6
+ provider: Schema.optional(Schema.String),
7
+ })
8
+ export type SubscriptionAccount = typeof SubscriptionAccount.Type
9
+
10
+ export const SubscriptionLimit = Schema.Struct({
11
+ window: Schema.String,
12
+ percent: Schema.Number,
13
+ status: Schema.Literals(["available", "limited"]),
14
+ resetTime: Schema.NullOr(Schema.Number),
15
+ })
16
+ export type SubscriptionLimit = typeof SubscriptionLimit.Type
17
+
18
+ export const Subscription = Schema.Struct({
19
+ harness: Schema.String,
20
+ provider: Schema.String,
21
+ machine: Schema.Literal("local"),
22
+ account: SubscriptionAccount,
23
+ limits: Schema.Array(SubscriptionLimit),
24
+ updatedAt: Schema.Number,
25
+ error: Schema.optional(Schema.String),
26
+ })
27
+ export type Subscription = typeof Subscription.Type
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.