@haywoodmarx/agent-pager 0.1.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 +21 -0
- package/README.md +63 -0
- package/dist/src/broker/address.d.ts +49 -0
- package/dist/src/broker/address.js +110 -0
- package/dist/src/broker/broker.d.ts +665 -0
- package/dist/src/broker/broker.js +2270 -0
- package/dist/src/broker/database.d.ts +81 -0
- package/dist/src/broker/database.js +69 -0
- package/dist/src/broker/operator-projection.d.ts +291 -0
- package/dist/src/broker/operator-projection.js +722 -0
- package/dist/src/broker/protocol.d.ts +237 -0
- package/dist/src/broker/protocol.js +311 -0
- package/dist/src/broker/schema.d.ts +94 -0
- package/dist/src/broker/schema.js +454 -0
- package/dist/src/broker/snapshot.d.ts +171 -0
- package/dist/src/broker/snapshot.js +78 -0
- package/dist/src/configuration-defaults.d.ts +64 -0
- package/dist/src/configuration-defaults.js +48 -0
- package/dist/src/configuration.d.ts +76 -0
- package/dist/src/configuration.js +156 -0
- package/dist/src/implementations/claude/environment.d.ts +8 -0
- package/dist/src/implementations/claude/environment.js +9 -0
- package/dist/src/implementations/claude/gateway-cli.d.ts +2 -0
- package/dist/src/implementations/claude/gateway-cli.js +136 -0
- package/dist/src/implementations/claude/gateway-identity.d.ts +134 -0
- package/dist/src/implementations/claude/gateway-identity.js +103 -0
- package/dist/src/implementations/claude/gateway.d.ts +148 -0
- package/dist/src/implementations/claude/gateway.js +236 -0
- package/dist/src/implementations/claude/instructions.d.ts +33 -0
- package/dist/src/implementations/claude/instructions.js +64 -0
- package/dist/src/implementations/claude/manifest.d.ts +33 -0
- package/dist/src/implementations/claude/manifest.js +108 -0
- package/dist/src/implementations/claude/plugin-directory.d.ts +80 -0
- package/dist/src/implementations/claude/plugin-directory.js +137 -0
- package/dist/src/implementations/claude/session-continuation.d.ts +25 -0
- package/dist/src/implementations/claude/session-continuation.js +125 -0
- package/dist/src/implementations/claude/session-identity.d.ts +25 -0
- package/dist/src/implementations/claude/session-identity.js +31 -0
- package/dist/src/implementations/claude/session-start-cli.d.ts +2 -0
- package/dist/src/implementations/claude/session-start-cli.js +16 -0
- package/dist/src/implementations/claude/socket-delivery.d.ts +52 -0
- package/dist/src/implementations/claude/socket-delivery.js +159 -0
- package/dist/src/implementations/model.d.ts +162 -0
- package/dist/src/implementations/model.js +1 -0
- package/dist/src/implementations/opencode/adapter.d.ts +71 -0
- package/dist/src/implementations/opencode/adapter.js +94 -0
- package/dist/src/implementations/opencode/environment.d.ts +8 -0
- package/dist/src/implementations/opencode/environment.js +9 -0
- package/dist/src/implementations/opencode/manifest.d.ts +30 -0
- package/dist/src/implementations/opencode/manifest.js +93 -0
- package/dist/src/implementations/opencode/plugin-api.d.ts +120 -0
- package/dist/src/implementations/opencode/plugin-api.js +1 -0
- package/dist/src/implementations/opencode/plugin.d.ts +38 -0
- package/dist/src/implementations/opencode/plugin.js +303 -0
- package/dist/src/implementations/opencode/self-close-tool.d.ts +9 -0
- package/dist/src/implementations/opencode/self-close-tool.js +31 -0
- package/dist/src/implementations/orca/terminal.d.ts +48 -0
- package/dist/src/implementations/orca/terminal.js +154 -0
- package/dist/src/implementations/pi/broker-client.d.ts +56 -0
- package/dist/src/implementations/pi/broker-client.js +156 -0
- package/dist/src/implementations/pi/environment.d.ts +8 -0
- package/dist/src/implementations/pi/environment.js +9 -0
- package/dist/src/implementations/pi/extension.d.ts +57 -0
- package/dist/src/implementations/pi/extension.js +253 -0
- package/dist/src/implementations/pi/host-slots.d.ts +18 -0
- package/dist/src/implementations/pi/host-slots.js +27 -0
- package/dist/src/implementations/pi/manifest.d.ts +11 -0
- package/dist/src/implementations/pi/manifest.js +61 -0
- package/dist/src/implementations/pi/self-close-tool.d.ts +7 -0
- package/dist/src/implementations/pi/self-close-tool.js +27 -0
- package/dist/src/implementations/registry.d.ts +47 -0
- package/dist/src/implementations/registry.js +157 -0
- package/dist/src/implementations/session-key.d.ts +13 -0
- package/dist/src/implementations/session-key.js +19 -0
- package/dist/src/index.d.ts +27 -0
- package/dist/src/index.js +26 -0
- package/dist/src/launch/broker-lock.d.ts +257 -0
- package/dist/src/launch/broker-lock.js +644 -0
- package/dist/src/launch/cli.d.ts +37 -0
- package/dist/src/launch/cli.js +317 -0
- package/dist/src/launch/environment.d.ts +45 -0
- package/dist/src/launch/environment.js +48 -0
- package/dist/src/launch/launch.d.ts +235 -0
- package/dist/src/launch/launch.js +223 -0
- package/dist/src/launch/on-demand.d.ts +202 -0
- package/dist/src/launch/on-demand.js +435 -0
- package/dist/src/launch/runtime-composition.d.ts +88 -0
- package/dist/src/launch/runtime-composition.js +253 -0
- package/dist/src/launch/runtime.d.ts +79 -0
- package/dist/src/launch/runtime.js +196 -0
- package/dist/src/launch/service-system.d.ts +11 -0
- package/dist/src/launch/service-system.js +39 -0
- package/dist/src/launch/service.d.ts +173 -0
- package/dist/src/launch/service.js +492 -0
- package/dist/src/launch/skill.d.ts +57 -0
- package/dist/src/launch/skill.js +81 -0
- package/dist/src/launch/terminal.d.ts +26 -0
- package/dist/src/launch/terminal.js +43 -0
- package/dist/src/launch/workspace-branch.d.ts +10 -0
- package/dist/src/launch/workspace-branch.js +29 -0
- package/dist/src/messaging/delivery-client.d.ts +144 -0
- package/dist/src/messaging/delivery-client.js +261 -0
- package/dist/src/messaging/delivery.d.ts +75 -0
- package/dist/src/messaging/delivery.js +22 -0
- package/dist/src/messaging/inbox-socket.d.ts +98 -0
- package/dist/src/messaging/inbox-socket.js +278 -0
- package/dist/src/messaging/mcp.d.ts +53 -0
- package/dist/src/messaging/mcp.js +501 -0
- package/dist/src/messaging/notifications.d.ts +231 -0
- package/dist/src/messaging/notifications.js +489 -0
- package/dist/src/messaging/push-delivery.d.ts +77 -0
- package/dist/src/messaging/push-delivery.js +187 -0
- package/dist/src/messaging/tools.d.ts +11 -0
- package/dist/src/messaging/tools.js +102 -0
- package/dist/src/messaging/wake.d.ts +23 -0
- package/dist/src/messaging/wake.js +39 -0
- package/dist/src/operator/agent-projection.d.ts +102 -0
- package/dist/src/operator/agent-projection.js +249 -0
- package/dist/src/operator/commands.d.ts +50 -0
- package/dist/src/operator/commands.js +199 -0
- package/dist/src/operator/diagnostics.d.ts +21 -0
- package/dist/src/operator/diagnostics.js +22 -0
- package/dist/src/operator/protocol.d.ts +511 -0
- package/dist/src/operator/protocol.js +49 -0
- package/dist/src/operator/repository-system.d.ts +14 -0
- package/dist/src/operator/repository-system.js +150 -0
- package/dist/src/operator/repository.d.ts +79 -0
- package/dist/src/operator/repository.js +72 -0
- package/dist/src/operator/traffic-projection.d.ts +19 -0
- package/dist/src/operator/traffic-projection.js +229 -0
- package/dist/src/operator/transport.d.ts +87 -0
- package/dist/src/operator/transport.js +549 -0
- package/dist/src/operator/update-store.d.ts +53 -0
- package/dist/src/operator/update-store.js +162 -0
- package/dist/src/operator/updates.d.ts +94 -0
- package/dist/src/operator/updates.js +280 -0
- package/dist/src/operator/validation.d.ts +114 -0
- package/dist/src/operator/validation.js +916 -0
- package/dist/src/shared/guards.d.ts +59 -0
- package/dist/src/shared/guards.js +119 -0
- package/dist/src/shared/http.d.ts +30 -0
- package/dist/src/shared/http.js +50 -0
- package/dist/src/shared/row.d.ts +2 -0
- package/dist/src/shared/row.js +1 -0
- package/dist/src/shared/shell.d.ts +6 -0
- package/dist/src/shared/shell.js +8 -0
- package/dist/src/tui/actions.d.ts +166 -0
- package/dist/src/tui/actions.js +253 -0
- package/dist/src/tui/agent-tree.d.ts +125 -0
- package/dist/src/tui/agent-tree.js +663 -0
- package/dist/src/tui/app.d.ts +38 -0
- package/dist/src/tui/app.js +378 -0
- package/dist/src/tui/chrome.d.ts +86 -0
- package/dist/src/tui/chrome.js +85 -0
- package/dist/src/tui/client.d.ts +41 -0
- package/dist/src/tui/client.js +279 -0
- package/dist/src/tui/composition.d.ts +41 -0
- package/dist/src/tui/composition.js +146 -0
- package/dist/src/tui/message-views.d.ts +94 -0
- package/dist/src/tui/message-views.js +515 -0
- package/dist/src/tui/model.d.ts +414 -0
- package/dist/src/tui/model.js +758 -0
- package/dist/src/tui/presentation.d.ts +350 -0
- package/dist/src/tui/presentation.js +541 -0
- package/dist/src/tui/production.d.ts +79 -0
- package/dist/src/tui/production.js +253 -0
- package/dist/src/tui/run-terminal.d.ts +32 -0
- package/dist/src/tui/run-terminal.js +54 -0
- package/dist/src/tui/runtime.d.ts +113 -0
- package/dist/src/tui/runtime.js +189 -0
- package/dist/src/tui/theme.d.ts +49 -0
- package/dist/src/tui/theme.js +55 -0
- package/dist/src/tui/transport.d.ts +31 -0
- package/dist/src/tui/transport.js +255 -0
- package/dist/src/version.d.ts +11 -0
- package/dist/src/version.js +52 -0
- package/package.json +142 -0
- package/skills/pager/SKILL.md +112 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** Sets how long a connection waits for a competing writer before reporting the database busy. */
|
|
2
|
+
export declare const DATABASE_BUSY_TIMEOUT_MS = 5000;
|
|
3
|
+
/** One row returned by a broker query, keyed by result column name. */
|
|
4
|
+
export type DatabaseRow = Record<string, unknown>;
|
|
5
|
+
/** Value accepted by a positional statement placeholder. */
|
|
6
|
+
export type DatabaseParameter = string | number | bigint | boolean | null | Uint8Array;
|
|
7
|
+
/** Reports what one write statement changed. */
|
|
8
|
+
export type DatabaseWriteResult = {
|
|
9
|
+
/** Counts rows inserted, updated, or deleted by the statement. */
|
|
10
|
+
changes: number;
|
|
11
|
+
/** Identifies the row inserted by the statement, zero when it inserted none. */
|
|
12
|
+
lastInsertRowid: number | bigint;
|
|
13
|
+
};
|
|
14
|
+
/** Prepared statement bound to one broker connection. */
|
|
15
|
+
export type DatabaseStatement = {
|
|
16
|
+
/**
|
|
17
|
+
* Execute a write and report what it changed.
|
|
18
|
+
* @param parameters - Values bound to the statement's positional placeholders.
|
|
19
|
+
* @returns - Change count and inserted row identity.
|
|
20
|
+
*/
|
|
21
|
+
run(...parameters: DatabaseParameter[]): DatabaseWriteResult;
|
|
22
|
+
/**
|
|
23
|
+
* Execute a read and return its first row.
|
|
24
|
+
* @param parameters - Values bound to the statement's positional placeholders.
|
|
25
|
+
* @returns - First matching row, or undefined when the query selected none.
|
|
26
|
+
*/
|
|
27
|
+
get(...parameters: DatabaseParameter[]): DatabaseRow | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Execute a read and return every row.
|
|
30
|
+
* @param parameters - Values bound to the statement's positional placeholders.
|
|
31
|
+
* @returns - Every matching row in query order.
|
|
32
|
+
*/
|
|
33
|
+
all(...parameters: DatabaseParameter[]): DatabaseRow[];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Durability settings reported by one connection. SQLite scopes `synchronous` and `busy_timeout` to
|
|
37
|
+
* the connection that set them, so only the connection that owns the writes can attest to them.
|
|
38
|
+
*/
|
|
39
|
+
export type DatabaseDurability = {
|
|
40
|
+
/** Reports the file-level journal mode, which is durable in the database file itself. */
|
|
41
|
+
journalMode: string;
|
|
42
|
+
/** Reports the connection-local synchronous level as SQLite's numeric setting. */
|
|
43
|
+
synchronous: number;
|
|
44
|
+
/** Reports the connection-local lock-contention wait budget in milliseconds. */
|
|
45
|
+
busyTimeoutMs: number;
|
|
46
|
+
/** Reports whether the connection enforces foreign keys. */
|
|
47
|
+
foreignKeys: boolean;
|
|
48
|
+
};
|
|
49
|
+
/** Single SQLite connection used by the broker and its offline inspection commands. */
|
|
50
|
+
export type BrokerDatabase = {
|
|
51
|
+
/**
|
|
52
|
+
* Run one or more statements without collecting results.
|
|
53
|
+
* @param sql - Semicolon-separated SQL executed in order.
|
|
54
|
+
*/
|
|
55
|
+
exec(sql: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Compile one statement for execution.
|
|
58
|
+
* @param sql - Single SQL statement using positional placeholders.
|
|
59
|
+
* @returns - Statement bound to this connection.
|
|
60
|
+
*/
|
|
61
|
+
prepare(sql: string): DatabaseStatement;
|
|
62
|
+
/**
|
|
63
|
+
* Report this connection's durability settings.
|
|
64
|
+
* @returns - Journal mode, synchronous level, busy timeout, and foreign-key enforcement.
|
|
65
|
+
*/
|
|
66
|
+
durability(): DatabaseDurability;
|
|
67
|
+
/** Release the connection. */
|
|
68
|
+
close(): void;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Open a broker SQLite connection with the project's durability settings applied.
|
|
72
|
+
*
|
|
73
|
+
* `synchronous` and `busy_timeout` are connection-local, so every connection that must honour them
|
|
74
|
+
* sets them here rather than relying on a setting a different connection made.
|
|
75
|
+
* @param path - Database file location, or SQLite's in-memory sentinel.
|
|
76
|
+
* @param options - Read-only inspection mode used by offline diagnostics.
|
|
77
|
+
* @returns - Configured connection.
|
|
78
|
+
*/
|
|
79
|
+
export declare function openBrokerDatabase(path: string, options?: {
|
|
80
|
+
readonly?: boolean;
|
|
81
|
+
}): BrokerDatabase;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Database } from "bun:sqlite";
|
|
2
|
+
/** Sets how long a connection waits for a competing writer before reporting the database busy. */
|
|
3
|
+
export const DATABASE_BUSY_TIMEOUT_MS = 5_000;
|
|
4
|
+
/**
|
|
5
|
+
* Open a broker SQLite connection with the project's durability settings applied.
|
|
6
|
+
*
|
|
7
|
+
* `synchronous` and `busy_timeout` are connection-local, so every connection that must honour them
|
|
8
|
+
* sets them here rather than relying on a setting a different connection made.
|
|
9
|
+
* @param path - Database file location, or SQLite's in-memory sentinel.
|
|
10
|
+
* @param options - Read-only inspection mode used by offline diagnostics.
|
|
11
|
+
* @returns - Configured connection.
|
|
12
|
+
*/
|
|
13
|
+
export function openBrokerDatabase(path, options = {}) {
|
|
14
|
+
const database = options.readonly ? new Database(path, { readonly: true }) : new Database(path);
|
|
15
|
+
// Every statement on this connection is prepared here, keyed by SQL text, so close can finalize them
|
|
16
|
+
// all. The keys are bounded: callers build SQL from fixed statements, schema names and placeholder
|
|
17
|
+
// lists capped by their chunk size.
|
|
18
|
+
const statements = new Map();
|
|
19
|
+
const wrapped = {
|
|
20
|
+
exec: (sql) => {
|
|
21
|
+
database.run(sql);
|
|
22
|
+
},
|
|
23
|
+
prepare: (sql) => {
|
|
24
|
+
let statement = statements.get(sql);
|
|
25
|
+
if (statement === undefined) {
|
|
26
|
+
statement = database.prepare(sql);
|
|
27
|
+
statements.set(sql, statement);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
run: (...parameters) => {
|
|
31
|
+
const result = statement.run(...parameters);
|
|
32
|
+
return { changes: result.changes, lastInsertRowid: result.lastInsertRowid };
|
|
33
|
+
},
|
|
34
|
+
// A missing row is absent, not a stored null.
|
|
35
|
+
get: (...parameters) => statement.get(...parameters) ?? undefined,
|
|
36
|
+
all: (...parameters) => statement.all(...parameters),
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
durability: () => readDurability(wrapped),
|
|
40
|
+
close: () => {
|
|
41
|
+
// A connection with a statement still unfinalized stays open, holding the file, its write-ahead
|
|
42
|
+
// log and shared memory, until garbage collection.
|
|
43
|
+
for (const statement of statements.values())
|
|
44
|
+
statement.finalize();
|
|
45
|
+
statements.clear();
|
|
46
|
+
database.close();
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
// A read-only connection cannot write the journal header, and applying FULL to it would make it
|
|
50
|
+
// report a durability level it did not observe on the writer.
|
|
51
|
+
if (options.readonly)
|
|
52
|
+
wrapped.exec(`pragma busy_timeout = ${String(DATABASE_BUSY_TIMEOUT_MS)}; pragma foreign_keys = ON;`);
|
|
53
|
+
else
|
|
54
|
+
wrapped.exec(`pragma journal_mode = WAL; pragma synchronous = FULL; pragma busy_timeout = ${String(DATABASE_BUSY_TIMEOUT_MS)}; pragma foreign_keys = ON;`);
|
|
55
|
+
return wrapped;
|
|
56
|
+
}
|
|
57
|
+
function readDurability(database) {
|
|
58
|
+
const read = (sql) => database.prepare(sql).get();
|
|
59
|
+
const journal = read("pragma journal_mode");
|
|
60
|
+
const synchronous = read("pragma synchronous");
|
|
61
|
+
const busy = read("pragma busy_timeout");
|
|
62
|
+
const foreignKeys = read("pragma foreign_keys");
|
|
63
|
+
return {
|
|
64
|
+
journalMode: typeof journal?.journal_mode === "string" ? journal.journal_mode.toLowerCase() : "",
|
|
65
|
+
synchronous: Number(synchronous?.synchronous ?? -1),
|
|
66
|
+
busyTimeoutMs: Number(busy?.timeout ?? -1),
|
|
67
|
+
foreignKeys: Number(foreignKeys?.foreign_keys ?? 0) === 1,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import type { BrokerDatabase } from "./database.js";
|
|
2
|
+
import { type AgentId, type MessageState } from "./protocol.js";
|
|
3
|
+
import type { BrokerSnapshot, SnapshotHealth } from "./snapshot.js";
|
|
4
|
+
/** Identifies the policy that shed a broker message. */
|
|
5
|
+
export type BrokerShedReason = BrokerMessageShedEvent["reason"];
|
|
6
|
+
/**
|
|
7
|
+
* Describes an operational event emitted when the broker sheds a message.
|
|
8
|
+
*
|
|
9
|
+
* A pair-scoped policy carries the peer it was measured against; a body-size rejection is decided
|
|
10
|
+
* from the send alone, before the recipient is resolved, and has no peer to name.
|
|
11
|
+
*/
|
|
12
|
+
export type BrokerMessageShedEvent = {
|
|
13
|
+
/** Identifies this operational event. */
|
|
14
|
+
type: "message_shed";
|
|
15
|
+
/** Identifies the agent whose send was shed. */
|
|
16
|
+
agentId: AgentId;
|
|
17
|
+
/** Records the policy limit that was reached. */
|
|
18
|
+
limit: number;
|
|
19
|
+
} & ({
|
|
20
|
+
/** Names the size policy, which rejects a send before its recipient is resolved. */
|
|
21
|
+
reason: "body_size";
|
|
22
|
+
} | {
|
|
23
|
+
/** Names a policy measured against one sender-recipient pair. */
|
|
24
|
+
reason: "per_pair_rate" | "queue_limit";
|
|
25
|
+
/** Identifies the resolved recipient the policy was measured against. */
|
|
26
|
+
peerId: AgentId;
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Describes a stored row the traffic projection could not account for and left out.
|
|
30
|
+
*
|
|
31
|
+
* The row is reported rather than thrown on, because one unreadable row must not cost the operator
|
|
32
|
+
* every other row in the window: the projection feeds a long-lived update stream that has no way to
|
|
33
|
+
* recover from a throw.
|
|
34
|
+
*/
|
|
35
|
+
export type BrokerTrafficSkippedEvent = {
|
|
36
|
+
/** Identifies this operational event. */
|
|
37
|
+
type: "traffic_row_skipped";
|
|
38
|
+
/** Identifies the durable message left out of the projection. */
|
|
39
|
+
messageId: string;
|
|
40
|
+
/** Names the stored columns that could not be read: absent, or holding a value this build does not write. */
|
|
41
|
+
unreadable: readonly string[];
|
|
42
|
+
};
|
|
43
|
+
/** Reports one operator ping audit left out of the traffic window because a stored column could not be read. */
|
|
44
|
+
export type BrokerPingSkippedEvent = {
|
|
45
|
+
/** Identifies this operational event. */
|
|
46
|
+
type: "ping_row_skipped";
|
|
47
|
+
/** Identifies the durable ping audit left out of the projection. */
|
|
48
|
+
auditId: string;
|
|
49
|
+
/** Names the stored columns that could not be read: absent, or holding a value this build does not write. */
|
|
50
|
+
unreadable: readonly string[];
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Reports one durable agent row left out of a projection because a stored column could not be read.
|
|
54
|
+
*/
|
|
55
|
+
export type BrokerAgentSkippedEvent = {
|
|
56
|
+
/** Identifies this operational event. */
|
|
57
|
+
type: "agent_row_skipped";
|
|
58
|
+
/** Identifies the durable agent left out of the projection. */
|
|
59
|
+
agentId: string;
|
|
60
|
+
/** Names the stored columns that could not be read: absent, or holding a value this build does not write. */
|
|
61
|
+
unreadable: readonly string[];
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Reports one lifecycle observation left out of a delivery because a stored column could not be read.
|
|
65
|
+
*/
|
|
66
|
+
export type BrokerLifecycleSkippedEvent = {
|
|
67
|
+
/** Identifies this operational event. */
|
|
68
|
+
type: "lifecycle_entry_skipped";
|
|
69
|
+
/** Identifies the delivery whose audit is one observation short. */
|
|
70
|
+
messageId: string;
|
|
71
|
+
/** Names the stored columns that could not be read: absent, or holding a value this build does not write. */
|
|
72
|
+
unreadable: readonly string[];
|
|
73
|
+
};
|
|
74
|
+
/** Reports that a table holds more rows whose durable position is not a positive safe integer than one read names. */
|
|
75
|
+
export type BrokerSkipsTruncatedEvent = {
|
|
76
|
+
/** Identifies this operational event. */
|
|
77
|
+
type: "skips_truncated";
|
|
78
|
+
/** Names the table whose rows could not all be listed. */
|
|
79
|
+
table: string;
|
|
80
|
+
/** How many rows with such a position this read named individually. */
|
|
81
|
+
named: number;
|
|
82
|
+
/** How many rows with such a position the table holds. */
|
|
83
|
+
total: number;
|
|
84
|
+
};
|
|
85
|
+
/** Reports one durable row whose stored column the broker could not read. */
|
|
86
|
+
export type BrokerStoredRowSkippedEvent = {
|
|
87
|
+
/** Identifies this operational event. */
|
|
88
|
+
type: "stored_row_skipped";
|
|
89
|
+
/** Names the stored column that could not be read, qualified by its table. */
|
|
90
|
+
column: string;
|
|
91
|
+
/** Identifies the row within its table, by rowid or by the durable id the caller held. */
|
|
92
|
+
rowKey: string;
|
|
93
|
+
};
|
|
94
|
+
/** Describes an operational event the broker observed while accepting or projecting traffic. */
|
|
95
|
+
export type BrokerOperationalEvent = BrokerMessageShedEvent | BrokerTrafficSkippedEvent | BrokerPingSkippedEvent | BrokerAgentSkippedEvent | BrokerLifecycleSkippedEvent | BrokerStoredRowSkippedEvent | BrokerSkipsTruncatedEvent;
|
|
96
|
+
/** Carries one traffic read: the rows it could project, and the rows it could not. */
|
|
97
|
+
export type BrokerTrafficReadResult = {
|
|
98
|
+
/** Rows the read projected, in their single broker-owned durable order. */
|
|
99
|
+
records: BrokerTrafficRecord[];
|
|
100
|
+
/** Rows this read could not project, and each table it could not list in full. */
|
|
101
|
+
skips: readonly (BrokerTrafficSkippedEvent | BrokerPingSkippedEvent | BrokerSkipsTruncatedEvent)[];
|
|
102
|
+
};
|
|
103
|
+
/** Describes one durable lifecycle row without exposing notification text or process bindings. */
|
|
104
|
+
export type BrokerTrafficLifecycleRecord = {
|
|
105
|
+
/** Identifies the durable lifecycle row. */
|
|
106
|
+
id: number;
|
|
107
|
+
/** Records when the broker appended the observation. */
|
|
108
|
+
at: number;
|
|
109
|
+
/** Names the broker-owned observation. */
|
|
110
|
+
type: string;
|
|
111
|
+
};
|
|
112
|
+
/** Supplies the bounded durable input used by the renderer-neutral operator traffic projection. */
|
|
113
|
+
export type BrokerTrafficRecord = {
|
|
114
|
+
/** Identifies a delivery accepted into the durable inbox. */
|
|
115
|
+
kind: "accepted_delivery";
|
|
116
|
+
/** Identifies the durable message. */
|
|
117
|
+
messageId: string;
|
|
118
|
+
/** Orders this row among every durable operator traffic kind. */
|
|
119
|
+
trafficPosition: number;
|
|
120
|
+
/** Identifies the sending agent. */
|
|
121
|
+
senderAgentId: AgentId;
|
|
122
|
+
/** Identifies the resolved recipient. */
|
|
123
|
+
recipientAgentId: AgentId;
|
|
124
|
+
/** Preserves the broker routing team. */
|
|
125
|
+
teamId: string;
|
|
126
|
+
/** Preserves the broker routing workspace. */
|
|
127
|
+
workspaceId: string;
|
|
128
|
+
/** Records when the message was accepted. */
|
|
129
|
+
acceptedAt: number;
|
|
130
|
+
/** Carries the one-line subject the sender supplied. */
|
|
131
|
+
subject: string;
|
|
132
|
+
/** Carries the sender-supplied message type. */
|
|
133
|
+
type: string;
|
|
134
|
+
/** Reports the current durable delivery state. */
|
|
135
|
+
state: MessageState;
|
|
136
|
+
/** Carries the single stored JSON representation. */
|
|
137
|
+
encodedBody: string;
|
|
138
|
+
/** Records the stored representation size in bytes. */
|
|
139
|
+
bodySizeBytes: number;
|
|
140
|
+
/** Identifies the stored representation. */
|
|
141
|
+
contentType: string;
|
|
142
|
+
/** Lists durable lifecycle rows in append order. */
|
|
143
|
+
lifecycle: BrokerTrafficLifecycleRecord[];
|
|
144
|
+
} | {
|
|
145
|
+
/** Identifies acceptance of a body-free operator ping request. */
|
|
146
|
+
kind: "ping_audit";
|
|
147
|
+
/** Identifies the durable audit row. */
|
|
148
|
+
auditId: string;
|
|
149
|
+
/** Orders this row among every durable operator traffic kind. */
|
|
150
|
+
trafficPosition: number;
|
|
151
|
+
/** Correlates the command with its body-free control wake. */
|
|
152
|
+
controlId: string;
|
|
153
|
+
/** Identifies the requested target. */
|
|
154
|
+
targetAgentId: AgentId;
|
|
155
|
+
/** Records the durable actor class that requested the ping. */
|
|
156
|
+
actor: "operator";
|
|
157
|
+
/** Records command acceptance without claiming wake delivery. */
|
|
158
|
+
acceptedAt: number;
|
|
159
|
+
};
|
|
160
|
+
/** Describes one durable operator command acceptance used for idempotent retries. */
|
|
161
|
+
export type BrokerOperatorCommandRecord = {
|
|
162
|
+
/** Identifies a body-free ping request. */
|
|
163
|
+
type: "ping_agent";
|
|
164
|
+
/** Correlates retries of the same request. */
|
|
165
|
+
commandId: string;
|
|
166
|
+
/** Identifies the target agent. */
|
|
167
|
+
targetId: string;
|
|
168
|
+
/** Records broker acceptance time. */
|
|
169
|
+
acceptedAt: number;
|
|
170
|
+
/** Correlates the durable audit with its control wake. */
|
|
171
|
+
controlId: string;
|
|
172
|
+
} | {
|
|
173
|
+
/** Identifies a message-expiry request. */
|
|
174
|
+
type: "expire_message";
|
|
175
|
+
/** Correlates retries of the same request. */
|
|
176
|
+
commandId: string;
|
|
177
|
+
/** Identifies the target message. */
|
|
178
|
+
targetId: string;
|
|
179
|
+
/** Records broker acceptance time. */
|
|
180
|
+
acceptedAt: number;
|
|
181
|
+
} | {
|
|
182
|
+
/** Identifies an agent-archive request. */
|
|
183
|
+
type: "archive_agent";
|
|
184
|
+
/** Correlates retries of the same request. */
|
|
185
|
+
commandId: string;
|
|
186
|
+
/** Identifies the target agent. */
|
|
187
|
+
targetId: string;
|
|
188
|
+
/** Records broker acceptance time. */
|
|
189
|
+
acceptedAt: number;
|
|
190
|
+
};
|
|
191
|
+
/** Distinguishes a newly committed command from an exact durable retry. */
|
|
192
|
+
export type BrokerOperatorCommandAcceptance = {
|
|
193
|
+
/** Returns the validated durable acceptance used for the operator result. */
|
|
194
|
+
record: BrokerOperatorCommandRecord;
|
|
195
|
+
/** Reports whether this transaction created the command and its side effects. */
|
|
196
|
+
status: "created" | "existing";
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Read one stored column against the vocabulary its `check` constraint admits.
|
|
200
|
+
*
|
|
201
|
+
* Throws; a caller that cannot afford a throw must not call it.
|
|
202
|
+
* @param value - Column value as the driver returned it.
|
|
203
|
+
* @param allowed - Vocabulary the column's constraint admits.
|
|
204
|
+
* @param column - Column named in the rejection, qualified by its table.
|
|
205
|
+
* @returns - The value, narrowed to the vocabulary.
|
|
206
|
+
*/
|
|
207
|
+
export declare function readStoredEnum<T extends string>(value: unknown, allowed: readonly T[], column: string): T;
|
|
208
|
+
/**
|
|
209
|
+
* Read a stored agent identifier, refusing one this build could not have written.
|
|
210
|
+
* @param value - Column value as the driver returned it.
|
|
211
|
+
* @param column - Column named in the rejection.
|
|
212
|
+
* @returns - The value, narrowed to an agent identity.
|
|
213
|
+
*/
|
|
214
|
+
export declare function readStoredAgentId(value: unknown, column: string): AgentId;
|
|
215
|
+
/**
|
|
216
|
+
* Assert an untrusted value has the shape of a durable operator-facing identity.
|
|
217
|
+
* @param value - Untrusted candidate identity.
|
|
218
|
+
* @param label - Names the identity kind for the rejection message.
|
|
219
|
+
* @returns - The value, narrowed to a validated durable identity string.
|
|
220
|
+
*/
|
|
221
|
+
export declare function assertDurableOperatorId(value: unknown, label: string): string;
|
|
222
|
+
/**
|
|
223
|
+
* Reads durable operator-facing state over a broker connection: traffic records, command
|
|
224
|
+
* idempotency, and snapshot projections. Holds the in-memory operational event log, which only this
|
|
225
|
+
* projection reads.
|
|
226
|
+
*/
|
|
227
|
+
export declare class BrokerOperatorProjection {
|
|
228
|
+
#private;
|
|
229
|
+
/**
|
|
230
|
+
* Bind operator projection reads to one connection.
|
|
231
|
+
* @param db - Connection this projection reads.
|
|
232
|
+
* @param now - Clock shared with the rest of the broker.
|
|
233
|
+
*/
|
|
234
|
+
constructor(db: BrokerDatabase, now: () => number);
|
|
235
|
+
/**
|
|
236
|
+
* Record a shed-message operational event for later diagnostic reporting.
|
|
237
|
+
* @param event - Operational event describing the shed policy and its target.
|
|
238
|
+
*/
|
|
239
|
+
recordShed(event: BrokerMessageShedEvent): void;
|
|
240
|
+
/**
|
|
241
|
+
* Record one durable row whose stored column the broker could not read, unless the ring holds it.
|
|
242
|
+
* @param event - Row and column the caller could not read.
|
|
243
|
+
* @returns - True when this call recorded it, so the caller knows whether to also say so.
|
|
244
|
+
*/
|
|
245
|
+
recordStoredRowSkip(event: BrokerStoredRowSkippedEvent): boolean;
|
|
246
|
+
/**
|
|
247
|
+
* Return operational events recorded since the broker started.
|
|
248
|
+
* @returns - Copy of every retained operational event, oldest first.
|
|
249
|
+
*/
|
|
250
|
+
operationalEvents(): BrokerOperationalEvent[];
|
|
251
|
+
/**
|
|
252
|
+
* Read bounded durable traffic without claiming, acknowledging, or changing retained bodies.
|
|
253
|
+
* @returns Traffic source rows in their single broker-owned durable order.
|
|
254
|
+
*/
|
|
255
|
+
operatorTrafficRecords(): BrokerTrafficReadResult;
|
|
256
|
+
/**
|
|
257
|
+
* Return a prior operator command acceptance for idempotent request handling.
|
|
258
|
+
* @param commandId - Opaque command correlation supplied by the operator boundary.
|
|
259
|
+
* @returns Stored acceptance, or null when this command has not been accepted.
|
|
260
|
+
*/
|
|
261
|
+
operatorCommand(commandId: string): BrokerOperatorCommandRecord | null;
|
|
262
|
+
/**
|
|
263
|
+
* Read a durable message body without claiming or changing it.
|
|
264
|
+
* @param messageId - Durable message whose retained body is being read.
|
|
265
|
+
* @returns - Decoded body, its raw stored copy, and its retained size and representation.
|
|
266
|
+
*/
|
|
267
|
+
readMessageBody(messageId: string): {
|
|
268
|
+
messageId: string;
|
|
269
|
+
body: unknown;
|
|
270
|
+
rawCopy: string;
|
|
271
|
+
sizeBytes: number;
|
|
272
|
+
contentType: string;
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* Return the agent-derived state an operator projection reads, without any delivery.
|
|
276
|
+
* @param workspaceId - Restricts the read to one workspace, or reads every workspace.
|
|
277
|
+
* @returns - Agent-derived snapshot sections only.
|
|
278
|
+
*/
|
|
279
|
+
readAgentSource(workspaceId?: string): Pick<BrokerSnapshot, "workspaces" | "agents" | "connections">;
|
|
280
|
+
/**
|
|
281
|
+
* Read the complete broker snapshot, optionally scoped to one workspace.
|
|
282
|
+
*
|
|
283
|
+
* Never writes, so claim state is as the last `Broker.expireClaims` left it.
|
|
284
|
+
* @param workspaceId - Restricts the read to one workspace's agents and the messages they sent or
|
|
285
|
+
* received, or reads every workspace.
|
|
286
|
+
* @param sequence - Snapshot sequence stamp, taken by the caller from the shared clock.
|
|
287
|
+
* @param health - Broker generation and durability, computed by the caller from owned state.
|
|
288
|
+
* @returns - Broker snapshot, optionally scoped to the requested workspace.
|
|
289
|
+
*/
|
|
290
|
+
readSnapshot(workspaceId: string | undefined, sequence: number, health: SnapshotHealth): BrokerSnapshot;
|
|
291
|
+
}
|