@slopus/happy-agent-client 0.0.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.
Files changed (90) hide show
  1. package/README.md +17 -0
  2. package/dist/HappyAgentApiError.d.ts +41 -0
  3. package/dist/HappyAgentApiError.d.ts.map +1 -0
  4. package/dist/HappyAgentApiError.js +57 -0
  5. package/dist/HappyAgentApiError.js.map +1 -0
  6. package/dist/HappyAgentClient.d.ts +256 -0
  7. package/dist/HappyAgentClient.d.ts.map +1 -0
  8. package/dist/HappyAgentClient.js +739 -0
  9. package/dist/HappyAgentClient.js.map +1 -0
  10. package/dist/endpointUrl.d.ts +14 -0
  11. package/dist/endpointUrl.d.ts.map +1 -0
  12. package/dist/endpointUrl.js +27 -0
  13. package/dist/endpointUrl.js.map +1 -0
  14. package/dist/index.d.ts +26 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +22 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/protocol/agents.d.ts +116 -0
  19. package/dist/protocol/agents.d.ts.map +1 -0
  20. package/dist/protocol/agents.js +3 -0
  21. package/dist/protocol/agents.js.map +1 -0
  22. package/dist/protocol/bootstrap.d.ts +28 -0
  23. package/dist/protocol/bootstrap.d.ts.map +1 -0
  24. package/dist/protocol/bootstrap.js +3 -0
  25. package/dist/protocol/bootstrap.js.map +1 -0
  26. package/dist/protocol/common.d.ts +104 -0
  27. package/dist/protocol/common.d.ts.map +1 -0
  28. package/dist/protocol/common.js +92 -0
  29. package/dist/protocol/common.js.map +1 -0
  30. package/dist/protocol/daemon.d.ts +486 -0
  31. package/dist/protocol/daemon.d.ts.map +1 -0
  32. package/dist/protocol/daemon.js +210 -0
  33. package/dist/protocol/daemon.js.map +1 -0
  34. package/dist/protocol/events.d.ts +208 -0
  35. package/dist/protocol/events.d.ts.map +1 -0
  36. package/dist/protocol/events.js +9 -0
  37. package/dist/protocol/events.js.map +1 -0
  38. package/dist/protocol/files.d.ts +74 -0
  39. package/dist/protocol/files.d.ts.map +1 -0
  40. package/dist/protocol/files.js +8 -0
  41. package/dist/protocol/files.js.map +1 -0
  42. package/dist/protocol/git.d.ts +55 -0
  43. package/dist/protocol/git.d.ts.map +1 -0
  44. package/dist/protocol/git.js +3 -0
  45. package/dist/protocol/git.js.map +1 -0
  46. package/dist/protocol/messages.d.ts +210 -0
  47. package/dist/protocol/messages.d.ts.map +1 -0
  48. package/dist/protocol/messages.js +8 -0
  49. package/dist/protocol/messages.js.map +1 -0
  50. package/dist/protocol/processes.d.ts +26 -0
  51. package/dist/protocol/processes.d.ts.map +1 -0
  52. package/dist/protocol/processes.js +3 -0
  53. package/dist/protocol/processes.js.map +1 -0
  54. package/dist/protocol/profile.d.ts +40 -0
  55. package/dist/protocol/profile.d.ts.map +1 -0
  56. package/dist/protocol/profile.js +23 -0
  57. package/dist/protocol/profile.js.map +1 -0
  58. package/dist/protocol/projects.d.ts +377 -0
  59. package/dist/protocol/projects.d.ts.map +1 -0
  60. package/dist/protocol/projects.js +107 -0
  61. package/dist/protocol/projects.js.map +1 -0
  62. package/dist/protocol/questions.d.ts +54 -0
  63. package/dist/protocol/questions.d.ts.map +1 -0
  64. package/dist/protocol/questions.js +3 -0
  65. package/dist/protocol/questions.js.map +1 -0
  66. package/dist/protocol/terminals.d.ts +50 -0
  67. package/dist/protocol/terminals.d.ts.map +1 -0
  68. package/dist/protocol/terminals.js +3 -0
  69. package/dist/protocol/terminals.js.map +1 -0
  70. package/dist/protocol/usage.d.ts +27 -0
  71. package/dist/protocol/usage.d.ts.map +1 -0
  72. package/dist/protocol/usage.js +9 -0
  73. package/dist/protocol/usage.js.map +1 -0
  74. package/dist/protocol/workspaces.d.ts +216 -0
  75. package/dist/protocol/workspaces.d.ts.map +1 -0
  76. package/dist/protocol/workspaces.js +87 -0
  77. package/dist/protocol/workspaces.js.map +1 -0
  78. package/dist/readEventStream.d.ts +19 -0
  79. package/dist/readEventStream.d.ts.map +1 -0
  80. package/dist/readEventStream.js +46 -0
  81. package/dist/readEventStream.js.map +1 -0
  82. package/dist/readSseFrames.d.ts +20 -0
  83. package/dist/readSseFrames.d.ts.map +1 -0
  84. package/dist/readSseFrames.js +77 -0
  85. package/dist/readSseFrames.js.map +1 -0
  86. package/dist/requestOptions.d.ts +44 -0
  87. package/dist/requestOptions.d.ts.map +1 -0
  88. package/dist/requestOptions.js +9 -0
  89. package/dist/requestOptions.js.map +1 -0
  90. package/package.json +42 -0
@@ -0,0 +1,210 @@
1
+ /** The daemon itself: its greeting, health, configuration, and debug surface. */
2
+ import { Type } from "@sinclair/typebox";
3
+ import { effortSchema, Nullable, permissionModeSchema, serviceTierSchema } from "./common.js";
4
+ /**
5
+ * The wire protocol this client was built for.
6
+ *
7
+ * A daemon reports its own number through `GET /v0/health`; a client that reads
8
+ * a different one refuses to talk to that daemon.
9
+ */
10
+ export const HAPPY_AGENT_PROTOCOL_VERSION = 17;
11
+ /** `GET /` — a greeting confirming the caller reached a Happy agent. */
12
+ export const greetingResponseSchema = Type.Object({ text: Type.String() });
13
+ /** What a daemon says about itself. */
14
+ export const daemonVersionSchema = Type.Object({
15
+ /** The product version string, for display and diagnostics. */
16
+ daemon: Type.String(),
17
+ /** The wire protocol number; the client's compatibility check. */
18
+ protocol: Type.Integer(),
19
+ });
20
+ /** `GET /v0/health` */
21
+ export const healthResponseSchema = Type.Object({
22
+ /** Always `true`; a daemon that cannot answer does not answer. */
23
+ healthy: Type.Boolean(),
24
+ /** `false` while the agent system is still loading. */
25
+ ready: Type.Boolean(),
26
+ status: Type.Union([Type.Literal("starting"), Type.Literal("ready")]),
27
+ version: daemonVersionSchema,
28
+ });
29
+ /** What a new agent gets when it names nothing. */
30
+ export const configDefaultsSchema = Type.Object({
31
+ effort: effortSchema,
32
+ modelId: Type.String(),
33
+ permissionMode: permissionModeSchema,
34
+ providerId: Type.String(),
35
+ });
36
+ export const configFeaturesSchema = Type.Object({
37
+ crossWorkspace: Type.Boolean(),
38
+ workflows: Type.Boolean(),
39
+ workspaces: Type.Boolean(),
40
+ });
41
+ /** A configured MCP server, stripped of everything private. */
42
+ export const mcpServerConfigSchema = Type.Object({
43
+ enabled: Type.Boolean(),
44
+ transport: Type.Union([Type.Literal("stdio"), Type.Literal("http")]),
45
+ });
46
+ /** The sandbox network policy. */
47
+ export const networkConfigSchema = Type.Object({
48
+ allowedDomains: Type.Array(Type.String()),
49
+ allowedLoopbackPorts: Type.Array(Type.Integer()),
50
+ allowedPorts: Type.Array(Type.Integer()),
51
+ allowLocalBinding: Type.Boolean(),
52
+ deniedDomains: Type.Array(Type.String()),
53
+ });
54
+ /** Peer-to-peer identity and transports. */
55
+ export const p2pConfigSchema = Type.Object({
56
+ enableDirect: Type.Boolean(),
57
+ enableIroh: Type.Boolean(),
58
+ enableSsh: Type.Boolean(),
59
+ exposeApi: Type.Boolean(),
60
+ name: Type.String(),
61
+ role: Type.String(),
62
+ });
63
+ export const permissionsConfigSchema = Type.Object({
64
+ /** Project-relative paths that mutations must not touch unattended. */
65
+ protectedPaths: Type.Array(Type.String()),
66
+ });
67
+ /** One presence state the person can be in. */
68
+ export const presenceStateSchema = Type.Object({
69
+ /** How long a question waits for an answer; `null` waits indefinitely. */
70
+ answerWaitMs: Nullable(Type.Integer()),
71
+ emoji: Type.String(),
72
+ /** What the model is told about the person's availability. */
73
+ prompt: Type.String(),
74
+ title: Type.String(),
75
+ });
76
+ export const presenceConfigSchema = Type.Object({
77
+ current: Type.String(),
78
+ fallback: Type.String(),
79
+ states: Type.Record(Type.String(), presenceStateSchema),
80
+ });
81
+ /** Everything a client needs to present a model, defined once. */
82
+ export const modelDefinitionSchema = Type.Object({
83
+ defaultEffort: effortSchema,
84
+ efforts: Type.Array(effortSchema),
85
+ name: Type.String(),
86
+ /** Empty when the model has no service tiers. */
87
+ serviceTiers: Type.Array(serviceTierSchema),
88
+ });
89
+ /**
90
+ * A provider's reference to a model in the top-level catalog.
91
+ *
92
+ * A provider serving a model with narrower capabilities than the shared
93
+ * definition overrides just those fields.
94
+ */
95
+ export const providerModelReferenceSchema = Type.Object({
96
+ defaultEffort: Type.Optional(effortSchema),
97
+ efforts: Type.Optional(Type.Array(effortSchema)),
98
+ enabled: Type.Boolean(),
99
+ id: Type.String(),
100
+ name: Type.Optional(Type.String()),
101
+ serviceTiers: Type.Optional(Type.Array(serviceTierSchema)),
102
+ });
103
+ export const providerConfigSchema = Type.Object({
104
+ enabled: Type.Boolean(),
105
+ models: Type.Array(providerModelReferenceSchema),
106
+ /** The canonical provider key: `"claude"`, `"codex"`, `"grok"`, … */
107
+ type: Type.String(),
108
+ });
109
+ /** Daemon behavior toggles and tunables. */
110
+ export const daemonSettingsSchema = Type.Object({
111
+ compactCompletedTurns: Type.Boolean(),
112
+ completionChime: Type.Boolean(),
113
+ inferenceMaxRetries: Type.Integer(),
114
+ showReasoning: Type.Boolean(),
115
+ showUsage: Type.Boolean(),
116
+ toolResultRetentionDays: Type.Integer(),
117
+ });
118
+ /** Terminal color assignments. */
119
+ export const themeConfigSchema = Type.Object({
120
+ accent: Type.String(),
121
+ brand: Type.String(),
122
+ error: Type.String(),
123
+ primary: Type.String(),
124
+ secondary: Type.String(),
125
+ success: Type.String(),
126
+ warning: Type.String(),
127
+ });
128
+ /** Workspace lifecycle configuration. */
129
+ export const workspaceConfigSchema = Type.Object({
130
+ keepCopiesOnArchive: Type.Boolean(),
131
+ keepWorktreesOnArchive: Type.Boolean(),
132
+ protectedSync: Type.Array(Type.String()),
133
+ setupCommands: Type.Array(Type.String()),
134
+ /** Files copied into every new workspace. */
135
+ sync: Type.Array(Type.String()),
136
+ });
137
+ /** The daemon's effective configuration, with every secret removed. */
138
+ export const daemonConfigSchema = Type.Object({
139
+ defaults: configDefaultsSchema,
140
+ features: configFeaturesSchema,
141
+ mcpServers: Type.Record(Type.String(), mcpServerConfigSchema),
142
+ /** Every model the daemon knows, keyed by model ID. */
143
+ models: Type.Record(Type.String(), modelDefinitionSchema),
144
+ network: networkConfigSchema,
145
+ p2p: p2pConfigSchema,
146
+ permissions: permissionsConfigSchema,
147
+ presence: presenceConfigSchema,
148
+ providers: Type.Record(Type.String(), providerConfigSchema),
149
+ settings: daemonSettingsSchema,
150
+ theme: themeConfigSchema,
151
+ workspace: workspaceConfigSchema,
152
+ });
153
+ /** `GET /v0/config` */
154
+ export const configResponseSchema = Type.Object({ config: daemonConfigSchema });
155
+ /**
156
+ * `PATCH /v0/config` — a runtime settings change.
157
+ *
158
+ * The specification validates the body against "the mutable subset" without
159
+ * enumerating it, so the request admits a partial of any group and leaves the
160
+ * daemon to refuse what it will not change at runtime.
161
+ */
162
+ export const configPatchSchema = Type.Partial(Type.Object({
163
+ defaults: Type.Partial(configDefaultsSchema),
164
+ features: Type.Partial(configFeaturesSchema),
165
+ network: Type.Partial(networkConfigSchema),
166
+ p2p: Type.Partial(p2pConfigSchema),
167
+ permissions: Type.Partial(permissionsConfigSchema),
168
+ settings: Type.Partial(daemonSettingsSchema),
169
+ theme: Type.Partial(themeConfigSchema),
170
+ workspace: Type.Partial(workspaceConfigSchema),
171
+ }));
172
+ /** `GET` and `PUT /v0/config/instructions` */
173
+ export const instructionsResponseSchema = Type.Object({ instructions: Type.String() });
174
+ /** `GET` and `PUT /v0/config/security` */
175
+ export const securityPolicyResponseSchema = Type.Object({ policy: Type.String() });
176
+ /** `POST /v0/shutdown` */
177
+ export const shutdownResponseSchema = Type.Object({
178
+ /** The daemon's process ID, so the caller can confirm the process exited. */
179
+ pid: Type.Integer(),
180
+ shuttingDown: Type.Boolean(),
181
+ });
182
+ /** `POST /v0/debug/inspector` */
183
+ export const inspectorStartedResponseSchema = Type.Object({
184
+ /** The devtools websocket URL a debugger attaches to. */
185
+ inspectorUrl: Type.String(),
186
+ });
187
+ /** `DELETE /v0/debug/inspector` */
188
+ export const inspectorStoppedResponseSchema = Type.Object({
189
+ /** `false` when no inspector was running. */
190
+ stopped: Type.Boolean(),
191
+ });
192
+ /** `GET /v0/onboarding` */
193
+ export const onboardingStateSchema = Type.Object({
194
+ /** Set explicitly when the person finished or dismissed onboarding. */
195
+ completed: Type.Boolean(),
196
+ steps: Type.Object({
197
+ /** The profile has a name. */
198
+ profile: Type.Object({ done: Type.Boolean() }),
199
+ /** At least one project exists. */
200
+ project: Type.Object({ done: Type.Boolean() }),
201
+ /** At least one provider has working credentials. */
202
+ providers: Type.Object({
203
+ done: Type.Boolean(),
204
+ signedIn: Type.Array(Type.String()),
205
+ }),
206
+ }),
207
+ });
208
+ /** `POST /v0/onboarding/complete` */
209
+ export const onboardingCompletedResponseSchema = Type.Object({ completed: Type.Boolean() });
210
+ //# sourceMappingURL=daemon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daemon.js","sourceRoot":"","sources":["../../sources/protocol/daemon.ts"],"names":[],"mappings":"AAAA,iFAAiF;AAEjF,OAAO,EAAe,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE9F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAE/C,wEAAwE;AACxE,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAG3E,uCAAuC;AACvC,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3C,+DAA+D;IAC/D,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;IACrB,kEAAkE;IAClE,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE;CAC3B,CAAC,CAAC;AAGH,uBAAuB;AACvB,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC5C,kEAAkE;IAClE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;IACvB,uDAAuD;IACvD,KAAK,EAAE,IAAI,CAAC,O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AG,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC"}
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Events: everything that changes on the daemon, announced on one journal.
3
+ *
4
+ * A client opens with REST snapshots and follows events to stay current. The
5
+ * journal is a bounded window: a cursor that fell out of it cannot be replayed,
6
+ * and the daemon says so rather than silently skipping what was lost.
7
+ */
8
+ import type { Cuid2, EventCursor, ResourceVersion, Timestamp } from "./common.js";
9
+ import type { Agent } from "./agents.js";
10
+ import type { GitState } from "./git.js";
11
+ import type { Message, Run } from "./messages.js";
12
+ import type { BackgroundProcess } from "./processes.js";
13
+ import type { Profile } from "./profile.js";
14
+ import type { Project } from "./projects.js";
15
+ import type { Question } from "./questions.js";
16
+ import type { Terminal } from "./terminals.js";
17
+ import type { Workspace } from "./workspaces.js";
18
+ /**
19
+ * What every `*.updated` payload carries beside the resource's own ID.
20
+ *
21
+ * A client whose cached `version` equals `previousVersion` merges `changes` and
22
+ * adopts the new version; when they differ its copy is dirty and it refetches
23
+ * that one resource.
24
+ */
25
+ export interface ResourceUpdate<TResource> {
26
+ /** The resource's version before this change. */
27
+ previousVersion: ResourceVersion;
28
+ /** Its version after. */
29
+ version: ResourceVersion;
30
+ /** Only the fields that changed; `updatedAt` is always among them. */
31
+ changes: Partial<TResource>;
32
+ /** Echoed when the mutation behind this change supplied one. */
33
+ mutationId?: string;
34
+ }
35
+ /** What every mutation-caused payload may carry. */
36
+ export interface MutationEcho {
37
+ mutationId?: string;
38
+ }
39
+ export type ProjectCreatedPayload = MutationEcho & {
40
+ project: Project;
41
+ };
42
+ export type ProjectUpdatedPayload = ResourceUpdate<Project> & {
43
+ projectId: Cuid2;
44
+ };
45
+ export type WorkspaceCreatedPayload = MutationEcho & {
46
+ workspace: Workspace;
47
+ };
48
+ export type WorkspaceUpdatedPayload = ResourceUpdate<Workspace> & {
49
+ workspaceId: Cuid2;
50
+ };
51
+ export type TerminalCreatedPayload = MutationEcho & {
52
+ terminal: Terminal;
53
+ };
54
+ export type TerminalUpdatedPayload = ResourceUpdate<Terminal> & {
55
+ terminalId: Cuid2;
56
+ };
57
+ /** Git state is computed, so it has no version chain: the payload is the whole snapshot. */
58
+ export interface GitUpdatedPayload {
59
+ workspaceId: Cuid2;
60
+ git: GitState;
61
+ }
62
+ export type AgentCreatedPayload = MutationEcho & {
63
+ agent: Agent;
64
+ };
65
+ export type AgentUpdatedPayload = ResourceUpdate<Agent> & {
66
+ agentId: Cuid2;
67
+ };
68
+ export type ProcessStartedPayload = MutationEcho & {
69
+ process: BackgroundProcess;
70
+ };
71
+ export type ProcessUpdatedPayload = ResourceUpdate<BackgroundProcess> & {
72
+ processId: Cuid2;
73
+ };
74
+ export type QuestionCreatedPayload = MutationEcho & {
75
+ question: Question;
76
+ };
77
+ export type QuestionUpdatedPayload = ResourceUpdate<Question> & {
78
+ questionId: Cuid2;
79
+ };
80
+ /** A run began; the agent left `"idle"`. */
81
+ export interface RunStartedPayload extends MutationEcho {
82
+ agentId: Cuid2;
83
+ run: Run;
84
+ /** Pending user messages accepted into the run, oldest first. */
85
+ acceptedMessageIds: Cuid2[];
86
+ }
87
+ /** User steering atomically closed one run and opened its successor. */
88
+ export interface RunBoundaryPayload extends MutationEcho {
89
+ agentId: Cuid2;
90
+ finishedRun: Run;
91
+ startedRun: Run;
92
+ /** Pending steering messages accepted into the successor, oldest first. */
93
+ acceptedMessageIds: Cuid2[];
94
+ }
95
+ /** A run reached a terminal state; the agent is `"idle"` again. */
96
+ export interface RunFinishedPayload extends MutationEcho {
97
+ agentId: Cuid2;
98
+ run: Run;
99
+ }
100
+ export interface MessageCreatedPayload extends MutationEcho {
101
+ agentId: Cuid2;
102
+ /** `null` for a pending user message, which belongs to no run yet. */
103
+ runId: Cuid2 | null;
104
+ message: Message;
105
+ }
106
+ /** The whole message as of now, not a diff. */
107
+ export interface MessageUpdatedPayload extends MutationEcho {
108
+ agentId: Cuid2;
109
+ runId: Cuid2;
110
+ message: Message;
111
+ }
112
+ /**
113
+ * Streaming text: the one event that is not a full object.
114
+ *
115
+ * A client that misses deltas recovers the full message from the next
116
+ * `message.updated` or from history.
117
+ */
118
+ export interface MessageDeltaPayload {
119
+ agentId: Cuid2;
120
+ runId: Cuid2;
121
+ messageId: Cuid2;
122
+ /** Which content block grows. */
123
+ blockIndex: number;
124
+ /** Text to concatenate onto that block. */
125
+ append: string;
126
+ }
127
+ /**
128
+ * The message is gone from history.
129
+ *
130
+ * Deletion happens only when the daemon resets a block of the transcript to
131
+ * restart inference; the replacements arrive as ordinary `message.created`.
132
+ */
133
+ export interface MessageDeletedPayload {
134
+ agentId: Cuid2;
135
+ runId: Cuid2;
136
+ messageId: Cuid2;
137
+ }
138
+ /** Deliberately empty: a nudge to refetch the config endpoints when convenient. */
139
+ export type ConfigUpdatedPayload = Record<string, never>;
140
+ export interface ProfileUpdatedPayload extends MutationEcho {
141
+ profile: Profile;
142
+ }
143
+ /** One event on the journal. */
144
+ export interface EventEnvelope<TType extends string, TPayload> {
145
+ /** This event's place in the journal; never a resource identity. */
146
+ cursor: EventCursor;
147
+ type: TType;
148
+ occurredAt: Timestamp;
149
+ payload: TPayload;
150
+ }
151
+ /** Every event the specification names today. */
152
+ export type HappyAgentEvent = EventEnvelope<"project.created", ProjectCreatedPayload> | EventEnvelope<"project.updated", ProjectUpdatedPayload> | EventEnvelope<"workspace.created", WorkspaceCreatedPayload> | EventEnvelope<"workspace.updated", WorkspaceUpdatedPayload> | EventEnvelope<"terminal.created", TerminalCreatedPayload> | EventEnvelope<"terminal.updated", TerminalUpdatedPayload> | EventEnvelope<"git.updated", GitUpdatedPayload> | EventEnvelope<"agent.created", AgentCreatedPayload> | EventEnvelope<"agent.updated", AgentUpdatedPayload> | EventEnvelope<"process.started", ProcessStartedPayload> | EventEnvelope<"process.updated", ProcessUpdatedPayload> | EventEnvelope<"process.exited", ProcessUpdatedPayload> | EventEnvelope<"question.created", QuestionCreatedPayload> | EventEnvelope<"question.updated", QuestionUpdatedPayload> | EventEnvelope<"run.started", RunStartedPayload> | EventEnvelope<"run.boundary", RunBoundaryPayload> | EventEnvelope<"run.finished", RunFinishedPayload> | EventEnvelope<"message.created", MessageCreatedPayload> | EventEnvelope<"message.updated", MessageUpdatedPayload> | EventEnvelope<"message.delta", MessageDeltaPayload> | EventEnvelope<"message.deleted", MessageDeletedPayload> | EventEnvelope<"config.updated", ConfigUpdatedPayload> | EventEnvelope<"profile.updated", ProfileUpdatedPayload>;
153
+ /** The name of an event this client build knows. */
154
+ export type HappyAgentEventType = HappyAgentEvent["type"];
155
+ /** `GET /v0/events` query parameters. */
156
+ export interface EventPageQuery {
157
+ /** The cursor to read from, exclusive; omitted, reading starts at the oldest. */
158
+ after?: EventCursor;
159
+ /** An inclusive upper bound, for pulling the changes between two cursors. */
160
+ until?: EventCursor;
161
+ /** Default 100. */
162
+ limit?: number;
163
+ }
164
+ /** `GET /v0/events` */
165
+ export interface EventPageResponse {
166
+ /** Oldest first. */
167
+ events: HappyAgentEvent[];
168
+ /** Where this page ended; pass it as the next `after`. */
169
+ cursor: EventCursor;
170
+ /** The newest event the daemon holds, so a client knows how far behind it is. */
171
+ latestCursor: EventCursor;
172
+ }
173
+ /** The `hello` frame `GET /v0/events/stream` opens with. */
174
+ export interface EventStreamHello {
175
+ /** The position the stream continues from. */
176
+ cursor: EventCursor;
177
+ /**
178
+ * The supplied cursor was lost to the journal window. The stream is live
179
+ * from now, but the client must resync its snapshots.
180
+ */
181
+ gap: boolean;
182
+ /** The supplied cursor was honored; everything since it follows, in order. */
183
+ resumed: boolean;
184
+ connectedAt: Timestamp;
185
+ }
186
+ /** One frame read off `GET /v0/events/stream`. */
187
+ export type EventStreamFrame = {
188
+ kind: "hello";
189
+ hello: EventStreamHello;
190
+ } | {
191
+ kind: "event";
192
+ event: HappyAgentEvent;
193
+ cursor: EventCursor;
194
+ };
195
+ /** `GET /v0/events/stream` options. */
196
+ export interface EventStreamOptions {
197
+ /** The cursor to resume from, sent as the `after` query parameter. */
198
+ after?: EventCursor | undefined;
199
+ /**
200
+ * The cursor to resume from, sent as the standard `Last-Event-ID` header.
201
+ * Equivalent to `after`; both forms exist because SSE reconnects use the
202
+ * header and a first connection usually names the cursor in the query.
203
+ */
204
+ lastEventId?: EventCursor | undefined;
205
+ /** Closes the connection and ends the iteration. */
206
+ signal?: AbortSignal | undefined;
207
+ }
208
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../sources/protocol/events.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,WAAW,cAAc,CAAC,SAAS;IACrC,iDAAiD;IACjD,eAAe,EAAE,eAAe,CAAC;IACjC,yBAAyB;IACzB,OAAO,EAAE,eAAe,CAAC;IACzB,sEAAsE;IACtE,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5B,gEAAgE;IAChE,UAAU,C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CAAA;CAAE,CAAC;AAErE,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IAC/B,sEAAsE;IACtE,KAAK,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAChC;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACtC,oDAAoD;IACpD,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CACpC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Events: everything that changes on the daemon, announced on one journal.
3
+ *
4
+ * A client opens with REST snapshots and follows events to stay current. The
5
+ * journal is a bounded window: a cursor that fell out of it cannot be replayed,
6
+ * and the daemon says so rather than silently skipping what was lost.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../sources/protocol/events.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Files: read-mostly access to a workspace's folder.
3
+ *
4
+ * Every path is relative to the workspace root; absolute paths, `..`, and
5
+ * symlinks escaping the root are rejected by the daemon.
6
+ */
7
+ /** One hit from the filename search. */
8
+ export interface FileMatch {
9
+ path: string;
10
+ fileName: string;
11
+ }
12
+ /** `GET /v0/workspaces/:workspaceId/files` query parameters. */
13
+ export interface FileSearchQuery {
14
+ query: string;
15
+ limit?: number;
16
+ }
17
+ /** `GET /v0/workspaces/:workspaceId/files` */
18
+ export interface FileSearchResponse {
19
+ files: FileMatch[];
20
+ }
21
+ /** One entry of a directory listing. */
22
+ export interface FileTreeEntry {
23
+ name: string;
24
+ path: string;
25
+ type: "file" | "directory" | "symlink" | "other";
26
+ size: number;
27
+ modified: number;
28
+ }
29
+ /** `GET /v0/workspaces/:workspaceId/file-tree` query parameters. */
30
+ export interface FileTreeQuery {
31
+ /** Defaults to the workspace root. */
32
+ path?: string;
33
+ cursor?: string;
34
+ limit?: number;
35
+ }
36
+ /** `GET /v0/workspaces/:workspaceId/file-tree` */
37
+ export interface FileTreeResponse {
38
+ entries: FileTreeEntry[];
39
+ nextCursor: string | null;
40
+ }
41
+ /** `GET /v0/workspaces/:workspaceId/file` */
42
+ export interface FileContentResponse {
43
+ /** Base64, because files are bytes and not necessarily text. */
44
+ content: string;
45
+ /** The sha256 hex digest, which is the write guard. */
46
+ hash: string;
47
+ }
48
+ /** `PUT /v0/workspaces/:workspaceId/file` */
49
+ export interface WriteFileRequest {
50
+ path: string;
51
+ /** Base64 file content. */
52
+ content: string;
53
+ /**
54
+ * The compare-and-swap: the sha256 the client read, or `null` to require
55
+ * that the file not exist yet.
56
+ */
57
+ expectedHash: string | null;
58
+ }
59
+ /** `PUT /v0/workspaces/:workspaceId/file` */
60
+ export interface WriteFileResponse {
61
+ hash: string;
62
+ }
63
+ /** `GET /v0/workspaces/:workspaceId/file-revision` query parameters. */
64
+ export interface FileRevisionQuery {
65
+ path: string;
66
+ /** A commit-ish. */
67
+ revision: string;
68
+ }
69
+ /** `GET /v0/workspaces/:workspaceId/file-revision` */
70
+ export interface FileRevisionResponse {
71
+ /** Base64 file content as of the revision. */
72
+ content: string;
73
+ }
74
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../sources/protocol/files.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wCAAwC;AACxC,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,gEAAgE;AAChE,MAAM,WAAW,eAAe;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,8CAA8C;AAC9C,MAAM,WAAW,kBAAkB;IAC/B,KAAK,EAAE,SAAS,EAAE,CAAC;CACtB;AAED,wCAAwC;AACxC,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,oEAAoE;AACpE,MAAM,WAAW,aAAa;IAC1B,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,kDAAkD;AAClD,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,6CAA6C;AAC7C,MAAM,WAAW,mBAAmB;IAChC,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,6CAA6C;AAC7C,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,wEAAwE;AACxE,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,sDAAsD;AACtD,MAAM,WAAW,oBAAoB;IACjC,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Files: read-mostly access to a workspace's folder.
3
+ *
4
+ * Every path is relative to the workspace root; absolute paths, `..`, and
5
+ * symlinks escaping the root are rejected by the daemon.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../sources/protocol/files.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,55 @@
1
+ /** Git state: branch and sync facts plus the working tree's changes. */
2
+ import type { Cuid2, GitSummary, Timestamp } from "./common.js";
3
+ /** What happened to a single changed file. */
4
+ export type GitFileStatus = "added" | "modified" | "deleted" | "renamed" | "copied" | "untracked" | "conflicted" | "type_changed" | "submodule";
5
+ export interface GitFileChange {
6
+ path: string;
7
+ status: GitFileStatus;
8
+ staged: boolean;
9
+ unstaged: boolean;
10
+ binary: boolean;
11
+ insertions: number;
12
+ deletions: number;
13
+ }
14
+ /**
15
+ * The git state object.
16
+ *
17
+ * Git state is computed rather than mutated, so it carries no version chain:
18
+ * the newest snapshot simply replaces what a client held.
19
+ */
20
+ export interface GitState {
21
+ facts: GitSummary;
22
+ /** `"unavailable"` when no sensible base exists yet; then only `facts` mean anything. */
23
+ comparison: "ready" | "unavailable";
24
+ /** What the changes are measured against. */
25
+ base: string | null;
26
+ changedFiles: number;
27
+ insertions: number;
28
+ deletions: number;
29
+ /** `false` when a large tree made the daemon estimate. */
30
+ countsExact: boolean;
31
+ conflicted: boolean;
32
+ files: GitFileChange[];
33
+ /** `true` when the file list was capped. */
34
+ filesTruncated: boolean;
35
+ scannedAt: Timestamp;
36
+ }
37
+ /** `GET /v0/workspaces/:workspaceId/git` */
38
+ export interface GitStateResponse {
39
+ git: GitState;
40
+ }
41
+ /** `POST /v0/git/watch` */
42
+ export interface WatchGitRequest {
43
+ workspaceIds: Cuid2[];
44
+ }
45
+ /**
46
+ * `POST /v0/git/watch`
47
+ *
48
+ * Whatever the watcher already knows for the requested workspaces. A repository
49
+ * it has not scanned yet is simply absent, and its first `git.updated` event
50
+ * follows shortly.
51
+ */
52
+ export interface WatchGitResponse {
53
+ snapshots: Record<string, GitState>;
54
+ }
55
+ //# sourceMappingURL=git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git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,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CACvC"}
@@ -0,0 +1,3 @@
1
+ /** Git state: branch and sync facts plus the working tree's changes. */
2
+ export {};
3
+ //# sourceMappingURL=git.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["../../sources/protocol/git.ts"],"names":[],"mappings":"AAAA,wEAAwE"}