@creatornader/agent-bridge 0.2.0 → 0.3.1
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/CHANGELOG.md +86 -4
- package/README.md +567 -55
- package/ROADMAP.md +114 -0
- package/SECURITY.md +90 -0
- package/SKILL.md +68 -2
- package/bin/agent-bridge +2 -2
- package/clients/claude-desktop.json +3 -1
- package/dist/archive.d.ts +163 -0
- package/dist/archive.js +50 -0
- package/dist/archive.js.map +1 -0
- package/dist/bridge-domain-CBX3IVqC.d.ts +153 -0
- package/dist/{bridge-service-CfqMcMAn.d.ts → bridge-service-hX1ZQp4W.d.ts} +15 -5
- package/dist/bridge-store-DPVSCwfs.d.ts +102 -0
- package/dist/bridge.d.ts +76 -17
- package/dist/bridge.js +52 -24
- package/dist/chunk-2DFNOLMO.js +618 -0
- package/dist/chunk-2DFNOLMO.js.map +1 -0
- package/dist/{chunk-KVR4JBRF.js → chunk-2EVLG3YA.js} +2 -2
- package/dist/{chunk-KVR4JBRF.js.map → chunk-2EVLG3YA.js.map} +1 -1
- package/dist/chunk-45BZGB77.js +709 -0
- package/dist/chunk-45BZGB77.js.map +1 -0
- package/dist/chunk-4VB44KJU.js +230 -0
- package/dist/chunk-4VB44KJU.js.map +1 -0
- package/dist/chunk-5GMB3A77.js +1013 -0
- package/dist/chunk-5GMB3A77.js.map +1 -0
- package/dist/chunk-A6W4QALF.js +1258 -0
- package/dist/chunk-A6W4QALF.js.map +1 -0
- package/dist/chunk-BZLMF5O5.js +328 -0
- package/dist/chunk-BZLMF5O5.js.map +1 -0
- package/dist/{chunk-AXL2I7FH.js → chunk-CEXBMOI5.js} +240 -79
- package/dist/chunk-CEXBMOI5.js.map +1 -0
- package/dist/chunk-GADH244D.js +527 -0
- package/dist/chunk-GADH244D.js.map +1 -0
- package/dist/chunk-MBPZXTJA.js +2428 -0
- package/dist/chunk-MBPZXTJA.js.map +1 -0
- package/dist/chunk-NCO7RLBM.js +146 -0
- package/dist/chunk-NCO7RLBM.js.map +1 -0
- package/dist/chunk-Q6PPMXJC.js +1050 -0
- package/dist/chunk-Q6PPMXJC.js.map +1 -0
- package/dist/{chunk-4KAOBC5X.js → chunk-SPSMZOCJ.js} +190 -165
- package/dist/chunk-SPSMZOCJ.js.map +1 -0
- package/dist/chunk-UAHMP6GC.js +54 -0
- package/dist/chunk-UAHMP6GC.js.map +1 -0
- package/dist/{chunk-YD6YJATN.js → chunk-VOQIDTCJ.js} +4 -2
- package/dist/chunk-VOQIDTCJ.js.map +1 -0
- package/dist/chunk-WAI2IYIQ.js +554 -0
- package/dist/chunk-WAI2IYIQ.js.map +1 -0
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +3555 -214
- package/dist/cli.js.map +1 -1
- package/dist/client-config.d.ts +1 -1
- package/dist/client-config.js +1 -1
- package/dist/client-runtime.d.ts +10 -6
- package/dist/client-runtime.js +9 -6
- package/dist/contracts/generate.d.ts +2 -0
- package/dist/contracts/generate.js +247 -0
- package/dist/contracts/generate.js.map +1 -0
- package/dist/dr.d.ts +324 -0
- package/dist/dr.js +124 -0
- package/dist/dr.js.map +1 -0
- package/dist/gateway-CggQ8vTC.d.ts +78 -0
- package/dist/gateway-main.js +190 -8
- package/dist/gateway-main.js.map +1 -1
- package/dist/gateway.d.ts +4 -3
- package/dist/gateway.js +4 -3
- package/dist/index.js +11 -8
- package/dist/index.js.map +1 -1
- package/dist/postgres-bridge-store-Bfd3hRId.d.ts +49 -0
- package/dist/server.d.ts +3 -2
- package/dist/server.js +13 -8
- package/dist/sqlite.d.ts +94 -12
- package/dist/sqlite.js +7 -4
- package/docs/architecture-v2.md +394 -0
- package/docs/decisions/0001-protocol-layers-and-acknowledgment-semantics.md +85 -0
- package/docs/decisions/0002-canonical-operation-contract-registry.md +46 -0
- package/docs/decisions/0003-host-adapters-and-consumer-instance-keys.md +88 -0
- package/docs/ecosystem.md +86 -0
- package/docs/postmortems/2026-07-08-wrapper-source-drift.md +82 -0
- package/docs/troubleshooting.md +89 -0
- package/llms.txt +107 -6
- package/openapi/agent-bridge-v2.openapi.json +9610 -0
- package/package.json +24 -4
- package/schemas/agent-bridge-v2.capabilities.json +1829 -0
- package/schemas/agent-bridge-v2.mcp.json +2074 -0
- package/schemas/agent-bridge-v2.schema.json +4560 -0
- package/sql/migrations/008_message_projects.sql +36 -0
- package/sql/migrations/009_mailbox_query_indexes.sql +28 -0
- package/sql/migrations/010_publisher_delivery_policy.sql +210 -0
- package/sql/migrations/011_credential_security.sql +875 -0
- package/sql/migrations/012_request_authority.sql +177 -0
- package/sql/migrations/013_row_isolation.sql +495 -0
- package/sql/migrations/014_owner_control_plane.sql +1641 -0
- package/sql/migrations/015_portable_archives.sql +1813 -0
- package/sql/migrations/016_native_dr_fence.sql +1005 -0
- package/bin/CLAUDE.md +0 -11
- package/dist/bridge-domain-BcnBeHOn.d.ts +0 -97
- package/dist/bridge-store-BuGjxTn4.d.ts +0 -61
- package/dist/chunk-4KAOBC5X.js.map +0 -1
- package/dist/chunk-6MAZ6YLZ.js +0 -146
- package/dist/chunk-6MAZ6YLZ.js.map +0 -1
- package/dist/chunk-AXL2I7FH.js.map +0 -1
- package/dist/chunk-BV6W4AJK.js +0 -211
- package/dist/chunk-BV6W4AJK.js.map +0 -1
- package/dist/chunk-CKSKUBDQ.js +0 -153
- package/dist/chunk-CKSKUBDQ.js.map +0 -1
- package/dist/chunk-JOUBDRYX.js +0 -272
- package/dist/chunk-JOUBDRYX.js.map +0 -1
- package/dist/chunk-JTC5YURG.js +0 -49
- package/dist/chunk-JTC5YURG.js.map +0 -1
- package/dist/chunk-O26W5QHS.js +0 -409
- package/dist/chunk-O26W5QHS.js.map +0 -1
- package/dist/chunk-WEULPMUY.js +0 -988
- package/dist/chunk-WEULPMUY.js.map +0 -1
- package/dist/chunk-YD6YJATN.js.map +0 -1
- package/dist/gateway-BULozv3K.d.ts +0 -54
package/bin/CLAUDE.md
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<claude-mem-context>
|
|
2
|
-
# Recent Activity
|
|
3
|
-
|
|
4
|
-
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
|
|
5
|
-
|
|
6
|
-
### Feb 23, 2026
|
|
7
|
-
|
|
8
|
-
| ID | Time | T | Title | Read |
|
|
9
|
-
|----|------|---|-------|------|
|
|
10
|
-
| #5341 | 6:57 AM | ✅ | Agent-bridge database configuration migrated from old to new Supabase account | ~523 |
|
|
11
|
-
</claude-mem-context>
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
2
|
-
[key: string]: JsonValue;
|
|
3
|
-
};
|
|
4
|
-
type DeliveryState = "pending" | "claimed" | "acked" | "retrying" | "dead";
|
|
5
|
-
type MessagePriority = "info" | "high" | "urgent";
|
|
6
|
-
interface RetryPolicy {
|
|
7
|
-
maxAttempts: number;
|
|
8
|
-
baseDelayMs: number;
|
|
9
|
-
maxDelayMs: number;
|
|
10
|
-
jitterRatio: number;
|
|
11
|
-
}
|
|
12
|
-
interface BridgePrincipal {
|
|
13
|
-
workspace: string;
|
|
14
|
-
agent: string;
|
|
15
|
-
instance?: string;
|
|
16
|
-
}
|
|
17
|
-
interface MessageDraft {
|
|
18
|
-
id?: string;
|
|
19
|
-
type: string;
|
|
20
|
-
content: string;
|
|
21
|
-
contentType?: string;
|
|
22
|
-
data?: JsonValue;
|
|
23
|
-
targets?: string[];
|
|
24
|
-
threadId?: string;
|
|
25
|
-
replyToId?: string;
|
|
26
|
-
correlationId?: string;
|
|
27
|
-
causationId?: string;
|
|
28
|
-
priority?: MessagePriority;
|
|
29
|
-
expiresAt?: string;
|
|
30
|
-
idempotencyKey?: string;
|
|
31
|
-
atribReceiptId?: string;
|
|
32
|
-
informedBy?: string[];
|
|
33
|
-
metadata?: JsonValue;
|
|
34
|
-
}
|
|
35
|
-
interface BridgeMessage extends Required<Pick<MessageDraft, "id" | "type" | "content" | "contentType" | "targets" | "priority">> {
|
|
36
|
-
workspace: string;
|
|
37
|
-
source: string;
|
|
38
|
-
sequence: string;
|
|
39
|
-
createdAt: string;
|
|
40
|
-
data?: JsonValue;
|
|
41
|
-
threadId?: string;
|
|
42
|
-
replyToId?: string;
|
|
43
|
-
correlationId?: string;
|
|
44
|
-
causationId?: string;
|
|
45
|
-
expiresAt?: string;
|
|
46
|
-
idempotencyKey?: string;
|
|
47
|
-
atribReceiptId?: string;
|
|
48
|
-
informedBy?: string[];
|
|
49
|
-
metadata?: JsonValue;
|
|
50
|
-
}
|
|
51
|
-
interface BridgeDelivery {
|
|
52
|
-
id: string;
|
|
53
|
-
messageId: string;
|
|
54
|
-
workspace: string;
|
|
55
|
-
recipient: string;
|
|
56
|
-
state: DeliveryState;
|
|
57
|
-
attempt: number;
|
|
58
|
-
availableAt: string;
|
|
59
|
-
leaseToken?: string;
|
|
60
|
-
leaseOwner?: string;
|
|
61
|
-
leaseExpiresAt?: string;
|
|
62
|
-
lastError?: string;
|
|
63
|
-
}
|
|
64
|
-
interface BridgeDeliveryEvent {
|
|
65
|
-
sequence: string;
|
|
66
|
-
deliveryId: string;
|
|
67
|
-
messageId: string;
|
|
68
|
-
workspace: string;
|
|
69
|
-
recipient: string;
|
|
70
|
-
fromState?: DeliveryState;
|
|
71
|
-
toState: DeliveryState;
|
|
72
|
-
attempt: number;
|
|
73
|
-
leaseOwner?: string;
|
|
74
|
-
error?: string;
|
|
75
|
-
createdAt: string;
|
|
76
|
-
}
|
|
77
|
-
interface AgentPresence {
|
|
78
|
-
workspace: string;
|
|
79
|
-
agent: string;
|
|
80
|
-
instance: string;
|
|
81
|
-
runtimeType?: string;
|
|
82
|
-
capabilities: string[];
|
|
83
|
-
leaseExpiresAt: string;
|
|
84
|
-
lastSeenAt: string;
|
|
85
|
-
}
|
|
86
|
-
declare class BridgeValidationError extends Error {
|
|
87
|
-
readonly code = "invalid_input";
|
|
88
|
-
}
|
|
89
|
-
declare function uuidv7(now?: number): string;
|
|
90
|
-
declare function validatePrincipal(value: BridgePrincipal): BridgePrincipal;
|
|
91
|
-
declare function validateUuid(value: unknown, field: string): string;
|
|
92
|
-
declare function validateRetryPolicy(input?: Partial<RetryPolicy> | null): RetryPolicy;
|
|
93
|
-
declare function validateMessageDraft(input: MessageDraft): Omit<BridgeMessage, "workspace" | "source" | "sequence" | "createdAt">;
|
|
94
|
-
declare function encodeCursor(sequence: string): string;
|
|
95
|
-
declare function decodeCursor(cursor: string | undefined): string | undefined;
|
|
96
|
-
|
|
97
|
-
export { type AgentPresence as A, type BridgeDelivery as B, type DeliveryState as D, type JsonValue as J, type MessageDraft as M, type RetryPolicy as R, type BridgeDeliveryEvent as a, type BridgeMessage as b, type BridgePrincipal as c, BridgeValidationError as d, type MessagePriority as e, decodeCursor as f, encodeCursor as g, validatePrincipal as h, validateRetryPolicy as i, validateUuid as j, uuidv7 as u, validateMessageDraft as v };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { b as BridgeMessage, c as BridgePrincipal, B as BridgeDelivery, D as DeliveryState, R as RetryPolicy, A as AgentPresence, a as BridgeDeliveryEvent } from './bridge-domain-BcnBeHOn.js';
|
|
2
|
-
|
|
3
|
-
interface InsertMessageResult {
|
|
4
|
-
message: BridgeMessage;
|
|
5
|
-
created: boolean;
|
|
6
|
-
}
|
|
7
|
-
interface MessageQuery {
|
|
8
|
-
cursor?: string;
|
|
9
|
-
limit?: number;
|
|
10
|
-
types?: string[];
|
|
11
|
-
includeExpired?: boolean;
|
|
12
|
-
source?: string;
|
|
13
|
-
since?: string;
|
|
14
|
-
unacknowledgedBy?: string;
|
|
15
|
-
threadId?: string;
|
|
16
|
-
latest?: boolean;
|
|
17
|
-
}
|
|
18
|
-
interface MessagePage {
|
|
19
|
-
messages: BridgeMessage[];
|
|
20
|
-
cursor?: string;
|
|
21
|
-
}
|
|
22
|
-
interface BridgeDiagnostics {
|
|
23
|
-
schemaVersion: "local-v2" | "postgres-v2" | "legacy-v1";
|
|
24
|
-
deliverySupported: boolean;
|
|
25
|
-
pending: number | null;
|
|
26
|
-
claimed: number | null;
|
|
27
|
-
retrying: number | null;
|
|
28
|
-
dead: number | null;
|
|
29
|
-
oldestAvailableAt?: string;
|
|
30
|
-
principal?: {
|
|
31
|
-
workspace: string;
|
|
32
|
-
agent: string;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
interface ClaimOptions {
|
|
36
|
-
leaseMs: number;
|
|
37
|
-
maxAttempts?: number;
|
|
38
|
-
now?: Date;
|
|
39
|
-
}
|
|
40
|
-
interface BridgeStore {
|
|
41
|
-
initialize(): Promise<void>;
|
|
42
|
-
insertMessage(message: Omit<BridgeMessage, "sequence" | "createdAt">): Promise<InsertMessageResult>;
|
|
43
|
-
listMessages(principal: BridgePrincipal, query?: MessageQuery): Promise<MessagePage>;
|
|
44
|
-
recordReceipt(workspace: string, messageIds: string[], principal: string, readAt?: Date): Promise<number>;
|
|
45
|
-
recordLegacyReceipt?(legacyIds: string[], principal: string): Promise<number>;
|
|
46
|
-
claimDelivery(principal: BridgePrincipal, options: ClaimOptions): Promise<BridgeDelivery | null>;
|
|
47
|
-
renewDelivery(principal: BridgePrincipal, deliveryId: string, leaseToken: string, leaseMs: number): Promise<BridgeDelivery | null>;
|
|
48
|
-
settleDelivery(principal: BridgePrincipal, deliveryId: string, leaseToken: string, state: Extract<DeliveryState, "acked" | "retrying" | "dead">, error: string | undefined, retryPolicy: RetryPolicy): Promise<BridgeDelivery | null>;
|
|
49
|
-
diagnostics?(principal: BridgePrincipal): Promise<BridgeDiagnostics>;
|
|
50
|
-
heartbeat?(principal: BridgePrincipal, leaseMs: number, runtimeType?: string, capabilities?: string[]): Promise<AgentPresence>;
|
|
51
|
-
listPresence?(principal: BridgePrincipal): Promise<AgentPresence[]>;
|
|
52
|
-
listDeliveryEvents?(deliveryId: string): Promise<BridgeDeliveryEvent[]>;
|
|
53
|
-
sync?(options?: {
|
|
54
|
-
maxPush?: number;
|
|
55
|
-
maxPages?: number;
|
|
56
|
-
}): Promise<unknown>;
|
|
57
|
-
verifyRemote?(): Promise<void>;
|
|
58
|
-
close?(): Promise<void>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export type { BridgeDiagnostics as B, ClaimOptions as C, InsertMessageResult as I, MessagePage as M, BridgeStore as a, MessageQuery as b };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server.ts","../src/message-envelope.ts","../src/source-identity.ts"],"sourcesContent":["import { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n CallToolRequestSchema,\n ErrorCode,\n ListToolsRequestSchema,\n McpError,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { homedir } from \"node:os\";\nimport { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\n\nimport { normalizeReceiptId } from \"./atrib-receipt.js\";\nimport {\n buildMessageEnvelope,\n filterContextRows,\n mergeEnvelopeMetadata,\n} from \"./message-envelope.js\";\nimport { resolveAgentIdentity, resolvePostSource } from \"./source-identity.js\";\nimport { BridgeService } from \"./bridge-service.js\";\nimport {\n BridgeValidationError,\n type BridgePrincipal,\n type MessageDraft,\n type RetryPolicy,\n} from \"./bridge-domain.js\";\nimport { createStore } from \"./client-runtime.js\";\nimport { legacyContextMetadata, legacyNumericMessageId } from \"./legacy-compat.js\";\nimport {\n readClientConfigFile,\n resolveClientConfig,\n type ClientConfig,\n type ClientEnvironment,\n type ClientProvider,\n} from \"./client-config.js\";\n\nexport interface AgentBridgeServerConfig {\n supabaseUrl?: string;\n supabaseKey?: string;\n agent?: string;\n provider?: ClientProvider;\n workspace?: string;\n instance?: string;\n databasePath?: string;\n edgeDatabasePath?: string;\n cursorPath?: string;\n gatewayUrl?: string;\n gatewayToken?: string;\n}\n\nconst packageVersion = (createRequire(import.meta.url)(\"../package.json\") as { version: string }).version;\n\nexport interface AgentBridgeServerEnv {\n AGENT_BRIDGE_URL?: string;\n AGENT_BRIDGE_KEY?: string;\n AGENT_BRIDGE_AGENT?: string;\n AGENT_BRIDGE_CONFIG?: string;\n HOME?: string;\n AGENT_BRIDGE_PROVIDER?: string;\n AGENT_BRIDGE_TOKEN?: string;\n AGENT_BRIDGE_WORKSPACE?: string;\n AGENT_BRIDGE_INSTANCE?: string;\n AGENT_BRIDGE_DB?: string;\n}\n\nfunction normalizedConfigValue(value: string | undefined): string | undefined {\n const trimmed = value?.trim();\n return trimmed || undefined;\n}\n\nfunction defaultConfigPath(env: AgentBridgeServerEnv): string {\n return (\n normalizedConfigValue(env.AGENT_BRIDGE_CONFIG) ??\n join(normalizedConfigValue(env.HOME) ?? homedir(), \".agent-bridge\", \"config\")\n );\n}\n\nexport function configFromEnv(\n env: AgentBridgeServerEnv = process.env,\n): AgentBridgeServerConfig {\n const sharedFile = readClientConfigFile(defaultConfigPath(env));\n const value = (key: keyof AgentBridgeServerEnv) =>\n normalizedConfigValue(env[key]) ?? normalizedConfigValue(sharedFile[key]);\n const runtimeAgent = normalizedConfigValue(env.AGENT_BRIDGE_AGENT);\n const rawProvider = normalizedConfigValue(env.AGENT_BRIDGE_PROVIDER) ??\n normalizedConfigValue(sharedFile.AGENT_BRIDGE_PROVIDER);\n const provider = rawProvider === \"legacy\" || rawProvider === \"supabase\"\n ? \"legacy-supabase\"\n : rawProvider ?? (value(\"AGENT_BRIDGE_TOKEN\") ? \"gateway\" : \"legacy-supabase\");\n if (!([\"local\", \"gateway\", \"legacy-supabase\"] as string[]).includes(provider)) {\n throw new Error(`Unsupported AGENT_BRIDGE_PROVIDER: ${rawProvider}`);\n }\n if (provider === \"local\" || provider === \"gateway\") {\n const client = resolveClientConfig(env as ClientEnvironment);\n return {\n provider: client.provider,\n agent: client.principal.agent,\n workspace: client.principal.workspace,\n instance: client.principal.instance,\n databasePath: client.databasePath,\n edgeDatabasePath: client.edgeDatabasePath,\n cursorPath: client.cursorPath,\n gatewayUrl: client.provider === \"gateway\" ? client.url : undefined,\n gatewayToken: client.provider === \"gateway\" ? client.credential : undefined,\n };\n }\n const supabaseUrl =\n value(\"AGENT_BRIDGE_URL\");\n const supabaseKey =\n value(\"AGENT_BRIDGE_KEY\");\n if (!supabaseUrl || !supabaseKey) {\n throw new Error(\n \"Missing AGENT_BRIDGE_URL or AGENT_BRIDGE_KEY environment variables or ~/.agent-bridge/config\",\n );\n }\n return {\n supabaseUrl,\n supabaseKey,\n agent: runtimeAgent,\n provider: provider as ClientProvider,\n workspace: value(\"AGENT_BRIDGE_WORKSPACE\") ?? \"*\",\n instance: normalizedConfigValue(env.AGENT_BRIDGE_INSTANCE),\n };\n}\n\nfunction buildSupabaseRequest(config: AgentBridgeServerConfig & { supabaseUrl: string; supabaseKey: string }) {\n const parsed = new URL(config.supabaseUrl);\n const loopback = parsed.hostname === \"localhost\" || parsed.hostname === \"127.0.0.1\" || parsed.hostname === \"[::1]\";\n if (parsed.protocol !== \"https:\" && !(parsed.protocol === \"http:\" && loopback)) {\n throw new Error(\"Agent Bridge requires HTTPS for non-loopback legacy providers\");\n }\n const restUrl = `${config.supabaseUrl.replace(/\\/$/, \"\")}/rest/v1`;\n const headers = {\n apikey: config.supabaseKey,\n Authorization: `Bearer ${config.supabaseKey}`,\n \"Content-Type\": \"application/json\",\n Prefer: \"return=representation\",\n };\n\n return async function supabaseRequest(\n path: string,\n options: RequestInit = {},\n ): Promise<unknown> {\n const url = `${restUrl}${path}`;\n const res = await fetch(url, {\n ...options,\n signal: options.signal ?? AbortSignal.timeout(10_000),\n headers: { ...headers, ...(options.headers as Record<string, string>) },\n });\n if (!res.ok) {\n throw new Error(`Supabase request failed (${res.status})`);\n }\n const text = await res.text();\n return text ? JSON.parse(text) : null;\n };\n}\n\nexport function createAgentBridgeServer(\n config: AgentBridgeServerConfig,\n): Server {\n const supabaseRequest = config.supabaseUrl && config.supabaseKey ? buildSupabaseRequest(config as AgentBridgeServerConfig & { supabaseUrl: string; supabaseKey: string }) : undefined;\n const principal: BridgePrincipal | undefined = config.agent ? { workspace: config.workspace ?? \"default\", agent: config.agent, instance: config.instance } : undefined;\n const clientConfig: ClientConfig | undefined = principal ? {\n provider: config.provider ?? (config.gatewayToken ? \"gateway\" : config.supabaseUrl ? \"legacy-supabase\" : \"local\"), principal,\n url: config.gatewayUrl ?? config.supabaseUrl, credential: config.gatewayToken ?? config.supabaseKey,\n databasePath: config.databasePath ?? \":memory:\", edgeDatabasePath: config.edgeDatabasePath ?? config.databasePath ?? \":memory:\", cursorPath: config.cursorPath ?? \"\", configPath: \"\",\n } : undefined;\n const store = clientConfig ? createStore(clientConfig) : undefined;\n const service = store ? new BridgeService(store) : undefined;\n const deliveryToolsAvailable = Boolean(\n service && clientConfig?.provider !== \"legacy-supabase\",\n );\n const server = new Server(\n { name: \"agent-bridge\", version: packageVersion },\n { capabilities: { tools: {} } },\n );\n\n server.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: [\n {\n name: \"post_context\",\n description:\n \"Post a shared context entry visible to all agents. Categories: operational, config-change, goal-update, flag, bridge-meta (for suggesting improvements to the Agent Bridge itself).\",\n inputSchema: {\n type: \"object\" as const,\n properties: {\n source: {\n type: \"string\",\n description:\n \"Optional posting agent. Defaults to AGENT_BRIDGE_AGENT when configured; an explicit value must match it.\",\n },\n category: {\n type: \"string\",\n description:\n \"Entry type: operational | config-change | goal-update | flag | bridge-meta\",\n },\n content: {\n type: \"string\",\n description: \"The context message\",\n },\n priority: {\n type: \"string\",\n description: \"info (default) | high | urgent\",\n },\n project: {\n type: \"string\",\n description:\n \"Scope to a project (e.g. project-a, project-b). Omit for cross-project.\",\n },\n metadata: {\n type: \"object\",\n description: \"Arbitrary structured data\",\n },\n message_id: {\n type: \"string\",\n description:\n \"Stable message id. Generated by the bridge when omitted.\",\n },\n target_agents: {\n type: \"array\",\n items: { type: \"string\" },\n description:\n \"Optional target agent names. Empty or omitted means broadcast.\",\n },\n thread_id: {\n type: \"string\",\n description: \"Optional conversation/thread id.\",\n },\n reply_to_id: {\n type: \"string\",\n description: \"Optional parent message id for reply threading.\",\n },\n kind: {\n type: \"string\",\n description:\n \"Message kind: operational | config-change | goal-update | flag | bridge-meta | handoff | request | result\",\n },\n payload_mime: {\n type: \"string\",\n description:\n \"Payload MIME type. Defaults to text/plain for the content column.\",\n },\n payload: {\n anyOf: [\n { type: \"object\" },\n { type: \"array\" },\n { type: \"string\" },\n { type: \"number\" },\n { type: \"boolean\" },\n { type: \"null\" },\n ],\n description:\n \"Optional structured payload stored in metadata.message_envelope.\",\n },\n payload_ref: {\n type: \"string\",\n description: \"Optional external blob pointer for large payloads.\",\n },\n payload_ciphertext: {\n type: \"string\",\n description:\n \"Optional inline encrypted payload for small encrypted messages.\",\n },\n informed_by: {\n type: \"array\",\n items: { type: \"string\" },\n description:\n \"Optional atrib record hashes (sha256:<64-hex>) this message depends on.\",\n },\n expires_at: {\n type: \"string\",\n description: \"Optional ISO timestamp retention boundary.\",\n },\n atrib_receipt_id: {\n type: \"string\",\n description:\n \"Optional. Signed atrib record receipt_id for the wrapper that signed this post_context call. Set automatically by an atrib-signing wrapper; consumers reading the row use this as the informed_by anchor for cross-process causal edges.\",\n },\n },\n required: [\"category\", \"content\"],\n },\n },\n {\n name: \"get_context\",\n description:\n \"Read shared context entries, newest first. Filter by source, category, project, or unacknowledged entries.\",\n inputSchema: {\n type: \"object\" as const,\n properties: {\n since: {\n type: \"string\",\n description: \"ISO timestamp. Only entries after this time\",\n },\n source: {\n type: \"string\",\n description: \"Filter by posting agent\",\n },\n category: {\n type: \"string\",\n description: \"Filter by category\",\n },\n project: {\n type: \"string\",\n description: \"Filter by project scope\",\n },\n unacked_by: {\n type: \"string\",\n description:\n \"Only entries NOT yet acknowledged by this agent name. Defaults to AGENT_BRIDGE_AGENT when configured.\",\n },\n limit: {\n type: \"number\",\n description: \"Max entries to return (default 20)\",\n minimum: 1,\n maximum: 200,\n },\n target_agent: {\n type: \"string\",\n description:\n \"Return broadcast entries plus entries targeted to this agent.\",\n },\n thread_id: {\n type: \"string\",\n description: \"Filter by metadata.message_envelope.thread_id.\",\n },\n kind: {\n type: \"string\",\n description: \"Filter by metadata.message_envelope.kind.\",\n },\n },\n },\n },\n {\n name: \"ack_context\",\n description:\n \"Acknowledge context entries so they won't appear in unacked queries for this agent.\",\n inputSchema: {\n type: \"object\" as const,\n properties: {\n ids: {\n type: \"array\",\n items: { anyOf: [{ type: \"number\" }, { type: \"string\" }] },\n description: \"Legacy numeric entry IDs or v2 UUID message IDs to acknowledge\",\n },\n agent: {\n type: \"string\",\n description:\n \"Optional acknowledging agent. Defaults to AGENT_BRIDGE_AGENT when configured; an explicit value must match it.\",\n },\n },\n required: [\"ids\"],\n },\n },\n ...(service ? [{\n name: \"send\",\n description: \"Create an immutable Agent Bridge v2 message.\",\n inputSchema: {\n type: \"object\" as const,\n properties: {\n source: { type: \"string\", description: \"Optional identity assertion; must match AGENT_BRIDGE_AGENT.\" },\n type: { type: \"string\" }, content: { type: \"string\" }, contentType: { type: \"string\" },\n data: {}, targets: { type: \"array\", items: { type: \"string\" } },\n threadId: { type: \"string\" }, replyToId: { type: \"string\" }, correlationId: { type: \"string\" }, causationId: { type: \"string\" },\n priority: { type: \"string\", enum: [\"info\", \"high\", \"urgent\"] }, expiresAt: { type: \"string\" },\n idempotencyKey: { type: \"string\" }, atribReceiptId: { type: \"string\" },\n informedBy: { type: \"array\", items: { type: \"string\" } }, metadata: {},\n },\n required: [\"type\", \"content\"],\n additionalProperties: false,\n },\n outputSchema: { type: \"object\" as const, properties: { created: { type: \"boolean\" }, message: { type: \"object\", additionalProperties: true } }, required: [\"created\", \"message\"] },\n },\n {\n name: \"history\",\n description: \"Read visible Agent Bridge v2 messages after an opaque cursor.\",\n inputSchema: { type: \"object\" as const, properties: {\n cursor: { type: \"string\" }, limit: { type: \"number\", minimum: 1, maximum: 200 }, types: { type: \"array\", items: { type: \"string\" } },\n includeExpired: { type: \"boolean\" }, source: { type: \"string\" }, since: { type: \"string\" }, unacknowledgedBy: { type: \"string\" },\n threadId: { type: \"string\" }, latest: { type: \"boolean\" },\n }, additionalProperties: false },\n outputSchema: { type: \"object\" as const, properties: { messages: { type: \"array\", items: { type: \"object\", additionalProperties: true } }, cursor: { type: \"string\" } }, required: [\"messages\"] },\n }] : []),\n ...(deliveryToolsAvailable ? [{\n name: \"claim\",\n description: \"Atomically claim the next targeted delivery.\",\n inputSchema: { type: \"object\" as const, properties: { leaseMs: { type: \"number\" }, maxAttempts: { type: \"number\" } }, additionalProperties: false },\n outputSchema: { type: \"object\" as const, additionalProperties: true },\n },\n ...[\"extend\", \"acknowledge\", \"negative_acknowledge\"].map((name) => ({\n name,\n description: `Agent Bridge v2 ${name.replace(/_/g, \" \")} delivery operation.`,\n inputSchema: {\n type: \"object\" as const,\n properties: {\n deliveryId: { type: \"string\" }, leaseToken: { type: \"string\" },\n ...(name === \"extend\" ? { leaseMs: { type: \"number\" } } : {}),\n ...(name === \"negative_acknowledge\" ? { error: { type: \"string\" }, dead: { type: \"boolean\" }, retryPolicy: { type: \"object\", additionalProperties: true } } : {}),\n },\n required: [\"deliveryId\", \"leaseToken\"],\n additionalProperties: false,\n },\n outputSchema: { type: \"object\" as const, additionalProperties: true },\n })),\n {\n name: \"heartbeat\",\n description: \"Publish a leased runtime presence record and capabilities.\",\n inputSchema: { type: \"object\" as const, properties: {\n leaseMs: { type: \"number\", minimum: 1000, maximum: 900000 }, runtimeType: { type: \"string\" },\n capabilities: { type: \"array\", items: { type: \"string\" } },\n }, additionalProperties: false },\n outputSchema: { type: \"object\" as const, additionalProperties: true },\n },\n {\n name: \"presence\",\n description: \"List active agent runtime instances in this workspace.\",\n inputSchema: { type: \"object\" as const, properties: {}, additionalProperties: false },\n outputSchema: { type: \"object\" as const, properties: { agents: { type: \"array\", items: { type: \"object\", additionalProperties: true } } }, required: [\"agents\"] },\n }] : []),\n ],\n }));\n\n server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n try {\n switch (name) {\n case \"post_context\": {\n let source: string | undefined;\n try {\n source = resolvePostSource(args?.source, config.agent);\n if (!source) {\n throw new Error(\n \"source is required when AGENT_BRIDGE_AGENT is not configured\",\n );\n }\n } catch (e) {\n throw new McpError(\n ErrorCode.InvalidParams,\n e instanceof Error ? e.message : \"source identity mismatch\",\n );\n }\n const postArgs = { ...(args ?? {}), source };\n const receiptId = normalizeReceiptId(args?.atrib_receipt_id);\n const envelope = buildMessageEnvelope(postArgs, receiptId);\n const body: Record<string, unknown> = {\n source,\n category: args?.category,\n content: args?.content,\n priority: args?.priority || \"info\",\n project: args?.project || null,\n metadata: mergeEnvelopeMetadata(args?.metadata, envelope),\n };\n // Optional cross-tool causal anchor; written when an atrib-signing\n // wrapper signs this call before forwarding. Format-validated so\n // unexpected producers cannot pollute the column with garbage.\n if (receiptId) {\n body.atrib_receipt_id = receiptId;\n }\n if (!supabaseRequest) {\n if (!service || !principal) throw new McpError(ErrorCode.InternalError, \"bridge provider is not configured\");\n if (args?.project && String(args.project) !== principal.workspace) {\n throw new McpError(ErrorCode.InvalidParams, \"project must match AGENT_BRIDGE_WORKSPACE\");\n }\n const result = await service.publish(principal, {\n id: String(envelope.message_id),\n type: String(args?.kind ?? args?.category),\n content: String(args?.content ?? \"\"),\n contentType: String(args?.payload_mime ?? \"text/plain\"),\n data: args?.payload as MessageDraft[\"data\"],\n targets: Array.isArray(args?.target_agents) ? args.target_agents.map(String) : [],\n threadId: args?.thread_id as string | undefined,\n replyToId: args?.reply_to_id as string | undefined,\n priority: (args?.priority ?? \"info\") as MessageDraft[\"priority\"],\n expiresAt: args?.expires_at as string | undefined,\n atribReceiptId: receiptId,\n informedBy: Array.isArray(args?.informed_by) ? args.informed_by.map(String) : [],\n metadata: body.metadata as MessageDraft[\"metadata\"],\n });\n return { content: [{ type: \"text\", text: JSON.stringify(result) }], structuredContent: result as unknown as Record<string, unknown> };\n }\n if (!supabaseRequest) throw new McpError(ErrorCode.InternalError, \"bridge provider is not configured\");\n const data = await supabaseRequest(\"/shared_context\", {\n method: \"POST\",\n body: JSON.stringify(body),\n });\n return {\n content: [{ type: \"text\", text: JSON.stringify(data, null, 2) }],\n };\n }\n\n case \"get_context\": {\n const rawLimit = args?.limit;\n if (\n rawLimit !== undefined &&\n (typeof rawLimit !== \"number\" || !Number.isSafeInteger(rawLimit) || rawLimit < 1 || rawLimit > 200)\n ) {\n throw new McpError(ErrorCode.InvalidParams, \"limit must be between 1 and 200\");\n }\n const requestedLimit = rawLimit ?? 20;\n if (service && principal) {\n if (!service || !principal) throw new McpError(ErrorCode.InternalError, \"bridge provider is not configured\");\n if (args?.project && String(args.project) !== principal.workspace) {\n return { content: [{ type: \"text\", text: \"[]\" }], structuredContent: { entries: [] } };\n }\n if (args?.target_agent && String(args.target_agent) !== principal.agent) {\n return { content: [{ type: \"text\", text: \"[]\" }], structuredContent: { entries: [] } };\n }\n const result = await service.history(principal, {\n limit: requestedLimit,\n types: args?.kind ? [String(args.kind)] : args?.category ? [String(args.category)] : undefined,\n source: args?.source ? String(args.source) : undefined,\n since: args?.since ? String(args.since) : undefined,\n unacknowledgedBy: args?.unacked_by ? String(args.unacked_by) : config.agent,\n threadId: args?.thread_id ? String(args.thread_id) : undefined,\n latest: true,\n });\n const entries = result.messages\n .slice(0, requestedLimit)\n .map((message) => ({\n id: clientConfig?.provider === \"legacy-supabase\" && /^\\d+$/.test(message.sequence)\n ? Number.isSafeInteger(Number(message.sequence)) ? Number(message.sequence) : message.sequence\n : message.id,\n source: message.source,\n category: message.type,\n content: message.content,\n priority: message.priority,\n project: message.workspace,\n metadata: legacyContextMetadata(message),\n atrib_receipt_id: message.atribReceiptId ?? null,\n created_at: message.createdAt,\n }));\n const cachedResult = result as typeof result & {\n source?: \"remote\" | \"cache\";\n stale?: boolean;\n lastSyncedAt?: string;\n };\n const cacheMetadata = cachedResult.source\n ? {\n source: cachedResult.source,\n stale: Boolean(cachedResult.stale),\n lastSyncedAt: cachedResult.lastSyncedAt ?? null,\n }\n : {};\n return {\n content: [{ type: \"text\", text: JSON.stringify(entries, null, 2) }],\n structuredContent: { entries, ...cacheMetadata },\n };\n }\n const hasEnvelopeFilter = Boolean(\n args?.target_agent || args?.thread_id || args?.kind,\n );\n const fetchLimit = hasEnvelopeFilter\n ? Math.min(Math.max(requestedLimit * 5, 50), 200)\n : requestedLimit;\n const params: string[] = [\n \"order=created_at.desc\",\n `limit=${fetchLimit}`,\n ];\n if (args?.since)\n params.push(\n `created_at=gte.${encodeURIComponent(String(args.since))}`,\n );\n if (args?.source)\n params.push(`source=eq.${encodeURIComponent(String(args.source))}`);\n if (args?.category)\n params.push(\n `category=eq.${encodeURIComponent(String(args.category))}`,\n );\n if (args?.project)\n params.push(`project=eq.${encodeURIComponent(String(args.project))}`);\n const unackedBy = args?.unacked_by ?? config.agent;\n if (unackedBy)\n params.push(\n `acked_by=not.cs.%7B${encodeURIComponent(String(unackedBy))}%7D`,\n );\n\n if (!supabaseRequest) throw new McpError(ErrorCode.InternalError, \"bridge provider is not configured\");\n const data = await supabaseRequest(\n `/shared_context?${params.join(\"&\")}`,\n );\n const filtered = filterContextRows(data, args, requestedLimit);\n return {\n content: [{ type: \"text\", text: JSON.stringify(filtered, null, 2) }],\n };\n }\n\n case \"ack_context\": {\n const ids = args?.ids as unknown[];\n let agent: string | undefined;\n try {\n agent = resolveAgentIdentity(args?.agent, config.agent);\n } catch (e) {\n throw new McpError(\n ErrorCode.InvalidParams,\n e instanceof Error ? e.message : \"agent identity mismatch\",\n );\n }\n if (!ids?.length || !agent) {\n throw new McpError(\n ErrorCode.InvalidParams,\n \"ids are required; agent is required when AGENT_BRIDGE_AGENT is not configured\",\n );\n }\n if (service && principal) {\n if (!service || !principal) throw new McpError(ErrorCode.InternalError, \"bridge provider is not configured\");\n const rawIds = ids.map(String);\n const acknowledged = clientConfig?.provider === \"legacy-supabase\" &&\n store?.recordLegacyReceipt && rawIds.every((id) => /^\\d+$/.test(id))\n ? await store.recordLegacyReceipt(rawIds, principal.agent)\n : await service.acknowledge(\n principal,\n ids.map((id) => legacyNumericMessageId(id as string | number)),\n );\n return { content: [{ type: \"text\", text: JSON.stringify({ acknowledged, agent }) }], structuredContent: { acknowledged, agent } };\n }\n if (!supabaseRequest) throw new McpError(ErrorCode.InternalError, \"bridge provider is not configured\");\n const data = await supabaseRequest(\"/rpc/ack_context\", {\n method: \"POST\",\n body: JSON.stringify({ entry_ids: ids.map(String), agent_name: agent }),\n });\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify({ acknowledged: data, agent }),\n },\n ],\n };\n }\n\n case \"send\": {\n if (!service || !principal) throw new McpError(ErrorCode.InvalidParams, \"AGENT_BRIDGE_AGENT is required\");\n try { resolvePostSource(args?.source, principal.agent); } catch (error) { throw new McpError(ErrorCode.InvalidParams, error instanceof Error ? error.message : \"source identity mismatch\"); }\n const result = await service.publish(principal, args as unknown as MessageDraft);\n return { content: [{ type: \"text\", text: JSON.stringify(result) }], structuredContent: result as unknown as Record<string, unknown> };\n }\n case \"history\": {\n if (!service || !principal) throw new McpError(ErrorCode.InvalidParams, \"AGENT_BRIDGE_AGENT is required\");\n const result = await service.history(principal, args ?? {});\n return { content: [{ type: \"text\", text: JSON.stringify(result) }], structuredContent: result as unknown as Record<string, unknown> };\n }\n case \"claim\": {\n if (!service || !principal) throw new McpError(ErrorCode.InvalidParams, \"AGENT_BRIDGE_AGENT is required\");\n const result = await service.claim(principal, { leaseMs: args?.leaseMs as number | undefined, maxAttempts: args?.maxAttempts as number | undefined });\n return { content: [{ type: \"text\", text: JSON.stringify(result) }], structuredContent: (result ?? { delivery: null }) as unknown as Record<string, unknown> };\n }\n case \"extend\": case \"acknowledge\": case \"negative_acknowledge\": {\n if (!service || !principal) throw new McpError(ErrorCode.InvalidParams, \"AGENT_BRIDGE_AGENT is required\");\n const id = String(args?.deliveryId ?? \"\"), token = String(args?.leaseToken ?? \"\");\n const result = name === \"extend\" ? await service.extend(principal, id, token, args?.leaseMs as number | undefined)\n : name === \"acknowledge\" ? await service.ack(principal, id, token)\n : await service.nack(\n principal,\n id,\n token,\n (args?.error ?? \"negative acknowledgment\") as string,\n (args?.dead ?? false) as boolean,\n args?.retryPolicy as Partial<RetryPolicy> | undefined,\n );\n return { content: [{ type: \"text\", text: JSON.stringify(result) }], structuredContent: (result ?? { delivery: null }) as unknown as Record<string, unknown> };\n }\n case \"heartbeat\": {\n if (!service || !principal) throw new McpError(ErrorCode.InvalidParams, \"AGENT_BRIDGE_AGENT is required\");\n const result = await service.heartbeat(principal, {\n leaseMs: args?.leaseMs as number | undefined,\n runtimeType: args?.runtimeType as string | undefined,\n capabilities: args?.capabilities as string[] | undefined,\n });\n return { content: [{ type: \"text\", text: JSON.stringify(result) }], structuredContent: result as unknown as Record<string, unknown> };\n }\n case \"presence\": {\n if (!service || !principal) throw new McpError(ErrorCode.InvalidParams, \"AGENT_BRIDGE_AGENT is required\");\n const result = { agents: await service.presence(principal) };\n return { content: [{ type: \"text\", text: JSON.stringify(result) }], structuredContent: result };\n }\n\n default:\n throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);\n }\n } catch (error) {\n if (error instanceof McpError) throw error;\n if (error instanceof BridgeValidationError) {\n throw new McpError(ErrorCode.InvalidParams, error.message);\n }\n throw error;\n }\n });\n\n server.onclose = () => {\n void store?.close?.();\n };\n\n return server;\n}\n\nexport async function startServer(\n config: AgentBridgeServerConfig = configFromEnv(),\n) {\n const server = createAgentBridgeServer(config);\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n","import { randomUUID } from \"node:crypto\";\n\nexport const MESSAGE_ENVELOPE_SCHEMA = \"agent-bridge.message-envelope.v1\";\n\nconst RECORD_HASH_RE = /^sha256:[a-f0-9]{64}$/i;\n\ntype JsonRecord = Record<string, unknown>;\n\nfunction isRecord(value: unknown): value is JsonRecord {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction normalizeString(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n return trimmed ? trimmed : undefined;\n}\n\nfunction normalizeStringList(value: unknown): string[] | undefined {\n const raw = Array.isArray(value)\n ? value\n : typeof value === \"string\"\n ? value.split(\",\")\n : [];\n const seen = new Set<string>();\n for (const item of raw) {\n const normalized = normalizeString(item);\n if (normalized) seen.add(normalized);\n }\n return seen.size ? [...seen] : undefined;\n}\n\nfunction normalizeRecordHashes(value: unknown): string[] | undefined {\n const raw = Array.isArray(value)\n ? value\n : typeof value === \"string\"\n ? value.split(\",\")\n : [];\n const seen = new Set<string>();\n for (const item of raw) {\n const normalized = normalizeString(item);\n if (normalized && RECORD_HASH_RE.test(normalized)) {\n seen.add(normalized.toLowerCase());\n }\n }\n return seen.size ? [...seen] : undefined;\n}\n\nfunction normalizeIsoTimestamp(value: unknown): string | undefined {\n const text = normalizeString(value);\n if (!text) return undefined;\n const parsed = Date.parse(text);\n if (Number.isNaN(parsed)) return undefined;\n return new Date(parsed).toISOString();\n}\n\nexport function normalizeMetadata(value: unknown): JsonRecord {\n return isRecord(value) ? { ...value } : {};\n}\n\nexport function buildMessageEnvelope(\n args: JsonRecord | undefined,\n receiptId?: string\n): JsonRecord {\n const source = normalizeString(args?.source) ?? \"unknown\";\n const category = normalizeString(args?.category);\n const kind = normalizeString(args?.kind) ?? category ?? \"operational\";\n const messageId = normalizeString(args?.message_id) ?? randomUUID();\n\n const envelope: JsonRecord = {\n schema: MESSAGE_ENVELOPE_SCHEMA,\n message_id: messageId,\n source_agent: source,\n kind,\n priority: normalizeString(args?.priority) ?? \"info\",\n payload_mime: normalizeString(args?.payload_mime) ?? \"text/plain\",\n };\n\n const targetAgents = normalizeStringList(args?.target_agents);\n if (targetAgents) envelope.target_agents = targetAgents;\n\n const project = normalizeString(args?.project);\n if (project) envelope.project = project;\n\n const threadId = normalizeString(args?.thread_id);\n if (threadId) envelope.thread_id = threadId;\n\n const replyToId = normalizeString(args?.reply_to_id);\n if (replyToId) envelope.reply_to_id = replyToId;\n\n if (Object.prototype.hasOwnProperty.call(args ?? {}, \"payload\")) {\n envelope.payload = args?.payload;\n }\n\n const payloadRef = normalizeString(args?.payload_ref);\n if (payloadRef) envelope.payload_ref = payloadRef;\n\n const payloadCiphertext = normalizeString(args?.payload_ciphertext);\n if (payloadCiphertext) envelope.payload_ciphertext = payloadCiphertext;\n\n if (receiptId) envelope.atrib_receipt_id = receiptId;\n\n const informedBy = normalizeRecordHashes(args?.informed_by);\n if (informedBy) envelope.informed_by = informedBy;\n\n const expiresAt = normalizeIsoTimestamp(args?.expires_at);\n if (expiresAt) envelope.expires_at = expiresAt;\n\n return envelope;\n}\n\nexport function mergeEnvelopeMetadata(\n metadataInput: unknown,\n envelope: JsonRecord\n): JsonRecord {\n return {\n ...normalizeMetadata(metadataInput),\n message_envelope: envelope,\n };\n}\n\nfunction getEnvelope(row: unknown): JsonRecord | undefined {\n if (!isRecord(row)) return undefined;\n const metadata = row.metadata;\n if (!isRecord(metadata)) return undefined;\n const envelope = metadata.message_envelope;\n return isRecord(envelope) ? envelope : undefined;\n}\n\nexport function rowMatchesMessageFilters(\n row: unknown,\n filters: JsonRecord | undefined\n): boolean {\n const targetAgent = normalizeString(filters?.target_agent);\n const threadId = normalizeString(filters?.thread_id);\n const kind = normalizeString(filters?.kind);\n\n if (!targetAgent && !threadId && !kind) return true;\n\n const envelope = getEnvelope(row);\n if (!envelope) {\n return !threadId && !kind;\n }\n\n if (targetAgent) {\n const targets = normalizeStringList(envelope.target_agents);\n if (targets && !targets.includes(targetAgent)) return false;\n }\n\n if (threadId && normalizeString(envelope.thread_id) !== threadId) {\n return false;\n }\n\n if (kind && normalizeString(envelope.kind) !== kind) {\n return false;\n }\n\n return true;\n}\n\nexport function filterContextRows(\n rows: unknown,\n filters: JsonRecord | undefined,\n limit: number\n): unknown {\n if (!Array.isArray(rows)) return rows;\n return rows.filter((row) => rowMatchesMessageFilters(row, filters)).slice(0, limit);\n}\n","function normalizeSource(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n return trimmed ? trimmed : undefined;\n}\n\nexport function resolveAgentIdentity(\n requestedAgent: unknown,\n configuredAgent: unknown,\n field = \"agent\",\n): string | undefined {\n const requested = normalizeSource(requestedAgent);\n const configured = normalizeSource(configuredAgent);\n\n if (requested && configured && requested !== configured) {\n throw new Error(\n `${field} must match AGENT_BRIDGE_AGENT (${configured}); got ${requested}`,\n );\n }\n\n return requested ?? configured;\n}\n\nexport function resolvePostSource(\n requestedSource: unknown,\n configuredAgent: unknown,\n): string | undefined {\n return resolveAgentIdentity(requestedSource, configuredAgent, \"source\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,SAAS,YAAY;;;ACVrB,SAAS,kBAAkB;AAEpB,IAAM,0BAA0B;AAEvC,IAAM,iBAAiB;AAIvB,SAAS,SAAS,OAAqC;AACrD,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,gBAAgB,OAAoC;AAC3D,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,UAAU,MAAM,KAAK;AAC3B,SAAO,UAAU,UAAU;AAC7B;AAEA,SAAS,oBAAoB,OAAsC;AACjE,QAAM,MAAM,MAAM,QAAQ,KAAK,IAC3B,QACA,OAAO,UAAU,WACf,MAAM,MAAM,GAAG,IACf,CAAC;AACP,QAAM,OAAO,oBAAI,IAAY;AAC7B,aAAW,QAAQ,KAAK;AACtB,UAAM,aAAa,gBAAgB,IAAI;AACvC,QAAI,WAAY,MAAK,IAAI,UAAU;AAAA,EACrC;AACA,SAAO,KAAK,OAAO,CAAC,GAAG,IAAI,IAAI;AACjC;AAEA,SAAS,sBAAsB,OAAsC;AACnE,QAAM,MAAM,MAAM,QAAQ,KAAK,IAC3B,QACA,OAAO,UAAU,WACf,MAAM,MAAM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,UAAU,eAAe,gCAAgC;AACxG,gBAAM,SAAS,EAAE,QAAQ,MAAM,QAAQ,SAAS,SAAS,EAAE;AAC3D,iBAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,MAAM,EAAE,CAAC,GAAG,mBAAmB,OAAO;AAAA,QAChG;AAAA,QAEA;AACE,gBAAM,IAAI,SAAS,UAAU,gBAAgB,iBAAiB,IAAI,EAAE;AAAA,MACtE;AAAA,IACF,SAAS,OAAO;AACd,UAAI,iBAAiB,SAAU,OAAM;AACrC,UAAI,iBAAiB,uBAAuB;AAC1C,cAAM,IAAI,SAAS,UAAU,eAAe,MAAM,OAAO;AAAA,MAC3D;AACA,YAAM;AAAA,IACR;AAAA,EACF,CAAC;AAED,SAAO,UAAU,MAAM;AACrB,SAAK,OAAO,QAAQ;AAAA,EACtB;AAEA,SAAO;AACT;AAEA,eAAsB,YACpB,SAAkC,cAAc,GAChD;AACA,QAAM,SAAS,wBAAwB,MAAM;AAC7C,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAChC;","names":[]}
|
package/dist/chunk-6MAZ6YLZ.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/migrations.ts
|
|
4
|
-
import { createHash } from "crypto";
|
|
5
|
-
import { readdir, readFile } from "fs/promises";
|
|
6
|
-
import { join } from "path";
|
|
7
|
-
var MIGRATION_NAME = /^(\d+)_([a-z0-9_]+)\.sql$/;
|
|
8
|
-
var REQUIRED_COLUMNS = /* @__PURE__ */ new Map([
|
|
9
|
-
["workspaces.id", "text"],
|
|
10
|
-
["agents.id", "uuid"],
|
|
11
|
-
["agents.workspace_id", "text"],
|
|
12
|
-
["agents.principal", "text"],
|
|
13
|
-
["credentials.id", "uuid"],
|
|
14
|
-
["credentials.workspace_id", "text"],
|
|
15
|
-
["credentials.agent_id", "uuid"],
|
|
16
|
-
["credentials.token_hash", "bpchar"],
|
|
17
|
-
["messages.sequence", "int8"],
|
|
18
|
-
["messages.id", "uuid"],
|
|
19
|
-
["messages.workspace", "text"],
|
|
20
|
-
["messages.source", "text"],
|
|
21
|
-
["messages.targets", "jsonb"],
|
|
22
|
-
["receipts.workspace", "text"],
|
|
23
|
-
["receipts.message_id", "uuid"],
|
|
24
|
-
["receipts.principal", "text"],
|
|
25
|
-
["deliveries.id", "uuid"],
|
|
26
|
-
["deliveries.message_id", "uuid"],
|
|
27
|
-
["deliveries.workspace", "text"],
|
|
28
|
-
["deliveries.recipient", "text"],
|
|
29
|
-
["deliveries.state", "text"],
|
|
30
|
-
["deliveries.lease_token", "uuid"],
|
|
31
|
-
["delivery_events.delivery_id", "uuid"],
|
|
32
|
-
["delivery_events.to_state", "text"],
|
|
33
|
-
["agent_instances.workspace", "text"],
|
|
34
|
-
["agent_instances.instance", "text"],
|
|
35
|
-
["agent_instances.capabilities", "jsonb"]
|
|
36
|
-
]);
|
|
37
|
-
var REQUIRED_MIGRATIONS = [
|
|
38
|
-
{ version: 1, name: "schema_state" },
|
|
39
|
-
{ version: 2, name: "workspaces_agents_credentials" },
|
|
40
|
-
{ version: 3, name: "messages_receipts_deliveries" },
|
|
41
|
-
{ version: 4, name: "message_query_indexes" },
|
|
42
|
-
{ version: 5, name: "delivery_events_presence" },
|
|
43
|
-
{ version: 6, name: "legacy_shared_context_import" },
|
|
44
|
-
{ version: 7, name: "runtime_role" }
|
|
45
|
-
];
|
|
46
|
-
function checksum(source) {
|
|
47
|
-
return createHash("sha256").update(source, "utf8").digest("hex");
|
|
48
|
-
}
|
|
49
|
-
async function recordedMigrations(db) {
|
|
50
|
-
const exists = await db.query(
|
|
51
|
-
"SELECT to_regclass('agent_bridge.schema_migrations')::text AS table_name"
|
|
52
|
-
);
|
|
53
|
-
if (!exists.rows[0]?.table_name) return [];
|
|
54
|
-
const result = await db.query(
|
|
55
|
-
"SELECT version, name, checksum FROM agent_bridge.schema_migrations ORDER BY version"
|
|
56
|
-
);
|
|
57
|
-
return result.rows.map((row) => ({
|
|
58
|
-
version: Number(row.version),
|
|
59
|
-
name: row.name,
|
|
60
|
-
checksum: row.checksum
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
async function loadMigrationPlan(directory) {
|
|
64
|
-
const files = (await readdir(directory)).filter((file) => MIGRATION_NAME.test(file)).sort((left, right) => left.localeCompare(right));
|
|
65
|
-
const expected = await Promise.all(files.map(async (file) => {
|
|
66
|
-
const match = file.match(MIGRATION_NAME);
|
|
67
|
-
const source = await readFile(join(directory, file), "utf8");
|
|
68
|
-
return { version: Number(match[1]), name: match[2], source, checksum: checksum(source) };
|
|
69
|
-
}));
|
|
70
|
-
if (expected.length !== REQUIRED_MIGRATIONS.length || !expected.every(
|
|
71
|
-
(migration, index) => migration.version === REQUIRED_MIGRATIONS[index]?.version && migration.name === REQUIRED_MIGRATIONS[index]?.name
|
|
72
|
-
)) {
|
|
73
|
-
throw new Error("migration directory does not match the required migration sequence");
|
|
74
|
-
}
|
|
75
|
-
return expected;
|
|
76
|
-
}
|
|
77
|
-
async function migrationsReady(db, expected) {
|
|
78
|
-
const applied = await recordedMigrations(db);
|
|
79
|
-
return expected.every(
|
|
80
|
-
(required, index) => applied[index]?.version === required.version && applied[index]?.name === required.name && applied[index]?.checksum === required.checksum
|
|
81
|
-
) && applied.length === expected.length;
|
|
82
|
-
}
|
|
83
|
-
async function runtimeSchemaReady(db) {
|
|
84
|
-
const columns = await db.query(
|
|
85
|
-
`SELECT table_name, column_name, udt_name
|
|
86
|
-
FROM information_schema.columns
|
|
87
|
-
WHERE table_schema='agent_bridge'`
|
|
88
|
-
);
|
|
89
|
-
const actual = new Map(
|
|
90
|
-
columns.rows.map((row2) => [`${row2.table_name}.${row2.column_name}`, row2.udt_name])
|
|
91
|
-
);
|
|
92
|
-
if ([...REQUIRED_COLUMNS].some(([name, type]) => actual.get(name) !== type)) return false;
|
|
93
|
-
const objects = await db.query(
|
|
94
|
-
`SELECT
|
|
95
|
-
EXISTS (
|
|
96
|
-
SELECT 1 FROM pg_trigger
|
|
97
|
-
WHERE tgrelid='agent_bridge.messages'::regclass
|
|
98
|
-
AND tgname='messages_immutable' AND NOT tgisinternal
|
|
99
|
-
) AS immutable,
|
|
100
|
-
EXISTS (
|
|
101
|
-
SELECT 1 FROM pg_trigger
|
|
102
|
-
WHERE tgrelid='agent_bridge.deliveries'::regclass
|
|
103
|
-
AND tgname='deliveries_record_event' AND NOT tgisinternal
|
|
104
|
-
) AS "deliveryAudit",
|
|
105
|
-
to_regclass('agent_bridge.messages_idempotency') IS NOT NULL AS idempotency,
|
|
106
|
-
to_regclass('agent_bridge.deliveries_claim') IS NOT NULL AS claim,
|
|
107
|
-
to_regclass('agent_bridge.messages_source') IS NOT NULL AS source,
|
|
108
|
-
to_regclass('agent_bridge.messages_thread') IS NOT NULL AS thread,
|
|
109
|
-
to_regclass('agent_bridge.messages_created') IS NOT NULL AS created,
|
|
110
|
-
to_regclass('agent_bridge.agent_instances_active') IS NOT NULL AS presence`
|
|
111
|
-
);
|
|
112
|
-
const row = objects.rows[0];
|
|
113
|
-
return Boolean(row?.immutable && row.deliveryAudit && row.idempotency && row.claim && row.source && row.thread && row.created && row.presence);
|
|
114
|
-
}
|
|
115
|
-
async function runMigrations(db, directory) {
|
|
116
|
-
const expected = await loadMigrationPlan(directory);
|
|
117
|
-
for (const migration of expected) {
|
|
118
|
-
const applied = await recordedMigrations(db);
|
|
119
|
-
const recorded = applied.find((entry) => entry.version === migration.version);
|
|
120
|
-
if (recorded) {
|
|
121
|
-
if (recorded.name !== migration.name || recorded.checksum !== migration.checksum) {
|
|
122
|
-
throw new Error(`migration ${migration.version}_${migration.name} conflicts with schema state`);
|
|
123
|
-
}
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
await db.query(
|
|
127
|
-
migration.source.split("__AGENT_BRIDGE_MIGRATION_CHECKSUM__").join(migration.checksum)
|
|
128
|
-
);
|
|
129
|
-
const verified = (await recordedMigrations(db)).find(
|
|
130
|
-
(entry) => entry.version === migration.version
|
|
131
|
-
);
|
|
132
|
-
if (verified?.name !== migration.name || verified.checksum !== migration.checksum) {
|
|
133
|
-
throw new Error(`migration ${migration.version}_${migration.name} was not recorded correctly`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return recordedMigrations(db);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export {
|
|
140
|
-
REQUIRED_MIGRATIONS,
|
|
141
|
-
loadMigrationPlan,
|
|
142
|
-
migrationsReady,
|
|
143
|
-
runtimeSchemaReady,
|
|
144
|
-
runMigrations
|
|
145
|
-
};
|
|
146
|
-
//# sourceMappingURL=chunk-6MAZ6YLZ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/migrations.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { readdir, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport type { PgQueryable } from \"./postgres-bridge-store.js\";\n\nconst MIGRATION_NAME = /^(\\d+)_([a-z0-9_]+)\\.sql$/;\nconst REQUIRED_COLUMNS = new Map([\n [\"workspaces.id\", \"text\"],\n [\"agents.id\", \"uuid\"],\n [\"agents.workspace_id\", \"text\"],\n [\"agents.principal\", \"text\"],\n [\"credentials.id\", \"uuid\"],\n [\"credentials.workspace_id\", \"text\"],\n [\"credentials.agent_id\", \"uuid\"],\n [\"credentials.token_hash\", \"bpchar\"],\n [\"messages.sequence\", \"int8\"],\n [\"messages.id\", \"uuid\"],\n [\"messages.workspace\", \"text\"],\n [\"messages.source\", \"text\"],\n [\"messages.targets\", \"jsonb\"],\n [\"receipts.workspace\", \"text\"],\n [\"receipts.message_id\", \"uuid\"],\n [\"receipts.principal\", \"text\"],\n [\"deliveries.id\", \"uuid\"],\n [\"deliveries.message_id\", \"uuid\"],\n [\"deliveries.workspace\", \"text\"],\n [\"deliveries.recipient\", \"text\"],\n [\"deliveries.state\", \"text\"],\n [\"deliveries.lease_token\", \"uuid\"],\n [\"delivery_events.delivery_id\", \"uuid\"],\n [\"delivery_events.to_state\", \"text\"],\n [\"agent_instances.workspace\", \"text\"],\n [\"agent_instances.instance\", \"text\"],\n [\"agent_instances.capabilities\", \"jsonb\"],\n]);\n\nexport interface AppliedMigration {\n version: number;\n name: string;\n checksum: string;\n}\n\nexport interface MigrationPlanEntry extends AppliedMigration {\n source: string;\n}\n\nexport const REQUIRED_MIGRATIONS = [\n { version: 1, name: \"schema_state\" },\n { version: 2, name: \"workspaces_agents_credentials\" },\n { version: 3, name: \"messages_receipts_deliveries\" },\n { version: 4, name: \"message_query_indexes\" },\n { version: 5, name: \"delivery_events_presence\" },\n { version: 6, name: \"legacy_shared_context_import\" },\n { version: 7, name: \"runtime_role\" },\n] as const;\n\nfunction checksum(source: string): string {\n return createHash(\"sha256\").update(source, \"utf8\").digest(\"hex\");\n}\n\nasync function recordedMigrations(db: PgQueryable): Promise<AppliedMigration[]> {\n const exists = await db.query<{ table_name: string | null }>(\n \"SELECT to_regclass('agent_bridge.schema_migrations')::text AS table_name\",\n );\n if (!exists.rows[0]?.table_name) return [];\n const result = await db.query<{ version: number; name: string; checksum: string }>(\n \"SELECT version, name, checksum FROM agent_bridge.schema_migrations ORDER BY version\",\n );\n return result.rows.map((row) => ({\n version: Number(row.version),\n name: row.name,\n checksum: row.checksum,\n }));\n}\n\nexport async function loadMigrationPlan(directory: string): Promise<MigrationPlanEntry[]> {\n const files = (await readdir(directory))\n .filter((file) => MIGRATION_NAME.test(file))\n .sort((left, right) => left.localeCompare(right));\n const expected = await Promise.all(files.map(async (file) => {\n const match = file.match(MIGRATION_NAME)!;\n const source = await readFile(join(directory, file), \"utf8\");\n return { version: Number(match[1]), name: match[2], source, checksum: checksum(source) };\n }));\n\n if (\n expected.length !== REQUIRED_MIGRATIONS.length ||\n !expected.every(\n (migration, index) =>\n migration.version === REQUIRED_MIGRATIONS[index]?.version &&\n migration.name === REQUIRED_MIGRATIONS[index]?.name,\n )\n ) {\n throw new Error(\"migration directory does not match the required migration sequence\");\n }\n return expected;\n}\n\nexport async function migrationsReady(\n db: PgQueryable,\n expected: ReadonlyArray<Pick<MigrationPlanEntry, \"version\" | \"name\" | \"checksum\">>,\n): Promise<boolean> {\n const applied = await recordedMigrations(db);\n return expected.every(\n (required, index) =>\n applied[index]?.version === required.version &&\n applied[index]?.name === required.name &&\n applied[index]?.checksum === required.checksum,\n ) && applied.length === expected.length;\n}\n\nexport async function runtimeSchemaReady(db: PgQueryable): Promise<boolean> {\n const columns = await db.query<{ table_name: string; column_name: string; udt_name: string }>(\n `SELECT table_name, column_name, udt_name\n FROM information_schema.columns\n WHERE table_schema='agent_bridge'`,\n );\n const actual = new Map(\n columns.rows.map((row) => [`${row.table_name}.${row.column_name}`, row.udt_name]),\n );\n if ([...REQUIRED_COLUMNS].some(([name, type]) => actual.get(name) !== type)) return false;\n\n const objects = await db.query<{ immutable: boolean; deliveryAudit: boolean; idempotency: boolean; claim: boolean; source: boolean; thread: boolean; created: boolean; presence: boolean }>(\n `SELECT\n EXISTS (\n SELECT 1 FROM pg_trigger\n WHERE tgrelid='agent_bridge.messages'::regclass\n AND tgname='messages_immutable' AND NOT tgisinternal\n ) AS immutable,\n EXISTS (\n SELECT 1 FROM pg_trigger\n WHERE tgrelid='agent_bridge.deliveries'::regclass\n AND tgname='deliveries_record_event' AND NOT tgisinternal\n ) AS \"deliveryAudit\",\n to_regclass('agent_bridge.messages_idempotency') IS NOT NULL AS idempotency,\n to_regclass('agent_bridge.deliveries_claim') IS NOT NULL AS claim,\n to_regclass('agent_bridge.messages_source') IS NOT NULL AS source,\n to_regclass('agent_bridge.messages_thread') IS NOT NULL AS thread,\n to_regclass('agent_bridge.messages_created') IS NOT NULL AS created,\n to_regclass('agent_bridge.agent_instances_active') IS NOT NULL AS presence`,\n );\n const row = objects.rows[0];\n return Boolean(row?.immutable && row.deliveryAudit && row.idempotency && row.claim && row.source && row.thread && row.created && row.presence);\n}\n\nexport async function runMigrations(\n db: PgQueryable,\n directory: string,\n): Promise<AppliedMigration[]> {\n const expected = await loadMigrationPlan(directory);\n\n for (const migration of expected) {\n const applied = await recordedMigrations(db);\n const recorded = applied.find((entry) => entry.version === migration.version);\n if (recorded) {\n if (recorded.name !== migration.name || recorded.checksum !== migration.checksum) {\n throw new Error(`migration ${migration.version}_${migration.name} conflicts with schema state`);\n }\n continue;\n }\n await db.query(\n migration.source.split(\"__AGENT_BRIDGE_MIGRATION_CHECKSUM__\").join(migration.checksum),\n );\n const verified = (await recordedMigrations(db)).find(\n (entry) => entry.version === migration.version,\n );\n if (verified?.name !== migration.name || verified.checksum !== migration.checksum) {\n throw new Error(`migration ${migration.version}_${migration.name} was not recorded correctly`);\n }\n }\n\n return recordedMigrations(db);\n}\n"],"mappings":";;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS,gBAAgB;AAClC,SAAS,YAAY;AAGrB,IAAM,iBAAiB;AACvB,IAAM,mBAAmB,oBAAI,IAAI;AAAA,EAC/B,CAAC,iBAAiB,MAAM;AAAA,EACxB,CAAC,aAAa,MAAM;AAAA,EACpB,CAAC,uBAAuB,MAAM;AAAA,EAC9B,CAAC,oBAAoB,MAAM;AAAA,EAC3B,CAAC,kBAAkB,MAAM;AAAA,EACzB,CAAC,4BAA4B,MAAM;AAAA,EACnC,CAAC,wBAAwB,MAAM;AAAA,EAC/B,CAAC,0BAA0B,QAAQ;AAAA,EACnC,CAAC,qBAAqB,MAAM;AAAA,EAC5B,CAAC,eAAe,MAAM;AAAA,EACtB,CAAC,sBAAsB,MAAM;AAAA,EAC7B,CAAC,mBAAmB,MAAM;AAAA,EAC1B,CAAC,oBAAoB,OAAO;AAAA,EAC5B,CAAC,sBAAsB,MAAM;AAAA,EAC7B,CAAC,uBAAuB,MAAM;AAAA,EAC9B,CAAC,sBAAsB,MAAM;AAAA,EAC7B,CAAC,iBAAiB,MAAM;AAAA,EACxB,CAAC,yBAAyB,MAAM;AAAA,EAChC,CAAC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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBF;AACA,QAAM,MAAM,QAAQ,KAAK,CAAC;AAC1B,SAAO,QAAQ,KAAK,aAAa,IAAI,iBAAiB,IAAI,eAAe,IAAI,SAAS,IAAI,UAAU,IAAI,UAAU,IAAI,WAAW,IAAI,QAAQ;AAC/I;AAEA,eAAsB,cACpB,IACA,WAC6B;AAC7B,QAAM,WAAW,MAAM,kBAAkB,SAAS;AAElD,aAAW,aAAa,UAAU;AAChC,UAAM,UAAU,MAAM,mBAAmB,EAAE;AAC3C,UAAM,WAAW,QAAQ,KAAK,CAAC,UAAU,MAAM,YAAY,UAAU,OAAO;AAC5E,QAAI,UAAU;AACZ,UAAI,SAAS,SAAS,UAAU,QAAQ,SAAS,aAAa,UAAU,UAAU;AAChF,cAAM,IAAI,MAAM,aAAa,UAAU,OAAO,IAAI,UAAU,IAAI,8BAA8B;AAAA,MAChG;AACA;AAAA,IACF;AACA,UAAM,GAAG;AAAA,MACP,UAAU,OAAO,MAAM,qCAAqC,EAAE,KAAK,UAAU,QAAQ;AAAA,IACvF;AACA,UAAM,YAAY,MAAM,mBAAmB,EAAE,GAAG;AAAA,MAC9C,CAAC,UAAU,MAAM,YAAY,UAAU;AAAA,IACzC;AACA,QAAI,UAAU,SAAS,UAAU,QAAQ,SAAS,aAAa,UAAU,UAAU;AACjF,YAAM,IAAI,MAAM,aAAa,UAAU,OAAO,IAAI,UAAU,IAAI,6BAA6B;AAAA,IAC/F;AAAA,EACF;AAEA,SAAO,mBAAmB,EAAE;AAC9B;","names":["row"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/legacy-compat.ts","../src/legacy-supabase-store.ts","../src/http-bridge-store.ts"],"sourcesContent":["import type { BridgeMessage, JsonValue } from \"./bridge-domain.js\";\n\nexport function legacyMessageIdFromSequence(value: string | number): string {\n const text = String(value);\n if (!/^-?\\d+$/.test(text)) throw new Error(\"legacy message ID must be an integer\");\n if (typeof value === \"number\" && !Number.isSafeInteger(value)) {\n throw new Error(\"legacy message ID must be decoded without precision loss\");\n }\n const numeric = BigInt(text);\n if (numeric >= 0n && numeric <= 0xffffffffffffn) {\n return `00000000-0000-8000-8000-${numeric.toString(16).padStart(12, \"0\")}`;\n }\n if (numeric < -0x8000000000000000n || numeric > 0x7fffffffffffffffn) {\n throw new Error(\"legacy message ID exceeds bigint range\");\n }\n const unsigned = numeric < 0 ? numeric + 0x10000000000000000n : numeric;\n const encoded = unsigned.toString(16).padStart(16, \"0\").padStart(18, \"0\");\n return `00000000-0000-8${encoded.slice(0, 3)}-9${encoded.slice(3, 6)}-${encoded.slice(6)}`;\n}\n\nexport function legacySequenceFromMessageId(value: string): string | undefined {\n const small = value.match(/^00000000-0000-8000-8000-([0-9a-f]{12})$/i);\n if (small) return BigInt(`0x${small[1]}`).toString();\n const large = value.match(/^00000000-0000-8([0-9a-f]{3})-9([0-9a-f]{3})-([0-9a-f]{12})$/i);\n if (!large) return undefined;\n const encoded = `${large[1]}${large[2]}${large[3]}`;\n if (!encoded.startsWith(\"00\")) return undefined;\n const unsigned = BigInt(`0x${encoded.slice(2)}`);\n return (unsigned >= 0x8000000000000000n\n ? unsigned - 0x10000000000000000n\n : unsigned).toString();\n}\n\nexport function legacyNumericMessageId(value: string | number): string {\n const text = String(value);\n return /^-?\\d+$/.test(text) ? legacyMessageIdFromSequence(value) : text;\n}\n\nexport function legacyContextMetadata(message: BridgeMessage): Record<string, JsonValue> {\n const metadata = message.metadata &&\n typeof message.metadata === \"object\" &&\n !Array.isArray(message.metadata)\n ? message.metadata\n : {};\n const existingEnvelope = metadata.message_envelope &&\n typeof metadata.message_envelope === \"object\" &&\n !Array.isArray(metadata.message_envelope)\n ? metadata.message_envelope\n : {};\n const envelope: Record<string, JsonValue> = {\n ...existingEnvelope,\n schema: \"agent-bridge.message-envelope.v1\",\n message_id: message.id,\n source_agent: message.source,\n kind: message.type,\n priority: message.priority,\n target_agents: message.targets,\n payload_mime: message.contentType,\n };\n if (message.workspace !== \"*\") envelope.project = message.workspace;\n if (message.threadId) envelope.thread_id = message.threadId;\n if (message.replyToId) envelope.reply_to_id = message.replyToId;\n if (message.correlationId) envelope.correlation_id = message.correlationId;\n if (message.causationId) envelope.causation_id = message.causationId;\n if (message.data !== undefined) envelope.payload = message.data;\n if (message.expiresAt) envelope.expires_at = message.expiresAt;\n if (message.atribReceiptId) envelope.atrib_receipt_id = message.atribReceiptId;\n if (message.informedBy?.length) envelope.informed_by = message.informedBy;\n return { ...metadata, message_envelope: envelope };\n}\n","import { decodeCursor, encodeCursor, type BridgeDelivery, type BridgeMessage, type BridgePrincipal, type RetryPolicy } from \"./bridge-domain.js\";\nimport type {\n BridgeStore,\n BridgeDiagnostics,\n ClaimOptions,\n InsertMessageResult,\n MessagePage,\n MessageQuery,\n} from \"./bridge-store.js\";\nimport { legacyMessageIdFromSequence, legacySequenceFromMessageId } from \"./legacy-compat.js\";\n\ntype LegacyRow = Record<string, any>;\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\nexport class LegacySupabaseError extends Error {\n constructor(readonly status: number, readonly code: string) {\n super(`Legacy Supabase request failed: ${code}`);\n }\n}\n\nfunction messageId(row: LegacyRow): string {\n const envelopeId = row.metadata?.message_envelope?.message_id;\n return typeof envelopeId === \"string\" && UUID_RE.test(envelopeId)\n ? envelopeId\n : legacyMessageIdFromSequence(String(row.id));\n}\n\nfunction isVisible(row: LegacyRow, principal: BridgePrincipal, query: MessageQuery): boolean {\n const envelope = row.metadata?.message_envelope;\n const targets = Array.isArray(envelope?.target_agents) ? envelope.target_agents : [];\n if (targets.length && !targets.includes(principal.agent)) return false;\n\n const type = envelope?.kind ?? row.category;\n if (query.types?.length && !query.types.includes(type)) return false;\n if (query.threadId && envelope?.thread_id !== query.threadId) return false;\n\n const expiresAt = envelope?.expires_at;\n if (!query.includeExpired && expiresAt && new Date(expiresAt).getTime() <= Date.now()) return false;\n return true;\n}\n\nfunction asMessage(row: LegacyRow, principal: BridgePrincipal): BridgeMessage {\n const envelope = row.metadata?.message_envelope;\n return {\n id: messageId(row),\n sequence: String(row.id),\n workspace: row.project ?? principal.workspace,\n source: row.source,\n type: envelope?.kind ?? row.category,\n content: row.content,\n contentType: envelope?.payload_mime ?? \"text/plain\",\n data: envelope?.payload,\n targets: envelope?.target_agents ?? [],\n threadId: envelope?.thread_id,\n replyToId: envelope?.reply_to_id,\n correlationId: envelope?.correlation_id,\n causationId: envelope?.causation_id,\n priority: row.priority ?? \"info\",\n expiresAt: envelope?.expires_at,\n idempotencyKey: envelope?.idempotency_key,\n atribReceiptId: row.atrib_receipt_id ?? envelope?.atrib_receipt_id,\n informedBy: envelope?.informed_by,\n metadata: row.metadata,\n createdAt: row.created_at,\n };\n}\n\nexport class LegacySupabaseRestStore implements BridgeStore {\n private readonly legacyIds = new Map<string, string>();\n private initialized = false;\n\n constructor(\n private readonly url: string,\n private readonly key: string,\n private readonly fetchImpl: typeof fetch = fetch,\n private readonly timeoutMs = 10_000,\n ) {\n const parsed = new URL(url);\n const loopback = parsed.hostname === \"localhost\" || parsed.hostname === \"127.0.0.1\" || parsed.hostname === \"[::1]\";\n if (parsed.protocol !== \"https:\" && !(parsed.protocol === \"http:\" && loopback)) {\n throw new Error(\"Agent Bridge requires HTTPS for non-loopback legacy providers\");\n }\n }\n\n async initialize(): Promise<void> {\n if (this.initialized) return;\n await this.request(\"/shared_context?select=id&limit=1\");\n this.initialized = true;\n }\n\n private async request(path: string, init: RequestInit = {}): Promise<any> {\n try {\n const response = await this.fetchImpl(`${this.url.replace(/\\/$/, \"\")}/rest/v1${path}`, {\n ...init,\n signal: init.signal ?? AbortSignal.timeout(this.timeoutMs),\n headers: {\n apikey: this.key,\n Authorization: `Bearer ${this.key}`,\n \"Content-Type\": \"application/json\",\n Prefer: \"return=representation\",\n ...(init.headers ?? {}),\n },\n });\n if (!response.ok) {\n throw new LegacySupabaseError(response.status, \"provider_error\");\n }\n const text = await response.text();\n return text ? JSON.parse(text) : null;\n } catch (error) {\n if (error instanceof LegacySupabaseError) throw error;\n if (error instanceof Error && (error.name === \"TimeoutError\" || error.name === \"AbortError\")) {\n throw new LegacySupabaseError(504, \"request_timeout\");\n }\n throw new LegacySupabaseError(0, \"network_error\");\n }\n }\n\n async insertMessage(\n input: Omit<BridgeMessage, \"sequence\" | \"createdAt\">,\n ): Promise<InsertMessageResult> {\n if (input.idempotencyKey) {\n throw new Error(\n \"legacy Supabase mode cannot enforce idempotency keys; migrate to shared mode\",\n );\n }\n const lookup = encodeURIComponent(\n JSON.stringify({ message_envelope: { message_id: input.id } }),\n );\n const existing = await this.request(\n `/shared_context?metadata=cs.${lookup}&order=id.asc&limit=1`,\n );\n if (existing[0]) {\n this.legacyIds.set(messageId(existing[0]), String(existing[0].id));\n return { created: false, message: asMessage(existing[0], { workspace: input.workspace, agent: input.source }) };\n }\n\n const existingMetadata = input.metadata &&\n typeof input.metadata === \"object\" &&\n !Array.isArray(input.metadata)\n ? input.metadata\n : {};\n const existingEnvelope = existingMetadata.message_envelope &&\n typeof existingMetadata.message_envelope === \"object\"\n ? existingMetadata.message_envelope as Record<string, unknown>\n : {};\n const body = {\n source: input.source,\n category: input.type,\n content: input.content,\n priority: input.priority,\n project: input.workspace === \"*\" ? null : input.workspace,\n metadata: {\n ...existingMetadata,\n message_envelope: {\n ...existingEnvelope,\n schema: \"agent-bridge.message-envelope.v1\",\n message_id: input.id,\n source_agent: input.source,\n kind: input.type,\n payload_mime: input.contentType,\n payload: input.data,\n target_agents: input.targets,\n thread_id: input.threadId,\n reply_to_id: input.replyToId,\n correlation_id: input.correlationId,\n causation_id: input.causationId,\n expires_at: input.expiresAt,\n informed_by: input.informedBy,\n },\n },\n atrib_receipt_id: input.atribReceiptId,\n };\n const rows = await this.request(\"/shared_context\", {\n method: \"POST\",\n body: JSON.stringify(body),\n });\n const row = rows[0];\n this.legacyIds.set(input.id, String(row.id));\n return {\n created: true,\n message: { ...input, sequence: String(row.id), createdAt: row.created_at },\n };\n }\n\n async listMessages(\n principal: BridgePrincipal,\n query: MessageQuery = {},\n ): Promise<MessagePage> {\n const limit = query.limit ?? 50;\n let after = decodeCursor(query.cursor) ?? \"0\";\n let before: string | undefined;\n let latestCursor: string | undefined;\n const messages: BridgeMessage[] = [];\n\n while (messages.length < limit) {\n const batchLimit = Math.min(Math.max(limit * 2, 50), 200);\n const workspaceFilter = principal.workspace === \"*\"\n ? \"\"\n : `&project=eq.${encodeURIComponent(principal.workspace)}`;\n const sourceFilter = query.source\n ? `&source=eq.${encodeURIComponent(query.source)}`\n : \"\";\n const sinceFilter = query.since\n ? `&created_at=gte.${encodeURIComponent(query.since)}`\n : \"\";\n const unacknowledgedFilter = query.unacknowledgedBy\n ? `&acked_by=not.cs.%7B${encodeURIComponent(query.unacknowledgedBy)}%7D`\n : \"\";\n const cursorFilter = query.latest\n ? before ? `&id=lt.${encodeURIComponent(before)}` : \"\"\n : `&id=gt.${encodeURIComponent(after)}`;\n const rows = (await this.request(\n `/shared_context?select=*${cursorFilter}` +\n `${workspaceFilter}${sourceFilter}${sinceFilter}${unacknowledgedFilter}` +\n `&order=id.${query.latest ? \"desc\" : \"asc\"}&limit=${batchLimit}`,\n )) as LegacyRow[];\n if (!rows.length) break;\n if (query.latest && latestCursor === undefined) latestCursor = String(rows[0].id);\n\n for (const row of rows) {\n after = String(row.id);\n const id = messageId(row);\n this.legacyIds.set(id, after);\n if (isVisible(row, principal, query)) messages.push(asMessage(row, principal));\n if (messages.length === limit) break;\n }\n if (query.latest) before = String(rows[rows.length - 1]!.id);\n if (rows.length < batchLimit || messages.length === limit) break;\n }\n\n const next = query.latest ? latestCursor : after === \"0\" ? undefined : after;\n return { messages, cursor: next ? encodeCursor(next) : query.cursor };\n }\n\n async recordReceipt(_workspace: string, ids: string[], principal: string): Promise<number> {\n const entryIds = await Promise.all(ids.map(async (id) => {\n const mapped = this.legacyIds.get(id);\n if (mapped) return mapped;\n const lookup = encodeURIComponent(JSON.stringify({ message_envelope: { message_id: id } }));\n const rows = await this.request(`/shared_context?select=id,metadata&metadata=cs.${lookup}&limit=2`);\n if (Array.isArray(rows) && rows.length === 1) {\n const sequence = String(rows[0].id);\n this.legacyIds.set(id, sequence);\n return sequence;\n }\n if (Array.isArray(rows) && rows.length > 1) {\n throw new LegacySupabaseError(409, \"ambiguous_message_id\");\n }\n const decodedSequence = legacySequenceFromMessageId(id);\n if (decodedSequence !== undefined) return decodedSequence;\n throw new LegacySupabaseError(404, \"message_not_found\");\n }));\n return this.request(\"/rpc/ack_context\", {\n method: \"POST\",\n body: JSON.stringify({ entry_ids: entryIds, agent_name: principal }),\n });\n }\n\n async recordLegacyReceipt(ids: string[], principal: string): Promise<number> {\n const entryIds = ids.map((id) => {\n if (!/^\\d+$/.test(id)) throw new Error(\"legacy receipt IDs must be numeric\");\n const value = BigInt(id);\n if (value > 0x7fffffffffffffffn) throw new Error(\"legacy receipt ID exceeds bigint range\");\n return value.toString();\n });\n return this.request(\"/rpc/ack_context\", {\n method: \"POST\",\n body: JSON.stringify({ entry_ids: entryIds, agent_name: principal }),\n });\n }\n\n async claimDelivery(\n _principal: BridgePrincipal,\n _options: ClaimOptions,\n ): Promise<BridgeDelivery | null> {\n throw new Error(\"legacy Supabase adapter does not support deliveries\");\n }\n\n async renewDelivery(\n _principal: BridgePrincipal,\n _deliveryId: string,\n _leaseToken: string,\n _leaseMs: number,\n ): Promise<BridgeDelivery | null> {\n throw new Error(\"legacy Supabase adapter does not support deliveries\");\n }\n\n async settleDelivery(\n _principal: BridgePrincipal,\n _deliveryId: string,\n _leaseToken: string,\n _state: \"acked\" | \"retrying\" | \"dead\",\n _error: string | undefined,\n _retryPolicy: RetryPolicy,\n ): Promise<BridgeDelivery | null> {\n throw new Error(\"legacy Supabase adapter does not support deliveries\");\n }\n\n async diagnostics(_principal: BridgePrincipal): Promise<BridgeDiagnostics> {\n return { schemaVersion: \"legacy-v1\", deliverySupported: false, pending: null, claimed: null, retrying: null, dead: null };\n }\n}\n","import type { AgentPresence, BridgeDelivery, BridgeMessage, BridgePrincipal, RetryPolicy } from \"./bridge-domain.js\";\nimport type { BridgeDiagnostics, BridgeStore, ClaimOptions, InsertMessageResult, MessagePage, MessageQuery } from \"./bridge-store.js\";\n\nexport interface HttpBridgeStoreOptions {\n baseUrl: string;\n token: string;\n principal: BridgePrincipal;\n timeoutMs?: number;\n allowInsecureRemoteHttp?: boolean;\n fetch?: typeof fetch;\n}\n\nexport class BridgeHttpError extends Error {\n constructor(readonly status: number, readonly code: string) { super(`Agent Bridge request failed: ${code}`); }\n}\n\nexport class HttpBridgeStore implements BridgeStore {\n private readonly fetchImpl: typeof fetch;\n constructor(private readonly options: HttpBridgeStoreOptions) {\n const url = new URL(options.baseUrl);\n const loopback = url.hostname === \"localhost\" || url.hostname === \"127.0.0.1\" || url.hostname === \"[::1]\";\n if (url.protocol !== \"https:\" && !(url.protocol === \"http:\" && loopback) && !options.allowInsecureRemoteHttp) {\n throw new Error(\"Agent Bridge requires HTTPS for non-loopback gateways\");\n }\n this.fetchImpl = options.fetch ?? fetch;\n }\n async initialize(): Promise<void> {\n await this.request(\"/readyz\", { authenticated: false });\n const status = await this.request(\"/v2/status\");\n this.assertBoundPrincipal(status);\n }\n\n private assertBoundPrincipal(status: any): void {\n const principal = status?.principal;\n if (\n !principal ||\n principal.workspace !== this.options.principal.workspace ||\n principal.agent !== this.options.principal.agent\n ) {\n throw new BridgeHttpError(403, \"principal_mismatch\");\n }\n }\n\n private async request(path: string, options: { method?: string; body?: unknown; authenticated?: boolean } = {}): Promise<any> {\n try {\n const signal = AbortSignal.timeout(this.options.timeoutMs ?? 10_000);\n const response = await this.fetchImpl(`${this.options.baseUrl.replace(/\\/$/, \"\")}${path}`, {\n method: options.method ?? \"GET\", signal,\n headers: {\n ...(options.authenticated === false ? {} : { authorization: `Bearer ${this.options.token}` }),\n ...(this.options.principal.instance ? { \"x-agent-bridge-instance\": this.options.principal.instance } : {}),\n ...(options.body === undefined ? {} : { \"content-type\": \"application/json\" }),\n },\n body: options.body === undefined ? undefined : JSON.stringify(options.body),\n });\n const payload = await response.json().catch(() => ({}));\n if (!response.ok) throw new BridgeHttpError(response.status, payload?.error?.code ?? \"request_failed\");\n return payload;\n } catch (error) {\n if (error instanceof BridgeHttpError) throw error;\n if (error instanceof Error && (error.name === \"TimeoutError\" || error.name === \"AbortError\")) {\n throw new BridgeHttpError(504, \"request_timeout\");\n }\n throw new BridgeHttpError(0, \"network_error\");\n }\n }\n\n private assertPrincipal(principal: BridgePrincipal, includeInstance = true): void {\n const expected = this.options.principal;\n if (\n principal.workspace !== expected.workspace ||\n principal.agent !== expected.agent ||\n (includeInstance && principal.instance !== expected.instance)\n ) {\n throw new BridgeHttpError(403, \"principal_mismatch\");\n }\n }\n\n async insertMessage(message: Omit<BridgeMessage, \"sequence\" | \"createdAt\">): Promise<InsertMessageResult> {\n this.assertPrincipal({ workspace: message.workspace, agent: message.source }, false);\n const { workspace: _workspace, source: _source, ...draft } = message;\n return this.request(\"/v2/messages\", { method: \"POST\", body: draft });\n }\n async listMessages(principal: BridgePrincipal, query: MessageQuery = {}): Promise<MessagePage> {\n this.assertPrincipal(principal);\n const params = new URLSearchParams();\n if (query.cursor) params.set(\"cursor\", query.cursor);\n if (query.limit) params.set(\"limit\", String(query.limit));\n if (query.includeExpired) params.set(\"includeExpired\", \"true\");\n if (query.source) params.set(\"source\", query.source);\n if (query.since) params.set(\"since\", query.since);\n if (query.unacknowledgedBy) params.set(\"unacknowledgedBy\", query.unacknowledgedBy);\n if (query.threadId) params.set(\"threadId\", query.threadId);\n if (query.latest) params.set(\"latest\", \"true\");\n for (const type of query.types ?? []) params.append(\"type\", type);\n return this.request(`/v2/history${params.size ? `?${params}` : \"\"}`);\n }\n async recordReceipt(workspace: string, ids: string[], principal: string): Promise<number> {\n this.assertPrincipal({ workspace, agent: principal }, false);\n return (await this.request(\"/v2/receipts\", { method: \"POST\", body: { messageIds: ids } })).recorded;\n }\n async diagnostics(principal: BridgePrincipal): Promise<BridgeDiagnostics> {\n this.assertPrincipal(principal);\n const status = await this.request(\"/v2/status\");\n this.assertBoundPrincipal(status);\n return status;\n }\n async claimDelivery(principal: BridgePrincipal, options: ClaimOptions): Promise<BridgeDelivery | null> {\n this.assertPrincipal(principal);\n return (await this.request(\"/v2/deliveries/claim\", { method: \"POST\", body: options }))?.delivery ?? null;\n }\n async renewDelivery(principal: BridgePrincipal, id: string, token: string, leaseMs: number): Promise<BridgeDelivery | null> {\n this.assertPrincipal(principal);\n try {\n return await this.request(`/v2/deliveries/${id}/extend`, { method: \"POST\", body: { leaseToken: token, leaseMs } });\n } catch (error) {\n if (error instanceof BridgeHttpError && error.status === 409) return null;\n throw error;\n }\n }\n async settleDelivery(principal: BridgePrincipal, id: string, token: string, state: \"acked\" | \"retrying\" | \"dead\", error: string | undefined, retryPolicy: RetryPolicy): Promise<BridgeDelivery | null> {\n this.assertPrincipal(principal);\n const action = state === \"acked\" ? \"ack\" : \"nack\";\n try {\n return await this.request(`/v2/deliveries/${id}/${action}`, { method: \"POST\", body: { leaseToken: token, error, dead: state === \"dead\", retryPolicy } });\n } catch (caught) {\n if (caught instanceof BridgeHttpError && caught.status === 409) return null;\n throw caught;\n }\n }\n async heartbeat(principal: BridgePrincipal, leaseMs: number, runtimeType?: string, capabilities: string[] = []): Promise<AgentPresence> {\n this.assertPrincipal(principal);\n return this.request(\"/v2/presence/heartbeat\", { method: \"POST\", body: { leaseMs, runtimeType, capabilities } });\n }\n async listPresence(principal: BridgePrincipal): Promise<AgentPresence[]> {\n this.assertPrincipal(principal);\n return (await this.request(\"/v2/presence\")).agents;\n }\n}\n"],"mappings":";;;;;;;AAEO,SAAS,4BAA4B,OAAgC;AAC1E,QAAM,OAAO,OAAO,KAAK;AACzB,MAAI,CAAC,UAAU,KAAK,IAAI,EAAG,OAAM,IAAI,MAAM,sCAAs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