vellum 0.2.12 → 0.2.14
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/README.md +32 -0
- package/bun.lock +2 -2
- package/docs/skills.md +4 -4
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/ipc-snapshot.test.ts.snap +213 -3
- package/src/__tests__/app-git-history.test.ts +176 -0
- package/src/__tests__/app-git-service.test.ts +169 -0
- package/src/__tests__/assistant-events-sse-hardening.test.ts +315 -0
- package/src/__tests__/browser-skill-baseline-tool-payload.test.ts +8 -8
- package/src/__tests__/browser-skill-endstate.test.ts +6 -6
- package/src/__tests__/call-bridge.test.ts +105 -13
- package/src/__tests__/call-domain.test.ts +163 -0
- package/src/__tests__/call-orchestrator.test.ts +171 -0
- package/src/__tests__/call-routes-http.test.ts +246 -6
- package/src/__tests__/channel-approval-routes.test.ts +438 -0
- package/src/__tests__/channel-approval.test.ts +266 -0
- package/src/__tests__/channel-approvals.test.ts +393 -0
- package/src/__tests__/channel-delivery-store.test.ts +447 -0
- package/src/__tests__/checker.test.ts +607 -1048
- package/src/__tests__/cli.test.ts +1 -56
- package/src/__tests__/config-schema.test.ts +402 -5
- package/src/__tests__/conflict-intent-tokenization.test.ts +141 -0
- package/src/__tests__/conflict-policy.test.ts +121 -0
- package/src/__tests__/conflict-store.test.ts +2 -0
- package/src/__tests__/contacts-tools.test.ts +3 -3
- package/src/__tests__/contradiction-checker.test.ts +99 -1
- package/src/__tests__/credential-security-invariants.test.ts +22 -6
- package/src/__tests__/credential-vault-unit.test.ts +780 -0
- package/src/__tests__/elevenlabs-client.test.ts +271 -0
- package/src/__tests__/ephemeral-permissions.test.ts +73 -23
- package/src/__tests__/filesystem-tools.test.ts +579 -0
- package/src/__tests__/gateway-only-enforcement.test.ts +114 -4
- package/src/__tests__/handlers-add-trust-rule-metadata.test.ts +202 -0
- package/src/__tests__/handlers-cu-observation-blob.test.ts +2 -1
- package/src/__tests__/handlers-ipc-blob-probe.test.ts +2 -1
- package/src/__tests__/handlers-slack-config.test.ts +2 -1
- package/src/__tests__/handlers-telegram-config.test.ts +855 -0
- package/src/__tests__/handlers-twitter-config.test.ts +141 -1
- package/src/__tests__/hooks-runner.test.ts +6 -2
- package/src/__tests__/host-file-edit-tool.test.ts +124 -0
- package/src/__tests__/host-file-read-tool.test.ts +62 -0
- package/src/__tests__/host-file-write-tool.test.ts +59 -0
- package/src/__tests__/host-shell-tool.test.ts +251 -0
- package/src/__tests__/ingress-reconcile.test.ts +581 -0
- package/src/__tests__/ipc-snapshot.test.ts +100 -41
- package/src/__tests__/ipc-validate.test.ts +50 -0
- package/src/__tests__/key-migration.test.ts +23 -0
- package/src/__tests__/memory-regressions.test.ts +99 -0
- package/src/__tests__/memory-retrieval.benchmark.test.ts +1 -1
- package/src/__tests__/oauth-callback-registry.test.ts +11 -4
- package/src/__tests__/playbook-execution.test.ts +502 -0
- package/src/__tests__/playbook-tools.test.ts +4 -6
- package/src/__tests__/public-ingress-urls.test.ts +34 -0
- package/src/__tests__/qdrant-manager.test.ts +267 -0
- package/src/__tests__/recurrence-engine-rruleset.test.ts +97 -0
- package/src/__tests__/recurrence-engine.test.ts +9 -0
- package/src/__tests__/recurrence-types.test.ts +8 -0
- package/src/__tests__/registry.test.ts +1 -1
- package/src/__tests__/runtime-runs.test.ts +1 -25
- package/src/__tests__/schedule-store.test.ts +16 -14
- package/src/__tests__/schedule-tools.test.ts +83 -0
- package/src/__tests__/scheduler-recurrence.test.ts +111 -10
- package/src/__tests__/secret-allowlist.test.ts +18 -17
- package/src/__tests__/secret-ingress-handler.test.ts +11 -0
- package/src/__tests__/secret-scanner.test.ts +43 -0
- package/src/__tests__/session-conflict-gate.test.ts +442 -6
- package/src/__tests__/session-init.benchmark.test.ts +3 -0
- package/src/__tests__/session-process-bridge.test.ts +242 -0
- package/src/__tests__/session-skill-tools.test.ts +1 -1
- package/src/__tests__/shell-identity.test.ts +256 -0
- package/src/__tests__/skill-projection.benchmark.test.ts +11 -1
- package/src/__tests__/subagent-tools.test.ts +637 -54
- package/src/__tests__/task-management-tools.test.ts +936 -0
- package/src/__tests__/task-runner.test.ts +2 -2
- package/src/__tests__/terminal-tools.test.ts +840 -0
- package/src/__tests__/tool-executor-shell-integration.test.ts +301 -0
- package/src/__tests__/tool-executor.test.ts +85 -151
- package/src/__tests__/tool-permission-simulate-handler.test.ts +336 -0
- package/src/__tests__/trust-store.test.ts +28 -453
- package/src/__tests__/twilio-provider.test.ts +153 -3
- package/src/__tests__/twilio-routes-elevenlabs.test.ts +375 -0
- package/src/__tests__/twilio-routes-twiml.test.ts +127 -0
- package/src/__tests__/twilio-routes.test.ts +17 -262
- package/src/__tests__/twitter-auth-handler.test.ts +2 -1
- package/src/__tests__/twitter-cli-error-shaping.test.ts +208 -0
- package/src/__tests__/twitter-cli-routing.test.ts +252 -0
- package/src/__tests__/twitter-oauth-client.test.ts +209 -0
- package/src/__tests__/workspace-policy.test.ts +213 -0
- package/src/calls/call-bridge.ts +92 -19
- package/src/calls/call-domain.ts +157 -5
- package/src/calls/call-orchestrator.ts +96 -8
- package/src/calls/call-store.ts +6 -0
- package/src/calls/elevenlabs-client.ts +97 -0
- package/src/calls/elevenlabs-config.ts +31 -0
- package/src/calls/twilio-provider.ts +91 -0
- package/src/calls/twilio-routes.ts +50 -6
- package/src/calls/types.ts +3 -1
- package/src/calls/voice-quality.ts +114 -0
- package/src/cli/twitter.ts +200 -21
- package/src/cli.ts +1 -20
- package/src/config/bundled-skills/contacts/tools/contact-merge.ts +52 -4
- package/src/config/bundled-skills/contacts/tools/contact-search.ts +55 -4
- package/src/config/bundled-skills/contacts/tools/contact-upsert.ts +61 -4
- package/src/config/bundled-skills/messaging/SKILL.md +17 -2
- package/src/config/bundled-skills/messaging/tools/messaging-reply.ts +4 -1
- package/src/config/bundled-skills/messaging/tools/messaging-send.ts +5 -1
- package/src/config/bundled-skills/messaging/tools/shared.ts +5 -0
- package/src/config/bundled-skills/phone-calls/SKILL.md +207 -19
- package/src/config/bundled-skills/playbooks/tools/playbook-create.ts +95 -6
- package/src/config/bundled-skills/playbooks/tools/playbook-delete.ts +51 -6
- package/src/config/bundled-skills/playbooks/tools/playbook-list.ts +73 -6
- package/src/config/bundled-skills/playbooks/tools/playbook-update.ts +110 -6
- package/src/config/bundled-skills/public-ingress/SKILL.md +22 -5
- package/src/config/bundled-skills/twitter/SKILL.md +103 -17
- package/src/config/defaults.ts +26 -2
- package/src/config/schema.ts +178 -9
- package/src/config/types.ts +3 -0
- package/src/config/vellum-skills/telegram-setup/SKILL.md +56 -61
- package/src/daemon/assistant-attachments.ts +4 -2
- package/src/daemon/handlers/apps.ts +69 -0
- package/src/daemon/handlers/config.ts +543 -24
- package/src/daemon/handlers/index.ts +1 -0
- package/src/daemon/handlers/sessions.ts +22 -6
- package/src/daemon/handlers/shared.ts +2 -1
- package/src/daemon/handlers/skills.ts +5 -20
- package/src/daemon/ipc-contract-inventory.json +28 -0
- package/src/daemon/ipc-contract.ts +168 -10
- package/src/daemon/ipc-validate.ts +17 -0
- package/src/daemon/lifecycle.ts +2 -0
- package/src/daemon/server.ts +78 -72
- package/src/daemon/session-attachments.ts +1 -1
- package/src/daemon/session-conflict-gate.ts +62 -6
- package/src/daemon/session-notifiers.ts +1 -1
- package/src/daemon/session-process.ts +62 -3
- package/src/daemon/session-tool-setup.ts +1 -2
- package/src/daemon/tls-certs.ts +189 -0
- package/src/daemon/video-thumbnail.ts +5 -3
- package/src/hooks/manager.ts +5 -9
- package/src/memory/app-git-service.ts +295 -0
- package/src/memory/app-store.ts +21 -0
- package/src/memory/conflict-intent.ts +47 -4
- package/src/memory/conflict-policy.ts +73 -0
- package/src/memory/conflict-store.ts +9 -1
- package/src/memory/contradiction-checker.ts +28 -0
- package/src/memory/conversation-key-store.ts +15 -0
- package/src/memory/db.ts +81 -0
- package/src/memory/embedding-local.ts +3 -13
- package/src/memory/external-conversation-store.ts +234 -0
- package/src/memory/job-handlers/conflict.ts +22 -2
- package/src/memory/jobs-worker.ts +67 -28
- package/src/memory/runs-store.ts +54 -7
- package/src/memory/schema.ts +20 -0
- package/src/messaging/provider.ts +9 -0
- package/src/messaging/providers/telegram-bot/adapter.ts +162 -0
- package/src/messaging/providers/telegram-bot/client.ts +104 -0
- package/src/messaging/providers/telegram-bot/types.ts +15 -0
- package/src/messaging/registry.ts +1 -0
- package/src/permissions/checker.ts +48 -44
- package/src/permissions/defaults.ts +11 -0
- package/src/permissions/prompter.ts +0 -4
- package/src/permissions/shell-identity.ts +227 -0
- package/src/permissions/trust-store.ts +76 -53
- package/src/permissions/types.ts +0 -19
- package/src/permissions/workspace-policy.ts +114 -0
- package/src/providers/retry.ts +12 -37
- package/src/runtime/assistant-event-hub.ts +41 -4
- package/src/runtime/channel-approval-parser.ts +60 -0
- package/src/runtime/channel-approval-types.ts +71 -0
- package/src/runtime/channel-approvals.ts +145 -0
- package/src/runtime/gateway-client.ts +16 -0
- package/src/runtime/http-server.ts +29 -9
- package/src/runtime/routes/call-routes.ts +52 -2
- package/src/runtime/routes/channel-routes.ts +296 -16
- package/src/runtime/routes/conversation-routes.ts +12 -5
- package/src/runtime/routes/events-routes.ts +97 -28
- package/src/runtime/routes/run-routes.ts +2 -7
- package/src/runtime/run-orchestrator.ts +0 -3
- package/src/schedule/recurrence-engine.ts +26 -2
- package/src/schedule/recurrence-types.ts +1 -1
- package/src/schedule/schedule-store.ts +12 -3
- package/src/security/secret-scanner.ts +7 -0
- package/src/tasks/ephemeral-permissions.ts +0 -2
- package/src/tasks/task-scheduler.ts +2 -1
- package/src/tools/calls/call-start.ts +8 -0
- package/src/tools/execution-target.ts +21 -0
- package/src/tools/execution-timeout.ts +49 -0
- package/src/tools/executor.ts +6 -135
- package/src/tools/network/web-search.ts +9 -32
- package/src/tools/policy-context.ts +29 -0
- package/src/tools/schedule/update.ts +8 -1
- package/src/tools/terminal/parser.ts +16 -18
- package/src/tools/types.ts +4 -11
- package/src/twitter/oauth-client.ts +102 -0
- package/src/twitter/router.ts +101 -0
- package/src/util/debounce.ts +88 -0
- package/src/util/network-info.ts +47 -0
- package/src/util/platform.ts +29 -4
- package/src/util/promise-guard.ts +37 -0
- package/src/util/retry.ts +98 -0
- package/src/util/truncate.ts +1 -1
- package/src/workspace/git-service.ts +129 -112
- package/src/tools/contacts/contact-merge.ts +0 -55
- package/src/tools/contacts/contact-search.ts +0 -58
- package/src/tools/contacts/contact-upsert.ts +0 -64
- package/src/tools/playbooks/index.ts +0 -4
- package/src/tools/playbooks/playbook-create.ts +0 -96
- package/src/tools/playbooks/playbook-delete.ts +0 -52
- package/src/tools/playbooks/playbook-list.ts +0 -74
- package/src/tools/playbooks/playbook-update.ts +0 -111
|
@@ -31,6 +31,18 @@ mock.module('../util/logger.js', () => ({
|
|
|
31
31
|
}),
|
|
32
32
|
}));
|
|
33
33
|
|
|
34
|
+
const mockCallsConfig = {
|
|
35
|
+
enabled: true,
|
|
36
|
+
provider: 'twilio',
|
|
37
|
+
maxDurationSeconds: 3600,
|
|
38
|
+
userConsultTimeoutSeconds: 120,
|
|
39
|
+
disclosure: { enabled: false, text: '' },
|
|
40
|
+
safety: { denyCategories: [] },
|
|
41
|
+
callerIdentity: {
|
|
42
|
+
allowPerCallOverride: true,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
34
46
|
mock.module('../config/loader.js', () => ({
|
|
35
47
|
getConfig: () => ({
|
|
36
48
|
model: 'test',
|
|
@@ -39,13 +51,19 @@ mock.module('../config/loader.js', () => ({
|
|
|
39
51
|
memory: { enabled: false },
|
|
40
52
|
rateLimit: { maxRequestsPerMinute: 0, maxTokensPerSession: 0 },
|
|
41
53
|
secretDetection: { enabled: false },
|
|
42
|
-
calls:
|
|
54
|
+
calls: mockCallsConfig,
|
|
55
|
+
}),
|
|
56
|
+
loadConfig: () => ({
|
|
57
|
+
model: 'test',
|
|
58
|
+
provider: 'test',
|
|
59
|
+
apiKeys: {},
|
|
60
|
+
memory: { enabled: false },
|
|
61
|
+
rateLimit: { maxRequestsPerMinute: 0, maxTokensPerSession: 0 },
|
|
62
|
+
secretDetection: { enabled: false },
|
|
63
|
+
calls: mockCallsConfig,
|
|
64
|
+
ingress: {
|
|
43
65
|
enabled: true,
|
|
44
|
-
|
|
45
|
-
maxDurationSeconds: 3600,
|
|
46
|
-
userConsultTimeoutSeconds: 120,
|
|
47
|
-
disclosure: { enabled: false, text: '' },
|
|
48
|
-
safety: { denyCategories: [] },
|
|
66
|
+
publicBaseUrl: 'https://test.example.com',
|
|
49
67
|
},
|
|
50
68
|
}),
|
|
51
69
|
}));
|
|
@@ -241,6 +259,88 @@ describe('runtime call routes — HTTP layer', () => {
|
|
|
241
259
|
await stopServer();
|
|
242
260
|
});
|
|
243
261
|
|
|
262
|
+
test('POST /v1/calls/start with callerIdentityMode user_number is accepted', async () => {
|
|
263
|
+
await startServer();
|
|
264
|
+
ensureConversation('conv-start-identity-1');
|
|
265
|
+
|
|
266
|
+
const res = await fetch(callsUrl('/start'), {
|
|
267
|
+
method: 'POST',
|
|
268
|
+
headers: { 'Content-Type': 'application/json', ...AUTH_HEADERS },
|
|
269
|
+
body: JSON.stringify({
|
|
270
|
+
phoneNumber: '+15559998888',
|
|
271
|
+
task: 'Book a table for two',
|
|
272
|
+
conversationId: 'conv-start-identity-1',
|
|
273
|
+
callerIdentityMode: 'user_number',
|
|
274
|
+
}),
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
// user_number mode requires a configured user phone number;
|
|
278
|
+
// since we haven't set one, this should return a 400 explaining why
|
|
279
|
+
expect(res.status).toBe(400);
|
|
280
|
+
const body = await res.json() as { error: string };
|
|
281
|
+
expect(body.error).toContain('user_number');
|
|
282
|
+
|
|
283
|
+
await stopServer();
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
test('POST /v1/calls/start without callerIdentityMode defaults to assistant_number', async () => {
|
|
287
|
+
await startServer();
|
|
288
|
+
ensureConversation('conv-start-identity-2');
|
|
289
|
+
|
|
290
|
+
const res = await fetch(callsUrl('/start'), {
|
|
291
|
+
method: 'POST',
|
|
292
|
+
headers: { 'Content-Type': 'application/json', ...AUTH_HEADERS },
|
|
293
|
+
body: JSON.stringify({
|
|
294
|
+
phoneNumber: '+15559998888',
|
|
295
|
+
task: 'Book a table for two',
|
|
296
|
+
conversationId: 'conv-start-identity-2',
|
|
297
|
+
}),
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
expect(res.status).toBe(201);
|
|
301
|
+
|
|
302
|
+
const body = await res.json() as {
|
|
303
|
+
callSessionId: string;
|
|
304
|
+
callSid: string;
|
|
305
|
+
status: string;
|
|
306
|
+
toNumber: string;
|
|
307
|
+
fromNumber: string;
|
|
308
|
+
callerIdentityMode: string;
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
expect(body.callSessionId).toBeDefined();
|
|
312
|
+
expect(body.callSid).toBe('CA_mock_sid_123');
|
|
313
|
+
expect(body.fromNumber).toBe('+15550001111');
|
|
314
|
+
expect(body.callerIdentityMode).toBe('assistant_number');
|
|
315
|
+
|
|
316
|
+
await stopServer();
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
test('POST /v1/calls/start returns 400 for invalid callerIdentityMode', async () => {
|
|
320
|
+
await startServer();
|
|
321
|
+
ensureConversation('conv-start-identity-bogus');
|
|
322
|
+
|
|
323
|
+
const res = await fetch(callsUrl('/start'), {
|
|
324
|
+
method: 'POST',
|
|
325
|
+
headers: { 'Content-Type': 'application/json', ...AUTH_HEADERS },
|
|
326
|
+
body: JSON.stringify({
|
|
327
|
+
phoneNumber: '+15559998888',
|
|
328
|
+
task: 'Book a table for two',
|
|
329
|
+
conversationId: 'conv-start-identity-bogus',
|
|
330
|
+
callerIdentityMode: 'bogus',
|
|
331
|
+
}),
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
expect(res.status).toBe(400);
|
|
335
|
+
const body = await res.json() as { error: string };
|
|
336
|
+
expect(body.error).toContain('Invalid callerIdentityMode');
|
|
337
|
+
expect(body.error).toContain('bogus');
|
|
338
|
+
expect(body.error).toContain('assistant_number');
|
|
339
|
+
expect(body.error).toContain('user_number');
|
|
340
|
+
|
|
341
|
+
await stopServer();
|
|
342
|
+
});
|
|
343
|
+
|
|
244
344
|
// ── GET /v1/calls/:id ───────────────────────────────────────────────
|
|
245
345
|
|
|
246
346
|
test('GET /v1/calls/:id returns call status', async () => {
|
|
@@ -456,4 +556,144 @@ describe('runtime call routes — HTTP layer', () => {
|
|
|
456
556
|
|
|
457
557
|
await stopServer();
|
|
458
558
|
});
|
|
559
|
+
|
|
560
|
+
// ── POST /v1/calls/:id/instruction ────────────────────────────────
|
|
561
|
+
|
|
562
|
+
test('POST /v1/calls/:id/instruction returns 400 for malformed JSON', async () => {
|
|
563
|
+
await startServer();
|
|
564
|
+
ensureConversation('conv-instr-badjson');
|
|
565
|
+
|
|
566
|
+
const session = createCallSession({
|
|
567
|
+
conversationId: 'conv-instr-badjson',
|
|
568
|
+
provider: 'twilio',
|
|
569
|
+
fromNumber: '+15550001111',
|
|
570
|
+
toNumber: '+15559998888',
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
const res = await fetch(callsUrl(`/${session.id}/instruction`), {
|
|
574
|
+
method: 'POST',
|
|
575
|
+
headers: { 'Content-Type': 'application/json', ...AUTH_HEADERS },
|
|
576
|
+
body: 'not-json{{',
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
expect(res.status).toBe(400);
|
|
580
|
+
const body = await res.json() as { error: string };
|
|
581
|
+
expect(body.error).toContain('Invalid JSON');
|
|
582
|
+
|
|
583
|
+
await stopServer();
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
test('POST /v1/calls/:id/instruction returns 400 when instruction is empty', async () => {
|
|
587
|
+
await startServer();
|
|
588
|
+
ensureConversation('conv-instr-empty');
|
|
589
|
+
|
|
590
|
+
const session = createCallSession({
|
|
591
|
+
conversationId: 'conv-instr-empty',
|
|
592
|
+
provider: 'twilio',
|
|
593
|
+
fromNumber: '+15550001111',
|
|
594
|
+
toNumber: '+15559998888',
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
const res = await fetch(callsUrl(`/${session.id}/instruction`), {
|
|
598
|
+
method: 'POST',
|
|
599
|
+
headers: { 'Content-Type': 'application/json', ...AUTH_HEADERS },
|
|
600
|
+
body: JSON.stringify({ instruction: '' }),
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
expect(res.status).toBe(400);
|
|
604
|
+
const body = await res.json() as { error: string };
|
|
605
|
+
expect(body.error).toContain('instructionText');
|
|
606
|
+
|
|
607
|
+
await stopServer();
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
test('POST /v1/calls/:id/instruction returns 400 when instruction field is missing', async () => {
|
|
611
|
+
await startServer();
|
|
612
|
+
ensureConversation('conv-instr-missing');
|
|
613
|
+
|
|
614
|
+
const session = createCallSession({
|
|
615
|
+
conversationId: 'conv-instr-missing',
|
|
616
|
+
provider: 'twilio',
|
|
617
|
+
fromNumber: '+15550001111',
|
|
618
|
+
toNumber: '+15559998888',
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
const res = await fetch(callsUrl(`/${session.id}/instruction`), {
|
|
622
|
+
method: 'POST',
|
|
623
|
+
headers: { 'Content-Type': 'application/json', ...AUTH_HEADERS },
|
|
624
|
+
body: JSON.stringify({}),
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
expect(res.status).toBe(400);
|
|
628
|
+
const body = await res.json() as { error: string };
|
|
629
|
+
expect(body.error).toContain('instructionText');
|
|
630
|
+
|
|
631
|
+
await stopServer();
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
test('POST /v1/calls/:id/instruction returns 404 for unknown session', async () => {
|
|
635
|
+
await startServer();
|
|
636
|
+
|
|
637
|
+
const res = await fetch(callsUrl('/nonexistent-id/instruction'), {
|
|
638
|
+
method: 'POST',
|
|
639
|
+
headers: { 'Content-Type': 'application/json', ...AUTH_HEADERS },
|
|
640
|
+
body: JSON.stringify({ instruction: 'Speed things up' }),
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
expect(res.status).toBe(404);
|
|
644
|
+
const body = await res.json() as { error: string };
|
|
645
|
+
expect(body.error).toContain('No call session found');
|
|
646
|
+
|
|
647
|
+
await stopServer();
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
test('POST /v1/calls/:id/instruction returns 409 for ended call', async () => {
|
|
651
|
+
await startServer();
|
|
652
|
+
ensureConversation('conv-instr-ended');
|
|
653
|
+
|
|
654
|
+
const session = createCallSession({
|
|
655
|
+
conversationId: 'conv-instr-ended',
|
|
656
|
+
provider: 'twilio',
|
|
657
|
+
fromNumber: '+15550001111',
|
|
658
|
+
toNumber: '+15559998888',
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
updateCallSession(session.id, { status: 'completed', endedAt: Date.now() });
|
|
662
|
+
|
|
663
|
+
const res = await fetch(callsUrl(`/${session.id}/instruction`), {
|
|
664
|
+
method: 'POST',
|
|
665
|
+
headers: { 'Content-Type': 'application/json', ...AUTH_HEADERS },
|
|
666
|
+
body: JSON.stringify({ instruction: 'Speed things up' }),
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
expect(res.status).toBe(409);
|
|
670
|
+
const body = await res.json() as { error: string };
|
|
671
|
+
expect(body.error).toContain('not active');
|
|
672
|
+
|
|
673
|
+
await stopServer();
|
|
674
|
+
});
|
|
675
|
+
|
|
676
|
+
test('POST /v1/calls/:id/instruction returns 409 when no orchestrator', async () => {
|
|
677
|
+
await startServer();
|
|
678
|
+
ensureConversation('conv-instr-no-orch');
|
|
679
|
+
|
|
680
|
+
const session = createCallSession({
|
|
681
|
+
conversationId: 'conv-instr-no-orch',
|
|
682
|
+
provider: 'twilio',
|
|
683
|
+
fromNumber: '+15550001111',
|
|
684
|
+
toNumber: '+15559998888',
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
const res = await fetch(callsUrl(`/${session.id}/instruction`), {
|
|
688
|
+
method: 'POST',
|
|
689
|
+
headers: { 'Content-Type': 'application/json', ...AUTH_HEADERS },
|
|
690
|
+
body: JSON.stringify({ instruction: 'Speed things up' }),
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
expect(res.status).toBe(409);
|
|
694
|
+
const body = await res.json() as { error: string };
|
|
695
|
+
expect(body.error).toContain('orchestrator');
|
|
696
|
+
|
|
697
|
+
await stopServer();
|
|
698
|
+
});
|
|
459
699
|
});
|