@mosadd/mcp 3.0.0-alpha.47 → 3.0.0-alpha.48
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/dist/bin/mcp.js +1 -1
- package/dist/{chunk-XTQMZ6K7.js → chunk-MGF7BV3M.js} +41 -23
- package/dist/index.js +1 -1
- package/package.json +73 -73
- package/src/__tests__/knowledge-ingest.test.ts +114 -114
- package/src/__tests__/presence.test.ts +190 -190
- package/src/__tests__/serverJsonVersion.test.ts +45 -45
- package/src/providers/supabase.ts +231 -231
- package/src/server.ts +162 -162
- package/src/tools/__tests__/ragDeleteFoldsSourceId.test.ts +67 -67
- package/src/tools/knowledge-graph.ts +186 -186
- package/src/tools/mail-agentbox.ts +155 -155
- package/src/tools/mcall.ts +216 -216
- package/src/tools/mdm-as-agent.ts +126 -126
- package/src/tools/mdm-voice.ts +220 -220
- package/src/tools/mdm.ts +495 -494
- package/src/tools/mirc-messages.ts +186 -185
- package/src/tools/murl.ts +314 -314
- package/src/tools/presence.ts +442 -414
- package/src/tools/ptt-ingest.ts +99 -99
- package/src/tools/threat.ts +123 -123
- package/src/tools/voice-format.ts +28 -0
- package/src/version.ts +8 -8
- package/LICENSE +0 -201
- package/dist/bin/login.d.ts +0 -13
- package/dist/bin/mcp.d.ts +0 -1
- package/dist/index.d.ts +0 -310
|
@@ -1,190 +1,190 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* comms_session_attach — the liveness contract.
|
|
3
|
-
*
|
|
4
|
-
* This tool decides WHO answers the owner: a live agent session, or the 24/7 cloud stand-in.
|
|
5
|
-
* Both answering, or the stand-in answering in a live session's name, is the exact failure that
|
|
6
|
-
* cost the founder his trust in the agent (see the file header in tools/presence.ts). So the
|
|
7
|
-
* things pinned here are the ones that would silently re-open it:
|
|
8
|
-
*
|
|
9
|
-
* 1. attaching writes the liveness row the stand-in reads, under the CALLER'S identity;
|
|
10
|
-
* 2. the hold renews itself on a timer — the model is not asked to remember a clock;
|
|
11
|
-
* 3. the timer is unref()ed, so a held line can never keep a dead session's process alive;
|
|
12
|
-
* 4. re-attaching replaces the beat instead of stacking a second one;
|
|
13
|
-
* 5. release DELETES the row (no backdated timestamp lying in a table other code reads).
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
17
|
-
|
|
18
|
-
const IDENTITY_ID = "b228b6ae-dda6-4823-9882-40ea91ed1530";
|
|
19
|
-
const USER_ID = "b1b6c60a-f5c5-47bd-8772-9e4e387994ad";
|
|
20
|
-
const TEST_SESSION = "test-host:11111111-2222-3333-4444-555555555555";
|
|
21
|
-
const AGENT_ID = "0489d4c6-8727-442f-bf83-68747a469492";
|
|
22
|
-
|
|
23
|
-
/** Calls recorded by the fake Supabase client, so assertions read like the wire traffic. */
|
|
24
|
-
const calls = {
|
|
25
|
-
upserts: [] as Record<string, unknown>[],
|
|
26
|
-
deletes: [] as string[],
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Minimal query-builder stand-in: every method returns the builder, `maybeSingle()` resolves the
|
|
31
|
-
* identity row, and the builder is thenable so `await delete().eq()` works like PostgREST's.
|
|
32
|
-
*/
|
|
33
|
-
function makeBuilder(table: string) {
|
|
34
|
-
const builder: Record<string, unknown> = {};
|
|
35
|
-
let pendingDelete = false;
|
|
36
|
-
const self = () => builder;
|
|
37
|
-
Object.assign(builder, {
|
|
38
|
-
select: self,
|
|
39
|
-
is: self,
|
|
40
|
-
or: self,
|
|
41
|
-
upsert: (row: Record<string, unknown>) => {
|
|
42
|
-
calls.upserts.push({ table, ...row });
|
|
43
|
-
return Promise.resolve({ error: null });
|
|
44
|
-
},
|
|
45
|
-
delete: () => {
|
|
46
|
-
pendingDelete = true;
|
|
47
|
-
return builder;
|
|
48
|
-
},
|
|
49
|
-
// ⛔ KASOWANIE MA TERAZ DWA WARUNKI: (konto, sesja). Atrapa musi dać się złożyć w łańcuch
|
|
50
|
-
// `.delete().eq(user).eq(session)`, więc zwracany obiekt jest JEDNOCZEŚNIE budowniczym i
|
|
51
|
-
// obietnicą — inaczej test przechodziłby tylko dlatego, że atrapa nie umie tego, co produkcja.
|
|
52
|
-
eq: (_col: string, val: string) => {
|
|
53
|
-
if (pendingDelete) {
|
|
54
|
-
calls.deletes.push(val);
|
|
55
|
-
return Object.assign(
|
|
56
|
-
{ eq: (_c2: string, v2: string) => { calls.deletes.push(v2); return Promise.resolve({ error: null }); } },
|
|
57
|
-
{ then: (res: (v: { error: null }) => unknown) => Promise.resolve({ error: null }).then(res) },
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
return builder;
|
|
61
|
-
},
|
|
62
|
-
// resolveOwnedAgentLine path: .or(...).limit(2) → the caller's ONE owned agent.
|
|
63
|
-
limit: () =>
|
|
64
|
-
Promise.resolve({
|
|
65
|
-
data: [{ id: AGENT_ID, m0ssad_email: "dispatcher@mosadd.com", display_name: "DYSPOZYTOR" }],
|
|
66
|
-
error: null,
|
|
67
|
-
}),
|
|
68
|
-
maybeSingle: () => Promise.resolve({ data: { id: IDENTITY_ID, display_name: "mosADD CTO" }, error: null }),
|
|
69
|
-
});
|
|
70
|
-
return builder;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
vi.mock("../providers/supabase.js", () => ({
|
|
74
|
-
readSupabaseEnv: () => ({ url: "https://example.supabase.co", anonKey: "anon", userJwt: "jwt" }),
|
|
75
|
-
// Stała tożsamość sesji — deklaracja linii jest odtąd kluczowana po (konto, sesja), żeby
|
|
76
|
-
// generałowie wpięci tym samym kluczem nie odbierali sobie linii nawzajem.
|
|
77
|
-
sessionId: () => TEST_SESSION,
|
|
78
|
-
getSupabase: () => ({
|
|
79
|
-
auth: { getUser: () => Promise.resolve({ data: { user: { id: USER_ID } }, error: null }) },
|
|
80
|
-
from: (table: string) => makeBuilder(table),
|
|
81
|
-
}),
|
|
82
|
-
}));
|
|
83
|
-
|
|
84
|
-
const ctx = { log: () => {} } as never;
|
|
85
|
-
|
|
86
|
-
/** Import after the mock is registered, so the module under test picks it up. */
|
|
87
|
-
const { presenceTools, __clearAttachmentsForTest } = await import("../tools/presence.js");
|
|
88
|
-
const attach = presenceTools[0];
|
|
89
|
-
|
|
90
|
-
async function call(input: Record<string, unknown>) {
|
|
91
|
-
return (await attach.handler(input, ctx)) as Record<string, unknown>;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
describe("comms_session_attach", () => {
|
|
95
|
-
beforeEach(() => {
|
|
96
|
-
calls.upserts = [];
|
|
97
|
-
calls.deletes = [];
|
|
98
|
-
vi.useFakeTimers();
|
|
99
|
-
});
|
|
100
|
-
afterEach(() => {
|
|
101
|
-
__clearAttachmentsForTest();
|
|
102
|
-
vi.useRealTimers();
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("is registered as a network tool under the comms_ capability group", () => {
|
|
106
|
-
expect(attach.name).toBe("comms_session_attach");
|
|
107
|
-
expect(attach.requires).toBe("network");
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("claims the line for the CALLER'S identity, with a label the owner can read", async () => {
|
|
111
|
-
const out = await call({ label: "CTO — Claude Code" });
|
|
112
|
-
expect(out.attached).toBe(true);
|
|
113
|
-
expect(out.identity_id).toBe(IDENTITY_ID);
|
|
114
|
-
expect(calls.upserts).toHaveLength(1);
|
|
115
|
-
expect(calls.upserts[0]).toMatchObject({
|
|
116
|
-
table: "agent_bridge_heartbeat",
|
|
117
|
-
identity_id: IDENTITY_ID,
|
|
118
|
-
host: "CTO — Claude Code",
|
|
119
|
-
mode: "mcp-session",
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it("renews the hold on its own — the model is never asked to keep time", async () => {
|
|
124
|
-
await call({});
|
|
125
|
-
expect(calls.upserts).toHaveLength(1);
|
|
126
|
-
await vi.advanceTimersByTimeAsync(60_000);
|
|
127
|
-
expect(calls.upserts).toHaveLength(2);
|
|
128
|
-
await vi.advanceTimersByTimeAsync(60_000);
|
|
129
|
-
expect(calls.upserts).toHaveLength(3);
|
|
130
|
-
// Every beat is a fresh timestamp, not a replay of the first one.
|
|
131
|
-
expect(calls.upserts[2].last_seen_at).not.toBe(calls.upserts[0].last_seen_at);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("never keeps a finished session's process alive (timer is unref'ed)", async () => {
|
|
135
|
-
const unref = vi.fn();
|
|
136
|
-
const spy = vi.spyOn(globalThis, "setInterval").mockReturnValue({ unref } as never);
|
|
137
|
-
await call({});
|
|
138
|
-
expect(unref).toHaveBeenCalledOnce();
|
|
139
|
-
spy.mockRestore();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it("re-attaching replaces the beat instead of stacking a second one", async () => {
|
|
143
|
-
await call({ label: "first" });
|
|
144
|
-
await call({ label: "second" });
|
|
145
|
-
calls.upserts = [];
|
|
146
|
-
await vi.advanceTimersByTimeAsync(60_000);
|
|
147
|
-
expect(calls.upserts).toHaveLength(1);
|
|
148
|
-
expect(calls.upserts[0].host).toBe("second");
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it("release DELETES the row and stops beating — the stand-in resumes at once", async () => {
|
|
152
|
-
await call({});
|
|
153
|
-
const out = await call({ release: true });
|
|
154
|
-
expect(out.attached).toBe(false);
|
|
155
|
-
// Two deletes since 2026-08-26: the heartbeat row (by identity) AND the as_agent
|
|
156
|
-
// declaration in mosadd_gateway_agent_binding (by user) — a finishing session hands
|
|
157
|
-
// back EVERYTHING it could hold, so no stale declaration keeps signing later posts.
|
|
158
|
-
// Zwolnienie kasuje: puls linii + deklarację TEJ sesji (konto ORAZ sesja). Trzeci element to
|
|
159
|
-
// dowód, że nie kasujemy po samym koncie — bo to zabierało linię wszystkim innym generałom.
|
|
160
|
-
expect(calls.deletes).toEqual([IDENTITY_ID, USER_ID, TEST_SESSION]);
|
|
161
|
-
calls.upserts = [];
|
|
162
|
-
await vi.advanceTimersByTimeAsync(180_000);
|
|
163
|
-
expect(calls.upserts).toHaveLength(0);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it("as_agent declares the line: binding upsert + beat on the AGENT's identity, not the key's", async () => {
|
|
167
|
-
const out = await call({ as_agent: "dispatcher@mosadd.com", label: "dispatcher — Cowork" });
|
|
168
|
-
expect(out.attached).toBe(true);
|
|
169
|
-
expect(out.identity_id).toBe(AGENT_ID);
|
|
170
|
-
expect((out.speaking_as as { address: string }).address).toBe("dispatcher@mosadd.com");
|
|
171
|
-
// The signing declaration message-send reads (migration 20260826210000)…
|
|
172
|
-
expect(calls.upserts).toContainEqual(
|
|
173
|
-
expect.objectContaining({
|
|
174
|
-
table: "mosadd_gateway_agent_binding",
|
|
175
|
-
user_id: USER_ID,
|
|
176
|
-
agent_identity_id: AGENT_ID,
|
|
177
|
-
}),
|
|
178
|
-
);
|
|
179
|
-
// …and the AGENT's liveness row, so ITS cloud stand-in defers to this session.
|
|
180
|
-
expect(calls.upserts).toContainEqual(
|
|
181
|
-
expect.objectContaining({
|
|
182
|
-
table: "agent_bridge_heartbeat",
|
|
183
|
-
identity_id: AGENT_ID,
|
|
184
|
-
host: "dispatcher — Cowork",
|
|
185
|
-
}),
|
|
186
|
-
);
|
|
187
|
-
// The key's own line is NOT claimed — attaching as an agent must not silence the owner's lane.
|
|
188
|
-
expect(calls.upserts.some((u) => u.table === "agent_bridge_heartbeat" && u.identity_id === IDENTITY_ID)).toBe(false);
|
|
189
|
-
});
|
|
190
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* comms_session_attach — the liveness contract.
|
|
3
|
+
*
|
|
4
|
+
* This tool decides WHO answers the owner: a live agent session, or the 24/7 cloud stand-in.
|
|
5
|
+
* Both answering, or the stand-in answering in a live session's name, is the exact failure that
|
|
6
|
+
* cost the founder his trust in the agent (see the file header in tools/presence.ts). So the
|
|
7
|
+
* things pinned here are the ones that would silently re-open it:
|
|
8
|
+
*
|
|
9
|
+
* 1. attaching writes the liveness row the stand-in reads, under the CALLER'S identity;
|
|
10
|
+
* 2. the hold renews itself on a timer — the model is not asked to remember a clock;
|
|
11
|
+
* 3. the timer is unref()ed, so a held line can never keep a dead session's process alive;
|
|
12
|
+
* 4. re-attaching replaces the beat instead of stacking a second one;
|
|
13
|
+
* 5. release DELETES the row (no backdated timestamp lying in a table other code reads).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
17
|
+
|
|
18
|
+
const IDENTITY_ID = "b228b6ae-dda6-4823-9882-40ea91ed1530";
|
|
19
|
+
const USER_ID = "b1b6c60a-f5c5-47bd-8772-9e4e387994ad";
|
|
20
|
+
const TEST_SESSION = "test-host:11111111-2222-3333-4444-555555555555";
|
|
21
|
+
const AGENT_ID = "0489d4c6-8727-442f-bf83-68747a469492";
|
|
22
|
+
|
|
23
|
+
/** Calls recorded by the fake Supabase client, so assertions read like the wire traffic. */
|
|
24
|
+
const calls = {
|
|
25
|
+
upserts: [] as Record<string, unknown>[],
|
|
26
|
+
deletes: [] as string[],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Minimal query-builder stand-in: every method returns the builder, `maybeSingle()` resolves the
|
|
31
|
+
* identity row, and the builder is thenable so `await delete().eq()` works like PostgREST's.
|
|
32
|
+
*/
|
|
33
|
+
function makeBuilder(table: string) {
|
|
34
|
+
const builder: Record<string, unknown> = {};
|
|
35
|
+
let pendingDelete = false;
|
|
36
|
+
const self = () => builder;
|
|
37
|
+
Object.assign(builder, {
|
|
38
|
+
select: self,
|
|
39
|
+
is: self,
|
|
40
|
+
or: self,
|
|
41
|
+
upsert: (row: Record<string, unknown>) => {
|
|
42
|
+
calls.upserts.push({ table, ...row });
|
|
43
|
+
return Promise.resolve({ error: null });
|
|
44
|
+
},
|
|
45
|
+
delete: () => {
|
|
46
|
+
pendingDelete = true;
|
|
47
|
+
return builder;
|
|
48
|
+
},
|
|
49
|
+
// ⛔ KASOWANIE MA TERAZ DWA WARUNKI: (konto, sesja). Atrapa musi dać się złożyć w łańcuch
|
|
50
|
+
// `.delete().eq(user).eq(session)`, więc zwracany obiekt jest JEDNOCZEŚNIE budowniczym i
|
|
51
|
+
// obietnicą — inaczej test przechodziłby tylko dlatego, że atrapa nie umie tego, co produkcja.
|
|
52
|
+
eq: (_col: string, val: string) => {
|
|
53
|
+
if (pendingDelete) {
|
|
54
|
+
calls.deletes.push(val);
|
|
55
|
+
return Object.assign(
|
|
56
|
+
{ eq: (_c2: string, v2: string) => { calls.deletes.push(v2); return Promise.resolve({ error: null }); } },
|
|
57
|
+
{ then: (res: (v: { error: null }) => unknown) => Promise.resolve({ error: null }).then(res) },
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
return builder;
|
|
61
|
+
},
|
|
62
|
+
// resolveOwnedAgentLine path: .or(...).limit(2) → the caller's ONE owned agent.
|
|
63
|
+
limit: () =>
|
|
64
|
+
Promise.resolve({
|
|
65
|
+
data: [{ id: AGENT_ID, m0ssad_email: "dispatcher@mosadd.com", display_name: "DYSPOZYTOR" }],
|
|
66
|
+
error: null,
|
|
67
|
+
}),
|
|
68
|
+
maybeSingle: () => Promise.resolve({ data: { id: IDENTITY_ID, display_name: "mosADD CTO" }, error: null }),
|
|
69
|
+
});
|
|
70
|
+
return builder;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
vi.mock("../providers/supabase.js", () => ({
|
|
74
|
+
readSupabaseEnv: () => ({ url: "https://example.supabase.co", anonKey: "anon", userJwt: "jwt" }),
|
|
75
|
+
// Stała tożsamość sesji — deklaracja linii jest odtąd kluczowana po (konto, sesja), żeby
|
|
76
|
+
// generałowie wpięci tym samym kluczem nie odbierali sobie linii nawzajem.
|
|
77
|
+
sessionId: () => TEST_SESSION,
|
|
78
|
+
getSupabase: () => ({
|
|
79
|
+
auth: { getUser: () => Promise.resolve({ data: { user: { id: USER_ID } }, error: null }) },
|
|
80
|
+
from: (table: string) => makeBuilder(table),
|
|
81
|
+
}),
|
|
82
|
+
}));
|
|
83
|
+
|
|
84
|
+
const ctx = { log: () => {} } as never;
|
|
85
|
+
|
|
86
|
+
/** Import after the mock is registered, so the module under test picks it up. */
|
|
87
|
+
const { presenceTools, __clearAttachmentsForTest } = await import("../tools/presence.js");
|
|
88
|
+
const attach = presenceTools[0];
|
|
89
|
+
|
|
90
|
+
async function call(input: Record<string, unknown>) {
|
|
91
|
+
return (await attach.handler(input, ctx)) as Record<string, unknown>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
describe("comms_session_attach", () => {
|
|
95
|
+
beforeEach(() => {
|
|
96
|
+
calls.upserts = [];
|
|
97
|
+
calls.deletes = [];
|
|
98
|
+
vi.useFakeTimers();
|
|
99
|
+
});
|
|
100
|
+
afterEach(() => {
|
|
101
|
+
__clearAttachmentsForTest();
|
|
102
|
+
vi.useRealTimers();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("is registered as a network tool under the comms_ capability group", () => {
|
|
106
|
+
expect(attach.name).toBe("comms_session_attach");
|
|
107
|
+
expect(attach.requires).toBe("network");
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("claims the line for the CALLER'S identity, with a label the owner can read", async () => {
|
|
111
|
+
const out = await call({ label: "CTO — Claude Code" });
|
|
112
|
+
expect(out.attached).toBe(true);
|
|
113
|
+
expect(out.identity_id).toBe(IDENTITY_ID);
|
|
114
|
+
expect(calls.upserts).toHaveLength(1);
|
|
115
|
+
expect(calls.upserts[0]).toMatchObject({
|
|
116
|
+
table: "agent_bridge_heartbeat",
|
|
117
|
+
identity_id: IDENTITY_ID,
|
|
118
|
+
host: "CTO — Claude Code",
|
|
119
|
+
mode: "mcp-session",
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("renews the hold on its own — the model is never asked to keep time", async () => {
|
|
124
|
+
await call({});
|
|
125
|
+
expect(calls.upserts).toHaveLength(1);
|
|
126
|
+
await vi.advanceTimersByTimeAsync(60_000);
|
|
127
|
+
expect(calls.upserts).toHaveLength(2);
|
|
128
|
+
await vi.advanceTimersByTimeAsync(60_000);
|
|
129
|
+
expect(calls.upserts).toHaveLength(3);
|
|
130
|
+
// Every beat is a fresh timestamp, not a replay of the first one.
|
|
131
|
+
expect(calls.upserts[2].last_seen_at).not.toBe(calls.upserts[0].last_seen_at);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("never keeps a finished session's process alive (timer is unref'ed)", async () => {
|
|
135
|
+
const unref = vi.fn();
|
|
136
|
+
const spy = vi.spyOn(globalThis, "setInterval").mockReturnValue({ unref } as never);
|
|
137
|
+
await call({});
|
|
138
|
+
expect(unref).toHaveBeenCalledOnce();
|
|
139
|
+
spy.mockRestore();
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("re-attaching replaces the beat instead of stacking a second one", async () => {
|
|
143
|
+
await call({ label: "first" });
|
|
144
|
+
await call({ label: "second" });
|
|
145
|
+
calls.upserts = [];
|
|
146
|
+
await vi.advanceTimersByTimeAsync(60_000);
|
|
147
|
+
expect(calls.upserts).toHaveLength(1);
|
|
148
|
+
expect(calls.upserts[0].host).toBe("second");
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("release DELETES the row and stops beating — the stand-in resumes at once", async () => {
|
|
152
|
+
await call({});
|
|
153
|
+
const out = await call({ release: true });
|
|
154
|
+
expect(out.attached).toBe(false);
|
|
155
|
+
// Two deletes since 2026-08-26: the heartbeat row (by identity) AND the as_agent
|
|
156
|
+
// declaration in mosadd_gateway_agent_binding (by user) — a finishing session hands
|
|
157
|
+
// back EVERYTHING it could hold, so no stale declaration keeps signing later posts.
|
|
158
|
+
// Zwolnienie kasuje: puls linii + deklarację TEJ sesji (konto ORAZ sesja). Trzeci element to
|
|
159
|
+
// dowód, że nie kasujemy po samym koncie — bo to zabierało linię wszystkim innym generałom.
|
|
160
|
+
expect(calls.deletes).toEqual([IDENTITY_ID, USER_ID, TEST_SESSION]);
|
|
161
|
+
calls.upserts = [];
|
|
162
|
+
await vi.advanceTimersByTimeAsync(180_000);
|
|
163
|
+
expect(calls.upserts).toHaveLength(0);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("as_agent declares the line: binding upsert + beat on the AGENT's identity, not the key's", async () => {
|
|
167
|
+
const out = await call({ as_agent: "dispatcher@mosadd.com", label: "dispatcher — Cowork" });
|
|
168
|
+
expect(out.attached).toBe(true);
|
|
169
|
+
expect(out.identity_id).toBe(AGENT_ID);
|
|
170
|
+
expect((out.speaking_as as { address: string }).address).toBe("dispatcher@mosadd.com");
|
|
171
|
+
// The signing declaration message-send reads (migration 20260826210000)…
|
|
172
|
+
expect(calls.upserts).toContainEqual(
|
|
173
|
+
expect.objectContaining({
|
|
174
|
+
table: "mosadd_gateway_agent_binding",
|
|
175
|
+
user_id: USER_ID,
|
|
176
|
+
agent_identity_id: AGENT_ID,
|
|
177
|
+
}),
|
|
178
|
+
);
|
|
179
|
+
// …and the AGENT's liveness row, so ITS cloud stand-in defers to this session.
|
|
180
|
+
expect(calls.upserts).toContainEqual(
|
|
181
|
+
expect.objectContaining({
|
|
182
|
+
table: "agent_bridge_heartbeat",
|
|
183
|
+
identity_id: AGENT_ID,
|
|
184
|
+
host: "dispatcher — Cowork",
|
|
185
|
+
}),
|
|
186
|
+
);
|
|
187
|
+
// The key's own line is NOT claimed — attaching as an agent must not silence the owner's lane.
|
|
188
|
+
expect(calls.upserts.some((u) => u.table === "agent_bridge_heartbeat" && u.identity_id === IDENTITY_ID)).toBe(false);
|
|
189
|
+
});
|
|
190
|
+
});
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* server.json MUSI ZGADZAĆ SIĘ Z package.json — inaczej oficjalny rejestr MCP rozdaje starą wersję.
|
|
3
|
-
*
|
|
4
|
-
* ⛔ POWÓD JEST ZMIERZONY, NIE TEORETYCZNY (2026-08-28). `packages/mcp/server.json` stał na
|
|
5
|
-
* `3.0.0-alpha.33`, podczas gdy pakiet był już na `3.0.0-alpha.44` — **jedenaście wersji wstecz**.
|
|
6
|
-
* `server.json` to karta, którą czyta oficjalny rejestr MCP, więc każdy, kto znalazłby mosADD tam,
|
|
7
|
-
* a nie u nas, instalowałby alpha.33: wersję sprzed poprawki modelu-widma, sprzed stabilnej
|
|
8
|
-
* tożsamości sesji i sprzed dwóch wycofanych wydań (alpha.39 zdeprecowana, alpha.42 cofnięta).
|
|
9
|
-
* Pierwsze wrażenie z produktu brałoby się z kodu, o którym my sami wiemy, że jest zepsuty.
|
|
10
|
-
*
|
|
11
|
-
* Rozjechało się dlatego, że NIC tego nie pilnowało: publikacja bumpuje `package.json`, a karta
|
|
12
|
-
* rejestru jest osobnym plikiem, którego nikt nie tyka. Klasyczne „dwie kopie prawdy" — ta sama
|
|
13
|
-
* klasa, która trzy razy przywracała model-widmo na czoło łańcucha. Opis w dokumentacji niczego
|
|
14
|
-
* nie broni; test broni przy każdym przebiegu.
|
|
15
|
-
*
|
|
16
|
-
* Sprawdzamy OBA miejsca w server.json: `version` na wierzchu i `packages[].version`.
|
|
17
|
-
*/
|
|
18
|
-
import { describe, it, expect } from "vitest";
|
|
19
|
-
import { readFileSync } from "node:fs";
|
|
20
|
-
import { dirname, join } from "node:path";
|
|
21
|
-
import { fileURLToPath } from "node:url";
|
|
22
|
-
|
|
23
|
-
// Zakotwiczone w import.meta.url, nigdy w cwd — pułapka build-cwd kosztowała nas już raz.
|
|
24
|
-
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
25
|
-
const PKG_DIR = join(HERE, "..", "..");
|
|
26
|
-
|
|
27
|
-
const pkg = JSON.parse(readFileSync(join(PKG_DIR, "package.json"), "utf8")) as { version: string };
|
|
28
|
-
const card = JSON.parse(readFileSync(join(PKG_DIR, "server.json"), "utf8")) as {
|
|
29
|
-
version: string;
|
|
30
|
-
packages?: Array<{ identifier?: string; version?: string }>;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
describe("server.json (karta rejestru MCP)", () => {
|
|
34
|
-
it("ma tę samą wersję co package.json", () => {
|
|
35
|
-
expect(card.version, `server.json.version rozjechało się z package.json (${pkg.version}). ` +
|
|
36
|
-
"Karta rejestru rozdawałaby innym ludziom INNĄ wersję niż publikujemy.").toBe(pkg.version);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("ma tę samą wersję w bloku packages[]", () => {
|
|
40
|
-
const npmEntry = (card.packages ?? []).find((p) => p.identifier === "@mosadd/mcp");
|
|
41
|
-
expect(npmEntry, "brak wpisu @mosadd/mcp w server.json → packages[]").toBeTruthy();
|
|
42
|
-
expect(npmEntry?.version, `server.json → packages[].version rozjechało się z package.json ` +
|
|
43
|
-
`(${pkg.version}). To jest wersja, którą rejestr KAŻE ZAINSTALOWAĆ.`).toBe(pkg.version);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* server.json MUSI ZGADZAĆ SIĘ Z package.json — inaczej oficjalny rejestr MCP rozdaje starą wersję.
|
|
3
|
+
*
|
|
4
|
+
* ⛔ POWÓD JEST ZMIERZONY, NIE TEORETYCZNY (2026-08-28). `packages/mcp/server.json` stał na
|
|
5
|
+
* `3.0.0-alpha.33`, podczas gdy pakiet był już na `3.0.0-alpha.44` — **jedenaście wersji wstecz**.
|
|
6
|
+
* `server.json` to karta, którą czyta oficjalny rejestr MCP, więc każdy, kto znalazłby mosADD tam,
|
|
7
|
+
* a nie u nas, instalowałby alpha.33: wersję sprzed poprawki modelu-widma, sprzed stabilnej
|
|
8
|
+
* tożsamości sesji i sprzed dwóch wycofanych wydań (alpha.39 zdeprecowana, alpha.42 cofnięta).
|
|
9
|
+
* Pierwsze wrażenie z produktu brałoby się z kodu, o którym my sami wiemy, że jest zepsuty.
|
|
10
|
+
*
|
|
11
|
+
* Rozjechało się dlatego, że NIC tego nie pilnowało: publikacja bumpuje `package.json`, a karta
|
|
12
|
+
* rejestru jest osobnym plikiem, którego nikt nie tyka. Klasyczne „dwie kopie prawdy" — ta sama
|
|
13
|
+
* klasa, która trzy razy przywracała model-widmo na czoło łańcucha. Opis w dokumentacji niczego
|
|
14
|
+
* nie broni; test broni przy każdym przebiegu.
|
|
15
|
+
*
|
|
16
|
+
* Sprawdzamy OBA miejsca w server.json: `version` na wierzchu i `packages[].version`.
|
|
17
|
+
*/
|
|
18
|
+
import { describe, it, expect } from "vitest";
|
|
19
|
+
import { readFileSync } from "node:fs";
|
|
20
|
+
import { dirname, join } from "node:path";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
|
|
23
|
+
// Zakotwiczone w import.meta.url, nigdy w cwd — pułapka build-cwd kosztowała nas już raz.
|
|
24
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
25
|
+
const PKG_DIR = join(HERE, "..", "..");
|
|
26
|
+
|
|
27
|
+
const pkg = JSON.parse(readFileSync(join(PKG_DIR, "package.json"), "utf8")) as { version: string };
|
|
28
|
+
const card = JSON.parse(readFileSync(join(PKG_DIR, "server.json"), "utf8")) as {
|
|
29
|
+
version: string;
|
|
30
|
+
packages?: Array<{ identifier?: string; version?: string }>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
describe("server.json (karta rejestru MCP)", () => {
|
|
34
|
+
it("ma tę samą wersję co package.json", () => {
|
|
35
|
+
expect(card.version, `server.json.version rozjechało się z package.json (${pkg.version}). ` +
|
|
36
|
+
"Karta rejestru rozdawałaby innym ludziom INNĄ wersję niż publikujemy.").toBe(pkg.version);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("ma tę samą wersję w bloku packages[]", () => {
|
|
40
|
+
const npmEntry = (card.packages ?? []).find((p) => p.identifier === "@mosadd/mcp");
|
|
41
|
+
expect(npmEntry, "brak wpisu @mosadd/mcp w server.json → packages[]").toBeTruthy();
|
|
42
|
+
expect(npmEntry?.version, `server.json → packages[].version rozjechało się z package.json ` +
|
|
43
|
+
`(${pkg.version}). To jest wersja, którą rejestr KAŻE ZAINSTALOWAĆ.`).toBe(pkg.version);
|
|
44
|
+
});
|
|
45
|
+
});
|