@langspan/client 0.0.0-stage → 0.17.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 +202 -0
- package/NOTICE +25 -0
- package/README.md +39 -2
- package/dist/commands/admission.d.ts +124 -0
- package/dist/commands/admission.js +4 -0
- package/dist/commands/checks.d.ts +115 -0
- package/dist/commands/checks.js +3 -0
- package/dist/commands/graph.d.ts +119 -0
- package/dist/commands/graph.js +4 -0
- package/dist/commands/index.d.ts +25 -0
- package/dist/commands/index.js +125 -0
- package/dist/commands/notes.d.ts +103 -0
- package/dist/commands/notes.js +3 -0
- package/dist/commands/policy.d.ts +49 -0
- package/dist/commands/policy.js +3 -0
- package/dist/commands/reads.d.ts +105 -0
- package/dist/commands/reads.js +4 -0
- package/dist/commands/remote.d.ts +52 -0
- package/dist/commands/remote.js +3 -0
- package/dist/commands/scans.d.ts +39 -0
- package/dist/commands/scans.js +4 -0
- package/dist/commands/sessions.d.ts +63 -0
- package/dist/commands/sessions.js +3 -0
- package/dist/commands/turns.d.ts +67 -0
- package/dist/commands/turns.js +3 -0
- package/dist/errors.d.ts +35 -0
- package/dist/errors.js +195 -0
- package/dist/node.d.ts +16 -0
- package/dist/node.js +78 -0
- package/dist/outcomes/admission.d.ts +79 -0
- package/dist/outcomes/admission.js +4 -0
- package/dist/outcomes/checks.d.ts +123 -0
- package/dist/outcomes/checks.js +4 -0
- package/dist/outcomes/graph.d.ts +181 -0
- package/dist/outcomes/graph.js +5 -0
- package/dist/outcomes/index.d.ts +21 -0
- package/dist/outcomes/index.js +126 -0
- package/dist/outcomes/log.d.ts +87 -0
- package/dist/outcomes/log.js +4 -0
- package/dist/outcomes/notes.d.ts +140 -0
- package/dist/outcomes/notes.js +4 -0
- package/dist/outcomes/sessions.d.ts +120 -0
- package/dist/outcomes/sessions.js +3 -0
- package/dist/protocol.d.ts +100 -0
- package/dist/protocol.js +166 -0
- package/dist/records.d.ts +250 -0
- package/dist/records.js +6 -0
- package/dist/values.d.ts +330 -0
- package/dist/values.js +7 -0
- package/package.json +43 -4
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every error code this coordinator build writes, sorted by name. The list
|
|
3
|
+
* is `ErrorCode` in `crates/langspan-core/src/error_code.rs`; the tests pin
|
|
4
|
+
* it to `crates/langspan-core/tests/golden/error_codes.txt`, which that
|
|
5
|
+
* crate's own test pins to the enum. The usage guide's "Error codes" table
|
|
6
|
+
* says what each one means.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ERROR_CODES: readonly ["adoption_chain", "adoption_changed", "already_adopted", "already_published", "already_retracted", "coordination_unavailable", "different_repository", "different_task", "index_export_failed", "index_import_refused", "index_unavailable", "internal", "invalid_adoption", "invalid_alert", "invalid_away", "invalid_base", "invalid_batch", "invalid_branch_oids", "invalid_branch_ref", "invalid_calls", "invalid_check", "invalid_check_report", "invalid_checkout", "invalid_command", "invalid_conflict_table", "invalid_content_digest", "invalid_coverage", "invalid_cursor", "invalid_deadline", "invalid_digest", "invalid_event", "invalid_failure", "invalid_frame", "invalid_git_oid", "invalid_graph_context", "invalid_hosts", "invalid_id", "invalid_input_digest", "invalid_key", "invalid_landing", "invalid_left", "invalid_limit", "invalid_line_digests", "invalid_lines", "invalid_message", "invalid_move", "invalid_name", "invalid_note", "invalid_notice", "invalid_number", "invalid_overwrites", "invalid_participant", "invalid_path", "invalid_paths", "invalid_payload", "invalid_policy", "invalid_presence", "invalid_process_identity", "invalid_publication", "invalid_query", "invalid_reason", "invalid_refusal", "invalid_regions", "invalid_remote", "invalid_request", "invalid_request_id", "invalid_retention", "invalid_root", "invalid_sequence", "invalid_session", "invalid_subscription", "invalid_summary", "invalid_symbol", "invalid_symbols", "invalid_tag", "invalid_test_name", "invalid_test_results", "invalid_told", "invalid_ttl", "invalid_turn", "invalid_wait", "invalid_window", "invalid_workspace_verification", "lease_expired", "lease_id_reused", "lease_not_active", "lease_not_found", "message_not_kept", "message_secret_shape", "no_current_evidence", "not_checkout_top", "not_holder", "not_queued", "not_sender", "old_root_exists", "old_root_missing", "other_workspace", "own_publication", "owner_grant_off", "policy_fixed", "presence_off", "process_identity_mismatch", "read_timeout", "receipt_unreadable", "recipient_not_found", "remote_messages_full", "remote_messages_off", "remote_messages_quota", "remote_messages_unsupported", "remote_not_enabled", "remote_sharing_on", "report_busy", "report_unavailable", "request_id_conflict", "response_too_large", "root_derived_id", "scope_unknown", "secret_in_command", "secret_in_test_name", "sender_not_in_workspace", "session_conflict", "session_ended", "session_live", "session_not_found", "snapshot_mismatch", "stale_lease", "stale_liveness_observation", "stale_session", "status_part", "storage_error", "storage_operation", "subscriptions_full", "symbol_ambiguous", "symbol_not_found", "too_many_attempts", "too_many_inputs", "too_many_keys", "too_many_paths", "too_many_related_operations", "too_many_verified_overlaps", "turn_lost", "unknown_message", "unknown_notice", "unknown_session", "unknown_workspace", "unsupported_version", "workspace_busy", "workspace_changed", "workspace_conflict", "workspace_in_use", "workspace_not_found"];
|
|
9
|
+
/** A code of `ERROR_CODES`. */
|
|
10
|
+
export type ErrorCode = (typeof ERROR_CODES)[number];
|
|
11
|
+
/**
|
|
12
|
+
* The coordinator refused the request. `code` is one of `ERROR_CODES`
|
|
13
|
+
* unless a newer coordinator sent one this client doesn't know yet, so it
|
|
14
|
+
* also admits any other string; `isKnownCode` tells them apart.
|
|
15
|
+
*/
|
|
16
|
+
export declare class CoordinatorError extends Error {
|
|
17
|
+
readonly code: ErrorCode | (string & {});
|
|
18
|
+
readonly requestId: string;
|
|
19
|
+
constructor(code: string, message: string, requestId: string);
|
|
20
|
+
}
|
|
21
|
+
/** Whether `code` is one of this client's `ERROR_CODES`. */
|
|
22
|
+
export declare function isKnownCode(code: string): code is ErrorCode;
|
|
23
|
+
/**
|
|
24
|
+
* The coordinator could not be reached, or its answer was not a frame of
|
|
25
|
+
* this protocol. A request may still have been recorded: retry with the
|
|
26
|
+
* same request ID, never a new one. `requestId` is that ID when the error
|
|
27
|
+
* belongs to a request: pass it as `SendOptions.requestId`.
|
|
28
|
+
*/
|
|
29
|
+
export declare class TransportError extends Error {
|
|
30
|
+
readonly requestId: string | undefined;
|
|
31
|
+
constructor(message: string, options?: {
|
|
32
|
+
cause?: unknown;
|
|
33
|
+
requestId?: string;
|
|
34
|
+
});
|
|
35
|
+
}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// The coordinator's error codes and the two errors the client throws.
|
|
2
|
+
/**
|
|
3
|
+
* Every error code this coordinator build writes, sorted by name. The list
|
|
4
|
+
* is `ErrorCode` in `crates/langspan-core/src/error_code.rs`; the tests pin
|
|
5
|
+
* it to `crates/langspan-core/tests/golden/error_codes.txt`, which that
|
|
6
|
+
* crate's own test pins to the enum. The usage guide's "Error codes" table
|
|
7
|
+
* says what each one means.
|
|
8
|
+
*/
|
|
9
|
+
export const ERROR_CODES = [
|
|
10
|
+
"adoption_chain",
|
|
11
|
+
"adoption_changed",
|
|
12
|
+
"already_adopted",
|
|
13
|
+
"already_published",
|
|
14
|
+
"already_retracted",
|
|
15
|
+
"coordination_unavailable",
|
|
16
|
+
"different_repository",
|
|
17
|
+
"different_task",
|
|
18
|
+
"index_export_failed",
|
|
19
|
+
"index_import_refused",
|
|
20
|
+
"index_unavailable",
|
|
21
|
+
"internal",
|
|
22
|
+
"invalid_adoption",
|
|
23
|
+
"invalid_alert",
|
|
24
|
+
"invalid_away",
|
|
25
|
+
"invalid_base",
|
|
26
|
+
"invalid_batch",
|
|
27
|
+
"invalid_branch_oids",
|
|
28
|
+
"invalid_branch_ref",
|
|
29
|
+
"invalid_calls",
|
|
30
|
+
"invalid_check",
|
|
31
|
+
"invalid_check_report",
|
|
32
|
+
"invalid_checkout",
|
|
33
|
+
"invalid_command",
|
|
34
|
+
"invalid_conflict_table",
|
|
35
|
+
"invalid_content_digest",
|
|
36
|
+
"invalid_coverage",
|
|
37
|
+
"invalid_cursor",
|
|
38
|
+
"invalid_deadline",
|
|
39
|
+
"invalid_digest",
|
|
40
|
+
"invalid_event",
|
|
41
|
+
"invalid_failure",
|
|
42
|
+
"invalid_frame",
|
|
43
|
+
"invalid_git_oid",
|
|
44
|
+
"invalid_graph_context",
|
|
45
|
+
"invalid_hosts",
|
|
46
|
+
"invalid_id",
|
|
47
|
+
"invalid_input_digest",
|
|
48
|
+
"invalid_key",
|
|
49
|
+
"invalid_landing",
|
|
50
|
+
"invalid_left",
|
|
51
|
+
"invalid_limit",
|
|
52
|
+
"invalid_line_digests",
|
|
53
|
+
"invalid_lines",
|
|
54
|
+
"invalid_message",
|
|
55
|
+
"invalid_move",
|
|
56
|
+
"invalid_name",
|
|
57
|
+
"invalid_note",
|
|
58
|
+
"invalid_notice",
|
|
59
|
+
"invalid_number",
|
|
60
|
+
"invalid_overwrites",
|
|
61
|
+
"invalid_participant",
|
|
62
|
+
"invalid_path",
|
|
63
|
+
"invalid_paths",
|
|
64
|
+
"invalid_payload",
|
|
65
|
+
"invalid_policy",
|
|
66
|
+
"invalid_presence",
|
|
67
|
+
"invalid_process_identity",
|
|
68
|
+
"invalid_publication",
|
|
69
|
+
"invalid_query",
|
|
70
|
+
"invalid_reason",
|
|
71
|
+
"invalid_refusal",
|
|
72
|
+
"invalid_regions",
|
|
73
|
+
"invalid_remote",
|
|
74
|
+
"invalid_request",
|
|
75
|
+
"invalid_request_id",
|
|
76
|
+
"invalid_retention",
|
|
77
|
+
"invalid_root",
|
|
78
|
+
"invalid_sequence",
|
|
79
|
+
"invalid_session",
|
|
80
|
+
"invalid_subscription",
|
|
81
|
+
"invalid_summary",
|
|
82
|
+
"invalid_symbol",
|
|
83
|
+
"invalid_symbols",
|
|
84
|
+
"invalid_tag",
|
|
85
|
+
"invalid_test_name",
|
|
86
|
+
"invalid_test_results",
|
|
87
|
+
"invalid_told",
|
|
88
|
+
"invalid_ttl",
|
|
89
|
+
"invalid_turn",
|
|
90
|
+
"invalid_wait",
|
|
91
|
+
"invalid_window",
|
|
92
|
+
"invalid_workspace_verification",
|
|
93
|
+
"lease_expired",
|
|
94
|
+
"lease_id_reused",
|
|
95
|
+
"lease_not_active",
|
|
96
|
+
"lease_not_found",
|
|
97
|
+
"message_not_kept",
|
|
98
|
+
"message_secret_shape",
|
|
99
|
+
"no_current_evidence",
|
|
100
|
+
"not_checkout_top",
|
|
101
|
+
"not_holder",
|
|
102
|
+
"not_queued",
|
|
103
|
+
"not_sender",
|
|
104
|
+
"old_root_exists",
|
|
105
|
+
"old_root_missing",
|
|
106
|
+
"other_workspace",
|
|
107
|
+
"own_publication",
|
|
108
|
+
"owner_grant_off",
|
|
109
|
+
"policy_fixed",
|
|
110
|
+
"presence_off",
|
|
111
|
+
"process_identity_mismatch",
|
|
112
|
+
"read_timeout",
|
|
113
|
+
"receipt_unreadable",
|
|
114
|
+
"recipient_not_found",
|
|
115
|
+
"remote_messages_full",
|
|
116
|
+
"remote_messages_off",
|
|
117
|
+
"remote_messages_quota",
|
|
118
|
+
"remote_messages_unsupported",
|
|
119
|
+
"remote_not_enabled",
|
|
120
|
+
"remote_sharing_on",
|
|
121
|
+
"report_busy",
|
|
122
|
+
"report_unavailable",
|
|
123
|
+
"request_id_conflict",
|
|
124
|
+
"response_too_large",
|
|
125
|
+
"root_derived_id",
|
|
126
|
+
"scope_unknown",
|
|
127
|
+
"secret_in_command",
|
|
128
|
+
"secret_in_test_name",
|
|
129
|
+
"sender_not_in_workspace",
|
|
130
|
+
"session_conflict",
|
|
131
|
+
"session_ended",
|
|
132
|
+
"session_live",
|
|
133
|
+
"session_not_found",
|
|
134
|
+
"snapshot_mismatch",
|
|
135
|
+
"stale_lease",
|
|
136
|
+
"stale_liveness_observation",
|
|
137
|
+
"stale_session",
|
|
138
|
+
"status_part",
|
|
139
|
+
"storage_error",
|
|
140
|
+
"storage_operation",
|
|
141
|
+
"subscriptions_full",
|
|
142
|
+
"symbol_ambiguous",
|
|
143
|
+
"symbol_not_found",
|
|
144
|
+
"too_many_attempts",
|
|
145
|
+
"too_many_inputs",
|
|
146
|
+
"too_many_keys",
|
|
147
|
+
"too_many_paths",
|
|
148
|
+
"too_many_related_operations",
|
|
149
|
+
"too_many_verified_overlaps",
|
|
150
|
+
"turn_lost",
|
|
151
|
+
"unknown_message",
|
|
152
|
+
"unknown_notice",
|
|
153
|
+
"unknown_session",
|
|
154
|
+
"unknown_workspace",
|
|
155
|
+
"unsupported_version",
|
|
156
|
+
"workspace_busy",
|
|
157
|
+
"workspace_changed",
|
|
158
|
+
"workspace_conflict",
|
|
159
|
+
"workspace_in_use",
|
|
160
|
+
"workspace_not_found",
|
|
161
|
+
];
|
|
162
|
+
/**
|
|
163
|
+
* The coordinator refused the request. `code` is one of `ERROR_CODES`
|
|
164
|
+
* unless a newer coordinator sent one this client doesn't know yet, so it
|
|
165
|
+
* also admits any other string; `isKnownCode` tells them apart.
|
|
166
|
+
*/
|
|
167
|
+
export class CoordinatorError extends Error {
|
|
168
|
+
code;
|
|
169
|
+
requestId;
|
|
170
|
+
constructor(code, message, requestId) {
|
|
171
|
+
super(`${code}: ${message}`);
|
|
172
|
+
this.name = "CoordinatorError";
|
|
173
|
+
this.code = code;
|
|
174
|
+
this.requestId = requestId;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const known = new Set(ERROR_CODES);
|
|
178
|
+
/** Whether `code` is one of this client's `ERROR_CODES`. */
|
|
179
|
+
export function isKnownCode(code) {
|
|
180
|
+
return known.has(code);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The coordinator could not be reached, or its answer was not a frame of
|
|
184
|
+
* this protocol. A request may still have been recorded: retry with the
|
|
185
|
+
* same request ID, never a new one. `requestId` is that ID when the error
|
|
186
|
+
* belongs to a request: pass it as `SendOptions.requestId`.
|
|
187
|
+
*/
|
|
188
|
+
export class TransportError extends Error {
|
|
189
|
+
requestId;
|
|
190
|
+
constructor(message, options) {
|
|
191
|
+
super(message, options?.cause === undefined ? undefined : { cause: options.cause });
|
|
192
|
+
this.name = "TransportError";
|
|
193
|
+
this.requestId = options?.requestId;
|
|
194
|
+
}
|
|
195
|
+
}
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Client } from "./protocol.ts";
|
|
2
|
+
import type { ClientOptions, Transport } from "./protocol.ts";
|
|
3
|
+
export * from "./protocol.ts";
|
|
4
|
+
/** The longest one exchange waits, connect to answer, unless told otherwise. */
|
|
5
|
+
export declare const DEFAULT_TIMEOUT_MS = 5000;
|
|
6
|
+
export interface SocketOptions {
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
}
|
|
9
|
+
/** A client of the coordinator whose state directory is `stateDir`. */
|
|
10
|
+
export declare function connect(stateDir: string, options?: ClientOptions & SocketOptions): Client;
|
|
11
|
+
/**
|
|
12
|
+
* The transport to `STATE_DIR/daemon.sock`. Before each connection it checks
|
|
13
|
+
* that the directory and the socket belong to this user and are closed to
|
|
14
|
+
* everyone else, as the coordinator keeps them, and refuses otherwise.
|
|
15
|
+
*/
|
|
16
|
+
export declare function unixSocket(stateDir: string, options?: SocketOptions): Transport;
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// The Node adapter: the coordinator's owner-only Unix socket, one request
|
|
2
|
+
// and one answer per connection, as every LangSpan client speaks it.
|
|
3
|
+
import { lstat } from "node:fs/promises";
|
|
4
|
+
import { createConnection } from "node:net";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { Client, MAX_FRAME_BYTES, TransportError } from "./protocol.js";
|
|
7
|
+
export * from "./protocol.js";
|
|
8
|
+
/** The longest one exchange waits, connect to answer, unless told otherwise. */
|
|
9
|
+
export const DEFAULT_TIMEOUT_MS = 5_000;
|
|
10
|
+
/** A client of the coordinator whose state directory is `stateDir`. */
|
|
11
|
+
export function connect(stateDir, options = {}) {
|
|
12
|
+
return new Client(unixSocket(stateDir, options), options);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The transport to `STATE_DIR/daemon.sock`. Before each connection it checks
|
|
16
|
+
* that the directory and the socket belong to this user and are closed to
|
|
17
|
+
* everyone else, as the coordinator keeps them, and refuses otherwise.
|
|
18
|
+
*/
|
|
19
|
+
export function unixSocket(stateDir, options = {}) {
|
|
20
|
+
const socket = join(stateDir, "daemon.sock");
|
|
21
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
22
|
+
return {
|
|
23
|
+
async exchange(frame, signal) {
|
|
24
|
+
const deadline = AbortSignal.timeout(timeoutMs);
|
|
25
|
+
const stop = signal ? AbortSignal.any([signal, deadline]) : deadline;
|
|
26
|
+
await checkEndpoint(stateDir, socket);
|
|
27
|
+
return await exchangeOnce(socket, frame, stop, timeoutMs);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async function checkEndpoint(stateDir, socket) {
|
|
32
|
+
const uid = process.getuid?.();
|
|
33
|
+
if (uid === undefined) {
|
|
34
|
+
throw new TransportError("the coordinator's socket needs a Unix system; Windows is not supported yet");
|
|
35
|
+
}
|
|
36
|
+
const unavailable = (why) => new TransportError(`coordination unavailable at ${socket}: ${why}; start \`langspan daemon --state-dir ${stateDir}\``);
|
|
37
|
+
const [dir, sock] = await Promise.all([lstat(stateDir), lstat(socket)]).catch((error) => {
|
|
38
|
+
throw unavailable(error.code ?? String(error));
|
|
39
|
+
});
|
|
40
|
+
if (!dir.isDirectory() || !sock.isSocket()) {
|
|
41
|
+
throw unavailable("the state directory must be a directory and daemon.sock a socket, neither a symlink");
|
|
42
|
+
}
|
|
43
|
+
for (const entry of [dir, sock]) {
|
|
44
|
+
if (entry.uid !== uid || (entry.mode & 0o077) !== 0) {
|
|
45
|
+
throw unavailable("the state directory and its socket must belong to the current user and be owner-only");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function exchangeOnce(socket, frame, stop, timeoutMs) {
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
const chunks = [];
|
|
52
|
+
let length = 0;
|
|
53
|
+
const connection = createConnection({ path: socket, signal: stop });
|
|
54
|
+
const fail = (why, cause) => {
|
|
55
|
+
connection.destroy();
|
|
56
|
+
reject(new TransportError(`coordination unavailable at ${socket}: ${why}; retry with the same request ID`, { cause }));
|
|
57
|
+
};
|
|
58
|
+
connection.on("connect", () => connection.write(`${frame}\n`));
|
|
59
|
+
connection.on("data", (chunk) => {
|
|
60
|
+
const newline = chunk.indexOf(0x0a);
|
|
61
|
+
const end = newline === -1 ? chunk.length : newline + 1;
|
|
62
|
+
chunks.push(chunk.subarray(0, end));
|
|
63
|
+
length += end;
|
|
64
|
+
if (length > MAX_FRAME_BYTES) {
|
|
65
|
+
fail("the answer exceeds the 64 KiB frame limit");
|
|
66
|
+
}
|
|
67
|
+
else if (newline !== -1) {
|
|
68
|
+
connection.destroy();
|
|
69
|
+
resolve(Buffer.concat(chunks, length - 1).toString("utf8"));
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
connection.on("end", () => fail("the coordinator closed the connection before answering"));
|
|
73
|
+
connection.on("error", (error) => {
|
|
74
|
+
const timedOut = stop.reason instanceof DOMException && stop.reason.name === "TimeoutError";
|
|
75
|
+
fail(timedOut ? `no answer within ${timeoutMs} ms` : error.message, error);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { BranchObservation, Briefing, Conflict, DiskObservation, Intent, IntentOverlaps, Lease, Observation, Reservation, StaleFile } from "../records.ts";
|
|
2
|
+
import type { KeyVersion, StaleKey, WrittenLines } from "../values.ts";
|
|
3
|
+
export interface IntentOutcome {
|
|
4
|
+
type: "intent";
|
|
5
|
+
intent: Intent;
|
|
6
|
+
/** Present when there is something to report; capability `intent_overlaps`. */
|
|
7
|
+
overlaps?: IntentOverlaps;
|
|
8
|
+
}
|
|
9
|
+
export interface IntentEndedOutcome {
|
|
10
|
+
type: "intent_ended";
|
|
11
|
+
session_id: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The number taken, and the other running sessions' claims of the same
|
|
15
|
+
* counter, newest first.
|
|
16
|
+
*/
|
|
17
|
+
export interface ReservedOutcome {
|
|
18
|
+
type: "reserved";
|
|
19
|
+
reservation: Reservation;
|
|
20
|
+
held: Reservation[];
|
|
21
|
+
}
|
|
22
|
+
export interface AdmittedOutcome {
|
|
23
|
+
type: "admitted";
|
|
24
|
+
lease: Lease;
|
|
25
|
+
}
|
|
26
|
+
export interface ConflictOutcome {
|
|
27
|
+
type: "conflict";
|
|
28
|
+
holders: Conflict[];
|
|
29
|
+
}
|
|
30
|
+
export interface CompletedOutcome {
|
|
31
|
+
type: "completed";
|
|
32
|
+
lease_id: string;
|
|
33
|
+
}
|
|
34
|
+
export interface ObservedOutcome {
|
|
35
|
+
type: "observed";
|
|
36
|
+
observation: Observation;
|
|
37
|
+
}
|
|
38
|
+
export interface DiskObservedOutcome {
|
|
39
|
+
type: "disk_observed";
|
|
40
|
+
observation: DiskObservation;
|
|
41
|
+
}
|
|
42
|
+
export interface BranchObservedOutcome {
|
|
43
|
+
type: "branch_observed";
|
|
44
|
+
observation: BranchObservation;
|
|
45
|
+
}
|
|
46
|
+
export interface GitTroubleRecordedOutcome {
|
|
47
|
+
type: "git_trouble_recorded";
|
|
48
|
+
session_id: string;
|
|
49
|
+
}
|
|
50
|
+
export interface BriefingOutcome {
|
|
51
|
+
type: "briefing";
|
|
52
|
+
briefing: Briefing;
|
|
53
|
+
}
|
|
54
|
+
/** Nothing was admitted: the session's view of these files is out of date. */
|
|
55
|
+
export interface StaleBaseOutcome {
|
|
56
|
+
type: "stale_base";
|
|
57
|
+
stale: StaleFile[];
|
|
58
|
+
/** The written keys whose base is not current; capability `versioned_keys`. */
|
|
59
|
+
keys?: StaleKey[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Nothing was admitted: the edit would change lines other live sessions
|
|
63
|
+
* wrote recently, and this session has not read the file.
|
|
64
|
+
*/
|
|
65
|
+
export interface UnreadLinesOutcome {
|
|
66
|
+
type: "unread_lines";
|
|
67
|
+
lines: WrittenLines[];
|
|
68
|
+
}
|
|
69
|
+
export interface SourceObservedOutcome {
|
|
70
|
+
type: "source_observed";
|
|
71
|
+
session_id: string;
|
|
72
|
+
files: number;
|
|
73
|
+
}
|
|
74
|
+
/** The versions a key report recorded; capability `versioned_keys`. */
|
|
75
|
+
export interface KeysReportedOutcome {
|
|
76
|
+
type: "keys_reported";
|
|
77
|
+
session_id: string;
|
|
78
|
+
keys: KeyVersion[];
|
|
79
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { AutoCheck, CheckRecord, CheckView, FlakyTest, Landing, ListedExample, QueuedLanding, Turn } from "../records.ts";
|
|
2
|
+
export interface AutoCheckOutcome {
|
|
3
|
+
type: "auto_check";
|
|
4
|
+
check: AutoCheck;
|
|
5
|
+
}
|
|
6
|
+
export interface AutoCheckDisabledOutcome {
|
|
7
|
+
type: "auto_check_disabled";
|
|
8
|
+
workspace_id: string;
|
|
9
|
+
}
|
|
10
|
+
export interface CheckRecordedOutcome {
|
|
11
|
+
type: "check_recorded";
|
|
12
|
+
check: CheckRecord;
|
|
13
|
+
}
|
|
14
|
+
export interface ChecksOutcome {
|
|
15
|
+
type: "checks";
|
|
16
|
+
checks: CheckView[];
|
|
17
|
+
}
|
|
18
|
+
/** Known-flaky tests, newest flip first; `more` when some were left out. */
|
|
19
|
+
export interface FlakyTestsOutcome {
|
|
20
|
+
type: "flaky_tests";
|
|
21
|
+
workspace_id: string;
|
|
22
|
+
tests: FlakyTest[];
|
|
23
|
+
more?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** `forgotten` is false when nothing was learned about the test. */
|
|
26
|
+
export interface FlakyTestForgottenOutcome {
|
|
27
|
+
type: "flaky_test_forgotten";
|
|
28
|
+
workspace_id: string;
|
|
29
|
+
test: string;
|
|
30
|
+
forgotten: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** The workspace's worked examples, newest first. */
|
|
33
|
+
export interface ExamplesOutcome {
|
|
34
|
+
type: "examples";
|
|
35
|
+
workspace_id: string;
|
|
36
|
+
examples: ListedExample[];
|
|
37
|
+
}
|
|
38
|
+
/** `retired` is false when no kept example has that ID. */
|
|
39
|
+
export interface ExampleRetiredOutcome {
|
|
40
|
+
type: "example_retired";
|
|
41
|
+
workspace_id: string;
|
|
42
|
+
example_id: string;
|
|
43
|
+
retired: boolean;
|
|
44
|
+
}
|
|
45
|
+
/** `shown` is false when the example is gone or was offered before. */
|
|
46
|
+
export interface ExampleShownOutcome {
|
|
47
|
+
type: "example_shown";
|
|
48
|
+
session_id: string;
|
|
49
|
+
example_id: string;
|
|
50
|
+
shown: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* `ready` only when a passing check of that name exists for exactly the tree
|
|
54
|
+
* asked about. `reason` says what is missing otherwise.
|
|
55
|
+
*/
|
|
56
|
+
export interface ReadinessOutcome {
|
|
57
|
+
type: "readiness";
|
|
58
|
+
ready: boolean;
|
|
59
|
+
reason: string;
|
|
60
|
+
check: CheckRecord | null;
|
|
61
|
+
}
|
|
62
|
+
export interface LandedOutcome {
|
|
63
|
+
type: "landed";
|
|
64
|
+
landing: Landing;
|
|
65
|
+
}
|
|
66
|
+
/** The caller holds the turn. */
|
|
67
|
+
export interface TurnOutcome {
|
|
68
|
+
type: "turn";
|
|
69
|
+
turn: Turn;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Another landing holds the turn; nothing was taken. `held_ms` is how long
|
|
73
|
+
* it has held it.
|
|
74
|
+
*/
|
|
75
|
+
export interface TurnBusyOutcome {
|
|
76
|
+
type: "turn_busy";
|
|
77
|
+
holder: Turn;
|
|
78
|
+
held_ms: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The caller is waiting for the turn, at `position` (1 is next). `waiting`
|
|
82
|
+
* is the whole line, first first.
|
|
83
|
+
*/
|
|
84
|
+
export interface TurnWaitingOutcome {
|
|
85
|
+
type: "turn_waiting";
|
|
86
|
+
position: number;
|
|
87
|
+
holder: Turn | null;
|
|
88
|
+
held_ms: number | null;
|
|
89
|
+
waiting: QueuedLanding[];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The caller neither has the turn nor is waiting for it: the queue is full,
|
|
93
|
+
* or the caller did not ask to wait and others are in line.
|
|
94
|
+
*/
|
|
95
|
+
export interface TurnUnavailableOutcome {
|
|
96
|
+
type: "turn_unavailable";
|
|
97
|
+
holder: Turn | null;
|
|
98
|
+
held_ms: number | null;
|
|
99
|
+
waiting: QueuedLanding[];
|
|
100
|
+
queue_full: boolean;
|
|
101
|
+
}
|
|
102
|
+
/** Who holds a target's push turn and who waits for it, first first. */
|
|
103
|
+
export interface TurnQueueOutcome {
|
|
104
|
+
type: "turn_queue";
|
|
105
|
+
holder: Turn | null;
|
|
106
|
+
held_ms: number | null;
|
|
107
|
+
waiting: QueuedLanding[];
|
|
108
|
+
}
|
|
109
|
+
/** `left` is false when the landing was not waiting. */
|
|
110
|
+
export interface TurnQueueLeftOutcome {
|
|
111
|
+
type: "turn_queue_left";
|
|
112
|
+
ticket: string;
|
|
113
|
+
left: boolean;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* `released` is false when the turn was not held by `turn_id`: it had
|
|
117
|
+
* already ended.
|
|
118
|
+
*/
|
|
119
|
+
export interface TurnReleasedOutcome {
|
|
120
|
+
type: "turn_released";
|
|
121
|
+
turn_id: string;
|
|
122
|
+
released: boolean;
|
|
123
|
+
}
|