@startsimpli/integrations 0.2.16 → 0.2.17
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/package.json +1 -1
- package/src/__tests__/corpus-llm-timeout.test.ts +91 -0
- package/src/__tests__/corpus-runs.test.ts +631 -0
- package/src/__tests__/corpus-tracker.test.tsx +254 -1
- package/src/components/pages/TrackerPage.tsx +326 -2
- package/src/corpus/client.ts +57 -1
- package/src/corpus/entities.ts +79 -0
- package/src/corpus/extract.ts +85 -8
- package/src/corpus/fixtures.ts +34 -0
- package/src/corpus/index.ts +29 -0
- package/src/corpus/llm.ts +32 -3
- package/src/corpus/runs.ts +563 -0
- package/src/corpus/types.ts +176 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startsimpli/integrations",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"description": "Provider-agnostic types, API clients, hooks, and UI primitives for email + calendar integrations across StartSimpli apps.",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE SECOND SIXTY-SECOND WALL (bd startsim-768w.38.28).
|
|
3
|
+
*
|
|
4
|
+
* The one everybody measured was the tenant gateway's. This is the other one:
|
|
5
|
+
* the provider client in `@startsimpli/llm` defaults to a 60,000ms
|
|
6
|
+
* AbortController, and against claude-sonnet-5 over the real tandem corpus one
|
|
7
|
+
* document takes 19.6 seconds while two (7,909 prompt characters) do not finish
|
|
8
|
+
* at all. Because the extract call is deliberately wrapped so a provider outage
|
|
9
|
+
* costs the extras and not the list, hitting it was SILENT — the run returned
|
|
10
|
+
* every rules-derived commitment and `fromModel: 0`, which reads exactly like
|
|
11
|
+
* "the model found nothing to add".
|
|
12
|
+
*
|
|
13
|
+
* Putting extraction on a job is what makes a longer deadline affordable:
|
|
14
|
+
* nothing is holding a socket open waiting for it. So the deadline has to be
|
|
15
|
+
* settable per call, and it has to actually reach the provider — an option that
|
|
16
|
+
* is accepted and dropped is worse than no option, because it looks fixed.
|
|
17
|
+
*/
|
|
18
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
19
|
+
|
|
20
|
+
import { createCorpusExtractor, createCorpusLlm } from '../corpus/llm';
|
|
21
|
+
|
|
22
|
+
function fakeService(content: string) {
|
|
23
|
+
return {
|
|
24
|
+
chat: vi.fn(async () => ({ content, model: 'claude-sonnet-5' })),
|
|
25
|
+
isAvailable: () => true,
|
|
26
|
+
getAvailableProviders: () => ['anthropic'],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
describe('a queued run can buy real time from the provider', () => {
|
|
31
|
+
it('passes the deadline the caller asked for through to the provider call', async () => {
|
|
32
|
+
const service = fakeService('{"items":[],"resolutions":[]}');
|
|
33
|
+
const extractor = createCorpusExtractor({
|
|
34
|
+
service: service as never,
|
|
35
|
+
timeoutMs: 240_000,
|
|
36
|
+
env: {},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
await extractor.extract({ documents: [] });
|
|
40
|
+
|
|
41
|
+
expect(service.chat).toHaveBeenCalledTimes(1);
|
|
42
|
+
expect(service.chat.mock.calls[0][2]).toEqual({ timeout: 240_000 });
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('carries the deadline into the JSON-repair retry too', async () => {
|
|
46
|
+
// The repair is a correction of the SAME request, so it has the same amount
|
|
47
|
+
// of work to do. Sending it with the default deadline would make the retry
|
|
48
|
+
// fail for a reason the first attempt did not.
|
|
49
|
+
const service = fakeService('not json at all');
|
|
50
|
+
const extractor = createCorpusExtractor({
|
|
51
|
+
service: service as never,
|
|
52
|
+
timeoutMs: 240_000,
|
|
53
|
+
env: {},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
await extractor.extract({ documents: [] });
|
|
57
|
+
|
|
58
|
+
expect(service.chat).toHaveBeenCalledTimes(2);
|
|
59
|
+
expect(service.chat.mock.calls[1][2]).toEqual({ timeout: 240_000 });
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('falls back to the deployment-wide LLM_TIMEOUT_MS when no call sets one', async () => {
|
|
63
|
+
const service = fakeService('{"items":[],"resolutions":[]}');
|
|
64
|
+
const extractor = createCorpusExtractor({
|
|
65
|
+
service: service as never,
|
|
66
|
+
env: { LLM_TIMEOUT_MS: '120000' },
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
await extractor.extract({ documents: [] });
|
|
70
|
+
|
|
71
|
+
expect(service.chat.mock.calls[0][2]).toEqual({ timeout: 120_000 });
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('sends nothing at all when neither is set, so the provider default stands', async () => {
|
|
75
|
+
const service = fakeService('{"items":[],"resolutions":[]}');
|
|
76
|
+
const extractor = createCorpusExtractor({ service: service as never, env: {} });
|
|
77
|
+
|
|
78
|
+
await extractor.extract({ documents: [] });
|
|
79
|
+
|
|
80
|
+
expect(service.chat.mock.calls[0][2]).toBeUndefined();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('applies to the Ask adapter as well, which shares the seam', async () => {
|
|
84
|
+
const service = fakeService('{"answer":"x","citations":[]}');
|
|
85
|
+
const llm = createCorpusLlm({ service: service as never, timeoutMs: 90_000, env: {} });
|
|
86
|
+
|
|
87
|
+
await llm.answer({ mode: 'ask', question: 'x', documents: [] } as never);
|
|
88
|
+
|
|
89
|
+
expect(service.chat.mock.calls[0][2]).toEqual({ timeout: 90_000 });
|
|
90
|
+
});
|
|
91
|
+
});
|