@electric-ax/agents-server-conformance-tests 0.1.2 → 0.1.4
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/index.cjs +47 -81
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +47 -81
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -253,8 +253,8 @@ var ElectricAgentsScenario = class {
|
|
|
253
253
|
this.steps.push({
|
|
254
254
|
kind: `send`,
|
|
255
255
|
payload,
|
|
256
|
-
from: opts
|
|
257
|
-
type: opts
|
|
256
|
+
from: opts?.from,
|
|
257
|
+
type: opts?.type
|
|
258
258
|
});
|
|
259
259
|
return this;
|
|
260
260
|
}
|
|
@@ -263,7 +263,7 @@ var ElectricAgentsScenario = class {
|
|
|
263
263
|
kind: `sendTo`,
|
|
264
264
|
url,
|
|
265
265
|
payload,
|
|
266
|
-
from: opts
|
|
266
|
+
from: opts?.from
|
|
267
267
|
});
|
|
268
268
|
return this;
|
|
269
269
|
}
|
|
@@ -455,7 +455,7 @@ var ElectricAgentsScenario = class {
|
|
|
455
455
|
this.steps.push({
|
|
456
456
|
kind: `expectSendSchemaError`,
|
|
457
457
|
payload,
|
|
458
|
-
messageType: opts
|
|
458
|
+
messageType: opts?.type ?? `default`,
|
|
459
459
|
code: `SCHEMA_VALIDATION_ERROR`,
|
|
460
460
|
status: 422
|
|
461
461
|
});
|
|
@@ -756,10 +756,7 @@ async function executeStep(ctx, step) {
|
|
|
756
756
|
if (!ctx.currentEntityUrl) throw new Error(`No current entity`);
|
|
757
757
|
const res = await electricAgentsFetch$1(ctx.baseUrl, `${ctx.currentEntityUrl}/send`, {
|
|
758
758
|
method: `POST`,
|
|
759
|
-
body: JSON.stringify({
|
|
760
|
-
from: `test`,
|
|
761
|
-
payload: { should: `fail` }
|
|
762
|
-
})
|
|
759
|
+
body: JSON.stringify({ payload: { should: `fail` } })
|
|
763
760
|
});
|
|
764
761
|
(0, vitest.expect)(res.status).toBe(step.status);
|
|
765
762
|
const body = await res.json();
|
|
@@ -1844,26 +1841,23 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
1844
1841
|
name: `send-test-worker`,
|
|
1845
1842
|
description: `Test entity type for send`,
|
|
1846
1843
|
creation_schema: { type: `object` }
|
|
1847
|
-
}).spawn(`send-test-worker`, `entity-1`).send({ task: `hello` }
|
|
1848
|
-
const envelope = ctx.lastStreamMessages.find((m) => m.type === `
|
|
1849
|
-
(0, vitest.expect)(envelope.type).toBe(`
|
|
1844
|
+
}).spawn(`send-test-worker`, `entity-1`).send({ task: `hello` }).expectWebhook().respondDone().readStream().expectStreamContains(`inbox`).custom(async (ctx) => {
|
|
1845
|
+
const envelope = ctx.lastStreamMessages.find((m) => m.type === `inbox`);
|
|
1846
|
+
(0, vitest.expect)(envelope.type).toBe(`inbox`);
|
|
1850
1847
|
(0, vitest.expect)(envelope.key).toBeDefined();
|
|
1851
|
-
(0, vitest.expect)(envelope.value?.from).
|
|
1848
|
+
(0, vitest.expect)(envelope.value?.from).toMatch(/^\/principal\//);
|
|
1852
1849
|
(0, vitest.expect)(envelope.value?.payload).toEqual({ task: `hello` });
|
|
1853
1850
|
}).run());
|
|
1854
1851
|
(0, vitest.test)(`send triggers webhook with entity context`, () => electricAgents(config.baseUrl).subscription(`/webhook-ctx-agent/**`, `webhook-ctx-sub`).registerType({
|
|
1855
1852
|
name: `webhook-ctx-agent`,
|
|
1856
1853
|
description: `Test entity type for webhook context`,
|
|
1857
1854
|
creation_schema: { type: `object` }
|
|
1858
|
-
}).spawn(`webhook-ctx-agent`, `entity-1`).send({ ping: true }
|
|
1855
|
+
}).spawn(`webhook-ctx-agent`, `entity-1`).send({ ping: true }).expectWebhook().expectEntityContext({ type: `webhook-ctx-agent` }).respondDone().run());
|
|
1859
1856
|
(0, vitest.test)(`send to nonexistent entity returns 404`, () => electricAgents(config.baseUrl).custom(async (ctx) => {
|
|
1860
1857
|
const res = await fetch(`${ctx.baseUrl}${routeControlPlanePath(`/nonexistent-type/nonexistent-id/send`)}`, {
|
|
1861
1858
|
method: `POST`,
|
|
1862
1859
|
headers: { "content-type": `application/json` },
|
|
1863
|
-
body: JSON.stringify({
|
|
1864
|
-
from: `test`,
|
|
1865
|
-
payload: {}
|
|
1866
|
-
})
|
|
1860
|
+
body: JSON.stringify({ payload: {} })
|
|
1867
1861
|
});
|
|
1868
1862
|
(0, vitest.expect)(res.status).toBe(404);
|
|
1869
1863
|
}).skipInvariants().run());
|
|
@@ -1873,13 +1867,13 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
1873
1867
|
name: `order-test-agent-${id}`,
|
|
1874
1868
|
description: `Test entity type for ordering`,
|
|
1875
1869
|
creation_schema: { type: `object` }
|
|
1876
|
-
}).spawn(`order-test-agent-${id}`, `entity-1`).send({ seq: 1 }
|
|
1877
|
-
const msgs = ctx.lastStreamMessages.filter((m) => m.type === `
|
|
1870
|
+
}).spawn(`order-test-agent-${id}`, `entity-1`).send({ seq: 1 }).expectWebhook().respondDone().send({ seq: 2 }).expectWebhook().respondDone().send({ seq: 3 }).expectWebhook().respondDone().readStream().custom(async (ctx) => {
|
|
1871
|
+
const msgs = ctx.lastStreamMessages.filter((m) => m.type === `inbox`);
|
|
1878
1872
|
(0, vitest.expect)(msgs.length).toBe(3);
|
|
1879
1873
|
for (let i = 0; i < 3; i++) (0, vitest.expect)(msgs[i].value?.payload).toEqual({ seq: i + 1 });
|
|
1880
1874
|
}).run();
|
|
1881
1875
|
});
|
|
1882
|
-
(0, vitest.test)(`send without from
|
|
1876
|
+
(0, vitest.test)(`send without from uses principal`, () => electricAgents(config.baseUrl).subscription(`/nofrom-test-agent/**`, `nofrom-test-sub`).registerType({
|
|
1883
1877
|
name: `nofrom-test-agent`,
|
|
1884
1878
|
description: `Test entity type for send without from`,
|
|
1885
1879
|
creation_schema: { type: `object` }
|
|
@@ -1888,10 +1882,8 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
1888
1882
|
method: `POST`,
|
|
1889
1883
|
body: JSON.stringify({ payload: { hello: true } })
|
|
1890
1884
|
});
|
|
1891
|
-
(0, vitest.expect)(res.status).toBe(
|
|
1892
|
-
|
|
1893
|
-
(0, vitest.expect)(body.error.code).toBe(`INVALID_REQUEST`);
|
|
1894
|
-
}).run());
|
|
1885
|
+
(0, vitest.expect)(res.status).toBe(204);
|
|
1886
|
+
}).expectWebhook().respondDone().run());
|
|
1895
1887
|
});
|
|
1896
1888
|
(0, vitest.describe)(`Electric Agents List`, () => {
|
|
1897
1889
|
(0, vitest.test)(`ps lists entities`, () => electricAgents(config.baseUrl).subscription(`/ps-test-worker/**`, `ps-test-worker-sub`).subscription(`/ps-test-agent/**`, `ps-test-agent-sub`).registerType({
|
|
@@ -1931,9 +1923,9 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
1931
1923
|
name: `kill-persist-agent`,
|
|
1932
1924
|
description: `Test entity type for kill persistence`,
|
|
1933
1925
|
creation_schema: { type: `object` }
|
|
1934
|
-
}).spawn(`kill-persist-agent`, `entity-1`).send({ before: `kill` }
|
|
1926
|
+
}).spawn(`kill-persist-agent`, `entity-1`).send({ before: `kill` }).expectWebhook().respondDone().kill().readStream().expectStreamContains(`inbox`).custom(async (ctx) => {
|
|
1935
1927
|
const msgs = ctx.lastStreamMessages;
|
|
1936
|
-
const msgReceived = msgs.find((m) => m.type === `
|
|
1928
|
+
const msgReceived = msgs.find((m) => m.type === `inbox`);
|
|
1937
1929
|
(0, vitest.expect)(msgReceived.value?.payload).toEqual({ before: `kill` });
|
|
1938
1930
|
const stopped = msgs.find((m) => m.type === `entity_stopped`);
|
|
1939
1931
|
(0, vitest.expect)(stopped).toBeDefined();
|
|
@@ -1971,7 +1963,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
1971
1963
|
name: `e2e-test-agent`,
|
|
1972
1964
|
description: `Test entity type for E2E lifecycle`,
|
|
1973
1965
|
creation_schema: { type: `object` }
|
|
1974
|
-
}).spawn(`e2e-test-agent`, `entity-1`).expectStatus(`running`).send({ task: `do-something` }
|
|
1966
|
+
}).spawn(`e2e-test-agent`, `entity-1`).expectStatus(`running`).send({ task: `do-something` }).expectWebhook().expectEntityContext({ type: `e2e-test-agent` }).respondDone().readStream().expectStreamContains(`inbox`).kill().custom(async (ctx) => {
|
|
1975
1967
|
const entity = await pollEntityStatus(ctx.baseUrl, ctx.currentEntityUrl, [`stopped`]);
|
|
1976
1968
|
(0, vitest.expect)(entity.status).toBe(`stopped`);
|
|
1977
1969
|
}).expectSendError(`NOT_RUNNING`, 409).run());
|
|
@@ -2226,10 +2218,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2226
2218
|
properties: { text: { type: `string` } },
|
|
2227
2219
|
required: [`text`]
|
|
2228
2220
|
} }
|
|
2229
|
-
}).spawn(typeName, `entity-1`).send({ text: `hello` }, {
|
|
2230
|
-
from: `user`,
|
|
2231
|
-
type: `query`
|
|
2232
|
-
}).expectWebhook().respondDone().run();
|
|
2221
|
+
}).spawn(typeName, `entity-1`).send({ text: `hello` }, { type: `query` }).expectWebhook().respondDone().run();
|
|
2233
2222
|
});
|
|
2234
2223
|
(0, vitest.test)(`send rejects invalid typed message (C11)`, () => {
|
|
2235
2224
|
const typeName = `send-schema-inv-${Date.now()}`;
|
|
@@ -2242,10 +2231,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2242
2231
|
properties: { text: { type: `string` } },
|
|
2243
2232
|
required: [`text`]
|
|
2244
2233
|
} }
|
|
2245
|
-
}).spawn(typeName, `entity-1`).expectSendSchemaError({ invalid: true }, {
|
|
2246
|
-
from: `user`,
|
|
2247
|
-
type: `query`
|
|
2248
|
-
}).run();
|
|
2234
|
+
}).spawn(typeName, `entity-1`).expectSendSchemaError({ invalid: true }, { type: `query` }).run();
|
|
2249
2235
|
});
|
|
2250
2236
|
(0, vitest.test)(`send rejects unknown message type (C13)`, () => {
|
|
2251
2237
|
const typeName = `send-unknown-type-${Date.now()}`;
|
|
@@ -2258,10 +2244,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2258
2244
|
properties: { text: { type: `string` } },
|
|
2259
2245
|
required: [`text`]
|
|
2260
2246
|
} }
|
|
2261
|
-
}).spawn(typeName, `entity-1`).expectSendUnknownType({ text: `hi` }, {
|
|
2262
|
-
from: `user`,
|
|
2263
|
-
type: `unknown_type`
|
|
2264
|
-
}).run();
|
|
2247
|
+
}).spawn(typeName, `entity-1`).expectSendUnknownType({ text: `hi` }, { type: `unknown_type` }).run();
|
|
2265
2248
|
});
|
|
2266
2249
|
(0, vitest.test)(`send without type when no input_schemas accepts any`, () => {
|
|
2267
2250
|
const typeName = `send-no-schemas-${Date.now()}`;
|
|
@@ -2269,7 +2252,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2269
2252
|
name: typeName,
|
|
2270
2253
|
description: `Type without input schemas`,
|
|
2271
2254
|
creation_schema: { type: `object` }
|
|
2272
|
-
}).spawn(typeName, `entity-1`).send({ anything: `goes` }
|
|
2255
|
+
}).spawn(typeName, `entity-1`).send({ anything: `goes` }).expectWebhook().respondDone().run();
|
|
2273
2256
|
});
|
|
2274
2257
|
(0, vitest.test)(`send with empty input_schemas rejects all`, () => {
|
|
2275
2258
|
const typeName = `send-empty-schemas-${Date.now()}`;
|
|
@@ -2278,10 +2261,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2278
2261
|
description: `Type with empty input schemas`,
|
|
2279
2262
|
creation_schema: { type: `object` },
|
|
2280
2263
|
input_schemas: {}
|
|
2281
|
-
}).spawn(typeName, `entity-1`).expectSendUnknownType({ text: `anything` }, {
|
|
2282
|
-
from: `user`,
|
|
2283
|
-
type: `some_type`
|
|
2284
|
-
}).run();
|
|
2264
|
+
}).spawn(typeName, `entity-1`).expectSendUnknownType({ text: `anything` }, { type: `some_type` }).run();
|
|
2285
2265
|
});
|
|
2286
2266
|
vitest.test.skip(`write appends event to entity stream`, () => {
|
|
2287
2267
|
const typeName = `write-append-${Date.now()}`;
|
|
@@ -2456,10 +2436,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2456
2436
|
type: `object`,
|
|
2457
2437
|
properties: { action: { type: `string` } },
|
|
2458
2438
|
required: [`action`]
|
|
2459
|
-
} } }).spawn(typeName, `entity-1`).send({ action: `do-it` }, {
|
|
2460
|
-
from: `user`,
|
|
2461
|
-
type: `command`
|
|
2462
|
-
}).expectWebhook().respondDone().run();
|
|
2439
|
+
} } }).spawn(typeName, `entity-1`).send({ action: `do-it` }, { type: `command` }).expectWebhook().respondDone().run();
|
|
2463
2440
|
});
|
|
2464
2441
|
(0, vitest.test)(`amend schemas rejects modifying existing keys (C16)`, () => {
|
|
2465
2442
|
const typeName = `amend-conflict-${Date.now()}`;
|
|
@@ -2641,13 +2618,10 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2641
2618
|
if (!url) return;
|
|
2642
2619
|
const res = await electricAgentsFetch(ctx.baseUrl, `${url}/send`, {
|
|
2643
2620
|
method: `POST`,
|
|
2644
|
-
body: JSON.stringify({
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
targetIdx
|
|
2649
|
-
}
|
|
2650
|
-
})
|
|
2621
|
+
body: JSON.stringify({ payload: {
|
|
2622
|
+
action: `prop-send`,
|
|
2623
|
+
targetIdx
|
|
2624
|
+
} })
|
|
2651
2625
|
});
|
|
2652
2626
|
(0, vitest.expect)(res.status).toBe(204);
|
|
2653
2627
|
ctx.history.push({
|
|
@@ -2656,8 +2630,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2656
2630
|
payload: {
|
|
2657
2631
|
action: `prop-send`,
|
|
2658
2632
|
targetIdx
|
|
2659
|
-
}
|
|
2660
|
-
from: `prop-test`
|
|
2633
|
+
}
|
|
2661
2634
|
});
|
|
2662
2635
|
});
|
|
2663
2636
|
scenario.expectWebhook();
|
|
@@ -2969,12 +2942,12 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2969
2942
|
name: `sp-send-worker`,
|
|
2970
2943
|
description: `Test entity type for SP send format`,
|
|
2971
2944
|
creation_schema: { type: `object` }
|
|
2972
|
-
}).spawn(`sp-send-worker`, `entity-1`).send({ text: `hello world` }
|
|
2945
|
+
}).spawn(`sp-send-worker`, `entity-1`).send({ text: `hello world` }).expectWebhook().respondDone().readStream().custom(async (ctx) => {
|
|
2973
2946
|
const events = ctx.lastStreamMessages;
|
|
2974
|
-
const msgEvent = events.find((e) => e.type === `
|
|
2975
|
-
(0, vitest.expect)(msgEvent.type).toBe(`
|
|
2947
|
+
const msgEvent = events.find((e) => e.type === `inbox`);
|
|
2948
|
+
(0, vitest.expect)(msgEvent.type).toBe(`inbox`);
|
|
2976
2949
|
(0, vitest.expect)(msgEvent.key).toBeDefined();
|
|
2977
|
-
(0, vitest.expect)(msgEvent.value?.from).
|
|
2950
|
+
(0, vitest.expect)(msgEvent.value?.from).toMatch(/^\/principal\//);
|
|
2978
2951
|
(0, vitest.expect)(msgEvent.value?.payload).toEqual({ text: `hello world` });
|
|
2979
2952
|
(0, vitest.expect)(msgEvent.headers).toBeDefined();
|
|
2980
2953
|
}).run());
|
|
@@ -2982,9 +2955,9 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2982
2955
|
name: `sp-inv-worker`,
|
|
2983
2956
|
description: `Test entity type for SP invariant checks`,
|
|
2984
2957
|
creation_schema: { type: `object` }
|
|
2985
|
-
}).spawn(`sp-inv-worker`, `entity-1`).send({ text: `first` }
|
|
2958
|
+
}).spawn(`sp-inv-worker`, `entity-1`).send({ text: `first` }).expectWebhook().respondDone().send({ text: `second` }).expectWebhook().respondDone().readStream().custom(async (ctx) => {
|
|
2986
2959
|
const events = ctx.lastStreamMessages;
|
|
2987
|
-
const messageEvents = events.filter((ev) => ev.type === `
|
|
2960
|
+
const messageEvents = events.filter((ev) => ev.type === `inbox`);
|
|
2988
2961
|
(0, vitest.expect)(messageEvents.length).toBe(2);
|
|
2989
2962
|
checkStateProtocolInvariants(events);
|
|
2990
2963
|
}).run());
|
|
@@ -2994,8 +2967,8 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2994
2967
|
name: `sp-keys-agent-${id}`,
|
|
2995
2968
|
description: `Test entity type for send key uniqueness`,
|
|
2996
2969
|
creation_schema: { type: `object` }
|
|
2997
|
-
}).spawn(`sp-keys-agent-${id}`, `entity-1`).send({ seq: 1 }
|
|
2998
|
-
const events = ctx.lastStreamMessages.filter((e) => e.type === `
|
|
2970
|
+
}).spawn(`sp-keys-agent-${id}`, `entity-1`).send({ seq: 1 }).expectWebhook().respondDone().send({ seq: 2 }).expectWebhook().respondDone().send({ seq: 3 }).expectWebhook().respondDone().readStream().custom(async (ctx) => {
|
|
2971
|
+
const events = ctx.lastStreamMessages.filter((e) => e.type === `inbox`);
|
|
2999
2972
|
(0, vitest.expect)(events.length).toBe(3);
|
|
3000
2973
|
for (let i = 0; i < 3; i++) (0, vitest.expect)(events[i].value?.payload).toEqual({ seq: i + 1 });
|
|
3001
2974
|
}).run();
|
|
@@ -3008,9 +2981,9 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
3008
2981
|
name: `flum-agent-${id}`,
|
|
3009
2982
|
description: `Test send event format for webhook parsing`,
|
|
3010
2983
|
creation_schema: { type: `object` }
|
|
3011
|
-
}).spawn(`flum-agent-${id}`, `entity-1`).send({ text: `test message for parsing` }
|
|
2984
|
+
}).spawn(`flum-agent-${id}`, `entity-1`).send({ text: `test message for parsing` }).expectWebhook().respondDone().readStream().custom(async (ctx) => {
|
|
3012
2985
|
const events = ctx.lastStreamMessages;
|
|
3013
|
-
const msgEvent = events.find((e) => e.type === `
|
|
2986
|
+
const msgEvent = events.find((e) => e.type === `inbox`);
|
|
3014
2987
|
(0, vitest.expect)(msgEvent).toBeDefined();
|
|
3015
2988
|
(0, vitest.expect)(msgEvent.value?.payload).toBeDefined();
|
|
3016
2989
|
const payload = msgEvent.value.payload;
|
|
@@ -3023,10 +2996,10 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
3023
2996
|
name: `flum-all-agent-${id}`,
|
|
3024
2997
|
description: `Test all events are SP format`,
|
|
3025
2998
|
creation_schema: { type: `object` }
|
|
3026
|
-
}).spawn(`flum-all-agent-${id}`, `entity-1`).send({ text: `verify all SP` }
|
|
2999
|
+
}).spawn(`flum-all-agent-${id}`, `entity-1`).send({ text: `verify all SP` }).expectWebhook().respondDone().readStream().custom(async (ctx) => {
|
|
3027
3000
|
const events = ctx.lastStreamMessages;
|
|
3028
3001
|
(0, vitest.expect)(events.length).toBeGreaterThanOrEqual(1);
|
|
3029
|
-
const hasMsg = events.some((e) => e.type === `
|
|
3002
|
+
const hasMsg = events.some((e) => e.type === `inbox`);
|
|
3030
3003
|
(0, vitest.expect)(hasMsg).toBe(true);
|
|
3031
3004
|
for (const ev of events) {
|
|
3032
3005
|
(0, vitest.expect)(ev.type, `every event must have type`).toBeDefined();
|
|
@@ -3071,7 +3044,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
3071
3044
|
}).spawn(`no-payload-agent-${id}`, `entity-1`).custom(async (ctx) => {
|
|
3072
3045
|
const res = await electricAgentsFetch(ctx.baseUrl, `${ctx.currentEntityUrl}/send`, {
|
|
3073
3046
|
method: `POST`,
|
|
3074
|
-
body: JSON.stringify({
|
|
3047
|
+
body: JSON.stringify({})
|
|
3075
3048
|
});
|
|
3076
3049
|
(0, vitest.expect)(res.status).toBe(400);
|
|
3077
3050
|
const body = await res.json();
|
|
@@ -3140,7 +3113,6 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
3140
3113
|
const res = await electricAgentsFetch(ctx.baseUrl, `${rev1EntityUrl}/send`, {
|
|
3141
3114
|
method: `POST`,
|
|
3142
3115
|
body: JSON.stringify({
|
|
3143
|
-
from: `tester`,
|
|
3144
3116
|
payload: { reason: `bye` },
|
|
3145
3117
|
type: `farewell`
|
|
3146
3118
|
})
|
|
@@ -3170,7 +3142,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
3170
3142
|
name: `seq-meta-agent-${id}`,
|
|
3171
3143
|
description: `Test sequential tag updates`,
|
|
3172
3144
|
creation_schema: { type: `object` }
|
|
3173
|
-
}).spawn(`seq-meta-agent-${id}`, `entity-1`).send({ trigger: `claim` }
|
|
3145
|
+
}).spawn(`seq-meta-agent-${id}`, `entity-1`).send({ trigger: `claim` }).expectWebhook().custom(async (ctx) => {
|
|
3174
3146
|
const notification = ctx.notification;
|
|
3175
3147
|
const claimRes = await fetch(notification.parsed.callback, {
|
|
3176
3148
|
method: `POST`,
|
|
@@ -3314,10 +3286,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
3314
3286
|
const res = await fetch(`${ctx.baseUrl}${routeControlPlanePath(`${ctx.currentEntityUrl}/send`)}`, {
|
|
3315
3287
|
method: `POST`,
|
|
3316
3288
|
headers: { "content-type": `application/json` },
|
|
3317
|
-
body: JSON.stringify({
|
|
3318
|
-
from: `tester`,
|
|
3319
|
-
payload: `hi`
|
|
3320
|
-
})
|
|
3289
|
+
body: JSON.stringify({ payload: `hi` })
|
|
3321
3290
|
});
|
|
3322
3291
|
(0, vitest.expect)(res.status).toBe(204);
|
|
3323
3292
|
}).expectWebhook().respondDone().run();
|
|
@@ -3449,7 +3418,7 @@ function runCliConformanceTests(config) {
|
|
|
3449
3418
|
const streamRes = await fetch(`${baseUrl}${streams.main}?offset=0000000000000000_0000000000000000`);
|
|
3450
3419
|
const events = await streamRes.json();
|
|
3451
3420
|
(0, vitest.expect)(events.length).toBeGreaterThanOrEqual(1);
|
|
3452
|
-
const msgEvent = events.find((e) => e.type === `
|
|
3421
|
+
const msgEvent = events.find((e) => e.type === `inbox`);
|
|
3453
3422
|
(0, vitest.expect)(msgEvent).toBeDefined();
|
|
3454
3423
|
const payload = msgEvent.value?.payload;
|
|
3455
3424
|
(0, vitest.expect)(payload.text).toBe(`hello world`);
|
|
@@ -3541,10 +3510,7 @@ function runMockAgentTests(config) {
|
|
|
3541
3510
|
const res = await fetch(`${baseUrl}${routeControlPlanePath(`${entityUrl}/send`)}`, {
|
|
3542
3511
|
method: `POST`,
|
|
3543
3512
|
headers: { "content-type": `application/json` },
|
|
3544
|
-
body: JSON.stringify({
|
|
3545
|
-
payload: { text },
|
|
3546
|
-
from: `tester`
|
|
3547
|
-
})
|
|
3513
|
+
body: JSON.stringify({ payload: { text } })
|
|
3548
3514
|
});
|
|
3549
3515
|
(0, vitest.expect)(res.ok || res.status === 204, `send should succeed: ${res.status}`).toBe(true);
|
|
3550
3516
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -308,12 +308,12 @@ declare class ElectricAgentsScenario {
|
|
|
308
308
|
parent?: string;
|
|
309
309
|
initialMessage?: unknown;
|
|
310
310
|
}): this;
|
|
311
|
-
send(payload: unknown, opts
|
|
312
|
-
from
|
|
311
|
+
send(payload: unknown, opts?: {
|
|
312
|
+
from?: string;
|
|
313
313
|
type?: string;
|
|
314
314
|
}): this;
|
|
315
|
-
sendTo(url: string, payload: unknown, opts
|
|
316
|
-
from
|
|
315
|
+
sendTo(url: string, payload: unknown, opts?: {
|
|
316
|
+
from?: string;
|
|
317
317
|
}): this;
|
|
318
318
|
kill(): this;
|
|
319
319
|
killUrl(url: string): this;
|
|
@@ -366,15 +366,15 @@ declare class ElectricAgentsScenario {
|
|
|
366
366
|
expectSpawnSchemaError(typeName: string, instanceId: string, opts?: {
|
|
367
367
|
args?: Record<string, unknown>;
|
|
368
368
|
}): this;
|
|
369
|
-
expectSendSchemaError(payload: unknown, opts
|
|
370
|
-
from
|
|
369
|
+
expectSendSchemaError(payload: unknown, opts?: {
|
|
370
|
+
from?: string;
|
|
371
371
|
type?: string;
|
|
372
372
|
}): this;
|
|
373
373
|
expectWriteSchemaError(payload: unknown, opts?: {
|
|
374
374
|
type?: string;
|
|
375
375
|
}): this;
|
|
376
376
|
expectSendUnknownType(payload: unknown, opts: {
|
|
377
|
-
from
|
|
377
|
+
from?: string;
|
|
378
378
|
type: string;
|
|
379
379
|
}): this;
|
|
380
380
|
expectWriteUnknownType(payload: unknown, opts: {
|
package/dist/index.d.ts
CHANGED
|
@@ -308,12 +308,12 @@ declare class ElectricAgentsScenario {
|
|
|
308
308
|
parent?: string;
|
|
309
309
|
initialMessage?: unknown;
|
|
310
310
|
}): this;
|
|
311
|
-
send(payload: unknown, opts
|
|
312
|
-
from
|
|
311
|
+
send(payload: unknown, opts?: {
|
|
312
|
+
from?: string;
|
|
313
313
|
type?: string;
|
|
314
314
|
}): this;
|
|
315
|
-
sendTo(url: string, payload: unknown, opts
|
|
316
|
-
from
|
|
315
|
+
sendTo(url: string, payload: unknown, opts?: {
|
|
316
|
+
from?: string;
|
|
317
317
|
}): this;
|
|
318
318
|
kill(): this;
|
|
319
319
|
killUrl(url: string): this;
|
|
@@ -366,15 +366,15 @@ declare class ElectricAgentsScenario {
|
|
|
366
366
|
expectSpawnSchemaError(typeName: string, instanceId: string, opts?: {
|
|
367
367
|
args?: Record<string, unknown>;
|
|
368
368
|
}): this;
|
|
369
|
-
expectSendSchemaError(payload: unknown, opts
|
|
370
|
-
from
|
|
369
|
+
expectSendSchemaError(payload: unknown, opts?: {
|
|
370
|
+
from?: string;
|
|
371
371
|
type?: string;
|
|
372
372
|
}): this;
|
|
373
373
|
expectWriteSchemaError(payload: unknown, opts?: {
|
|
374
374
|
type?: string;
|
|
375
375
|
}): this;
|
|
376
376
|
expectSendUnknownType(payload: unknown, opts: {
|
|
377
|
-
from
|
|
377
|
+
from?: string;
|
|
378
378
|
type: string;
|
|
379
379
|
}): this;
|
|
380
380
|
expectWriteUnknownType(payload: unknown, opts: {
|
package/dist/index.js
CHANGED
|
@@ -229,8 +229,8 @@ var ElectricAgentsScenario = class {
|
|
|
229
229
|
this.steps.push({
|
|
230
230
|
kind: `send`,
|
|
231
231
|
payload,
|
|
232
|
-
from: opts
|
|
233
|
-
type: opts
|
|
232
|
+
from: opts?.from,
|
|
233
|
+
type: opts?.type
|
|
234
234
|
});
|
|
235
235
|
return this;
|
|
236
236
|
}
|
|
@@ -239,7 +239,7 @@ var ElectricAgentsScenario = class {
|
|
|
239
239
|
kind: `sendTo`,
|
|
240
240
|
url,
|
|
241
241
|
payload,
|
|
242
|
-
from: opts
|
|
242
|
+
from: opts?.from
|
|
243
243
|
});
|
|
244
244
|
return this;
|
|
245
245
|
}
|
|
@@ -431,7 +431,7 @@ var ElectricAgentsScenario = class {
|
|
|
431
431
|
this.steps.push({
|
|
432
432
|
kind: `expectSendSchemaError`,
|
|
433
433
|
payload,
|
|
434
|
-
messageType: opts
|
|
434
|
+
messageType: opts?.type ?? `default`,
|
|
435
435
|
code: `SCHEMA_VALIDATION_ERROR`,
|
|
436
436
|
status: 422
|
|
437
437
|
});
|
|
@@ -732,10 +732,7 @@ async function executeStep(ctx, step) {
|
|
|
732
732
|
if (!ctx.currentEntityUrl) throw new Error(`No current entity`);
|
|
733
733
|
const res = await electricAgentsFetch$1(ctx.baseUrl, `${ctx.currentEntityUrl}/send`, {
|
|
734
734
|
method: `POST`,
|
|
735
|
-
body: JSON.stringify({
|
|
736
|
-
from: `test`,
|
|
737
|
-
payload: { should: `fail` }
|
|
738
|
-
})
|
|
735
|
+
body: JSON.stringify({ payload: { should: `fail` } })
|
|
739
736
|
});
|
|
740
737
|
expect(res.status).toBe(step.status);
|
|
741
738
|
const body = await res.json();
|
|
@@ -1820,26 +1817,23 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
1820
1817
|
name: `send-test-worker`,
|
|
1821
1818
|
description: `Test entity type for send`,
|
|
1822
1819
|
creation_schema: { type: `object` }
|
|
1823
|
-
}).spawn(`send-test-worker`, `entity-1`).send({ task: `hello` }
|
|
1824
|
-
const envelope = ctx.lastStreamMessages.find((m) => m.type === `
|
|
1825
|
-
expect(envelope.type).toBe(`
|
|
1820
|
+
}).spawn(`send-test-worker`, `entity-1`).send({ task: `hello` }).expectWebhook().respondDone().readStream().expectStreamContains(`inbox`).custom(async (ctx) => {
|
|
1821
|
+
const envelope = ctx.lastStreamMessages.find((m) => m.type === `inbox`);
|
|
1822
|
+
expect(envelope.type).toBe(`inbox`);
|
|
1826
1823
|
expect(envelope.key).toBeDefined();
|
|
1827
|
-
expect(envelope.value?.from).
|
|
1824
|
+
expect(envelope.value?.from).toMatch(/^\/principal\//);
|
|
1828
1825
|
expect(envelope.value?.payload).toEqual({ task: `hello` });
|
|
1829
1826
|
}).run());
|
|
1830
1827
|
test(`send triggers webhook with entity context`, () => electricAgents(config.baseUrl).subscription(`/webhook-ctx-agent/**`, `webhook-ctx-sub`).registerType({
|
|
1831
1828
|
name: `webhook-ctx-agent`,
|
|
1832
1829
|
description: `Test entity type for webhook context`,
|
|
1833
1830
|
creation_schema: { type: `object` }
|
|
1834
|
-
}).spawn(`webhook-ctx-agent`, `entity-1`).send({ ping: true }
|
|
1831
|
+
}).spawn(`webhook-ctx-agent`, `entity-1`).send({ ping: true }).expectWebhook().expectEntityContext({ type: `webhook-ctx-agent` }).respondDone().run());
|
|
1835
1832
|
test(`send to nonexistent entity returns 404`, () => electricAgents(config.baseUrl).custom(async (ctx) => {
|
|
1836
1833
|
const res = await fetch(`${ctx.baseUrl}${routeControlPlanePath(`/nonexistent-type/nonexistent-id/send`)}`, {
|
|
1837
1834
|
method: `POST`,
|
|
1838
1835
|
headers: { "content-type": `application/json` },
|
|
1839
|
-
body: JSON.stringify({
|
|
1840
|
-
from: `test`,
|
|
1841
|
-
payload: {}
|
|
1842
|
-
})
|
|
1836
|
+
body: JSON.stringify({ payload: {} })
|
|
1843
1837
|
});
|
|
1844
1838
|
expect(res.status).toBe(404);
|
|
1845
1839
|
}).skipInvariants().run());
|
|
@@ -1849,13 +1843,13 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
1849
1843
|
name: `order-test-agent-${id}`,
|
|
1850
1844
|
description: `Test entity type for ordering`,
|
|
1851
1845
|
creation_schema: { type: `object` }
|
|
1852
|
-
}).spawn(`order-test-agent-${id}`, `entity-1`).send({ seq: 1 }
|
|
1853
|
-
const msgs = ctx.lastStreamMessages.filter((m) => m.type === `
|
|
1846
|
+
}).spawn(`order-test-agent-${id}`, `entity-1`).send({ seq: 1 }).expectWebhook().respondDone().send({ seq: 2 }).expectWebhook().respondDone().send({ seq: 3 }).expectWebhook().respondDone().readStream().custom(async (ctx) => {
|
|
1847
|
+
const msgs = ctx.lastStreamMessages.filter((m) => m.type === `inbox`);
|
|
1854
1848
|
expect(msgs.length).toBe(3);
|
|
1855
1849
|
for (let i = 0; i < 3; i++) expect(msgs[i].value?.payload).toEqual({ seq: i + 1 });
|
|
1856
1850
|
}).run();
|
|
1857
1851
|
});
|
|
1858
|
-
test(`send without from
|
|
1852
|
+
test(`send without from uses principal`, () => electricAgents(config.baseUrl).subscription(`/nofrom-test-agent/**`, `nofrom-test-sub`).registerType({
|
|
1859
1853
|
name: `nofrom-test-agent`,
|
|
1860
1854
|
description: `Test entity type for send without from`,
|
|
1861
1855
|
creation_schema: { type: `object` }
|
|
@@ -1864,10 +1858,8 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
1864
1858
|
method: `POST`,
|
|
1865
1859
|
body: JSON.stringify({ payload: { hello: true } })
|
|
1866
1860
|
});
|
|
1867
|
-
expect(res.status).toBe(
|
|
1868
|
-
|
|
1869
|
-
expect(body.error.code).toBe(`INVALID_REQUEST`);
|
|
1870
|
-
}).run());
|
|
1861
|
+
expect(res.status).toBe(204);
|
|
1862
|
+
}).expectWebhook().respondDone().run());
|
|
1871
1863
|
});
|
|
1872
1864
|
describe(`Electric Agents List`, () => {
|
|
1873
1865
|
test(`ps lists entities`, () => electricAgents(config.baseUrl).subscription(`/ps-test-worker/**`, `ps-test-worker-sub`).subscription(`/ps-test-agent/**`, `ps-test-agent-sub`).registerType({
|
|
@@ -1907,9 +1899,9 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
1907
1899
|
name: `kill-persist-agent`,
|
|
1908
1900
|
description: `Test entity type for kill persistence`,
|
|
1909
1901
|
creation_schema: { type: `object` }
|
|
1910
|
-
}).spawn(`kill-persist-agent`, `entity-1`).send({ before: `kill` }
|
|
1902
|
+
}).spawn(`kill-persist-agent`, `entity-1`).send({ before: `kill` }).expectWebhook().respondDone().kill().readStream().expectStreamContains(`inbox`).custom(async (ctx) => {
|
|
1911
1903
|
const msgs = ctx.lastStreamMessages;
|
|
1912
|
-
const msgReceived = msgs.find((m) => m.type === `
|
|
1904
|
+
const msgReceived = msgs.find((m) => m.type === `inbox`);
|
|
1913
1905
|
expect(msgReceived.value?.payload).toEqual({ before: `kill` });
|
|
1914
1906
|
const stopped = msgs.find((m) => m.type === `entity_stopped`);
|
|
1915
1907
|
expect(stopped).toBeDefined();
|
|
@@ -1947,7 +1939,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
1947
1939
|
name: `e2e-test-agent`,
|
|
1948
1940
|
description: `Test entity type for E2E lifecycle`,
|
|
1949
1941
|
creation_schema: { type: `object` }
|
|
1950
|
-
}).spawn(`e2e-test-agent`, `entity-1`).expectStatus(`running`).send({ task: `do-something` }
|
|
1942
|
+
}).spawn(`e2e-test-agent`, `entity-1`).expectStatus(`running`).send({ task: `do-something` }).expectWebhook().expectEntityContext({ type: `e2e-test-agent` }).respondDone().readStream().expectStreamContains(`inbox`).kill().custom(async (ctx) => {
|
|
1951
1943
|
const entity = await pollEntityStatus(ctx.baseUrl, ctx.currentEntityUrl, [`stopped`]);
|
|
1952
1944
|
expect(entity.status).toBe(`stopped`);
|
|
1953
1945
|
}).expectSendError(`NOT_RUNNING`, 409).run());
|
|
@@ -2202,10 +2194,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2202
2194
|
properties: { text: { type: `string` } },
|
|
2203
2195
|
required: [`text`]
|
|
2204
2196
|
} }
|
|
2205
|
-
}).spawn(typeName, `entity-1`).send({ text: `hello` }, {
|
|
2206
|
-
from: `user`,
|
|
2207
|
-
type: `query`
|
|
2208
|
-
}).expectWebhook().respondDone().run();
|
|
2197
|
+
}).spawn(typeName, `entity-1`).send({ text: `hello` }, { type: `query` }).expectWebhook().respondDone().run();
|
|
2209
2198
|
});
|
|
2210
2199
|
test(`send rejects invalid typed message (C11)`, () => {
|
|
2211
2200
|
const typeName = `send-schema-inv-${Date.now()}`;
|
|
@@ -2218,10 +2207,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2218
2207
|
properties: { text: { type: `string` } },
|
|
2219
2208
|
required: [`text`]
|
|
2220
2209
|
} }
|
|
2221
|
-
}).spawn(typeName, `entity-1`).expectSendSchemaError({ invalid: true }, {
|
|
2222
|
-
from: `user`,
|
|
2223
|
-
type: `query`
|
|
2224
|
-
}).run();
|
|
2210
|
+
}).spawn(typeName, `entity-1`).expectSendSchemaError({ invalid: true }, { type: `query` }).run();
|
|
2225
2211
|
});
|
|
2226
2212
|
test(`send rejects unknown message type (C13)`, () => {
|
|
2227
2213
|
const typeName = `send-unknown-type-${Date.now()}`;
|
|
@@ -2234,10 +2220,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2234
2220
|
properties: { text: { type: `string` } },
|
|
2235
2221
|
required: [`text`]
|
|
2236
2222
|
} }
|
|
2237
|
-
}).spawn(typeName, `entity-1`).expectSendUnknownType({ text: `hi` }, {
|
|
2238
|
-
from: `user`,
|
|
2239
|
-
type: `unknown_type`
|
|
2240
|
-
}).run();
|
|
2223
|
+
}).spawn(typeName, `entity-1`).expectSendUnknownType({ text: `hi` }, { type: `unknown_type` }).run();
|
|
2241
2224
|
});
|
|
2242
2225
|
test(`send without type when no input_schemas accepts any`, () => {
|
|
2243
2226
|
const typeName = `send-no-schemas-${Date.now()}`;
|
|
@@ -2245,7 +2228,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2245
2228
|
name: typeName,
|
|
2246
2229
|
description: `Type without input schemas`,
|
|
2247
2230
|
creation_schema: { type: `object` }
|
|
2248
|
-
}).spawn(typeName, `entity-1`).send({ anything: `goes` }
|
|
2231
|
+
}).spawn(typeName, `entity-1`).send({ anything: `goes` }).expectWebhook().respondDone().run();
|
|
2249
2232
|
});
|
|
2250
2233
|
test(`send with empty input_schemas rejects all`, () => {
|
|
2251
2234
|
const typeName = `send-empty-schemas-${Date.now()}`;
|
|
@@ -2254,10 +2237,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2254
2237
|
description: `Type with empty input schemas`,
|
|
2255
2238
|
creation_schema: { type: `object` },
|
|
2256
2239
|
input_schemas: {}
|
|
2257
|
-
}).spawn(typeName, `entity-1`).expectSendUnknownType({ text: `anything` }, {
|
|
2258
|
-
from: `user`,
|
|
2259
|
-
type: `some_type`
|
|
2260
|
-
}).run();
|
|
2240
|
+
}).spawn(typeName, `entity-1`).expectSendUnknownType({ text: `anything` }, { type: `some_type` }).run();
|
|
2261
2241
|
});
|
|
2262
2242
|
test.skip(`write appends event to entity stream`, () => {
|
|
2263
2243
|
const typeName = `write-append-${Date.now()}`;
|
|
@@ -2432,10 +2412,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2432
2412
|
type: `object`,
|
|
2433
2413
|
properties: { action: { type: `string` } },
|
|
2434
2414
|
required: [`action`]
|
|
2435
|
-
} } }).spawn(typeName, `entity-1`).send({ action: `do-it` }, {
|
|
2436
|
-
from: `user`,
|
|
2437
|
-
type: `command`
|
|
2438
|
-
}).expectWebhook().respondDone().run();
|
|
2415
|
+
} } }).spawn(typeName, `entity-1`).send({ action: `do-it` }, { type: `command` }).expectWebhook().respondDone().run();
|
|
2439
2416
|
});
|
|
2440
2417
|
test(`amend schemas rejects modifying existing keys (C16)`, () => {
|
|
2441
2418
|
const typeName = `amend-conflict-${Date.now()}`;
|
|
@@ -2617,13 +2594,10 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2617
2594
|
if (!url) return;
|
|
2618
2595
|
const res = await electricAgentsFetch(ctx.baseUrl, `${url}/send`, {
|
|
2619
2596
|
method: `POST`,
|
|
2620
|
-
body: JSON.stringify({
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
targetIdx
|
|
2625
|
-
}
|
|
2626
|
-
})
|
|
2597
|
+
body: JSON.stringify({ payload: {
|
|
2598
|
+
action: `prop-send`,
|
|
2599
|
+
targetIdx
|
|
2600
|
+
} })
|
|
2627
2601
|
});
|
|
2628
2602
|
expect(res.status).toBe(204);
|
|
2629
2603
|
ctx.history.push({
|
|
@@ -2632,8 +2606,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2632
2606
|
payload: {
|
|
2633
2607
|
action: `prop-send`,
|
|
2634
2608
|
targetIdx
|
|
2635
|
-
}
|
|
2636
|
-
from: `prop-test`
|
|
2609
|
+
}
|
|
2637
2610
|
});
|
|
2638
2611
|
});
|
|
2639
2612
|
scenario.expectWebhook();
|
|
@@ -2945,12 +2918,12 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2945
2918
|
name: `sp-send-worker`,
|
|
2946
2919
|
description: `Test entity type for SP send format`,
|
|
2947
2920
|
creation_schema: { type: `object` }
|
|
2948
|
-
}).spawn(`sp-send-worker`, `entity-1`).send({ text: `hello world` }
|
|
2921
|
+
}).spawn(`sp-send-worker`, `entity-1`).send({ text: `hello world` }).expectWebhook().respondDone().readStream().custom(async (ctx) => {
|
|
2949
2922
|
const events = ctx.lastStreamMessages;
|
|
2950
|
-
const msgEvent = events.find((e) => e.type === `
|
|
2951
|
-
expect(msgEvent.type).toBe(`
|
|
2923
|
+
const msgEvent = events.find((e) => e.type === `inbox`);
|
|
2924
|
+
expect(msgEvent.type).toBe(`inbox`);
|
|
2952
2925
|
expect(msgEvent.key).toBeDefined();
|
|
2953
|
-
expect(msgEvent.value?.from).
|
|
2926
|
+
expect(msgEvent.value?.from).toMatch(/^\/principal\//);
|
|
2954
2927
|
expect(msgEvent.value?.payload).toEqual({ text: `hello world` });
|
|
2955
2928
|
expect(msgEvent.headers).toBeDefined();
|
|
2956
2929
|
}).run());
|
|
@@ -2958,9 +2931,9 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2958
2931
|
name: `sp-inv-worker`,
|
|
2959
2932
|
description: `Test entity type for SP invariant checks`,
|
|
2960
2933
|
creation_schema: { type: `object` }
|
|
2961
|
-
}).spawn(`sp-inv-worker`, `entity-1`).send({ text: `first` }
|
|
2934
|
+
}).spawn(`sp-inv-worker`, `entity-1`).send({ text: `first` }).expectWebhook().respondDone().send({ text: `second` }).expectWebhook().respondDone().readStream().custom(async (ctx) => {
|
|
2962
2935
|
const events = ctx.lastStreamMessages;
|
|
2963
|
-
const messageEvents = events.filter((ev) => ev.type === `
|
|
2936
|
+
const messageEvents = events.filter((ev) => ev.type === `inbox`);
|
|
2964
2937
|
expect(messageEvents.length).toBe(2);
|
|
2965
2938
|
checkStateProtocolInvariants(events);
|
|
2966
2939
|
}).run());
|
|
@@ -2970,8 +2943,8 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2970
2943
|
name: `sp-keys-agent-${id}`,
|
|
2971
2944
|
description: `Test entity type for send key uniqueness`,
|
|
2972
2945
|
creation_schema: { type: `object` }
|
|
2973
|
-
}).spawn(`sp-keys-agent-${id}`, `entity-1`).send({ seq: 1 }
|
|
2974
|
-
const events = ctx.lastStreamMessages.filter((e) => e.type === `
|
|
2946
|
+
}).spawn(`sp-keys-agent-${id}`, `entity-1`).send({ seq: 1 }).expectWebhook().respondDone().send({ seq: 2 }).expectWebhook().respondDone().send({ seq: 3 }).expectWebhook().respondDone().readStream().custom(async (ctx) => {
|
|
2947
|
+
const events = ctx.lastStreamMessages.filter((e) => e.type === `inbox`);
|
|
2975
2948
|
expect(events.length).toBe(3);
|
|
2976
2949
|
for (let i = 0; i < 3; i++) expect(events[i].value?.payload).toEqual({ seq: i + 1 });
|
|
2977
2950
|
}).run();
|
|
@@ -2984,9 +2957,9 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2984
2957
|
name: `flum-agent-${id}`,
|
|
2985
2958
|
description: `Test send event format for webhook parsing`,
|
|
2986
2959
|
creation_schema: { type: `object` }
|
|
2987
|
-
}).spawn(`flum-agent-${id}`, `entity-1`).send({ text: `test message for parsing` }
|
|
2960
|
+
}).spawn(`flum-agent-${id}`, `entity-1`).send({ text: `test message for parsing` }).expectWebhook().respondDone().readStream().custom(async (ctx) => {
|
|
2988
2961
|
const events = ctx.lastStreamMessages;
|
|
2989
|
-
const msgEvent = events.find((e) => e.type === `
|
|
2962
|
+
const msgEvent = events.find((e) => e.type === `inbox`);
|
|
2990
2963
|
expect(msgEvent).toBeDefined();
|
|
2991
2964
|
expect(msgEvent.value?.payload).toBeDefined();
|
|
2992
2965
|
const payload = msgEvent.value.payload;
|
|
@@ -2999,10 +2972,10 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
2999
2972
|
name: `flum-all-agent-${id}`,
|
|
3000
2973
|
description: `Test all events are SP format`,
|
|
3001
2974
|
creation_schema: { type: `object` }
|
|
3002
|
-
}).spawn(`flum-all-agent-${id}`, `entity-1`).send({ text: `verify all SP` }
|
|
2975
|
+
}).spawn(`flum-all-agent-${id}`, `entity-1`).send({ text: `verify all SP` }).expectWebhook().respondDone().readStream().custom(async (ctx) => {
|
|
3003
2976
|
const events = ctx.lastStreamMessages;
|
|
3004
2977
|
expect(events.length).toBeGreaterThanOrEqual(1);
|
|
3005
|
-
const hasMsg = events.some((e) => e.type === `
|
|
2978
|
+
const hasMsg = events.some((e) => e.type === `inbox`);
|
|
3006
2979
|
expect(hasMsg).toBe(true);
|
|
3007
2980
|
for (const ev of events) {
|
|
3008
2981
|
expect(ev.type, `every event must have type`).toBeDefined();
|
|
@@ -3047,7 +3020,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
3047
3020
|
}).spawn(`no-payload-agent-${id}`, `entity-1`).custom(async (ctx) => {
|
|
3048
3021
|
const res = await electricAgentsFetch(ctx.baseUrl, `${ctx.currentEntityUrl}/send`, {
|
|
3049
3022
|
method: `POST`,
|
|
3050
|
-
body: JSON.stringify({
|
|
3023
|
+
body: JSON.stringify({})
|
|
3051
3024
|
});
|
|
3052
3025
|
expect(res.status).toBe(400);
|
|
3053
3026
|
const body = await res.json();
|
|
@@ -3116,7 +3089,6 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
3116
3089
|
const res = await electricAgentsFetch(ctx.baseUrl, `${rev1EntityUrl}/send`, {
|
|
3117
3090
|
method: `POST`,
|
|
3118
3091
|
body: JSON.stringify({
|
|
3119
|
-
from: `tester`,
|
|
3120
3092
|
payload: { reason: `bye` },
|
|
3121
3093
|
type: `farewell`
|
|
3122
3094
|
})
|
|
@@ -3146,7 +3118,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
3146
3118
|
name: `seq-meta-agent-${id}`,
|
|
3147
3119
|
description: `Test sequential tag updates`,
|
|
3148
3120
|
creation_schema: { type: `object` }
|
|
3149
|
-
}).spawn(`seq-meta-agent-${id}`, `entity-1`).send({ trigger: `claim` }
|
|
3121
|
+
}).spawn(`seq-meta-agent-${id}`, `entity-1`).send({ trigger: `claim` }).expectWebhook().custom(async (ctx) => {
|
|
3150
3122
|
const notification = ctx.notification;
|
|
3151
3123
|
const claimRes = await fetch(notification.parsed.callback, {
|
|
3152
3124
|
method: `POST`,
|
|
@@ -3290,10 +3262,7 @@ function runElectricAgentsConformanceTests(config) {
|
|
|
3290
3262
|
const res = await fetch(`${ctx.baseUrl}${routeControlPlanePath(`${ctx.currentEntityUrl}/send`)}`, {
|
|
3291
3263
|
method: `POST`,
|
|
3292
3264
|
headers: { "content-type": `application/json` },
|
|
3293
|
-
body: JSON.stringify({
|
|
3294
|
-
from: `tester`,
|
|
3295
|
-
payload: `hi`
|
|
3296
|
-
})
|
|
3265
|
+
body: JSON.stringify({ payload: `hi` })
|
|
3297
3266
|
});
|
|
3298
3267
|
expect(res.status).toBe(204);
|
|
3299
3268
|
}).expectWebhook().respondDone().run();
|
|
@@ -3425,7 +3394,7 @@ function runCliConformanceTests(config) {
|
|
|
3425
3394
|
const streamRes = await fetch(`${baseUrl}${streams.main}?offset=0000000000000000_0000000000000000`);
|
|
3426
3395
|
const events = await streamRes.json();
|
|
3427
3396
|
expect(events.length).toBeGreaterThanOrEqual(1);
|
|
3428
|
-
const msgEvent = events.find((e) => e.type === `
|
|
3397
|
+
const msgEvent = events.find((e) => e.type === `inbox`);
|
|
3429
3398
|
expect(msgEvent).toBeDefined();
|
|
3430
3399
|
const payload = msgEvent.value?.payload;
|
|
3431
3400
|
expect(payload.text).toBe(`hello world`);
|
|
@@ -3517,10 +3486,7 @@ function runMockAgentTests(config) {
|
|
|
3517
3486
|
const res = await fetch(`${baseUrl}${routeControlPlanePath(`${entityUrl}/send`)}`, {
|
|
3518
3487
|
method: `POST`,
|
|
3519
3488
|
headers: { "content-type": `application/json` },
|
|
3520
|
-
body: JSON.stringify({
|
|
3521
|
-
payload: { text },
|
|
3522
|
-
from: `tester`
|
|
3523
|
-
})
|
|
3489
|
+
body: JSON.stringify({ payload: { text } })
|
|
3524
3490
|
});
|
|
3525
3491
|
expect(res.ok || res.status === 204, `send should succeed: ${res.status}`).toBe(true);
|
|
3526
3492
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@electric-ax/agents-server-conformance-tests",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Conformance test suite for Electric Agents server implementations",
|
|
5
5
|
"author": "Durable Stream contributors",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@mariozechner/pi-agent-core": "^0.70.2",
|
|
44
44
|
"tsdown": "^0.9.0",
|
|
45
45
|
"typescript": "^5.0.0",
|
|
46
|
-
"@electric-ax/agents-server": "0.
|
|
46
|
+
"@electric-ax/agents-server": "0.4.1"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=18.0.0"
|