@chipschat/conformance 0.0.0-stage → 1.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.
- package/LICENSE +201 -0
- package/README.md +34 -2
- package/dist/checks.d.ts +29 -0
- package/dist/checks.d.ts.map +1 -0
- package/dist/checks.js +133 -0
- package/dist/checks.js.map +1 -0
- package/dist/exchange.d.ts +30 -0
- package/dist/exchange.d.ts.map +1 -0
- package/dist/exchange.js +102 -0
- package/dist/exchange.js.map +1 -0
- package/dist/fake-chips.d.ts +130 -0
- package/dist/fake-chips.d.ts.map +1 -0
- package/dist/fake-chips.js +1642 -0
- package/dist/fake-chips.js.map +1 -0
- package/dist/fake-join.d.ts +56 -0
- package/dist/fake-join.d.ts.map +1 -0
- package/dist/fake-join.js +181 -0
- package/dist/fake-join.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/project.d.ts +39 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +254 -0
- package/dist/project.js.map +1 -0
- package/dist/report.d.ts +65 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +142 -0
- package/dist/report.js.map +1 -0
- package/dist/room-files.d.ts +54 -0
- package/dist/room-files.d.ts.map +1 -0
- package/dist/room-files.js +144 -0
- package/dist/room-files.js.map +1 -0
- package/dist/scenario.d.ts +41 -0
- package/dist/scenario.d.ts.map +1 -0
- package/dist/scenario.js +414 -0
- package/dist/scenario.js.map +1 -0
- package/dist/settings.d.ts +60 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +142 -0
- package/dist/settings.js.map +1 -0
- package/dist/spend.d.ts +20 -0
- package/dist/spend.d.ts.map +1 -0
- package/dist/spend.js +50 -0
- package/dist/spend.js.map +1 -0
- package/dist/subject.d.ts +55 -0
- package/dist/subject.d.ts.map +1 -0
- package/dist/subject.js +22 -0
- package/dist/subject.js.map +1 -0
- package/dist/waiting.d.ts +12 -0
- package/dist/waiting.d.ts.map +1 -0
- package/dist/waiting.js +30 -0
- package/dist/waiting.js.map +1 -0
- package/dist/workspace.d.ts +893 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +3160 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +38 -3
|
@@ -0,0 +1,893 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace behind the fake: an event log with the door rules the real server applies, and
|
|
3
|
+
* the projections the scenario reads. Nothing here listens on a port — `fake-chips.ts` is the
|
|
4
|
+
* door — so every rule can be driven by a plain call.
|
|
5
|
+
*
|
|
6
|
+
* What is mirrored, and what is not. Mirrored: the envelope Chips fills in (the clock, the
|
|
7
|
+
* actor, who decided), the schema check with the protocol's own `parseEvent`, the direction an
|
|
8
|
+
* event travels, the idempotency key and what a repeat of one means, a run's life, membership,
|
|
9
|
+
* first answer wins, and — since Phase 5 — who may change a space or who is in it, that an added
|
|
10
|
+
* participant exists, and that a decision comes from who the ask named (rules 7 to 9, the Phase
|
|
11
|
+
* 3 review's finding 11); and a room a person asks the harness for, which only a harness that
|
|
12
|
+
* declares `new_spaces` may be asked (rule 15), and which it claims under a key of its own
|
|
13
|
+
* (`space.claimed`, the new-space plan's Phase 2); and agents (ADR 0087): the harness's agents, which
|
|
14
|
+
* rooms hold in its place, the actor rule that reads the harness as its one agent in a room, and
|
|
15
|
+
* which of them a message is for. Not mirrored, on purpose: the policy engine — nothing here decides an
|
|
16
|
+
* approval on the spot, every card waits for the person the scenario plays, which is what "ask
|
|
17
|
+
* first" means and what the handshake reports — and pricing, so a `usage` sent without a cost
|
|
18
|
+
* is delivered without one. An adapter that passes here has spoken the protocol; what the real
|
|
19
|
+
* server's dial would have allowed unasked is that server's business.
|
|
20
|
+
*/
|
|
21
|
+
import { type IdGenerator, type JobSpend, type NoteMember, type ReplyingTo, type RoomContext, type RoomFile, type SpaceIcon, type Viewer } from "@chipschat/protocol";
|
|
22
|
+
import { type FakeExchange } from "./exchange.js";
|
|
23
|
+
export interface Principal {
|
|
24
|
+
readonly kind: "person" | "harness";
|
|
25
|
+
readonly participantId: string;
|
|
26
|
+
readonly workspaceId: string;
|
|
27
|
+
readonly displayName: string;
|
|
28
|
+
}
|
|
29
|
+
/** An event as the log holds it: the envelope's fields lifted out, and the whole event as sent. */
|
|
30
|
+
export interface StoredEvent {
|
|
31
|
+
readonly seq: number;
|
|
32
|
+
readonly id: string;
|
|
33
|
+
readonly type: string;
|
|
34
|
+
readonly ts: string;
|
|
35
|
+
readonly space_id: string | null;
|
|
36
|
+
readonly run_id: string | null;
|
|
37
|
+
readonly actor: {
|
|
38
|
+
readonly kind: string;
|
|
39
|
+
readonly id: string;
|
|
40
|
+
};
|
|
41
|
+
readonly idempotency_key: string | null;
|
|
42
|
+
readonly payload: Readonly<Record<string, unknown>>;
|
|
43
|
+
}
|
|
44
|
+
export type RunState = "queued" | "running" | "waiting" | "done" | "failed" | "cancelled";
|
|
45
|
+
export type Role = "owner" | "member" | "guest";
|
|
46
|
+
export interface RunRow {
|
|
47
|
+
readonly run_id: string;
|
|
48
|
+
readonly space_id: string;
|
|
49
|
+
readonly harness_id: string;
|
|
50
|
+
/** The agent it is by, when an agent's (ADR 0087). */
|
|
51
|
+
readonly agent_id?: string | undefined;
|
|
52
|
+
state: RunState;
|
|
53
|
+
}
|
|
54
|
+
export interface ApprovalRow {
|
|
55
|
+
readonly approval_id: string;
|
|
56
|
+
readonly run_id: string;
|
|
57
|
+
readonly space_id: string | null;
|
|
58
|
+
readonly expires_at: string;
|
|
59
|
+
readonly fallback: string;
|
|
60
|
+
/** Who may answer, as the real server resolves it: person ids; empty means anyone in the room. */
|
|
61
|
+
readonly approvers: readonly string[];
|
|
62
|
+
/** Whether the ask matters (ADR 0195): its action's flags and its risk classes, as declared. */
|
|
63
|
+
readonly matters: boolean;
|
|
64
|
+
state: "pending" | "resolved";
|
|
65
|
+
decision: string | null;
|
|
66
|
+
scope: string | null;
|
|
67
|
+
reason: string | null;
|
|
68
|
+
resolved_by: string | null;
|
|
69
|
+
resolved_at: string | null;
|
|
70
|
+
updated_input: unknown;
|
|
71
|
+
}
|
|
72
|
+
export interface QuestionRow {
|
|
73
|
+
readonly ask_id: string;
|
|
74
|
+
readonly run_id: string;
|
|
75
|
+
readonly space_id: string | null;
|
|
76
|
+
readonly questions: readonly {
|
|
77
|
+
readonly question_id: string;
|
|
78
|
+
readonly options: readonly {
|
|
79
|
+
readonly value: string;
|
|
80
|
+
}[];
|
|
81
|
+
readonly default_value?: string;
|
|
82
|
+
}[];
|
|
83
|
+
state: "pending" | "answered";
|
|
84
|
+
answered_by: string | null;
|
|
85
|
+
}
|
|
86
|
+
export interface SpaceRow {
|
|
87
|
+
readonly space_id: string;
|
|
88
|
+
/** Direct, group, channel or thread, as it was opened: what says whether it may be erased. */
|
|
89
|
+
readonly kind: string;
|
|
90
|
+
readonly title: string | undefined;
|
|
91
|
+
/** Whether a person or a harness last named it: a person's name holds over a harness's. */
|
|
92
|
+
readonly title_by: "person" | "harness" | undefined;
|
|
93
|
+
readonly external_key: string | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Who sent `space.created`, or the harness that claimed it: the one harness that may retitle
|
|
96
|
+
* or close it later (rule 7).
|
|
97
|
+
*/
|
|
98
|
+
readonly opened_by: string;
|
|
99
|
+
/** The harness a person asked into it, to claim under a key of its own (rule 15). */
|
|
100
|
+
readonly asked_of: string | undefined;
|
|
101
|
+
/** The other harnesses asked with it from the + (ADR 0087's addendum of 30 September). */
|
|
102
|
+
readonly also_asked_of: readonly string[];
|
|
103
|
+
/** The harness's home, its Main room: people join it, and no agent but the lead (rule 7). */
|
|
104
|
+
readonly home: boolean;
|
|
105
|
+
readonly state: "open" | "closed";
|
|
106
|
+
/** Who last archived or unarchived it, when anybody has (ADR 0066). */
|
|
107
|
+
readonly state_by: "person" | "harness" | undefined;
|
|
108
|
+
readonly created_at: string;
|
|
109
|
+
readonly members: Map<string, Role>;
|
|
110
|
+
}
|
|
111
|
+
/** A room the harness opened by key, as `GET /v1/harnesses/:id/spaces` lists it. */
|
|
112
|
+
export interface OpenedSpace {
|
|
113
|
+
readonly space_id: string;
|
|
114
|
+
readonly key: string;
|
|
115
|
+
readonly shared: boolean;
|
|
116
|
+
readonly title: string | null;
|
|
117
|
+
readonly state: "open" | "closed";
|
|
118
|
+
readonly moved_by?: "person" | "harness";
|
|
119
|
+
}
|
|
120
|
+
/** A room a person asked the harness for and it has not claimed, as the same listing has it. */
|
|
121
|
+
export interface AskedSpace {
|
|
122
|
+
readonly space_id: string;
|
|
123
|
+
readonly asked_by: string;
|
|
124
|
+
readonly title: string | null;
|
|
125
|
+
readonly state: "open" | "closed";
|
|
126
|
+
readonly asked_at: string;
|
|
127
|
+
}
|
|
128
|
+
/** What a claim did, as the door answers it. */
|
|
129
|
+
export interface Claimed {
|
|
130
|
+
readonly spaceId: string;
|
|
131
|
+
/** False on a retry with the key that had already claimed it. */
|
|
132
|
+
readonly claimed: boolean;
|
|
133
|
+
readonly retitled: boolean;
|
|
134
|
+
}
|
|
135
|
+
export interface StoredBytes {
|
|
136
|
+
readonly bytes: Uint8Array;
|
|
137
|
+
readonly mime_type: string;
|
|
138
|
+
readonly sha256: string;
|
|
139
|
+
readonly byte_size: number;
|
|
140
|
+
}
|
|
141
|
+
export interface UploadRow {
|
|
142
|
+
readonly attachment_id: string;
|
|
143
|
+
readonly filename: string;
|
|
144
|
+
readonly uploaded_by: string;
|
|
145
|
+
stored: StoredBytes | undefined;
|
|
146
|
+
}
|
|
147
|
+
/** A URL a harness may fetch an attachment at, for its own token (decision 10). */
|
|
148
|
+
export type Signs = (attachmentId: string) => {
|
|
149
|
+
url: string;
|
|
150
|
+
url_expires_at: string;
|
|
151
|
+
};
|
|
152
|
+
/** The wire's word for a refusal, and the HTTP status it becomes. */
|
|
153
|
+
export type RefusalCode = "forbidden" | "not_found" | "invalid_event" | "stale_file";
|
|
154
|
+
export interface Refusal {
|
|
155
|
+
readonly code: RefusalCode;
|
|
156
|
+
/** The rule that refused, in the real server's own words for it. */
|
|
157
|
+
readonly kind: string;
|
|
158
|
+
readonly message: string;
|
|
159
|
+
readonly issues?: readonly {
|
|
160
|
+
readonly path: string;
|
|
161
|
+
readonly message: string;
|
|
162
|
+
}[];
|
|
163
|
+
/** For `agent_elsewhere`: the room the agent is in (ADR 0087). */
|
|
164
|
+
readonly space_id?: string | undefined;
|
|
165
|
+
}
|
|
166
|
+
/** A refusal as the report reads it: who was refused, for what, and when. */
|
|
167
|
+
export interface Refused extends Refusal {
|
|
168
|
+
readonly at: string;
|
|
169
|
+
readonly who: "person" | "harness";
|
|
170
|
+
readonly type: string | undefined;
|
|
171
|
+
}
|
|
172
|
+
/** A field an event was taken without, because the protocol does not declare it (ADR 0162). */
|
|
173
|
+
export interface Dropped {
|
|
174
|
+
readonly who: "person" | "harness";
|
|
175
|
+
readonly type: string;
|
|
176
|
+
readonly field: string;
|
|
177
|
+
}
|
|
178
|
+
/** Where a task's lane is, for the sender's acknowledgement (M3.5). */
|
|
179
|
+
export interface LaneOpened {
|
|
180
|
+
readonly lane_id: string;
|
|
181
|
+
readonly run_id: string;
|
|
182
|
+
readonly space_id: string;
|
|
183
|
+
}
|
|
184
|
+
export type Outcome = {
|
|
185
|
+
readonly ok: true;
|
|
186
|
+
readonly event: StoredEvent;
|
|
187
|
+
readonly duplicate: boolean;
|
|
188
|
+
/** For a `task` that opened a lane: where it is. Absent when the task was flattened. */
|
|
189
|
+
readonly lane?: LaneOpened | undefined;
|
|
190
|
+
/** A message held from the agents it named (ADR 0097): the count with it, and the ceiling. */
|
|
191
|
+
readonly held?: {
|
|
192
|
+
readonly count: number;
|
|
193
|
+
readonly allowance?: number;
|
|
194
|
+
} | undefined;
|
|
195
|
+
} | {
|
|
196
|
+
readonly ok: false;
|
|
197
|
+
readonly error: Refusal;
|
|
198
|
+
};
|
|
199
|
+
/** A lane the fake opened: the run it is, where it lives, and where its news goes. */
|
|
200
|
+
interface LaneRow {
|
|
201
|
+
readonly lane_id: string;
|
|
202
|
+
readonly run_id: string;
|
|
203
|
+
/** The lead's run that opened it, when the task was sent in one: what a cancel cascades from. */
|
|
204
|
+
readonly lead_run: string | undefined;
|
|
205
|
+
readonly home: string;
|
|
206
|
+
readonly linked: readonly string[];
|
|
207
|
+
told: boolean;
|
|
208
|
+
}
|
|
209
|
+
export type { Viewer };
|
|
210
|
+
/** One of the harness's agents (ADR 0087): who it takes part in rooms as. */
|
|
211
|
+
export interface AgentRow {
|
|
212
|
+
readonly agent_id: string;
|
|
213
|
+
readonly key: string;
|
|
214
|
+
name: string;
|
|
215
|
+
/** Its harness's Main agent (ADR 0087, rule 7), or no longer, its default agent Main instead. */
|
|
216
|
+
lead: boolean;
|
|
217
|
+
state: "active" | "archived";
|
|
218
|
+
/** While free, the room an archive took it out of, which an unarchive brings it back to. */
|
|
219
|
+
released_from?: string | undefined;
|
|
220
|
+
/** The room it was last taken out of, whatever took it. */
|
|
221
|
+
last_space?: string | undefined;
|
|
222
|
+
/** The agent it is a copy of, when it is a fork's copy (ADR 0087, Fork). */
|
|
223
|
+
readonly forked_from?: string | undefined;
|
|
224
|
+
/** The face a person chose for it (ADR 0089); absent while it wears its initials. */
|
|
225
|
+
face?: SpaceIcon | undefined;
|
|
226
|
+
/** The person who last named it (ADR 0091); while set, its harness does not rename it. */
|
|
227
|
+
name_by?: string | undefined;
|
|
228
|
+
/** Deleted by a person (ADR 0095): its key is refused, and it is nobody's to speak as. */
|
|
229
|
+
deleted?: boolean | undefined;
|
|
230
|
+
}
|
|
231
|
+
/** A deleted agent's key, asked for again (ADR 0095, point 5): deleted stays deleted. */
|
|
232
|
+
export declare class AgentDeleted extends Error {
|
|
233
|
+
readonly name = "AgentDeleted";
|
|
234
|
+
constructor();
|
|
235
|
+
}
|
|
236
|
+
/** What came of a fork's copy registered for a room, as the real server answers it. */
|
|
237
|
+
export type ForkAnswer = {
|
|
238
|
+
readonly attached: true;
|
|
239
|
+
} | {
|
|
240
|
+
readonly attached: false;
|
|
241
|
+
readonly why?: string | undefined;
|
|
242
|
+
};
|
|
243
|
+
/** What an agent said while in no room (ADR 0087, rule 6), until it is posted. */
|
|
244
|
+
export interface HeldRow {
|
|
245
|
+
readonly event_id: string;
|
|
246
|
+
readonly agent_id: string;
|
|
247
|
+
readonly said_at: string;
|
|
248
|
+
readonly text: string;
|
|
249
|
+
readonly attachments: readonly unknown[];
|
|
250
|
+
}
|
|
251
|
+
/** Somebody the directory names: a person, the harness, or one of its agents. */
|
|
252
|
+
export interface Named {
|
|
253
|
+
readonly participantId: string;
|
|
254
|
+
readonly kind: "person" | "harness" | "agent";
|
|
255
|
+
readonly displayName: string;
|
|
256
|
+
/** For an agent: the face a person chose for it (ADR 0089), `null` while it has none. */
|
|
257
|
+
readonly face?: SpaceIcon | null | undefined;
|
|
258
|
+
}
|
|
259
|
+
export interface WorkspaceOptions {
|
|
260
|
+
readonly workspaceId: string;
|
|
261
|
+
readonly owner: Principal;
|
|
262
|
+
readonly harness: Principal;
|
|
263
|
+
readonly ids: IdGenerator;
|
|
264
|
+
readonly now: () => Date;
|
|
265
|
+
/** What the harness declares, as its registration would (ADR 0046). Nothing, by default. */
|
|
266
|
+
readonly capabilities?: readonly string[] | undefined;
|
|
267
|
+
}
|
|
268
|
+
export declare class Workspace {
|
|
269
|
+
readonly id: string;
|
|
270
|
+
readonly owner: Principal;
|
|
271
|
+
readonly harness: Principal;
|
|
272
|
+
/** What the harness declares: `new_spaces` is what lets a person ask it for a room. */
|
|
273
|
+
readonly capabilities: readonly string[];
|
|
274
|
+
readonly log: StoredEvent[];
|
|
275
|
+
readonly runs: Map<string, RunRow>;
|
|
276
|
+
readonly approvals: Map<string, ApprovalRow>;
|
|
277
|
+
readonly questions: Map<string, QuestionRow>;
|
|
278
|
+
readonly spaces: Map<string, SpaceRow>;
|
|
279
|
+
/**
|
|
280
|
+
* The first name each room asked of the harness holds for its agent there (ADR 0150), and the
|
|
281
|
+
* person whose naming it is, until the agent takes the harness's place.
|
|
282
|
+
*/
|
|
283
|
+
private readonly holds;
|
|
284
|
+
readonly uploads: Map<string, UploadRow>;
|
|
285
|
+
/** The lanes opened by `task`, by lane id (M3.5). */
|
|
286
|
+
readonly lanes: Map<string, LaneRow>;
|
|
287
|
+
/** The harness's agents, by id (ADR 0087). */
|
|
288
|
+
readonly agents: Map<string, AgentRow>;
|
|
289
|
+
/** In each room, who took whose place: `membership.replaced`, from → to. */
|
|
290
|
+
private readonly replaced;
|
|
291
|
+
/** What free agents said, oldest first (ADR 0087, rule 6). */
|
|
292
|
+
readonly held: HeldRow[];
|
|
293
|
+
/** Every event the door turned away, for the report. */
|
|
294
|
+
readonly refusals: Refused[];
|
|
295
|
+
/** Every field the door dropped from an event it took, for the report. */
|
|
296
|
+
readonly dropped: Dropped[];
|
|
297
|
+
private seq;
|
|
298
|
+
private readonly byKey;
|
|
299
|
+
private readonly listeners;
|
|
300
|
+
private readonly ids;
|
|
301
|
+
private readonly now;
|
|
302
|
+
constructor(options: WorkspaceOptions);
|
|
303
|
+
/** Hear every append, in order. Returns the way to stop hearing. */
|
|
304
|
+
onAppend(listener: (event: StoredEvent) => void): () => void;
|
|
305
|
+
head(): number;
|
|
306
|
+
nowIso(): string;
|
|
307
|
+
/** The one way an event gets in: filled in, validated, checked against who sent it, appended. */
|
|
308
|
+
submit(principal: Principal, raw: unknown, extras?: {
|
|
309
|
+
readonly runId?: string | undefined;
|
|
310
|
+
readonly idempotencyKey?: string | undefined;
|
|
311
|
+
}): Outcome;
|
|
312
|
+
private take;
|
|
313
|
+
/**
|
|
314
|
+
* A message said in no room, which went to everybody (agents review, 3); and what each file of a
|
|
315
|
+
* post was made from (ADR 0099), refusing one made from a version no longer current.
|
|
316
|
+
*/
|
|
317
|
+
private refuseUnsaid;
|
|
318
|
+
/**
|
|
319
|
+
* Who a harness's event is by (ADR 0087, point 2), as the real door reads it: an agent it names
|
|
320
|
+
* must be its own, and its own id is read as its one agent in the room — refused as ambiguous
|
|
321
|
+
* where it has several. A room it is in itself, and anything in no room, stay the harness's.
|
|
322
|
+
*/
|
|
323
|
+
private speakerOf;
|
|
324
|
+
/** The room an event is in: the one it names, or its run's. */
|
|
325
|
+
private roomOf;
|
|
326
|
+
/** The event as its agent's, with the harness beside it, and who decided or spoke with it. */
|
|
327
|
+
private speakAs;
|
|
328
|
+
/**
|
|
329
|
+
* A person adding the harness to a room adds its default agent (ADR 0087's addendum, point 5),
|
|
330
|
+
* except to a room asked of it from the +, which holds the harness until it claims it.
|
|
331
|
+
*/
|
|
332
|
+
private addedAsAgent;
|
|
333
|
+
/** Whether the harness speaks agents: it declared `agents` (ADR 0087's addendum). */
|
|
334
|
+
speaksAgents(): boolean;
|
|
335
|
+
/**
|
|
336
|
+
* The harness's agent for a key: found, renamed when the name has changed, archived or brought
|
|
337
|
+
* back as `state` says, or registered. A change is keyed by the log's head, as the server's is.
|
|
338
|
+
* One asked for as Main is the harness's Main from here, and no other is (ADR 0183).
|
|
339
|
+
*/
|
|
340
|
+
registerAgent(key: string, name: string, options?: Parameters<Workspace["registerOrChange"]>[2]): {
|
|
341
|
+
agent: AgentRow;
|
|
342
|
+
created: boolean;
|
|
343
|
+
renamed: boolean;
|
|
344
|
+
};
|
|
345
|
+
private registerOrChange;
|
|
346
|
+
/**
|
|
347
|
+
* The agent a key names, and, when a person deleted the last one, the suffix that keys a new
|
|
348
|
+
* one apart from it. Deleted stays deleted, but for the agent Chips makes for the harness
|
|
349
|
+
* itself, which is made afresh (ADR 0095, point 5).
|
|
350
|
+
*/
|
|
351
|
+
private byAgentKey;
|
|
352
|
+
/**
|
|
353
|
+
* The names nobody but `except` may be given, as the server keeps them (ADR 0091): the owner's,
|
|
354
|
+
* every active agent's, and the first names open rooms hold for the harness's agents-to-be but
|
|
355
|
+
* the one `heldIn` holds (ADR 0150). The harness's own row shares its default agent's name.
|
|
356
|
+
*/
|
|
357
|
+
private takenNames;
|
|
358
|
+
/**
|
|
359
|
+
* The name a known agent has after its harness asks for `wanted`: the name it has where that is
|
|
360
|
+
* the one asked for or a number of it, a person's name for it whatever is asked, and numbered
|
|
361
|
+
* when it comes back to find its name taken, as the server's `registerAgent` does.
|
|
362
|
+
*/
|
|
363
|
+
private nameFor;
|
|
364
|
+
/**
|
|
365
|
+
* A person renames an agent, as `PUT /v1/agents/:id/name` does (ADR 0091): refused a name the
|
|
366
|
+
* owner or another active agent answers to, case and spaces aside; the same name records nothing.
|
|
367
|
+
*/
|
|
368
|
+
renameAgent(agentId: string, wanted: string): {
|
|
369
|
+
readonly ok: true;
|
|
370
|
+
readonly changed: boolean;
|
|
371
|
+
} | {
|
|
372
|
+
readonly ok: false;
|
|
373
|
+
readonly message: string;
|
|
374
|
+
};
|
|
375
|
+
/**
|
|
376
|
+
* The owner archives an agent or brings it back, as `PUT /v1/agents/:id/state` does (ADR 0095):
|
|
377
|
+
* `agent.updated` with the person as its actor, and rule 9's reactions after it. The Main agent
|
|
378
|
+
* and a deleted one are refused; the same state again records nothing.
|
|
379
|
+
*/
|
|
380
|
+
archiveAgent(agentId: string, state: AgentRow["state"]): boolean;
|
|
381
|
+
/**
|
|
382
|
+
* The owner deletes an agent, as `DELETE /v1/agents/:id` does (ADR 0095): out of its room, which
|
|
383
|
+
* is archived when no other agent is left there, then `agent.deleted`, which its harness hears.
|
|
384
|
+
*/
|
|
385
|
+
deleteAgent(agentId: string): boolean;
|
|
386
|
+
/**
|
|
387
|
+
* One of the harness's agents in a room in the place of another of its own there, or of the
|
|
388
|
+
* harness itself (ADR 0087, Phase 3), as the server's attach door does it.
|
|
389
|
+
*/
|
|
390
|
+
attachAgent(agentId: string, spaceId: string, replacing: string): {
|
|
391
|
+
readonly ok: true;
|
|
392
|
+
readonly attached: boolean;
|
|
393
|
+
} | {
|
|
394
|
+
readonly ok: false;
|
|
395
|
+
readonly kind: "unknown_agent" | "unknown_space" | "invalid";
|
|
396
|
+
};
|
|
397
|
+
/**
|
|
398
|
+
* The agent the harness has in a room it opened or claimed: the key's own, for every harness
|
|
399
|
+
* (ADR 0087's addendum of 30 September, point 2), named by the room for one that follows its
|
|
400
|
+
* rooms and after the harness otherwise; its default for a room with no key.
|
|
401
|
+
*/
|
|
402
|
+
private agentForRoom;
|
|
403
|
+
/**
|
|
404
|
+
* The agent a room held a first name for takes it (ADR 0150), as named by the person who held
|
|
405
|
+
* it, so the harness asking for another later changes nothing. One a person named keeps that.
|
|
406
|
+
*/
|
|
407
|
+
private nameAsHeld;
|
|
408
|
+
/**
|
|
409
|
+
* The harness's agent in its place in a room, once. One that is in another room stays there,
|
|
410
|
+
* and the harness leaves this one: an agent is in one room at a time.
|
|
411
|
+
*/
|
|
412
|
+
private agentInPlace;
|
|
413
|
+
/**
|
|
414
|
+
* What the real door fills in on a message: the members its @handles name, and who it is for
|
|
415
|
+
* (M3.3, ADR 0081), by the protocol's own two functions, over what the fake knows. The fake
|
|
416
|
+
* knows the names of the owner and the harness under test, so only they can be @mentioned; a
|
|
417
|
+
* harness is any member with a harness id.
|
|
418
|
+
*/
|
|
419
|
+
private fillAddress;
|
|
420
|
+
/**
|
|
421
|
+
* The reply's author and the sender's last aim, as the room reads now: the harness before
|
|
422
|
+
* its agent took its place there is the agent (ADR 0087).
|
|
423
|
+
*/
|
|
424
|
+
private asNowIn;
|
|
425
|
+
/**
|
|
426
|
+
* Who an @ in a room may name: the owner and the harness where they are in it, and the
|
|
427
|
+
* harness's agents — its name a handle for its one agent there (ADR 0087's addendum).
|
|
428
|
+
*/
|
|
429
|
+
private mentionable;
|
|
430
|
+
/** The sender's `to`, with the harness's id read as its one agent in the room. */
|
|
431
|
+
private aimedAt;
|
|
432
|
+
/** The messages said in a space, newest first. */
|
|
433
|
+
private messagesIn;
|
|
434
|
+
/**
|
|
435
|
+
* A reply answers a message said in the room it is said in (ADR 0219), as the real server's
|
|
436
|
+
* rule: one naming no message is `not_found`, one in another space `invalid_event`.
|
|
437
|
+
*/
|
|
438
|
+
private refuseOnReply;
|
|
439
|
+
/** The `message.post` a message id names, wherever it was said. */
|
|
440
|
+
private saidMessage;
|
|
441
|
+
/** Who wrote the message a reply answers, when it is in the same space. */
|
|
442
|
+
private authorOf;
|
|
443
|
+
/** Where a sender's newest message in a space that says went, `all` for everyone (ADR 0081). */
|
|
444
|
+
private lastAddressed;
|
|
445
|
+
/** The lane a task opened, for its acknowledgement; nothing for any other event. */
|
|
446
|
+
private laneOf;
|
|
447
|
+
/**
|
|
448
|
+
* What the real router does with a task, as far as one harness allows (M3.5, ADR 0032): a
|
|
449
|
+
* task the harness routes to itself opens a lane — a `run.requested` in the home it named,
|
|
450
|
+
* or in the direct space, with the run seeded there — and any other target is flattened into
|
|
451
|
+
* a step on the lead's run, since there is nobody else here to route to. A home the harness
|
|
452
|
+
* is not in is refused the same way.
|
|
453
|
+
*/
|
|
454
|
+
/**
|
|
455
|
+
* Where the route card appears: the space the task was sent from, and the space `link_to`
|
|
456
|
+
* names when the harness is in it — never one it is not (the real router's rule).
|
|
457
|
+
*/
|
|
458
|
+
private linkedFor;
|
|
459
|
+
private routeTask;
|
|
460
|
+
/** The rows a lane is: its run, going in its home, and the lane itself with where its news goes. */
|
|
461
|
+
private openLane;
|
|
462
|
+
/** What the lead itself was asked, to name its hop in a lane's trail: its run's goal. */
|
|
463
|
+
private leadGoal;
|
|
464
|
+
/**
|
|
465
|
+
* Cancelling a lead's run cancels the lanes it opened, and theirs, down the chain, as the real
|
|
466
|
+
* router does. A lane that has ended keeps its ending, and the chain below it is still walked.
|
|
467
|
+
* No cancel reached a lane anywhere here before (agents review, finding 37).
|
|
468
|
+
*/
|
|
469
|
+
private cascade;
|
|
470
|
+
/**
|
|
471
|
+
* Where a lane lives (ADR 0087, rule 8): the room named, when its agent is there or the room is
|
|
472
|
+
* no room of the harness's; otherwise the room its agent is in, or, while it is free, a new
|
|
473
|
+
* room with the person, as the real router has it.
|
|
474
|
+
*/
|
|
475
|
+
private laneHome;
|
|
476
|
+
/** The agent a lane to the harness is worked by: the one named, its lead, or its default. */
|
|
477
|
+
private specialistAgent;
|
|
478
|
+
/** A task the harness routes to itself or one of its agents, and not to a child. */
|
|
479
|
+
private toItself;
|
|
480
|
+
/** The agent of the harness's that works a lane in a home: the one named, or its only one. */
|
|
481
|
+
private laneAgent;
|
|
482
|
+
/** A task Chips will not open a lane for: a done step on the lead's run, saying why. */
|
|
483
|
+
private flatten;
|
|
484
|
+
/** A lane's run ended: tell the lead, in every space the lane is linked into. */
|
|
485
|
+
private tellLead;
|
|
486
|
+
/**
|
|
487
|
+
* The files a lane's answer carried, handed back to the lead with the summary: the attachments
|
|
488
|
+
* on the specialist's own messages in the run. A lane that answers with photographs would
|
|
489
|
+
* otherwise send the lead a sentence about them and nothing else.
|
|
490
|
+
*/
|
|
491
|
+
private filesOf;
|
|
492
|
+
/** An event Chips itself appends as `system`: filled in and validated, past the door. */
|
|
493
|
+
private appendSystem;
|
|
494
|
+
/** What the transport knows and the sender must not choose, as the real server fills it. */
|
|
495
|
+
private draftOf;
|
|
496
|
+
private validate;
|
|
497
|
+
/** The attachment an upload id stands for: the uploader's, and only once its bytes are in. */
|
|
498
|
+
private attachmentFor;
|
|
499
|
+
/** Rule 4: the run the event names. Fills in the run's space when the event names none. */
|
|
500
|
+
private refuseOnRun;
|
|
501
|
+
/**
|
|
502
|
+
* Rule 5: the space the event names, and whether the sender is in it. Answering an approval
|
|
503
|
+
* and handing one on are the exceptions, judged by rule 9 instead (ADR 0042): whoever the ask
|
|
504
|
+
* named answers from wherever they are.
|
|
505
|
+
*/
|
|
506
|
+
private refuseOnMembership;
|
|
507
|
+
/**
|
|
508
|
+
* Rule 7: a change to a space comes from somebody with standing in it. A harness retitles or
|
|
509
|
+
* closes only a space it opened; a guest changes nothing; somebody else is removed only by the
|
|
510
|
+
* space's owner, where leaving is anyone's. Rule 5 has already said the sender is in the space.
|
|
511
|
+
*/
|
|
512
|
+
private refuseOnSpaceChange;
|
|
513
|
+
private refuseOnSpaceUpdate;
|
|
514
|
+
/** Rule 8: somebody added to a space is somebody — here, the owner or the harness. */
|
|
515
|
+
private refuseOnParticipant;
|
|
516
|
+
/**
|
|
517
|
+
* Rule 15: a room asked of a harness is asked of one that takes new spaces, for it to claim
|
|
518
|
+
* under a key of its own — so not a thread, which is its parent's, and not a room with a key.
|
|
519
|
+
*/
|
|
520
|
+
private refuseOnAsking;
|
|
521
|
+
/**
|
|
522
|
+
* Rule 9: a decision comes from who the ask named to make it, when it named anyone — from
|
|
523
|
+
* wherever they are, since being named is standing enough (ADR 0042) — and when it named
|
|
524
|
+
* nobody, from anyone in the room but a guest (Gate 5), which is where the room is required.
|
|
525
|
+
*/
|
|
526
|
+
private refuseNotAnApprover;
|
|
527
|
+
/**
|
|
528
|
+
* A harness settles an ask of its own run, answered in its own tools (ADR 0079): the ask is of
|
|
529
|
+
* the run the event names, and that run is the harness's. Once, and never an expiry; This
|
|
530
|
+
* session and Always are a person's to give. And only an ask that does not matter (SEC-10, ADR
|
|
531
|
+
* 0195): money, outside messages, deletions and anything irreversible wait for a person. In this
|
|
532
|
+
* fake nothing hands a harness an ask.
|
|
533
|
+
*/
|
|
534
|
+
private refuseHarnessAnswer;
|
|
535
|
+
/**
|
|
536
|
+
* An ask that named nobody: anyone in the room but a guest, which is where the room is still
|
|
537
|
+
* asked for, rule 5 having stood aside for every decision since ADR 0042.
|
|
538
|
+
*/
|
|
539
|
+
private refuseOnAnyone;
|
|
540
|
+
/**
|
|
541
|
+
* Who may answer an ask, as the real server resolves the refs a harness sent (ADR 0030):
|
|
542
|
+
* `owner` is the harness's owner, `any` is everyone in the room, a person id is itself; a
|
|
543
|
+
* role has nobody but the owner here. Empty means anyone in the room but a guest (Gate 5).
|
|
544
|
+
* `owner` and a person id resolve wherever that person is, as the real server resolves them
|
|
545
|
+
* since ADR 0042; `any` and a role are the room's.
|
|
546
|
+
*/
|
|
547
|
+
private approversOf;
|
|
548
|
+
/** Rule 6: first answer wins. And an answer names an ask this workspace has. */
|
|
549
|
+
private refuseSecondAnswer;
|
|
550
|
+
/** Into the log, then into the projections, then to whoever is listening. */
|
|
551
|
+
private append;
|
|
552
|
+
private project;
|
|
553
|
+
/** An agent registered or changed (ADR 0087). */
|
|
554
|
+
private projectAgent;
|
|
555
|
+
/** An agent a person deleted (ADR 0095): marked, and what it was holding dropped. */
|
|
556
|
+
private projectDeleted;
|
|
557
|
+
/** An agent's new name, state or face, whichever `agent.updated` carries. */
|
|
558
|
+
private projectAgentChange;
|
|
559
|
+
/** Where an agent was last, the room an archive took it from, and what it said meanwhile. */
|
|
560
|
+
private projectWhereabouts;
|
|
561
|
+
/** An agent put in a room, taken out of one, or replaced in one. */
|
|
562
|
+
private projectPlace;
|
|
563
|
+
private projectRun;
|
|
564
|
+
private projectAsks;
|
|
565
|
+
private projectSpace;
|
|
566
|
+
/**
|
|
567
|
+
* One member in another's place in a room, keeping its role; and whoever holds a place last is
|
|
568
|
+
* who what was said in it reads as (ADR 0087, Phase 3).
|
|
569
|
+
*/
|
|
570
|
+
private replaceMember;
|
|
571
|
+
/** The open room an agent is in, or nothing while it is free (rule 1). */
|
|
572
|
+
agentRoom(agentId: string): string | undefined;
|
|
573
|
+
/**
|
|
574
|
+
* Why this agent may not work on a room's project (ADR 0220), in the server's words, or nothing
|
|
575
|
+
* when it may: it is the harness's, not deleted, and in the room now.
|
|
576
|
+
*/
|
|
577
|
+
refuseOnProject(agentId: string | undefined, spaceId: string): string | undefined;
|
|
578
|
+
/** A push that moved a room's project forward (ADR 0220), as the server records it. */
|
|
579
|
+
recordProjectChange(spaceId: string, agentId: string, change: Readonly<Record<string, unknown>>): StoredEvent;
|
|
580
|
+
/** What the harness's agents route reports of an agent: its room, and how much it holds. */
|
|
581
|
+
whereabouts(agent: AgentRow): {
|
|
582
|
+
room: string | null;
|
|
583
|
+
released_from: string | null;
|
|
584
|
+
held: number;
|
|
585
|
+
};
|
|
586
|
+
/** A reaction's event, once: the real store's idempotency key does this for it. */
|
|
587
|
+
private appendOnce;
|
|
588
|
+
/** The harness's own event, once, for a reaction said as the harness. */
|
|
589
|
+
private appendAsOnce;
|
|
590
|
+
private readonly reactions;
|
|
591
|
+
private react;
|
|
592
|
+
/**
|
|
593
|
+
* A room's job weighed against its ceiling after each cost reported there (ADR 0118), as the
|
|
594
|
+
* real `hold-at-ceiling`: from 80% a warning to the room, and at the ceiling the agents paused by
|
|
595
|
+
* Chips, saying why, unless they are paused already, then the pause's warning. Once each per job.
|
|
596
|
+
*/
|
|
597
|
+
private holdAtCeiling;
|
|
598
|
+
/**
|
|
599
|
+
* What the referee held, handed over once a person acts in the room (ADR 0097), as the real
|
|
600
|
+
* `hand-over-held`: for each agent, the newest held message that was for it, once.
|
|
601
|
+
*/
|
|
602
|
+
private handOver;
|
|
603
|
+
/** A held message's own aim, as it was sent. */
|
|
604
|
+
private toOf;
|
|
605
|
+
/** How the agents' talk in a room stands as of a seq (ADR 0097), for what a turn is handed. */
|
|
606
|
+
exchangeAt(spaceId: string, seq: number): FakeExchange;
|
|
607
|
+
/** A person pauses the agents in a room, or lets them carry on (ADR 0097). */
|
|
608
|
+
setExchange(spaceId: string, state: "paused" | "going", by: string): StoredEvent;
|
|
609
|
+
/**
|
|
610
|
+
* A person chooses who leads a room, or that nobody does (ADR 0104). The fake keeps no clock, so
|
|
611
|
+
* it never hands a lead what was nobody's turn on its own; `handToLead` does, when a test says.
|
|
612
|
+
*/
|
|
613
|
+
setLead(spaceId: string, agentId: string | null, by: string): StoredEvent;
|
|
614
|
+
/** Who leads a room now (ADR 0104): the agent last chosen, while it is there. */
|
|
615
|
+
leadOf(spaceId: string): string | undefined;
|
|
616
|
+
/** A person sets what a room allows a job, or sets it back to the default (ADR 0117). */
|
|
617
|
+
setSpendCeiling(spaceId: string, usd: number | null, by: string): StoredEvent;
|
|
618
|
+
/**
|
|
619
|
+
* What a room's job has spent as of `upto`, against what the room allows a job (ADR 0117), as
|
|
620
|
+
* Chips works it out: from the last person's act or brief handed in, what the room's `usage`
|
|
621
|
+
* reports said since, a run's own report being its total so far.
|
|
622
|
+
*/
|
|
623
|
+
spendOf(spaceId: string, upto: number): JobSpend;
|
|
624
|
+
/** What was nobody's turn, handed to the room's lead as the sweep would (ADR 0104). */
|
|
625
|
+
handToLead(spaceId: string, messageEventId: string): StoredEvent | undefined;
|
|
626
|
+
/** An agent put in a room: said where everyone can see. */
|
|
627
|
+
private attachedNotice;
|
|
628
|
+
/** What an agent said while in no room, posted in the room it is in now, oldest first. */
|
|
629
|
+
private postHeld;
|
|
630
|
+
/** An agent out of a room: said, with why. */
|
|
631
|
+
private releasedNotice;
|
|
632
|
+
/**
|
|
633
|
+
* Stop the work in a room that somebody is leaving (agents review, findings 10 and 12): one
|
|
634
|
+
* agent's runs there, or every run there when the room itself is going. Before the leaving is
|
|
635
|
+
* written, as the real server does it, so the harness is still in the room to hear.
|
|
636
|
+
*/
|
|
637
|
+
private stopWork;
|
|
638
|
+
/** Take an agent out of a room, for a reason: its work there is stopped first. */
|
|
639
|
+
private takeOut;
|
|
640
|
+
/** A room archived (rule 3): its runs stopped, then its agents released. */
|
|
641
|
+
private archived;
|
|
642
|
+
/** A room unarchived (rule 4): the agents its archive released that are still free. */
|
|
643
|
+
private unarchived;
|
|
644
|
+
/** An agent archived in its harness (rule 9): out, and the room archived if it was alone. */
|
|
645
|
+
private agentArchived;
|
|
646
|
+
/** A room archived because the only agent in it left for good (rule 9, ADR 0095). */
|
|
647
|
+
private closeIfEmpty;
|
|
648
|
+
/** An agent restored in its harness: back to the room its archive closed, reopened. */
|
|
649
|
+
private agentRestored;
|
|
650
|
+
/**
|
|
651
|
+
* Rule 16: an agent is in one room at a time; an archived room takes none; the Main agent is
|
|
652
|
+
* only in its Main room, which takes no other agent; and an agent archived in its harness joins
|
|
653
|
+
* nothing. All but the first clause below and the archived one are `refuseAgentInto`, the
|
|
654
|
+
* function the real door and the real store ask (agents review, findings 5 to 8).
|
|
655
|
+
*/
|
|
656
|
+
private refuseOnAgentMembership;
|
|
657
|
+
/** The one-room rule for an agent and a room, as the real store's gate asks it. */
|
|
658
|
+
private refusePlacing;
|
|
659
|
+
/** Rule 17: the Main agent is not taken out of its Main room (agents review, finding 9). */
|
|
660
|
+
private refuseOnLeadRemoval;
|
|
661
|
+
/**
|
|
662
|
+
* What an agent in no room says (rule 6): held, or, for one never in a room, said in a room
|
|
663
|
+
* opened with the harness's owner. Naming no room, one in a room says it there.
|
|
664
|
+
*/
|
|
665
|
+
private holdIfFree;
|
|
666
|
+
/**
|
|
667
|
+
* The agent a post is said by, when it is not in the room the post names. Nothing for an agent
|
|
668
|
+
* in the room it names, and nothing for a room that is gone, which the door refuses and does
|
|
669
|
+
* not hold for the next (agents review, finding 10).
|
|
670
|
+
*/
|
|
671
|
+
private speakerOutside;
|
|
672
|
+
/** Who a harness's post is said by: its agent named, or the one that last left the room named. */
|
|
673
|
+
private speakerAgent;
|
|
674
|
+
/** Whether an agent was ever in a room. */
|
|
675
|
+
private everIn;
|
|
676
|
+
/** A room with the harness's owner for a free agent: its first words, or a hand-off (rule 8). */
|
|
677
|
+
private roomWithOwner;
|
|
678
|
+
/** A claim whose key's agent is in another room: refused. */
|
|
679
|
+
private refuseElsewhere;
|
|
680
|
+
/** A room asked of the harness beside another: it answers with its key's agent in its place. */
|
|
681
|
+
private answer;
|
|
682
|
+
/** Why an agent may not be moved into a room, or nothing when it may. */
|
|
683
|
+
private refuseMove;
|
|
684
|
+
/**
|
|
685
|
+
* A person gives an agent a face, or its initials back with `null`, as `PUT` and `DELETE
|
|
686
|
+
* /v1/agents/:id/face` do (ADR 0089): `agent.updated` carrying the face and nothing else, which
|
|
687
|
+
* every connection hears. The same face again records nothing.
|
|
688
|
+
*/
|
|
689
|
+
setAgentFace(agentId: string, face: SpaceIcon | null): boolean;
|
|
690
|
+
/**
|
|
691
|
+
* A person moves an agent into a room (ADR 0087, point 4): its runs where it was stop, it is
|
|
692
|
+
* taken out saying where it went, and it is put here. The owner is the one person here.
|
|
693
|
+
*/
|
|
694
|
+
moveAgent(agentId: string, spaceId: string): {
|
|
695
|
+
ok: true;
|
|
696
|
+
moved: boolean;
|
|
697
|
+
from: string | null;
|
|
698
|
+
} | {
|
|
699
|
+
ok: false;
|
|
700
|
+
error: Refusal;
|
|
701
|
+
};
|
|
702
|
+
/**
|
|
703
|
+
* The person deletes a room (ADR 0067; ADR 0087, rule 5), as `DELETE /v1/spaces/:id` does on
|
|
704
|
+
* the real server: every run going in it is stopped while its agents are still there, what was
|
|
705
|
+
* said in it goes from the log, one `space.erased` stays, and each of its agents is told it is
|
|
706
|
+
* free. Asked to delete the room's one agent too, Chips archives it, and its harness deletes
|
|
707
|
+
* its side. The owner is the one person here, and owns the harness.
|
|
708
|
+
*/
|
|
709
|
+
eraseSpace(spaceId: string, options?: {
|
|
710
|
+
readonly deleteAgent?: boolean;
|
|
711
|
+
}): {
|
|
712
|
+
ok: true;
|
|
713
|
+
} | {
|
|
714
|
+
ok: false;
|
|
715
|
+
error: Refusal;
|
|
716
|
+
};
|
|
717
|
+
/** A room gone from the log and from every row built from it, as the real erase leaves it. */
|
|
718
|
+
private forget;
|
|
719
|
+
/** The newest ask for a copy of this agent in this room, and whether a copy joined for it. */
|
|
720
|
+
forkAsk(agentId: string, spaceId: string): {
|
|
721
|
+
readonly event: StoredEvent;
|
|
722
|
+
readonly answered: boolean;
|
|
723
|
+
} | undefined;
|
|
724
|
+
/** Whether an ask still waits for its copy: none joined, and the minute is not up. */
|
|
725
|
+
private stands;
|
|
726
|
+
/** Why the owner may not ask for a copy of this agent in this room, or nothing when they may. */
|
|
727
|
+
private refuseFork;
|
|
728
|
+
/**
|
|
729
|
+
* The owner asks for a copy of an agent in a room (ADR 0087, Fork): `agent.fork` there, which
|
|
730
|
+
* the harness hears. Asked again while an ask stands, it is the same ask.
|
|
731
|
+
*/
|
|
732
|
+
forkAgent(agentId: string, spaceId: string): {
|
|
733
|
+
ok: true;
|
|
734
|
+
asked: boolean;
|
|
735
|
+
forkId: string;
|
|
736
|
+
} | {
|
|
737
|
+
ok: false;
|
|
738
|
+
error: Refusal;
|
|
739
|
+
};
|
|
740
|
+
/**
|
|
741
|
+
* The harness's copy, registered for the room it was asked for: in the room while the ask
|
|
742
|
+
* stands, free otherwise, with why, as the real server answers.
|
|
743
|
+
*/
|
|
744
|
+
answerFork(agentId: string, forkedFrom: string, spaceId: string): ForkAnswer;
|
|
745
|
+
/** A person's ask for a new agent (ADR 0108), by its id, and whether an agent joined for it. */
|
|
746
|
+
agentAsk(askId: string): {
|
|
747
|
+
readonly event: StoredEvent;
|
|
748
|
+
readonly answered: boolean;
|
|
749
|
+
} | undefined;
|
|
750
|
+
/**
|
|
751
|
+
* The owner asks the harness for a new agent in a room (ADR 0108): `agent.asked` there, which
|
|
752
|
+
* the harness hears, under the name given or the harness's own, numbered to a free one.
|
|
753
|
+
*/
|
|
754
|
+
askAgent(spaceId: string, name?: string): {
|
|
755
|
+
ok: true;
|
|
756
|
+
askId: string;
|
|
757
|
+
name: string;
|
|
758
|
+
} | {
|
|
759
|
+
ok: false;
|
|
760
|
+
error: Refusal;
|
|
761
|
+
};
|
|
762
|
+
/**
|
|
763
|
+
* The harness's new agent, registered for the ask it answers: in the ask's room while the ask
|
|
764
|
+
* stands, free otherwise, with why, as the real server answers.
|
|
765
|
+
*/
|
|
766
|
+
answerAsk(agentId: string, askId: string, spaceId: string): ForkAnswer;
|
|
767
|
+
/** Whether this run is a lane's: work the harness routed to one of its own rooms (M3.5). */
|
|
768
|
+
isLaneRun(runId: string | null): boolean;
|
|
769
|
+
/** The run of this harness in this space that has not ended, if there is one. */
|
|
770
|
+
liveRunIn(spaceId: string, harnessId: string): RunRow | undefined;
|
|
771
|
+
roleOf(spaceId: string, participantId: string): Role | undefined;
|
|
772
|
+
/** The rooms a participant is in: a harness's, its agents' too (ADR 0087). */
|
|
773
|
+
memberSpacesOf(participantId: string): string[];
|
|
774
|
+
/** The harness's agents in a room, in the order they came. */
|
|
775
|
+
agentsIn(spaceId: string): AgentRow[];
|
|
776
|
+
/**
|
|
777
|
+
* A room's members as the room note lists them (ADR 0092): in the order they joined, the harness
|
|
778
|
+
* in its own right as an agent, and each agent with its harness's name (ADR 0101), as the
|
|
779
|
+
* server lists them.
|
|
780
|
+
*/
|
|
781
|
+
noteMembers(spaceId: string): NoteMember[];
|
|
782
|
+
/** The people, the harness and its agents sharing a space with this participant, themselves included. */
|
|
783
|
+
participantsVisibleTo(participantId: string): Named[];
|
|
784
|
+
/**
|
|
785
|
+
* Who may see an event: the real server's rule, which is the protocol's own function, so the
|
|
786
|
+
* two cannot differ on it (phase-0-review finding 6; agents review, finding 37).
|
|
787
|
+
*/
|
|
788
|
+
canSee(event: StoredEvent, viewer: Viewer): boolean;
|
|
789
|
+
/**
|
|
790
|
+
* What a participant is handed with the message at `seq` (ADR 0088), as the real server works it
|
|
791
|
+
* out: the room's lines since it last spoke there, else since it joined, as the room reads now,
|
|
792
|
+
* the newest that fit its budget. Nothing for a budget of no lines.
|
|
793
|
+
*/
|
|
794
|
+
contextFor(participantIds: readonly string[], spaceId: string, seq: number, budget: {
|
|
795
|
+
readonly lines: number;
|
|
796
|
+
readonly chars: number;
|
|
797
|
+
}, sign?: Signs): RoomContext | undefined;
|
|
798
|
+
/** Where the turn that said these words began: its run's first event, else the words. */
|
|
799
|
+
private turnBegan;
|
|
800
|
+
/**
|
|
801
|
+
* The message a reply answers, as the real server hands it over (ADR 0219): its line as the room
|
|
802
|
+
* reads now, of one taken back only who and when, its files signed, and beside a turn's context
|
|
803
|
+
* (`handed`), when it is older than those lines, the lines said just before it. Nothing for a
|
|
804
|
+
* message not said in this room.
|
|
805
|
+
*/
|
|
806
|
+
replyingToFor(spaceId: string, replyTo: string, handed: RoomContext | undefined, sign?: Signs): (ReplyingTo & {
|
|
807
|
+
readonly attachments?: readonly Record<string, unknown>[];
|
|
808
|
+
}) | undefined;
|
|
809
|
+
/**
|
|
810
|
+
* What an agent is handed as it joins a room (ADR 0088, point 5): the room's last lines before it
|
|
811
|
+
* joined, within the budget. Nothing for a budget of no lines.
|
|
812
|
+
*/
|
|
813
|
+
catchUpFor(spaceId: string, seq: number, budget: {
|
|
814
|
+
readonly lines: number;
|
|
815
|
+
readonly chars: number;
|
|
816
|
+
}, sign?: Signs): RoomContext | undefined;
|
|
817
|
+
/** A page of a room's lines before a cursor, and its files now, for `GET /v1/spaces/:id/context`. */
|
|
818
|
+
contextPage(spaceId: string, before: number, limit: number, sign?: Signs): RoomContext;
|
|
819
|
+
/**
|
|
820
|
+
* A room's files at their current version, newest first (ADR 0099): as of the event at `upto`,
|
|
821
|
+
* with it, or as of now. Who posted each as the room reads now.
|
|
822
|
+
*/
|
|
823
|
+
roomFiles(spaceId: string, most: number, upto?: number, sign?: Signs): RoomFile[];
|
|
824
|
+
/** One name's versions in a room, newest first, each with what it was made from (ADR 0100). */
|
|
825
|
+
fileVersions(spaceId: string, name: string, most: number, sign?: Signs): RoomFile[];
|
|
826
|
+
/** Who posted a room's file, as the room reads now. */
|
|
827
|
+
private postedBy;
|
|
828
|
+
private withFiles;
|
|
829
|
+
/** Who everybody the fake knows is now: the owner, the harness and its agents. */
|
|
830
|
+
private whoIs;
|
|
831
|
+
/** A room's lines between two `seq`s, with every edit and deletion there is folded in. */
|
|
832
|
+
private roomLines;
|
|
833
|
+
/** Events as lines, as a room reads them now: whose place each took, and who each is. */
|
|
834
|
+
private linesAsNow;
|
|
835
|
+
/** A page of the log after `cursor`, as this viewer may see it. */
|
|
836
|
+
since(cursor: number, limit: number, viewer: Viewer): {
|
|
837
|
+
events: StoredEvent[];
|
|
838
|
+
nextCursor: number | null;
|
|
839
|
+
};
|
|
840
|
+
/**
|
|
841
|
+
* The space a harness works in, by its own key: found when it exists, opened for its owner
|
|
842
|
+
* when it does not (ADR 0024). The key is stored prefixed with the harness's id, as the real
|
|
843
|
+
* server stores it, so no adapter can name another's space; a shared key — a worktree — is
|
|
844
|
+
* stored under its own namespace, which a second harness would find (ADR 0033). With one
|
|
845
|
+
* harness here there is nobody to join it, and `joined` is always false.
|
|
846
|
+
*/
|
|
847
|
+
openSpace(key: string, title: string | undefined, shared?: boolean): {
|
|
848
|
+
spaceId: string;
|
|
849
|
+
created: boolean;
|
|
850
|
+
joined: boolean;
|
|
851
|
+
};
|
|
852
|
+
/**
|
|
853
|
+
* The room a person asked the harness for, given the harness's key as `space.claimed`, as the
|
|
854
|
+
* real space door claims it when it is sent a `space_id`: only a room asked of this harness,
|
|
855
|
+
* that it is still in and that has no key, under a key no other room holds. A retry with the
|
|
856
|
+
* key that claimed it finds it. The title goes with the claim unless a person named the room.
|
|
857
|
+
* A refusal is kept with the others, for the report.
|
|
858
|
+
*/
|
|
859
|
+
claimSpace(spaceId: string, key: string, title: string | undefined): {
|
|
860
|
+
ok: true;
|
|
861
|
+
value: Claimed;
|
|
862
|
+
} | {
|
|
863
|
+
ok: false;
|
|
864
|
+
error: Refusal;
|
|
865
|
+
};
|
|
866
|
+
/**
|
|
867
|
+
* A room claimed from the + is led by the agent that took the harness's place in it (ADR 0104),
|
|
868
|
+
* unless a person chose a lead first: as the real door has it.
|
|
869
|
+
*/
|
|
870
|
+
private leadFromClaim;
|
|
871
|
+
private refuseClaim;
|
|
872
|
+
/** Every room the harness opened or claimed by key, and whether each is on the list. */
|
|
873
|
+
spacesOpened(): OpenedSpace[];
|
|
874
|
+
/**
|
|
875
|
+
* The rooms people asked the harness for that it has not claimed, and is still in as itself:
|
|
876
|
+
* asked first, or beside another (ADR 0087's addendum of 30 September).
|
|
877
|
+
*/
|
|
878
|
+
spacesAsked(): AskedSpace[];
|
|
879
|
+
/** The direct space `POST /v1/harnesses` opens: the owner and the harness, and nobody else. */
|
|
880
|
+
createDirectSpace(): string;
|
|
881
|
+
private addMembers;
|
|
882
|
+
/** A workspace event Chips itself appends: filled in and validated, past the door's rules. */
|
|
883
|
+
private appendAs;
|
|
884
|
+
newUpload(principal: Principal, filename: string): UploadRow;
|
|
885
|
+
storeUpload(principal: Principal, id: string, bytes: Uint8Array): {
|
|
886
|
+
ok: true;
|
|
887
|
+
row: UploadRow;
|
|
888
|
+
} | {
|
|
889
|
+
ok: false;
|
|
890
|
+
error: Refusal;
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
//# sourceMappingURL=workspace.d.ts.map
|