@amodalai/runtime 0.2.9 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/__fixtures__/e2e.test.js +2 -2
- package/dist/src/__fixtures__/e2e.test.js.map +1 -1
- package/dist/src/__fixtures__/smoke.test.js +0 -88
- package/dist/src/__fixtures__/smoke.test.js.map +1 -1
- package/dist/src/__tests__/studio-integration.test.js +298 -0
- package/dist/src/__tests__/studio-integration.test.js.map +1 -0
- package/dist/src/agent/agent-types.d.ts +4 -0
- package/dist/src/agent/feedback-store.d.ts +11 -10
- package/dist/src/agent/feedback-store.js +147 -75
- package/dist/src/agent/feedback-store.js.map +1 -1
- package/dist/src/agent/local-server.js +30 -111
- package/dist/src/agent/local-server.js.map +1 -1
- package/dist/src/agent/local-server.test.js +17 -1
- package/dist/src/agent/local-server.test.js.map +1 -1
- package/dist/src/agent/routes/context.d.ts +24 -0
- package/dist/src/agent/routes/context.js +30 -0
- package/dist/src/agent/routes/context.js.map +1 -0
- package/dist/src/agent/routes/feedback.js +28 -56
- package/dist/src/agent/routes/feedback.js.map +1 -1
- package/dist/src/api/create-agent.js +8 -4
- package/dist/src/api/create-agent.js.map +1 -1
- package/dist/src/api/types.d.ts +1 -1
- package/dist/src/channels/channel-session-mapper.js +1 -1
- package/dist/src/channels/channel-session-mapper.js.map +1 -1
- package/dist/src/config.d.ts +2 -2
- package/dist/src/config.js +2 -1
- package/dist/src/config.js.map +1 -1
- package/dist/src/config.test.js +1 -1
- package/dist/src/config.test.js.map +1 -1
- package/dist/src/errors.d.ts +2 -2
- package/dist/src/errors.js +2 -2
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.js +0 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/server.d.ts +2 -0
- package/dist/src/server.js +1 -0
- package/dist/src/server.js.map +1 -1
- package/dist/src/session/drizzle-session-store.d.ts +4 -6
- package/dist/src/session/drizzle-session-store.js +15 -5
- package/dist/src/session/drizzle-session-store.js.map +1 -1
- package/dist/src/session/manager.js +1 -1
- package/dist/src/session/manager.test.js +7 -5
- package/dist/src/session/manager.test.js.map +1 -1
- package/dist/src/session/postgres-session-store.d.ts +3 -24
- package/dist/src/session/postgres-session-store.js +9 -128
- package/dist/src/session/postgres-session-store.js.map +1 -1
- package/dist/src/session/session-builder.d.ts +0 -4
- package/dist/src/session/session-builder.js +2 -9
- package/dist/src/session/session-builder.js.map +1 -1
- package/dist/src/session/session-builder.test.js +0 -25
- package/dist/src/session/session-builder.test.js.map +1 -1
- package/dist/src/session/session-store-selector.d.ts +11 -26
- package/dist/src/session/session-store-selector.js +3 -48
- package/dist/src/session/session-store-selector.js.map +1 -1
- package/dist/src/session/session-store-selector.test.js +5 -57
- package/dist/src/session/session-store-selector.test.js.map +1 -1
- package/dist/src/session/store.d.ts +8 -14
- package/dist/src/session/store.js +8 -10
- package/dist/src/session/store.js.map +1 -1
- package/dist/src/session/store.test.js +6 -126
- package/dist/src/session/store.test.js.map +1 -1
- package/dist/src/session/tool-context-factory.js +1 -1
- package/dist/src/session/tool-context-factory.js.map +1 -1
- package/dist/src/stores/drizzle-store-backend.d.ts +5 -0
- package/dist/src/stores/drizzle-store-backend.js +23 -3
- package/dist/src/stores/drizzle-store-backend.js.map +1 -1
- package/dist/src/stores/drizzle-store-backend.test.js +10 -58
- package/dist/src/stores/drizzle-store-backend.test.js.map +1 -1
- package/dist/src/stores/index.d.ts +0 -2
- package/dist/src/stores/index.js +0 -1
- package/dist/src/stores/index.js.map +1 -1
- package/dist/src/stores/postgres-store-backend.d.ts +5 -15
- package/dist/src/stores/postgres-store-backend.js +14 -72
- package/dist/src/stores/postgres-store-backend.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -6
- package/dist/src/agent/automation-bridge.d.ts +0 -33
- package/dist/src/agent/automation-bridge.js +0 -50
- package/dist/src/agent/automation-bridge.js.map +0 -1
- package/dist/src/agent/automation-bridge.test.d.ts +0 -6
- package/dist/src/agent/automation-bridge.test.js +0 -130
- package/dist/src/agent/automation-bridge.test.js.map +0 -1
- package/dist/src/agent/eval-store.d.ts +0 -50
- package/dist/src/agent/eval-store.js +0 -137
- package/dist/src/agent/eval-store.js.map +0 -1
- package/dist/src/agent/proactive/delivery-router.d.ts +0 -68
- package/dist/src/agent/proactive/delivery-router.js +0 -337
- package/dist/src/agent/proactive/delivery-router.js.map +0 -1
- package/dist/src/agent/proactive/delivery-router.test.js +0 -455
- package/dist/src/agent/proactive/delivery-router.test.js.map +0 -1
- package/dist/src/agent/proactive/delivery.d.ts +0 -21
- package/dist/src/agent/proactive/delivery.js +0 -68
- package/dist/src/agent/proactive/delivery.js.map +0 -1
- package/dist/src/agent/proactive/delivery.test.d.ts +0 -6
- package/dist/src/agent/proactive/delivery.test.js +0 -65
- package/dist/src/agent/proactive/delivery.test.js.map +0 -1
- package/dist/src/agent/proactive/proactive-runner.d.ts +0 -129
- package/dist/src/agent/proactive/proactive-runner.js +0 -301
- package/dist/src/agent/proactive/proactive-runner.js.map +0 -1
- package/dist/src/agent/proactive/proactive-runner.test.d.ts +0 -6
- package/dist/src/agent/proactive/proactive-runner.test.js +0 -250
- package/dist/src/agent/proactive/proactive-runner.test.js.map +0 -1
- package/dist/src/agent/routes/admin-chat-abort.test.d.ts +0 -6
- package/dist/src/agent/routes/admin-chat-abort.test.js +0 -207
- package/dist/src/agent/routes/admin-chat-abort.test.js.map +0 -1
- package/dist/src/agent/routes/admin-chat.d.ts +0 -28
- package/dist/src/agent/routes/admin-chat.js +0 -110
- package/dist/src/agent/routes/admin-chat.js.map +0 -1
- package/dist/src/agent/routes/automations.d.ts +0 -19
- package/dist/src/agent/routes/automations.js +0 -86
- package/dist/src/agent/routes/automations.js.map +0 -1
- package/dist/src/agent/routes/automations.test.d.ts +0 -6
- package/dist/src/agent/routes/automations.test.js +0 -117
- package/dist/src/agent/routes/automations.test.js.map +0 -1
- package/dist/src/agent/routes/evals.d.ts +0 -17
- package/dist/src/agent/routes/evals.js +0 -389
- package/dist/src/agent/routes/evals.js.map +0 -1
- package/dist/src/agent/routes/webhooks.d.ts +0 -17
- package/dist/src/agent/routes/webhooks.js +0 -63
- package/dist/src/agent/routes/webhooks.js.map +0 -1
- package/dist/src/agent/routes/webhooks.test.d.ts +0 -6
- package/dist/src/agent/routes/webhooks.test.js +0 -100
- package/dist/src/agent/routes/webhooks.test.js.map +0 -1
- package/dist/src/session/pglite-session-store.d.ts +0 -23
- package/dist/src/session/pglite-session-store.js +0 -92
- package/dist/src/session/pglite-session-store.js.map +0 -1
- package/dist/src/stores/pglite-store-backend.d.ts +0 -39
- package/dist/src/stores/pglite-store-backend.js +0 -128
- package/dist/src/stores/pglite-store-backend.js.map +0 -1
- package/dist/src/stores/pglite-store-backend.test.d.ts +0 -6
- package/dist/src/stores/pglite-store-backend.test.js +0 -150
- package/dist/src/stores/pglite-store-backend.test.js.map +0 -1
- package/dist/src/stores/schema.d.ts +0 -593
- package/dist/src/stores/schema.js +0 -75
- package/dist/src/stores/schema.js.map +0 -1
- package/dist/src/tools/admin-file-tools.d.ts +0 -42
- package/dist/src/tools/admin-file-tools.js +0 -714
- package/dist/src/tools/admin-file-tools.js.map +0 -1
- package/dist/src/tools/admin-file-tools.test.d.ts +0 -6
- package/dist/src/tools/admin-file-tools.test.js +0 -523
- package/dist/src/tools/admin-file-tools.test.js.map +0 -1
- /package/dist/src/{agent/proactive/delivery-router.test.d.ts → __tests__/studio-integration.test.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amodalai/runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Agent Runtime Platform — HTTP server for repo and platform modes",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"@ai-sdk/google": "^3.0.58",
|
|
23
23
|
"@ai-sdk/openai": "^3.0.50",
|
|
24
24
|
"@anthropic-ai/sdk": "^0.39.0",
|
|
25
|
-
"@electric-sql/pglite": "^0.3.15",
|
|
26
25
|
"@mozilla/readability": "^0.6.0",
|
|
27
26
|
"ai": "^6.0.145",
|
|
28
27
|
"drizzle-orm": "^0.45.2",
|
|
@@ -32,16 +31,15 @@
|
|
|
32
31
|
"glob": "^10.5.0",
|
|
33
32
|
"jose": "^6.0.0",
|
|
34
33
|
"linkedom": "^0.18.12",
|
|
35
|
-
"node-cron": "^3.0.3",
|
|
36
34
|
"pg": "^8.13.1",
|
|
37
35
|
"zod": "^3.25.0",
|
|
38
36
|
"zod-to-json-schema": "^3.25.2",
|
|
39
|
-
"@amodalai/
|
|
40
|
-
"@amodalai/
|
|
37
|
+
"@amodalai/core": "0.3.0",
|
|
38
|
+
"@amodalai/db": "0.0.0",
|
|
39
|
+
"@amodalai/types": "0.3.0"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
43
42
|
"@types/express": "^4.17.21",
|
|
44
|
-
"@types/node-cron": "^3.0.11",
|
|
45
43
|
"@types/pg": "^8.11.10",
|
|
46
44
|
"@types/supertest": "^6.0.2",
|
|
47
45
|
"@vitest/coverage-v8": "^3.1.1",
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Amodal Labs, Inc.
|
|
4
|
-
* SPDX-License-Identifier: MIT
|
|
5
|
-
*/
|
|
6
|
-
import type { LoadedAutomation } from '@amodalai/core';
|
|
7
|
-
import type { DeliveryConfig, FailureAlertConfig } from '@amodalai/types';
|
|
8
|
-
/**
|
|
9
|
-
* Parsed automation config ready for the proactive runner.
|
|
10
|
-
*/
|
|
11
|
-
export interface RunnableAutomation {
|
|
12
|
-
name: string;
|
|
13
|
-
title: string;
|
|
14
|
-
prompt: string;
|
|
15
|
-
schedule?: string;
|
|
16
|
-
isWebhookTriggered: boolean;
|
|
17
|
-
delivery?: DeliveryConfig;
|
|
18
|
-
failureAlert?: FailureAlertConfig;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Convert a LoadedAutomation into a runnable config.
|
|
22
|
-
*
|
|
23
|
-
* Resolves `env:NAME` references in delivery webhook URLs at bundle-load
|
|
24
|
-
* time via `resolveEnvValue` (which throws RepoError if the env var is
|
|
25
|
-
* missing). Failing fast at startup is deliberate — an operator who
|
|
26
|
-
* misconfigured their SLACK_WEBHOOK_URL should learn at server boot, not
|
|
27
|
-
* the first time an automation tries to deliver.
|
|
28
|
-
*/
|
|
29
|
-
export declare function bridgeAutomation(automation: LoadedAutomation): RunnableAutomation;
|
|
30
|
-
/**
|
|
31
|
-
* Bridge all automations from a repo.
|
|
32
|
-
*/
|
|
33
|
-
export declare function bridgeAutomations(automations: LoadedAutomation[]): RunnableAutomation[];
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Amodal Labs, Inc.
|
|
4
|
-
* SPDX-License-Identifier: MIT
|
|
5
|
-
*/
|
|
6
|
-
import { resolveEnvValue } from '@amodalai/core';
|
|
7
|
-
/**
|
|
8
|
-
* Convert a LoadedAutomation into a runnable config.
|
|
9
|
-
*
|
|
10
|
-
* Resolves `env:NAME` references in delivery webhook URLs at bundle-load
|
|
11
|
-
* time via `resolveEnvValue` (which throws RepoError if the env var is
|
|
12
|
-
* missing). Failing fast at startup is deliberate — an operator who
|
|
13
|
-
* misconfigured their SLACK_WEBHOOK_URL should learn at server boot, not
|
|
14
|
-
* the first time an automation tries to deliver.
|
|
15
|
-
*/
|
|
16
|
-
export function bridgeAutomation(automation) {
|
|
17
|
-
return {
|
|
18
|
-
name: automation.name,
|
|
19
|
-
title: automation.title,
|
|
20
|
-
prompt: automation.prompt,
|
|
21
|
-
schedule: automation.schedule,
|
|
22
|
-
isWebhookTriggered: automation.trigger === 'webhook',
|
|
23
|
-
delivery: automation.delivery ? resolveDeliveryEnvRefs(automation.delivery) : undefined,
|
|
24
|
-
failureAlert: automation.failureAlert
|
|
25
|
-
? {
|
|
26
|
-
...automation.failureAlert,
|
|
27
|
-
targets: automation.failureAlert.targets.map(resolveTargetEnvRefs),
|
|
28
|
-
}
|
|
29
|
-
: undefined,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function resolveDeliveryEnvRefs(delivery) {
|
|
33
|
-
return {
|
|
34
|
-
...delivery,
|
|
35
|
-
targets: delivery.targets.map(resolveTargetEnvRefs),
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function resolveTargetEnvRefs(target) {
|
|
39
|
-
if (target.type === 'webhook') {
|
|
40
|
-
return { ...target, url: resolveEnvValue(target.url) };
|
|
41
|
-
}
|
|
42
|
-
return target;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Bridge all automations from a repo.
|
|
46
|
-
*/
|
|
47
|
-
export function bridgeAutomations(automations) {
|
|
48
|
-
return automations.map(bridgeAutomation);
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=automation-bridge.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"automation-bridge.js","sourceRoot":"","sources":["../../../src/agent/automation-bridge.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAiB/C;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAA4B;IAC3D,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,kBAAkB,EAAE,UAAU,CAAC,OAAO,KAAK,SAAS;QACpD,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,sBAAsB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;QACvF,YAAY,EAAE,UAAU,CAAC,YAAY;YACnC,CAAC,CAAC;gBACE,GAAG,UAAU,CAAC,YAAY;gBAC1B,OAAO,EAAE,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;aACnE;YACH,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC;AAED,SAAS,sBAAsB,CAAC,QAAwB;IACtD,OAAO;QACL,GAAG,QAAQ;QACX,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;KACpD,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAsB;IAClD,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,EAAC,GAAG,MAAM,EAAE,GAAG,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,EAAC,CAAC;IACvD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAA+B;IAC/D,OAAO,WAAW,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Amodal Labs, Inc.
|
|
4
|
-
* SPDX-License-Identifier: MIT
|
|
5
|
-
*/
|
|
6
|
-
import { describe, it, expect } from 'vitest';
|
|
7
|
-
import { bridgeAutomation, bridgeAutomations } from './automation-bridge.js';
|
|
8
|
-
function makeAutomation(overrides = {}) {
|
|
9
|
-
return {
|
|
10
|
-
name: 'test-auto',
|
|
11
|
-
title: 'Test Automation',
|
|
12
|
-
trigger: 'cron',
|
|
13
|
-
schedule: '0 9 * * 1-5',
|
|
14
|
-
prompt: 'Run the daily check',
|
|
15
|
-
location: '/test',
|
|
16
|
-
...overrides,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
describe('bridgeAutomation', () => {
|
|
20
|
-
it('converts a cron automation', () => {
|
|
21
|
-
const result = bridgeAutomation(makeAutomation());
|
|
22
|
-
expect(result.name).toBe('test-auto');
|
|
23
|
-
expect(result.title).toBe('Test Automation');
|
|
24
|
-
expect(result.prompt).toBe('Run the daily check');
|
|
25
|
-
expect(result.schedule).toBe('0 9 * * 1-5');
|
|
26
|
-
expect(result.isWebhookTriggered).toBe(false);
|
|
27
|
-
});
|
|
28
|
-
it('detects webhook trigger', () => {
|
|
29
|
-
const result = bridgeAutomation(makeAutomation({
|
|
30
|
-
trigger: 'webhook',
|
|
31
|
-
schedule: undefined,
|
|
32
|
-
}));
|
|
33
|
-
expect(result.isWebhookTriggered).toBe(true);
|
|
34
|
-
expect(result.schedule).toBeUndefined();
|
|
35
|
-
});
|
|
36
|
-
it('handles manual trigger', () => {
|
|
37
|
-
const result = bridgeAutomation(makeAutomation({
|
|
38
|
-
trigger: 'manual',
|
|
39
|
-
schedule: undefined,
|
|
40
|
-
}));
|
|
41
|
-
expect(result.isWebhookTriggered).toBe(false);
|
|
42
|
-
expect(result.schedule).toBeUndefined();
|
|
43
|
-
});
|
|
44
|
-
it('preserves the prompt', () => {
|
|
45
|
-
const prompt = 'Check revenue data from Stripe.\nCompare to baselines.\nPost to #revenue-alerts.';
|
|
46
|
-
const result = bridgeAutomation(makeAutomation({ prompt }));
|
|
47
|
-
expect(result.prompt).toBe(prompt);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
describe('bridgeAutomation env:NAME resolution', () => {
|
|
51
|
-
it('resolves env:NAME refs in delivery webhook URLs', () => {
|
|
52
|
-
process.env['TEST_WEBHOOK_URL'] = 'https://hooks.example.com/abc123';
|
|
53
|
-
try {
|
|
54
|
-
const result = bridgeAutomation(makeAutomation({
|
|
55
|
-
delivery: {
|
|
56
|
-
targets: [{ type: 'webhook', url: 'env:TEST_WEBHOOK_URL' }],
|
|
57
|
-
},
|
|
58
|
-
}));
|
|
59
|
-
expect(result.delivery?.targets[0]).toEqual({
|
|
60
|
-
type: 'webhook',
|
|
61
|
-
url: 'https://hooks.example.com/abc123',
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
finally {
|
|
65
|
-
delete process.env['TEST_WEBHOOK_URL'];
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
it('resolves env:NAME refs in failureAlert webhook URLs', () => {
|
|
69
|
-
process.env['TEST_ALERT_URL'] = 'https://alerts.example.com/oncall';
|
|
70
|
-
try {
|
|
71
|
-
const result = bridgeAutomation(makeAutomation({
|
|
72
|
-
failureAlert: {
|
|
73
|
-
targets: [{ type: 'webhook', url: 'env:TEST_ALERT_URL' }],
|
|
74
|
-
},
|
|
75
|
-
}));
|
|
76
|
-
expect(result.failureAlert?.targets[0]).toEqual({
|
|
77
|
-
type: 'webhook',
|
|
78
|
-
url: 'https://alerts.example.com/oncall',
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
finally {
|
|
82
|
-
delete process.env['TEST_ALERT_URL'];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
it('leaves callback targets unchanged', () => {
|
|
86
|
-
const result = bridgeAutomation(makeAutomation({
|
|
87
|
-
delivery: {
|
|
88
|
-
targets: [{ type: 'callback', name: 'my-handler' }],
|
|
89
|
-
},
|
|
90
|
-
}));
|
|
91
|
-
expect(result.delivery?.targets[0]).toEqual({ type: 'callback', name: 'my-handler' });
|
|
92
|
-
});
|
|
93
|
-
it('leaves literal http URLs unchanged', () => {
|
|
94
|
-
const result = bridgeAutomation(makeAutomation({
|
|
95
|
-
delivery: {
|
|
96
|
-
targets: [{ type: 'webhook', url: 'https://hooks.example.com/fixed' }],
|
|
97
|
-
},
|
|
98
|
-
}));
|
|
99
|
-
expect(result.delivery?.targets[0]).toEqual({
|
|
100
|
-
type: 'webhook',
|
|
101
|
-
url: 'https://hooks.example.com/fixed',
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
it('throws at bridge time if env var is missing (fail fast at boot)', () => {
|
|
105
|
-
delete process.env['NONEXISTENT_WEBHOOK'];
|
|
106
|
-
expect(() => bridgeAutomation(makeAutomation({
|
|
107
|
-
delivery: {
|
|
108
|
-
targets: [{ type: 'webhook', url: 'env:NONEXISTENT_WEBHOOK' }],
|
|
109
|
-
},
|
|
110
|
-
}))).toThrow(/NONEXISTENT_WEBHOOK/);
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
describe('bridgeAutomations', () => {
|
|
114
|
-
it('converts an array of automations', () => {
|
|
115
|
-
const automations = [
|
|
116
|
-
makeAutomation({ name: 'auto-1', trigger: 'cron' }),
|
|
117
|
-
makeAutomation({ name: 'auto-2', trigger: 'webhook', schedule: undefined }),
|
|
118
|
-
makeAutomation({ name: 'auto-3', trigger: 'manual', schedule: undefined }),
|
|
119
|
-
];
|
|
120
|
-
const results = bridgeAutomations(automations);
|
|
121
|
-
expect(results).toHaveLength(3);
|
|
122
|
-
expect(results[0].isWebhookTriggered).toBe(false);
|
|
123
|
-
expect(results[1].isWebhookTriggered).toBe(true);
|
|
124
|
-
expect(results[2].isWebhookTriggered).toBe(false);
|
|
125
|
-
});
|
|
126
|
-
it('returns empty array for empty input', () => {
|
|
127
|
-
expect(bridgeAutomations([])).toEqual([]);
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
//# sourceMappingURL=automation-bridge.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"automation-bridge.test.js","sourceRoot":"","sources":["../../../src/agent/automation-bridge.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAC,MAAM,QAAQ,CAAC;AAE5C,OAAO,EAAC,gBAAgB,EAAE,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AAE3E,SAAS,cAAc,CAAC,YAAuC,EAAE;IAC/D,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,iBAAiB;QACxB,OAAO,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AAkB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,MAAM,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2026 Amodal Labs, Inc.
|
|
4
|
-
* SPDX-License-Identifier: MIT
|
|
5
|
-
*/
|
|
6
|
-
interface EvalHistoryEntry {
|
|
7
|
-
runId: string;
|
|
8
|
-
passed: boolean;
|
|
9
|
-
durationMs: number;
|
|
10
|
-
queryCostMicros: number;
|
|
11
|
-
judgeCostMicros: number;
|
|
12
|
-
timestamp: string;
|
|
13
|
-
model: string;
|
|
14
|
-
assertions: Array<{
|
|
15
|
-
passed: boolean;
|
|
16
|
-
}>;
|
|
17
|
-
}
|
|
18
|
-
interface EvalRunSummary {
|
|
19
|
-
id: string;
|
|
20
|
-
model: {
|
|
21
|
-
provider: string;
|
|
22
|
-
model: string;
|
|
23
|
-
};
|
|
24
|
-
passRate: number;
|
|
25
|
-
totalPassed: number;
|
|
26
|
-
totalFailed: number;
|
|
27
|
-
totalDurationMs: number;
|
|
28
|
-
totalCostMicros: number;
|
|
29
|
-
totalCostNoCacheMicros?: number;
|
|
30
|
-
label?: string;
|
|
31
|
-
gitSha?: string;
|
|
32
|
-
triggeredBy: string;
|
|
33
|
-
createdAt: string;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Persists eval run results to disk.
|
|
37
|
-
* Runs are stored as JSON files in .amodal/evals/ under the repo root.
|
|
38
|
-
*/
|
|
39
|
-
export declare class EvalStore {
|
|
40
|
-
private readonly dir;
|
|
41
|
-
constructor(repoPath: string);
|
|
42
|
-
private ensureDir;
|
|
43
|
-
private resolvePath;
|
|
44
|
-
save(run: Record<string, unknown>): void;
|
|
45
|
-
load(id: string): Record<string, unknown> | null;
|
|
46
|
-
list(): EvalRunSummary[];
|
|
47
|
-
listByEval(evalName: string): EvalHistoryEntry[];
|
|
48
|
-
delete(id: string): boolean;
|
|
49
|
-
}
|
|
50
|
-
export {};
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2026 Amodal Labs, Inc.
|
|
4
|
-
* SPDX-License-Identifier: MIT
|
|
5
|
-
*/
|
|
6
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
7
|
-
import { join, resolve } from 'node:path';
|
|
8
|
-
/**
|
|
9
|
-
* Persists eval run results to disk.
|
|
10
|
-
* Runs are stored as JSON files in .amodal/evals/ under the repo root.
|
|
11
|
-
*/
|
|
12
|
-
export class EvalStore {
|
|
13
|
-
dir;
|
|
14
|
-
constructor(repoPath) {
|
|
15
|
-
this.dir = join(repoPath, '.amodal', 'evals');
|
|
16
|
-
}
|
|
17
|
-
ensureDir() {
|
|
18
|
-
if (!existsSync(this.dir)) {
|
|
19
|
-
mkdirSync(this.dir, { recursive: true });
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
resolvePath(id) {
|
|
23
|
-
const trimmed = id.trim();
|
|
24
|
-
if (trimmed.length === 0 || trimmed.length > 128)
|
|
25
|
-
return null;
|
|
26
|
-
if (!/^[A-Za-z0-9_-]+$/.test(trimmed))
|
|
27
|
-
return null;
|
|
28
|
-
const resolved = resolve(this.dir, `${trimmed}.json`);
|
|
29
|
-
if (!resolved.startsWith(resolve(this.dir) + '/'))
|
|
30
|
-
return null;
|
|
31
|
-
return resolved;
|
|
32
|
-
}
|
|
33
|
-
save(run) {
|
|
34
|
-
const id = String(run['id'] ?? '');
|
|
35
|
-
const file = this.resolvePath(id);
|
|
36
|
-
if (!file)
|
|
37
|
-
return;
|
|
38
|
-
this.ensureDir();
|
|
39
|
-
writeFileSync(file, JSON.stringify(run, null, 2));
|
|
40
|
-
}
|
|
41
|
-
load(id) {
|
|
42
|
-
const file = this.resolvePath(id);
|
|
43
|
-
if (!file || !existsSync(file))
|
|
44
|
-
return null;
|
|
45
|
-
const raw = JSON.parse(readFileSync(file, 'utf-8'));
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Trusted local file
|
|
47
|
-
return raw;
|
|
48
|
-
}
|
|
49
|
-
list() {
|
|
50
|
-
if (!existsSync(this.dir))
|
|
51
|
-
return [];
|
|
52
|
-
const files = readdirSync(this.dir).filter((f) => f.endsWith('.json'));
|
|
53
|
-
const runs = [];
|
|
54
|
-
for (const file of files) {
|
|
55
|
-
try {
|
|
56
|
-
const raw = JSON.parse(readFileSync(join(this.dir, file), 'utf-8'));
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Trusted local file
|
|
58
|
-
const data = raw;
|
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Trusted local file
|
|
60
|
-
const model = (data['model'] ?? { provider: 'unknown', model: 'unknown' });
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Trusted local file
|
|
62
|
-
const suite = (data['suite'] ?? {});
|
|
63
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Trusted local file
|
|
64
|
-
const totalCost = (data['totalCost'] ?? {});
|
|
65
|
-
runs.push({
|
|
66
|
-
id: String(data['id'] ?? file.replace('.json', '')),
|
|
67
|
-
model,
|
|
68
|
-
passRate: Number(suite['totalPassed'] ?? 0) / Math.max(Number(suite['totalPassed'] ?? 0) + Number(suite['totalFailed'] ?? 0), 1),
|
|
69
|
-
totalPassed: Number(suite['totalPassed'] ?? 0),
|
|
70
|
-
totalFailed: Number(suite['totalFailed'] ?? 0),
|
|
71
|
-
totalDurationMs: Number(suite['totalDurationMs'] ?? 0),
|
|
72
|
-
totalCostMicros: Number(totalCost['estimatedCostMicros'] ?? 0),
|
|
73
|
-
...(totalCost['estimatedCostNoCacheMicros'] ? { totalCostNoCacheMicros: Number(totalCost['estimatedCostNoCacheMicros']) } : {}),
|
|
74
|
-
label: typeof data['label'] === 'string' ? data['label'] : undefined,
|
|
75
|
-
gitSha: typeof data['gitSha'] === 'string' ? data['gitSha'] : undefined,
|
|
76
|
-
triggeredBy: String(data['triggeredBy'] ?? 'manual'),
|
|
77
|
-
createdAt: String(data['createdAt'] ?? suite['timestamp'] ?? new Date().toISOString()),
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
catch {
|
|
81
|
-
// Skip corrupt files
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return runs.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
|
|
85
|
-
}
|
|
86
|
-
listByEval(evalName) {
|
|
87
|
-
if (!existsSync(this.dir))
|
|
88
|
-
return [];
|
|
89
|
-
const files = readdirSync(this.dir).filter((f) => f.endsWith('.json'));
|
|
90
|
-
const entries = [];
|
|
91
|
-
for (const file of files) {
|
|
92
|
-
try {
|
|
93
|
-
const raw = JSON.parse(readFileSync(join(this.dir, file), 'utf-8'));
|
|
94
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Trusted local file
|
|
95
|
-
const data = raw;
|
|
96
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Trusted local file
|
|
97
|
-
const suite = (data['suite'] ?? {});
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Trusted local file
|
|
99
|
-
const results = (suite['results'] ?? []);
|
|
100
|
-
for (const r of results) {
|
|
101
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Trusted local file
|
|
102
|
-
const ev = (r['eval'] ?? {});
|
|
103
|
-
if (String(ev['name'] ?? '') !== evalName)
|
|
104
|
-
continue;
|
|
105
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Trusted local file
|
|
106
|
-
const cost = (r['cost'] ?? {});
|
|
107
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Trusted local file
|
|
108
|
-
const modelInfo = (data['model'] ?? {});
|
|
109
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Trusted local file
|
|
110
|
-
const assertionResults = (r['assertions'] ?? []);
|
|
111
|
-
entries.push({
|
|
112
|
-
runId: String(data['id'] ?? file.replace('.json', '')),
|
|
113
|
-
passed: Boolean(r['passed']),
|
|
114
|
-
durationMs: Number(r['durationMs'] ?? 0),
|
|
115
|
-
queryCostMicros: Number(cost['estimatedCostMicros'] ?? 0),
|
|
116
|
-
judgeCostMicros: 0,
|
|
117
|
-
timestamp: String(suite['timestamp'] ?? data['createdAt'] ?? new Date().toISOString()),
|
|
118
|
-
model: String(modelInfo['model'] ?? 'unknown'),
|
|
119
|
-
assertions: assertionResults.map((a) => ({ passed: Boolean(a['passed']) })),
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
catch {
|
|
124
|
-
// Skip corrupt files
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return entries.sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime());
|
|
128
|
-
}
|
|
129
|
-
delete(id) {
|
|
130
|
-
const file = this.resolvePath(id);
|
|
131
|
-
if (!file || !existsSync(file))
|
|
132
|
-
return false;
|
|
133
|
-
unlinkSync(file);
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
//# sourceMappingURL=eval-store.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eval-store.js","sourceRoot":"","sources":["../../../src/agent/eval-store.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,E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M,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAC,CAAC,CAAC;qBAC1E,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,qBAAqB;YACvB,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IACnG,CAAC;IAED,MAAM,CAAC,EAAU;QACf,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,OAAO,KAAK,CAAC;QAC7C,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2026 Amodal Labs, Inc.
|
|
4
|
-
* SPDX-License-Identifier: MIT
|
|
5
|
-
*/
|
|
6
|
-
import type { DeliveryConfig, DeliveryPayload, FailureAlertConfig, RuntimeEventPayload } from '@amodalai/types';
|
|
7
|
-
import type { Logger } from '../../logger.js';
|
|
8
|
-
/**
|
|
9
|
-
* Invoked when a callback-type delivery target fires. The second argument
|
|
10
|
-
* carries target metadata (currently just `name`) so ISVs with multiple
|
|
11
|
-
* callback targets can distinguish which one is firing.
|
|
12
|
-
*/
|
|
13
|
-
export type AutomationResultCallback = (payload: DeliveryPayload, target: {
|
|
14
|
-
name?: string;
|
|
15
|
-
}) => void | Promise<void>;
|
|
16
|
-
interface DeliveryEventBus {
|
|
17
|
-
emit: (payload: RuntimeEventPayload) => unknown;
|
|
18
|
-
}
|
|
19
|
-
export interface DeliveryRouterOptions {
|
|
20
|
-
logger: Logger;
|
|
21
|
-
/** Shared HMAC secret for webhook signing. Optional. */
|
|
22
|
-
webhookSecret?: string;
|
|
23
|
-
/** ISV callback invoked when a target of type 'callback' fires. */
|
|
24
|
-
onResult?: AutomationResultCallback;
|
|
25
|
-
/** Optional event bus for emitting delivery_succeeded / delivery_failed events. */
|
|
26
|
-
eventBus?: DeliveryEventBus;
|
|
27
|
-
}
|
|
28
|
-
export declare class DeliveryRouter {
|
|
29
|
-
private readonly logger;
|
|
30
|
-
private readonly webhookSecret;
|
|
31
|
-
private readonly onResult;
|
|
32
|
-
private readonly eventBus;
|
|
33
|
-
private readonly failureState;
|
|
34
|
-
/** Templates we've already warned about (one log per template + missing-key combo). */
|
|
35
|
-
private readonly missingVarWarnings;
|
|
36
|
-
constructor(opts: DeliveryRouterOptions);
|
|
37
|
-
/**
|
|
38
|
-
* Record a successful automation run and dispatch the configured
|
|
39
|
-
* delivery (if any). Resets the failure counter for this automation.
|
|
40
|
-
*/
|
|
41
|
-
onSuccess(automationName: string, rawOutput: string, delivery: DeliveryConfig | undefined): Promise<void>;
|
|
42
|
-
/**
|
|
43
|
-
* Record a failed automation run. Increments the consecutive-failure
|
|
44
|
-
* counter. If it meets the `after` threshold and no recent alert has
|
|
45
|
-
* fired within the cooldown window, dispatches the failure alert.
|
|
46
|
-
*/
|
|
47
|
-
onFailure(automationName: string, error: string, failureAlert: FailureAlertConfig | undefined): Promise<void>;
|
|
48
|
-
/** For tests / observability. */
|
|
49
|
-
getFailureCount(automationName: string): number;
|
|
50
|
-
private dispatchTargets;
|
|
51
|
-
private dispatchTarget;
|
|
52
|
-
private emitDeliverySucceeded;
|
|
53
|
-
/**
|
|
54
|
-
* Deliver with one retry on 5xx / network errors. 4xx errors are not
|
|
55
|
-
* retried — they're client-side config bugs that won't fix themselves.
|
|
56
|
-
* Throws a `WebhookFailure` carrying the final status + attempt count.
|
|
57
|
-
*/
|
|
58
|
-
private deliverWebhookWithRetry;
|
|
59
|
-
private deliverWebhook;
|
|
60
|
-
/**
|
|
61
|
-
* Render a template, warning once per (automation, template, missing-keys)
|
|
62
|
-
* combo. Helps diagnose agent-output drift (e.g. agent stopped producing
|
|
63
|
-
* `{{count}}` in its JSON output and now every alert reads
|
|
64
|
-
* "Found {{count}} new articles").
|
|
65
|
-
*/
|
|
66
|
-
private renderTemplateWithWarnings;
|
|
67
|
-
}
|
|
68
|
-
export {};
|